From f834073264a5d7319a323ac678eaaa3ef8f4648d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 6 Jun 2024 16:36:49 -0400 Subject: Fix issue with importing modules --- environment.h | 1 - typecheck.c | 17 +---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/environment.h b/environment.h index 0582dfc0..f2229df8 100644 --- a/environment.h +++ b/environment.h @@ -12,7 +12,6 @@ typedef struct { CORD staticdefs; CORD funcs; CORD typeinfos; - CORD object_files; } compilation_unit_t; typedef struct { 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) -- cgit v1.2.3