Polymorphs nested structs

This commit is contained in:
Krzosa Karol
2023-04-01 14:31:41 +02:00
parent 2c19658115
commit 3d438645a0
7 changed files with 48 additions and 23 deletions

View File

@@ -223,6 +223,7 @@ ast_struct(Token *pos, Ast_Scope *scope, Ast_Kind kind, Array<Ast_Decl *> polymo
if (polymorph_parameters.len) {
result->polymorph_parameters = polymorph_parameters;
set_flag(result->flags, AST_POLYMORPH);
set_flag(result->flags, AST_PARENT_POLYMORPH);
result->polymorphs.allocator = pctx->heap;
}
return result;
@@ -631,6 +632,13 @@ set_flag_typespec(Ast_Expr *expr) {
}
}
CORE_Static void
unset_polymorph(Ast *ast) {
for (Ast_Iter iter = iterate_depth_first(pctx->heap, ast, true); iter.ast; next(&iter)) {
unset_flag(iter.ast->flags, AST_POLYMORPH);
}
}
CORE_Static bool
is_typespec_polymorphic(Ast *ast) {
for (Ast_Iter iter = iterate_depth_first(pctx->heap, ast, true); iter.ast; next(&iter)) {