commit 7e853c4c8d785762fc4ece704d9e9277bb9eaa46
parent 777ee77e05570b7ff8864cbf1352d71741d96737
Author: Brian Swetland <swetland@frotz.net>
Date: Thu, 2 Dec 2021 00:05:42 -0800
compiler2: fix forward calls
- don't save forward decls in the AST
- use the right helper to emit call and add to symbol fixups
Diffstat:
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/codegen-risc5-simple.c b/src/codegen-risc5-simple.c
@@ -239,7 +239,7 @@ u32 gen_call(Ast node) {
arg = arg->next;
n = n + 1;
}
- emit_bi(AL|L, 0); ///XXX
+ gen_branch_sym(AL|L, sym);
emit_opi(ADD, SP, SP, 4 * sym->type->len);
// return is in r0, if it exists
diff --git a/src/compiler2.c b/src/compiler2.c
@@ -1716,22 +1716,19 @@ Ast parse_function() {
symbol_add_global(sym);
}
- Ast node = ast_make_simple(AST_FUNC, 0);
- node->name = fname;
- node->sym = sym;
-
// handle definition if it is one
if (isdef) {
- // patch any forward references
- //fixup_branches_fwd(obj->fixups);
+ Ast node = ast_make_simple(AST_FUNC, 0);
+ node->name = fname;
+ node->sym = sym;
// mark as defined and save entry address
sym->flags |= SYM_IS_DEFINED;
- //sym->value = ctx.pc;
node->child = parse_function_body(sym);
+ return node;
}
- return node;
+ return nil;
}
Ast parse_type_def() {