Mercurial > hg > truffle
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemParser.java @ 10600:e93efe3ba5f4
Truffle-DSL: rewritten polymorphic optimization for simpler generated code.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 02 Jul 2013 14:51:05 +0200 |
parents | 79041ab43660 |
children | 4830676526e3 |
comparison
equal
deleted
inserted
replaced
10599:ebf5c5c23564 | 10600:e93efe3ba5f4 |
---|---|
74 if (typeSystem.getTypes() == null) { | 74 if (typeSystem.getTypes() == null) { |
75 return typeSystem; | 75 return typeSystem; |
76 } | 76 } |
77 | 77 |
78 TypeMirror genericType = context.getType(Object.class); | 78 TypeMirror genericType = context.getType(Object.class); |
79 TypeData voidType = new TypeData(typeSystem, null, context.getType(void.class), context.getType(Void.class)); | 79 TypeData voidType = new TypeData(typeSystem, typeSystem.getTypes().size(), null, context.getType(void.class), context.getType(Void.class)); |
80 | 80 |
81 typeSystem.setGenericType(genericType); | 81 typeSystem.setGenericType(genericType); |
82 typeSystem.setVoidType(voidType); | 82 typeSystem.setVoidType(voidType); |
83 | 83 |
84 verifyExclusiveMethodAnnotation(typeSystem, TypeCast.class, TypeCheck.class); | 84 verifyExclusiveMethodAnnotation(typeSystem, TypeCast.class, TypeCheck.class); |
149 } | 149 } |
150 | 150 |
151 final AnnotationValue annotationValue = Utils.getAnnotationValue(typeSystem.getTemplateTypeAnnotation(), "value"); | 151 final AnnotationValue annotationValue = Utils.getAnnotationValue(typeSystem.getTemplateTypeAnnotation(), "value"); |
152 final TypeMirror objectType = context.getType(Object.class); | 152 final TypeMirror objectType = context.getType(Object.class); |
153 | 153 |
154 int index = 0; | |
154 for (TypeMirror primitiveType : typeMirrors) { | 155 for (TypeMirror primitiveType : typeMirrors) { |
155 TypeMirror boxedType = Utils.boxType(context, primitiveType); | 156 TypeMirror boxedType = Utils.boxType(context, primitiveType); |
156 TypeData typeData = new TypeData(typeSystem, annotationValue, primitiveType, boxedType); | 157 TypeData typeData = new TypeData(typeSystem, index, annotationValue, primitiveType, boxedType); |
157 | 158 |
158 if (isPrimitiveWrapper(primitiveType)) { | 159 if (isPrimitiveWrapper(primitiveType)) { |
159 typeData.addError("Types must not contain primitive wrapper types."); | 160 typeData.addError("Types must not contain primitive wrapper types."); |
160 } | 161 } |
161 | 162 |
162 if (Utils.typeEquals(boxedType, objectType)) { | 163 if (Utils.typeEquals(boxedType, objectType)) { |
163 typeData.addError("Types must not contain the generic type java.lang.Object."); | 164 typeData.addError("Types must not contain the generic type java.lang.Object."); |
164 } | 165 } |
165 | 166 |
166 types.add(typeData); | 167 types.add(typeData); |
168 index++; | |
167 } | 169 } |
168 | 170 |
169 verifyTypeOrder(types); | 171 verifyTypeOrder(types); |
170 | 172 |
171 types.add(new TypeData(typeSystem, annotationValue, objectType, objectType)); | 173 types.add(new TypeData(typeSystem, index, annotationValue, objectType, objectType)); |
172 | 174 |
173 return types; | 175 return types; |
174 } | 176 } |
175 | 177 |
176 private static void verifyTypeOrder(List<TypeData> types) { | 178 private static void verifyTypeOrder(List<TypeData> types) { |