Fix adding loads multiple times
This commit is contained in:
23
parsing.cpp
23
parsing.cpp
@@ -583,6 +583,20 @@ parse_enum(Token *pos){
|
||||
return result;
|
||||
}
|
||||
|
||||
function void
|
||||
add_implicit_import(Ast_Scope *scope, Ast_Scope *add){
|
||||
B32 found = false;
|
||||
For(scope->implicit_imports){
|
||||
if(it == add){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found){
|
||||
scope->implicit_imports.add(add);
|
||||
}
|
||||
}
|
||||
|
||||
function Ast_File *
|
||||
register_ast_file(Intern_String filename, Ast_Module *module, B32 global_implicit_load){
|
||||
Ast_File *file = 0;
|
||||
@@ -593,8 +607,8 @@ register_ast_file(Intern_String filename, Ast_Module *module, B32 global_implici
|
||||
}
|
||||
}
|
||||
if(!file){
|
||||
file = exp_alloc_type(pctx->perm, Ast_File, AF_ZeroMemory);
|
||||
file->kind = AST_FILE;
|
||||
AST_NEW(File, FILE, 0, 0);
|
||||
file = result;
|
||||
file->filename = filename;
|
||||
file->module = module;
|
||||
file->file = file; // @warning: self referential!
|
||||
@@ -604,8 +618,7 @@ register_ast_file(Intern_String filename, Ast_Module *module, B32 global_implici
|
||||
}
|
||||
|
||||
if(global_implicit_load) {
|
||||
file->global_implicit_load = true;
|
||||
module->implicit_imports.add(file);
|
||||
add_implicit_import(module, file);
|
||||
}
|
||||
|
||||
return file;
|
||||
@@ -624,7 +637,7 @@ parse_import(B32 global_implicit_import){
|
||||
Token *file = token_expect(TK_StringLit);
|
||||
Ast_Module *result = add_module(file->intern_val);
|
||||
if(global_implicit_import){
|
||||
pctx->currently_parsed_file->module->implicit_imports.add(result);
|
||||
add_implicit_import(pctx->currently_parsed_file->module, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user