Mercurial > hg > graal-compiler
comparison 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 |
comparison
equal
deleted
inserted
replaced
13203:401e1473c546 | 13271:2b9fcffd6f36 |
---|---|
203 splittedNode.addError("Classes containing a @%s annotation must not be private.", Specialization.class.getSimpleName()); | 203 splittedNode.addError("Classes containing a @%s annotation must not be private.", Specialization.class.getSimpleName()); |
204 } | 204 } |
205 | 205 |
206 finalizeSpecializations(elements, splittedNode); | 206 finalizeSpecializations(elements, splittedNode); |
207 verifyNode(splittedNode, elements); | 207 verifyNode(splittedNode, elements); |
208 expandExecutableTypeVarArgs(splittedNode); | |
208 createPolymorphicSpecializations(splittedNode); | 209 createPolymorphicSpecializations(splittedNode); |
209 assignShortCircuitsToSpecializations(splittedNode); | 210 assignShortCircuitsToSpecializations(splittedNode); |
210 } | 211 } |
211 | 212 |
212 if (node.isNodeContainer()) { | 213 if (node.isNodeContainer()) { |
213 node.setDeclaredNodes(nodes); | 214 node.setDeclaredNodes(nodes); |
214 node.setSpecializationListeners(new ArrayList<SpecializationListenerData>()); | 215 node.setSpecializationListeners(new ArrayList<SpecializationListenerData>()); |
215 node.setSpecializations(new ArrayList<SpecializationData>()); | 216 node.setSpecializations(new ArrayList<SpecializationData>()); |
216 } | 217 } |
217 return node; | 218 return node; |
219 } | |
220 | |
221 private static void expandExecutableTypeVarArgs(NodeData node) { | |
222 for (ExecutableTypeData executableMethod : node.getExecutableTypes()) { | |
223 if (!(executableMethod.getMethod().isVarArgs() && executableMethod.getSpecification().isVariableRequiredArguments())) { | |
224 continue; | |
225 } | |
226 int expandArguments = node.getSignatureSize() - executableMethod.getSignatureSize(); | |
227 if (expandArguments > 0) { | |
228 int signatureSize = executableMethod.getSignatureSize(); | |
229 ActualParameter parameter = executableMethod.getSignatureParameter(signatureSize - 1); | |
230 for (int i = 0; i < expandArguments; i++) { | |
231 int newVarArgsIndex = parameter.getVarArgsIndex() + i + 1; | |
232 int newSpecificationIndex = parameter.getSpecificationIndex() + i + 1; | |
233 executableMethod.getParameters().add( | |
234 new ActualParameter(parameter.getSpecification(), parameter.getTypeSystemType(), newSpecificationIndex, newVarArgsIndex, parameter.isImplicit())); | |
235 } | |
236 | |
237 } | |
238 } | |
218 } | 239 } |
219 | 240 |
220 private void createPolymorphicSpecializations(NodeData node) { | 241 private void createPolymorphicSpecializations(NodeData node) { |
221 if (!node.needsRewrites(context) || !node.isPolymorphic()) { | 242 if (!node.needsRewrites(context) || !node.isPolymorphic()) { |
222 node.setPolymorphicSpecializations(Collections.<SpecializationData> emptyList()); | 243 node.setPolymorphicSpecializations(Collections.<SpecializationData> emptyList()); |