/** * Generates a DUP instruction. */ public void dup() { mv.visitInsn(Opcodes.DUP); }
/** * Generates a DUP2_X1 instruction. */ public void dup2X1() { mv.visitInsn(Opcodes.DUP2_X1); }
/** * Generates a SWAP instruction. */ public void swap() { mv.visitInsn(Opcodes.SWAP); }
/** * Generates the instruction to compute the length of an array. */ public void arrayLength() { mv.visitInsn(Opcodes.ARRAYLENGTH); }
/** * Generates the instruction to throw an exception. */ public void throwException() { mv.visitInsn(Opcodes.ATHROW); }
/** * Generates the instruction to get the monitor of the top stack value. */ public void monitorEnter() { mv.visitInsn(Opcodes.MONITORENTER); }
@Override public void visitInsn(final int opcode) { minSize += 1; maxSize += 1; if (mv != null) { mv.visitInsn(opcode); } }
/** * Generates a POP2 instruction. */ public void pop2() { mv.visitInsn(Opcodes.POP2); }
/** * Generates a DUP2 instruction. */ public void dup2() { mv.visitInsn(Opcodes.DUP2); }
@Override public void visitInsn(final int opcode) { p.visitInsn(opcode); super.visitInsn(opcode); }
public void fconst(final float cst) { int bits = Float.floatToIntBits(cst); if (bits == 0L || bits == 0x3f800000 || bits == 0x40000000) { // 0..2 mv.visitInsn(Opcodes.FCONST_0 + (int) cst); } else { mv.visitLdcInsn(new Float(cst)); } }
/** * Makes the given visitor visit this instruction. * * @param mv * a method visitor. */ @Override public void accept(final MethodVisitor mv) { mv.visitInsn(opcode); acceptAnnotations(mv); }
/** * Generates the instruction to store an element in an array. * * @param type * the type of the array element to be stored. */ public void arrayStore(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IASTORE)); }
/** * Generates the instruction to load an element from an array. * * @param type * the type of the array element to be loaded. */ public void arrayLoad(final Type type) { mv.visitInsn(type.getOpcode(Opcodes.IALOAD)); }
public void aconst(final Object cst) { if (cst == null) { mv.visitInsn(Opcodes.ACONST_NULL); } else { mv.visitLdcInsn(cst); } }
public void dconst(final double cst) { long bits = Double.doubleToLongBits(cst); if (bits == 0L || bits == 0x3ff0000000000000L) { // +0.0d and 1.0d mv.visitInsn(Opcodes.DCONST_0 + (int) cst); } else { mv.visitLdcInsn(new Double(cst)); } }
@Override public void visitInsn(final int opcode) { if (mv != null) { mv.visitInsn(opcode); } execute(opcode, 0, null); if ((opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN) || opcode == Opcodes.ATHROW) { this.locals = null; this.stack = null; } }
/** * Generates the instruction to return the top stack value to the caller. */ public void returnValue() { mv.visitInsn(returnType.getOpcode(Opcodes.IRETURN)); }
@Override public void visitEnd() { if (clinit != null) { clinit.visitInsn(Opcodes.RETURN); clinit.visitMaxs(0, 0); } cv.visitEnd(); } }