Search in sources :

Example 1 with ReportPolymorphism

use of com.oracle.truffle.api.dsl.ReportPolymorphism in project graal by oracle.

the class NodeParser method parseNode.

private NodeData parseNode(TypeElement originalTemplateType) {
    // reloading the type elements is needed for ecj
    TypeElement templateType = ElementUtils.fromTypeMirror(context.reloadTypeElement(originalTemplateType));
    if (ElementUtils.findAnnotationMirror(processingEnv, originalTemplateType, GeneratedBy.class) != null) {
        // generated nodes should not get called again.
        return null;
    }
    if (!ElementUtils.isAssignable(templateType.asType(), context.getTruffleTypes().getNode())) {
        return null;
    }
    List<TypeElement> lookupTypes = collectSuperClasses(new ArrayList<TypeElement>(), templateType);
    List<Element> members = loadMembers(templateType);
    // ensure the processed element has at least one @Specialization annotation.
    if (!containsSpecializations(members)) {
        return null;
    }
    NodeData node = parseNodeData(templateType, lookupTypes);
    if (node.hasErrors()) {
        return node;
    }
    AnnotationMirror reflectable = findFirstAnnotation(lookupTypes, Introspectable.class);
    if (reflectable != null) {
        node.setReflectable(true);
    }
    AnnotationMirror reportPolymorphism = findFirstAnnotation(lookupTypes, ReportPolymorphism.class);
    AnnotationMirror excludePolymorphism = findFirstAnnotation(lookupTypes, ReportPolymorphism.Exclude.class);
    if (reportPolymorphism != null && excludePolymorphism == null) {
        node.setReportPolymorphism(true);
    }
    node.getFields().addAll(parseFields(lookupTypes, members));
    node.getChildren().addAll(parseChildren(node, lookupTypes, members));
    node.getChildExecutions().addAll(parseExecutions(node.getFields(), node.getChildren(), members));
    node.getExecutableTypes().addAll(parseExecutableTypeData(node, members, node.getSignatureSize(), context.getFrameTypes(), false));
    initializeExecutableTypes(node);
    initializeImportGuards(node, lookupTypes, members);
    initializeChildren(node);
    if (node.hasErrors()) {
        // error sync point
        return node;
    }
    node.getSpecializations().addAll(new SpecializationMethodParser(context, node).parse(members));
    node.getSpecializations().addAll(new FallbackParser(context, node).parse(members));
    node.getCasts().addAll(new CreateCastParser(context, node).parse(members));
    if (node.hasErrors()) {
        // error sync point
        return node;
    }
    initializeSpecializations(members, node);
    initializeExecutableTypeHierarchy(node);
    verifySpecializationSameLength(node);
    verifyVisibilities(node);
    verifyMissingAbstractMethods(node, members);
    verifyConstructors(node);
    verifySpecializationThrows(node);
    return node;
}
Also used : AnnotationMirror(javax.lang.model.element.AnnotationMirror) GeneratedBy(com.oracle.truffle.api.dsl.GeneratedBy) ReportPolymorphism(com.oracle.truffle.api.dsl.ReportPolymorphism) TypeElement(javax.lang.model.element.TypeElement) TypeElement(javax.lang.model.element.TypeElement) CodeVariableElement(com.oracle.truffle.dsl.processor.java.model.CodeVariableElement) CodeExecutableElement(com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement) Element(javax.lang.model.element.Element) VariableElement(javax.lang.model.element.VariableElement) ExecutableElement(javax.lang.model.element.ExecutableElement) NodeData(com.oracle.truffle.dsl.processor.model.NodeData)

Aggregations

GeneratedBy (com.oracle.truffle.api.dsl.GeneratedBy)1 ReportPolymorphism (com.oracle.truffle.api.dsl.ReportPolymorphism)1 CodeExecutableElement (com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement)1 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)1 NodeData (com.oracle.truffle.dsl.processor.model.NodeData)1 AnnotationMirror (javax.lang.model.element.AnnotationMirror)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1