[Swift-commit] r2538 - in trunk: libexec resources src/org/griphyn/vdl/engine src/org/griphyn/vdl/karajan/lib tests/language/working tests/language/working-base tests/language-behaviour

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Sat Feb 14 06:45:51 CST 2009


Author: benc
Date: 2009-02-14 06:45:50 -0600 (Sat, 14 Feb 2009)
New Revision: 2538

Added:
   trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java
   trunk/tests/language-behaviour/161-star-dot.swift
   trunk/tests/language/working-base/0471-fmri.xml
   trunk/tests/language/working/0471-fmri.swift
Modified:
   trunk/libexec/vdl-lib.xml
   trunk/resources/Karajan.stg
   trunk/src/org/griphyn/vdl/engine/Karajan.java
   trunk/src/org/griphyn/vdl/karajan/lib/GetField.java
Log:
[*] is changed so that it is an identity operation: array[*] == array

The structure-member operator . is changed so that it can take arrays
of structures on the left-hand side. In such cases, the expression will
evaluate to an array containing the named members of each element of the
structure.

Modified: trunk/libexec/vdl-lib.xml
===================================================================
--- trunk/libexec/vdl-lib.xml	2009-02-14 12:43:48 UTC (rev 2537)
+++ trunk/libexec/vdl-lib.xml	2009-02-14 12:45:50 UTC (rev 2538)
@@ -47,6 +47,7 @@
 	<export name="getFieldValue"><elementDef classname="org.griphyn.vdl.karajan.lib.GetFieldValue"/></export>
 	<export name="waitFieldValue"><elementDef classname="org.griphyn.vdl.karajan.lib.WaitFieldValue"/></export>
 	<export name="getArrayIterator"><elementDef classname="org.griphyn.vdl.karajan.lib.GetArrayIterator"/></export>
+	<export name="slicearray"><elementDef classname="org.griphyn.vdl.karajan.lib.SliceArray"/></export>
 	<export name="isFileBound"><elementDef classname="org.griphyn.vdl.karajan.lib.IsFileBound"/></export>
 	<export name="isRestartable"><elementDef classname="org.griphyn.vdl.karajan.lib.IsRestartable"/></export>
 	<export name="fringePaths"><elementDef classname="org.griphyn.vdl.karajan.lib.FringePaths"/></export>

Modified: trunk/resources/Karajan.stg
===================================================================
--- trunk/resources/Karajan.stg	2009-02-14 12:43:48 UTC (rev 2537)
+++ trunk/resources/Karajan.stg	2009-02-14 12:45:50 UTC (rev 2538)
@@ -470,6 +470,15 @@
 
 >>
 
+slicearray(parent, memberchild, datatype) ::= <<
+<vdl:slicearray>
+  <argument name="var">$parent$</argument>
+  <argument name="path">$memberchild$</argument>
+  <argument name="type">$datatype$</argument>
+</vdl:slicearray>
+>>
+
+
 iConst(value, datatype) ::= <<
 <vdl:new type="int" value="$value$" />
 >>

