Enums working

This commit is contained in:
Krzosa Karol
2022-06-10 19:41:10 +02:00
parent 43fe057cf4
commit 70255c18cb
4 changed files with 27 additions and 37 deletions

View File

@@ -339,6 +339,23 @@ gen_ast(Ast *ast){
BREAK();
}
CASE(ENUM, Decl){
gen("/*enum %s{", node->name.str);
// @todo add typespec
global_indent++;
For(node->scope->decls){
genln("%s", it->name.str);
if(it->expr){
gen(" = ");
gen_expr(it->expr);
}
gen(",");
}
global_indent--;
genln("};*/");
BREAK();
}
CASE(CONST, Decl){
switch(node->type->kind){
CASE_FLOAT:{
@@ -382,25 +399,7 @@ gen_ast(Ast *ast){
// }
// }
// else if(sym->type_val->kind == TYPE_ENUM){
// Ast_Enum *enu = (Ast_Enum *)sym->type_val->ast;
// assert(enu->kind == AST_ENUM);
// if(node->value->kind == AST_ENUM){
// gen("/*enum %s{", node->name.str);
// // @todo add typespec
// global_indent++;
// For(enu->members){
// genln("%s", it->name.str);
// gen(" = ");
// Sym *value_sym = resolved_get(it);
// gen("%d", bigint_as_signed(&value_sym->big_int_val));
// gen(",");
// }
// global_indent--;
// genln("};*/");
// }
// else{
// // Type alias
// }
//
// }
// else{
// gen("// typedef ");