Polymorphic procedure, with passed in compile time type but without removing the type in params etc.
This commit is contained in:
12
core_ast.cpp
12
core_ast.cpp
@@ -116,7 +116,14 @@ 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;
|
||||
For(params) if (is_flag_set(it->flags, AST_POLYMORPH)) set_flag(result->flags, AST_POLYMORPH);
|
||||
|
||||
For(params) {
|
||||
if (is_flag_set(it->flags, AST_POLYMORPH)) {
|
||||
set_flag(result->flags, AST_POLYMORPH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -224,7 +231,6 @@ ast_struct(Token *pos, Ast_Scope *scope, Ast_Kind kind, Array<Ast_Decl *> polymo
|
||||
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;
|
||||
}
|
||||
@@ -627,7 +633,6 @@ end_of_switch:
|
||||
CORE_Static void
|
||||
set_flag_typespec(Ast_Expr *expr) {
|
||||
for (Ast_Iter iter = iterate_depth_first(pctx->heap, expr, true); iter.ast; next(&iter)) {
|
||||
assert(iter.kind == AST_UNARY || iter.kind == AST_ARRAY || iter.kind == AST_CALL || iter.kind == AST_CALL_ITEM || iter.kind == AST_IDENT);
|
||||
set_flag(iter.ast->flags, AST_TYPESPEC);
|
||||
}
|
||||
}
|
||||
@@ -642,7 +647,6 @@ unset_polymorph(Ast *ast) {
|
||||
CORE_Static bool
|
||||
is_typespec_polymorphic(Ast *ast) {
|
||||
for (Ast_Iter iter = iterate_depth_first(pctx->heap, ast, true); iter.ast; next(&iter)) {
|
||||
assert(iter.kind == AST_UNARY || iter.kind == AST_ARRAY || iter.kind == AST_CALL || iter.kind == AST_CALL_ITEM || iter.kind == AST_IDENT);
|
||||
if (is_flag_set(iter.ast->flags, AST_POLYMORPH)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user