Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/TypeSystemCodeGenerator.java @ 19282:ae81dd154fb6
Truffle-DSL: remove old DSL layout; Make new layout the default.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 22 Jan 2015 20:44:24 +0100 |
parents | c0fb70634640 |
children | 18c0f02fa4d2 |
comparison
equal
deleted
inserted
replaced
19281:92880b0f7fed | 19282:ae81dd154fb6 |
---|---|
116 builder.startStaticCall(typeSystem.getTemplateType().asType(), type.getTypeCasts().get(0).getMethodName()).tree(content).end(); | 116 builder.startStaticCall(typeSystem.getTemplateType().asType(), type.getTypeCasts().get(0).getMethodName()).tree(content).end(); |
117 } | 117 } |
118 return builder.build(); | 118 return builder.build(); |
119 } | 119 } |
120 | 120 |
121 public static CodeTree cast(TypeData sourceType, TypeData targetType, CodeTree content) { | |
122 if (sourceType != null && !sourceType.needsCastTo(targetType)) { | |
123 return content; | |
124 } else { | |
125 return cast(targetType, content); | |
126 } | |
127 } | |
128 | |
129 public static CodeTree expect(TypeData type, CodeTree content) { | 121 public static CodeTree expect(TypeData type, CodeTree content) { |
130 if (type.isGeneric() || type.isVoid()) { | 122 if (type.isGeneric() || type.isVoid()) { |
131 return content; | 123 return content; |
132 } | 124 } |
133 CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); | 125 CodeTreeBuilder builder = CodeTreeBuilder.createBuilder(); |
206 | 198 |
207 @Override | 199 @Override |
208 public CodeTypeElement create(ProcessorContext context, TypeSystemData typeSystem) { | 200 public CodeTypeElement create(ProcessorContext context, TypeSystemData typeSystem) { |
209 CodeTypeElement clazz = new TypeClassFactory(context, typeSystem).create(); | 201 CodeTypeElement clazz = new TypeClassFactory(context, typeSystem).create(); |
210 | 202 |
211 if (typeSystem.getOptions().useNewLayout()) { | 203 clazz.add(new TypeSystemNodeFactory(context, typeSystem).create()); |
212 clazz.add(new TypeSystemNodeFactory(context, typeSystem).create()); | 204 |
213 | 205 if (typeSystem.getOptions().implicitCastOptimization().isMergeCasts()) { |
214 if (typeSystem.getOptions().implicitCastOptimization().isMergeCasts()) { | 206 for (TypeData type : typeSystem.getTypes()) { |
215 for (TypeData type : typeSystem.getTypes()) { | 207 List<TypeData> sourceTypes = typeSystem.lookupSourceTypes(type); |
216 List<TypeData> sourceTypes = typeSystem.lookupSourceTypes(type); | 208 if (sourceTypes.size() > 1) { |
217 if (sourceTypes.size() > 1) { | 209 clazz.add(new ImplicitCastNodeFactory(context, type).create()); |
218 clazz.add(new ImplicitCastNodeFactory(context, type).create()); | |
219 } | |
220 } | 210 } |
221 } | 211 } |
222 } | 212 } |
223 return clazz; | 213 return clazz; |
224 } | 214 } |