# HG changeset patch # User Christian Humer # Date 1389122161 -3600 # Node ID b466199f19e1859459d92778c711ba17b8488be8 # Parent 85b485b1e8e1d21c4fd00589f97a943958b7a425 Truffle-DSL: fixed bug when using @CreateCast with children arrays. diff -r 85b485b1e8e1 -r b466199f19e1 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/CreateCastTest.java --- 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; diff -r 85b485b1e8e1 -r b466199f19e1 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/CreateCastParser.java --- 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; } diff -r 85b485b1e8e1 -r b466199f19e1 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java --- 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())); } diff -r 85b485b1e8e1 -r b466199f19e1 graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/ParameterSpec.java --- 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() {