Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemParser.java @ 13528:5a0c694ef735
Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 07 Jan 2014 18:52:32 +0100 |
parents | e08a9328ce92 |
children | bd28da642eea |
comparison
equal
deleted
inserted
replaced
13527:25ecb47a6d0e | 13528:5a0c694ef735 |
---|---|
33 | 33 |
34 import com.oracle.truffle.api.dsl.*; | 34 import com.oracle.truffle.api.dsl.*; |
35 import com.oracle.truffle.dsl.processor.*; | 35 import com.oracle.truffle.dsl.processor.*; |
36 import com.oracle.truffle.dsl.processor.template.*; | 36 import com.oracle.truffle.dsl.processor.template.*; |
37 | 37 |
38 public class TypeSystemParser extends TemplateParser<TypeSystemData> { | 38 public class TypeSystemParser extends AbstractParser<TypeSystemData> { |
39 | 39 |
40 public static final List<Class<? extends Annotation>> ANNOTATIONS = Arrays.asList(TypeSystem.class, ExpectError.class); | 40 public static final List<Class<? extends Annotation>> ANNOTATIONS = Arrays.asList(TypeSystem.class, ExpectError.class); |
41 | 41 |
42 public TypeSystemParser(ProcessorContext c) { | 42 public TypeSystemParser(ProcessorContext c) { |
43 super(c); | 43 super(c); |
111 verifyGenericTypeChecksAndCasts(typeSystem); | 111 verifyGenericTypeChecksAndCasts(typeSystem); |
112 verifyMethodSignatures(typeSystem); | 112 verifyMethodSignatures(typeSystem); |
113 verifyNamesUnique(typeSystem); | 113 verifyNamesUnique(typeSystem); |
114 | 114 |
115 return typeSystem; | 115 return typeSystem; |
116 } | |
117 | |
118 protected void verifyExclusiveMethodAnnotation(Template template, Class<?>... annotationTypes) { | |
119 List<ExecutableElement> methods = ElementFilter.methodsIn(template.getTemplateType().getEnclosedElements()); | |
120 for (ExecutableElement method : methods) { | |
121 List<AnnotationMirror> foundAnnotations = new ArrayList<>(); | |
122 for (int i = 0; i < annotationTypes.length; i++) { | |
123 Class<?> annotationType = annotationTypes[i]; | |
124 AnnotationMirror mirror = Utils.findAnnotationMirror(context.getEnvironment(), method, annotationType); | |
125 if (mirror != null) { | |
126 foundAnnotations.add(mirror); | |
127 } | |
128 } | |
129 if (foundAnnotations.size() > 1) { | |
130 List<String> annotationNames = new ArrayList<>(); | |
131 for (AnnotationMirror mirror : foundAnnotations) { | |
132 annotationNames.add("@" + Utils.getSimpleName(mirror.getAnnotationType())); | |
133 } | |
134 | |
135 template.addError("Non exclusive usage of annotations %s.", annotationNames); | |
136 } | |
137 } | |
116 } | 138 } |
117 | 139 |
118 private static void verifyGenericTypeChecksAndCasts(TypeSystemData typeSystem) { | 140 private static void verifyGenericTypeChecksAndCasts(TypeSystemData typeSystem) { |
119 for (TypeData type : typeSystem.getTypes()) { | 141 for (TypeData type : typeSystem.getTypes()) { |
120 if (!type.getTypeChecks().isEmpty()) { | 142 if (!type.getTypeChecks().isEmpty()) { |