Inline ast_module constructor

This commit is contained in:
Krzosa Karol
2022-06-27 10:11:12 +02:00
parent d8e5955010
commit 6644a2c5ae
2 changed files with 10 additions and 16 deletions

View File

@@ -794,8 +794,16 @@ add_module(Token *pos, Intern_String filename){
}
log_info("Adding module: %Q\n", filename);
Ast_Module *result = ast_module(pos, filename);
register_ast_file(pos, result->name, result, true);
Ast_Module *result = ast_new(Ast_Module, AST_MODULE, pos, 0);
result->name = filename;
result->module = result; // @warning: self referential
result->file = result; // @warning: self referential
result->all_loaded_files = {pctx->heap};
result->implicit_imports = {pctx->heap};
result->decls = {pctx->heap};
result->parent_scope = 0;
register_ast_file(pos, result->name, result, GLOBAL_IMPLICIT_LOAD);
pctx->modules.add(result);
return result;
}