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

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Jun 6 10:14:51 CDT 2008


Author: benc
Date: 2008-06-06 10:14:50 -0500 (Fri, 06 Jun 2008)
New Revision: 2049

Added:
   trunk/tests/language-behaviour/033-and.ff.out.expected
   trunk/tests/language-behaviour/033-and.ft.out.expected
   trunk/tests/language-behaviour/033-and.swift
   trunk/tests/language-behaviour/033-and.tf.out.expected
   trunk/tests/language-behaviour/033-and.tt.out.expected
   trunk/tests/language-behaviour/034-or.ff.out.expected
   trunk/tests/language-behaviour/034-or.ft.out.expected
   trunk/tests/language-behaviour/034-or.swift
   trunk/tests/language-behaviour/034-or.tf.out.expected
   trunk/tests/language-behaviour/034-or.tt.out.expected
   trunk/tests/language-behaviour/035-not.swift
Modified:
   trunk/libexec/execute-default.k
   trunk/libexec/execute-dryrun.k
   trunk/libexec/operators.xml
   trunk/libexec/vdl-int.k
   trunk/libexec/vdl-lib.xml
   trunk/libexec/vdl.k
   trunk/resources/XDTM.stg
   trunk/src/org/griphyn/vdl/karajan/lib/Operators.java
   trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
Log:
make boolean operators work

