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

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

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

InsnList.remove介绍

[英]Removes the given instruction from this list.
[中]从此列表中删除给定的指令。

代码示例

代码示例来源:origin: pxb1988/dex2jar

void removeInsts(MethodNode m, MethodInsnNode mn, int pSize) {
  // remove args
  for (int i = 0; i < pSize; i++) {
    m.instructions.remove(mn.getPrevious());
  }
  // remove INVOKESTATIC
  m.instructions.remove(mn);
}

代码示例来源:origin: pxb1988/dex2jar

private void cleanDebug(MethodNode mn) {
  for (AbstractInsnNode p = mn.instructions.getFirst(); p != null; ) {
    if (p.getType() == AbstractInsnNode.LINE) {
      AbstractInsnNode q = p.getNext();
      mn.instructions.remove(p);
      p = q;
    } else {
      p = p.getNext();
    }
  }
  mn.localVariables = null;
}

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

ctor.instructions.remove(insns[startIndex]);
removedInstructions.add(insns[startIndex]);
startIndex++;

代码示例来源:origin: jphp-group/jphp

if (useConstants && code.getLast() instanceof LdcInsnNode) {
  LdcInsnNode node = (LdcInsnNode) code.getLast();
  code.remove(node);
if (useConstants && code.getLast() instanceof LdcInsnNode) {
  LdcInsnNode node = (LdcInsnNode) code.getLast();
  code.remove(node);
if (useConstants && code.getLast() instanceof LdcInsnNode) {
  LdcInsnNode node = (LdcInsnNode) code.getLast();
  code.remove(node);

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

public void remove() {
  if (remove != null) {
    if (remove == next) {
      next = next.next;
    } else {
      prev = prev.prev;
    }
    InsnList.this.remove(remove);
    remove = null;
  } else {
    throw new IllegalStateException();
  }
}

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

@Override
public void remove() {
 if (remove != null) {
  if (remove == nextInsn) {
   nextInsn = nextInsn.nextInsn;
  } else {
   previousInsn = previousInsn.previousInsn;
  }
  InsnList.this.remove(remove);
  remove = null;
 } else {
  throw new IllegalStateException();
 }
}

代码示例来源:origin: iLexiconn/LLibrary

@Override
  public void apply(MethodPatcher.PatchData patch, MethodNode methodNode, AbstractInsnNode location, Method method) {
    methodNode.instructions.insertBefore(location, method.insnList);
    methodNode.instructions.remove(location);
  }
};

代码示例来源:origin: org.lwjgl.lwjgl/lwjgl_util

/** Replace an instruction with a list of instructions. */
static int replace(final InsnList instructions, final int i, final AbstractInsnNode location, final InsnList list) {
  final int size = list.size();
  instructions.insert(location, list);
  instructions.remove(location);
  return i + (size - 1);
}

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

private void insertDoubleComparisonL(AbstractInsnNode position, InsnList list) {
  MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
      Type.getInternalName(BooleanHelper.class), "doubleSubL",
      Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE,
          Type.DOUBLE_TYPE }), false);
  list.insert(position, get);
  list.remove(position);
}

代码示例来源:origin: org.parboiled/parboiled-java

private void removeGroupRootInstruction() {
  method.instructions.remove(group.getRoot().getInstruction());
}

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

private void insertDoubleComparisonG(AbstractInsnNode position, InsnList list) {
  MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
      Type.getInternalName(BooleanHelper.class), "doubleSubG",
      Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.DOUBLE_TYPE,
          Type.DOUBLE_TYPE }), false);
  list.insert(position, get);
  list.remove(position);
}

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

private void insertFloatComparisonG(AbstractInsnNode position, InsnList list) {
  MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
      Type.getInternalName(BooleanHelper.class), "floatSubG",
      Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE,
          Type.FLOAT_TYPE }), false);
  list.insert(position, get);
  list.remove(position);
}

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

