From eee5bfa0f14573eb56b5404c55e5ea25f09f53d8 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 9 Oct 2019 00:59:45 -0400 Subject: Fix scope offsets --- pc.y | 7 ++++--- scope.c | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pc.y b/pc.y index 1de6065..1783ccd 100644 --- a/pc.y +++ b/pc.y @@ -247,7 +247,8 @@ sub_prog_head tmp->var_type = $5; } - update_offsets($3, -1); + update_offsets($3, -2); + cur_scope->offset -= i; free_tree($3); @@ -277,7 +278,8 @@ sub_prog_head assert(!set_func_types($3, tmp->func_info->argv, i)); - update_offsets($3, -1); + update_offsets($3, -2); + cur_scope->offset -= i; free_tree($3); $$ = mktree(PROC, mkid(tmp), NULL); @@ -287,7 +289,6 @@ sub_prog_head arguments :'(' param_list ')' { - cur_scope->offset -= count_args($2); $$ = $2; } |/*empty*/{ diff --git a/scope.c b/scope.c index c2b3c8e..47e5943 100644 --- a/scope.c +++ b/scope.c @@ -21,6 +21,7 @@ scope* mkscope() p->prev = NULL; p->ret_var= NULL; + p->offset = 2; return p; } -- cgit v1.1