comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/ShortCircuitParser.java @ 8252:0905d796944a

Refactored codegen error model to make error redirection a lot easier.
author Christian Humer <christian.humer@gmail.com>
date Wed, 13 Mar 2013 19:58:28 +0100
parents c4c3f50fa9c2
children a80bf36c6a1e
comparison
equal deleted inserted replaced
8251:cb70ed101b5f 8252:0905d796944a
47 } 47 }
48 48
49 @Override 49 @Override
50 public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) { 50 public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
51 String shortCircuitValue = Utils.getAnnotationValue(String.class, mirror, "value"); 51 String shortCircuitValue = Utils.getAnnotationValue(String.class, mirror, "value");
52
53 if (!shortCircuitValues.contains(shortCircuitValue)) {
54 getContext().getLog().error(method, mirror, "Invalid short circuit value %s.", shortCircuitValue);
55 return null;
56 }
57
58 return createDefaultMethodSpec(method, mirror, shortCircuitValue); 52 return createDefaultMethodSpec(method, mirror, shortCircuitValue);
59 } 53 }
60 54
61 @Override 55 @Override
62 protected ParameterSpec createReturnParameterSpec() { 56 protected ParameterSpec createReturnParameterSpec() {
64 } 58 }
65 59
66 @Override 60 @Override
67 public ShortCircuitData create(TemplateMethod method) { 61 public ShortCircuitData create(TemplateMethod method) {
68 String shortCircuitValue = Utils.getAnnotationValue(String.class, method.getMarkerAnnotation(), "value"); 62 String shortCircuitValue = Utils.getAnnotationValue(String.class, method.getMarkerAnnotation(), "value");
69 assert shortCircuitValue != null; 63
70 assert shortCircuitValues.contains(shortCircuitValue); 64 if (!shortCircuitValues.contains(shortCircuitValue)) {
65 method.addError("Invalid short circuit value %s.", shortCircuitValue);
66 }
67
71 return new ShortCircuitData(method, shortCircuitValue); 68 return new ShortCircuitData(method, shortCircuitValue);
72 } 69 }
73 70
74 @Override 71 @Override
75 public Class<? extends Annotation> getAnnotationType() { 72 public Class<? extends Annotation> getAnnotationType() {