use of com.oracle.truffle.dsl.processor.CompileErrorException in project graal by oracle.
the class ElementUtils method getTypeId.
public static String getTypeId(TypeMirror mirror) {
switch(mirror.getKind()) {
case BOOLEAN:
return "Boolean";
case BYTE:
return "Byte";
case CHAR:
return "Char";
case DOUBLE:
return "Double";
case FLOAT:
return "Float";
case SHORT:
return "Short";
case INT:
return "Int";
case LONG:
return "Long";
case DECLARED:
return fixECJBinaryNameIssue(((DeclaredType) mirror).asElement().getSimpleName().toString());
case ARRAY:
return getTypeId(((ArrayType) mirror).getComponentType()) + "Array";
case VOID:
return "Void";
case NULL:
return "Null";
case WILDCARD:
StringBuilder b = new StringBuilder();
WildcardType type = (WildcardType) mirror;
if (type.getExtendsBound() != null) {
b.append("Extends").append(getTypeId(type.getExtendsBound()));
} else if (type.getSuperBound() != null) {
b.append("Super").append(getTypeId(type.getExtendsBound()));
}
return b.toString();
case TYPEVAR:
return "Any";
case ERROR:
throw new CompileErrorException("Type error " + mirror);
default:
throw new RuntimeException("Unknown type specified " + mirror.getKind() + " mirror: " + mirror);
}
}
use of com.oracle.truffle.dsl.processor.CompileErrorException in project graal by oracle.
the class AbstractParser method parse.
public final M parse(Element element) {
M model = null;
try {
AnnotationMirror mirror = null;
if (getAnnotationType() != null) {
mirror = ElementUtils.findAnnotationMirror(processingEnv, element.getAnnotationMirrors(), getAnnotationType());
}
if (!context.getTruffleTypes().verify(context, element, mirror)) {
return null;
}
model = parse(element, mirror);
if (model == null) {
return null;
}
redirectMessages(new HashSet<MessageContainer>(), model, model);
model.emitMessages(context, log);
if (model instanceof NodeData) {
return model;
} else {
return filterErrorElements(model);
}
} catch (CompileErrorException e) {
log.message(Kind.WARNING, element, null, null, "The truffle processor could not parse class due to error: %s", e.getMessage());
return null;
}
}
use of com.oracle.truffle.dsl.processor.CompileErrorException in project graal by oracle.
the class NodeParser method parseRootType.
private NodeData parseRootType(TypeElement rootType) {
List<NodeData> enclosedNodes = new ArrayList<>();
for (TypeElement enclosedType : ElementFilter.typesIn(rootType.getEnclosedElements())) {
NodeData enclosedChild = parseRootType(enclosedType);
if (enclosedChild != null) {
enclosedNodes.add(enclosedChild);
}
}
NodeData node;
try {
node = parseNode(rootType);
} catch (CompileErrorException e) {
throw e;
} catch (Throwable e) {
RuntimeException e2 = new RuntimeException(String.format("Parsing of Node %s failed.", ElementUtils.getQualifiedName(rootType)));
e2.addSuppressed(e);
throw e2;
}
if (node == null && !enclosedNodes.isEmpty()) {
node = new NodeData(context, rootType);
}
if (node != null) {
for (NodeData enclosedNode : enclosedNodes) {
node.addEnclosedNode(enclosedNode);
}
}
return node;
}
Aggregations