Baby steps struct polymorphs
This commit is contained in:
15
core_ast.cpp
15
core_ast.cpp
@@ -20,6 +20,17 @@ _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);
|
||||
@@ -214,11 +225,13 @@ finalize_stmt_scope(Ast_Scope *scope) {
|
||||
}
|
||||
|
||||
CORE_Static Ast_Decl *
|
||||
ast_struct(Token *pos, Ast_Scope *scope, Ast_Kind kind = AST_STRUCT) {
|
||||
ast_struct(Token *pos, Ast_Scope *scope, Ast_Kind kind, Array<Ast_Decl *> polymorph_parameters) {
|
||||
assert(kind == AST_STRUCT || kind == AST_UNION);
|
||||
AST_NEW(Decl, STRUCT, pos, AST_DECL | AST_AGGREGATE);
|
||||
result->kind = kind;
|
||||
result->scope = scope;
|
||||
result->polymorph_parameters = polymorph_parameters;
|
||||
if (polymorph_parameters.len) set_flag(result->flags, AST_POLYMORPH);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user