Ast_Init is not Ast_Binary with TK_Comma

This commit is contained in:
Krzosa Karol
2022-05-31 16:24:04 +02:00
parent 7dfc4c7b36
commit 41697dec80
6 changed files with 29 additions and 41 deletions

View File

@@ -108,6 +108,17 @@ gen_expr(Ast_Expr *ast){
else gen(".");
gen_expr(node->right);
}
else if(node->op == TK_Comma){
Sym *sym = resolved_get(node);
Ast_Atom *atom = (Ast_Atom *)node->left;
assert(atom->kind == AST_ATOM);
gen_simple_decl(sym->type, atom->intern_val);
if(node->right){
gen(" = ");
gen_expr(node->right);
}
gen(";");
}
else{
gen("(");
gen_expr(node->left);
@@ -236,17 +247,6 @@ gen_ast(Ast *ast){
BREAK();
}
CASE(INIT, Init){
Sym *sym = resolved_get(node);
gen_simple_decl(sym->type, node->ident->intern_val);
if(node->expr){
gen(" = ");
gen_expr(node->expr);
}
gen(";");
BREAK();
}
CASE(IF, If){
For(node->ifs){
if(it->init) gen_ast(it->init);