[Swift-commit] r7782 - in branches/release-0.95/src/org/griphyn/vdl: karajan/lib karajan/lib/swiftscript mapping
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Sat Apr 19 14:30:29 CDT 2014
Author: hategan
Date: 2014-04-19 14:30:28 -0500 (Sat, 19 Apr 2014)
New Revision: 7782
Added:
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java
Modified:
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
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
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java
branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
branches/release-0.95/src/org/griphyn/vdl/mapping/RootDataNode.java
Log:
fixed (to some extent) the lazy errors not propagating through built-in functions issue (0.95 version)
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SetFieldValue.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -45,6 +45,8 @@
import org.griphyn.vdl.karajan.WaitingThreadsMonitor;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.Mapper;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.type.Type;
@@ -188,7 +190,13 @@
protected void deepCopy(DSHandle dest, DSHandle source, Stack stack) {
// don't create a state if only a non-composite is copied
- ((AbstractDataNode) source).waitFor(this);
+ try {
+ ((AbstractDataNode) source).waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return;
+ }
if (source.getType().isPrimitive()) {
dest.setValue(source.getValue());
}
@@ -208,7 +216,13 @@
/** make dest look like source - if its a simple value, copy that
and if its an array then recursively copy */
public void deepCopy(DSHandle dest, DSHandle source, State state, int level) {
- ((AbstractDataNode) source).waitFor(this);
+ try {
+ ((AbstractDataNode) source).waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return;
+ }
if (source.getType().isPrimitive()) {
dest.setValue(source.getValue());
}
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SwiftFunction.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -52,6 +52,7 @@
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.GeneralizedFileFormat;
import org.griphyn.vdl.mapping.HandleOpenException;
@@ -60,6 +61,7 @@
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PathComparator;
import org.griphyn.vdl.mapping.PhysicalFormat;
+import org.griphyn.vdl.mapping.RootDataNode;
import org.griphyn.vdl.mapping.RootHandle;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -103,8 +105,8 @@
@Override
public void runBody(LWThread thr) {
+ Stack stack = thr.getStack();
try {
- Stack stack = thr.getStack();
ret(stack, function(stack));
}
catch (AssertFailedException e) {
@@ -112,11 +114,15 @@
throw e;
}
catch (DependentException e) {
- // This would not be the primal fault so in non-lazy errors mode it
- // should not matter
- throw new ExecutionException("Wrapping a dependent exception in VDLFunction.post() - errors in data dependencies",e);
+ RootDataNode rdn = new RootDataNode(getReturnType());
+ rdn.setValue(new DataDependentException(rdn, e));
+ ret(stack, rdn);
}
}
+
+ protected Type getReturnType() {
+ return Types.ANY;
+ }
/*
* This will likely break if the engine changes in fundamental ways. It also
Added: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java (rev 0)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/AbstractSingleValuedSwiftFunction.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -0,0 +1,40 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Apr 18, 2014
+ */
+package org.griphyn.vdl.karajan.lib.swiftscript;
+
+import k.rt.Stack;
+import k.thr.LWThread;
+
+import org.globus.cog.karajan.compiled.nodes.functions.AbstractSingleValuedFunction;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
+import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.type.Type;
+import org.griphyn.vdl.type.Types;
+
+public abstract class AbstractSingleValuedSwiftFunction extends AbstractSingleValuedFunction {
+
+ @Override
+ public void runBody(LWThread thr) {
+ Stack stack = thr.getStack();
+ try {
+ ret(stack, function(stack));
+ }
+ catch (DependentException e) {
+ RootDataNode rdn = new RootDataNode(getReturnType());
+ rdn.setValue(new DataDependentException(rdn, e));
+ ret(stack, rdn);
+ }
+ }
+
+ protected Type getReturnType() {
+ return Types.ANY;
+ }
+}
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -28,6 +28,7 @@
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.type.Types;
/**
@@ -59,17 +60,22 @@
}
String message;
- if (hmessage != null) {
- hmessage.waitFor(this);
- message = (String) hmessage.getValue();
+ try {
+ if (hmessage != null) {
+ hmessage.waitFor(this);
+ message = (String) hmessage.getValue();
+ }
+ else {
+ message = "Assertion failed";
+ }
+ AbstractDataNode hvalue = fargs.get(0);
+ hvalue.waitFor(this);
+
+ checkAssert(hvalue, message);
}
- else {
- message = "Assertion failed";
+ catch (DependentException e) {
+ // cannot make assertion so ignore
}
- AbstractDataNode hvalue = fargs.get(0);
- hvalue.waitFor(this);
-
- checkAssert(hvalue, message);
return null;
}
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractFloat.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -31,6 +31,7 @@
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -41,6 +42,11 @@
protected Signature getSignature() {
return new Signature(params("var"));
}
+
+ @Override
+ protected Type getReturnType() {
+ return Types.FLOAT;
+ }
@Override
public Object function(Stack stack) {
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ExtractInt.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -31,6 +31,7 @@
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -43,6 +44,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.INT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode handle = this.var.getValue(stack);
try {
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-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileName.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -25,6 +25,7 @@
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
public class FileName extends SwiftFunction {
@@ -34,6 +35,11 @@
protected Signature getSignature() {
return new Signature(params("var"));
}
+
+ @Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
@Override
public Object function(Stack stack) {
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-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FileNames.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -31,6 +31,7 @@
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.RootArrayDataNode;
+import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
public class FileNames extends SwiftFunction {
@@ -40,6 +41,11 @@
protected Signature getSignature() {
return new Signature(params("var"));
}
+
+ @Override
+ protected Type getReturnType() {
+ return Types.STRING.arrayType();
+ }
@Override
public Object function(Stack stack) {
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/FnArg.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -36,6 +36,7 @@
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -48,6 +49,11 @@
protected Signature getSignature() {
return new Signature(params("..."));
}
+
+ @Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
@Override
protected void addLocals(Scope scope) {
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Fprintf.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -31,6 +31,7 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbstractDataNode;
+import org.griphyn.vdl.mapping.DependentException;
/**
Formatted file output. <br>
@@ -57,24 +58,29 @@
public Object function(Stack stack) {
AbstractDataNode hfilename = this.filename.getValue(stack);
AbstractDataNode hspec = this.spec.getValue(stack);
- hfilename.waitFor(this);
- hspec.waitFor(this);
- Channel<AbstractDataNode> args = c_vargs.get(stack);
- waitForAll(this, args);
- String filename = (String) hfilename.getValue();
- String spec = (String) hspec.getValue();
-
- StringBuilder output = new StringBuilder();
try {
- Sprintf.format(spec, args, output);
+ hfilename.waitFor(this);
+ hspec.waitFor(this);
+ Channel<AbstractDataNode> args = c_vargs.get(stack);
+ waitForAll(this, args);
+ String filename = (String) hfilename.getValue();
+ String spec = (String) hspec.getValue();
+
+ StringBuilder output = new StringBuilder();
+ try {
+ Sprintf.format(spec, args, output);
+ }
+ catch (RuntimeException e) {
+ throw new ExecutionException(this, e.getMessage());
+ }
+ String msg = output.toString();
+
+ logger.debug("file: " + filename + " msg: " + msg);
+ write(filename, msg);
}
- catch (RuntimeException e) {
- throw new ExecutionException(this, e.getMessage());
+ catch (DependentException e) {
+ logger.debug("<exception>");
}
- String msg = output.toString();
-
- logger.debug("file: " + filename + " msg: " + msg);
- write(filename, msg);
return null;
}
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Misc.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -32,14 +32,15 @@
import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.globus.cog.karajan.compiled.nodes.InternalFunction;
-import org.globus.cog.karajan.compiled.nodes.functions.AbstractSingleValuedFunction;
import org.globus.cog.karajan.util.TypeUtil;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.RootArrayDataNode;
import org.griphyn.vdl.mapping.RootDataNode;
+import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
import org.griphyn.vdl.util.VDL2Config;
@@ -73,22 +74,26 @@
@Override
protected void runBody(LWThread thr) {
Channel<AbstractDataNode> vargs = c_vargs.get(thr.getStack());
- SwiftFunction.waitForAll(this, vargs);
-
- StringBuilder buf = new StringBuilder();
- buf.append("SwiftScript trace: ");
- boolean first = true;
- for (AbstractDataNode n : vargs) {
- if (!first) {
- buf.append(", ");
+ try {
+ SwiftFunction.waitForAll(this, vargs);
+ StringBuilder buf = new StringBuilder();
+ buf.append("SwiftScript trace: ");
+ boolean first = true;
+ for (AbstractDataNode n : vargs) {
+ if (!first) {
+ buf.append(", ");
+ }
+ else {
+ first = false;
+ }
+ //buf.append(v == null ? args[i] : v);
+ prettyPrint(buf, n);
}
- else {
- first = false;
- }
- //buf.append(v == null ? args[i] : v);
- prettyPrint(buf, n);
- }
- traceLogger.warn(buf);
+ traceLogger.warn(buf);
+ }
+ catch (DependentException e) {
+ traceLogger.warn("<exception>");
+ }
}
}
@@ -128,7 +133,7 @@
}
}
- public static class StrCat extends AbstractSingleValuedFunction {
+ public static class StrCat extends AbstractSingleValuedSwiftFunction {
private ChannelRef<AbstractDataNode> c_vargs;
@Override
@@ -137,6 +142,13 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+
+
+ @Override
public Object function(Stack stack) {
Channel<AbstractDataNode> vargs = c_vargs.get(stack);
Channel<Object> args = SwiftFunction.unwrapAll(this, vargs);
@@ -161,7 +173,7 @@
}
}
- public static class Exists extends AbstractSingleValuedFunction {
+ public static class Exists extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> file;
@Override
@@ -170,6 +182,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.BOOLEAN;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode dn = file.getValue(stack);
String filename = SwiftFunction.unwrap(this, dn);
@@ -190,7 +207,7 @@
}
}
- public static class StrCut extends AbstractSingleValuedFunction {
+ public static class StrCut extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
@@ -200,6 +217,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -238,7 +260,7 @@
}
}
- public static class StrStr extends AbstractSingleValuedFunction {
+ public static class StrStr extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
@@ -248,6 +270,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -271,7 +298,7 @@
}
}
- public static class StrSplit extends AbstractSingleValuedFunction {
+ public static class StrSplit extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
@@ -281,6 +308,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING.arrayType();
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -318,7 +350,7 @@
* @return DSHandle representing the resulting string
* @throws ExecutionException
*/
- public static class StrJoin extends AbstractSingleValuedFunction {
+ public static class StrJoin extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> array;
private ArgRef<AbstractDataNode> delim;
@@ -328,6 +360,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode harray = this.array.getValue(stack);
Map<Comparable<?>, DSHandle> arrayValues = SwiftFunction.waitForArray(this, harray);
@@ -359,7 +396,7 @@
}
}
- public static class Regexp extends AbstractSingleValuedFunction {
+ public static class Regexp extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> input;
private ArgRef<AbstractDataNode> pattern;
private ArgRef<AbstractDataNode> transform;
@@ -370,6 +407,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hinput = this.input.getValue(stack);
String input = SwiftFunction.unwrap(this, hinput);
@@ -410,7 +452,7 @@
}
}
- public static class ToInt extends AbstractSingleValuedFunction {
+ public static class ToInt extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> str;
@Override
@@ -419,6 +461,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.INT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hstr = str.getValue(stack);
String str = SwiftFunction.unwrap(this, hstr);
@@ -435,7 +482,7 @@
}
}
- public static class ToFloat extends AbstractSingleValuedFunction {
+ public static class ToFloat extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> str;
@Override
@@ -444,6 +491,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.FLOAT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hstr = str.getValue(stack);
Object obj = SwiftFunction.unwrap(this, hstr);
@@ -474,7 +526,7 @@
/*
* Takes in a float and formats to desired precision and returns a string
*/
- public static class Format extends AbstractSingleValuedFunction {
+ public static class Format extends AbstractSingleValuedSwiftFunction {
private ChannelRef<AbstractDataNode> c_vargs;
@Override
@@ -483,6 +535,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
Channel<AbstractDataNode> vargs = c_vargs.get(stack);
Channel<Object> args = SwiftFunction.unwrapAll(this, vargs);
@@ -507,7 +564,7 @@
/*
* Takes in an int and pads zeros to the left and returns a string
*/
- public static class Pad extends AbstractSingleValuedFunction {
+ public static class Pad extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> size;
private ArgRef<AbstractDataNode> value;
@@ -517,6 +574,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hsize = this.size.getValue(stack);
Integer size = SwiftFunction.unwrap(this, hsize);
@@ -536,7 +598,7 @@
}
}
- public static class ToString extends AbstractSingleValuedFunction {
+ public static class ToString extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> value;
@Override
@@ -545,6 +607,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode hvalue = this.value.getValue(stack);
hvalue.waitFor(this);
@@ -570,7 +637,7 @@
* Good for debugging because array needs to be closed
* before the length is determined
*/
- public static class Dirname extends AbstractSingleValuedFunction {
+ public static class Dirname extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> file;
@Override
@@ -579,6 +646,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.STRING;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode dn = file.getValue(stack);
String name = SwiftFunction.filename(dn)[0];
@@ -596,7 +668,7 @@
}
}
- public static class Length extends AbstractSingleValuedFunction {
+ public static class Length extends AbstractSingleValuedSwiftFunction {
private ArgRef<AbstractDataNode> array;
@Override
@@ -605,6 +677,11 @@
}
@Override
+ protected Type getReturnType() {
+ return Types.INT;
+ }
+
+ @Override
public Object function(Stack stack) {
AbstractDataNode harray = this.array.getValue(stack);
harray.waitFor(this);
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadData.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -38,6 +38,8 @@
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.PhysicalFormat;
import org.griphyn.vdl.type.Type;
import org.griphyn.vdl.type.Types;
@@ -59,7 +61,13 @@
public Object function(Stack stack) {
AbstractDataNode dest = this.dest.getValue(stack);
AbstractDataNode src = this.src.getValue(stack);
- src.waitFor(this);
+ try {
+ src.waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return null;
+ }
if (src.getType().equals(Types.STRING)) {
readData(dest, (String) src.getValue());
}
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/ReadStructured.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -35,6 +35,8 @@
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
import org.griphyn.vdl.type.Types;
@@ -57,7 +59,13 @@
public Object function(Stack stack) {
AbstractDataNode dest = this.dest.getValue(stack);
AbstractDataNode src = this.src.getValue(stack);
- src.waitFor(this);
+ try {
+ src.waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return null;
+ }
if (src.getType().equals(Types.STRING)) {
readData(dest, (String) src.getValue());
dest.closeDeep();
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/Tracef.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -26,6 +26,7 @@
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
import org.griphyn.vdl.mapping.AbstractDataNode;
+import org.griphyn.vdl.mapping.DependentException;
/**
Formatted trace output. <br>
@@ -52,12 +53,18 @@
@Override
public Object function(Stack stack) {
AbstractDataNode hspec = this.spec.getValue(stack);
- hspec.waitFor(this);
- Channel<AbstractDataNode> args = c_vargs.get(stack);
- waitForAll(this, args);
- String spec = (String) hspec.getValue();
-
- String msg = Sprintf.format(spec, args);
+ String msg;
+ try {
+ hspec.waitFor(this);
+ Channel<AbstractDataNode> args = c_vargs.get(stack);
+ waitForAll(this, args);
+ String spec = (String) hspec.getValue();
+
+ msg = Sprintf.format(spec, args);
+ }
+ catch (DependentException e) {
+ msg = "<exception>";
+ }
logger.info(msg);
System.out.print(msg);
return null;
Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/swiftscript/WriteData.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -34,6 +34,8 @@
import org.griphyn.vdl.mapping.AbsFile;
import org.griphyn.vdl.mapping.AbstractDataNode;
import org.griphyn.vdl.mapping.DSHandle;
+import org.griphyn.vdl.mapping.DataDependentException;
+import org.griphyn.vdl.mapping.DependentException;
import org.griphyn.vdl.mapping.InvalidPathException;
import org.griphyn.vdl.mapping.Path;
import org.griphyn.vdl.mapping.PhysicalFormat;
@@ -62,7 +64,13 @@
// src can be any of several forms of value
AbstractDataNode src = this.src.getValue(stack);
- src.waitFor(this);
+ try {
+ src.waitFor(this);
+ }
+ catch (DependentException e) {
+ dest.setValue(new DataDependentException(dest, e));
+ return null;
+ }
if (dest.getType().equals(Types.STRING)) {
writeData((String)dest.getValue(), src);
Modified: branches/release-0.95/src/org/griphyn/vdl/mapping/RootDataNode.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/mapping/RootDataNode.java 2014-04-18 21:32:30 UTC (rev 7781)
+++ branches/release-0.95/src/org/griphyn/vdl/mapping/RootDataNode.java 2014-04-19 19:30:28 UTC (rev 7782)
@@ -54,6 +54,10 @@
this("?", type, value);
}
+ public RootDataNode(Type type) {
+ this("?", type, null);
+ }
+
public RootDataNode(String name, Type type) {
this(name, type, null);
}
@@ -64,7 +68,7 @@
setValue(value);
}
- public int getLine() {
+ public int getLine() {
return line;
}
More information about the Swift-commit
mailing list