Search in sources :

Example 16 with Parameter

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

the class FlatNodeGenFactory method initializeCasts.

private List<IfTriple> initializeCasts(FrameState frameState, SpecializationGroup group, DSLExpression expression, NodeExecutionMode specializationExecution) {
    Set<VariableElement> boundElements = expression.findBoundVariableElements();
    if (boundElements.isEmpty()) {
        return Collections.emptyList();
    }
    List<IfTriple> triples = new ArrayList<>();
    for (VariableElement variable : boundElements) {
        Parameter p = group.getSpecialization().findByVariable(variable);
        if (p != null) {
            NodeExecutionData execution = p.getSpecification().getExecution();
            if (execution != null) {
                LocalVariable var = frameState.getValue(execution);
                if (var == null) {
                    throw new AssertionError();
                }
                IfTriple triple = createTypeCheckOrCast(frameState, group, new TypeGuard(p.getType(), execution.getIndex()), specializationExecution, true, false);
                if (triple != null) {
                    triples.add(triple);
                }
            }
        }
    }
    return triples;
}
Also used : NodeExecutionData(com.oracle.truffle.dsl.processor.model.NodeExecutionData) ArrayList(java.util.ArrayList) Parameter(com.oracle.truffle.dsl.processor.model.Parameter) CodeVariableElement(com.oracle.truffle.dsl.processor.java.model.CodeVariableElement) VariableElement(javax.lang.model.element.VariableElement) TypeGuard(com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard)

Aggregations

Parameter (com.oracle.truffle.dsl.processor.model.Parameter)16 ArrayList (java.util.ArrayList)10 TypeMirror (javax.lang.model.type.TypeMirror)9 ArrayCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror)8 SpecializationData (com.oracle.truffle.dsl.processor.model.SpecializationData)8 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)7 DeclaredCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror)6 GeneratedTypeMirror (com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror)6 CodeTree (com.oracle.truffle.dsl.processor.java.model.CodeTree)4 NodeExecutionData (com.oracle.truffle.dsl.processor.model.NodeExecutionData)4 VariableElement (javax.lang.model.element.VariableElement)4 CodeTreeBuilder (com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder)3 TypeGuard (com.oracle.truffle.dsl.processor.parser.SpecializationGroup.TypeGuard)3 Cached (com.oracle.truffle.api.dsl.Cached)2 Node (com.oracle.truffle.api.nodes.Node)2 NodeInterface (com.oracle.truffle.api.nodes.NodeInterface)2 DSLExpression (com.oracle.truffle.dsl.processor.expression.DSLExpression)2 Variable (com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable)2 DSLExpressionResolver (com.oracle.truffle.dsl.processor.expression.DSLExpressionResolver)2 CodeExecutableElement (com.oracle.truffle.dsl.processor.java.model.CodeExecutableElement)2