use of com.oracle.truffle.dsl.processor.model.MethodSpec in project graal by oracle.
the class NodeParser method createGenericSpecialization.
private SpecializationData createGenericSpecialization(final NodeData node) {
FallbackParser parser = new FallbackParser(context, node);
MethodSpec specification = parser.createDefaultMethodSpec(node.getSpecializations().iterator().next().getMethod(), null, true, null);
List<VariableElement> parameterTypes = new ArrayList<>();
int signatureIndex = 1;
for (ParameterSpec spec : specification.getRequired()) {
parameterTypes.add(new CodeVariableElement(createGenericType(node, spec), "arg" + signatureIndex));
if (spec.isSignature()) {
signatureIndex++;
}
}
TypeMirror returnType = createGenericType(node, specification.getReturnType());
SpecializationData generic = parser.create("Generic", TemplateMethod.NO_NATURAL_ORDER, null, null, returnType, parameterTypes);
if (generic == null) {
throw new RuntimeException("Unable to create generic signature for node " + node.getNodeId() + " with " + parameterTypes + ". Specification " + specification + ".");
}
return generic;
}
use of com.oracle.truffle.dsl.processor.model.MethodSpec in project graal by oracle.
the class SpecializationMethodParser method createSpecification.
@Override
public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
MethodSpec spec = createDefaultMethodSpec(method, mirror, true, null);
spec.getAnnotations().add(new CachedParameterSpec(getContext().getDeclaredType(Cached.class)));
return spec;
}
use of com.oracle.truffle.dsl.processor.model.MethodSpec 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.MethodSpec in project graal by oracle.
the class TypeCastParser method createSpecification.
@Override
public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
TypeMirror targetTypeMirror = ElementUtils.getAnnotationValue(TypeMirror.class, mirror, "value");
ParameterSpec returnTypeSpec = new ParameterSpec("returnType", targetTypeMirror);
returnTypeSpec.setAllowSubclasses(false);
MethodSpec spec = new MethodSpec(returnTypeSpec);
spec.addRequired(new ParameterSpec("value", getContext().getType(Object.class)));
return spec;
}
use of com.oracle.truffle.dsl.processor.model.MethodSpec in project graal by oracle.
the class CreateCastParser method createSpecification.
@Override
public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
List<String> childNames = ElementUtils.getAnnotationValueList(String.class, mirror, "value");
NodeChildData foundChild = null;
for (String childName : childNames) {
foundChild = getNode().findChild(childName);
if (foundChild != null) {
break;
}
}
TypeMirror baseType = getContext().getTruffleTypes().getNode();
if (foundChild != null) {
baseType = foundChild.getOriginalType();
}
MethodSpec spec = new MethodSpec(new ParameterSpec("child", baseType));
addDefaultFieldMethodSpec(spec);
ParameterSpec childSpec = new ParameterSpec("castedChild", baseType);
childSpec.setSignature(true);
spec.addRequired(childSpec);
return spec;
}
Aggregations