Less heap more List
This commit is contained in:
@@ -230,7 +230,7 @@ How does current declaration order resolver works:
|
||||
|
||||
struct Ast_Scope: Ast{
|
||||
String debug_name; // Dont use
|
||||
Array<Ast_Scope *> implicit_imports;
|
||||
List<Ast_Scope *> implicit_imports;
|
||||
Array<Ast_Decl *> decls;
|
||||
Array<Ast *> stmts;
|
||||
|
||||
|
||||
@@ -165,8 +165,10 @@ parse_all_modules(){
|
||||
parse_file(*it.item);
|
||||
}
|
||||
|
||||
if(module != pctx->language_base_module)
|
||||
module->implicit_imports.add(pctx->language_base_module);
|
||||
if(module != pctx->language_base_module){
|
||||
add(pctx->perm, &module->implicit_imports, (Ast_Scope *)pctx->language_base_module);
|
||||
// module->implicit_imports.add(pctx->language_base_module);
|
||||
}
|
||||
|
||||
module->state = MODULE_PARSED;
|
||||
}
|
||||
@@ -223,7 +225,6 @@ add_module(Token *pos, Intern_String filename, B32 command_line_module){
|
||||
result->debug_name = string_skip_to_last_slash(result->absolute_file_path);
|
||||
result->module = result; // @warning: self referential
|
||||
result->file = result; // @warning: self referential
|
||||
result->implicit_imports = {pctx->heap};
|
||||
result->decls = {pctx->heap};
|
||||
result->parent_scope = 0;
|
||||
result->scope_id = pctx->scope_ids++;
|
||||
|
||||
@@ -707,16 +707,16 @@ parse_enum(Token *pos){
|
||||
}
|
||||
|
||||
function void
|
||||
add_implicit_import(Ast_Scope *scope, Ast_Scope *add){
|
||||
add_implicit_import(Ast_Scope *scope, Ast_Scope *to_add){
|
||||
B32 found = false;
|
||||
For(scope->implicit_imports){
|
||||
if(it == add){
|
||||
Iter(&scope->implicit_imports){
|
||||
if(it.item[0] == to_add){
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found){
|
||||
scope->implicit_imports.add(add);
|
||||
add(pctx->perm, &scope->implicit_imports, to_add);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -748,7 +748,6 @@ register_ast_file(Token *pos, String absolute_file_path, Ast_Module *module, B32
|
||||
file->parent_scope = 0;
|
||||
file->file = file; // @warning: self referential!
|
||||
file->decls = {pctx->heap};
|
||||
file->implicit_imports = {pctx->heap};
|
||||
file->pos = pos;
|
||||
file->debug_name = string_skip_to_last_slash(absolute_file_path);
|
||||
add(pctx->perm, &file->module->all_loaded_files, file);
|
||||
|
||||
@@ -778,8 +778,8 @@ inside_scope_search(Scope_Search *search, Ast_Scope *scope, int level){
|
||||
|
||||
// Search for declarations in imported implicitly scopes
|
||||
if(level < 2 || scope->kind != AST_FILE){
|
||||
For(scope->implicit_imports){
|
||||
inside_scope_search(search, it, level + 1);
|
||||
Iter(&scope->implicit_imports){
|
||||
inside_scope_search(search, it.item[0], level + 1);
|
||||
|
||||
if(search->exit_on_find && search->results.len){
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user