Adding struts

This commit is contained in:
Krzosa Karol
2022-05-29 12:30:02 +02:00
parent 07b793aacc
commit ea1b74cda0
7 changed files with 112 additions and 44 deletions

View File

@@ -278,9 +278,22 @@ gen_ast(Ast *ast){
gen("String %s = LIT(\"%s\");", node->name.str, sym->intern_val.str);
}
else if(sym->type == type_type){
gen("// typedef ");
gen_simple_decl(sym->type_val, node->name);
gen(";");
if(sym->type_val->kind == TYPE_Struct){
Ast_Struct *agg = (Ast_Struct *)node->value;
gen("struct %s{", node->name.str);
global_indent++;
For(agg->members){
genln("");
gen_ast(it[0]);
}
global_indent--;
genln("};");
}
else{
gen("// typedef ");
gen_simple_decl(sym->type_val, node->name);
gen(";");
}
}
else{
parsing_error(node->pos, "C_Codegen: Unhandled type of constant expression");