Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java @ 13271:2b9fcffd6f36
Truffle-DSL: added support for generating execute methods with java varargs.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sun, 01 Dec 2013 18:18:33 +0100 |
parents | 02f844c76626 |
children | 25ecb47a6d0e |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java Sat Nov 30 19:09:55 2013 +0100 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeParser.java Sun Dec 01 18:18:33 2013 +0100 @@ -205,6 +205,7 @@ finalizeSpecializations(elements, splittedNode); verifyNode(splittedNode, elements); + expandExecutableTypeVarArgs(splittedNode); createPolymorphicSpecializations(splittedNode); assignShortCircuitsToSpecializations(splittedNode); } @@ -217,6 +218,26 @@ return node; } + private static void expandExecutableTypeVarArgs(NodeData node) { + for (ExecutableTypeData executableMethod : node.getExecutableTypes()) { + if (!(executableMethod.getMethod().isVarArgs() && executableMethod.getSpecification().isVariableRequiredArguments())) { + continue; + } + int expandArguments = node.getSignatureSize() - executableMethod.getSignatureSize(); + if (expandArguments > 0) { + int signatureSize = executableMethod.getSignatureSize(); + ActualParameter parameter = executableMethod.getSignatureParameter(signatureSize - 1); + for (int i = 0; i < expandArguments; i++) { + int newVarArgsIndex = parameter.getVarArgsIndex() + i + 1; + int newSpecificationIndex = parameter.getSpecificationIndex() + i + 1; + executableMethod.getParameters().add( + new ActualParameter(parameter.getSpecification(), parameter.getTypeSystemType(), newSpecificationIndex, newVarArgsIndex, parameter.isImplicit())); + } + + } + } + } + private void createPolymorphicSpecializations(NodeData node) { if (!node.needsRewrites(context) || !node.isPolymorphic()) { node.setPolymorphicSpecializations(Collections.<SpecializationData> emptyList());