From 502067ade0e38e4b84134d729dee3e34c8d2890e Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Sun, 6 Feb 2022 23:13:05 -0500 Subject: [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! --- compiler/codegen.cup | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'compiler/codegen.cup') 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); -- cgit v1.2.3