aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-30 14:30:56 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-30 14:30:56 -0400
commit46818674d3588dd15ebca5cb7be4afa8cd485cfe (patch)
tree1494ed66d14cce185a4b4317b047bba3b1f5119c
parent45f0051c50949744fd1a52313fbf48a944f49c10 (diff)
Use namespace prefix function when appropriate
-rw-r--r--src/compile.c4
-rw-r--r--src/environment.c2
-rw-r--r--src/tomo.c2
3 files changed, 4 insertions, 4 deletions
diff --git a/src/compile.c b/src/compile.c
index 93fe92cf..52c8a736 100644
--- a/src/compile.c
+++ b/src/compile.c
@@ -4485,7 +4485,7 @@ CORD compile_file(env_t *env, ast_t *ast)
env->code->lambdas, "\n",
env->code->staticdefs, "\n",
top_level_code,
- "public void _$", env->namespace->name, "$$initialize(void) {\n",
+ "public void ", namespace_prefix(env, env->namespace), "$initialize(void) {\n",
"static bool initialized = false;\n",
"if (initialized) return;\n",
"initialized = true;\n",
@@ -4721,7 +4721,7 @@ CORD compile_file_header(env_t *env, Path_t header_path, ast_t *ast)
visit_topologically(Match(ast, Block)->statements, (Closure_t){.fn=(void*)_make_typedefs, &info});
visit_topologically(Match(ast, Block)->statements, (Closure_t){.fn=(void*)_define_types_and_funcs, &info});
- header = CORD_all(header, "void _$", env->namespace->name, "$$initialize(void);\n");
+ header = CORD_all(header, "void ", namespace_prefix(env, env->namespace), "$initialize(void);\n");
return header;
}
diff --git a/src/environment.c b/src/environment.c
index 290ebe12..b950cf9e 100644
--- a/src/environment.c
+++ b/src/environment.c
@@ -531,7 +531,7 @@ env_t *global_env(bool source_mapping)
return env;
}
-CORD namespace_prefix(env_t *env, namespace_t *ns)
+CORD CONSTFUNC namespace_prefix(env_t *env, namespace_t *ns)
{
CORD prefix = CORD_EMPTY;
for (; ns; ns = ns->parent)
diff --git a/src/tomo.c b/src/tomo.c
index 287454ef..dd61891e 100644
--- a/src/tomo.c
+++ b/src/tomo.c
@@ -807,7 +807,7 @@ void transpile_code(env_t *base_env, Path_t path)
"int ", main_binding->code, "$parse_and_run(int argc, char *argv[]) {\n",
module_env->do_source_mapping ? "#line 1\n" : CORD_EMPTY,
"tomo_init();\n",
- "_$", module_env->namespace->name, "$$initialize();\n"
+ namespace_prefix(module_env, module_env->namespace), "$initialize();\n"
"\n",
compile_cli_arg_call(module_env, main_binding->code, main_binding->type),
"return 0;\n"