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