/** * For use in mathematical operators, handles converting from a (possibly boxed) * number on the stack to a primitive numeric type. * <p>For example, from a Integer to a double, just need to call 'Number.doubleValue()' * but from an int to a double, need to use the bytecode 'i2d'. * @param mv the method visitor when instructions should be appended * @param stackDescriptor a descriptor of the operand on the stack * @param targetDescriptor a primitive type descriptor */ public static void insertNumericUnboxOrPrimitiveTypeCoercion( MethodVisitor mv, @Nullable String stackDescriptor, char targetDescriptor) { if (!CodeFlow.isPrimitive(stackDescriptor)) { CodeFlow.insertUnboxNumberInsns(mv, targetDescriptor, stackDescriptor); } else { CodeFlow.insertAnyNecessaryTypeConversionBytecodes(mv, targetDescriptor, stackDescriptor); } }
/** * For use in mathematical operators, handles converting from a (possibly boxed) * number on the stack to a primitive numeric type. * <p>For example, from a Integer to a double, just need to call 'Number.doubleValue()' * but from an int to a double, need to use the bytecode 'i2d'. * @param mv the method visitor when instructions should be appended * @param stackDescriptor a descriptor of the operand on the stack * @param targetDescriptor a primitive type descriptor */ public static void insertNumericUnboxOrPrimitiveTypeCoercion( MethodVisitor mv, @Nullable String stackDescriptor, char targetDescriptor) { if (!CodeFlow.isPrimitive(stackDescriptor)) { CodeFlow.insertUnboxNumberInsns(mv, targetDescriptor, stackDescriptor); } else { CodeFlow.insertAnyNecessaryTypeConversionBytecodes(mv, targetDescriptor, stackDescriptor); } }
/** * For use in mathematical operators, handles converting from a (possibly boxed) * number on the stack to a primitive numeric type. * <p>For example, from a Integer to a double, just need to call 'Number.doubleValue()' * but from an int to a double, need to use the bytecode 'i2d'. * @param mv the method visitor when instructions should be appended * @param stackDescriptor a descriptor of the operand on the stack * @param targetDescriptor a primitive type descriptor */ public static void insertNumericUnboxOrPrimitiveTypeCoercion( MethodVisitor mv, @Nullable String stackDescriptor, char targetDescriptor) { if (!CodeFlow.isPrimitive(stackDescriptor)) { CodeFlow.insertUnboxNumberInsns(mv, targetDescriptor, stackDescriptor); } else { CodeFlow.insertAnyNecessaryTypeConversionBytecodes(mv, targetDescriptor, stackDescriptor); } }