List of usage examples for org.objectweb.asm Opcodes ICONST_0
int ICONST_0
To view the source code for org.objectweb.asm Opcodes ICONST_0.
Click Source Link
From source file:lucee.transformer.bytecode.visitor.DecisionDoubleVisitor.java
License:Open Source License
public void visitEnd(BytecodeContext bc) { GeneratorAdapter adapter = bc.getAdapter(); Label l1 = new Label(); Label l2 = new Label(); adapter.visitInsn(Opcodes.DCMPL);//from w w w. jav a 2s . co m adapter.visitJumpInsn(operation, l1); adapter.visitInsn(Opcodes.ICONST_1); adapter.visitJumpInsn(Opcodes.GOTO, l2); adapter.visitLabel(l1); adapter.visitInsn(Opcodes.ICONST_0); adapter.visitLabel(l2); }
From source file:lucee.transformer.bytecode.visitor.DecisionIntVisitor.java
License:Open Source License
public void visitEnd(BytecodeContext bc) { GeneratorAdapter adapter = bc.getAdapter(); Label l1 = new Label(); adapter.visitJumpInsn(operation, l1); //mv.visitJumpInsn(IF_ICMPGT, l1); adapter.visitInsn(Opcodes.ICONST_0); Label l2 = new Label(); adapter.visitJumpInsn(Opcodes.GOTO, l2); adapter.visitLabel(l1);/* w ww . j a va 2s . c om*/ adapter.visitInsn(Opcodes.ICONST_1); adapter.visitLabel(l2); }
From source file:lucee.transformer.bytecode.visitor.NotVisitor.java
License:Open Source License
public static void visitNot(BytecodeContext bc) { GeneratorAdapter adapter = bc.getAdapter(); Label l1 = new Label(); adapter.visitJumpInsn(Opcodes.IFEQ, l1); adapter.visitInsn(Opcodes.ICONST_0); Label l2 = new Label(); adapter.visitJumpInsn(Opcodes.GOTO, l2); adapter.visitLabel(l1);//from ww w. j av a2 s.c o m adapter.visitInsn(Opcodes.ICONST_1); adapter.visitLabel(l2); }
From source file:name.martingeisse.minimal.compiler.Compiler.java
License:Open Source License
/** * Compiles a {@link MethodNode} to MCode. * //w w w . j a v a 2s . c o m * @param methodNode the method node to compile * @return the compiled code */ public ImmutableList<MCodeEntry> compile(final MethodNode methodNode) { for (int i = 0; i < methodNode.instructions.size(); i++) { final AbstractInsnNode instruction = methodNode.instructions.get(i); if (instruction instanceof LineNumberNode) { // ignored } else if (instruction instanceof FrameNode) { // this could be useful in the future } else if (instruction instanceof LabelNode) { label(((LabelNode) instruction).getLabel()); } else if (instruction instanceof InsnNode) { switch (instruction.getOpcode()) { case Opcodes.ICONST_M1: iconst(-1); break; case Opcodes.ICONST_0: iconst(0); break; case Opcodes.ICONST_1: iconst(1); break; case Opcodes.ICONST_2: iconst(2); break; case Opcodes.ICONST_3: iconst(3); break; case Opcodes.ICONST_4: iconst(4); break; case Opcodes.ICONST_5: iconst(5); break; default: unsupported(instruction); break; } } else if (instruction instanceof VarInsnNode) { final VarInsnNode varInsnNode = (VarInsnNode) instruction; switch (varInsnNode.getOpcode()) { case Opcodes.ILOAD: iload(varInsnNode.var); break; case Opcodes.ISTORE: istore(varInsnNode.var); break; default: unsupported(instruction); break; } } else if (instruction instanceof IincInsnNode) { final IincInsnNode iincInsnNode = (IincInsnNode) instruction; iinc(iincInsnNode.var, iincInsnNode.incr); } else if (instruction instanceof JumpInsnNode) { final JumpInsnNode jumpInsnNode = (JumpInsnNode) instruction; switch (jumpInsnNode.getOpcode()) { case Opcodes.IFEQ: case Opcodes.IFNE: case Opcodes.IFLT: case Opcodes.IFGE: case Opcodes.IFGT: case Opcodes.IFLE: branch1(jumpInsnNode.label.getLabel(), jumpInsnNode.getOpcode()); break; case Opcodes.IF_ICMPEQ: case Opcodes.IF_ICMPNE: case Opcodes.IF_ICMPLT: case Opcodes.IF_ICMPGE: case Opcodes.IF_ICMPGT: case Opcodes.IF_ICMPLE: branch2(jumpInsnNode.label.getLabel(), jumpInsnNode.getOpcode()); break; case Opcodes.IFNULL: case Opcodes.IFNONNULL: // unsupported: one-argument reference comparison operator unsupported(instruction); break; case Opcodes.IF_ACMPEQ: case Opcodes.IF_ACMPNE: // unsupported: two-argument reference comparison operator unsupported(instruction); break; case Opcodes.GOTO: jump(jumpInsnNode.label.getLabel()); break; case Opcodes.JSR: jsr(jumpInsnNode.label.getLabel()); break; default: unsupported(instruction); break; } } else if (instruction instanceof IntInsnNode) { final IntInsnNode intInsnNode = (IntInsnNode) instruction; if (instruction.getOpcode() == Opcodes.BIPUSH || instruction.getOpcode() == Opcodes.SIPUSH) { iconst(intInsnNode.operand); } else { // NEWARRAY unsupported(instruction); } } else if (instruction instanceof MethodInsnNode) { final MethodInsnNode methodInsnNode = (MethodInsnNode) instruction; if (methodInsnNode.getOpcode() == Opcodes.INVOKESTATIC) { if (methodInsnNode.owner.replace('/', '.').equals(Native.class.getName())) { nativeCall(methodInsnNode.name, methodInsnNode.desc); } else { unsupported(instruction); } } else { unsupported(instruction); } } else { unsupported(instruction); } } return builder.build(); }
From source file:net.sourceforge.cobertura.instrument.pass3.AtomicArrayCodeProvider.java
License:GNU General Public License
/** * <pre>/*from w w w .ja v a 2s. c o m*/ * int[] __cobertura_get_and_reset_counters() { * int[] res = new int[counters.length()]; * for(int i=0; i<counters.length(); i++){ * res[i]=counters.getAndSet(i, 0); * } * return res; * } * </pre> */ public void generateCoberturaGetAndResetCountersMethod(ClassVisitor cv, String className) { MethodVisitor mv = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, COBERTURA_GET_AND_RESET_COUNTERS_METHOD_NAME, "()[I", null, null); mv.visitCode(); mv.visitFieldInsn(Opcodes.GETSTATIC, className, COBERTURA_COUNTERS_FIELD_NAME, COBERTURA_COUNTERS_FIELD_TYPE); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/concurrent/atomic/AtomicIntegerArray", "length", "()I"); mv.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_INT); mv.visitVarInsn(Opcodes.ASTORE, 0); mv.visitInsn(Opcodes.ICONST_0); mv.visitVarInsn(Opcodes.ISTORE, 1); Label l3 = new Label(); mv.visitJumpInsn(Opcodes.GOTO, l3); Label l4 = new Label(); mv.visitLabel(l4); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitVarInsn(Opcodes.ILOAD, 1); mv.visitFieldInsn(Opcodes.GETSTATIC, className, COBERTURA_COUNTERS_FIELD_NAME, COBERTURA_COUNTERS_FIELD_TYPE); mv.visitVarInsn(Opcodes.ILOAD, 1); mv.visitInsn(Opcodes.ICONST_0); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/concurrent/atomic/AtomicIntegerArray", "getAndSet", "(II)I"); mv.visitInsn(Opcodes.IASTORE); mv.visitIincInsn(1, 1); mv.visitLabel(l3); mv.visitVarInsn(Opcodes.ILOAD, 1); mv.visitFieldInsn(Opcodes.GETSTATIC, className, COBERTURA_COUNTERS_FIELD_NAME, COBERTURA_COUNTERS_FIELD_TYPE); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/util/concurrent/atomic/AtomicIntegerArray", "length", "()I"); mv.visitJumpInsn(Opcodes.IF_ICMPLT, l4); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(0, 0);//will be recalculated by writer mv.visitEnd(); }
From source file:net.transmutator4j.mutations.BooleanMutation.java
License:Open Source License
private int getOppositeConstantOf(int opcode) { if (opcode == Opcodes.ICONST_0) { return Opcodes.ICONST_1; }/* w w w .j av a 2 s . c o m*/ return Opcodes.ICONST_0; }
From source file:net.transmutator4j.mutations.BooleanMutation.java
License:Open Source License
private String getConstantFor(int opcode) { if (opcode == Opcodes.ICONST_0) { return "0 (or false)"; }/*from www . j a v a 2s .c o m*/ return "1 (or true)"; }
From source file:net.transmutator4j.mutations.TestBooleanMutation.java
License:Open Source License
@Test public void isBooleanOpcode() { assertTrue(BooleanMutation.isMutatable(Opcodes.ICONST_0)); assertTrue(BooleanMutation.isMutatable(Opcodes.ICONST_1)); }
From source file:net.transmutator4j.mutations.TestBooleanMutation.java
License:Open Source License
@Test public void mutateBooleanFalse() { BooleanMutation mutatedFalse = BooleanMutation.getMutationFor(Opcodes.ICONST_0); assertEquals(Opcodes.ICONST_0, mutatedFalse.getOriginalOpCode()); assertEquals(Opcodes.ICONST_1, mutatedFalse.getMutatedOpCode()); assertEquals("changed constant 0 (or false) to 1 (or true)", mutatedFalse.description()); }
From source file:net.transmutator4j.mutations.TestBooleanMutation.java
License:Open Source License
@Test public void mutateBooleanTrue() { BooleanMutation mutatedFalse = BooleanMutation.getMutationFor(Opcodes.ICONST_1); assertEquals(Opcodes.ICONST_1, mutatedFalse.getOriginalOpCode()); assertEquals(Opcodes.ICONST_0, mutatedFalse.getMutatedOpCode()); assertEquals("changed constant 1 (or true) to 0 (or false)", mutatedFalse.description()); }