Esempio n. 1
0
 private static void unboxPointerOrStruct(
     final SkinnyMethodAdapter mv, final Class type, final Class nativeType) {
   mv.invokestatic(
       p(AsmRuntime.class),
       long.class == nativeType ? "longValue" : "intValue",
       sig(nativeType, type));
 }
Esempio n. 2
0
  static void boxValue(
      AsmBuilder builder, SkinnyMethodAdapter mv, Class boxedType, Class unboxedType) {
    if (boxedType == unboxedType || boxedType.isPrimitive()) {

    } else if (Boolean.class.isAssignableFrom(boxedType)) {
      narrow(mv, unboxedType, boolean.class);
      mv.invokestatic(Boolean.class, "valueOf", Boolean.class, boolean.class);

    } else if (Pointer.class.isAssignableFrom(boxedType)) {
      getfield(mv, builder, builder.getRuntimeField());
      mv.invokestatic(
          AsmRuntime.class, "pointerValue", Pointer.class, unboxedType, jnr.ffi.Runtime.class);

    } else if (Address.class == boxedType) {
      mv.invokestatic(boxedType, "valueOf", boxedType, unboxedType);

    } else if (Number.class.isAssignableFrom(boxedType) && boxedType(unboxedType) == boxedType) {
      mv.invokestatic(boxedType, "valueOf", boxedType, unboxedType);

    } else {
      throw new IllegalArgumentException(
          "cannot box value of type " + unboxedType + " to " + boxedType);
    }
  }