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(); } }
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(); } }
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); } }
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); } }
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); } }