use of com.oracle.truffle.dsl.processor.model.TypeSystemData in project graal by oracle.
the class NodeParser method parseNodeData.
private NodeData parseNodeData(TypeElement templateType, List<TypeElement> typeHierarchy) {
AnnotationMirror typeSystemMirror = findFirstAnnotation(typeHierarchy, TypeSystemReference.class);
TypeSystemData typeSystem = null;
if (typeSystemMirror != null) {
TypeMirror typeSystemType = ElementUtils.getAnnotationValue(TypeMirror.class, typeSystemMirror, "value");
typeSystem = (TypeSystemData) context.getTemplate(typeSystemType, true);
if (typeSystem == null) {
NodeData nodeData = new NodeData(context, templateType);
nodeData.addError("The used type system '%s' is invalid. Fix errors in the type system first.", ElementUtils.getQualifiedName(typeSystemType));
return nodeData;
}
} else {
// default dummy type system
typeSystem = new TypeSystemData(context, templateType, null, true);
}
boolean useNodeFactory = findFirstAnnotation(typeHierarchy, GenerateNodeFactory.class) != null;
return new NodeData(context, templateType, typeSystem, useNodeFactory);
}
use of com.oracle.truffle.dsl.processor.model.TypeSystemData in project graal by oracle.
the class TypeSystemParser method parse.
@Override
protected TypeSystemData parse(Element element, AnnotationMirror mirror) {
TypeElement templateType = (TypeElement) element;
AnnotationMirror templateTypeAnnotation = mirror;
TypeSystemData typeSystem = new TypeSystemData(context, templateType, templateTypeAnnotation, false);
// annotation type on class path!?
TypeElement annotationTypeElement = processingEnv.getElementUtils().getTypeElement(getAnnotationType().getCanonicalName());
if (annotationTypeElement == null) {
typeSystem.addError("Required class %s is not on the classpath.", getAnnotationType().getName());
}
if (templateType.getModifiers().contains(Modifier.PRIVATE)) {
typeSystem.addError("A @%s must have at least package protected visibility.", getAnnotationType().getName());
}
if (templateType.getModifiers().contains(Modifier.FINAL)) {
typeSystem.addError("The @%s must not be final.", getAnnotationType().getName());
}
if (typeSystem.hasErrors()) {
return typeSystem;
}
if (typeSystem.hasErrors()) {
return typeSystem;
}
verifyExclusiveMethodAnnotation(typeSystem, TypeCast.class, TypeCheck.class);
List<Element> elements = newElementList(context.getEnvironment().getElementUtils().getAllMembers(templateType));
List<ImplicitCastData> implicitCasts = new ImplicitCastParser(context, typeSystem).parse(elements);
List<TypeCastData> casts = new TypeCastParser(context, typeSystem).parse(elements);
List<TypeCheckData> checks = new TypeCheckParser(context, typeSystem).parse(elements);
if (casts == null || checks == null || implicitCasts == null) {
return typeSystem;
}
List<TypeMirror> legacyTypes = ElementUtils.getAnnotationValueList(TypeMirror.class, typeSystem.getTemplateTypeAnnotation(), "value");
for (int i = 0; i < legacyTypes.size(); i++) {
legacyTypes.set(i, ElementUtils.fillInGenericWildcards(legacyTypes.get(i)));
}
typeSystem.getLegacyTypes().addAll(legacyTypes);
verifyTypes(typeSystem);
typeSystem.getLegacyTypes().add(context.getType(Object.class));
typeSystem.getLegacyTypes().add(context.getType(void.class));
verifyNamesUnique(typeSystem);
typeSystem.getImplicitCasts().addAll(implicitCasts);
typeSystem.getCasts().addAll(casts);
typeSystem.getChecks().addAll(checks);
if (typeSystem.hasErrors()) {
return typeSystem;
}
return typeSystem;
}
Aggregations