comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/SpecializationMethodParser.java @ 8243:d81ff782fa1a

Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
author Christian Humer <christian.humer@gmail.com>
date Mon, 04 Mar 2013 17:20:26 +0100
parents 33e08aca06ff
children 703c09f8640c
comparison
equal deleted inserted replaced
8242:ac4e8c16ffdf 8243:d81ff782fa1a
62 if (order < 0 && order != Specialization.DEFAULT_ORDER) { 62 if (order < 0 && order != Specialization.DEFAULT_ORDER) {
63 getContext().getLog().error(method.getMethod(), method.getMarkerAnnotation(), "Invalid order attribute %d. The value must be >= 0 or the default value."); 63 getContext().getLog().error(method.getMethod(), method.getMarkerAnnotation(), "Invalid order attribute %d. The value must be >= 0 or the default value.");
64 return null; 64 return null;
65 } 65 }
66 66
67 List<AnnotationMirror> exceptionDefs = Utils.collectAnnotations(getContext(), method.getMarkerAnnotation(), "exceptions", method.getMethod(), SpecializationThrows.class); 67 List<TypeMirror> exceptionTypes = Utils.getAnnotationValueList(method.getMarkerAnnotation(), "rewriteOn");
68 SpecializationThrowsData[] exceptionData = new SpecializationThrowsData[exceptionDefs.size()]; 68 List<SpecializationThrowsData> exceptionData = new ArrayList<>();
69 for (int i = 0; i < exceptionData.length; i++) { 69 for (TypeMirror exceptionType : exceptionTypes) {
70 AnnotationMirror mirror = exceptionDefs.get(i); 70 exceptionData.add(new SpecializationThrowsData(method.getMarkerAnnotation(), exceptionType));
71 TypeMirror javaClass = Utils.getAnnotationValueType(mirror, "javaClass");
72 String transitionTo = Utils.getAnnotationValueString(mirror, "transitionTo");
73 exceptionData[i] = new SpecializationThrowsData(mirror, javaClass, transitionTo);
74 71
75 if (!Utils.canThrowType(method.getMethod().getThrownTypes(), javaClass)) { 72 if (!Utils.canThrowType(method.getMethod().getThrownTypes(), exceptionType)) {
76 getContext().getLog().error(method.getMethod(), "Method must specify a throws clause with the exception type '%s'.", Utils.getQualifiedName(javaClass)); 73 getContext().getLog().error(method.getMethod(), "Method must specify a throws clause with the exception type '%s'.", Utils.getQualifiedName(exceptionType));
77 return null; 74 return null;
78 } 75 }
79 } 76 }
80 77
81 Arrays.sort(exceptionData, new Comparator<SpecializationThrowsData>() { 78 Collections.sort(exceptionData, new Comparator<SpecializationThrowsData>() {
82 79
83 @Override 80 @Override
84 public int compare(SpecializationThrowsData o1, SpecializationThrowsData o2) { 81 public int compare(SpecializationThrowsData o1, SpecializationThrowsData o2) {
85 return Utils.compareByTypeHierarchy(o1.getJavaClass(), o2.getJavaClass()); 82 return Utils.compareByTypeHierarchy(o1.getJavaClass(), o2.getJavaClass());
86 } 83 }