src/java.base/share/classes/jdk/internal/org/objectweb/asm/commons/InstructionAdapter.java

Print this page




 720     public void nop() {
 721         mv.visitInsn(Opcodes.NOP);
 722     }
 723 
 724     public void aconst(final Object cst) {
 725         if (cst == null) {
 726             mv.visitInsn(Opcodes.ACONST_NULL);
 727         } else {
 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     }
 769 
 770     public void tconst(final Type type) {
 771         mv.visitLdcInsn(type);
 772     }
 773 
 774     public void hconst(final Handle handle) {
 775         mv.visitLdcInsn(handle);
 776     }
 777 
 778     public void load(final int var, final Type type) {
 779         mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), var);
 780     }
 781 
 782     public void aload(final Type type) {
 783         mv.visitInsn(type.getOpcode(Opcodes.IALOAD));
 784     }
 785 
 786     public void store(final int var, final Type type) {




 720     public void nop() {
 721         mv.visitInsn(Opcodes.NOP);
 722     }
 723 
 724     public void aconst(final Object cst) {
 725         if (cst == null) {
 726             mv.visitInsn(Opcodes.ACONST_NULL);
 727         } else {
 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(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(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(cst);
 767         }
 768     }
 769 
 770     public void tconst(final Type type) {
 771         mv.visitLdcInsn(type);
 772     }
 773 
 774     public void hconst(final Handle handle) {
 775         mv.visitLdcInsn(handle);
 776     }
 777 
 778     public void load(final int var, final Type type) {
 779         mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), var);
 780     }
 781 
 782     public void aload(final Type type) {
 783         mv.visitInsn(type.getOpcode(Opcodes.IALOAD));
 784     }
 785 
 786     public void store(final int var, final Type type) {