# HG changeset patch # User Andreas Woess # Date 1399038586 -7200 # Node ID fd18fa50a8e041a050ad37deb0825d1a290fe1f8 # Parent 97ee50d158823559a05962f1e7ce45d73f60abea TruffleDSL: NodeCodeGenerator: avoid referencing BaseNode class in factory diff -r 97ee50d15882 -r fd18fa50a8e0 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 Fri May 02 15:49:22 2014 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java Fri May 02 15:49:46 2014 +0200 @@ -867,7 +867,7 @@ if (found == null) { body.startThrow().startNew(getContext().getType(UnsupportedOperationException.class)).end().end(); } else { - body.startReturn().startCall(nodeSpecializationClassName(found), CREATE_SPECIALIZATION_NAME).startGroup().cast(baseClassName(node)).string(THIS_NODE_LOCAL_VAR_NAME).end().end().end(); + body.startReturn().startCall(nodeSpecializationClassName(found), CREATE_SPECIALIZATION_NAME).startGroup().string(THIS_NODE_LOCAL_VAR_NAME).end().end().end(); } return method; } @@ -1739,7 +1739,7 @@ } else { replaceCall.startCall("replace"); } - replaceCall.startGroup().startCall(className, CREATE_SPECIALIZATION_NAME).string(source); + replaceCall.startGroup().cast(baseClassName(current.getNode())).startCall(className, CREATE_SPECIALIZATION_NAME).string(source); for (ActualParameter param : current.getSignatureParameters()) { NodeChildData child = param.getSpecification().getExecution().getChild(); List types = child.getNodeData().getTypeSystem().lookupSourceTypes(param.getTypeSystemType()); @@ -2556,7 +2556,7 @@ // skip copy constructor - not used continue; } - clazz.add(createConstructorFactoryMethod(nodeGen.asType(), specialization, constructor)); + clazz.add(createConstructorFactoryMethod(specialization, constructor)); } } } @@ -2929,16 +2929,16 @@ CodeVariableElement[] parameters = new CodeVariableElement[implicitTypeParams.size() + 1]; int i = 0; String baseName = "current"; - parameters[i++] = new CodeVariableElement(baseType, baseName); + parameters[i++] = new CodeVariableElement(specialization.getNode().getNodeType(), baseName); for (ActualParameter implicitTypeParam : implicitTypeParams) { parameters[i++] = new CodeVariableElement(getContext().getType(Class.class), implicitTypeName(implicitTypeParam)); } - CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), baseType, CREATE_SPECIALIZATION_NAME, parameters); + CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), specialization.getNode().getNodeType(), CREATE_SPECIALIZATION_NAME, parameters); assert specialization != null; CodeTreeBuilder builder = method.createBuilder(); builder.startReturn(); builder.startNew(getElement().asType()); - builder.string(baseName); + builder.startGroup().cast(baseType, CodeTreeBuilder.singleString(baseName)).end(); for (ActualParameter param : implicitTypeParams) { builder.string(implicitTypeName(param)); } @@ -2946,9 +2946,10 @@ return method; } - protected CodeExecutableElement createConstructorFactoryMethod(TypeMirror baseType, SpecializationData specialization, ExecutableElement constructor) { + protected CodeExecutableElement createConstructorFactoryMethod(SpecializationData specialization, ExecutableElement constructor) { List parameters = constructor.getParameters(); - CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), baseType, CREATE_SPECIALIZATION_NAME, parameters.toArray(new CodeVariableElement[parameters.size()])); + CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), specialization.getNode().getNodeType(), CREATE_SPECIALIZATION_NAME, + parameters.toArray(new CodeVariableElement[parameters.size()])); assert specialization != null; CodeTreeBuilder builder = method.createBuilder(); builder.startReturn();