private LabelNode findLineLabel(InsnList insns, int line) { for (Iterator it = insns.iterator(); it.hasNext(); ) { Object n = it.next(); if (n instanceof LineNumberNode && ((LineNumberNode) n).line == line) { return ((LineNumberNode) n).start; } } return null; }
private boolean checkInlineExceptionHandler(LabelNode ln) { // If this label is reachable through an exception and through normal // code, we have to split the exceptional case (with the exception on // the stack) from the normal fall-through case without anything on the // stack. for (Iterator<AbstractInsnNode> it = instructions.iterator(); it.hasNext();) { AbstractInsnNode node = it.next(); if (node instanceof JumpInsnNode) { if (((JumpInsnNode) node).label == ln) { inlineExceptionLabels.add(ln); return true; } } else if (node instanceof LookupSwitchInsnNode) { if (((LookupSwitchInsnNode) node).labels.contains(ln)) { inlineExceptionLabels.add(ln); return true; } } else if (node instanceof TableSwitchInsnNode) { if (((TableSwitchInsnNode) node).labels.contains(ln)) { inlineExceptionLabels.add(ln); return true; } } } return false; }
ListIterator<AbstractInsnNode> instructions = callingMethod.instructions.iterator(); while (instructions.hasNext()) { AbstractInsnNode node = instructions.next();
private List<AbstractInsnNode> createInstructionList() { final List<AbstractInsnNode> list = new LinkedList<>(); final ListIterator<AbstractInsnNode> it = this.rawNode.instructions.iterator(); while (it.hasNext()) { list.add(it.next()); } this.lazyInstructions = new ArrayList<>(list); return this.lazyInstructions; }
final Iterator<AbstractInsnNode> i = mn.instructions.iterator(); while( i.hasNext() )
/** * Returns an iterator over the instructions in this list. * * @return an iterator over the instructions in this list. */ public ListIterator<AbstractInsnNode> iterator() { return iterator(0); }
/** * Returns an iterator over the instructions in this list. * * @return an iterator over the instructions in this list. */ public ListIterator<AbstractInsnNode> iterator() { return iterator(0); }
private static void handleMethodCalls(ClassNode cn, MethodNode mn) { InsnList instructions = mn.instructions; Iterator<AbstractInsnNode> iterator = instructions.iterator(); // TODO: This really shouldn't be here but in its own class while (iterator.hasNext()) { AbstractInsnNode insn = iterator.next(); if (insn instanceof MethodInsnNode) { MethodInsnNode minsn = (MethodInsnNode)insn; handleDependency(minsn.owner); } } } }
public static void clearNextInstructions(MethodNode methodNode, AbstractInsnNode insnNode, int count) { Iterator<AbstractInsnNode> iterator = methodNode.instructions.iterator(methodNode.instructions.indexOf(insnNode)); while (iterator.hasNext() && count > 0) { iterator.next(); iterator.remove(); count--; } }
private Set<Label> findJumpTargets(MethodNode methodNode) { Set<Label> targets = Sets.newHashSet(); ListIterator<AbstractInsnNode> it = methodNode.instructions.iterator(); while(it.hasNext()) { AbstractInsnNode node = it.next(); if(node instanceof JumpInsnNode) { JumpInsnNode jumpNode = (JumpInsnNode) node; targets.add(jumpNode.label.getLabel()); } } return targets; } }
List<Result> findMatchingCallSites(InsnList instructions, List<LocalVariableAnnotationNode> varAnnotations, Map<Integer, List<AnnotationNode>> paramAnnotations) { List<Result> result = new ArrayList<Result>(); for (@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> i = instructions.iterator(); i.hasNext(); ) { AbstractInsnNode ins = i.next(); if (ins instanceof MethodInsnNode) { MethodInsnNode mins = (MethodInsnNode)ins; Result entry = findMatchingCallSite(mins, varAnnotations, paramAnnotations); if (entry != null) { result.add(entry); } } } return result; }
public static void clearNextInstructions(MethodNode methodNode, AbstractInsnNode insnNode) { Iterator<AbstractInsnNode> iterator = methodNode.instructions.iterator(methodNode.instructions.indexOf(insnNode)); while (iterator.hasNext()) { iterator.next(); iterator.remove(); } }
private boolean hasInvokeOperation() { for (ListIterator<AbstractInsnNode> iterator = instructions.iterator(); iterator.hasNext(); ) { AbstractInsnNode node = iterator.next(); int opcode = node.getOpcode(); if (opcode == -1) continue; if (opcode >= INVOKEVIRTUAL && opcode <= INVOKEDYNAMIC) { return true; } } return false; } }
List<Result> findMatchingCallSites(InsnList instructions, List<LocalVariableAnnotationNode> varAnnotations, Map<Integer, List<AnnotationNode>> paramAnnotations) { List<Result> result = new ArrayList<>(); for (Iterator<AbstractInsnNode> i = instructions.iterator(); i.hasNext(); ) { AbstractInsnNode ins = i.next(); if (ins instanceof MethodInsnNode) { MethodInsnNode mins = (MethodInsnNode)ins; Result entry = findMatchingCallSite(mins, varAnnotations, paramAnnotations); if (entry != null) { result.add(entry); } } } return result; }
List<Result> findMatchingCallSites(InsnList instructions, List<LocalVariableAnnotationNode> varAnnotations, Map<Integer, List<AnnotationNode>> paramAnnotations) { List<Result> result = new ArrayList<Result>(); for (@SuppressWarnings("unchecked") Iterator<AbstractInsnNode> i = instructions.iterator(); i.hasNext(); ) { AbstractInsnNode ins = i.next(); if (ins instanceof MethodInsnNode) { MethodInsnNode mins = (MethodInsnNode)ins; Result entry = findMatchingCallSite(mins, varAnnotations, paramAnnotations); if (entry != null) { result.add(entry); } } } return result; }
@SuppressWarnings("unchecked") private void handleMethodNode(Set<String> calledClasses, ClassNode cn, MethodNode mn, Set<String> targetClasses) throws IOException { InsnList instructions = mn.instructions; Iterator<AbstractInsnNode> iterator = instructions.iterator(); while (iterator.hasNext()) { AbstractInsnNode insn = iterator.next(); if (insn instanceof MethodInsnNode) { String name = ResourceList.getClassNameFromResourcePath(((MethodInsnNode) insn).owner); if (!targetClasses.contains(name)) continue; if (isValidClass(name)) calledClasses.add(name); } } }
@Override void processMethod(MethodNode method) { sendPatchLog("handleHeldItemChange"); ListIterator<AbstractInsnNode> insn = method.instructions.iterator(); while (insn.hasNext()) { AbstractInsnNode nextNode = insn.next(); if (nextNode instanceof MethodInsnNode && nextNode.getOpcode() == INVOKESTATIC && ((MethodInsnNode) nextNode).owner.equals(inventoryPlayerClass)) { ((MethodInsnNode) nextNode).owner = "mods/battlegear2/api/core/InventoryPlayerBattle"; ((MethodInsnNode) nextNode).name = "isValidSwitch"; ((MethodInsnNode) nextNode).desc = "(I)Z"; return; } } }
private void addTraceThrow() { InsnList il = this.mn.instructions; Iterator<AbstractInsnNode> it = il.iterator(); while (it.hasNext()) { AbstractInsnNode abstractInsnNode = it.next(); switch (abstractInsnNode.getOpcode()) { case Opcodes.ATHROW: il.insertBefore(abstractInsnNode, getThrowTraceInstructions()); break; } } }
private void addTraceThrow() { val it = methodNode.instructions.iterator(); while (it.hasNext()) { val insnNode = (AbstractInsnNode) it.next(); switch (insnNode.getOpcode()) { case ATHROW: methodNode.instructions.insertBefore(insnNode, getThrowTraceInsts()); break; } } }
public static boolean applyOnNode(MethodNode method, NodeFilter filter, NodeAction action) { Iterator<AbstractInsnNode> iterator = method.instructions.iterator(); boolean didAny = false; while(iterator.hasNext()) { AbstractInsnNode anode = iterator.next(); if(filter.test(anode)) { log("Located patch target node " + getNodeString(anode)); didAny = true; if(action.test(method, anode)) break; } } return didAny; }