예제 #1
0
  static void emitReturn(
      AsmBuilder builder, SkinnyMethodAdapter mv, Class returnType, Class nativeIntType) {
    if (returnType.isPrimitive()) {

      if (long.class == returnType) {
        mv.lreturn();

      } else if (float.class == returnType) {
        mv.freturn();

      } else if (double.class == returnType) {
        mv.dreturn();

      } else if (void.class == returnType) {
        mv.voidreturn();

      } else {
        mv.ireturn();
      }

    } else {
      boxValue(builder, mv, returnType, nativeIntType);
      mv.areturn();
    }
  }
예제 #2
0
 static void emitReturnOp(SkinnyMethodAdapter mv, Class returnType) {
   if (!returnType.isPrimitive()) {
     mv.areturn();
   } else if (long.class == returnType) {
     mv.lreturn();
   } else if (float.class == returnType) {
     mv.freturn();
   } else if (double.class == returnType) {
     mv.dreturn();
   } else if (void.class == returnType) {
     mv.voidreturn();
   } else {
     mv.ireturn();
   }
 }
예제 #3
0
  static void store(SkinnyMethodAdapter mv, Class type, LocalVariable var) {
    if (!type.isPrimitive()) {
      mv.astore(var);

    } else if (long.class == type) {
      mv.lstore(var);

    } else if (double.class == type) {
      mv.dstore(var);

    } else if (float.class == type) {
      mv.fstore(var);

    } else {
      mv.istore(var);
    }
  }
예제 #4
0
  static void load(SkinnyMethodAdapter mv, Class parameterType, LocalVariable parameter) {
    if (!parameterType.isPrimitive()) {
      mv.aload(parameter);

    } else if (long.class == parameterType) {
      mv.lload(parameter);

    } else if (float.class == parameterType) {
      mv.fload(parameter);

    } else if (double.class == parameterType) {
      mv.dload(parameter);

    } else {
      mv.iload(parameter);
    }
  }
예제 #5
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);
    }
  }