org.objectweb.asm.tree.InsnList.iterator()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中org.objectweb.asm.tree.InsnList.iterator()方法的一些代码示例,展示了InsnList.iterator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InsnList.iterator()方法的具体详情如下:
包路径:org.objectweb.asm.tree.InsnList
类名称:InsnList
方法名:iterator

InsnList.iterator介绍

[英]Returns an iterator over the instructions in this list.
[中]返回此列表中指令的迭代器。

代码示例

代码示例来源:origin: linkedin/parseq

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;
}

代码示例来源:origin: Sable/soot

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;
}

代码示例来源:origin: robolectric/robolectric

ListIterator<AbstractInsnNode> instructions = callingMethod.instructions.iterator();
while (instructions.hasNext()) {
 AbstractInsnNode node = instructions.next();

代码示例来源:origin: hcoles/pitest

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;
}

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

final Iterator<AbstractInsnNode> i = mn.instructions.iterator();
while( i.hasNext() )

代码示例来源:origin: org.ow2.asm/asm-tree

/**
 * 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);
}

代码示例来源:origin: org.ow2.asm/asm-debug-all

/**
 * 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);
}

代码示例来源:origin: EvoSuite/evosuite

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);
      }
    }
  }
}

代码示例来源:origin: Glitchfiend/SereneSeasons

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--;
  }
}

代码示例来源:origin: org.renjin/gcc-bridge-compiler

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;
 }
}

代码示例来源:origin: net.tascalate.javaflow/net.tascalate.javaflow.providers.asm5

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;
}

代码示例来源:origin: Glitchfiend/SereneSeasons

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();
  }
}

代码示例来源:origin: SmartDengg/asm-clickdebounce

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;
 }
}

代码示例来源:origin: vsilaev/tascalate-javaflow

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;
}

代码示例来源:origin: vsilaev/tascalate-javaflow

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;
}

代码示例来源:origin: EvoSuite/evosuite

@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);
    }
  }
}

代码示例来源:origin: Mine-and-blade-admin/Battlegear2

@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;
    }
  }
}

代码示例来源:origin: brutusin/instrumentation

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;
    }
  }
}

代码示例来源:origin: com.github.bingoohuang/blackcat-instrument

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;
    }
  }
}

代码示例来源:origin: Vazkii/Quark

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;
}

相关文章