Propagate polymorphic to lambda
This commit is contained in:
23
core_ast.cpp
23
core_ast.cpp
@@ -20,17 +20,6 @@ _ast_new(size_t size, Ast_Kind kind, Token *pos, Ast_Flag flags = 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
CORE_Static void
|
||||
propagate_polymorphic(Ast *to, Ast *from) {
|
||||
if (is_flag_set(from->flags, AST_IDENT_POLYMORPH)) set_flag(to->flags, AST_IDENT_POLYMORPH);
|
||||
if (is_flag_set(from->flags, AST_TYPE_POLYMORPH)) set_flag(to->flags, AST_TYPE_POLYMORPH);
|
||||
}
|
||||
|
||||
CORE_Static void
|
||||
propagate_polymorphic(Ast *to, Token *from) {
|
||||
if (from->kind == TK_Polymorph) set_flag(to->flags, AST_IDENT_POLYMORPH);
|
||||
}
|
||||
|
||||
CORE_Static Ast_Atom *
|
||||
ast_str(Token *pos, Intern_String string) {
|
||||
AST_NEW(Atom, VALUE, pos, AST_EXPR | AST_ATOM);
|
||||
@@ -127,6 +116,7 @@ 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);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -640,3 +630,14 @@ set_flag_typespec(Ast_Expr *expr) {
|
||||
set_flag(iter.ast->flags, AST_TYPESPEC);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user