public static void convertPrimitiveToBoolean ( MethodVisitor mv , ClassNode type ) { if ( type == boolean_TYPE ) { return ; } // Special handling is done for floating point types in order to // handle checking for 0 or NaN values. if ( type == double_TYPE ) { convertDoubleToBoolean ( mv ) ; return ; } else if ( type == float_TYPE ) { convertFloatToBoolean ( mv ) ; return ; } Label trueLabel = new Label ( ) ; Label falseLabel = new Label ( ) ; // Convert long to int for IFEQ comparison using LCMP if ( type == long_TYPE ) { mv . visitInsn ( LCONST_0 ) ; mv . visitInsn ( LCMP ) ; } // This handles byte, short, char and int mv . visitJumpInsn ( IFEQ , falseLabel ) ; mv . visitInsn ( ICONST_1 ) ; mv . visitJumpInsn ( GOTO , trueLabel ) ; mv . visitLabel ( falseLabel ) ; mv . visitInsn ( ICONST_0 ) ; mv . visitLabel ( trueLabel ) ; }
Converts a primitive type to boolean .