diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-04 13:48:26 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-04 13:48:26 -0400 |
| commit | d1b2e9f598fb8e4c0bb46fda3bc2b8e03ff1db55 (patch) | |
| tree | 59d0171be180af6350df93638c751431a0765a20 /compile.c | |
| parent | f605df823016b9de23325c0a9d950c542a4ba1d5 (diff) | |
Disallow 'use' statements that aren't top level
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1169,10 +1169,10 @@ CORD compile_statement(env_t *env, ast_t *ast) case Use: { auto use = Match(ast, Use); if (use->what == USE_LOCAL) { - CORD name = file_base_name(Match(ast, Use)->name); + CORD name = file_base_name(Match(ast, Use)->path); env->code->variable_initializers = CORD_all(env->code->variable_initializers, name, "$$initialize();\n"); } else if (use->what == USE_MODULE) { - const char *libname = file_base_name(use->name); + const char *libname = file_base_name(use->path); const char *files_filename = heap_strf("%s/lib%s.files", libname, libname); const char *resolved_path = resolve_path(files_filename, ast->file->filename, getenv("TOMO_IMPORT_PATH")); if (!resolved_path) @@ -1183,7 +1183,7 @@ CORD compile_statement(env_t *env, ast_t *ast) const char *line = get_line(files_f, i); line = GC_strndup(line, strcspn(line, "\r\n")); env->code->variable_initializers = CORD_all( - env->code->variable_initializers, use->name, "$", file_base_name(line), "$$initialize();\n"); + env->code->variable_initializers, use->path, "$", file_base_name(line), "$$initialize();\n"); } } return CORD_EMPTY; @@ -3262,11 +3262,11 @@ CORD compile_statement_imports(env_t *env, ast_t *ast) auto use = Match(ast, Use); switch (use->what) { case USE_MODULE: - return CORD_all("#include <tomo/lib", use->name, ".h>\n"); + return CORD_all("#include <tomo/lib", use->path, ".h>\n"); case USE_LOCAL: - return CORD_all("#include \"", use->name, ".h\"\n"); + return CORD_all("#include \"", use->path, ".h\"\n"); case USE_HEADER: - return CORD_all("#include ", use->name, "\n"); + return CORD_all("#include ", use->path, "\n"); default: return CORD_EMPTY; } |
