use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue in project graal by oracle.
the class FlatNodeGenFactory method createExplodeLoop.
private CodeAnnotationMirror createExplodeLoop() {
DeclaredType explodeLoopType = context.getDeclaredType(ExplodeLoop.class);
CodeAnnotationMirror explodeLoop = new CodeAnnotationMirror(explodeLoopType);
DeclaredType loopExplosionKind = context.getDeclaredType(ExplodeLoop.LoopExplosionKind.class);
if (loopExplosionKind != null) {
VariableElement kindValue = ElementUtils.findVariableElement(loopExplosionKind, "FULL_EXPLODE_UNTIL_RETURN");
if (kindValue != null) {
explodeLoop.setElementValue(ElementUtils.findExecutableElement(explodeLoopType, "kind"), new CodeAnnotationValue(kindValue));
}
}
return explodeLoop;
}
use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue in project graal by oracle.
the class FlatNodeGenFactory method setFieldCompilationFinal.
private static void setFieldCompilationFinal(CodeVariableElement field, int dimensions) {
if (field.getModifiers().contains(Modifier.FINAL) && dimensions <= 0) {
// no need for the compilation final annotation.
return;
}
CodeAnnotationMirror annotation = new CodeAnnotationMirror(ProcessorContext.getInstance().getDeclaredType(CompilationFinal.class));
if (dimensions > 0 || field.getType().getKind() == TypeKind.ARRAY) {
annotation.setElementValue(annotation.findExecutableElement("dimensions"), new CodeAnnotationValue(dimensions < 0 ? 0 : dimensions));
}
field.getAnnotationMirrors().add(annotation);
}
use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue in project graal by oracle.
the class GeneratorUtils method createClass.
static CodeTypeElement createClass(Template sourceModel, TemplateMethod sourceMethod, Set<Modifier> modifiers, String simpleName, TypeMirror superType) {
TypeElement templateType = sourceModel.getTemplateType();
ProcessorContext context = ProcessorContext.getInstance();
PackageElement pack = context.getEnvironment().getElementUtils().getPackageOf(templateType);
CodeTypeElement clazz = new CodeTypeElement(modifiers, ElementKind.CLASS, pack, simpleName);
TypeMirror resolvedSuperType = superType;
if (resolvedSuperType == null) {
resolvedSuperType = context.getType(Object.class);
}
clazz.setSuperClass(resolvedSuperType);
CodeAnnotationMirror generatedByAnnotation = new CodeAnnotationMirror((DeclaredType) context.getType(GeneratedBy.class));
generatedByAnnotation.setElementValue(generatedByAnnotation.findExecutableElement("value"), new CodeAnnotationValue(templateType.asType()));
if (sourceMethod != null && sourceMethod.getMethod() != null) {
generatedByAnnotation.setElementValue(generatedByAnnotation.findExecutableElement("methodName"), new CodeAnnotationValue(sourceMethod.createReferenceName()));
}
clazz.addAnnotationMirror(generatedByAnnotation);
return clazz;
}
use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue 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;
}
use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue 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;
}
Aggregations