summaryrefslogtreecommitdiff
path: root/6
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2017-02-13 17:17:21 -0800
committerOri Bernstein <ori@markovcorp.com>2017-02-13 17:17:21 -0800
commit6fb3068098ac00cf2ebe8c5ec6b463a145662f92 (patch)
treeb683d4285a6b1201625c821d8632baac0033eefe /6
parentb4230c2187e0aa9a298cdebbcc6af769d3284cac (diff)
downloadmc-6fb3068098ac00cf2ebe8c5ec6b463a145662f92.tar.gz
Pad tuples and arrays correctly.
Diffstat (limited to '6')
-rw-r--r--6/blob.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/6/blob.c b/6/blob.c
index db06220..133a4d2 100644
--- a/6/blob.c
+++ b/6/blob.c
@@ -259,7 +259,7 @@ static size_t blobucon(Blob *seq, Htab *globls, Htab *strtab, Node *n)
static size_t blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n)
{
- size_t i, sz;
+ size_t i, sz, end;
switch(exprop(n)) {
case Oucon: sz = blobucon(b, globls, strtab, n); break;
@@ -269,9 +269,17 @@ static size_t blobrec(Blob *b, Htab *globls, Htab *strtab, Node *n)
case Otup:
case Oarr:
/* Assumption: We sorted this while folding */
+ if (!n->expr.args)
+ break;
sz = 0;
- for (i = 0; i < n->expr.nargs; i++)
+ for (i = 0; i < n->expr.nargs; i++) {
+ end = alignto(sz, exprtype(n->expr.args[i]));
+ sz += blobpad(b, end - sz);
sz += blobrec(b, globls, strtab, n->expr.args[i]);
+ }
+ /* if we need padding at the end.. */
+ end = alignto(sz, exprtype(n));
+ sz += blobpad(b, end - sz);
break;
default:
dump(n, stdout);