[Swift-commit] r2593 - in trunk: src/org/griphyn/vdl/engine tests/language-behaviour

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon Feb 23 09:04:30 CST 2009


Author: benc
Date: 2009-02-23 09:04:29 -0600 (Mon, 23 Feb 2009)
New Revision: 2593

Added:
   trunk/tests/language-behaviour/0851-iterate-using-body-variables.swift
Modified:
   trunk/src/org/griphyn/vdl/engine/Karajan.java
Log:
bug 177: loop condition in iterate statements can now refer to variables declared within the iteration body. This does not add to the expressiveness of the iterate construction (I think), but does allow a different coding style which may be more convenient.

Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-02-23 13:11:33 UTC (rev 2592)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-02-23 15:04:29 UTC (rev 2593)
@@ -581,14 +581,15 @@
 
 		StringTemplate iterateST = template("iterate");
 
-		XmlObject cond = iterate.getAbstractExpression();
-		StringTemplate condST = expressionToKarajan(cond, loopScope);
-		iterateST.setAttribute("cond", condST);
 		iterateST.setAttribute("var", iterate.getVar());
 		innerScope.bodyTemplate = iterateST;
 
 		statements(iterate.getBody(), innerScope);
 
+		XmlObject cond = iterate.getAbstractExpression();
+		StringTemplate condST = expressionToKarajan(cond, innerScope);
+		iterateST.setAttribute("cond", condST);
+
 		Object statementID = new Integer(callID++);
 		Iterator scopeIterator = innerScope.getVariableIterator();
 		while(scopeIterator.hasNext()) {

Added: trunk/tests/language-behaviour/0851-iterate-using-body-variables.swift
===================================================================
--- trunk/tests/language-behaviour/0851-iterate-using-body-variables.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/0851-iterate-using-body-variables.swift	2009-02-23 15:04:29 UTC (rev 2593)
@@ -0,0 +1,18 @@
+type messagefile;
+
+(messagefile t) greeting() { 
+    app {
+        echo "hello" stdout=@filename(t);
+    }
+}
+
+messagefile outfile[] <simple_mapper;
+                     prefix="085-iterate.",
+                     suffix=".out">;
+
+iterate i {
+  int j = i;
+  outfile[i] = greeting();
+} until(j>10);
+
+




More information about the Swift-commit mailing list