diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-06 23:13:05 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-07 03:18:08 -0500 |
| commit | 502067ade0e38e4b84134d729dee3e34c8d2890e (patch) | |
| tree | 605f404331e479f830595a8c6ec635be718fbf17 /compiler/codegen.cup | |
| parent | [cup] Add ability to import files (diff) | |
| download | cup-502067ade0e38e4b84134d729dee3e34c8d2890e.tar.xz cup-502067ade0e38e4b84134d729dee3e34c8d2890e.zip | |
[cup] Port over all the type-checking/pointer arithmetic stuff
There's still some work to be done when checking function call args,
etc, but the general mechanism of actually propagating the type back
up the AST is now here from the C compiler.
... Not to say that was very good, but it's passable enough for now.
More improvements to come in the future!
Diffstat (limited to 'compiler/codegen.cup')
| -rw-r--r-- | compiler/codegen.cup | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/codegen.cup b/compiler/codegen.cup index 68c3321..d0cf8ab 100644 --- a/compiler/codegen.cup +++ b/compiler/codegen.cup @@ -52,6 +52,8 @@ fn generate_lvalue_into_rax(node: Node*) { let offset = node.d.variable.offset; emit_asm(" mov rax, global_vars\n"); emit_asm(" add rax, "); emit_num(offset); emit_asm("\n"); + } else if (node.typ == AST_DEREF) { + generate_expr_into_rax(node.d.unary); } else { die2("Unsupported type in generate_lvalue_into_rax: ", node_type_to_string(node.typ)); } @@ -78,6 +80,9 @@ fn generate_expr_into_rax(node: Node*) { } else { die("Unsupported literal type in generate_expr_into_rax"); } + } else if (node.typ == AST_ADDROF) { + generate_lvalue_into_rax(node.d.unary); + } else if (node.typ == AST_CONDITIONAL) { let label = ++gen_label_counter; generate_expr_into_rax(node.d.conditional.cond); |