Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/TypeSystemParser.java @ 18782:3ea386a1036f
Truffle-DSL: breaking: @TypeCheck and @TypeCast now require casted/checked type as explicit parameter. Previously the type was parsed from the method name. (GRAAL-446 #resolve)
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 05 Jan 2015 20:23:22 +0100 |
parents | a665483c3881 |
children | 7d67a33e1bbb |
comparison
equal
deleted
inserted
replaced
18781:941761f6b736 | 18782:3ea386a1036f |
---|---|
119 | 119 |
120 for (TypeCastData cast : casts) { | 120 for (TypeCastData cast : casts) { |
121 cast.getTargetType().addTypeCast(cast); | 121 cast.getTargetType().addTypeCast(cast); |
122 } | 122 } |
123 | 123 |
124 verifyGenericTypeChecksAndCasts(typeSystem); | |
125 verifyMethodSignatures(typeSystem); | 124 verifyMethodSignatures(typeSystem); |
126 verifyNamesUnique(typeSystem); | 125 verifyNamesUnique(typeSystem); |
127 | 126 |
128 return typeSystem; | 127 return typeSystem; |
129 } | 128 } |
148 template.addError("Non exclusive usage of annotations %s.", annotationNames); | 147 template.addError("Non exclusive usage of annotations %s.", annotationNames); |
149 } | 148 } |
150 } | 149 } |
151 } | 150 } |
152 | 151 |
153 private static void verifyGenericTypeChecksAndCasts(TypeSystemData typeSystem) { | |
154 for (TypeData type : typeSystem.getTypes()) { | |
155 if (!type.getTypeChecks().isEmpty()) { | |
156 boolean hasGeneric = false; | |
157 for (TypeCheckData typeCheck : type.getTypeChecks()) { | |
158 if (typeCheck.isGeneric()) { | |
159 hasGeneric = true; | |
160 break; | |
161 } | |
162 } | |
163 if (!hasGeneric) { | |
164 type.addError("No generic but specific @%s method %s for type %s specified. " + "Specify a generic @%s method with parameter type %s to resolve this.", | |
165 TypeCheck.class.getSimpleName(), TypeSystemCodeGenerator.isTypeMethodName(type), ElementUtils.getSimpleName(type.getBoxedType()), TypeCheck.class.getSimpleName(), | |
166 Object.class.getSimpleName()); | |
167 } | |
168 } | |
169 if (!type.getTypeCasts().isEmpty()) { | |
170 boolean hasGeneric = false; | |
171 for (TypeCastData typeCast : type.getTypeCasts()) { | |
172 if (typeCast.isGeneric()) { | |
173 hasGeneric = true; | |
174 break; | |
175 } | |
176 } | |
177 if (!hasGeneric) { | |
178 type.addError("No generic but specific @%s method %s for type %s specified. " + "Specify a generic @%s method with parameter type %s to resolve this.", | |
179 TypeCast.class.getSimpleName(), TypeSystemCodeGenerator.asTypeMethodName(type), ElementUtils.getSimpleName(type.getBoxedType()), TypeCast.class.getSimpleName(), | |
180 Object.class.getSimpleName()); | |
181 } | |
182 } | |
183 } | |
184 } | |
185 | |
186 private List<TypeData> parseTypes(TypeSystemData typeSystem) { | 152 private List<TypeData> parseTypes(TypeSystemData typeSystem) { |
187 List<TypeData> types = new ArrayList<>(); | 153 List<TypeData> types = new ArrayList<>(); |
188 List<TypeMirror> typeMirrors = ElementUtils.getAnnotationValueList(TypeMirror.class, typeSystem.getTemplateTypeAnnotation(), "value"); | 154 List<TypeMirror> typeMirrors = ElementUtils.getAnnotationValueList(TypeMirror.class, typeSystem.getTemplateTypeAnnotation(), "value"); |
189 if (typeMirrors.isEmpty()) { | 155 if (typeMirrors.isEmpty()) { |
190 typeSystem.addError("At least one type must be defined."); | 156 typeSystem.addError("At least one type must be defined."); |