org.objectweb.asm.tree.IincInsnNode Java Examples
The following examples show how to use
org.objectweb.asm.tree.IincInsnNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #2
Source File: StackHelper.java From zelixkiller with GNU General Public License v3.0 | 6 votes |
public InsnValue incrementLocal(IincInsnNode iinc, InsnValue value) { Object obj = value.getValue(); if (obj == null) { return newValue(value.getType()); } if (value.getType().equals(Type.BYTE_TYPE)) { return InsnValue.byteValue((byte) (((Number) obj).byteValue() + iinc.incr)); } else if (value.getType().equals(Type.INT_TYPE)) { return InsnValue.byteValue((int) (((Number) obj).intValue() + iinc.incr)); } else if (value.getType().equals(Type.CHAR_TYPE)) { return InsnValue.charValue((char) (((Number) obj).intValue() + iinc.incr)); } else if (value.getType().equals(Type.LONG_TYPE)) { return InsnValue.longValue((long) (((Number) obj).longValue() + iinc.incr)); } else if (value.getType().equals(Type.DOUBLE_TYPE)) { return InsnValue.doubleValue((double) (((Number) obj).doubleValue() + iinc.incr)); } else if (value.getType().equals(Type.FLOAT_TYPE)) { return InsnValue.floatValue((float) (((Number) obj).floatValue() + iinc.incr)); } else if (value.getType().equals(Type.SHORT_TYPE)) { return InsnValue.shortValue((short) (((Number) obj).shortValue() + iinc.incr)); } return null; }
Example #3
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #4
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public static boolean insnEqual(AbstractInsnNode node1, AbstractInsnNode node2) { if (node1.getOpcode() != node2.getOpcode()) { return false; } switch (node2.getType()) { case VAR_INSN: return varInsnEqual((VarInsnNode) node1, (VarInsnNode) node2); case TYPE_INSN: return typeInsnEqual((TypeInsnNode) node1, (TypeInsnNode) node2); case FIELD_INSN: return fieldInsnEqual((FieldInsnNode) node1, (FieldInsnNode) node2); case METHOD_INSN: return methodInsnEqual((MethodInsnNode) node1, (MethodInsnNode) node2); case LDC_INSN: return ldcInsnEqual((LdcInsnNode) node1, (LdcInsnNode) node2); case IINC_INSN: return iincInsnEqual((IincInsnNode) node1, (IincInsnNode) node2); case INT_INSN: return intInsnEqual((IntInsnNode) node1, (IntInsnNode) node2); default: return true; } }
Example #5
Source File: InstructionMatchersTest.java From pitest with Apache License 2.0 | 5 votes |
@Test public void shouldNotMatchIncrementsToDifferentLocalVariable() { final Slot<Integer> slot = Slot.create(Integer.class); this.context.store(slot.write(), 42); final IincInsnNode node = new IincInsnNode(42 + 1, 1); assertFalse(incrementsVariable(slot.read()).test(this.context,node)); }
Example #6
Source File: OpcodeFormatting.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
public static String toString(AbstractInsnNode ain) { String s = getOpcodeText(ain.getOpcode()); switch (ain.getType()) { case AbstractInsnNode.FIELD_INSN: FieldInsnNode fin = (FieldInsnNode) ain; return s + " " + fin.owner + "#" + fin.name + " " + fin.desc; case AbstractInsnNode.METHOD_INSN: MethodInsnNode min = (MethodInsnNode) ain; return s + " " + min.owner + "#" + min.name + min.desc; case AbstractInsnNode.VAR_INSN: VarInsnNode vin = (VarInsnNode) ain; return s + " " + vin.var; case AbstractInsnNode.TYPE_INSN: TypeInsnNode tin = (TypeInsnNode) ain; return s + " " + tin.desc; case AbstractInsnNode.MULTIANEWARRAY_INSN: MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain; return s + " " + mnin.dims + " " + mnin.desc; case AbstractInsnNode.JUMP_INSN: JumpInsnNode jin = (JumpInsnNode) ain; return s + " " + getIndex(jin.label); case AbstractInsnNode.LDC_INSN: LdcInsnNode ldc = (LdcInsnNode) ain; return s + " " + ldc.cst.toString(); case AbstractInsnNode.INT_INSN: return s + " " + getIntValue(ain); case AbstractInsnNode.IINC_INSN: IincInsnNode iinc = (IincInsnNode) ain; return s + " " + iinc.var + " +" + iinc.incr; case AbstractInsnNode.FRAME: FrameNode fn = (FrameNode) ain; return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size(); case AbstractInsnNode.LABEL: LabelNode ln = (LabelNode) ain; return s + " " + getIndex(ln); } return s; }
Example #7
Source File: InstructionMatchersTest.java From pitest with Apache License 2.0 | 5 votes |
@Test public void shouldMatchIncrementsToStoredLocalVariable() { final Slot<Integer> slot = Slot.create(Integer.class); this.context.store(slot.write(), 42); final IincInsnNode node = new IincInsnNode(42, 1); assertTrue(incrementsVariable(slot.read()).test(this.context,node)); }
Example #8
Source File: InsnComparator.java From TFC2 with GNU General Public License v3.0 | 5 votes |
/** * Respects {@link #INT_WILDCARD} and {@link #WILDCARD} instruction properties. * Always returns true if {@code a} and {@code b} are label, line number, or frame instructions. * * @return Whether or not the given instructions are equivalent. */ public boolean areInsnsEqual(AbstractInsnNode a, AbstractInsnNode b) { if (a == b) return true; if (a == null || b == null) return false; if (a.equals(b)) return true; if (a.getOpcode() != b.getOpcode()) return false; switch (a.getType()) { case AbstractInsnNode.VAR_INSN: return areVarInsnsEqual((VarInsnNode) a, (VarInsnNode) b); case AbstractInsnNode.TYPE_INSN: return areTypeInsnsEqual((TypeInsnNode) a, (TypeInsnNode) b); case AbstractInsnNode.FIELD_INSN: return areFieldInsnsEqual((FieldInsnNode) a, (FieldInsnNode) b); case AbstractInsnNode.METHOD_INSN: return areMethodInsnsEqual((MethodInsnNode) a, (MethodInsnNode) b); case AbstractInsnNode.LDC_INSN: return areLdcInsnsEqual((LdcInsnNode) a, (LdcInsnNode) b); case AbstractInsnNode.IINC_INSN: return areIincInsnsEqual((IincInsnNode) a, (IincInsnNode) b); case AbstractInsnNode.INT_INSN: return areIntInsnsEqual((IntInsnNode) a, (IntInsnNode) b); default: return true; } }
Example #9
Source File: BlockLogMethodAdapter.java From jumbune with GNU Lesser General Public License v3.0 | 5 votes |
/** * <p> * This method tracks for mapreduce output method. If found, a counter is * incremented. * </p> * * @param startIndex * Start index of the instructions * @param endIndex * End index of the instructions */ private void handleCtxWrite(int startIndex, int endIndex) { for (int i = startIndex; i < endIndex; i++) { AbstractInsnNode ain = this.insnArr[i]; if (ain instanceof MethodInsnNode) { MethodInsnNode min = (MethodInsnNode) ain; if (InstrumentUtil.isOutputMethod(min)) { // adding incremental statement InsnList il = new InsnList(); il.add(new IincInsnNode(this.localVariableSize, 1)); instructions.insertBefore(ain, il); } } } }
Example #10
Source File: AsmMethodSource.java From JAADAS with GNU General Public License v3.0 | 5 votes |
private void convertIincInsn(IincInsnNode insn) { Local local = getLocal(insn.var); assignReadOps(local); if (!units.containsKey(insn)) { AddExpr add = Jimple.v().newAddExpr(local, IntConstant.v(insn.incr)); setUnit(insn, Jimple.v().newAssignStmt(local, add)); } }
Example #11
Source File: OpUtils.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
public static String toString(AbstractInsnNode ain) { String s = getOpcodeText(ain.getOpcode()); switch (ain.getType()) { case AbstractInsnNode.FIELD_INSN: FieldInsnNode fin = (FieldInsnNode) ain; return s + " " + fin.owner + "#" + fin.name + " " + fin.desc; case AbstractInsnNode.METHOD_INSN: MethodInsnNode min = (MethodInsnNode) ain; return s + " " + min.owner + "#" + min.name + min.desc; case AbstractInsnNode.VAR_INSN: VarInsnNode vin = (VarInsnNode) ain; return s + " " + vin.var; case AbstractInsnNode.TYPE_INSN: TypeInsnNode tin = (TypeInsnNode) ain; return s + " " + tin.desc; case AbstractInsnNode.MULTIANEWARRAY_INSN: MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain; return s + " " + mnin.dims + " " + mnin.desc; case AbstractInsnNode.JUMP_INSN: JumpInsnNode jin = (JumpInsnNode) ain; return s + " " + getIndex(jin.label); case AbstractInsnNode.LDC_INSN: LdcInsnNode ldc = (LdcInsnNode) ain; return s + " " + ldc.cst.toString(); case AbstractInsnNode.INT_INSN: return s + " " + getIntValue(ain); case AbstractInsnNode.IINC_INSN: IincInsnNode iinc = (IincInsnNode) ain; return s + " " + iinc.var + " +" + iinc.incr; case AbstractInsnNode.FRAME: FrameNode fn = (FrameNode) ain; return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size(); case AbstractInsnNode.LABEL: LabelNode ln = (LabelNode) ain; return s + " " + getIndex(ln); } return s; }
Example #12
Source File: Iinc.java From nuls with MIT License | 5 votes |
public static void iinc(final Frame frame) { IincInsnNode iincInsnNode = frame.iincInsnNode(); int index = iincInsnNode.var; int incr = iincInsnNode.incr; int value = frame.localVariables.getInt(index); int result = value + incr; frame.localVariables.setInt(index, result); //Log.result(frame.getCurrentOpCode(), result, value, "+", incr); }
Example #13
Source File: Iinc.java From nuls-v2 with MIT License | 5 votes |
public static void iinc(final Frame frame) { IincInsnNode iincInsnNode = frame.iincInsnNode(); int index = iincInsnNode.var; int incr = iincInsnNode.incr; int value = frame.localVariables.getInt(index); int result = value + incr; frame.localVariables.setInt(index, result); //Log.result(frame.getCurrentOpCode(), result, value, "+", incr); }
Example #14
Source File: OpUtils.java From zelixkiller with GNU General Public License v3.0 | 5 votes |
public static String toString(AbstractInsnNode ain) { String s = getOpcodeText(ain.getOpcode()); switch (ain.getType()) { case AbstractInsnNode.FIELD_INSN: FieldInsnNode fin = (FieldInsnNode) ain; return s + " " + fin.owner + "#" + fin.name + " " + fin.desc; case AbstractInsnNode.METHOD_INSN: MethodInsnNode min = (MethodInsnNode) ain; return s + " " + min.owner + "#" + min.name + min.desc; case AbstractInsnNode.VAR_INSN: VarInsnNode vin = (VarInsnNode) ain; return s + " " + vin.var; case AbstractInsnNode.TYPE_INSN: TypeInsnNode tin = (TypeInsnNode) ain; return s + " " + tin.desc; case AbstractInsnNode.JUMP_INSN: JumpInsnNode jin = (JumpInsnNode) ain; return s + " " + getIndex(jin.label); case AbstractInsnNode.LDC_INSN: LdcInsnNode ldc = (LdcInsnNode) ain; return s + " " + ldc.cst.toString(); case AbstractInsnNode.INT_INSN: return s + " " + getIntValue(ain); case AbstractInsnNode.IINC_INSN: IincInsnNode iinc = (IincInsnNode) ain; return s + " " + iinc.var + " +" + iinc.incr; case AbstractInsnNode.FRAME: FrameNode fn = (FrameNode) ain; return s + " " + getOpcodeText(fn.type) + " " + fn.local.size() + " " + fn.stack.size(); case AbstractInsnNode.LABEL: LabelNode ln = (LabelNode) ain; return s + " " + getIndex(ln); } return s; }
Example #15
Source File: IincInsNodeSerializer.java From maple-ir with GNU General Public License v3.0 | 5 votes |
@Override public IincInsnNode deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObject = (JsonObject) json; int var, incr; var = jsonObject.get("var").getAsInt(); incr = jsonObject.get("incr").getAsInt(); return new IincInsnNode(var, incr); }
Example #16
Source File: IincInsNodeSerializer.java From maple-ir with GNU General Public License v3.0 | 5 votes |
@Override public JsonElement serialize(IincInsnNode src, Type typeOfSrc, JsonSerializationContext context) { JsonObject jsonObject = new JsonObject(); jsonObject.add("var", context.serialize(src.var, Integer.class)); jsonObject.add("incr", context.serialize(src.incr, Integer.class)); return jsonObject; }
Example #17
Source File: IincInstructionFilter.java From maple-ir with GNU General Public License v3.0 | 4 votes |
@Override public boolean accept(AbstractInsnNode t) { if (!(t instanceof IincInsnNode)) return false; return incFilter.accept(((IincInsnNode) t).incr) && varFilter.accept(((IincInsnNode) t).var); }
Example #18
Source File: IincHandler.java From native-obfuscator with GNU General Public License v3.0 | 4 votes |
@Override protected void process(MethodContext context, IincInsnNode node) { props.put("incr", String.valueOf(node.incr)); props.put("var", String.valueOf(node.var)); }
Example #19
Source File: FrameSateTrackingMethodVisitor.java From Concurnas with MIT License | 4 votes |
public void visitIincInsn(int var, int increment) { BytecodeStackFrameModifier.intepret(0, IINC, new IincInsnNode(var, increment), currentFrame, ""); super.visitIincInsn(var, increment); }
Example #20
Source File: InstructionMatchers.java From pitest with Apache License 2.0 | 4 votes |
public static Match<AbstractInsnNode> incrementsVariable(final SlotRead<Integer> counterVariable) { return (context, a) -> (a instanceof IincInsnNode) && context.retrieve(counterVariable).filter(isEqual(((IincInsnNode)a).var)).isPresent(); }
Example #21
Source File: CodeBlock.java From grappa with Apache License 2.0 | 4 votes |
public CodeBlock visitIincInsn(final int varIndex, final int increment) { instructionList.add(new IincInsnNode(varIndex, increment)); return this; }
Example #22
Source File: CodeBlock.java From grappa with Apache License 2.0 | 4 votes |
public CodeBlock iinc(final int varIndex, final int increment) { instructionList.add(new IincInsnNode(varIndex, increment)); return this; }
Example #23
Source File: InsnComparator.java From TFC2 with GNU General Public License v3.0 | 4 votes |
private boolean areIincInsnsEqual(IincInsnNode a, IincInsnNode b) { return intValuesMatch(a.var, b.var) && intValuesMatch(a.incr, b.incr); }
Example #24
Source File: GenericGenerators.java From coroutines with GNU Lesser General Public License v3.0 | 4 votes |
/** * For each element in an object array, performs an action. * @param counterVar parameter used to keep track of count in loop * @param arrayLenVar parameter used to keep track of array length * @param array object array instruction list -- must leave an array on the stack * @param action action to perform on each element -- element will be at top of stack and must be consumed by these instructions * @return instructions instruction list to perform some action if two ints are equal * @throws NullPointerException if any argument is {@code null} */ public static InsnList forEach(Variable counterVar, Variable arrayLenVar, InsnList array, InsnList action) { Validate.notNull(counterVar); Validate.notNull(arrayLenVar); Validate.notNull(array); Validate.notNull(action); Validate.isTrue(counterVar.getType().equals(Type.INT_TYPE)); Validate.isTrue(arrayLenVar.getType().equals(Type.INT_TYPE)); InsnList ret = new InsnList(); LabelNode doneLabelNode = new LabelNode(); LabelNode loopLabelNode = new LabelNode(); // put zero in to counterVar ret.add(new LdcInsnNode(0)); // int ret.add(new VarInsnNode(Opcodes.ISTORE, counterVar.getIndex())); // // load array we'll be traversing over ret.add(array); // object[] // put array length in to arrayLenVar ret.add(new InsnNode(Opcodes.DUP)); // object[], object[] ret.add(new InsnNode(Opcodes.ARRAYLENGTH)); // object[], int ret.add(new VarInsnNode(Opcodes.ISTORE, arrayLenVar.getIndex())); // object[] // loopLabelNode: test if counterVar == arrayLenVar, if it does then jump to doneLabelNode ret.add(loopLabelNode); ret.add(new VarInsnNode(Opcodes.ILOAD, counterVar.getIndex())); // object[], int ret.add(new VarInsnNode(Opcodes.ILOAD, arrayLenVar.getIndex())); // object[], int, int ret.add(new JumpInsnNode(Opcodes.IF_ICMPEQ, doneLabelNode)); // object[] // load object from object[] ret.add(new InsnNode(Opcodes.DUP)); // object[], object[] ret.add(new VarInsnNode(Opcodes.ILOAD, counterVar.getIndex())); // object[], object[], int ret.add(new InsnNode(Opcodes.AALOAD)); // object[], object // call action ret.add(action); // object[] // increment counter var and goto loopLabelNode ret.add(new IincInsnNode(counterVar.getIndex(), 1)); // object[] ret.add(new JumpInsnNode(Opcodes.GOTO, loopLabelNode)); // object[] // doneLabelNode: pop object[] off of stack ret.add(doneLabelNode); ret.add(new InsnNode(Opcodes.POP)); // return ret; }
Example #25
Source File: InsnListPrinter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") private void _visitInsn(AbstractInsnNode insn) { switch (insn.getType()) { case 0: 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; } }
Example #26
Source File: InstrUtils.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
public static String toString(AbstractInsnNode ain) { String opc = TextUtils.toBold(OpUtils.getOpcodeText(ain.getOpcode()).toLowerCase()) + " "; switch (ain.getType()) { case AbstractInsnNode.LABEL: opc = TextUtils.toLight("label " + OpUtils.getLabelIndex((LabelNode) ain)); break; case AbstractInsnNode.LINE: opc = TextUtils.toLight("line " + ((LineNumberNode) ain).line); break; case AbstractInsnNode.FIELD_INSN: FieldInsnNode fin = (FieldInsnNode) ain; opc += getDisplayType(TextUtils.escape(fin.desc), true) + " " + getDisplayClassRed(TextUtils.escape(fin.owner)) + "." + fin.name; break; case AbstractInsnNode.METHOD_INSN: MethodInsnNode min = (MethodInsnNode) ain; if (min.desc.contains(")")) { opc += getDisplayType(min.desc.split("\\)")[1], true); } else { opc += min.desc; } opc += " " + getDisplayClassRed(TextUtils.escape(min.owner)) + "." + TextUtils.escape(min.name) + "(" + getDisplayArgs(TextUtils.escape(min.desc)) + ")"; break; case AbstractInsnNode.VAR_INSN: VarInsnNode vin = (VarInsnNode) ain; opc += vin.var; break; case AbstractInsnNode.TYPE_INSN: TypeInsnNode tin = (TypeInsnNode) ain; String esc = TextUtils.escape(tin.desc); if (esc.endsWith(";") && esc.startsWith("L")) { opc += TextUtils.addTag(esc, "font color=" + primColor.getString()); } else { opc += getDisplayClass(esc); } break; case AbstractInsnNode.MULTIANEWARRAY_INSN: MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain; opc += mnin.dims + " " + getDisplayType(TextUtils.escape(mnin.desc), true); break; case AbstractInsnNode.JUMP_INSN: JumpInsnNode jin = (JumpInsnNode) ain; opc += OpUtils.getLabelIndex(jin.label); break; case AbstractInsnNode.LDC_INSN: LdcInsnNode ldc = (LdcInsnNode) ain; opc += TextUtils.addTag(ldc.cst.getClass().getSimpleName(), "font color=" + primColor.getString()) + " "; if (ldc.cst instanceof String) opc += TextUtils.addTag("\"" + TextUtils.escape(ldc.cst.toString()) + "\"", "font color=#559955"); else { opc += ldc.cst.toString(); } break; case AbstractInsnNode.INT_INSN: opc += OpUtils.getIntValue(ain); break; case AbstractInsnNode.IINC_INSN: IincInsnNode iinc = (IincInsnNode) ain; opc += iinc.var + " " + iinc.incr; break; case AbstractInsnNode.FRAME: FrameNode fn = (FrameNode) ain; opc = TextUtils .toLight(OpUtils.getFrameType(fn.type).toLowerCase() + " " + fn.local.size() + " " + fn.stack.size()); break; case AbstractInsnNode.TABLESWITCH_INSN: TableSwitchInsnNode tsin = (TableSwitchInsnNode) ain; if (tsin.dflt != null) { opc += TextUtils.addTag("L" + OpUtils.getLabelIndex(tsin.dflt), "font color=" + secColor.getString()); } if (tsin.labels.size() < 20) { for (LabelNode l : tsin.labels) { opc += " " + TextUtils.addTag("L" + OpUtils.getLabelIndex(l), "font color=" + primColor.getString()); } } else { opc += " " + TextUtils.addTag(tsin.labels.size() + " cases", "font color=" + primColor.getString()); } break; case AbstractInsnNode.INVOKE_DYNAMIC_INSN: InvokeDynamicInsnNode idin = (InvokeDynamicInsnNode) ain; Object[] arr = idin.bsmArgs; if (arr.length > 1) { Object o = arr[1]; if (o instanceof Handle) { Handle h = (Handle) o; opc += getDisplayType(h.getDesc().split("\\)")[1], true) + " " + getDisplayClassRed(TextUtils.escape(h.getOwner())) + "." + TextUtils.escape(h.getName()) + "(" + getDisplayArgs(TextUtils.escape(h.getDesc())) + ")"; } } else { opc += TextUtils.addTag(TextUtils.escape(idin.name), "font color=" + primColor.getString()) + " " + TextUtils.escape(idin.desc); } break; } return opc; }
Example #27
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
public static boolean iincInsnEqual(IincInsnNode node1, IincInsnNode node2) { return node1.var == node2.var && node1.incr == node2.incr; }
Example #28
Source File: InsnListPrinter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
@SuppressWarnings("deprecation") private void _visitInsn(AbstractInsnNode insn) { switch (insn.getType()) { case 0: 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; } }
Example #29
Source File: InstructionComparator.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
public static boolean iincInsnEqual(IincInsnNode node1, IincInsnNode node2) { return node1.var == node2.var && node1.incr == node2.incr; }
Example #30
Source File: InsnListPrinter.java From NOVA-Core with GNU Lesser General Public License v3.0 | 4 votes |
private void _visitInsn(AbstractInsnNode insn) { switch (insn.getType()) { case 0: 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; } }