Change the decl searching api while figuring out how to implement

function overloading
This commit is contained in:
Krzosa Karol
2022-09-29 12:04:21 +02:00
parent a7524a0071
commit 5f11a11f0f
9 changed files with 113 additions and 53 deletions

View File

@@ -227,10 +227,12 @@ How does current declaration order resolver works:
*/
struct Ast_Scope: Ast{
String debug_name; // Dont use
Array<Ast_Scope *> implicit_imports;
Array<Ast_Decl *> decls;
Array<Ast *> stmts;
U32 visit_id;
U32 scope_id;
Ast_Scope *file; // Self referential for scope and module
Ast_Module *module;
@@ -264,7 +266,7 @@ enum Ast_Decl_State{
struct Ast_Decl: Ast{
Ast_Decl_State state;
Intern_String name;
Intern_String unique_name; // For code generation
Intern_String unique_name; // For code generation, currently only present on lambdas
Ast_Scope *scope;
Ast_Expr *typespec;
@@ -463,6 +465,7 @@ begin_decl_scope(Allocator *scratch, Token *pos){
result->file = pctx->currently_parsed_file;
result->module = pctx->currently_parsed_file->module;
result->scope_id = pctx->scope_ids++;
result->debug_name = pos->string;
assert(result->file);
pctx->currently_parsed_scope = result;
return result;
@@ -482,6 +485,7 @@ begin_stmt_scope(Allocator *scratch, Token *pos){
result->file = pctx->currently_parsed_file;
result->module = pctx->currently_parsed_file->module;
result->scope_id = pctx->scope_ids++;
result->debug_name = pos->string;
assert(result->file);
pctx->currently_parsed_scope = result;
return result;
@@ -547,6 +551,7 @@ ast_decl_scope(Token *pos, Allocator *allocator, Ast_File *file){
AST_NEW(Scope, SCOPE, pos, AST_DECL);
result->decls = {allocator};
result->file = file;
result->scope_id = pctx->scope_ids++;
assert(result->file);
return result;