[Swift-commit] r2737 - 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
Mon Mar 23 13:08:14 CDT 2009


Author: benc
Date: 2009-03-23 13:08:07 -0500 (Mon, 23 Mar 2009)
New Revision: 2737

Added:
   trunk/tests/language-behaviour/0191-not-equals.out.expected
   trunk/tests/language-behaviour/0191-not-equals.swift
Modified:
   trunk/libexec/operators.xml
   trunk/resources/Karajan.stg
   trunk/src/org/griphyn/vdl/karajan/lib/Operators.java
Log:
make != operator work

Modified: trunk/libexec/operators.xml
===================================================================
--- trunk/libexec/operators.xml	2009-03-23 17:38:05 UTC (rev 2736)
+++ trunk/libexec/operators.xml	2009-03-23 18:08:07 UTC (rev 2737)
@@ -11,6 +11,7 @@
 	<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="ne"><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>

Modified: trunk/resources/Karajan.stg
===================================================================
--- trunk/resources/Karajan.stg	2009-03-23 17:38:05 UTC (rev 2736)
+++ trunk/resources/Karajan.stg	2009-03-23 18:08:07 UTC (rev 2737)
@@ -412,6 +412,7 @@
   ">":"vdlop:gt",
   "<":"vdlop:lt",
   "==":"vdlop:eq",
+  "!=":"vdlop:ne",
   "&&":"vdlop:and",
   "||":"vdlop:or"
 ]

Modified: trunk/src/org/griphyn/vdl/karajan/lib/Operators.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/Operators.java	2009-03-23 17:38:05 UTC (rev 2736)
+++ trunk/src/org/griphyn/vdl/karajan/lib/Operators.java	2009-03-23 18:08:07 UTC (rev 2737)
@@ -62,7 +62,7 @@
 
 	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_and", "vdlop_or" };
+			"vdlop_remainder", "vdlop_le", "vdlop_ge", "vdlop_lt", "vdlop_gt", "vdlop_eq", "vdlop_ne", "vdlop_and", "vdlop_or" };
 	private static final String[] UNARY_OPERATORS = new String[] { "vdlop_not" };
 
 	private static final Arg[] BINARY_ARGS = new Arg[] { L, R };
@@ -159,6 +159,18 @@
 		return newBool(l.equals(r));
 	}
 
+	public Object vdlop_ne(VariableStack stack) throws ExecutionException {
+		Object l = L.getValue(stack);
+		Object r = R.getValue(stack);
+		if (l == null) {
+			throw new ExecutionException("First operand is null");
+		}
+		if (r == null) {
+			throw new ExecutionException("Second operand is null");
+		}
+		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();

Added: trunk/tests/language-behaviour/0191-not-equals.out.expected
===================================================================
--- trunk/tests/language-behaviour/0191-not-equals.out.expected	                        (rev 0)
+++ trunk/tests/language-behaviour/0191-not-equals.out.expected	2009-03-23 18:08:07 UTC (rev 2737)
@@ -0,0 +1 @@
+true

Added: trunk/tests/language-behaviour/0191-not-equals.swift
===================================================================
--- trunk/tests/language-behaviour/0191-not-equals.swift	                        (rev 0)
+++ trunk/tests/language-behaviour/0191-not-equals.swift	2009-03-23 18:08:07 UTC (rev 2737)
@@ -0,0 +1,14 @@
+type messagefile {}
+
+(messagefile t) greeting(boolean m) { 
+    app {
+        echo m stdout=@filename(t);
+    }
+}
+
+messagefile outfile <"0191-not-equals.out">;
+
+boolean i = 7!=9;
+
+outfile = greeting(i);
+




More information about the Swift-commit mailing list