Search in sources :

Example 6 with Invokestatic

use of org.robovm.compiler.trampoline.Invokestatic in project robovm by robovm.

the class BridgeMethodCompiler method updateObject.

private void updateObject(SootMethod method, Function fn, Value env, long flags, List<MarshaledArg> marshaledArgs) {
    for (MarshaledArg value : marshaledArgs) {
        MarshalerMethod marshalerMethod = config.getMarshalerLookup().findMarshalerMethod(new MarshalSite(method, value.paramIndex));
        SootMethod afterMethod = ((PointerMarshalerMethod) marshalerMethod).getAfterBridgeCallMethod();
        if (afterMethod != null) {
            Invokestatic invokestatic = new Invokestatic(getInternalName(method.getDeclaringClass()), getInternalName(afterMethod.getDeclaringClass()), afterMethod.getName(), getDescriptor(afterMethod));
            trampolines.add(invokestatic);
            call(fn, invokestatic.getFunctionRef(), env, value.object, value.handle, new IntegerConstant(flags));
        }
    }
}
Also used : MarshalSite(org.robovm.compiler.MarshalerLookup.MarshalSite) Invokestatic(org.robovm.compiler.trampoline.Invokestatic) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) SootMethod(soot.SootMethod) MarshalerMethod(org.robovm.compiler.MarshalerLookup.MarshalerMethod) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 7 with Invokestatic

use of org.robovm.compiler.trampoline.Invokestatic in project robovm by robovm.

the class CallbackMethodCompiler method updateNative.

private void updateNative(SootMethod method, Function fn, Value env, long flags, List<MarshaledArg> marshaledArgs) {
    for (MarshaledArg value : marshaledArgs) {
        MarshalerMethod marshalerMethod = config.getMarshalerLookup().findMarshalerMethod(new MarshalSite(method, value.paramIndex));
        SootMethod afterMethod = ((PointerMarshalerMethod) marshalerMethod).getAfterCallbackCallMethod();
        if (afterMethod != null) {
            Invokestatic invokestatic = new Invokestatic(getInternalName(method.getDeclaringClass()), getInternalName(afterMethod.getDeclaringClass()), afterMethod.getName(), getDescriptor(afterMethod));
            trampolines.add(invokestatic);
            call(fn, invokestatic.getFunctionRef(), env, value.handle, value.object, new IntegerConstant(flags));
        }
    }
}
Also used : MarshalSite(org.robovm.compiler.MarshalerLookup.MarshalSite) Invokestatic(org.robovm.compiler.trampoline.Invokestatic) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) SootMethod(soot.SootMethod) MarshalerMethod(org.robovm.compiler.MarshalerLookup.MarshalerMethod) PointerMarshalerMethod(org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 8 with Invokestatic

use of org.robovm.compiler.trampoline.Invokestatic in project robovm by robovm.

the class BroMethodCompiler method marshalArrayToNative.

protected void marshalArrayToNative(Function fn, MarshalerMethod marshalerMethod, Value env, Value object, Value destPtr, long flags, int[] dimensions) {
    Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokestatic);
    Variable handle = fn.newVariable(I64);
    fn.add(new Ptrtoint(handle, destPtr, I64));
    List<Value> args = new ArrayList<>();
    args.add(env);
    args.add(object);
    args.add(handle.ref());
    args.add(new IntegerConstant(flags));
    args.addAll(arrayDimensionsValues(dimensions));
    call(fn, invokestatic.getFunctionRef(), args);
}
Also used : Invokestatic(org.robovm.compiler.trampoline.Invokestatic) Variable(org.robovm.compiler.llvm.Variable) Ptrtoint(org.robovm.compiler.llvm.Ptrtoint) ArrayList(java.util.ArrayList) Value(org.robovm.compiler.llvm.Value) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Example 9 with Invokestatic

use of org.robovm.compiler.trampoline.Invokestatic in project robovm by robovm.

the class BroMethodCompiler method marshalNativeToObject.

protected Value marshalNativeToObject(Function fn, MarshalerMethod marshalerMethod, MarshaledArg marshaledArg, Value env, String valueClassName, Value nativeValue, long flags) {
    if (nativeValue.getType() instanceof StructureType) {
        nativeValue = createStackCopy(fn, nativeValue);
    }
    Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
    trampolines.add(invokestatic);
    Value valueClass = ldcClass(fn, valueClassName, env);
    Variable handle = fn.newVariable(I64);
    fn.add(new Ptrtoint(handle, nativeValue, I64));
    Value object = call(fn, invokestatic.getFunctionRef(), env, valueClass, handle.ref(), new IntegerConstant(flags));
    if (marshaledArg != null) {
        marshaledArg.handle = handle.ref();
        marshaledArg.object = object;
    }
    return object;
}
Also used : Invokestatic(org.robovm.compiler.trampoline.Invokestatic) Variable(org.robovm.compiler.llvm.Variable) Ptrtoint(org.robovm.compiler.llvm.Ptrtoint) StructureType(org.robovm.compiler.llvm.StructureType) Value(org.robovm.compiler.llvm.Value) IntegerConstant(org.robovm.compiler.llvm.IntegerConstant)

Aggregations

Invokestatic (org.robovm.compiler.trampoline.Invokestatic)9 IntegerConstant (org.robovm.compiler.llvm.IntegerConstant)8 Value (org.robovm.compiler.llvm.Value)7 Variable (org.robovm.compiler.llvm.Variable)4 ArrayList (java.util.ArrayList)3 Ptrtoint (org.robovm.compiler.llvm.Ptrtoint)3 SootMethod (soot.SootMethod)3 MarshalSite (org.robovm.compiler.MarshalerLookup.MarshalSite)2 MarshalerMethod (org.robovm.compiler.MarshalerLookup.MarshalerMethod)2 PointerMarshalerMethod (org.robovm.compiler.MarshalerLookup.PointerMarshalerMethod)2 StructureType (org.robovm.compiler.llvm.StructureType)2 List (java.util.List)1 ArrayType (org.robovm.compiler.llvm.ArrayType)1 FunctionRef (org.robovm.compiler.llvm.FunctionRef)1 Inttoptr (org.robovm.compiler.llvm.Inttoptr)1 Load (org.robovm.compiler.llvm.Load)1 PointerType (org.robovm.compiler.llvm.PointerType)1 Invokeinterface (org.robovm.compiler.trampoline.Invokeinterface)1 Invokespecial (org.robovm.compiler.trampoline.Invokespecial)1 Invokevirtual (org.robovm.compiler.trampoline.Invokevirtual)1