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

@@ -53,15 +53,15 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope, Array<Ast_Decl *> *replace, Arr
Ast_Atom *src = (Ast_Atom *)ast;
Ast_Atom *dst = ast_create_copy(parent_scope, Ast_Atom, ast);
if ((dst->flags & AST_TYPESPEC)) {
if (replace && with && (dst->flags & AST_TYPESPEC)) {
For(*replace) {
assert(it->type == pctx->type_type);
if (it->name == dst->intern_val) {
int it_index = replace->get_index(&it);
Ast_Call_Item *replacement = with[0][it_index];
Ast_Atom *replacement_v = (Ast_Atom *)replacement->item;
assert(replacement_v->resolved_type == pctx->type_type);
dst = ast_create_copy(parent_scope, Ast_Atom, replacement_v);
Ast *replacement_v = replacement->item;
// assert(replacement_v->resolved_type == pctx->type_type);
dst = (Ast_Atom *)ast_copy(replacement_v, parent_scope, 0, 0);
}
}
}
@@ -117,7 +117,7 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope, Array<Ast_Decl *> *replace, Arr
dst->name = (Ast_Expr *)ast_copy(src->name, parent_scope, replace, with);
dst->exprs.init(pctx->perm, src->exprs.len);
For(dst->exprs) {
For(src->exprs) {
auto copy = (Ast_Call_Item *)ast_copy(it, parent_scope, replace, with);
dst->exprs.add(copy);
}