comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/SpecializationMethodParser.java @ 9279:2a4b57f02fb4

Implemented basic support for assumptions for sourcecode generation.
author Christian Humer <christian.humer@gmail.com>
date Wed, 24 Apr 2013 17:44:15 +0200
parents 61ba6fc21ba4
children
comparison
equal deleted inserted replaced
9276:a9cfbe03d9c4 9279:2a4b57f02fb4
51 @Override 51 @Override
52 public Class<? extends Annotation> getAnnotationType() { 52 public Class<? extends Annotation> getAnnotationType() {
53 return Specialization.class; 53 return Specialization.class;
54 } 54 }
55 55
56 private static SpecializationData parseSpecialization(TemplateMethod method) { 56 private SpecializationData parseSpecialization(TemplateMethod method) {
57 int order = Utils.getAnnotationValue(Integer.class, method.getMarkerAnnotation(), "order"); 57 int order = Utils.getAnnotationValue(Integer.class, method.getMarkerAnnotation(), "order");
58 if (order < 0 && order != Specialization.DEFAULT_ORDER) { 58 if (order < 0 && order != Specialization.DEFAULT_ORDER) {
59 method.addError("Invalid order attribute %d. The value must be >= 0 or the default value."); 59 method.addError("Invalid order attribute %d. The value must be >= 0 or the default value.");
60 return null; 60 return null;
61 } 61 }
80 }); 80 });
81 SpecializationData specialization = new SpecializationData(method, order, exceptionData); 81 SpecializationData specialization = new SpecializationData(method, order, exceptionData);
82 List<String> guardDefs = Utils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "guards"); 82 List<String> guardDefs = Utils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "guards");
83 specialization.setGuardDefinitions(guardDefs); 83 specialization.setGuardDefinitions(guardDefs);
84 84
85 List<String> assumptionDefs = Utils.getAnnotationValueList(String.class, specialization.getMarkerAnnotation(), "assumptions");
86 specialization.setAssumptions(assumptionDefs);
87
88 for (String assumption : assumptionDefs) {
89 if (!getNode().getAssumptions().contains(assumption)) {
90 specialization.addError("Undeclared assumption '%s' used. Use @NodeAssumptions to declare them.", assumption);
91 }
92 }
93
85 return specialization; 94 return specialization;
86 } 95 }
87
88 } 96 }