diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-06-06 16:36:49 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-06-06 16:36:49 -0400 |
| commit | f834073264a5d7319a323ac678eaaa3ef8f4648d (patch) | |
| tree | 89a3749a7502c06ca336edcba8c221b3fc4b227c /typecheck.c | |
| parent | 8c7d53008072dfda8b9d60be92fae1a8046fae5d (diff) | |
Fix issue with importing modules
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/typecheck.c b/typecheck.c index b448e74a..2c6c6a01 100644 --- a/typecheck.c +++ b/typecheck.c @@ -110,13 +110,6 @@ static env_t *load_module(env_t *env, ast_t *use_ast) if (module_env) return module_env; - module_env = new_compilation_unit(); - module_env->file_prefix = heap_strf("%s$", name); - module_env->scope_prefix = module_env->file_prefix; - Table$str_set(module_env->imports, name, module_env); - const char *my_name = heap_strn(CORD_to_const_char_star(env->file_prefix), CORD_len(env->file_prefix)-1); - Table$str_set(module_env->imports, my_name, env); - const char *resolved_path = resolve_path(use->raw_path, use_ast->file->filename, getenv("TOMO_IMPORT_PATH")); if (!resolved_path) code_err(use_ast, "No such file exists: \"%s\"", use->raw_path); @@ -126,15 +119,7 @@ static env_t *load_module(env_t *env, ast_t *use_ast) ast_t *ast = parse_file(f, NULL); if (!ast) errx(1, "Could not compile!"); - - for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) { - prebind_statement(module_env, stmt->ast); - } - for (ast_list_t *stmt = Match(ast, Block)->statements; stmt; stmt = stmt->next) { - bind_statement(module_env, stmt->ast); - } - Table$str_set(env->imports, name, module_env); - return module_env; + return load_module_env(env, ast); } void prebind_statement(env_t *env, ast_t *statement) |
