changeset 16906:8eca9a00aaba

Truffle-DSL: Fixed guard matching for operations that use short circuits without boolean in the type system.
author Christian Humer <christian.humer@gmail.com>
date Sat, 23 Aug 2014 19:31:01 +0200
parents a85d43d86ea1
children 09d99d3c0c95
files graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/GuardParser.java
diffstat 2 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java	Sat Aug 23 16:55:56 2014 +0200
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/ShortCircuitTest.java	Sat Aug 23 19:31:01 2014 +0200
@@ -106,6 +106,26 @@
 
     }
 
+    @NodeChildren({@NodeChild("child0"), @NodeChild("child1")})
+    @SuppressWarnings("unused")
+    abstract static class GuardChildNode extends ValueNode {
+
+        @ShortCircuit("child1")
+        boolean needsChild1(Object a) {
+            return a.equals(new Integer(42));
+        }
+
+        static boolean guard(int a, boolean hasB, int b) {
+            return false;
+        }
+
+        @Specialization(guards = "guard")
+        int doIt(int a, boolean hasB, int b) {
+            return a + b;
+        }
+
+    }
+
     @Test
     public void testVarArgs1() {
         ArgumentNode arg0 = new ArgumentNode(0);
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/GuardParser.java	Sat Aug 23 16:55:56 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/GuardParser.java	Sat Aug 23 19:31:01 2014 +0200
@@ -79,7 +79,9 @@
         for (TypeMirror typeMirror : typeMirrors) {
             typeIds.add(ElementUtils.getUniqueIdentifier(typeMirror));
         }
-        typeIds.retainAll(getTypeSystem().getTypeIdentifiers());
+        if (parameter.getSpecification().isSignature()) {
+            typeIds.retainAll(getTypeSystem().getTypeIdentifiers());
+        }
 
         return new ParameterSpec(parameter.getSpecification(), typeMirrors, typeIds);
     }