changeset 9210:160f088e40db

Made handling of compile errors more robust in the truffle annotation parser.
author Christian Humer <christian.humer@gmail.com>
date Mon, 08 Apr 2013 16:50:51 +0200
parents 119a20bb3b1d
children 77c17c97f713
files graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/AbstractParser.java graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/Utils.java
diffstat 2 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/AbstractParser.java	Mon Apr 08 16:50:17 2013 +0200
+++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/AbstractParser.java	Mon Apr 08 16:50:51 2013 +0200
@@ -27,6 +27,7 @@
 
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
+import javax.tools.Diagnostic.Kind;
 
 import com.oracle.truffle.codegen.processor.template.*;
 
@@ -49,6 +50,7 @@
 
     public final M parse(RoundEnvironment env, Element element) {
         this.roundEnv = env;
+        M model = null;
         try {
             AnnotationMirror mirror = null;
             if (getAnnotationType() != null) {
@@ -58,13 +60,16 @@
             if (!context.getTruffleTypes().verify(context, element, mirror)) {
                 return null;
             }
-            M model = parse(element, mirror);
+            model = parse(element, mirror);
             if (model == null) {
                 return null;
             }
 
             model.emitMessages((TypeElement) element, log);
             return filterErrorElements(model);
+        } catch (CompileErrorException e) {
+            log.message(Kind.WARNING, element, null, null, "The truffle processor could not parse class due to error: %s", e.getMessage());
+            return null;
         } finally {
             this.roundEnv = null;
         }
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/Utils.java	Mon Apr 08 16:50:17 2013 +0200
+++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/Utils.java	Mon Apr 08 16:50:51 2013 +0200
@@ -210,6 +210,8 @@
                 return b.toString();
             case TYPEVAR:
                 return "Any";
+            case ERROR:
+                throw new CompileErrorException("Type error " + mirror);
             default:
                 throw new RuntimeException("Unknown type specified " + mirror.getKind() + " mirror: " + mirror);
         }
@@ -247,6 +249,8 @@
                 return getWildcardName((WildcardType) mirror);
             case TYPEVAR:
                 return "?";
+            case ERROR:
+                throw new CompileErrorException("Type error " + mirror);
             default:
                 throw new RuntimeException("Unknown type specified " + mirror.getKind() + " mirror: " + mirror);
         }
@@ -313,6 +317,8 @@
                 return "void";
             case TYPEVAR:
                 return getSimpleName(mirror);
+            case ERROR:
+                throw new CompileErrorException("Type error " + mirror);
             default:
                 throw new RuntimeException("Unknown type specified " + mirror + " mirror: " + mirror);
         }