List of usage examples for org.objectweb.asm Opcodes LONG
Integer LONG
To view the source code for org.objectweb.asm Opcodes LONG.
Click Source Link
From source file:org.jacoco.core.internal.flow.FrameSnapshotTest.java
License:Open Source License
@Test public void should_decrease_stack_when_popCount_is_given() { analyzer.visitInsn(Opcodes.ICONST_0); analyzer.visitInsn(Opcodes.LCONST_0); analyzer.visitInsn(Opcodes.ICONST_0); analyzer.visitInsn(Opcodes.ICONST_0); frame = FrameSnapshot.create(analyzer, 2); final Object[] stack = arr(Opcodes.INTEGER, Opcodes.LONG); expectedVisitor.visitFrame(Opcodes.F_FULL, 1, arr("Foo"), 2, stack); }
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;// www . j av a2 s. com 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.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitVarInsn(final int opcode, final int var) { final Object t; switch (opcode) { case Opcodes.ALOAD: push(get(var)); break;/*from ww w . j ava 2 s . c o m*/ case Opcodes.ILOAD: push(Opcodes.INTEGER); break; case Opcodes.FLOAD: push(Opcodes.FLOAT); break; case Opcodes.LLOAD: push(Opcodes.LONG); push(Opcodes.TOP); break; case Opcodes.DLOAD: push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Opcodes.ASTORE: case Opcodes.ISTORE: case Opcodes.FSTORE: t = pop(); set(var, t); break; case Opcodes.LSTORE: case Opcodes.DSTORE: pop(1); t = pop(); set(var, t); set(var + 1, Opcodes.TOP); break; default: throw new IllegalArgumentException(); } mv.visitVarInsn(opcode, var); }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
@Override public void visitLdcInsn(final Object cst) { if (cst instanceof Integer) { push(Opcodes.INTEGER);//from ww w . j a v a2 s. co m } else if (cst instanceof Float) { push(Opcodes.FLOAT); } else if (cst instanceof Long) { push(Opcodes.LONG); push(Opcodes.TOP); } else if (cst instanceof Double) { push(Opcodes.DOUBLE); push(Opcodes.TOP); } else if (cst instanceof String) { push("java/lang/String"); } else if (cst instanceof Type) { push("java/lang/Class"); } else { throw new IllegalArgumentException(); } mv.visitLdcInsn(cst); }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
private void push(final Type type) { switch (type.getSort()) { case Type.VOID: break;//from w w w. ja va 2 s .co m case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.INT: case Type.SHORT: push(Opcodes.INTEGER); break; case Type.FLOAT: push(Opcodes.FLOAT); break; case Type.LONG: push(Opcodes.LONG); push(Opcodes.TOP); break; case Type.DOUBLE: push(Opcodes.DOUBLE); push(Opcodes.TOP); break; case Type.ARRAY: case Type.OBJECT: push(type.getInternalName()); break; default: throw new AssertionError(type); } }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
private void set(final int pos, final Type type) { switch (type.getSort()) { case Type.BOOLEAN: case Type.BYTE: case Type.CHAR: case Type.INT: case Type.SHORT: set(pos, Opcodes.INTEGER);//from w ww. j a v a 2 s . c om break; case Type.FLOAT: set(pos, Opcodes.FLOAT); break; case Type.LONG: set(pos, Opcodes.LONG); set(pos + 1, Opcodes.TOP); break; case Type.DOUBLE: set(pos, Opcodes.DOUBLE); set(pos + 1, Opcodes.TOP); break; case Type.ARRAY: case Type.OBJECT: set(pos, type.getInternalName()); break; default: throw new AssertionError(type); } }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
/** * Expand double word types into two slots. *//*w w w . j a v a 2 s. c om*/ private int expand(final Object[] source, final int size, final Object[] target) { int targetIdx = 0; for (int sourceIdx = 0; sourceIdx < size; sourceIdx++) { final Object type = source[sourceIdx]; target[targetIdx++] = type; if (type == Opcodes.LONG || type == Opcodes.DOUBLE) { target[targetIdx++] = Opcodes.TOP; } } return targetIdx; }
From source file:org.jacoco.core.internal.instr.FrameTracker.java
License:Open Source License
/** * Reduce double word types into a single slot. *//*from w w w . jav a 2 s.c o m*/ private int reduce(final Object[] source, final int size, final Object[] target) { int targetIdx = 0; for (int sourceIdx = 0; sourceIdx < size; sourceIdx++) { final Object type = source[sourceIdx]; target[targetIdx++] = type; if (type == Opcodes.LONG || type == Opcodes.DOUBLE) { sourceIdx++; } } return targetIdx; }
From source file:org.jacoco.core.internal.instr.ProbeInserter.java
License:Open Source License
@Override public final void visitFrame(final int type, final int nLocal, final Object[] local, final int nStack, final Object[] stack) { if (type != Opcodes.F_NEW) { // uncompressed frame throw new IllegalArgumentException("ClassReader.accept() should be called with EXPAND_FRAMES flag"); }// w ww .j av a 2s. com final Object[] newLocal = new Object[Math.max(nLocal, variable) + 1]; int idx = 0; // Arrays index for existing locals int newIdx = 0; // Array index for new locals int pos = 0; // Current variable position while (idx < nLocal || pos <= variable) { if (pos == variable) { newLocal[newIdx++] = InstrSupport.DATAFIELD_DESC; pos++; } else { if (idx < nLocal) { final Object t = local[idx++]; newLocal[newIdx++] = t; pos++; if (t == Opcodes.LONG || t == Opcodes.DOUBLE) { pos++; } } else { // Fill unused slots with TOP newLocal[newIdx++] = Opcodes.TOP; pos++; } } } mv.visitFrame(type, newIdx, newLocal, nStack, stack); }
From source file:org.jacoco.core.internal.instr.ProbeInserterTest.java
License:Open Source License
@Test public void testVisitFrame() { ProbeInserter pi = new ProbeInserter(0, "(J)V", actualVisitor, arrayStrategy); pi.visitFrame(Opcodes.F_NEW, 3, new Object[] { "Foo", Opcodes.LONG, "java/lang/String" }, 0, new Object[0]); expectedVisitor.visitFrame(Opcodes.F_NEW, 4, new Object[] { "Foo", Opcodes.LONG, "[Z", "java/lang/String" }, 0, new Object[0]); }