List of usage examples for org.objectweb.asm Opcodes POP2
int POP2
To view the source code for org.objectweb.asm Opcodes POP2.
Click Source Link
From source file:org.graalvm.compiler.replacements.test.DeoptimizeOnExceptionTest.java
License:Open Source License
private static byte[] makeClazz() { // Code generated the class below using asm. String clazzName = DeoptimizeOnExceptionTest.class.getName().replace('.', '/'); final ClassWriter w = new ClassWriter(0); w.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, "t/TestJSR", null, "java/lang/Object", new String[] { "java/lang/Runnable" }); MethodVisitor mv = w.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, new String[] {}); mv.visitCode();/* ww w .ja va 2s. c o m*/ mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(10, 10); mv.visitEnd(); mv = w.visitMethod(Opcodes.ACC_PUBLIC, "run", "()V", null, null); mv.visitCode(); mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "getM", "()Ljava/lang/Object;", false); Label l1 = new Label(); mv.visitJumpInsn(Opcodes.JSR, l1); mv.visitInsn(Opcodes.RETURN); mv.visitLabel(l1); mv.visitVarInsn(Opcodes.ASTORE, 1); Label lElse = new Label(); Label lEnd = new Label(); mv.visitMethodInsn(Opcodes.INVOKESTATIC, "java/lang/System", "currentTimeMillis", "()J", false); mv.visitInsn(Opcodes.POP2); mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "getM", "()Ljava/lang/Object;", false); mv.visitInsn(Opcodes.DUP); mv.visitJumpInsn(Opcodes.IFNULL, lElse); mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "methodA", "()V", false); mv.visitJumpInsn(Opcodes.GOTO, lEnd); mv.visitLabel(lElse); mv.visitMethodInsn(Opcodes.INVOKESTATIC, clazzName, "methodB", "()V", false); mv.visitLabel(lEnd); mv.visitVarInsn(Opcodes.RET, 1); mv.visitMaxs(10, 10); mv.visitEnd(); return w.toByteArray(); }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitInsn(final int opcode) { final Object t1, t2, t3, t4; switch (opcode) { case Opcodes.NOP: case Opcodes.RETURN: break;/* w ww . java2s . c om*/ case Opcodes.ARETURN: case Opcodes.ATHROW: case Opcodes.FRETURN: case Opcodes.IRETURN: case Opcodes.MONITORENTER: case Opcodes.MONITOREXIT: case Opcodes.POP: pop(1); break; case Opcodes.DRETURN: case Opcodes.LRETURN: case Opcodes.POP2: pop(2); break; case Opcodes.AASTORE: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.FASTORE: case Opcodes.IASTORE: case Opcodes.SASTORE: pop(3); break; case Opcodes.LASTORE: case Opcodes.DASTORE: pop(4); break; case Opcodes.ICONST_M1: case Opcodes.ICONST_0: case Opcodes.ICONST_1: case Opcodes.ICONST_2: case Opcodes.ICONST_3: case Opcodes.ICONST_4: case Opcodes.ICONST_5: push(Opcodes.INTEGER); break; case Opcodes.ARRAYLENGTH: case Opcodes.F2I: case Opcodes.I2B: case Opcodes.I2C: case Opcodes.I2S: case Opcodes.INEG: pop(1); push(Opcodes.INTEGER); break; case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.D2I: case Opcodes.FCMPG: case Opcodes.FCMPL: case Opcodes.IADD: case Opcodes.IALOAD: case Opcodes.IAND: case Opcodes.IDIV: case Opcodes.IMUL: case Opcodes.IOR: case Opcodes.IREM: case Opcodes.ISHL: case Opcodes.ISHR: case Opcodes.ISUB: case Opcodes.IUSHR: case Opcodes.IXOR: case Opcodes.L2I: case Opcodes.SALOAD: pop(2); push(Opcodes.INTEGER); break; case Opcodes.DCMPG: case Opcodes.DCMPL: case Opcodes.LCMP: pop(4); push(Opcodes.INTEGER); break; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: push(Opcodes.FLOAT); break; case Opcodes.FNEG: case Opcodes.I2F: pop(1); push(Opcodes.FLOAT); break; case Opcodes.D2F: case Opcodes.FADD: case Opcodes.FALOAD: case Opcodes.FDIV: case Opcodes.FMUL: case Opcodes.FREM: case Opcodes.FSUB: case Opcodes.L2F: pop(2); push(Opcodes.FLOAT); break; case Opcodes.LCONST_0: case Opcodes.LCONST_1: push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.F2L: case Opcodes.I2L: pop(1); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.D2L: case Opcodes.LALOAD: case Opcodes.LNEG: pop(2); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.LSHL: case Opcodes.LSHR: case Opcodes.LUSHR: pop(3); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.LADD: case Opcodes.LAND: case Opcodes.LDIV: case Opcodes.LMUL: case Opcodes.LOR: case Opcodes.LREM: case Opcodes.LSUB: case Opcodes.LXOR: pop(4); push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.DCONST_0: case Opcodes.DCONST_1: push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.F2D: case Opcodes.I2D: pop(1); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.DALOAD: case Opcodes.DNEG: case Opcodes.L2D: pop(2); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.DADD: case Opcodes.DDIV: case Opcodes.DMUL: case Opcodes.DREM: case Opcodes.DSUB: pop(4); push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.ACONST_NULL: push(Opcodes.NULL); break; case Opcodes.AALOAD: pop(1); t1 = pop(); push(Type.getType(((String) t1).substring(1))); break; case Opcodes.DUP: t1 = pop(); push(t1); push(t1); break; case Opcodes.DUP_X1: t1 = pop(); t2 = pop(); push(t1); push(t2); push(t1); break; case Opcodes.DUP_X2: t1 = pop(); t2 = pop(); t3 = pop(); push(t1); push(t3); push(t2); push(t1); break; case Opcodes.DUP2: t1 = pop(); t2 = pop(); push(t2); push(t1); push(t2); push(t1); break; case Opcodes.DUP2_X1: t1 = pop(); t2 = pop(); t3 = pop(); push(t2); push(t1); push(t3); push(t2); push(t1); break; case Opcodes.DUP2_X2: t1 = pop(); t2 = pop(); t3 = pop(); t4 = pop(); push(t2); push(t1); push(t4); push(t3); push(t2); push(t1); break; case Opcodes.SWAP: t1 = pop(); t2 = pop(); push(t1); push(t2); break; default: throw new IllegalArgumentException(); } mv.visitInsn(opcode); }
From source file:org.jboss.byteman.agent.adapter.RuleGeneratorAdapter.java
License:Open Source License
/** * Generates a POP2 instruction. */ public void pop2() { visitInsn(Opcodes.POP2); }
From source file:org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter.java
License:Open Source License
/** * plant code to copy back any updated values from the argument array to the relevant local variable slots *//*w ww . j a va 2s . c om*/ private void doArgUpdate() { // at entry the top of the stack contains the object array // for an AT EXIT rule the entry below this is the return value Type objectType = Type.getType(Object.class); int arraySize = callArrayBindings.size(); int lastUpdated = -1; int returnIdx = -1; // identify which is the last index we will need to update. n.b. if we find a return value we will // update that last for (int i = 0; i < arraySize; i++) { Binding binding = callArrayBindings.get(i); if (binding.isUpdated()) { lastUpdated = i; if (binding.isReturn()) { returnIdx = i; } } } // if the return value is updated it gets done last if (returnIdx >= 0) { lastUpdated = returnIdx; } // write back all other args then stack new return value and drop old one for (int i = 0; i < arraySize; i++) { Binding binding = callArrayBindings.get(i); if (binding.isUpdated() && !binding.isReturn()) { // if this is the last update then we consume the arguments array // otherwise we need to copy it if (i != lastUpdated) { dup(); } push(i); arrayLoad(objectType); if (binding.isParam()) { int idx = binding.getIndex() - 1; unbox(argumentTypes[idx]); storeArg(idx); } else if (binding.isLocalVar()) { int idx = binding.getLocalIndex(); unbox(getLocalType(idx)); storeLocal(idx); } } } // if we had a return value to process then the args array will still be on top of the stack above // the old return value if (returnIdx >= 0) { // get rid of old return value remembering to use the correct type for $! // which varies depending if this is an AT EXIT or AFTER CALL rule if (saveValueType.getSize() == 2) { mv.visitInsn(Opcodes.DUP_X2); mv.visitInsn(Opcodes.POP); mv.visitInsn(Opcodes.POP2); } else { mv.visitInsn(Opcodes.SWAP); mv.visitInsn(Opcodes.POP); } push(returnIdx); arrayLoad(objectType); // use the correct type for $! which varies depending if this is an AT EXIT or AFTER CALL rule unbox(saveValueType); } }
From source file:org.jboss.byteman.rule.Action.java
License:Open Source License
public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException { int currentStack = compileContext.getStackCount(); for (Expression expr : action) { expr.compile(mv, compileContext); Type resultType = expr.getType(); // return and throw expressions don't actually leave a value on the stack even // though they may have a non-VOID value type boolean maybePop = !(expr instanceof ReturnExpression || expr instanceof ThrowExpression); if (maybePop && resultType != Type.VOID) { int expected = (resultType.getNBytes() > 4 ? 2 : 1); if (expected == 1) { mv.visitInsn(Opcodes.POP); compileContext.addStackCount(-1); } else if (expected == 2) { mv.visitInsn(Opcodes.POP2); compileContext.addStackCount(-2); }/* ww w. j av a 2 s. c o m*/ } } // check original stack height has been restored if (compileContext.getStackCount() != currentStack) { throw new CompileException("Action.compile : invalid stack height " + compileContext.getStackCount() + " expecting " + currentStack); } }
From source file:org.jboss.byteman.rule.expression.ComparisonExpression.java
License:Open Source License
public void compile(MethodVisitor mv, CompileContext compileContext) throws CompileException { // make sure we are at the right source line compileContext.notifySourceLine(line); Expression oper0 = getOperand(0); Expression oper1 = getOperand(1); int removed = 0; // evaluate the operands and ensure the reuslt is of the correct type for comparison adds 2 oper0.compile(mv, compileContext);/*w ww. j av a 2 s.c om*/ compileTypeConversion(oper0.getType(), comparisonType, mv, compileContext); oper1.compile(mv, compileContext); compileTypeConversion(oper1.getType(), comparisonType, mv, compileContext); // now do the appropriate type of comparison if (comparisonType == type.B || comparisonType == type.S || comparisonType == type.S || comparisonType == type.I) { Label elsetarget = new Label(); Label endtarget = new Label(); // we remove 2 words from the stack and then add 1 back removed = 2; switch (oper) { case LT: mv.visitJumpInsn(Opcodes.IF_ICMPGE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case LE: mv.visitJumpInsn(Opcodes.IF_ICMPGT, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case GT: mv.visitJumpInsn(Opcodes.IF_ICMPLE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case GE: mv.visitJumpInsn(Opcodes.IF_ICMPLT, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case EQ: mv.visitJumpInsn(Opcodes.IF_ICMPNE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case NE: mv.visitJumpInsn(Opcodes.IF_ICMPEQ, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; } } else if (comparisonType == type.J || comparisonType == type.F || comparisonType == type.D) { if (comparisonType == type.J) { mv.visitInsn(Opcodes.LCMP); // we remove four words from the stack and add 1 back removed = 4; } else if (comparisonType == type.F) { // we remove two words from the stack and add 1 back removed = 2; mv.visitInsn(Opcodes.FCMPG); } else if (comparisonType == type.D) { // we remove four words from the stack and add 1 back removed = 4; mv.visitInsn(Opcodes.DCMPG); } Label elsetarget = new Label(); Label endtarget = new Label(); switch (oper) { case LT: mv.visitJumpInsn(Opcodes.IFGE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case LE: mv.visitJumpInsn(Opcodes.IFGT, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case GT: mv.visitJumpInsn(Opcodes.IFLE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case GE: mv.visitJumpInsn(Opcodes.IFLT, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case EQ: mv.visitJumpInsn(Opcodes.IFNE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case NE: mv.visitJumpInsn(Opcodes.IFEQ, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; } } else if (comparable) { // we add a further two words setting up the relevant test then remove them // and also remove the original two words replacing them with a single word removed = 4; compileContext.addStackCount(2); // we need to deal with null values correctly // if op1 == null || op2 == null // then // EQ: // push value1 == value2 // NE: // push value1 != value2 // ow: // push false // else // execute compareTo or equals and test for the desired outcome // end if Label splittarget = new Label(); // else Label jointarget = new Label(); // end if mv.visitInsn(Opcodes.DUP2); // [... op1, op2 ] ==> [... op1, op2, op1, op2] mv.visitInsn(Opcodes.POP); // [... op1, op2, op1, op2 ] ==> [... op1, op2, op1] // if op1 == null mv.visitJumpInsn(Opcodes.IFNULL, splittarget); // [... op1, op2, op1] ==> [... op1, op2] mv.visitInsn(Opcodes.DUP); // [... op1, op2 ] ==> [... op1, op2, op2] // || op2 == null mv.visitJumpInsn(Opcodes.IFNULL, splittarget); // [... op1, op2, op2] ==> [... op1, op2] // so, it is ok to call compareTo leaving an int or equals leaving a boolean if (oper != EQ && oper != NE) { mv.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/lang/Comparable", "compareTo", "(Ljava/lang/Object;)I"); } else { mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z"); } // now if we did a compareTo we need to generate the required boolean Label elsetarget = new Label(); Label endtarget = new Label(); // if needed the convert the compareTo result to the required boolean outcome switch (oper) { case LT: mv.visitJumpInsn(Opcodes.IFGE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case LE: mv.visitJumpInsn(Opcodes.IFGT, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case GT: mv.visitJumpInsn(Opcodes.IFLE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case GE: mv.visitJumpInsn(Opcodes.IFLT, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); break; case NE: mv.visitJumpInsn(Opcodes.IFEQ, elsetarget); mv.visitLdcInsn(false); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(true); mv.visitLabel(endtarget); break; } // skip to the join point mv.visitJumpInsn(Opcodes.GOTO, jointarget); // label the split point mv.visitLabel(splittarget); if (oper == EQ) { elsetarget = new Label(); endtarget = new Label(); mv.visitJumpInsn(Opcodes.IF_ACMPEQ, elsetarget); mv.visitLdcInsn(false); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(true); mv.visitLabel(endtarget); } else if (oper == NE) { elsetarget = new Label(); endtarget = new Label(); mv.visitJumpInsn(Opcodes.IF_ACMPNE, elsetarget); mv.visitLdcInsn(false); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(true); mv.visitLabel(endtarget); } else { // pop the operands and stack false mv.visitInsn(Opcodes.POP2); mv.visitLdcInsn(false); } // label the join point mv.visitLabel(jointarget); } else if (comparisonType == Type.Z) { // unboxed booleans need special treatment // we remove two words replacing them with a single word removed = 2; Label elsetarget = new Label(); Label endtarget = new Label(); mv.visitJumpInsn(Opcodes.IFEQ, elsetarget); // on this branch for EQ the stacked value is what we need and for NE // the stacked value needs flipping if (oper == NE) { Label elsetarget2 = new Label(); mv.visitJumpInsn(Opcodes.IFEQ, elsetarget2); mv.visitLdcInsn(false); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget2); mv.visitLdcInsn(true); } mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); // on this branch for NE the stacked value is what we need and for EQ // the stacked value needs flipping if (oper == EQ) { Label elsetarget2 = new Label(); mv.visitJumpInsn(Opcodes.IFEQ, elsetarget2); mv.visitLdcInsn(false); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget2); mv.visitLdcInsn(true); } mv.visitLabel(endtarget); } else if (comparisonType == Type.BOOLEAN) { // boxed booleans need special treatment // we remove two words replacing them with a single word removed = 2; Label elsetarget = new Label(); Label endtarget = new Label(); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java.lang.Boolean", "equals", "(Ljava/lang/Boolean;)Z"); if (oper == NE) { mv.visitJumpInsn(Opcodes.IFEQ, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); } } else { // we remove two words replacing them with a single word removed = 2; Label elsetarget = new Label(); Label endtarget = new Label(); if (oper == EQ) { mv.visitJumpInsn(Opcodes.IF_ACMPNE, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); } else { mv.visitJumpInsn(Opcodes.IF_ACMPEQ, elsetarget); mv.visitLdcInsn(true); mv.visitJumpInsn(Opcodes.GOTO, endtarget); mv.visitLabel(elsetarget); mv.visitLdcInsn(false); mv.visitLabel(endtarget); } } compileContext.addStackCount(1 - removed); }
From source file:org.mbte.groovypp.compiler.bytecode.BytecodeExpr.java
License:Apache License
/** * box the primitive value on the stack//from w w w .j a v a 2s . c o m * * @param type * @param mv */ public void quickBoxIfNecessary(ClassNode type, MethodVisitor mv) { String descr = getTypeDescription(type); if (type == boolean_TYPE) { boxBoolean(mv); } else if (isPrimitiveType(type) && type != VOID_TYPE) { ClassNode wrapper = TypeUtil.wrapSafely(type); String internName = getClassInternalName(wrapper); mv.visitTypeInsn(Opcodes.NEW, internName); mv.visitInsn(Opcodes.DUP); if (type == double_TYPE || type == long_TYPE) { mv.visitInsn(Opcodes.DUP2_X2); mv.visitInsn(Opcodes.POP2); } else { mv.visitInsn(Opcodes.DUP2_X1); mv.visitInsn(Opcodes.POP2); } mv.visitMethodInsn(Opcodes.INVOKESPECIAL, internName, "<init>", "(" + descr + ")V"); } }
From source file:org.mbte.groovypp.compiler.bytecode.BytecodeExpr.java
License:Apache License
public void swapWithObject(ClassNode type, MethodVisitor mv) { if (type == long_TYPE || type == double_TYPE) { mv.visitInsn(Opcodes.DUP2_X1);//from w w w .j a v a 2 s . c om mv.visitInsn(Opcodes.POP2); } else { mv.visitInsn(Opcodes.SWAP); } }
From source file:org.mbte.groovypp.compiler.bytecode.BytecodeExpr.java
License:Apache License
public static void pop(ClassNode type, MethodVisitor mv) { if (type == double_TYPE || type == long_TYPE) mv.visitInsn(Opcodes.POP2); else/*from w w w.jav a 2 s . c om*/ mv.visitInsn(Opcodes.POP); }
From source file:org.openquark.cal.internal.javamodel.AsmJavaBytecodeGenerator.java
License:Open Source License
/** * @param type/*ww w .j a va2 s.c om*/ * @return the POP or POP2 instruction, depending on type. */ private static int getPopOpCode(JavaTypeName type) { switch (type.getTag()) { case JavaTypeName.BOOLEAN_TAG: case JavaTypeName.BYTE_TAG: case JavaTypeName.SHORT_TAG: case JavaTypeName.CHAR_TAG: case JavaTypeName.INT_TAG: case JavaTypeName.FLOAT_TAG: case JavaTypeName.ARRAY_TAG: case JavaTypeName.OBJECT_TAG: return Opcodes.POP; case JavaTypeName.LONG_TAG: case JavaTypeName.DOUBLE_TAG: return Opcodes.POP2; case JavaTypeName.VOID_TAG: default: { throw new IllegalArgumentException("invalid type: " + type); } } }