Search in sources :

Example 6 with Variable

use of com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable in project graal by oracle.

the class FlatNodeGenFactory method castBoundTypes.

private static Map<Variable, CodeTree> castBoundTypes(Map<Variable, LocalVariable> bindings) {
    Map<Variable, CodeTree> resolvedBindings = new HashMap<>();
    for (Variable variable : bindings.keySet()) {
        LocalVariable localVariable = bindings.get(variable);
        CodeTree resolved = localVariable.createReference();
        TypeMirror sourceType = localVariable.getTypeMirror();
        TypeMirror targetType = variable.getResolvedTargetType();
        if (targetType == null) {
            targetType = variable.getResolvedType();
        }
        if (!ElementUtils.isAssignable(sourceType, targetType)) {
            resolved = CodeTreeBuilder.createBuilder().startParantheses().cast(targetType, resolved).end().build();
        }
        resolvedBindings.put(variable, resolved);
    }
    return resolvedBindings;
}
Also used : Variable(com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable) CodeTree(com.oracle.truffle.dsl.processor.java.model.CodeTree) HashMap(java.util.HashMap) DeclaredCodeTypeMirror(com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror) ArrayCodeTypeMirror(com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror) GeneratedTypeMirror(com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror) TypeMirror(javax.lang.model.type.TypeMirror)

Aggregations

Variable (com.oracle.truffle.dsl.processor.expression.DSLExpression.Variable)6 DSLExpression (com.oracle.truffle.dsl.processor.expression.DSLExpression)3 Call (com.oracle.truffle.dsl.processor.expression.DSLExpression.Call)3 CodeTree (com.oracle.truffle.dsl.processor.java.model.CodeTree)3 Binary (com.oracle.truffle.dsl.processor.expression.DSLExpression.Binary)2 BooleanLiteral (com.oracle.truffle.dsl.processor.expression.DSLExpression.BooleanLiteral)2 GuardExpression (com.oracle.truffle.dsl.processor.model.GuardExpression)2 Parameter (com.oracle.truffle.dsl.processor.model.Parameter)2 HashMap (java.util.HashMap)2 AbstractDSLExpressionReducer (com.oracle.truffle.dsl.processor.expression.DSLExpression.AbstractDSLExpressionReducer)1 DSLExpressionVisitor (com.oracle.truffle.dsl.processor.expression.DSLExpression.DSLExpressionVisitor)1 IntLiteral (com.oracle.truffle.dsl.processor.expression.DSLExpression.IntLiteral)1 Negate (com.oracle.truffle.dsl.processor.expression.DSLExpression.Negate)1 ElementUtils.isObject (com.oracle.truffle.dsl.processor.java.ElementUtils.isObject)1 CodeTreeBuilder (com.oracle.truffle.dsl.processor.java.model.CodeTreeBuilder)1 ArrayCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror)1 DeclaredCodeTypeMirror (com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.DeclaredCodeTypeMirror)1 GeneratedTypeMirror (com.oracle.truffle.dsl.processor.java.model.GeneratedTypeMirror)1 NodeExecutionData (com.oracle.truffle.dsl.processor.model.NodeExecutionData)1 SpecializationData (com.oracle.truffle.dsl.processor.model.SpecializationData)1