summaryrefslogtreecommitdiff
path: root/parse/specialize.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-09-12 08:35:08 -0700
committerOri Bernstein <ori@eigenstate.org>2015-09-15 23:01:09 -0700
commitae9a74441cba3160943ad18bf500781143bff096 (patch)
tree1ae200fc755f3b726465a21a007710265e0ba981 /parse/specialize.c
parent80c52bc20a53ac4c1c304df7a1e470c0ab62c576 (diff)
downloadmc-ae9a74441cba3160943ad18bf500781143bff096.tar.gz
Allow 'var' in loop statements.
Diffstat (limited to 'parse/specialize.c')
-rw-r--r--parse/specialize.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/parse/specialize.c b/parse/specialize.c
index f10ef74..fd6a702 100644
--- a/parse/specialize.c
+++ b/parse/specialize.c
@@ -191,10 +191,12 @@ static void fixup(Node *n)
fixup(n->ifstmt.iffalse);
break;
case Nloopstmt:
+ pushstab(n->loopstmt.scope);
fixup(n->loopstmt.init);
fixup(n->loopstmt.cond);
fixup(n->loopstmt.step);
fixup(n->loopstmt.body);
+ popstab();
break;
case Niterstmt:
pushstab(n->iterstmt.body->block.scope);
@@ -290,10 +292,14 @@ static Node *specializenode(Node *n, Htab *tsmap)
r->ifstmt.iffalse = specializenode(n->ifstmt.iffalse, tsmap);
break;
case Nloopstmt:
+ r->loopstmt.scope = mkstab();
+ r->loopstmt.scope->super = curstab();
+ pushstab(r->loopstmt.scope);
r->loopstmt.init = specializenode(n->loopstmt.init, tsmap);
r->loopstmt.cond = specializenode(n->loopstmt.cond, tsmap);
r->loopstmt.step = specializenode(n->loopstmt.step, tsmap);
r->loopstmt.body = specializenode(n->loopstmt.body, tsmap);
+ popstab();
break;
case Niterstmt:
r->iterstmt.elt = specializenode(n->iterstmt.elt, tsmap);