Search in sources :

Example 6 with ParameterSpec

use of com.oracle.truffle.dsl.processor.model.ParameterSpec in project graal by oracle.

the class TypeCheckParser method createSpecification.

@Override
public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
    MethodSpec spec = new MethodSpec(new ParameterSpec("returnType", getContext().getType(boolean.class)));
    spec.addRequired(new ParameterSpec("value", getContext().getType(Object.class)));
    return spec;
}
Also used : MethodSpec(com.oracle.truffle.dsl.processor.model.MethodSpec) ParameterSpec(com.oracle.truffle.dsl.processor.model.ParameterSpec)

Example 7 with ParameterSpec

use of com.oracle.truffle.dsl.processor.model.ParameterSpec in project graal by oracle.

the class FallbackParser method createValueParameterSpec.

@Override
protected ParameterSpec createValueParameterSpec(NodeExecutionData execution) {
    ParameterSpec spec = new ParameterSpec(execution.getName(), Arrays.asList(getNode().getGenericType(execution)));
    spec.setExecution(execution);
    spec.setAllowSubclasses(false);
    return spec;
}
Also used : ParameterSpec(com.oracle.truffle.dsl.processor.model.ParameterSpec)

Example 8 with ParameterSpec

use of com.oracle.truffle.dsl.processor.model.ParameterSpec in project graal by oracle.

the class ImplicitCastParser method createSpecification.

@Override
public MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror) {
    MethodSpec spec = new MethodSpec(new ParameterSpec("target", getContext().getType(Object.class)));
    spec.addRequired(new ParameterSpec("source", getContext().getType(Object.class))).setSignature(true);
    return spec;
}
Also used : MethodSpec(com.oracle.truffle.dsl.processor.model.MethodSpec) ParameterSpec(com.oracle.truffle.dsl.processor.model.ParameterSpec)

Example 9 with ParameterSpec

use of com.oracle.truffle.dsl.processor.model.ParameterSpec in project graal by oracle.

the class MethodSpecParser method parseParametersRequired.

private static List<Parameter> parseParametersRequired(MethodSpec spec, List<VariableElement> types, boolean typeVarArgs) {
    List<Parameter> parsedParams = new ArrayList<>();
    List<ParameterSpec> specifications = spec.getRequired();
    boolean specVarArgs = spec.isVariableRequiredParameters();
    int typeIndex = 0;
    int specificationIndex = 0;
    ParameterSpec specification;
    while ((specification = nextSpecification(specifications, specificationIndex, specVarArgs)) != null) {
        VariableElement actualType = nextActualType(types, typeIndex, typeVarArgs);
        if (actualType == null) {
            if (spec.isIgnoreAdditionalSpecifications()) {
                break;
            }
            return null;
        }
        int typeVarArgsIndex = typeVarArgs ? typeIndex - types.size() + 1 : -1;
        int specVarArgsIndex = specVarArgs ? specificationIndex - specifications.size() + 1 : -1;
        if (typeVarArgsIndex >= 0 && specVarArgsIndex >= 0) {
            // we would get into an endless loop if we would continue
            break;
        }
        Parameter resolvedParameter = matchParameter(specification, actualType, specVarArgsIndex, typeVarArgsIndex);
        if (resolvedParameter == null) {
            return null;
        }
        parsedParams.add(resolvedParameter);
        typeIndex++;
        specificationIndex++;
    }
    // consume randomly ordered annotated parameters
    VariableElement variable;
    while ((variable = nextActualType(types, typeIndex, typeVarArgs)) != null) {
        Parameter matchedParamter = matchAnnotatedParameter(spec, variable);
        if (matchedParamter == null) {
            break;
        }
        parsedParams.add(matchedParamter);
        typeIndex++;
    }
    if (typeIndex < types.size()) {
        if (spec.isIgnoreAdditionalParameters()) {
            return parsedParams;
        } else {
            return null;
        }
    }
    return parsedParams;
}
Also used : ParameterSpec(com.oracle.truffle.dsl.processor.model.ParameterSpec) ArrayList(java.util.ArrayList) Parameter(com.oracle.truffle.dsl.processor.model.Parameter) VariableElement(javax.lang.model.element.VariableElement) CodeVariableElement(com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)

Example 10 with ParameterSpec

use of com.oracle.truffle.dsl.processor.model.ParameterSpec in project graal by oracle.

the class NodeMethodParser method createValueParameterSpec.

protected ParameterSpec createValueParameterSpec(NodeExecutionData execution) {
    ParameterSpec spec = new ParameterSpec(execution.getName(), getPossibleParameterTypes(execution));
    spec.setExecution(execution);
    return spec;
}
Also used : ParameterSpec(com.oracle.truffle.dsl.processor.model.ParameterSpec)

Aggregations

ParameterSpec (com.oracle.truffle.dsl.processor.model.ParameterSpec)11 MethodSpec (com.oracle.truffle.dsl.processor.model.MethodSpec)5 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)3 TypeMirror (javax.lang.model.type.TypeMirror)3 Parameter (com.oracle.truffle.dsl.processor.model.Parameter)2 ArrayList (java.util.ArrayList)2 VariableElement (javax.lang.model.element.VariableElement)2 ArrayCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror)1 NodeChildData (com.oracle.truffle.dsl.processor.model.NodeChildData)1 NodeFieldData (com.oracle.truffle.dsl.processor.model.NodeFieldData)1 SpecializationData (com.oracle.truffle.dsl.processor.model.SpecializationData)1 TemplateMethod (com.oracle.truffle.dsl.processor.model.TemplateMethod)1