Exemplo n.º 1
0
  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;
  }
Exemplo n.º 2
0
 protected Value createStackCopy(Function fn, Value value) {
   Variable stackCopy = fn.newVariable(new PointerType(value.getType()));
   fn.add(new Alloca(stackCopy, value.getType()));
   fn.add(new Store(value, stackCopy.ref()));
   return stackCopy.ref();
 }