List of usage examples for org.objectweb.asm.tree InsnList size
int size
To view the source code for org.objectweb.asm.tree InsnList size.
Click Source Link
From source file:net.epoxide.surge.asm.InstructionComparator.java
License:Creative Commons License
public static List<Integer> insnListFind(InsnList haystack, InsnList needle) { final LinkedList<Integer> list = new LinkedList<Integer>(); for (int start = 0; start <= haystack.size() - needle.size(); start++) if (insnListMatches(haystack, needle, start)) list.add(start);//from ww w .ja va2s . c o m return list; }
From source file:net.epoxide.surge.asm.InstructionComparator.java
License:Creative Commons License
public static List<AbstractInsnNode> insnListFindEnd(InsnList haystack, InsnList needle) { final LinkedList<AbstractInsnNode> callNodes = new LinkedList<AbstractInsnNode>(); for (final int callPoint : insnListFind(haystack, needle)) callNodes.add(haystack.get(callPoint + needle.size() - 1)); return callNodes; }
From source file:net.epoxide.surge.asm.InstructionComparator.java
License:Creative Commons License
public static List<InsnListSection> insnListFindL(InsnList haystack, InsnList needle) { final HashSet<LabelNode> controlFlowLabels = new HashSet<LabelNode>(); for (AbstractInsnNode insn = haystack.getFirst(); insn != null; insn = insn.getNext()) switch (insn.getType()) { case 8://from www . j a v a2 s . c o m case 15: break; case 7: final JumpInsnNode jinsn = (JumpInsnNode) insn; controlFlowLabels.add(jinsn.label); break; case 11: final TableSwitchInsnNode tsinsn = (TableSwitchInsnNode) insn; for (final LabelNode label : tsinsn.labels) controlFlowLabels.add(label); break; case 12: final LookupSwitchInsnNode lsinsn = (LookupSwitchInsnNode) insn; for (final LabelNode label : lsinsn.labels) controlFlowLabels.add(label); break; } final LinkedList<InsnListSection> list = new LinkedList<InsnListSection>(); nextsection: for (int start = 0; start <= haystack.size() - needle.size(); start++) { final InsnListSection section = insnListMatchesL(haystack, needle, start, controlFlowLabels); if (section != null) { for (final InsnListSection asection : list) if (asection.last == section.last) continue nextsection; list.add(section); } } return list; }
From source file:net.epoxide.surge.asm.InstructionComparator.java
License:Creative Commons License
public static boolean insnListMatches(InsnList haystack, InsnList needle, int start) { if (haystack.size() - start < needle.size()) return false; for (int i = 0; i < needle.size(); i++) if (!insnEqual(haystack.get(i + start), needle.get(i))) return false; return true;/*from ww w.j a v a 2 s. com*/ }
From source file:net.epoxide.surge.asm.InstructionComparator.java
License:Creative Commons License
private static InsnListSection insnListMatchesL(InsnList haystack, InsnList needle, int start, HashSet<LabelNode> controlFlowLabels) { int h = start, n = 0; for (; h < haystack.size() && n < needle.size(); h++) { final AbstractInsnNode insn = haystack.get(h); if (insn.getType() == 15) continue; if (insn.getType() == 8 && !controlFlowLabels.contains(insn)) continue; if (!insnEqual(haystack.get(h), needle.get(n))) return null; n++;// w w w .j av a 2s .c o m } if (n != needle.size()) return null; return new InsnListSection(haystack, start, h - 1); }
From source file:net.malisis.core.asm.AsmHook.java
License:Open Source License
public AsmHook jumpAfter(InsnList match) { this.jumpTo(match); this.jump(match.size()); return this; }
From source file:net.malisis.core.asm.AsmHook.java
License:Open Source License
public boolean walkSteps(MethodNode methodNode) { int index = 0; for (HookStep step : steps) { switch (step) { case FIND: InsnList match = matches.remove(0); AbstractInsnNode node = AsmUtils.findInstruction(methodNode, match); if (node == null) return false; else//from w w w . j ava 2 s.c o m index = methodNode.instructions.indexOf(node); break; case INSERT: InsnList insert = inserts.remove(0); index += insert.size(); methodNode.instructions.insert(methodNode.instructions.get(index - insert.size()), insert); break; case JUMP: int jump = jumps.remove(0); if (jump == END) index = methodNode.instructions.size() - 1; else index += jump; default: break; } } return true; }
From source file:nova.core.wrapper.mc.forge.v17.asm.lib.InstructionComparator.java
License:Open Source License
public static InsnList getImportantList(InsnList list) { if (list.size() == 0) { return list; }// w ww . j a v a 2s . co m HashMap<LabelNode, LabelNode> labels = new HashMap<LabelNode, LabelNode>(); for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) { if (insn instanceof LabelNode) { labels.put((LabelNode) insn, (LabelNode) insn); } } InsnList importantNodeList = new InsnList(); for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) { if (insn instanceof LabelNode || insn instanceof LineNumberNode) { continue; } importantNodeList.add(insn.clone(labels)); } return importantNodeList; }
From source file:nova.core.wrapper.mc.forge.v17.asm.lib.InstructionComparator.java
License:Open Source License
public static List<Integer> insnListFind(InsnList haystack, InsnList needle) { LinkedList<Integer> list = new LinkedList<Integer>(); for (int start = 0; start <= haystack.size() - needle.size(); start++) { if (insnListMatches(haystack, needle, start)) { list.add(start);//from ww w .j a va 2 s.com } } return list; }
From source file:nova.core.wrapper.mc.forge.v17.asm.lib.InstructionComparator.java
License:Open Source License
public static List<AbstractInsnNode> insnListFindEnd(InsnList haystack, InsnList needle) { LinkedList<AbstractInsnNode> callNodes = new LinkedList<AbstractInsnNode>(); for (int callPoint : insnListFind(haystack, needle)) { callNodes.add(haystack.get(callPoint + needle.size() - 1)); }/*from w w w . j a v a 2 s .c o m*/ return callNodes; }