use of com.oracle.truffle.dsl.processor.model.TemplateMethod in project graal by oracle.
the class TemplateMethodParser method parse.
private E parse(int naturalOrder, ExecutableElement method, AnnotationMirror annotation) {
MethodSpec methodSpecification = createSpecification(method, annotation);
if (methodSpecification == null) {
return null;
}
TemplateMethod templateMethod = parser.parse(methodSpecification, method, annotation, naturalOrder);
if (templateMethod != null) {
return create(templateMethod, templateMethod.hasErrors());
}
return null;
}
use of com.oracle.truffle.dsl.processor.model.TemplateMethod in project graal by oracle.
the class MethodSpecParser method parseImpl.
public TemplateMethod parseImpl(MethodSpec methodSpecification, int naturalOrder, String id, ExecutableElement method, AnnotationMirror annotation, TypeMirror returnType, List<? extends VariableElement> parameterTypes) {
ParameterSpec returnTypeSpec = methodSpecification.getReturnType();
Parameter returnTypeMirror = matchParameter(returnTypeSpec, new CodeVariableElement(returnType, "returnType"), -1, -1);
if (returnTypeMirror == null) {
if (isEmitErrors() && method != null) {
TemplateMethod invalidMethod = new TemplateMethod(id, naturalOrder, template, methodSpecification, method, annotation, returnTypeMirror, Collections.<Parameter>emptyList());
String expectedReturnType = returnTypeSpec.toSignatureString(true);
String actualReturnType = ElementUtils.getSimpleName(returnType);
String message = String.format("The provided return type \"%s\" does not match expected return type \"%s\".\nExpected signature: \n %s", actualReturnType, expectedReturnType, methodSpecification.toSignatureString(method.getSimpleName().toString()));
invalidMethod.addError(message);
return invalidMethod;
} else {
return null;
}
}
List<Parameter> parameters = parseParameters(methodSpecification, parameterTypes, isUseVarArgs() && method != null ? method.isVarArgs() : false);
if (parameters == null) {
if (isEmitErrors() && method != null) {
TemplateMethod invalidMethod = new TemplateMethod(id, naturalOrder, template, methodSpecification, method, annotation, returnTypeMirror, Collections.<Parameter>emptyList());
String message = String.format("Method signature %s does not match to the expected signature: \n%s", createActualSignature(method), methodSpecification.toSignatureString(method.getSimpleName().toString()));
invalidMethod.addError(message);
return invalidMethod;
} else {
return null;
}
}
return new TemplateMethod(id, naturalOrder, template, methodSpecification, method, annotation, returnTypeMirror, parameters);
}
use of com.oracle.truffle.dsl.processor.model.TemplateMethod in project graal by oracle.
the class NodeParser method initializeUninitialized.
private static void initializeUninitialized(final NodeData node) {
SpecializationData generic = node.getGenericSpecialization();
if (generic == null) {
return;
}
TemplateMethod uninializedMethod = new TemplateMethod("Uninitialized", -1, node, generic.getSpecification(), null, null, generic.getReturnType(), generic.getParameters());
// should not use messages from generic specialization
uninializedMethod.getMessages().clear();
node.getSpecializations().add(new SpecializationData(node, uninializedMethod, SpecializationKind.UNINITIALIZED));
}
Aggregations