shithub: mc

Download patch

ref: 1ba0be918be8f606f8ee165eefc6c43be2fd3f0c
parent: 29137fc29f53c66df62485ee3f7f956a5aae3041
author: Ori Bernstein <[email protected]>
date: Thu Jun 7 20:25:42 EDT 2012

Get args/locals at the right place.

--- a/8/reduce.c
+++ b/8/reduce.c
@@ -507,19 +507,19 @@
 void declarelocal(Simp *s, Node *n)
 {
     assert(n->type == Ndecl);
+    s->stksz += size(n);
     if (debug)
         printf("DECLARE %s(%ld) at %zd\n", declname(n), n->decl.sym->id, s->stksz);
-    htput(s->locs, (void*)n->decl.sym->id, (void*)(s->stksz + 4));
-    s->stksz += size(n);
+    htput(s->locs, (void*)n->decl.sym->id, (void*)s->stksz);
 }
 
 void declarearg(Simp *s, Node *n)
 {
     assert(n->type == Ndecl);
-    s->argsz += size(n);
     if (debug)
         printf("DECLARE %s(%ld) at %zd\n", declname(n), n->decl.sym->id, -(s->argsz + 8));
     htput(s->locs, (void*)n->decl.sym->id, (void*)-(s->argsz + 8));
+    s->argsz += size(n);
 }
 
 Node *simp(Simp *s, Node *n)