We are generating basic polymorphic types!

This commit is contained in:
Krzosa Karol
2023-04-01 10:30:07 +02:00
parent db3790016d
commit b14979d754
4 changed files with 19 additions and 4 deletions

View File

@@ -41,8 +41,13 @@ Ast *ast_copy(Ast *ast, Ast_Scope *parent_scope, Array<Ast_Decl *> *replace, Arr
if ((dst->flags & AST_TYPESPEC)) {
For(*replace) {
assert(it->type == pctx->type_type);
if (it->name == dst->intern_val) {
Breakpoint;
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);
}
}
}
@@ -289,6 +294,9 @@ Ast_Decl *get_or_instantiate_polymorph_type(Token *pos, Ast_Decl *poly, Array<As
if (!result) {
result = (Ast_Decl *)ast_copy(poly, poly->parent_scope, &poly->polymorph_parameters, &params);
unset_flag(result->flags, AST_POLYMORPH);
result->type_val = type_incomplete(result);
result->polymorph_hash = hash;
poly->polymorphs.add(result);
}