List of usage examples for org.objectweb.asm Opcodes SIPUSH
int SIPUSH
To view the source code for org.objectweb.asm Opcodes SIPUSH.
Click Source Link
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 {//from w w w. j a v a2s . com return new LdcInsnNode(i); } }
From source file:com.google.devtools.build.android.desugar.BytecodeTypeInference.java
License:Open Source License
@Override public void visitIntInsn(int opcode, int operand) { switch (opcode) { case Opcodes.BIPUSH: case Opcodes.SIPUSH: push(InferredType.INT);/*from w w w .j a va 2 s . co m*/ break; case Opcodes.NEWARRAY: pop(); switch (operand) { case Opcodes.T_BOOLEAN: pushDescriptor("[Z"); break; case Opcodes.T_CHAR: pushDescriptor("[C"); break; case Opcodes.T_FLOAT: pushDescriptor("[F"); break; case Opcodes.T_DOUBLE: pushDescriptor("[D"); break; case Opcodes.T_BYTE: pushDescriptor("[B"); break; case Opcodes.T_SHORT: pushDescriptor("[S"); break; case Opcodes.T_INT: pushDescriptor("[I"); break; case Opcodes.T_LONG: pushDescriptor("[J"); break; default: throw new RuntimeException("Unhandled operand value: " + operand); } break; default: throw new RuntimeException("Unhandled opcode " + opcode); } super.visitIntInsn(opcode, operand); }
From source file:com.google.test.metric.asm.MethodVisitorBuilder.java
License:Apache License
public void visitIntInsn(int opcode, int operand) { switch (opcode) { case Opcodes.NEWARRAY: newArray(operand, toType(operand)); break;//from ww w .j a v a 2s. co m case Opcodes.BIPUSH: loadConstant(operand, JavaType.INT); break; case Opcodes.SIPUSH: loadConstant(operand, JavaType.INT); break; default: throw new UnsupportedOperationException("Unexpected opcode: " + opcode); } }
From source file:com.mebigfatguy.baremetal4j.Sourcifier.java
License:Apache License
public void visitIntInsn(int opcode, int operand) { lines.add("\t\tBCO = " + String.format("%05d", byteOffset) + "; // " + Printer.OPCODES[opcode] + " " + operand);/*from w w w .j a v a 2 s.c o m*/ byteOffset += (opcode == Opcodes.SIPUSH) ? 3 : 2; }
From source file:com.mebigfatguy.junitflood.jvm.OperandStack.java
License:Apache License
public void performIntInsn(int opcode, int operand) { switch (opcode) { case Opcodes.BIPUSH: { Operand op = new Operand(); op.setSignature("B"); op.setConstant(Byte.valueOf((byte) operand)); push(op);/*from w w w . j ava 2 s . co m*/ } break; case Opcodes.SIPUSH: { Operand op = new Operand(); op.setSignature("S"); op.setConstant(Short.valueOf((short) operand)); push(op); } break; case Opcodes.NEWARRAY: { Operand op = new Operand(); op.setSignature("[Ljava/lang/Object;"); push(op); } break; } }
From source file:com.mogujie.instantrun.IncrementalTool.java
License:Apache License
public static byte[] getPatchFileContents(ImmutableList<String> patchFileContents, ImmutableList<Integer> patchIndexContents) { if (patchFileContents.size() != patchIndexContents.size()) { throw new GradleException("patchFileContents's size is " + patchFileContents.size() + ", but patchIndexContents's size is " + patchIndexContents.size() + ", please check the changed classes."); }/*from w ww .j a v a 2s .c om*/ ClassWriter cw = new ClassWriter(0); MethodVisitor mv; cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, IncrementalVisitor.APP_PATCHES_LOADER_IMPL, null, IncrementalVisitor.ABSTRACT_PATCHES_LOADER_IMPL, null); { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null); mv.visitCode(); mv.visitVarInsn(Opcodes.ALOAD, 0); mv.visitMethodInsn(Opcodes.INVOKESPECIAL, IncrementalVisitor.ABSTRACT_PATCHES_LOADER_IMPL, "<init>", "()V", false); mv.visitInsn(Opcodes.RETURN); mv.visitMaxs(1, 1); mv.visitEnd(); } { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getPatchedClasses", "()[Ljava/lang/String;", null, null); mv.visitCode(); mv.visitIntInsn(Opcodes.SIPUSH, patchFileContents.size()); mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/String"); for (int index = 0; index < patchFileContents.size(); index++) { mv.visitInsn(Opcodes.DUP); mv.visitIntInsn(Opcodes.SIPUSH, index); mv.visitLdcInsn(patchFileContents.get(index)); mv.visitInsn(Opcodes.AASTORE); } mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(4, 1); mv.visitEnd(); } { mv = cw.visitMethod(Opcodes.ACC_PUBLIC, "getPatchedClassIndexes", "()[I", null, null); mv.visitCode(); mv.visitIntInsn(Opcodes.SIPUSH, patchIndexContents.size()); mv.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_INT); for (int index = 0; index < patchIndexContents.size(); index++) { mv.visitInsn(Opcodes.DUP); mv.visitIntInsn(Opcodes.SIPUSH, index); mv.visitLdcInsn(patchIndexContents.get(index)); mv.visitInsn(Opcodes.IASTORE); } mv.visitInsn(Opcodes.ARETURN); mv.visitMaxs(4, 1); mv.visitEnd(); } cw.visitEnd(); return cw.toByteArray(); }
From source file:com.navercorp.pinpoint.profiler.instrument.ASMMethodVariables.java
License:Apache License
void push(InsnList insnList, final int value) { if (value >= -1 && value <= 5) { insnList.add(new InsnNode(Opcodes.ICONST_0 + value)); } else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { insnList.add(new IntInsnNode(Opcodes.BIPUSH, value)); } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) { insnList.add(new IntInsnNode(Opcodes.SIPUSH, value)); } else {/*from w w w . j a v a2 s.c om*/ insnList.add(new LdcInsnNode(value)); } }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Gets an instruction that pushes a integer onto the stack. The * instruction uses the smallest push possible (ICONST_*, BIPUSH, SIPUSH or * Integer constant).// ww w . j a va 2 s .co m * * @param c the integer to push onto the stack * @return insn node to insert */ public static AbstractInsnNode pushIntConstant(int c) { if (c == -1) { return new InsnNode(Opcodes.ICONST_M1); } else if (c >= 0 && c <= 5) { return new InsnNode(ASMHelper.CONSTANTS_INT[c + 1]); } else if (c >= Byte.MIN_VALUE && c <= Byte.MAX_VALUE) { return new IntInsnNode(Opcodes.BIPUSH, c); } else if (c >= Short.MIN_VALUE && c <= Short.MAX_VALUE) { return new IntInsnNode(Opcodes.SIPUSH, c); } else { return new LdcInsnNode(c); } }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
public static Object getConstant(AbstractInsnNode insn) { if (insn == null) { return null; } else if (insn instanceof LdcInsnNode) { return ((LdcInsnNode) insn).cst; } else if (insn instanceof IntInsnNode) { int value = ((IntInsnNode) insn).operand; if (insn.getOpcode() == Opcodes.BIPUSH || insn.getOpcode() == Opcodes.SIPUSH) { return Integer.valueOf(value); }/* w ww . j a va2 s . co m*/ throw new IllegalArgumentException( "IntInsnNode with invalid opcode " + insn.getOpcode() + " in getConstant"); } int index = Ints.indexOf(ASMHelper.CONSTANTS_ALL, insn.getOpcode()); return index < 0 ? null : ASMHelper.CONSTANTS_VALUES[index]; }
From source file:com.toolazydogs.maiden.agent.asm.AsmUtils.java
License:Apache License
/** * Generates the instruction to push the given value on the stack. * * @param methodVisitor the visitor to which to send the instruction * @param value the value to be pushed on the stack. *//*from w ww . j a v a 2 s . c o m*/ public static void push(MethodVisitor methodVisitor, int value) { if (value >= -1 && value <= 5) { methodVisitor.visitInsn(Opcodes.ICONST_0 + value); } else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE) { methodVisitor.visitIntInsn(Opcodes.BIPUSH, value); } else if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) { methodVisitor.visitIntInsn(Opcodes.SIPUSH, value); } else { methodVisitor.visitLdcInsn(value); } }