Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeGenFactory.java @ 20951:a77b760a0307
Truffle-DSL: fixed on-demand generation of getNext.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 14 Apr 2015 19:23:33 +0200 |
parents | 9a83732f97eb |
children | ec1dca6d288a |
comparison
equal
deleted
inserted
replaced
20950:a778fbcb8d8e | 20951:a77b760a0307 |
---|---|
373 | 373 |
374 for (SpecializationData specialization : generateSpecializations) { | 374 for (SpecializationData specialization : generateSpecializations) { |
375 generated.put(specialization, clazz.add(createSpecialization(specialization, baseSpecializationType))); | 375 generated.put(specialization, clazz.add(createSpecialization(specialization, baseSpecializationType))); |
376 } | 376 } |
377 | 377 |
378 if (nextUsed) { | 378 baseSpecialization.addOptional(createCreateNext(generated)); |
379 baseSpecialization.addOptional(createCreateNext(generated)); | |
380 } | |
381 baseSpecialization.addOptional(createCreateFallback(generated)); | 379 baseSpecialization.addOptional(createCreateFallback(generated)); |
382 baseSpecialization.addOptional(createCreatePolymorphic(generated)); | 380 baseSpecialization.addOptional(createCreatePolymorphic(generated)); |
381 baseSpecialization.addOptional(createGetNext(baseSpecialization)); | |
383 | 382 |
384 return node.getUninitializedSpecialization(); | 383 return node.getUninitializedSpecialization(); |
385 } | 384 } |
386 | 385 |
387 private boolean needsPolymorphic() { | 386 private boolean needsPolymorphic() { |
411 clazz.addOptional(createSpecializationConstructor(clazz, null, null)); | 410 clazz.addOptional(createSpecializationConstructor(clazz, null, null)); |
412 clazz.add(new CodeVariableElement(modifiers(PROTECTED, FINAL), nodeType(node), "root")); | 411 clazz.add(new CodeVariableElement(modifiers(PROTECTED, FINAL), nodeType(node), "root")); |
413 | 412 |
414 clazz.addOptional(createUnsupported()); | 413 clazz.addOptional(createUnsupported()); |
415 clazz.add(createGetSuppliedChildrenMethod()); | 414 clazz.add(createGetSuppliedChildrenMethod()); |
416 clazz.add(createGetNext(clazz)); | |
417 clazz.add(createAcceptAndExecute()); | 415 clazz.add(createAcceptAndExecute()); |
418 | 416 |
419 for (ExecutableTypeData type : usedTypes) { | 417 for (ExecutableTypeData type : usedTypes) { |
420 clazz.add(createFastPathExecuteMethod(null, type, usedTypes)); | 418 clazz.add(createFastPathExecuteMethod(null, type, usedTypes)); |
421 } | 419 } |
1247 } | 1245 } |
1248 | 1246 |
1249 return false; | 1247 return false; |
1250 } | 1248 } |
1251 | 1249 |
1252 private static Element createGetNext(CodeTypeElement type) { | 1250 private Element createGetNext(CodeTypeElement type) { |
1251 if (!nextUsed) { | |
1252 return null; | |
1253 } | |
1253 CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED, FINAL), type.asType(), "getNext"); | 1254 CodeExecutableElement method = new CodeExecutableElement(modifiers(PROTECTED, FINAL), type.asType(), "getNext"); |
1254 CodeTreeBuilder builder = method.createBuilder(); | 1255 CodeTreeBuilder builder = method.createBuilder(); |
1255 builder.startReturn().cast(type.asType(), CodeTreeBuilder.singleString("this.next")).end(); | 1256 builder.startReturn().cast(type.asType(), CodeTreeBuilder.singleString("this.next")).end(); |
1256 return method; | 1257 return method; |
1257 } | 1258 } |