aboutsummaryrefslogtreecommitdiff
path: root/src/lower.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-04-26 21:08:13 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-04-26 21:08:13 +0300
commit966f97ad7c92f559ae54d0214db90c370e3b48eb (patch)
tree5dfadd4f453cb0076039c70b0574e58dee8ff2a4 /src/lower.c
parent930e0f29ff5637f38a878d2e61352b151698a0ea (diff)
downloadposthaste-966f97ad7c92f559ae54d0214db90c370e3b48eb.tar.gz
posthaste-966f97ad7c92f559ae54d0214db90c370e3b48eb.zip
add check against proc calls as statements
Diffstat (limited to 'src/lower.c')
-rw-r--r--src/lower.c9
1 files changed, 5 insertions, 4 deletions
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)