diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-05 21:35:12 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-05 21:35:12 -0500 |
| commit | 710963c6085ade464c07c3884f73a82ace1d69a6 (patch) | |
| tree | d73ea7c6b0ec03c9444ffc5b33a0f51996ac6675 | |
| parent | [compiler.cup] Support for+while loops (diff) | |
| download | cup-710963c6085ade464c07c3884f73a82ace1d69a6.tar.xz cup-710963c6085ade464c07c3884f73a82ace1d69a6.zip | |
[cup] Fix error in codegen for `if`
| -rw-r--r-- | compiler/codegen.cup | 5 |
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) { |