Modified: trunk/src/org/griphyn/vdl/engine/Karajan.java
===================================================================
--- trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-02-14 12:43:48 UTC (rev 2537)
+++ trunk/src/org/griphyn/vdl/engine/Karajan.java	2009-02-14 12:45:50 UTC (rev 2538)
@@ -739,28 +739,32 @@
 	}
 
 	public StringTemplate application(ApplicationBinding app, VariableScope scope) throws CompilationException {
-		StringTemplate appST = new StringTemplate("application");
-		appST.setAttribute("exec", app.getExecutable());
-		for (int i = 0; i < app.sizeOfAbstractExpressionArray(); i++) {
-			XmlObject argument = app.getAbstractExpressionArray(i);
-			StringTemplate argumentST = expressionToKarajan(argument, scope);
-			String type = datatype(argumentST);
-			if(type.equals("string") || type.equals("string[]")
-			 || type.equals("int") || type.equals("float") 
-			 || type.equals("int[]") || type.equals("float[]") 
-			 || type.equals("boolean") || type.equals("boolean[]")) {
-				appST.setAttribute("arguments", argumentST);
-			} else {
-				throw new CompilationException("Cannot pass type '"+type+"' as a parameter to application '"+app.getExecutable()+"' at "+app.getSrc());
+		try {
+			StringTemplate appST = new StringTemplate("application");
+			appST.setAttribute("exec", app.getExecutable());
+			for (int i = 0; i < app.sizeOfAbstractExpressionArray(); i++) {
+				XmlObject argument = app.getAbstractExpressionArray(i);
+				StringTemplate argumentST = expressionToKarajan(argument, scope);
+				String type = datatype(argumentST);
+				if(type.equals("string") || type.equals("string[]")
+				 || type.equals("int") || type.equals("float") 
+				 || type.equals("int[]") || type.equals("float[]") 
+				 || type.equals("boolean") || type.equals("boolean[]")) {
+					appST.setAttribute("arguments", argumentST);
+				} else {
+					throw new CompilationException("Cannot pass type '"+type+"' as a parameter to application '"+app.getExecutable());
+				}
 			}
+			if(app.getStdin()!=null)
+				appST.setAttribute("stdin", expressionToKarajan(app.getStdin().getAbstractExpression(), scope));
+			if(app.getStdout()!=null)
+				appST.setAttribute("stdout", expressionToKarajan(app.getStdout().getAbstractExpression(), scope));
+			if(app.getStderr()!=null)
+				appST.setAttribute("stderr", expressionToKarajan(app.getStderr().getAbstractExpression(), scope));
+			return appST;
+		} catch(CompilationException e) {
+			throw new CompilationException(e.getMessage()+" in application "+app.getExecutable()+" at "+app.getSrc(),e);
 		}
-		if(app.getStdin()!=null)
-			appST.setAttribute("stdin", expressionToKarajan(app.getStdin().getAbstractExpression(), scope));
-		if(app.getStdout()!=null)
-			appST.setAttribute("stdout", expressionToKarajan(app.getStdout().getAbstractExpression(), scope));
-		if(app.getStderr()!=null)
-			appST.setAttribute("stderr", expressionToKarajan(app.getStderr().getAbstractExpression(), scope));
-		return appST;
 	}
 
 	/** Produces a Karajan function invocation from a SwiftScript invocation.
@@ -969,33 +973,52 @@
 			return st;
 		} else if (expressionQName.equals(ARRAY_SUBSCRIPT_EXPR)) {
 			BinaryOperator op = (BinaryOperator) expression;
-			StringTemplate newst = template("extractarrayelement");
 			StringTemplate arrayST = expressionToKarajan(op.getAbstractExpressionArray(1), scope);
 			StringTemplate parentST = expressionToKarajan(op.getAbstractExpressionArray(0), scope);
-			newst.setAttribute("arraychild", arrayST);
-			newst.setAttribute("parent", parentST);
-			
-			String arrayType = datatype(parentST); 
+
+			// handle [*] as identity/no-op
 			if (datatype(arrayST).equals("string")) {
 				XmlString var = (XmlString) op.getAbstractExpressionArray(1);
-				if (!var.getStringValue().equals("*"))
+				if (var.getStringValue().equals("*")) {
+					return parentST;
+				} else {
 				   throw new CompilationException("Array index must be of type int, or *.");
-				newst.setAttribute("datatype", arrayType);
-			} else if (datatype(arrayST).equals("int")) {
-				newst.setAttribute("datatype", arrayType.substring(0, arrayType.length()-2));
+				}
 			} else {
-				throw new CompilationException("Array index must be of type int.");
+				// the index should be numerical
+
+				StringTemplate newst = template("extractarrayelement");
+				newst.setAttribute("arraychild", arrayST);
+				newst.setAttribute("parent", parentST);
+			
+				String arrayType = datatype(parentST); 
+				if (datatype(arrayST).equals("int")) {
+					newst.setAttribute("datatype", arrayType.substring(0, arrayType.length()-2));
+				} else {
+					throw new CompilationException("Array index must be of type int, or *.");
+				}
+				return newst;
 			}
-			return newst;
 		} else if (expressionQName.equals(STRUCTURE_MEMBER_EXPR)) {
 			StructureMember sm = (StructureMember) expression;
-			StringTemplate newst = template("extractarrayelement");
 			StringTemplate parentST = expressionToKarajan(sm.getAbstractExpression(), scope);
-			newst.setAttribute("parent", parentST);
-			newst.setAttribute("memberchild", sm.getMemberName());
 			
 			String parentType = datatype(parentST);
+
+
+			// if the parent is an array, then check against
+			// the base type of the array
+
+boolean arrayMode = false;
+			if(parentType.endsWith("[]")) {
+System.err.println("Strimming the end off "+parentType+" to give ...");
+arrayMode=true;
+				parentType = parentType.substring(0, parentType.length() - 2);
+System.err.println("... to give "+parentType);
+			}
+
 			String actualType = null;					
+			// TODO this should be a map lookup of some kind?
 			for (int i = 0; i < types.sizeOfTypeArray(); i++) {
 				if (types.getTypeArray(i).getTypename().equals(parentType)) {
 					TypeStructure ts = types.getTypeArray(i).getTypestructure();
@@ -1014,8 +1037,20 @@
 			if (actualType == null) {
 				throw new CompilationException("Type " + parentType + " is not defined.");
 			}
-			newst.setAttribute("datatype", actualType); 
-			return newst;
+			if(arrayMode) {
+				actualType += "[]";
+				StringTemplate newst = template("slicearray");
+				newst.setAttribute("parent", parentST);
+				newst.setAttribute("memberchild", sm.getMemberName());
+				newst.setAttribute("datatype", actualType); 
+				return newst;
+			} else {
+				StringTemplate newst = template("extractarrayelement");
+				newst.setAttribute("parent", parentST);
+				newst.setAttribute("memberchild", sm.getMemberName());
+				newst.setAttribute("datatype", actualType); 
+				return newst;
+			}
 			// TODO the template layout for this and ARRAY_SUBSCRIPT are
 			// both a bit convoluted for historical reasons.
 			// should be straightforward to tidy up.

Modified: trunk/src/org/griphyn/vdl/karajan/lib/GetField.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/GetField.java	2009-02-14 12:43:48 UTC (rev 2537)
+++ trunk/src/org/griphyn/vdl/karajan/lib/GetField.java	2009-02-14 12:45:50 UTC (rev 2538)
@@ -11,9 +11,9 @@
 import org.globus.cog.karajan.stack.VariableStack;
 import org.globus.cog.karajan.workflow.ExecutionException;
 import org.griphyn.vdl.mapping.DSHandle;
-import org.griphyn.vdl.mapping.HandleOpenException;
 import org.griphyn.vdl.mapping.InvalidPathException;
 import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.type.Type;
 
 public class GetField extends VDLFunction {
 	static {
@@ -28,50 +28,17 @@
 
 			try {
 				DSHandle var = (DSHandle) var1;
+
+
 				Path path = parsePath(OA_PATH.getValue(stack), stack);
-				Collection fields = var.getFields(path);
-				if(fields.size() == 1) {
-					return fields.iterator().next();
-				} else {
-					return fields;
-				}
+				DSHandle field = var.getField(path);
+				return field;
 			}
 			catch (InvalidPathException e) {
 				throw new ExecutionException(e);
 			}
-			catch (HandleOpenException e) {
-				throw new ExecutionException(e);
-			}
-		} else if (var1 instanceof Collection) {
-			// this path gets reached if we've been passed the results
-			// of a [*] array reference
-			// iterate over each element in the collection, performing the
-			// above code on each; and then merge the resulting collections
-			// into one before performing the return processing
-			Collection var = (Collection)var1;
-			Collection results = new ArrayList();
-			Iterator i = var.iterator();
-			try {
-				Path path = parsePath(OA_PATH.getValue(stack), stack);
-				while(i.hasNext()) {
-					DSHandle d = (DSHandle) i.next();
-					Collection theseResults = d.getFields(path);
-					results.addAll(theseResults);
-				}
-			}
-			catch (InvalidPathException e) {
-				throw new ExecutionException(e);
-			}
-			catch (HandleOpenException e) {
-				throw new ExecutionException(e);
-			}
-			if(results.size() == 1) {
-				return results.iterator().next();
-			} else {
-				return results;
-			}
 		} else {
-			throw new ExecutionException("was expecting a DSHandle or collection of DSHandles, got: "+var1.getClass());
+			throw new ExecutionException("was expecting a DSHandle, got: "+var1.getClass());
 		}
 	}
 

Added: trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java	                        (rev 0)
+++ trunk/src/org/griphyn/vdl/karajan/lib/SliceArray.java	2009-02-14 12:45:50 UTC (rev 2538)
@@ -0,0 +1,130 @@
+/*
+ * Created on Dec 26, 2006
+ */
+package org.griphyn.vdl.karajan.lib;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.globus.cog.karajan.arguments.Arg;
+import org.globus.cog.karajan.stack.VariableStack;
+import org.globus.cog.karajan.workflow.ExecutionException;
+import org.globus.cog.karajan.workflow.futures.FutureNotYetAvailable;
+
+import org.griphyn.vdl.karajan.Pair;
+import org.griphyn.vdl.karajan.PairIterator;
+import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.InvalidPathException;
+import org.griphyn.vdl.mapping.Path;
+import org.griphyn.vdl.mapping.RootArrayDataNode;
+import org.griphyn.vdl.type.NoSuchTypeException;
+import org.griphyn.vdl.type.Type;
+import org.griphyn.vdl.type.Types;
+
+
+
+public class SliceArray extends VDLFunction {
+
+        public static final Arg PA_TYPE = new Arg.Positional("type");
+
+	static {
+		setArguments(SliceArray.class, new Arg[] { PA_VAR, PA_PATH, PA_TYPE });
+	}
+
+	public Object function(VariableStack stack) throws ExecutionException {
+		Object var1 = PA_VAR.getValue(stack);
+
+// TODO for now, this insists the the array be closed entirely before we
+// execute. This may cause overserialisation; and worse, will break when
+// we are trying to use the cut as an output parameter, not an input
+// parameter (likely resulting in a hang).
+// Need to think hard about how to handle this. Static assignment
+// analysis is going to fail, I think - its like pointer aliasing in C,
+// a bit. If I get a ref to an array element using this, then I can
+// assign to it, but the compiler isn't going to be aware that I am
+// assigning to it so can't construct partialCloseDatasets correctly...
+// perhaps thats another argument for map? (as in, moving away from
+// [] based assignments...
+
+
+		if(var1 instanceof DSHandle) {
+
+			try {
+				DSHandle sourceArray = (DSHandle) var1;
+				synchronized(sourceArray.getRoot()) {
+					if(!sourceArray.isClosed()) {
+                        			throw new FutureNotYetAvailable(VDLFunction.addFutureListener(stack, sourceArray));
+					}
+				}
+
+				Type sourceType = sourceArray.getType();
+
+				if(!sourceType.isArray()) {
+					throw new RuntimeException("SliceArray can only slice arrays.");
+				}
+
+				String destinationTypeName = (String) PA_TYPE.getValue(stack);
+System.err.println("Looking up destination type "+destinationTypeName);
+				Type destinationType = Types.getType(destinationTypeName);
+System.err.println("Got type object "+destinationType);
+				RootArrayDataNode destinationArray = new RootArrayDataNode(destinationType);
+
+
+                               	Path cutPath = Path.EMPTY_PATH.addLast((String)PA_PATH.getValue(stack), false);
+
+                        	PairIterator it = new PairIterator(sourceArray.getArrayValue());
+
+				while(it.hasNext()) {
+					Pair pair = (Pair) it.next();
+					Object index = pair.get(0);
+					DSHandle sourceElement = (DSHandle) pair.get(1);
+System.err.println("Processing index: "+index+" with sourceElement="+sourceElement);
+
+
+                                	Path p = Path.EMPTY_PATH.addLast(String.valueOf(index), true);
+
+					DSHandle n = sourceElement.getField(cutPath);
+
+                                	destinationArray.getField(p).set((DSHandle) n);
+				}
+
+				// all of the inputs should be closed, so
+				// we only need shallow close
+				destinationArray.closeShallow();
+
+				return destinationArray;
+
+/* code from setfieldvalue to look at:
+                } else if(source.getType().isArray()) {
+                        PairIterator it = new PairIterator(source.getArrayValue());
+                        while(it.hasNext()) {
+                                Pair pair = (Pair) it.next();
+                                Object lhs = pair.get(0);
+                                DSHandle rhs = (DSHandle) pair.get(1);
+                                Path memberPath = Path.EMPTY_PATH.addLast(String.valueOf(lhs),true);
+                                DSHandle field;
+                                try {
+                                        field = dest.getField(memberPath);
+                                } catch(InvalidPathException ipe) {
+                                        throw new ExecutionException("Could not get destination field",ipe);
+                                }
+                                deepCopy(field,rhs,stack);
+                        }
+                        closeShallow(stack, dest);
+
+*/
+			}
+			catch(NoSuchTypeException nste) {
+				throw new ExecutionException("No such type",nste);
+			}
+			catch (InvalidPathException e) {
+				throw new ExecutionException(e);
+			}
+		} else {
+			throw new ExecutionException("was expecting a DSHandle or collection of DSHandles, got: "+var1.getClass());
+		}
+	}
+
+
+}

Added: trunk/tests/language/working/0471-fmri.swift
===================================================================
--- trunk/tests/language/working/0471-fmri.swift	                        (rev 0)
+++ trunk/tests/language/working/0471-fmri.swift	2009-02-14 12:45:50 UTC (rev 2538)
@@ -0,0 +1,90 @@
+type voxelfile;
+type headerfile;
+
+type pgmfile;
+type imagefile;
+
+type warpfile;
+
+type volume {
+    voxelfile img;
+    headerfile hdr;
+};
+
+(warpfile warp) align_warp(volume reference, volume subject, string model, string quick) {
+    app {
+        align_warp @reference.img @subject.img @warp "-m " model quick;
+    }
+}
+
+(volume sliced) reslice(warpfile warp, volume subject)
+{
+    app {
+        reslice @warp @sliced.img;
+    }
+}
+
+(volume sliced) align_and_reslice(volume reference, volume subject, string model, string quick) {
+    warpfile warp;
+    warp = align_warp(reference, subject, model, quick);
+    sliced = reslice(warp, subject);
+}
+
+
+(volume atlas) softmean(volume sliced[])
+{
+    app {
+        softmean @atlas.img "y" "null" @filenames(sliced[*].img);
+    }
+}
+
+
+(pgmfile outslice) slicer(volume input, string axis, string position)
+{
+    app {
+        slicer @input.img axis position @outslice;
+    }
+}
+
+(imagefile outimg) convert(pgmfile inpgm)
+{
+    app {
+        convert @inpgm @outimg;
+    }
+}
+
+(imagefile outimg) slice_to_jpeg(volume inp, string axis, string position)
+{
+    pgmfile outslice;
+    outslice = slicer(inp, axis, position);
+    outimg = convert(outslice);
+}
+
+(volume s[]) all_align_reslices(volume reference, volume subjects[]) {
+
+    foreach subject, i in subjects {
+        s[i] = align_and_reslice(reference, subjects[i], "12", "-q");
+    }
+
+}
+
+
+volume references[] <csv_mapper;file="reference.csv">;
+volume reference=references[0];
+
+volume subjects[] <csv_mapper;file="subjects.csv">;
+
+volume slices[] <csv_mapper;file="slices.csv">;
+slices = all_align_reslices(reference, subjects);
+
+volume atlas <simple_mapper;prefix="atlas">;
+atlas = softmean(slices);
+
+string directions[] = [ "x", "y", "z"];
+
+foreach direction in directions {
+    imagefile o <single_file_mapper;file=@strcat("atlas-",direction,".jpeg")>;
+    string option = @strcat("-",direction);
+    o = slice_to_jpeg(atlas, option, ".5");
+}
+

Added: trunk/tests/language/working-base/0471-fmri.xml
===================================================================
--- trunk/tests/language/working-base/0471-fmri.xml	                        (rev 0)
+++ trunk/tests/language/working-base/0471-fmri.xml	2009-02-14 12:45:50 UTC (rev 2538)
@@ -0,0 +1,366 @@
+<program xmlns="http://ci.uchicago.edu/swift/2009/02/swiftscript"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  
+  <types>
+     	<type>
+     		<typename>voxelfile</typename>
+     		<typealias>string</typealias>
+     		<typestructure></typestructure>
+     	</type>
+     	<type>
+     		<typename>headerfile</typename>
+     		<typealias>string</typealias>
+     		<typestructure></typestructure>
+     	</type>
+     	<type>
+     		<typename>pgmfile</typename>
+     		<typealias>string</typealias>
+     		<typestructure></typestructure>
+     	</type>
+     	<type>
+     		<typename>imagefile</typename>
+     		<typealias>string</typealias>
+     		<typestructure></typestructure>
+     	</type>
+     	<type>
+     		<typename>warpfile</typename>
+     		<typealias>string</typealias>
+     		<typestructure></typestructure>
+     	</type>
+     	<type>
+     		<typename>volume</typename>
+     		<typealias></typealias>
+     		<typestructure>
+     			    <member>
+     					<membername>img</membername>
+     					<membertype>voxelfile</membertype>
+     				</member>
+     			    <member>
+     					<membername>hdr</membername>
+     					<membertype>headerfile</membertype>
+     				</member>
+     		</typestructure>
+     	</type>   
+  </types>  
+  <procedure name="align_warp">
+
+      <output 
+    name="warp" type="warpfile"
+
+     xsi:nil="true" />
+
+      <input 
+    name="reference" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="subject" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="model" type="string"
+
+     xsi:nil="true" />
+
+      <input 
+    name="quick" type="string"
+
+     xsi:nil="true" />
+    <binding>
+      <application src="line 15">
+        <executable>align_warp</executable>
+        <function name="filename">
+          <structureMember>
+            <variableReference>reference</variableReference>
+            <memberName>img</memberName>
+          </structureMember></function><function name="filename">
+          <structureMember>
+            <variableReference>subject</variableReference>
+            <memberName>img</memberName>
+          </structureMember></function><function name="filename">
+          <variableReference>warp</variableReference></function><stringConstant>-m </stringConstant><variableReference>model</variableReference><variableReference>quick</variableReference>  </application>
+    </binding>
+  </procedure>
+  <procedure name="reslice">
+
+      <output 
+    name="sliced" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="warp" type="warpfile"
+
+     xsi:nil="true" />
+
+      <input 
+    name="subject" type="volume"
+
+     xsi:nil="true" />
+    <binding>
+      <application src="line 22">
+        <executable>reslice</executable>
+        <function name="filename">
+          <variableReference>warp</variableReference></function><function name="filename">
+          <structureMember>
+            <variableReference>sliced</variableReference>
+            <memberName>img</memberName>
+          </structureMember></function>  </application>
+    </binding>
+  </procedure>
+  <procedure name="align_and_reslice">
+
+      <output 
+    name="sliced" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="reference" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="subject" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="model" type="string"
+
+     xsi:nil="true" />
+
+      <input 
+    name="quick" type="string"
+
+     xsi:nil="true" />
+    <variable name="warp" type="warpfile" xsi:nil="true"/>
+    <call proc="align_warp" src="line 29">
+      <output><variableReference>warp</variableReference></output>
+      <input><variableReference>reference</variableReference></input>
+      <input><variableReference>subject</variableReference></input>
+      <input><variableReference>model</variableReference></input>
+      <input><variableReference>quick</variableReference></input>
+    </call>
+    <call proc="reslice" src="line 30">
+      <output><variableReference>sliced</variableReference></output>
+      <input><variableReference>warp</variableReference></input>
+      <input><variableReference>subject</variableReference></input>
+    </call>
+  </procedure>
+  <procedure name="softmean">
+
+      <output 
+    name="atlas" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="sliced" type="volume[]"
+
+     xsi:nil="true" />
+    <binding>
+      <application src="line 36">
+        <executable>softmean</executable>
+        <function name="filename">
+          <structureMember>
+            <variableReference>atlas</variableReference>
+            <memberName>img</memberName>
+          </structureMember></function><stringConstant>y</stringConstant><stringConstant>null</stringConstant><function name="filenames">
+          <structureMember>
+            <arraySubscript>
+             <variableReference>sliced</variableReference>
+             <stringConstant>*</stringConstant>
+            </arraySubscript>
+            <memberName>img</memberName>
+          </structureMember></function>  </application>
+    </binding>
+  </procedure>
+  <procedure name="slicer">
+
+      <output 
+    name="outslice" type="pgmfile"
+
+     xsi:nil="true" />
+
+      <input 
+    name="input" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="axis" type="string"
+
+     xsi:nil="true" />
+
+      <input 
+    name="position" type="string"
+
+     xsi:nil="true" />
+    <binding>
+      <application src="line 44">
+        <executable>slicer</executable>
+        <function name="filename">
+          <structureMember>
+            <variableReference>input</variableReference>
+            <memberName>img</memberName>
+          </structureMember></function><variableReference>axis</variableReference><variableReference>position</variableReference><function name="filename">
+          <variableReference>outslice</variableReference></function>  </application>
+    </binding>
+  </procedure>
+  <procedure name="convert">
+
+      <output 
+    name="outimg" type="imagefile"
+
+     xsi:nil="true" />
+
+      <input 
+    name="inpgm" type="pgmfile"
+
+     xsi:nil="true" />
+    <binding>
+      <application src="line 51">
+        <executable>convert</executable>
+        <function name="filename">
+          <variableReference>inpgm</variableReference></function><function name="filename">
+          <variableReference>outimg</variableReference></function>  </application>
+    </binding>
+  </procedure>
+  <procedure name="slice_to_jpeg">
+
+      <output 
+    name="outimg" type="imagefile"
+
+     xsi:nil="true" />
+
+      <input 
+    name="inp" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="axis" type="string"
+
+     xsi:nil="true" />
+
+      <input 
+    name="position" type="string"
+
+     xsi:nil="true" />
+    <variable name="outslice" type="pgmfile" xsi:nil="true"/>
+    <call proc="slicer" src="line 59">
+      <output><variableReference>outslice</variableReference></output>
+      <input><variableReference>inp</variableReference></input>
+      <input><variableReference>axis</variableReference></input>
+      <input><variableReference>position</variableReference></input>
+    </call>
+    <call proc="convert" src="line 60">
+      <output><variableReference>outimg</variableReference></output>
+      <input><variableReference>outslice</variableReference></input>
+    </call>
+  </procedure>
+  <procedure name="all_align_reslices">
+
+      <output 
+    name="s" type="volume[]"
+
+     xsi:nil="true" />
+
+      <input 
+    name="reference" type="volume"
+
+     xsi:nil="true" />
+
+      <input 
+    name="subjects" type="volume[]"
+
+     xsi:nil="true" />
+    <foreach var="subject"  indexVar="i" src="line 65">
+    <in><variableReference>subjects</variableReference></in>
+    <body><call proc="align_and_reslice" src="line 66">
+        <output><arraySubscript>
+         <variableReference>s</variableReference>
+         <variableReference>i</variableReference>
+        </arraySubscript></output>
+        <input><variableReference>reference</variableReference></input>
+        <input><arraySubscript>
+         <variableReference>subjects</variableReference>
+         <variableReference>i</variableReference>
+        </arraySubscript></input>
+        <input><stringConstant>12</stringConstant></input>
+        <input><stringConstant>-q</stringConstant></input>
+      </call></body>
+    </foreach>
+  </procedure>
+  <variable name="references" type="volume[]">
+    <mapping descriptor="csv_mapper">
+      <param name="file"><stringConstant>reference.csv</stringConstant></param>
+    </mapping>
+  </variable>
+  <variable name="reference" type="volume" xsi:nil="true"/>
+  <assign src="line 75">
+   <variableReference>reference</variableReference>
+   <arraySubscript>
+    <variableReference>references</variableReference>
+    <integerConstant>0</integerConstant>
+   </arraySubscript>
+  </assign>
+  <variable name="subjects" type="volume[]">
+    <mapping descriptor="csv_mapper">
+      <param name="file"><stringConstant>subjects.csv</stringConstant></param>
+    </mapping>
+  </variable>
+  <variable name="slices" type="volume[]">
+    <mapping descriptor="csv_mapper">
+      <param name="file"><stringConstant>slices.csv</stringConstant></param>
+    </mapping>
+  </variable>
+  <call proc="all_align_reslices" src="line 78">
+    <output><variableReference>slices</variableReference></output>
+    <input><variableReference>reference</variableReference></input>
+    <input><variableReference>subjects</variableReference></input>
+  </call>
+  <variable name="atlas" type="volume">
+    <mapping descriptor="simple_mapper">
+      <param name="prefix"><stringConstant>atlas</stringConstant></param>
+    </mapping>
+  </variable>
+  <call proc="softmean" src="line 81">
+    <output><variableReference>atlas</variableReference></output>
+    <input><variableReference>slices</variableReference></input>
+  </call>
+  <variable name="directions" type="string[]" xsi:nil="true"/>
+  <assign src="line 85">
+   <variableReference>directions</variableReference>
+
+     <array>
+       <stringConstant>x</stringConstant><stringConstant>y</stringConstant><stringConstant>z</stringConstant>
+     </array>
+
+  </assign>
+  <foreach var="direction"  src="line 85">
+  <in><variableReference>directions</variableReference></in>
+  <body><variable name="o" type="imagefile">
+      <mapping descriptor="single_file_mapper">
+        <param name="file"><function name="strcat">
+          <stringConstant>atlas-</stringConstant><variableReference>direction</variableReference><stringConstant>.jpeg</stringConstant></function></param>
+      </mapping>
+    </variable>
+    <variable name="option" type="string" xsi:nil="true"/>
+    <assign src="line 88">
+     <variableReference>option</variableReference>
+     <function name="strcat">
+       <stringConstant>-</stringConstant><variableReference>direction</variableReference></function>
+    </assign>
+    <call proc="slice_to_jpeg" src="line 88">
+      <output><variableReference>o</variableReference></output>
+      <input><variableReference>atlas</variableReference></input>
+      <input><variableReference>option</variableReference></input>
+      <input><stringConstant>.5</stringConstant></input>
+    </call></body>
+  </foreach>
+</program>

Added: trunk/tests/language-behaviour/161-star-dot.swift
===================================================================
--- trunk/tests/language-behaviour/161-star-dot.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/161-star-dot.swift	2009-02-14 12:45:50 UTC (rev 2538)
@@ -0,0 +1,36 @@
+type messagefile;
+
+(messagefile t) greeting(string s) { 
+    app {
+        echo s stdout=@filename(t);
+    }
+}
+
+messagefile outfile <"161-star-dot.out">;
+
+type astruct {
+  string a;
+  string b;
+  string c;
+};
+
+astruct foo[];
+
+foo[0].a = "zero-A";
+foo[0].b = "zero-B";
+foo[0].c = "zero-C";
+
+foo[1].a = "one-A";
+foo[1].b = "one-B";
+foo[1].c = "one-C";
+
+foo[2].a = "two-A";
+foo[2].b = "two-B";
+foo[2].c = "two-C";
+
+string s[] = foo[*].c;
+
+string u = s[2];
+
+outfile = greeting(u);
+




More information about the Swift-commit mailing list