use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.
the class BroMethodCompiler method marshalValueObjectToNative.
protected Value marshalValueObjectToNative(Function fn, MarshalerMethod marshalerMethod, Type nativeType, Value env, Value object, long flags) {
Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
trampolines.add(invokestatic);
Value result = call(fn, invokestatic.getFunctionRef(), env, object, new IntegerConstant(flags));
return marshalPrimitiveToNative(fn, marshalerMethod.getMethod(), result);
}
use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.
the class BroMethodCompiler method marshalNativeToValueObject.
protected Value marshalNativeToValueObject(Function fn, MarshalerMethod marshalerMethod, Value env, String valueClassName, Value nativeValue, long flags) {
Invokestatic invokeToObject = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
trampolines.add(invokeToObject);
Value valueClass = ldcClass(fn, valueClassName, env);
nativeValue = marshalNativeToPrimitive(fn, marshalerMethod.getMethod(), 1, nativeValue);
return call(fn, invokeToObject.getFunctionRef(), env, valueClass, nativeValue, new IntegerConstant(flags));
}
use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.
the class BroMethodCompiler method marshalNativeToArray.
protected Value marshalNativeToArray(Function fn, MarshalerMethod marshalerMethod, Value env, String arrayClassName, Value nativeValue, long flags, int[] dimensions) {
Invokestatic invokeToObject = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
trampolines.add(invokeToObject);
Variable handle = fn.newVariable(I64);
fn.add(new Ptrtoint(handle, nativeValue, I64));
Value valueClass = ldcClass(fn, arrayClassName, env);
List<Value> args = new ArrayList<>();
args.add(env);
args.add(valueClass);
args.add(handle.ref());
args.add(new IntegerConstant(flags));
args.addAll(arrayDimensionsValues(dimensions));
return call(fn, invokeToObject.getFunctionRef(), args);
}
use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.
the class BroMethodCompiler method marshalObjectToNative.
protected Value marshalObjectToNative(Function fn, MarshalerMethod marshalerMethod, MarshaledArg marshaledArg, Type nativeType, Value env, Value object, long flags) {
Invokestatic invokestatic = marshalerMethod.getInvokeStatic(sootMethod.getDeclaringClass());
trampolines.add(invokestatic);
Value handle = call(fn, invokestatic.getFunctionRef(), env, object, new IntegerConstant(flags));
Variable nativeValue = fn.newVariable(nativeType);
if (nativeType instanceof StructureType || nativeType instanceof ArrayType) {
Variable tmp = fn.newVariable(new PointerType(nativeType));
fn.add(new Inttoptr(tmp, handle, tmp.getType()));
fn.add(new Load(nativeValue, tmp.ref()));
} else {
fn.add(new Inttoptr(nativeValue, handle, nativeType));
}
if (marshaledArg != null) {
marshaledArg.handle = handle;
marshaledArg.object = object;
}
return nativeValue.ref();
}
use of org.robovm.compiler.llvm.IntegerConstant in project robovm by robovm.
the class ClassCompiler method createLookupFunction.
private void createLookupFunction(SootMethod m) {
Function function = FunctionBuilder.lookup(m, true);
mb.addFunction(function);
Variable reserved0 = function.newVariable(I8_PTR_PTR);
function.add(new Getelementptr(reserved0, function.getParameterRef(0), 0, 4));
Variable reserved1 = function.newVariable(I8_PTR_PTR);
function.add(new Getelementptr(reserved1, function.getParameterRef(0), 0, 5));
function.add(new Store(getString(m.getName()), reserved0.ref()));
function.add(new Store(getString(getDescriptor(m)), reserved1.ref()));
if (!sootClass.isInterface()) {
int vtableIndex = 0;
try {
VTable vtable = config.getVTableCache().get(sootClass);
vtableIndex = vtable.getEntry(m).getIndex();
} catch (IllegalArgumentException e) {
// VTable throws this if any of the superclasses of the class is actually an interface.
// Shouldn't happen frequently but the DRLVM test suite has some tests for this.
// Use 0 as vtableIndex since this lookup function will never be called anyway.
}
Value classPtr = call(function, OBJECT_CLASS, function.getParameterRef(1));
Value vtablePtr = call(function, CLASS_VITABLE, classPtr);
Variable funcPtrPtr = function.newVariable(I8_PTR_PTR);
function.add(new Getelementptr(funcPtrPtr, vtablePtr, 0, 1, vtableIndex));
Variable funcPtr = function.newVariable(I8_PTR);
function.add(new Load(funcPtr, funcPtrPtr.ref()));
Variable f = function.newVariable(function.getType());
function.add(new Bitcast(f, funcPtr.ref(), f.getType()));
Value result = tailcall(function, f.ref(), function.getParameterRefs());
function.add(new Ret(result));
} else {
ITable itable = config.getITableCache().get(sootClass);
ITable.Entry entry = itable.getEntry(m);
List<Value> args = new ArrayList<Value>();
args.add(function.getParameterRef(0));
args.add(getInfoStruct(function, sootClass));
args.add(function.getParameterRef(1));
args.add(new IntegerConstant(entry.getIndex()));
Value fptr = call(function, BC_LOOKUP_INTERFACE_METHOD_IMPL, args);
Variable f = function.newVariable(function.getType());
function.add(new Bitcast(f, fptr, f.getType()));
Value result = tailcall(function, f.ref(), function.getParameterRefs());
function.add(new Ret(result));
}
}
Aggregations