Search in sources :

Example 11 with Load

use of org.robovm.compiler.llvm.Load in project robovm by robovm.

the class BroMethodCompiler method loadValueForGetter.

protected Value loadValueForGetter(SootMethod method, Function fn, Type memberType, Value memberPtr, Value env, boolean dereference, long flags) {
    soot.Type type = method.getReturnType();
    Value result = null;
    if (memberType instanceof StructureType) {
        // The member is a child struct contained in the current struct
        result = memberPtr;
    } else if (memberType instanceof ArrayType) {
        // The member is an array contained in the current struct
        result = memberPtr;
    } else if (dereference) {
        Variable tmp = fn.newVariable(memberType);
        fn.add(new Load(tmp, memberPtr));
        result = tmp.ref();
    } else {
        // Do not dereference the pointer but use it as is. This is needed for
        // global values such as _dispatch_main_q which is a struct and not a
        // pointer which we should load. We want the address of the struct.
        Variable tmp = fn.newVariable(memberType);
        fn.add(new Bitcast(tmp, memberPtr, tmp.getType()));
        result = tmp.ref();
    }
    if (needsMarshaler(type)) {
        MarshalerMethod marshalerMethod = config.getMarshalerLookup().findMarshalerMethod(new MarshalSite(method));
        String targetClassName = getInternalName(type);
        if (memberType instanceof PrimitiveType) {
            // Value type wrapping a primitive value (e.g. Enum, Integer and Bits)
            result = marshalNativeToValueObject(fn, marshalerMethod, env, targetClassName, result, flags);
        } else {
            if (memberType instanceof ArrayType) {
                // Array
                result = marshalNativeToArray(fn, marshalerMethod, env, targetClassName, result, flags, getArrayDimensions(method));
            } else {
                result = marshalNativeToObject(fn, marshalerMethod, null, env, targetClassName, result, flags);
            }
        }
    } else {
        result = marshalNativeToPrimitive(fn, method, result);
    }
    return result;
}
Also used : ArrayType(org.robovm.compiler.llvm.ArrayType) MarshalSite(org.robovm.compiler.MarshalerLookup.MarshalSite) Load(org.robovm.compiler.llvm.Load) Variable(org.robovm.compiler.llvm.Variable) Bitcast(org.robovm.compiler.llvm.Bitcast) ConstantBitcast(org.robovm.compiler.llvm.ConstantBitcast) StructureType(org.robovm.compiler.llvm.StructureType) Value(org.robovm.compiler.llvm.Value) PrimitiveType(org.robovm.compiler.llvm.PrimitiveType) MarshalerMethod(org.robovm.compiler.MarshalerLookup.MarshalerMethod) ValueMarshalerMethod(org.robovm.compiler.MarshalerLookup.ValueMarshalerMethod) ArrayMarshalerMethod(org.robovm.compiler.MarshalerLookup.ArrayMarshalerMethod)

Example 12 with Load

use of org.robovm.compiler.llvm.Load in project robovm by robovm.

the class ClassCompiler method getClassFieldPtr.

static Value getClassFieldPtr(Function f, SootField field, List<SootField> classFields, StructureType classType) {
    Value info = getInfoStruct(f, field.getDeclaringClass());
    Variable base = f.newVariable(I8_PTR);
    f.add(new Load(base, info));
    return getFieldPtr(f, new VariableRef(base), offsetof(classType, 1, classFields.indexOf(field), 1), getType(field.getType()));
}
Also used : Load(org.robovm.compiler.llvm.Load) VariableRef(org.robovm.compiler.llvm.VariableRef) Variable(org.robovm.compiler.llvm.Variable) Value(org.robovm.compiler.llvm.Value)

Aggregations

Load (org.robovm.compiler.llvm.Load)12 Variable (org.robovm.compiler.llvm.Variable)12 Value (org.robovm.compiler.llvm.Value)10 PointerType (org.robovm.compiler.llvm.PointerType)8 ConstantBitcast (org.robovm.compiler.llvm.ConstantBitcast)7 VariableRef (org.robovm.compiler.llvm.VariableRef)7 Bitcast (org.robovm.compiler.llvm.Bitcast)6 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)6 Ret (org.robovm.compiler.llvm.Ret)6 Function (org.robovm.compiler.llvm.Function)5 StructureType (org.robovm.compiler.llvm.StructureType)5 Type (org.robovm.compiler.llvm.Type)5 ArrayType (org.robovm.compiler.llvm.ArrayType)4 FunctionRef (org.robovm.compiler.llvm.FunctionRef)4 Getelementptr (org.robovm.compiler.llvm.Getelementptr)4 Icmp (org.robovm.compiler.llvm.Icmp)4 Br (org.robovm.compiler.llvm.Br)3 FunctionType (org.robovm.compiler.llvm.FunctionType)3 GlobalRef (org.robovm.compiler.llvm.GlobalRef)3 Inttoptr (org.robovm.compiler.llvm.Inttoptr)3