Modified: trunk/libexec/execute-default.k
===================================================================
--- trunk/libexec/execute-default.k	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/libexec/execute-default.k	2008-06-06 15:14:50 UTC (rev 2049)
@@ -10,7 +10,7 @@
 	if(
 		derr == false then(
 			if(
-				not(done) try(
+				sys:not(done) try(
 					sequential(
 						echo("{tr} started")
 						log(LOG:INFO, "START thread={#thread} tr={tr}") 

Modified: trunk/libexec/execute-dryrun.k
===================================================================
--- trunk/libexec/execute-dryrun.k	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/libexec/execute-dryrun.k	2008-06-06 15:14:50 UTC (rev 2049)
@@ -3,7 +3,7 @@
 	done := isDone(stageout)
 				
 	if(
-		not(done) sequential(
+		sys:not(done) sequential(
 			mark(stageout, err=false)
 			graphStuff(tr, stagein, stageout, err=false, maybe(args=arguments))
 		)

Modified: trunk/libexec/operators.xml
===================================================================
--- trunk/libexec/operators.xml	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/libexec/operators.xml	2008-06-06 15:14:50 UTC (rev 2049)
@@ -11,5 +11,8 @@
 	<export name="gt"><elementDef classname="org.griphyn.vdl.karajan.lib.Operators"/></export>
 	<export name="lt"><elementDef classname="org.griphyn.vdl.karajan.lib.Operators"/></export>
 	<export name="eq"><elementDef classname="org.griphyn.vdl.karajan.lib.Operators"/></export>
+	<export name="and"><elementDef classname="org.griphyn.vdl.karajan.lib.Operators"/></export>
+	<export name="or"><elementDef classname="org.griphyn.vdl.karajan.lib.Operators"/></export>
+	<export name="not"><elementDef classname="org.griphyn.vdl.karajan.lib.Operators"/></export>
   </namespace>
 </karajan>

Modified: trunk/libexec/vdl-int.k
===================================================================
--- trunk/libexec/vdl-int.k	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/libexec/vdl-int.k	2008-06-06 15:14:50 UTC (rev 2049)
@@ -32,12 +32,12 @@
 		)
 							
 		element(isDone, [stageout]
-			and(
+			sys:and(
 				for(pv, stageout
 					[path, var] := each(pv)
 					vdl:isLogged(var, path)
 				)
-				not(isEmpty(stageout))
+				sys:not(isEmpty(stageout))
 			)
 		)
 			
@@ -320,7 +320,7 @@
 		)
 		
 		element(transferKickstartRec, [rhost, wfdir, jobid, jobdir]
-			if(not(file:exists("{VDL:SCRIPTNAME}-{VDL:RUNID}.d"))
+			if(sys:not(file:exists("{VDL:SCRIPTNAME}-{VDL:RUNID}.d"))
 				task:dir:make("{VDL:SCRIPTNAME}-{VDL:RUNID}.d")
 			)
 			recfile := "{jobid}-kickstart.xml"
@@ -336,7 +336,7 @@
 		)
 
 		element(transferWrapperLog, [rhost, wfdir, jobid, jobdir]
-			if(not(file:exists("{VDL:SCRIPTNAME}-{VDL:RUNID}.d"))
+			if(sys:not(file:exists("{VDL:SCRIPTNAME}-{VDL:RUNID}.d"))
 				task:dir:make("{VDL:SCRIPTNAME}-{VDL:RUNID}.d")
 			)
 			recfile := "{jobid}-info"

Modified: trunk/libexec/vdl-lib.xml
===================================================================
--- trunk/libexec/vdl-lib.xml	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/libexec/vdl-lib.xml	2008-06-06 15:14:50 UTC (rev 2049)
@@ -14,10 +14,10 @@
 	<export name="arg">
 		<import file="sys.xml"/>
 		<if>
-			<or>
+			<sys:or>
 				<equals value1="${vdl:operation}" value2="typecheck"/>
 				<equals value1="${vdl:operation}" value2="graph"/>
-			</or>
+			</sys:or>
 			<element arguments="name"><string></string></element>
 			<elementDef classname="org.griphyn.vdl.karajan.lib.swiftscript.FnArg"/>
 		</if>

Modified: trunk/libexec/vdl.k
===================================================================
--- trunk/libexec/vdl.k	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/libexec/vdl.k	2008-06-06 15:14:50 UTC (rev 2049)
@@ -131,7 +131,7 @@
 
 			//this should be reached after everything is done
 			if(
-				not(anyerrors) then(
+				sys:not(anyerrors) then(
 					//hmm, you can append to channels!
 					append(warnings, from(warnings, cleanups(cleanup)))
 				)

Modified: trunk/resources/XDTM.stg
===================================================================
--- trunk/resources/XDTM.stg	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/resources/XDTM.stg	2008-06-06 15:14:50 UTC (rev 2049)
@@ -293,9 +293,19 @@
 </cond>
 >>
 
-and(left,right,sourcelocation) ::= "<and><left>$left$</left><right>$right$</right></and>"
+and(left,right,sourcelocation) ::= <<
+<and>
+  $left$
+  $right$
+</and>
+>>
 
-or(left, right,sourcelocation) ::= "<or><left>$left$</left><right>$right$</right></or>"
+or(left, right,sourcelocation) ::= <<
+<or>
+  $left$
+  $right$
+</or>
+>>
 
 not(exp,sourcelocation) ::= "<not>$exp$</not>"
 

Modified: trunk/src/org/griphyn/vdl/karajan/lib/Operators.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Operators.java	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Operators.java	2008-06-06 15:14:50 UTC (rev 2049)
@@ -15,6 +15,7 @@
 
 	public static final SwiftArg L = new SwiftArg.Positional("left");
 	public static final SwiftArg R = new SwiftArg.Positional("right");
+	public static final SwiftArg U = new SwiftArg.Positional("unaryArg");
 
 	private DSHandle newNum(Type type, double value) throws ExecutionException {
 		try {
@@ -61,16 +62,21 @@
 		}
 	}
 
-	private static final String[] OPERATORS = new String[] { "vdlop_sum", "vdlop_subtraction",
+	private static final String[] BINARY_OPERATORS = new String[] { "vdlop_sum", "vdlop_subtraction",
 			"vdlop_product", "vdlop_quotient", "vdlop_fquotient", "vdlop_iquotient",
-			"vdlop_remainder", "vdlop_le", "vdlop_ge", "vdlop_lt", "vdlop_gt", "vdlop_eq" };
+			"vdlop_remainder", "vdlop_le", "vdlop_ge", "vdlop_lt", "vdlop_gt", "vdlop_eq", "vdlop_and", "vdlop_or" };
+	private static final String[] UNARY_OPERATORS = new String[] { "vdlop_not" };
 
-	private static final Arg[] OPARGS = new Arg[] { L, R };
+	private static final Arg[] BINARY_ARGS = new Arg[] { L, R };
+	private static final Arg[] UNARY_ARGS = new Arg[] { U };
 
 	static {
-		for (int i = 0; i < OPERATORS.length; i++) {
-			setArguments(OPERATORS[i], OPARGS);
+		for (int i = 0; i < BINARY_OPERATORS.length; i++) {
+			setArguments(BINARY_OPERATORS[i], BINARY_ARGS);
 		}
+		for (int i = 0; i < UNARY_OPERATORS.length; i++) {
+			setArguments(UNARY_OPERATORS[i], UNARY_ARGS);
+		}
 	}
 
 	public Object vdlop_sum(VariableStack stack) throws ExecutionException {
@@ -154,4 +160,21 @@
 		}
 		return newBool(l.equals(r));
 	}
+
+	public Object vdlop_and(VariableStack stack) throws ExecutionException {
+		boolean l = ((Boolean)L.getValue(stack)).booleanValue();
+		boolean r = ((Boolean)R.getValue(stack)).booleanValue();
+		return newBool(l && r);
+	}
+
+	public Object vdlop_or(VariableStack stack) throws ExecutionException {
+		boolean l = ((Boolean)L.getValue(stack)).booleanValue();
+		boolean r = ((Boolean)R.getValue(stack)).booleanValue();
+		return newBool(l || r);
+	}
+
+	public Object vdlop_not(VariableStack stack) throws ExecutionException {
+		boolean u = ((Boolean)U.getValue(stack)).booleanValue();
+		return newBool(!u);
+	}
 }

Modified: trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2008-06-06 14:06:42 UTC (rev 2048)
+++ trunk/src/org/griphyn/vdl/karajan/lib/VDLFunction.java	2008-06-06 15:14:50 UTC (rev 2049)
@@ -160,6 +160,9 @@
 		else if (Types.INT.equals(type)) {
 			return new Double(TypeUtil.toInt(value));
 		}
+		else if (Types.BOOLEAN.equals(type)) {
+			return new Boolean(TypeUtil.toBoolean(value));
+		}
 		else if (value instanceof String) {
 			return (String) value;
 		}

Added: trunk/tests/language-behaviour/033-and.ff.out.expected
===================================================================
--- trunk/tests/language-behaviour/033-and.ff.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/033-and.ff.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+false

Added: trunk/tests/language-behaviour/033-and.ft.out.expected
===================================================================
--- trunk/tests/language-behaviour/033-and.ft.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/033-and.ft.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+false

Added: trunk/tests/language-behaviour/033-and.swift
===================================================================
--- trunk/tests/language-behaviour/033-and.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/033-and.swift	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1,18 @@
+type messagefile;
+
+(messagefile t) p(boolean b) { 
+    app {
+        echo b stdout=@filename(t);
+    }
+}
+
+messagefile fffile <"033-and.ff.out">;
+messagefile ftfile <"033-and.ft.out">;
+messagefile tffile <"033-and.tf.out">;
+messagefile ttfile <"033-and.tt.out">;
+
+fffile = p(false && false);
+ftfile = p(false && true);
+tffile = p(true && false);
+ttfile = p(true && true);
+

Added: trunk/tests/language-behaviour/033-and.tf.out.expected
===================================================================
--- trunk/tests/language-behaviour/033-and.tf.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/033-and.tf.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+false

Added: trunk/tests/language-behaviour/033-and.tt.out.expected
===================================================================
--- trunk/tests/language-behaviour/033-and.tt.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/033-and.tt.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+true

Added: trunk/tests/language-behaviour/034-or.ff.out.expected
===================================================================
--- trunk/tests/language-behaviour/034-or.ff.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/034-or.ff.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+false

Added: trunk/tests/language-behaviour/034-or.ft.out.expected
===================================================================
--- trunk/tests/language-behaviour/034-or.ft.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/034-or.ft.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+true

Added: trunk/tests/language-behaviour/034-or.swift
===================================================================
--- trunk/tests/language-behaviour/034-or.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/034-or.swift	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1,18 @@
+type messagefile;
+
+(messagefile t) p(boolean b) { 
+    app {
+        echo b stdout=@filename(t);
+    }
+}
+
+messagefile fffile <"034-or.ff.out">;
+messagefile ftfile <"034-or.ft.out">;
+messagefile tffile <"034-or.tf.out">;
+messagefile ttfile <"034-or.tt.out">;
+
+fffile = p(false || false);
+ftfile = p(false || true);
+tffile = p(true || false);
+ttfile = p(true || true);
+

Added: trunk/tests/language-behaviour/034-or.tf.out.expected
===================================================================
--- trunk/tests/language-behaviour/034-or.tf.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/034-or.tf.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+true

Added: trunk/tests/language-behaviour/034-or.tt.out.expected
===================================================================
--- trunk/tests/language-behaviour/034-or.tt.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/034-or.tt.out.expected	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1 @@
+true

Added: trunk/tests/language-behaviour/035-not.swift
===================================================================
--- trunk/tests/language-behaviour/035-not.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/035-not.swift	2008-06-06 15:14:50 UTC (rev 2049)
@@ -0,0 +1,14 @@
+type messagefile;
+
+(messagefile t) p(boolean b) { 
+    app {
+        echo b stdout=@filename(t);
+    }
+}
+
+messagefile tfile <"035-not.t.out">;
+messagefile ffile <"035-not.f.out">;
+
+tfile = p(!true);
+ffile = p(!false);
+




More information about the Swift-commit mailing list