changeset 13533:b466199f19e1

Truffle-DSL: fixed bug when using @CreateCast with children arrays.
author Christian Humer <christian.humer@gmail.com>
date Tue, 07 Jan 2014 20:16:01 +0100
parents 85b485b1e8e1
children dbc17f07cec6
files graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CreateCastTest.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/CreateCastParser.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/ParameterSpec.java
diffstat 4 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CreateCastTest.java	Tue Jan 07 20:06:27 2014 +0100
+++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CreateCastTest.java	Tue Jan 07 20:16:01 2014 +0100
@@ -28,6 +28,7 @@
 import com.oracle.truffle.api.dsl.test.CreateCastTestFactory.CreateCastNode1Factory;
 import com.oracle.truffle.api.dsl.test.CreateCastTestFactory.CreateCastNode2Factory;
 import com.oracle.truffle.api.dsl.test.CreateCastTestFactory.CreateCastNode3Factory;
+import com.oracle.truffle.api.dsl.test.TypeSystemTest.ChildrenNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
 import com.oracle.truffle.api.nodes.*;
@@ -87,12 +88,11 @@
         }
     }
 
-    @NodeChild(value = "a", type = ValueNode[].class)
-    abstract static class CreateCastNode3 extends ValueNode {
+    abstract static class CreateCastNode3 extends ChildrenNode {
 
         int invocations = 0;
 
-        @CreateCast("a")
+        @CreateCast("children")
         public ValueNode[] createCast(ValueNode[] node) {
             invocations++;
             return node;
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/CreateCastParser.java	Tue Jan 07 20:06:27 2014 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/CreateCastParser.java	Tue Jan 07 20:16:01 2014 +0100
@@ -60,7 +60,9 @@
 
         MethodSpec spec = new MethodSpec(new InheritsParameterSpec(getContext(), "child", baseType));
         addDefaultFieldMethodSpec(spec);
-        spec.addRequired(new ParameterSpec("castedChild", baseType));
+        ParameterSpec childSpec = new ParameterSpec("castedChild", baseType);
+        childSpec.setSignature(true);
+        spec.addRequired(childSpec);
         return spec;
     }
 
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Tue Jan 07 20:06:27 2014 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java	Tue Jan 07 20:16:01 2014 +0100
@@ -1160,11 +1160,10 @@
             }
 
             for (VariableElement var : type.getFields()) {
-                NodeExecutionData execution = node.findExecution(var.getSimpleName().toString());
-                NodeChildData child = execution != null ? execution.getChild() : null;
-
-                if (execution != null) {
-                    method.getParameters().add(new CodeVariableElement(execution.getNodeType(), execution.getName()));
+                NodeChildData child = node.findChild(var.getSimpleName().toString());
+
+                if (child != null) {
+                    method.getParameters().add(new CodeVariableElement(child.getNodeType(), child.getName()));
                 } else {
                     method.getParameters().add(new CodeVariableElement(var.asType(), var.getSimpleName().toString()));
                 }
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/ParameterSpec.java	Tue Jan 07 20:06:27 2014 +0100
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/ParameterSpec.java	Tue Jan 07 20:16:01 2014 +0100
@@ -37,6 +37,7 @@
 
     /** Type is bound to local final variable. */
     private boolean local;
+    private boolean signature;
 
     /** Optional bound execution of node. */
     private NodeExecutionData execution;
@@ -65,6 +66,11 @@
 
     public void setExecution(NodeExecutionData executionData) {
         this.execution = executionData;
+        this.signature = execution != null;
+    }
+
+    public void setSignature(boolean signature) {
+        this.signature = signature;
     }
 
     void setTypeDefinition(TypeDef typeDefinition) {
@@ -80,7 +86,7 @@
     }
 
     public boolean isSignature() {
-        return execution != null;
+        return signature;
     }
 
     public boolean isLocal() {