Search in sources :

Example 6 with CodeAnnotationMirror

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror in project graal by oracle.

the class FixWarningsVisitor method createUnused.

private CodeAnnotationMirror createUnused() {
    CodeAnnotationMirror mirror = new CodeAnnotationMirror(suppressWarnings);
    mirror.setElementValue(mirror.findExecutableElement("value"), new CodeAnnotationValue("unused"));
    return mirror;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Example 7 with CodeAnnotationMirror

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror in project graal by oracle.

the class GenerateOverrideVisitor method visitExecutable.

@Override
public Void visitExecutable(CodeExecutableElement e, Void p) {
    if (!e.getModifiers().contains(Modifier.STATIC) && !e.getModifiers().contains(Modifier.PRIVATE)) {
        String name = e.getSimpleName().toString();
        TypeMirror[] params = e.getParameterTypes();
        for (AnnotationMirror mirror : e.getAnnotationMirrors()) {
            if (ElementUtils.typeEquals(overrideType, mirror.getAnnotationType())) {
                // already declared (may happen if method copied from super class)
                return super.visitExecutable(e, p);
            }
        }
        if (isDeclaredMethodInSuperType(e.getEnclosingClass(), name, params)) {
            e.addAnnotationMirror(new CodeAnnotationMirror(overrideType));
        }
    }
    return super.visitExecutable(e, p);
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) AnnotationMirror(javax.lang.model.element.AnnotationMirror) TypeMirror(javax.lang.model.type.TypeMirror)

Example 8 with CodeAnnotationMirror

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror in project graal by oracle.

the class FlatNodeGenFactory method createIsValid.

private Element createIsValid(TypeMirror assumptionType) {
    CodeExecutableElement isValid = new CodeExecutableElement(modifiers(PRIVATE, STATIC), getType(boolean.class), "isValid_");
    CodeTreeBuilder builder = isValid.createBuilder();
    if (assumptionType.getKind() == TypeKind.ARRAY) {
        isValid.addAnnotationMirror(new CodeAnnotationMirror(context.getDeclaredType(ExplodeLoop.class)));
        isValid.addParameter(new CodeVariableElement(getType(Assumption[].class), "assumptions"));
        builder.startIf().string("assumptions == null").end().startBlock().returnFalse().end();
        builder.startFor().startGroup().type(((ArrayType) assumptionType).getComponentType()).string(" assumption : assumptions").end().end();
        builder.startBlock();
        builder.startIf().string("assumption == null || !assumption.isValid()").end();
        builder.startBlock();
        builder.returnFalse();
        builder.end();
        builder.end();
        builder.returnTrue();
    } else {
        isValid.addParameter(new CodeVariableElement(getType(Assumption.class), "assumption"));
        builder.startReturn().string("assumption != null && assumption.isValid()").end();
    }
    return isValid;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) ArrayType(javax.lang.model.type.ArrayType) CodeExecutableElement(com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement) CodeVariableElement(com.oracle.truffle.dsl.processor.java.model.CodeVariableElement) CodeTreeBuilder(com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder) Assumption(com.oracle.truffle.api.Assumption)

Example 9 with CodeAnnotationMirror

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror in project graal by oracle.

the class NodeFactoryFactory method create.

public CodeTypeElement create() {
    Modifier visibility = ElementUtils.getVisibility(node.getTemplateType().getModifiers());
    TypeMirror nodeFactory = ElementUtils.getDeclaredType(ElementUtils.fromTypeMirror(context.getType(NodeFactory.class)), node.getNodeType());
    CodeTypeElement clazz = GeneratorUtils.createClass(node, null, modifiers(), factoryClassName(node), null);
    if (visibility != null) {
        clazz.getModifiers().add(visibility);
    }
    clazz.getModifiers().add(Modifier.FINAL);
    if (createdFactoryElement != null) {
        clazz.getImplements().add(nodeFactory);
        CodeAnnotationMirror supressWarnings = new CodeAnnotationMirror(context.getDeclaredType(SuppressWarnings.class));
        supressWarnings.setElementValue(supressWarnings.findExecutableElement("value"), new CodeAnnotationValue(Arrays.asList(new CodeAnnotationValue("unchecked"), new CodeAnnotationValue("rawtypes"))));
        clazz.getAnnotationMirrors().add(supressWarnings);
        clazz.add(createNodeFactoryConstructor());
        clazz.add(createCreateGetNodeClass());
        clazz.add(createCreateGetExecutionSignature());
        clazz.add(createCreateGetNodeSignatures());
        clazz.add(createCreateNodeMethod());
        clazz.add(createGetInstanceMethod(visibility));
        clazz.add(createInstanceConstant(clazz.asType()));
        createFactoryMethods(clazz);
    }
    return clazz;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) TypeMirror(javax.lang.model.type.TypeMirror) CodeTypeElement(com.oracle.truffle.dsl.processor.java.model.CodeTypeElement) Modifier(javax.lang.model.element.Modifier) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Example 10 with CodeAnnotationMirror

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror in project graal by oracle.

the class FixWarningsVisitor method createIgnoreDeprecations.

private CodeAnnotationMirror createIgnoreDeprecations() {
    CodeAnnotationMirror mirror = new CodeAnnotationMirror(suppressWarnings);
    mirror.setElementValue(mirror.findExecutableElement("value"), new CodeAnnotationValue("deprecation"));
    return mirror;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Aggregations

CodeAnnotationMirror (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror)13 CodeAnnotationValue (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)8 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)4 DeclaredType (javax.lang.model.type.DeclaredType)4 TypeMirror (javax.lang.model.type.TypeMirror)4 CodeTypeElement (com.oracle.truffle.dsl.processor.java.model.CodeTypeElement)3 CodeExecutableElement (com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement)2 CodeTreeBuilder (com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder)2 Assumption (com.oracle.truffle.api.Assumption)1 CompilationFinal (com.oracle.truffle.api.CompilerDirectives.CompilationFinal)1 GeneratedBy (com.oracle.truffle.api.dsl.GeneratedBy)1 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)1 Child (com.oracle.truffle.api.nodes.Node.Child)1 ProcessorContext (com.oracle.truffle.dsl.processor.ProcessorContext)1 ElementUtils.fromTypeMirror (com.oracle.truffle.dsl.processor.java.ElementUtils.fromTypeMirror)1 CodeTree (com.oracle.truffle.dsl.processor.java.model.CodeTree)1 ArrayCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror)1 DeclaredCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror)1 GeneratedTypeMirror (com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror)1 SpecializationData (com.oracle.truffle.dsl.processor.model.SpecializationData)1