Search in sources :

Example 1 with NodeInfo

use of org.graalvm.compiler.nodeinfo.NodeInfo in project graal by oracle.

the class GraphNodeProcessor method process.

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (roundEnv.processingOver()) {
        return false;
    }
    GraphNodeVerifier verifier = new GraphNodeVerifier(this);
    for (Element element : roundEnv.getElementsAnnotatedWith(NodeInfo.class)) {
        scope = element;
        try {
            if (!isNodeType(element)) {
                errorMessage(element, "%s can only be applied to Node subclasses", NodeInfo.class.getSimpleName());
                continue;
            }
            NodeInfo nodeInfo = element.getAnnotation(NodeInfo.class);
            if (nodeInfo == null) {
                errorMessage(element, "Cannot get %s annotation from annotated element", NodeInfo.class.getSimpleName());
                continue;
            }
            TypeElement typeElement = (TypeElement) element;
            Set<Modifier> modifiers = typeElement.getModifiers();
            if (!modifiers.contains(Modifier.FINAL) && !modifiers.contains(Modifier.ABSTRACT)) {
            // TODO(thomaswue): Reenable this check.
            // errorMessage(element, "%s annotated class must be either final or abstract",
            // NodeInfo.class.getSimpleName());
            // continue;
            }
            boolean found = false;
            for (Element e : typeElement.getEnclosedElements()) {
                if (e.getKind() == ElementKind.FIELD) {
                    if (e.getSimpleName().toString().equals("TYPE")) {
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                errorMessage(element, "%s annotated class must have a field named TYPE", NodeInfo.class.getSimpleName());
            }
            if (!typeElement.equals(verifier.Node) && !modifiers.contains(Modifier.ABSTRACT)) {
                verifier.verify(typeElement);
            }
        } catch (ElementException ee) {
            errorMessage(ee.element, ee.getMessage());
        } catch (Throwable t) {
            reportException(isBug367599(t) ? Kind.NOTE : Kind.ERROR, element, t);
        } finally {
            scope = null;
        }
    }
    return false;
}
Also used : NodeInfo(org.graalvm.compiler.nodeinfo.NodeInfo) TypeElement(javax.lang.model.element.TypeElement) Element(javax.lang.model.element.Element) TypeElement(javax.lang.model.element.TypeElement) Modifier(javax.lang.model.element.Modifier)

Aggregations

Element (javax.lang.model.element.Element)1 Modifier (javax.lang.model.element.Modifier)1 TypeElement (javax.lang.model.element.TypeElement)1 NodeInfo (org.graalvm.compiler.nodeinfo.NodeInfo)1