private void insertFloatComparisonL(AbstractInsnNode position, InsnList list) {
  MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
      Type.getInternalName(BooleanHelper.class), "floatSubL",
      Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.FLOAT_TYPE,
          Type.FLOAT_TYPE }), false);
  list.insert(position, get);
  list.remove(position);
}

代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped

public static SpecificMethodNodeTransformer instructionsNodesTransformer(String target, int priority, Function<AbstractInsnNode, AbstractInsnNode> insnOld2new) {
  return instructionsTransformer(priority, target, instructions -> {
    for (AbstractInsnNode node : instructions.toArray()) {
      AbstractInsnNode res = insnOld2new.apply(node);
      if (res != null) instructions.set(node, res);
      else instructions.remove(node);
    }
  });
}

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

private void insertLongComparison(AbstractInsnNode position, InsnList list) {
  MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
      Type.getInternalName(BooleanHelper.class), "longSub",
      Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.LONG_TYPE,
          Type.LONG_TYPE }), false);
  list.insert(position, get);
  list.remove(position);
}

代码示例来源:origin: ItzSomebody/Radon

@Override
public void transform() {
  AtomicInteger count = new AtomicInteger();
  long current = System.currentTimeMillis();
  getClassWrappers().parallelStream().filter(classWrapper -> !excluded(classWrapper)).forEach(classWrapper ->
    classWrapper.methods.parallelStream().filter(methodWrapper -> !excluded(methodWrapper)
        && hasInstructions(methodWrapper.methodNode)).forEach(methodWrapper -> {
      MethodNode methodNode = methodWrapper.methodNode;
      for (AbstractInsnNode insn : methodNode.instructions.toArray()) {
        if (insn.getOpcode() == NOP) {
          methodNode.instructions.remove(insn);
        }
      }
    })
  );
  LoggerUtils.stdOut(String.format("Removed %d NOP instructions. [%dms]", count.get(), tookThisLong(current)));
}

代码示例来源:origin: org.parboiled/parboiled-java

@SuppressWarnings({"SuspiciousMethodCalls"})
public void process(ParserClassNode classNode, RuleMethod method) throws Exception {
  checkArgNotNull(classNode, "classNode");
  checkArgNotNull(method, "method");
  AbstractInsnNode current = method.instructions.getFirst();
  while (current != null) {
    AbstractInsnNode next = current.getNext();
    if (current.getType() == AbstractInsnNode.LABEL && !method.getUsedLabels().contains(current)) {
      method.instructions.remove(current);
    }
    current = next;
  }
}

代码示例来源:origin: org.parboiled/parboiled-java

private void extractInstructions(InstructionGroup group) {
  for (InstructionGraphNode node : group.getNodes()) {
    if (node != group.getRoot()) {
      AbstractInsnNode insn = node.getInstruction();
      method.instructions.remove(insn);
      group.getInstructions().add(insn);
    }
  }
}

代码示例来源:origin: fge/grappa

private void extractInstructions(final InstructionGroup group)
{
  AbstractInsnNode insn;
  for (final InstructionGraphNode node: group.getNodes()) {
    if (node == group.getRoot())
      continue;
    insn = node.getInstruction();
    method.instructions.remove(insn);
    group.getInstructions().add(insn);
  }
}

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

@Override
  protected AbstractInsnNode transformTypeInsnNode(MethodNode mn,
      TypeInsnNode typeNode) {
    if (frames == null)
      return typeNode;

    if (typeNode.getOpcode() == Opcodes.CHECKCAST) {
      Frame current = frames[mn.instructions.indexOf(typeNode)];
      int size = current.getStackSize();
      if (current.getStack(size - 1) == BooleanArrayInterpreter.INT_ARRAY) {
        BooleanTestabilityTransformation.logger.info("Array is of boolean type, changing CHECKCAST to [I");
        TypeInsnNode replacement = new TypeInsnNode(Opcodes.CHECKCAST, "[I");
        mn.instructions.insertBefore(typeNode, replacement);
        mn.instructions.remove(typeNode);
        return replacement;
      }
    }
    return typeNode;
  }
}

相关文章