[Swift-commit] r8348 - branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Sat Dec 13 15:48:36 CST 2014


Author: hategan
Date: 2014-12-13 15:48:36 -0600 (Sat, 13 Dec 2014)
New Revision: 8348

Modified:
   branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
   branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java
Log:
made filename() and filenames() context aware so that remote path translation is only done if invoked from an app body

Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java	2014-12-13 21:37:44 UTC (rev 8347)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java	2014-12-13 21:48:36 UTC (rev 8348)
@@ -20,7 +20,11 @@
 import k.rt.Stack;
 
 import org.globus.cog.karajan.analyzer.ArgRef;
+import org.globus.cog.karajan.analyzer.CompilationException;
+import org.globus.cog.karajan.analyzer.Scope;
 import org.globus.cog.karajan.analyzer.Signature;
+import org.globus.cog.karajan.compiled.nodes.Node;
+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;
@@ -30,6 +34,17 @@
 
 public class FileName extends SwiftFunction {
 	private ArgRef<AbstractDataNode> var;
+	private boolean inAppInvocation;
+    
+    @Override
+    public Node compile(WrapperNode w, Scope scope) throws CompilationException {        
+        Node self = super.compile(w, scope);
+        // either execute(arguments(this)) or execute(named(stdxxx, this))
+        if (hasAncestor(this, "swift:execute")) {
+            inAppInvocation = true;
+        }
+        return self;
+    }
 
     @Override
     protected Signature getSignature() {
@@ -44,7 +59,7 @@
     @Override
 	public Object function(Stack stack) {
         AbstractDataNode var = this.var.getValue(stack); 
-		String s = argList(filename(var), true);
+		String s = argList(filename(var), inAppInvocation);
 		DSHandle result = new RootDataNode(Types.STRING, s);
 		if (PROVENANCE_ENABLED) {
 		    int provid = SwiftFunction.nextProvenanceID();

Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java	2014-12-13 21:37:44 UTC (rev 8347)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java	2014-12-13 21:48:36 UTC (rev 8348)
@@ -24,7 +24,11 @@
 import k.rt.Stack;
 
 import org.globus.cog.karajan.analyzer.ArgRef;
+import org.globus.cog.karajan.analyzer.CompilationException;
+import org.globus.cog.karajan.analyzer.Scope;
 import org.globus.cog.karajan.analyzer.Signature;
+import org.globus.cog.karajan.compiled.nodes.Node;
+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;
@@ -36,6 +40,17 @@
 
 public class FileNames extends SwiftFunction {
 	private ArgRef<AbstractDataNode> var;
+	private boolean inAppInvocation;
+    
+    @Override
+    public Node compile(WrapperNode w, Scope scope) throws CompilationException {        
+        Node self = super.compile(w, scope);
+        // either execute(arguments(this)) or execute(named(stdxxx, this)) 
+        if (hasAncestor(this, "swift:execute")) {
+            inAppInvocation = true;
+        }
+        return self;
+    }
 
     @Override
     protected Signature getSignature() {
@@ -56,7 +71,12 @@
 			for (int i = 0; i < f.length; i++) {
 				Path p = parsePath("["+i+"]");
 				DSHandle h = returnArray.getField(p);
-				h.setValue(relativize(f[i]));
+				if (inAppInvocation) {
+				    h.setValue(relativize(f[i]));
+				}
+				else {
+				    h.setValue(f[i]);
+				}
 			}
 		} catch (InvalidPathException e) {
 			throw new ExecutionException("Unexpected invalid path exception",e);




More information about the Swift-commit mailing list