ref: 0e624db312994ed6e74a63187ecf8f3ac6babeb5
parent: 814f0d3958f7ac453d2913363a87238cc5c03a5f
author: Ori Bernstein <[email protected]>
date: Sun Jul 15 23:37:00 EDT 2012
Fix tuple offsetting.
--- a/8/isel.c
+++ b/8/isel.c
@@ -151,6 +151,10 @@
va_start(ap, op);
i = mkinsnv(op, ap);
va_end(ap);
+ if (debugopt['i']) {
+ printf("GEN ");
+ iprintf(stdout, i);
+ }
lappend(&s->curbb->il, &s->curbb->ni, i);
}
--- a/8/simp.c
+++ b/8/simp.c
@@ -241,6 +241,10 @@
assert(exprop(t->asize) == Olit);
return t->asize->expr.args[0]->lit.intval * tysize(t->sub[0]);
case Tytuple:
+ for (i = 0; i < t->nsub; i++)
+ sz += tysize(t->sub[i]);
+ return sz;
+ break;
case Tystruct:
for (i = 0; i < t->nmemb; i++)
sz += size(t->sdecls[i]);
@@ -719,7 +723,7 @@
stor = store(lv, load(prv));
}
append(s, stor);
- off += size(args[i]);
+ off += size(lv);
}
return NULL;
@@ -776,7 +780,7 @@
append(s, stor);
off += size(args[i]);
}
- return r;
+ return dst;
}
static Node *lowerucon(Simp *s, Node *n, Node *dst)
@@ -980,7 +984,7 @@
assert(n->type == Ndecl);
s->stksz += size(n);
if (debug)
- printf("declare %s(%ld) at %zd\n", declname(n), n->decl.did, s->stksz);
+ printf("declare %s:%s(%ld) at %zd\n", declname(n), tystr(decltype(n)), n->decl.did, s->stksz);
htput(s->locs, n, (void*)s->stksz);
}
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -518,7 +518,9 @@
tuphead : expr Tcomma {$$ = $1;}
;
-tuprest : expr
+tuprest : /*empty */
+ {$$.nl = NULL; $$.nn = 0;}
+ | expr
{$$.nl = NULL; $$.nn = 0; lappend(&$$.nl, &$$.nn, $1);}
| tuprest Tcomma expr
{lappend(&$$.nl, &$$.nn, $3);}