From 966f97ad7c92f559ae54d0214db90c370e3b48eb Mon Sep 17 00:00:00 2001 From: Kimplul Date: Fri, 26 Apr 2024 21:08:13 +0300 Subject: add check against proc calls as statements --- src/lower.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/lower.c') diff --git a/src/lower.c b/src/lower.c index 7c5fdbd..1949bd5 100644 --- a/src/lower.c +++ b/src/lower.c @@ -299,11 +299,11 @@ static void lower_proc_call(struct fn *f, struct ast *c) output_insn(f, CALL, null_loc(), null_loc(), null_loc(), loc_as_int(def->l)); + f->sp -= count; + c->l = build_local_loc(f->sp); if (c->t != TYPE_VOID) output_insn(f, RETVAL, c->l, null_loc(), null_loc(), 0); - - f->sp -= count; } static void lower_func_call(struct fn *f, struct ast *c) @@ -322,11 +322,12 @@ static void lower_func_call(struct fn *f, struct ast *c) struct ast *def = file_scope_find(c->scope, func_call_id(c)); output_insn(f, CALL, null_loc(), null_loc(), null_loc(), loc_as_int(def->l)); + + f->sp -= count; + c->l = build_local_loc(f->sp); if (c->t != TYPE_VOID) output_insn(f, RETVAL, c->l, null_loc(), null_loc(), 0); - - f->sp -= count; } static void lower_eq(struct fn *f, struct ast *n) -- cgit v1.2.3