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:com.codename1.tools.translator.Util.java
License:Open Source License
public static char[] getStackOutputTypes(Instruction instr) { char[] out = instr.getStackOutputTypes(); if (out != null) { return out; }/*from w w w . java2s. c om*/ switch (instr.getOpcode()) { case Opcodes.NOP: case Opcodes.BASTORE: case Opcodes.CASTORE: case Opcodes.SASTORE: case Opcodes.IASTORE: case Opcodes.LASTORE: case Opcodes.FASTORE: case Opcodes.DASTORE: case Opcodes.AASTORE: case Opcodes.POP: case Opcodes.POP2: case Opcodes.MONITORENTER: case Opcodes.MONITOREXIT: case Opcodes.ATHROW: return new char[0]; case Opcodes.ACONST_NULL: case Opcodes.AALOAD: case Opcodes.NEWARRAY: return new char[] { 'o' }; 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: case Opcodes.BALOAD: case Opcodes.CALOAD: case Opcodes.IALOAD: case Opcodes.SALOAD: case Opcodes.IADD: case Opcodes.ISUB: case Opcodes.IMUL: case Opcodes.IDIV: case Opcodes.IREM: case Opcodes.INEG: case Opcodes.ISHL: case Opcodes.ISHR: case Opcodes.IUSHR: case Opcodes.IAND: case Opcodes.IOR: case Opcodes.IXOR: case Opcodes.F2I: case Opcodes.D2I: case Opcodes.L2I: case Opcodes.I2C: case Opcodes.I2S: case Opcodes.LCMP: case Opcodes.FCMPG: case Opcodes.FCMPL: case Opcodes.DCMPL: case Opcodes.DCMPG: case Opcodes.ARRAYLENGTH: case Opcodes.SIPUSH: case Opcodes.BIPUSH: return new char[] { 'i' }; case Opcodes.LCONST_0: case Opcodes.LCONST_1: case Opcodes.LALOAD: case Opcodes.LADD: case Opcodes.LSUB: case Opcodes.LMUL: case Opcodes.LDIV: case Opcodes.LREM: case Opcodes.LNEG: case Opcodes.LSHL: case Opcodes.LSHR: case Opcodes.LUSHR: case Opcodes.LAND: case Opcodes.LOR: case Opcodes.LXOR: case Opcodes.I2L: case Opcodes.F2L: case Opcodes.D2L: return new char[] { 'l' }; case Opcodes.FCONST_0: case Opcodes.FCONST_1: case Opcodes.FCONST_2: case Opcodes.FALOAD: case Opcodes.FADD: case Opcodes.FSUB: case Opcodes.FMUL: case Opcodes.FDIV: case Opcodes.FREM: case Opcodes.FNEG: case Opcodes.I2F: case Opcodes.D2F: case Opcodes.L2F: return new char[] { 'f' }; case Opcodes.DCONST_0: case Opcodes.DCONST_1: case Opcodes.DALOAD: case Opcodes.DADD: case Opcodes.DSUB: case Opcodes.DMUL: case Opcodes.DDIV: case Opcodes.DREM: case Opcodes.DNEG: case Opcodes.I2D: case Opcodes.F2D: case Opcodes.L2D: return new char[] { 'd' }; case Opcodes.DUP: return new char[] { '0', '0' }; case Opcodes.DUP2: case Opcodes.DUP_X2: case Opcodes.DUP2_X2: return null; case Opcodes.DUP_X1: case Opcodes.DUP2_X1: return new char[] { '0', '1', '0' }; case Opcodes.SWAP: return new char[] { '1', '0' }; default: return null; } }
From source file:com.collir24.policyextractor.ExtractorVisitor.java
License:Apache License
@Override public void visitInsn(int opcode) { switch (opcode) { case Opcodes.ICONST_0: { booleanOnStack = false;//from w ww .jav a 2 s . c om break; } case Opcodes.ICONST_1: { booleanOnStack = true; break; } default: { booleanOnStack = null; } } }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Creates a numeric push instruction.//from w w w. jav a2s .c o m * * @param num * The number to push. * @return The instruction node. */ public static AbstractInsnNode createNumericPushInsn(Number num) { long value = num.longValue(); if (value == -1) { return new InsnNode(Opcodes.ICONST_M1); } else if (value == 0) { return new InsnNode(Opcodes.ICONST_0); } else if (value == 1) { return new InsnNode(Opcodes.ICONST_1); } else if (value == 2) { return new InsnNode(Opcodes.ICONST_2); } else if (value == 3) { return new InsnNode(Opcodes.ICONST_3); } else if (value == 4) { return new InsnNode(Opcodes.ICONST_4); } else if (value == 5) { return new InsnNode(Opcodes.ICONST_5); } else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { return new IntInsnNode(Opcodes.BIPUSH, (int) value); } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) { return new IntInsnNode(Opcodes.SIPUSH, (int) value); } else if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE) { return new LdcInsnNode((int) value); } else { return new LdcInsnNode(/* (long) */value); } }
From source file:com.dank.asm.InsnNodeUtils.java
License:Open Source License
/** * Reads the value of a numeric push instruction (which can be an * {@code ICONST_*} instruction, an {@code BIPUSH} instruction, an * {@code SIPUSH} instruction or a {@code LDC_*} instruction. * //from ww w . j ava 2 s. com * @param push * The instruction node. * @return The numeric value. */ public static long getNumericPushValue(AbstractInsnNode push) { if (push instanceof InsnNode) { switch (push.opcode()) { case Opcodes.ICONST_M1: return -1; case Opcodes.ICONST_0: return 0; case Opcodes.ICONST_1: return 1; case Opcodes.ICONST_2: return 2; case Opcodes.ICONST_3: return 3; case Opcodes.ICONST_4: return 4; case Opcodes.ICONST_5: return 5; default: throw new AssertionError(); } } else if (push instanceof IntInsnNode) { return ((IntInsnNode) push).operand; } else { return ((Number) ((LdcInsnNode) push).cst).longValue(); } }
From source file:com.geeksaga.light.profiler.util.ASMUtil.java
License:Apache License
public static AbstractInsnNode createPushNode(int value) { if (value == -1) { return new InsnNode(Opcodes.ICONST_M1); } else if (value == 0) { return new InsnNode(Opcodes.ICONST_0); } else if (value == 1) { return new InsnNode(Opcodes.ICONST_1); } else if (value == 2) { return new InsnNode(Opcodes.ICONST_2); } else if (value == 3) { return new InsnNode(Opcodes.ICONST_3); } else if (value == 4) { return new InsnNode(Opcodes.ICONST_4); } else if (value == 5) { return new InsnNode(Opcodes.ICONST_5); } else if ((value >= -128) && (value <= 127)) { return new IntInsnNode(Opcodes.BIPUSH, value); } else if ((value >= -32768) && (value <= 32767)) { return new IntInsnNode(Opcodes.SIPUSH, value); } else {/*from ww w . j a v a 2 s. c om*/ return new LdcInsnNode(value); } }
From source file:com.github.anba.es6draft.compiler.assembler.InstructionAssembler.java
License:Open Source License
/** * ∅ value// w w w .j a v a 2 s. c o m * * @param b * the constant boolean to load on the stack */ public void iconst(boolean b) { methodVisitor.visitInsn(b ? Opcodes.ICONST_1 : Opcodes.ICONST_0); stack.iconst(); }
From source file:com.github.anba.es6draft.compiler.assembler.InstructionAssembler.java
License:Open Source License
public void iconst(int value) { if (-1 <= value && value <= 5) { methodVisitor.visitInsn(Opcodes.ICONST_0 + value); stack.iconst();/*from w w w.jav a2 s. c o m*/ } else if (Byte.MIN_VALUE <= value && value <= Byte.MAX_VALUE) { bipush(value); } else if (Short.MIN_VALUE <= value && value <= Short.MAX_VALUE) { sipush(value); } else { constantPool.iconst(this, Integer.valueOf(value)); } }
From source file:com.github.fge.grappa.transform.CodeBlock.java
License:Apache License
public CodeBlock iconst_0() { instructionList.add(new InsnNode(Opcodes.ICONST_0)); return this; }
From source file:com.github.jasmo.util.BytecodeHelper.java
License:Open Source License
public static AbstractInsnNode newIntegerNode(int i) { if (i >= -1 && i <= 5) { return new InsnNode(Opcodes.ICONST_0 + i); } else if (i >= Byte.MIN_VALUE && i <= Byte.MAX_VALUE) { return new IntInsnNode(Opcodes.BIPUSH, i); } else if (i >= Short.MIN_VALUE && i <= Short.MAX_VALUE) { return new IntInsnNode(Opcodes.SIPUSH, i); } else {/*ww w . j av a 2 s . com*/ return new LdcInsnNode(i); } }
From source file:com.github.malamut2.low.AllocationMethodAdapter.java
License:Apache License
private void pushProductOfIntArrayOnStack() { Label beginScopeLabel = new Label(); Label endScopeLabel = new Label(); int dimsArrayIndex = newLocal("[I", beginScopeLabel, endScopeLabel); int counterIndex = newLocal("I", beginScopeLabel, endScopeLabel); int productIndex = newLocal("I", beginScopeLabel, endScopeLabel); Label loopLabel = new Label(); Label endLabel = new Label(); super.visitLabel(beginScopeLabel); // stack: ... intArray super.visitVarInsn(Opcodes.ASTORE, dimsArrayIndex); // -> stack: ... // counter = 0 super.visitInsn(Opcodes.ICONST_0); super.visitVarInsn(Opcodes.ISTORE, counterIndex); // product = 1 super.visitInsn(Opcodes.ICONST_1); super.visitVarInsn(Opcodes.ISTORE, productIndex); // loop:/*from w w w . j av a 2 s. c o m*/ super.visitLabel(loopLabel); // if index >= arraylength goto end: super.visitVarInsn(Opcodes.ILOAD, counterIndex); super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); super.visitInsn(Opcodes.ARRAYLENGTH); super.visitJumpInsn(Opcodes.IF_ICMPGE, endLabel); // product = product * max(array[counter],1) super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); super.visitVarInsn(Opcodes.ILOAD, counterIndex); super.visitInsn(Opcodes.IALOAD); super.visitInsn(Opcodes.DUP); Label nonZeroDimension = new Label(); super.visitJumpInsn(Opcodes.IFNE, nonZeroDimension); super.visitInsn(Opcodes.POP); super.visitInsn(Opcodes.ICONST_1); super.visitLabel(nonZeroDimension); super.visitVarInsn(Opcodes.ILOAD, productIndex); super.visitInsn(Opcodes.IMUL); // if overflow happens it happens. super.visitVarInsn(Opcodes.ISTORE, productIndex); // iinc counter 1 super.visitIincInsn(counterIndex, 1); // goto loop super.visitJumpInsn(Opcodes.GOTO, loopLabel); // end: super.visitLabel(endLabel); // re-push dimensions array super.visitVarInsn(Opcodes.ALOAD, dimsArrayIndex); // push product super.visitVarInsn(Opcodes.ILOAD, productIndex); super.visitLabel(endScopeLabel); }