shithub: mc

Download patch

ref: da9b73d68e4850f24e2eb8f727e810ed938b0355
parent: e9d34f76df78e253167157d440c2d1e8b9993836
parent: 92e25d24edc4cd7c954ecb2b0bd88956566cbe22
author: Ori Bernstein <[email protected]>
date: Mon Jan 6 12:40:15 EST 2014

Merge
branch 'master' of git+ssh://git.eigenstate.org/git/ori/mc

--- a/6/simp.c
+++ b/6/simp.c
@@ -505,7 +505,7 @@
 static void simpiter(Simp *s, Node *n)
 {
     Node *lbody, *lstep, *lcond, *lmatch, *lend;
-    Node *idx, *len, *dcl, *val, *done;
+    Node *idx, *len, *dcl, *seq, *val, *done;
     Node *zero;
 
     lbody = genlbl();
@@ -517,6 +517,7 @@
     zero = mkintlit(n->line, 0);
     zero->expr.type = tyintptr;
 
+    seq = rval(s, n->iterstmt.seq, NULL);
     idx = gentemp(s, n, tyintptr, &dcl);
     declarelocal(s, dcl);
 
@@ -531,11 +532,11 @@
     simp(s, assign(s, idx, addk(idx, 1)));
     /* condition */
     simp(s, lcond);
-    len = seqlen(s, n->iterstmt.seq, tyintptr);
+    len = seqlen(s, seq, tyintptr);
     done = mkexpr(n->line, Olt, idx, len, NULL);
     cjmp(s, done, lmatch, lend);
     simp(s, lmatch);
-    val = load(idxaddr(s, n->iterstmt.seq, idx));
+    val = load(idxaddr(s, seq, idx));
     umatch(s, n->iterstmt.elt, val, val->expr.type, lbody, lstep);
     simp(s, lend);
 }
--- /dev/null
+++ b/test/subrangefor.myr
@@ -1,0 +1,8 @@
+use std
+
+const main = {
+	for i in [1,2,3,4][:2]
+		std.put("%i", i)
+	;;
+	std.put("\n")
+}
--- a/test/tests
+++ b/test/tests
@@ -56,6 +56,7 @@
 B nestfn	E	42
 # B closure	E	55      ## BUGGERED
 B loop		E	45
+B subrangefor	P       12
 B patiter	P	23512
 B condiftrue	E	7
 B condiffalse	E	9