728 mv.visitLdcInsn(cst);
729 }
730 }
731
732 public void iconst(final int cst) {
733 if (cst >= -1 && cst <= 5) {
734 mv.visitInsn(Opcodes.ICONST_0 + cst);
735 } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {
736 mv.visitIntInsn(Opcodes.BIPUSH, cst);
737 } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
738 mv.visitIntInsn(Opcodes.SIPUSH, cst);
739 } else {
740 mv.visitLdcInsn(new Integer(cst));
741 }
742 }
743
744 public void lconst(final long cst) {
745 if (cst == 0L || cst == 1L) {
746 mv.visitInsn(Opcodes.LCONST_0 + (int) cst);
747 } else {
748 mv.visitLdcInsn(new Long(cst));
749 }
750 }
751
752 public void fconst(final float cst) {
753 int bits = Float.floatToIntBits(cst);
754 if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2
755 mv.visitInsn(Opcodes.FCONST_0 + (int) cst);
756 } else {
757 mv.visitLdcInsn(new Float(cst));
758 }
759 }
760
761 public void dconst(final double cst) {
762 long bits = Double.doubleToLongBits(cst);
763 if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d
764 mv.visitInsn(Opcodes.DCONST_0 + (int) cst);
765 } else {
766 mv.visitLdcInsn(new Double(cst));
767 }
768 }
|
728 mv.visitLdcInsn(cst);
729 }
730 }
731
732 public void iconst(final int cst) {
733 if (cst >= -1 && cst <= 5) {
734 mv.visitInsn(Opcodes.ICONST_0 + cst);
735 } else if (cst >= Byte.MIN_VALUE && cst <= Byte.MAX_VALUE) {
736 mv.visitIntInsn(Opcodes.BIPUSH, cst);
737 } else if (cst >= Short.MIN_VALUE && cst <= Short.MAX_VALUE) {
738 mv.visitIntInsn(Opcodes.SIPUSH, cst);
739 } else {
740 mv.visitLdcInsn(new Integer(cst));
741 }
742 }
743
744 public void lconst(final long cst) {
745 if (cst == 0L || cst == 1L) {
746 mv.visitInsn(Opcodes.LCONST_0 + (int) cst);
747 } else {
748 mv.visitLdcInsn(cst);
749 }
750 }
751
752 public void fconst(final float cst) {
753 int bits = Float.floatToIntBits(cst);
754 if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2
755 mv.visitInsn(Opcodes.FCONST_0 + (int) cst);
756 } else {
757 mv.visitLdcInsn(new Float(cst));
758 }
759 }
760
761 public void dconst(final double cst) {
762 long bits = Double.doubleToLongBits(cst);
763 if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d
764 mv.visitInsn(Opcodes.DCONST_0 + (int) cst);
765 } else {
766 mv.visitLdcInsn(new Double(cst));
767 }
768 }
|