Initial add parent_ast to scopes

This commit is contained in:
Krzosa Karol
2023-04-21 11:38:00 +02:00
parent 29238b6cc5
commit 2578a2a31a
3 changed files with 16 additions and 27 deletions

View File

@@ -116,6 +116,7 @@ ast_lambda(Token *pos, Array<Ast_Decl *> params, Array<Ast_Expr *> ret, Ast_Scop
result->args = params.tight_copy(pctx->perm);
result->ret = ret.tight_copy(pctx->perm);
result->scope = scope;
scope->parent_ast = result;
For(params) {
if (is_flag_set(it->flags, AST_POLYMORPH)) {
@@ -141,6 +142,7 @@ ast_for(Token *pos, Ast_Expr *init, Ast_Expr *cond, Ast_Expr *iter, Ast_Scope *s
result->cond = cond;
result->iter = iter;
result->scope = scope;
scope->parent_ast = result;
return result;
}
@@ -178,6 +180,7 @@ ast_if_node(Token *pos, Ast_Expr *init, Ast_Expr *expr, Ast_Scope *scope) {
result->scope = scope;
result->expr = expr;
result->init = (Ast_Binary *)init;
scope->parent_ast = result;
if (result->init) {
assert(init->kind == AST_VAR);
}
@@ -233,6 +236,7 @@ ast_struct(Token *pos, Ast_Scope *scope, Ast_Kind kind, Array<Ast_Decl *> polymo
AST_NEW(Decl, STRUCT, pos, AST_DECL | AST_AGGREGATE);
result->kind = kind;
result->scope = scope;
scope->parent_decl = result;
if (polymorph_parameters.len) {
result->polymorph_parameters = polymorph_parameters;
set_flag(result->flags, AST_POLYMORPH);
@@ -246,6 +250,7 @@ ast_enum(Token *pos, Ast_Expr *typespec, Ast_Scope *scope) {
AST_NEW(Decl, ENUM, pos, AST_DECL);
result->scope = scope;
result->typespec = typespec;
scope->parent_decl = result;
set_flag_typespec(typespec);
return result;
}