List of usage examples for org.objectweb.asm.tree IntInsnNode getOpcode
public int getOpcode()
From source file:de.unisb.cs.st.javaslicer.tracer.instrumentation.TracingMethodInstrumenter.java
License:Open Source License
private void transformIntInsn(final IntInsnNode insn) { if (insn.getOpcode() == NEWARRAY) { int newObjectIdSeqIndex = this.tracer.newLongTraceSequence(); transformArrayAllocation(// ww w . j a va 2 s . c om new NewArrayInstruction(this.readMethod, this.currentLine, insn.operand, newObjectIdSeqIndex), newObjectIdSeqIndex); } else { assert insn.getOpcode() == BIPUSH || insn.getOpcode() == SIPUSH; registerInstruction(new IntPush(this.readMethod, insn.getOpcode(), insn.operand, this.currentLine), InstructionType.SAFE); } }
From source file:edu.mit.streamjit.util.bytecode.MethodResolver.java
License:Open Source License
private void interpret(IntInsnNode insn, FrameState frame, BBInfo block) { int operand = insn.operand; switch (insn.getOpcode()) { case Opcodes.BIPUSH: case Opcodes.SIPUSH: frame.stack.push(module.constants().getSmallestIntConstant(insn.operand)); break;/* w w w.j a v a 2s .com*/ case Opcodes.NEWARRAY: ArrayType t; switch (operand) { case Opcodes.T_BOOLEAN: t = module.types().getArrayType(boolean[].class); break; case Opcodes.T_BYTE: t = module.types().getArrayType(byte[].class); break; case Opcodes.T_CHAR: t = module.types().getArrayType(char[].class); break; case Opcodes.T_SHORT: t = module.types().getArrayType(short[].class); break; case Opcodes.T_INT: t = module.types().getArrayType(int[].class); break; case Opcodes.T_LONG: t = module.types().getArrayType(long[].class); break; case Opcodes.T_FLOAT: t = module.types().getArrayType(float[].class); break; case Opcodes.T_DOUBLE: t = module.types().getArrayType(double[].class); break; default: throw new AssertionError(operand); } NewArrayInst i = new NewArrayInst(t, frame.stack.pop()); block.block.instructions().add(i); frame.stack.push(i); break; default: throw new UnsupportedOperationException("" + insn.getOpcode()); } }
From source file:nova.core.wrapper.mc.forge.v17.asm.lib.InsnListPrinter.java
License:Open Source License
private void _visitInsn(AbstractInsnNode insn) { switch (insn.getType()) { case 0:/*from w w w . j a va 2s. c om*/ visitInsn(insn.getOpcode()); break; case 1: IntInsnNode iinsn = (IntInsnNode) insn; visitIntInsn(iinsn.getOpcode(), iinsn.operand); break; case 2: VarInsnNode vinsn = (VarInsnNode) insn; visitVarInsn(vinsn.getOpcode(), vinsn.var); break; case 3: TypeInsnNode tinsn = (TypeInsnNode) insn; visitTypeInsn(tinsn.getOpcode(), tinsn.desc); break; case 4: FieldInsnNode finsn = (FieldInsnNode) insn; visitFieldInsn(finsn.getOpcode(), finsn.owner, finsn.name, finsn.desc); break; case 5: MethodInsnNode minsn = (MethodInsnNode) insn; visitMethodInsn(minsn.getOpcode(), minsn.owner, minsn.name, minsn.desc); break; case 6: InvokeDynamicInsnNode idinsn = (InvokeDynamicInsnNode) insn; visitInvokeDynamicInsn(idinsn.name, idinsn.desc, idinsn.bsm, idinsn.bsmArgs); break; case 7: JumpInsnNode jinsn = (JumpInsnNode) insn; visitJumpInsn(jinsn.getOpcode(), jinsn.label.getLabel()); break; case 8: LabelNode linsn = (LabelNode) insn; visitLabel(linsn.getLabel()); break; case 9: LdcInsnNode ldcinsn = (LdcInsnNode) insn; visitLdcInsn(ldcinsn.cst); break; case 10: IincInsnNode iiinsn = (IincInsnNode) insn; visitIincInsn(iiinsn.var, iiinsn.incr); break; case 11: TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn; Label[] tslables = new Label[tsinsn.labels.size()]; for (int i = 0; i < tslables.length; i++) { tslables[i] = tsinsn.labels.get(i).getLabel(); } visitTableSwitchInsn(tsinsn.min, tsinsn.max, tsinsn.dflt.getLabel(), tslables); break; case 12: LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn; Label[] lslables = new Label[lsinsn.labels.size()]; for (int i = 0; i < lslables.length; i++) { lslables[i] = lsinsn.labels.get(i).getLabel(); } int[] lskeys = new int[lsinsn.keys.size()]; for (int i = 0; i < lskeys.length; i++) { lskeys[i] = lsinsn.keys.get(i); } visitLookupSwitchInsn(lsinsn.dflt.getLabel(), lskeys, lslables); break; case 13: MultiANewArrayInsnNode ainsn = (MultiANewArrayInsnNode) insn; visitMultiANewArrayInsn(ainsn.desc, ainsn.dims); break; case 14: FrameNode fnode = (FrameNode) insn; switch (fnode.type) { case -1: case 0: visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), fnode.stack.size(), fnode.stack.toArray()); break; case 1: visitFrame(fnode.type, fnode.local.size(), fnode.local.toArray(), 0, null); break; case 2: visitFrame(fnode.type, fnode.local.size(), null, 0, null); break; case 3: visitFrame(fnode.type, 0, null, 0, null); break; case 4: visitFrame(fnode.type, 0, null, 1, fnode.stack.toArray()); } break; case 15: LineNumberNode lnode = (LineNumberNode) insn; visitLineNumber(lnode.line, lnode.start.getLabel()); break; } }
From source file:org.lambdamatic.analyzer.ast.LambdaExpressionReader.java
License:Open Source License
/** * Reads the given {@link IntInsnNode} instruction and adds the associated {@link Expression} to * the given {@link Stack}./*www . jav a 2 s . co m*/ * * @param intInsnNode the instruction to read * @param expressionStack the expression stack to put on or pop from. * @param localVariables the local variables */ private static void readIntInstruction(final IntInsnNode intInsnNode, final Stack<Expression> expressionStack, final LocalVariables localVariables) { switch (intInsnNode.getOpcode()) { case Opcodes.BIPUSH: // expressionStack.add(LiteralFactory.getLiteral(intInsnNode.operand, // expressionStack.peek())); final Expression literal = new NumberLiteral(intInsnNode.operand); LOGGER.trace("Stacking literal {}", literal); expressionStack.add(literal); break; default: LOGGER.warn("IntInsnNode with OpCode {} was ignored.", intInsnNode.getOpcode()); } }
From source file:pku.sei.checkedcoverage.tracer.instrumentation.TracingMethodInstrumenter.java
License:Creative Commons License
private void transformIntInsn(final IntInsnNode insn) { if (insn.getOpcode() == NEWARRAY) { final int newObjectIdSeqIndex = this.tracer.newLongTraceSequence(); registerInstruction(//from ww w .j av a 2 s. c o m new NewArrayInstruction(this.readMethod, this.currentLine, insn.operand, newObjectIdSeqIndex), InstructionType.UNSAFE); this.instructionIterator.add(new InsnNode(DUP)); this.instructionIterator.add(new VarInsnNode(ALOAD, this.tracerLocalVarIndex)); this.instructionIterator.add(new InsnNode(SWAP)); this.instructionIterator.add(getIntConstInsn(newObjectIdSeqIndex)); this.instructionIterator.add(new MethodInsnNode(INVOKEINTERFACE, Type.getInternalName(ThreadTracer.class), "traceObject", "(Ljava/lang/Object;I)V")); } else { assert insn.getOpcode() == BIPUSH || insn.getOpcode() == SIPUSH; registerInstruction(new IntPush(this.readMethod, insn.getOpcode(), insn.operand, this.currentLine), InstructionType.SAFE); } }
From source file:soot.asm.AsmMethodSource.java
License:Open Source License
private void convertIntInsn(IntInsnNode insn) { int op = insn.getOpcode(); StackFrame frame = getFrame(insn);/* w ww.jav a 2 s .c o m*/ Operand[] out = frame.out(); Operand opr; if (out == null) { Value v; if (op == BIPUSH || op == SIPUSH) { v = IntConstant.v(insn.operand); } else { Type type; switch (insn.operand) { case T_BOOLEAN: type = BooleanType.v(); break; case T_CHAR: type = CharType.v(); break; case T_FLOAT: type = FloatType.v(); break; case T_DOUBLE: type = DoubleType.v(); break; case T_BYTE: type = ByteType.v(); break; case T_SHORT: type = ShortType.v(); break; case T_INT: type = IntType.v(); break; case T_LONG: type = LongType.v(); break; default: throw new AssertionError("Unknown NEWARRAY type!"); } Operand size = popImmediate(); NewArrayExpr anew = Jimple.v().newNewArrayExpr(type, size.stackOrValue()); size.addBox(anew.getSizeBox()); frame.in(size); frame.boxes(anew.getSizeBox()); v = anew; } opr = new Operand(insn, v); frame.out(opr); } else { opr = out[0]; if (op == NEWARRAY) frame.mergeIn(pop()); } push(opr); }