From a5185aebb89eaa8ea318d7e3bf881f03349b789a Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Wed, 2 Feb 2022 02:14:10 -0500 Subject: Modify how types are stored. We now dynamically allocate the type structure, and recursively store a reference to the original type if it's a pointer. For now it's a little bit of a waste but it helps us future-proof stuff for more complex things to come --- src/generator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/generator.c') diff --git a/src/generator.c b/src/generator.c index 7de9d32..d3e63de 100644 --- a/src/generator.c +++ b/src/generator.c @@ -49,7 +49,7 @@ void generate_expr_into_rax(Node *expr, FILE *out) // TODO: Different sized output for different types? if (expr->type == AST_LITERAL) { // TODO: More literal types - assert(expr->literal.type.type == TYPE_INT); + assert(expr->literal.type->type == TYPE_INT); fprintf(out, " mov rax, %d\n", expr->literal.as_int); } else if (expr->type == AST_FUNCCALL) { @@ -340,7 +340,7 @@ void generate_block(Node *block, FILE *out) assert(block->type == AST_BLOCK); for (int i = 0; i < block->block.num_children; i++) generate_statement(block->block.children[i], out); - + assert(defer_stack_count - cur_defer_pos >= 0); while (defer_stack_count > cur_defer_pos) { Node *deferred = defer_stack[--defer_stack_count]; -- cgit v1.2.3