Polymorphic procedure, with passed in compile time type but without removing the type in params etc.

This commit is contained in:
Krzosa Karol
2023-04-01 19:40:12 +02:00
parent 3d438645a0
commit 7bf3e107bb
8 changed files with 158 additions and 80 deletions

View File

@@ -306,16 +306,26 @@ Ast_Decl *get_or_instantiate_polymorph_type(Token *pos, Ast_Decl *poly, Array<As
}
}
if (poly->kind == AST_LAMBDA) Breakpoint;
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);
unset_flag(result->flags, AST_PARENT_POLYMORPH);
if (poly->kind == AST_STRUCT || poly->kind == AST_UNION) result->type_val = type_incomplete(result);
result->polymorph_hash = hash;
assert(result->di != poly->di);
result->name = get_unique_name_for_decl(result);
poly->polymorphs.allocator = pctx->heap;
poly->polymorphs.add(result);
}
resolve_decl(result);
if (poly->kind == AST_STRUCT || poly->kind == AST_UNION) type_complete(result->type_val);
return result;
}
// Ast_Decl *get_or_instantiate_polymorph_lambda(Token *pos, Ast_Decl *poly, Array<Ast_Call_Item *> params, Ast_Scope *field_access_scope) {
// }