aboutsummaryrefslogtreecommitdiff
path: root/compiler/codegen.cup
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-05 21:35:12 -0500
committerMustafa Quraish <[email protected]>2022-02-05 21:35:12 -0500
commit710963c6085ade464c07c3884f73a82ace1d69a6 (patch)
treed73ea7c6b0ec03c9444ffc5b33a0f51996ac6675 /compiler/codegen.cup
parent[compiler.cup] Support for+while loops (diff)
downloadcup-710963c6085ade464c07c3884f73a82ace1d69a6.tar.xz
cup-710963c6085ade464c07c3884f73a82ace1d69a6.zip
[cup] Fix error in codegen for `if`
Diffstat (limited to 'compiler/codegen.cup')
-rw-r--r--compiler/codegen.cup5
1 files changed, 2 insertions, 3 deletions
diff --git a/compiler/codegen.cup b/compiler/codegen.cup
index ffe7c1f..d35f901 100644
--- a/compiler/codegen.cup
+++ b/compiler/codegen.cup
@@ -247,7 +247,6 @@ fn generate_expr_into_rax(node: Node*) {
emit_asm(" mov rax, [rax]\n");
} else if (node.typ == AST_ASSIGN) {
- putsln("...");
generate_lvalue_into_rax(node.d.assign.lhs);
emit_asm(" push rax\n");
generate_expr_into_rax(node.d.assign.rhs);
@@ -283,11 +282,11 @@ fn generate_statement(node: Node*) {
generate_expr_into_rax(node.d.conditional.cond);
emit_asm(" cmp rax, 0\n");
emit_asm(" je .els"); emit_num(label); emit_asm("\n");
- generate_block(node.d.conditional.then);
+ generate_statement(node.d.conditional.then);
emit_asm(" jmp .if"); emit_num(label); emit_asm("\n");
emit_asm(".els"); emit_num(label); emit_asm(":\n");
if (node.d.conditional.els)
- generate_block(node.d.conditional.els);
+ generate_statement(node.d.conditional.els);
emit_asm(".if"); emit_num(label); emit_asm(":\n");
} else if (node.typ == AST_WHILE) {