Java Code Examples for org.objectweb.asm.tree.AbstractInsnNode#LINE
The following examples show how to use
org.objectweb.asm.tree.AbstractInsnNode#LINE .
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: ClassContext.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Finds the line number closest to the given node * * @param node the instruction node to get a line number for * @return the closest line number, or -1 if not known */ public static int findLineNumber(@NonNull AbstractInsnNode node) { AbstractInsnNode curr = node; // First search backwards while (curr != null) { if (curr.getType() == AbstractInsnNode.LINE) { return ((LineNumberNode) curr).line; } curr = curr.getPrevious(); } // Then search forwards curr = node; while (curr != null) { if (curr.getType() == AbstractInsnNode.LINE) { return ((LineNumberNode) curr).line; } curr = curr.getNext(); } return -1; }
Example 2
Source File: LintUtils.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns the previous instruction prior to the given node, ignoring label * and line number nodes. * * @param node the node to look up the previous instruction for * @return the previous instruction, or null if no previous node was found */ @Nullable public static AbstractInsnNode getPrevInstruction(@NonNull AbstractInsnNode node) { AbstractInsnNode prev = node; while (true) { prev = prev.getPrevious(); if (prev == null) { return null; } else { int type = prev.getType(); if (type != AbstractInsnNode.LINE && type != AbstractInsnNode.LABEL && type != AbstractInsnNode.FRAME) { return prev; } } } }
Example 3
Source File: LintUtils.java From javaide with GNU General Public License v3.0 | 6 votes |
/** * Returns the next instruction after to the given node, ignoring label and * line number nodes. * * @param node the node to look up the next node for * @return the next instruction, or null if no next node was found */ @Nullable public static AbstractInsnNode getNextInstruction(@NonNull AbstractInsnNode node) { AbstractInsnNode next = node; while (true) { next = next.getNext(); if (next == null) { return null; } else { int type = next.getType(); if (type != AbstractInsnNode.LINE && type != AbstractInsnNode.LABEL && type != AbstractInsnNode.FRAME) { return next; } } } }
Example 4
Source File: Converter.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private boolean isJumpBlock(Block b) { for (AbstractInsnNode ain : b.getNodes()) { int type = ain.getType(); if (type != AbstractInsnNode.LABEL && type != AbstractInsnNode.LINE && type != AbstractInsnNode.FRAME && type != AbstractInsnNode.JUMP_INSN) { return false; } } return true; }
Example 5
Source File: Converter.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
private boolean isJumpBlock(Block b) { for (AbstractInsnNode ain : b.getNodes()) { int type = ain.getType(); if (type != AbstractInsnNode.LABEL && type != AbstractInsnNode.LINE && type != AbstractInsnNode.FRAME && type != AbstractInsnNode.JUMP_INSN) { return false; } } return true; }
Example 6
Source File: ASMMethodNodeAdapter.java From pinpoint with Apache License 2.0 | 5 votes |
public int getLineNumber() { AbstractInsnNode node = this.methodNode.instructions.getFirst(); while (node != null) { if (node.getType() == AbstractInsnNode.LINE) { return ((LineNumberNode) node).line; } node = node.getNext(); } return 0; }
Example 7
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 8
Source File: InstrUtils.java From JByteMod-Beta with GNU General Public License v2.0 | 4 votes |
public static String toEasyString(AbstractInsnNode ain) { String opc = OpUtils.getOpcodeText(ain.getOpcode()).toLowerCase() + " "; switch (ain.getType()) { case AbstractInsnNode.LABEL: opc = "label " + OpUtils.getLabelIndex((LabelNode) ain); break; case AbstractInsnNode.LINE: opc = "line " + ((LineNumberNode) ain).line; break; case AbstractInsnNode.FIELD_INSN: FieldInsnNode fin = (FieldInsnNode) ain; opc += getDisplayType(fin.desc, false) + " " + getDisplayClassEasy(fin.owner) + "." + fin.name; break; case AbstractInsnNode.METHOD_INSN: MethodInsnNode min = (MethodInsnNode) ain; opc += getDisplayType(min.desc.split("\\)")[1], false) + " " + getDisplayClassEasy(min.owner) + "." + min.name + "(" + getDisplayArgsEasy(min.desc) + ")"; break; case AbstractInsnNode.VAR_INSN: VarInsnNode vin = (VarInsnNode) ain; opc += vin.var; break; case AbstractInsnNode.MULTIANEWARRAY_INSN: MultiANewArrayInsnNode mnin = (MultiANewArrayInsnNode) ain; opc += mnin.dims + " " + getDisplayType(mnin.desc, false); break; case AbstractInsnNode.TYPE_INSN: TypeInsnNode tin = (TypeInsnNode) ain; String esc = tin.desc; if (esc.endsWith(";") && esc.startsWith("L")) { opc += esc; } else { opc += getDisplayClassEasy(esc); } break; case AbstractInsnNode.JUMP_INSN: JumpInsnNode jin = (JumpInsnNode) ain; opc += OpUtils.getLabelIndex(jin.label); break; case AbstractInsnNode.LDC_INSN: LdcInsnNode ldc = (LdcInsnNode) ain; opc += ldc.cst.getClass().getSimpleName() + " "; if (ldc.cst instanceof String) opc += "\"" + ldc.cst.toString() + "\""; 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 = OpUtils.getOpcodeText(fn.type).toLowerCase() + " " + fn.local.size() + " " + fn.stack.size(); break; case AbstractInsnNode.TABLESWITCH_INSN: TableSwitchInsnNode tsin = (TableSwitchInsnNode) ain; if (tsin.dflt != null) { opc += "L" + OpUtils.getLabelIndex(tsin.dflt); } if (tsin.labels.size() < 20) { for (LabelNode l : tsin.labels) { opc += " " + "L" + OpUtils.getLabelIndex(l); } } else { opc += " " + tsin.labels.size() + " cases"; } break; case AbstractInsnNode.INVOKE_DYNAMIC_INSN: InvokeDynamicInsnNode idin = (InvokeDynamicInsnNode) ain; opc += idin.name + " " + idin.desc; break; } return opc; }