[Swift-commit] r7088 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Thu Sep 19 04:12:54 CDT 2013


Author: hategan
Date: 2013-09-19 04:12:50 -0500 (Thu, 19 Sep 2013)
New Revision: 7088

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
Log:
ah, the second argument was not optional because that requires the "name = value" syntax; so use vargs instead

Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java	2013-09-19 08:43:05 UTC (rev 7087)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java	2013-09-19 09:12:50 UTC (rev 7088)
@@ -24,16 +24,14 @@
 import java.util.List;
 import java.util.Map;
 
+import k.rt.Channel;
 import k.rt.ExecutionException;
 import k.rt.Stack;
-import k.thr.LWThread;
 
-import org.globus.cog.karajan.analyzer.ArgRef;
-import org.globus.cog.karajan.analyzer.CompilationException;
+import org.globus.cog.karajan.analyzer.ChannelRef;
 import org.globus.cog.karajan.analyzer.Scope;
 import org.globus.cog.karajan.analyzer.Signature;
 import org.globus.cog.karajan.analyzer.VarRef;
-import org.globus.cog.karajan.parser.WrapperNode;
 import org.griphyn.vdl.karajan.lib.SwiftFunction;
 import org.griphyn.vdl.mapping.AbstractDataNode;
 import org.griphyn.vdl.mapping.DSHandle;
@@ -42,14 +40,13 @@
 
 
 public class FnArg extends SwiftFunction {
-    private ArgRef<AbstractDataNode> name;
-    private ArgRef<AbstractDataNode> value;
+    private ChannelRef<AbstractDataNode> c_vargs;
     
     private VarRef<Map<String, String>> parsedArgs;
     
 	@Override
     protected Signature getSignature() {
-        return new Signature(params("name", optional("value", null)));
+        return new Signature(params("..."));
     }
 
     @Override
@@ -58,12 +55,22 @@
         parsedArgs = scope.getVarRef("SWIFT:PARSED_ARGS");
     }
 
+    @SuppressWarnings("cast")
     @Override
     public Object function(Stack stack) {
 		Map<String, String> args = this.parsedArgs.getValue(stack);
-		AbstractDataNode hname = this.name.getValue(stack);
+		Channel<AbstractDataNode> fargs = c_vargs.get(stack);
+		
+		if (fargs.size() < 1) {
+		    throw new ExecutionException(this, "Missing argument 'name'");
+		}
+		
+        AbstractDataNode hname = (AbstractDataNode) fargs.get(0);
 		hname.waitFor(this);
-		AbstractDataNode hvalue = this.value.getValue(stack);
+		AbstractDataNode hvalue = null;
+		if (fargs.size() == 2) {
+		    hvalue = (AbstractDataNode) fargs.get(1);
+		}
 		if (hvalue != null) {
 		    hvalue.waitFor(this);
 		}




More information about the Swift-commit mailing list