Mercurial > hg > truffle
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @ 20949:9a83732f97eb
Truffle-DSL: ensure proper wildcards for generics are filled in; remove unused type system node code generator.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 14 Apr 2015 19:23:33 +0200 |
parents | 18c0f02fa4d2 |
children | 2e850dbf82ae |
comparison
equal
deleted
inserted
replaced
20948:a0d97b639d57 | 20949:9a83732f97eb |
---|---|
93 } | 93 } |
94 CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); | 94 CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); |
95 | 95 |
96 TypeCastData cast = typeSystem.getCast(type); | 96 TypeCastData cast = typeSystem.getCast(type); |
97 if (cast == null) { | 97 if (cast == null) { |
98 builder.cast(type, content); | 98 builder.cast(ElementUtils.fillInGenericWildcards(type), content); |
99 } else { | 99 } else { |
100 builder.startStaticCall(typeSystem.getTemplateType().asType(), cast.getMethodName()).tree(content).end(); | 100 builder.startStaticCall(typeSystem.getTemplateType().asType(), cast.getMethodName()).tree(content).end(); |
101 } | 101 } |
102 return builder.build(); | 102 return builder.build(); |
103 } | 103 } |
114 } | 114 } |
115 | 115 |
116 return builder.build(); | 116 return builder.build(); |
117 } | 117 } |
118 | 118 |
119 public static CodeExecutableElement createExpectMethod(Modifier visibility, TypeSystemData typeSystem, TypeMirror sourceType, TypeMirror expectedType) { | 119 public static CodeExecutableElement createExpectMethod(Modifier visibility, TypeSystemData typeSystem, TypeMirror sourceTypeOriginal, TypeMirror expectedTypeOriginal) { |
120 TypeMirror expectedType = ElementUtils.fillInGenericWildcards(expectedTypeOriginal); | |
121 TypeMirror sourceType = ElementUtils.fillInGenericWildcards(sourceTypeOriginal); | |
120 if (ElementUtils.isObject(expectedType) || ElementUtils.isVoid(expectedType)) { | 122 if (ElementUtils.isObject(expectedType) || ElementUtils.isVoid(expectedType)) { |
121 return null; | 123 return null; |
122 } | 124 } |
125 | |
123 CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), expectedType, TypeSystemCodeGenerator.expectTypeMethodName(typeSystem, expectedType)); | 126 CodeExecutableElement method = new CodeExecutableElement(modifiers(STATIC), expectedType, TypeSystemCodeGenerator.expectTypeMethodName(typeSystem, expectedType)); |
124 method.setVisibility(visibility); | 127 method.setVisibility(visibility); |
125 method.addParameter(new CodeVariableElement(sourceType, LOCAL_VALUE)); | 128 method.addParameter(new CodeVariableElement(sourceType, LOCAL_VALUE)); |
126 method.addThrownType(typeSystem.getContext().getTruffleTypes().getUnexpectedValueException()); | 129 method.addThrownType(typeSystem.getContext().getTruffleTypes().getUnexpectedValueException()); |
127 | 130 |
206 } | 209 } |
207 | 210 |
208 @Override | 211 @Override |
209 public CodeTypeElement create(ProcessorContext context, TypeSystemData typeSystem) { | 212 public CodeTypeElement create(ProcessorContext context, TypeSystemData typeSystem) { |
210 CodeTypeElement clazz = new TypeClassFactory(context, typeSystem).create(); | 213 CodeTypeElement clazz = new TypeClassFactory(context, typeSystem).create(); |
211 | |
212 clazz.add(new TypeSystemNodeFactory(context, typeSystem).create()); | |
213 | 214 |
214 if (typeSystem.getOptions().implicitCastOptimization().isMergeCasts()) { | 215 if (typeSystem.getOptions().implicitCastOptimization().isMergeCasts()) { |
215 for (TypeMirror type : typeSystem.lookupTargetTypes()) { | 216 for (TypeMirror type : typeSystem.lookupTargetTypes()) { |
216 clazz.add(new ImplicitCastNodeFactory(context, typeSystem, type).create()); | 217 clazz.add(new ImplicitCastNodeFactory(context, typeSystem, type).create()); |
217 } | 218 } |