[Swift-commit] r7097 - trunk/src/org/griphyn/vdl/karajan/lib/swiftscript
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Sat Sep 21 23:05:10 CDT 2013
Author: hategan
Date: 2013-09-21 23:05:10 -0500 (Sat, 21 Sep 2013)
New Revision: 7097
Modified:
trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
Log:
fixed assert
Modified: trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2013-09-22 03:29:22 UTC (rev 7096)
+++ trunk/src/org/griphyn/vdl/karajan/lib/swiftscript/Assert.java 2013-09-22 04:05:10 UTC (rev 7097)
@@ -18,10 +18,11 @@
package org.griphyn.vdl.karajan.lib.swiftscript;
// import org.apache.log4j.Logger;
+import k.rt.Channel;
import k.rt.ExecutionException;
import k.rt.Stack;
-import org.globus.cog.karajan.analyzer.ArgRef;
+import org.globus.cog.karajan.analyzer.ChannelRef;
import org.globus.cog.karajan.analyzer.Signature;
import org.griphyn.vdl.karajan.AssertFailedException;
import org.griphyn.vdl.karajan.lib.SwiftFunction;
@@ -34,17 +35,29 @@
Optional second argument is string message printed on failure.
*/
public class Assert extends SwiftFunction {
- private ArgRef<AbstractDataNode> value;
- private ArgRef<AbstractDataNode> message;
-
+ private ChannelRef<AbstractDataNode> c_vargs;
+
@Override
protected Signature getSignature() {
- return new Signature(params("value", "message"));
+ return new Signature(params("..."));
}
@Override
public Object function(Stack stack) {
- AbstractDataNode hmessage = this.message.getValue(stack);
+ Channel<AbstractDataNode> fargs = c_vargs.get(stack);
+
+ if (fargs.size() < 1) {
+ throw new ExecutionException(this, "Missing condition");
+ }
+ if (fargs.size() > 2) {
+ throw new ExecutionException(this, "Too many arguments");
+ }
+
+ AbstractDataNode hmessage = null;
+ if (fargs.size() == 2) {
+ hmessage = fargs.get(1);
+ }
+
String message;
if (hmessage != null) {
hmessage.waitFor(this);
@@ -53,7 +66,7 @@
else {
message = "Assertion failed";
}
- AbstractDataNode hvalue = this.value.getValue(stack);
+ AbstractDataNode hvalue = fargs.get(0);
hvalue.waitFor(this);
checkAssert(hvalue, message);
More information about the Swift-commit
mailing list