summaryrefslogtreecommitdiff
path: root/6/simp.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-10-21 21:09:47 -0700
committerOri Bernstein <ori@eigenstate.org>2015-11-06 00:38:56 -0800
commit7f04fcc98b500a390d5b89ca766982afa6feb168 (patch)
treec66e51bb8fb019e8c3c9eb06bf6c7d47fca19ce9 /6/simp.c
parent39562e06a87e2068d9dcd788201a2b7a6efdb7b2 (diff)
downloadmc-7f04fcc98b500a390d5b89ca766982afa6feb168.tar.gz
Fix decision trees for structs.
Diffstat (limited to '6/simp.c')
-rw-r--r--6/simp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/6/simp.c b/6/simp.c
index 74c8c83..f0aa0e3 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -655,7 +655,7 @@ static void matchpattern(Simp *s, Node *pat, Node *val, Type *t, Node *iftrue, N
}
}
-static void simpmatch(Simp *s, Node *n)
+void simpmatch(Simp *s, Node *n)
{
Node *end, *cur, *next; /* labels */
Node *val, *tmp;
@@ -1218,13 +1218,14 @@ static Node *simpucon(Simp *s, Node *n, Node *dst)
static Node *simpuget(Simp *s, Node *n, Node *dst)
{
- Node *u, *p;
+ Node *u, *p, *l;
if (!dst)
dst = temp(s, n);
- u = n->expr.args[0];
+ u = rval(s, n->expr.args[0], NULL);
p = addk(addr(s, u, exprtype(n)), Wordsz);
- assign(s, dst, load(p));
+ l = assign(s, dst, load(p));
+ append(s, l);
return dst;
}
@@ -1710,9 +1711,10 @@ static Node *rval(Simp *s, Node *n, Node *dst)
r = compare(s, n, 0);
break;
case Otupget:
- assert(exprop(args[0]) == Olit);
- i = args[0]->expr.args[0]->lit.intval;
+ assert(exprop(args[1]) == Olit);
+ i = args[1]->expr.args[0]->lit.intval;
r = tupget(s, args[0], i, dst);
+ break;
case Obad:
die("bad operator");
break;