comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeCodeGenerator.java @ 13530:0576e9a0358e

Truffle-DSL: minor cleanup.
author Christian Humer <christian.humer@gmail.com>
date Tue, 07 Jan 2014 19:13:54 +0100
parents 5a0c694ef735
children 85b485b1e8e1
comparison
equal deleted inserted replaced
13529:856c2c294f84 13530:0576e9a0358e
1113 return method; 1113 return method;
1114 } 1114 }
1115 1115
1116 private CodeExecutableElement createCachedExecute(NodeData node, SpecializationData polymorph) { 1116 private CodeExecutableElement createCachedExecute(NodeData node, SpecializationData polymorph) {
1117 CodeExecutableElement cachedExecute = new CodeExecutableElement(modifiers(PROTECTED, ABSTRACT), polymorph.getReturnType().getType(), EXECUTE_POLYMORPHIC_NAME); 1117 CodeExecutableElement cachedExecute = new CodeExecutableElement(modifiers(PROTECTED, ABSTRACT), polymorph.getReturnType().getType(), EXECUTE_POLYMORPHIC_NAME);
1118 addInternalValueParameters(cachedExecute, polymorph, true, true); 1118 addInternalValueParameters(cachedExecute, polymorph, true, false);
1119 1119
1120 ExecutableTypeData sourceExecutableType = node.findExecutableType(polymorph.getReturnType().getTypeSystemType(), 0); 1120 ExecutableTypeData sourceExecutableType = node.findExecutableType(polymorph.getReturnType().getTypeSystemType(), 0);
1121 boolean sourceThrowsUnexpected = sourceExecutableType != null && sourceExecutableType.hasUnexpectedValue(getContext()); 1121 boolean sourceThrowsUnexpected = sourceExecutableType != null && sourceExecutableType.hasUnexpectedValue(getContext());
1122 if (sourceExecutableType.getType().equals(node.getGenericSpecialization().getReturnType().getTypeSystemType())) { 1122 if (sourceExecutableType.getType().equals(node.getGenericSpecialization().getReturnType().getTypeSystemType())) {
1123 sourceThrowsUnexpected = false; 1123 sourceThrowsUnexpected = false;
2465 } 2465 }
2466 CodeTypeElement clazz = createClass(node, modifiers(PRIVATE, STATIC, FINAL), nodePolymorphicClassName(node), baseType, false); 2466 CodeTypeElement clazz = createClass(node, modifiers(PRIVATE, STATIC, FINAL), nodePolymorphicClassName(node), baseType, false);
2467 2467
2468 clazz.getAnnotationMirrors().add(createNodeInfo(node, Kind.POLYMORPHIC)); 2468 clazz.getAnnotationMirrors().add(createNodeInfo(node, Kind.POLYMORPHIC));
2469 2469
2470 for (ActualParameter polymorphParameter : polymorph.getParameters()) { 2470 for (ActualParameter polymorphParameter : polymorph.getSignatureParameters()) {
2471 if (!polymorphParameter.getSpecification().isSignature()) {
2472 continue;
2473 }
2474 if (!polymorphParameter.getTypeSystemType().isGeneric()) { 2471 if (!polymorphParameter.getTypeSystemType().isGeneric()) {
2475 continue; 2472 continue;
2476 } 2473 }
2477 Set<TypeData> types = new HashSet<>(); 2474 Set<TypeData> types = new HashSet<>();
2478 for (SpecializationData specialization : node.getSpecializations()) { 2475 for (SpecializationData specialization : node.getSpecializations()) {
2670 } 2667 }
2671 2668
2672 CodeTypeElement clazz = getElement(); 2669 CodeTypeElement clazz = getElement();
2673 2670
2674 final SpecializationData polymorphic = node.getPolymorphicSpecialization(); 2671 final SpecializationData polymorphic = node.getPolymorphicSpecialization();
2675
2676 ExecutableElement executeCached = nodeGen.getMethod(EXECUTE_POLYMORPHIC_NAME); 2672 ExecutableElement executeCached = nodeGen.getMethod(EXECUTE_POLYMORPHIC_NAME);
2677 // ExecutableTypeData execType = new ExecutableTypeData(polymorphic, executeCached, 2673 CodeExecutableElement executeMethod = CodeExecutableElement.clone(getContext().getEnvironment(), executeCached);
2678 // node.getTypeSystem(), polymorphic.getReturnType().getTypeSystemType()); 2674 executeMethod.getModifiers().remove(Modifier.ABSTRACT);
2679 2675 CodeTreeBuilder builder = executeMethod.createBuilder();
2680 ExecutableTypeMethodParser parser = new ExecutableTypeMethodParser(getContext(), node);
2681 ExecutableTypeData execType = parser.parse(Arrays.asList(executeCached)).get(0);
2682
2683 CodeExecutableElement executeMethod = createExecutableTypeOverride(execType, false);
2684 CodeTreeBuilder builder = executeMethod.getBuilder();
2685 2676
2686 if (specialization.isGeneric() || specialization.isPolymorphic()) { 2677 if (specialization.isGeneric() || specialization.isPolymorphic()) {
2687 builder.startThrow().startNew(getContext().getType(AssertionError.class)); 2678 builder.startThrow().startNew(getContext().getType(AssertionError.class));
2688 builder.doubleQuote("Should not be reached."); 2679 builder.doubleQuote("Should not be reached.");
2689 builder.end().end(); 2680 builder.end().end();