Search in sources :

Example 11 with CodeAnnotationMirror

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

the class InstrumentableProcessor method generateWrapperAndFactory.

private CodeTypeElement generateWrapperAndFactory(ProcessorContext context, Element e) {
    CodeTypeElement wrapper = generateWrapper(context, e, false);
    if (wrapper == null) {
        return null;
    }
    CodeTypeElement factory = generateFactory(context, e, wrapper);
    // add @SuppressWarnings("deprecation")
    DeclaredType suppressWarnings = context.getDeclaredType(SuppressWarnings.class);
    CodeAnnotationMirror suppressWarningsAnnotation = new CodeAnnotationMirror(suppressWarnings);
    suppressWarningsAnnotation.setElementValue(ElementUtils.findExecutableElement(suppressWarnings, "value"), new CodeAnnotationValue(Arrays.asList(new CodeAnnotationValue("deprecation"))));
    factory.getAnnotationMirrors().add(suppressWarningsAnnotation);
    wrapper.getModifiers().add(Modifier.STATIC);
    factory.add(wrapper);
    assertNoErrorExpected(e);
    return factory;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeTypeElement(com.oracle.truffle.dsl.processor.java.model.CodeTypeElement) DeclaredType(javax.lang.model.type.DeclaredType) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Example 12 with CodeAnnotationMirror

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

the class InstrumentableProcessor method addGeneratedBy.

private static void addGeneratedBy(ProcessorContext context, CodeTypeElement generatedType, TypeElement generatedByType) {
    DeclaredType generatedBy = (DeclaredType) context.getType(GeneratedBy.class);
    // only do this if generatedBy is on the classpath.
    if (generatedBy != null) {
        CodeAnnotationMirror generatedByAnnotation = new CodeAnnotationMirror(generatedBy);
        generatedByAnnotation.setElementValue(generatedByAnnotation.findExecutableElement("value"), new CodeAnnotationValue(generatedByType.asType()));
        generatedType.addAnnotationMirror(generatedByAnnotation);
    }
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) GeneratedBy(com.oracle.truffle.api.dsl.GeneratedBy) DeclaredType(javax.lang.model.type.DeclaredType) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Example 13 with CodeAnnotationMirror

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

the class InstrumentableProcessor method createNodeChild.

private static CodeVariableElement createNodeChild(ProcessorContext context, TypeMirror type, String name) {
    CodeVariableElement var = new CodeVariableElement(ElementUtils.modifiers(Modifier.PRIVATE), type, name);
    var.addAnnotationMirror(new CodeAnnotationMirror((DeclaredType) context.getType(Child.class)));
    return var;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeVariableElement(com.oracle.truffle.dsl.processor.java.model.CodeVariableElement) Child(com.oracle.truffle.api.nodes.Node.Child) DeclaredType(javax.lang.model.type.DeclaredType)

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