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

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

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

InsnList.insert介绍

[英]Inserts the given instruction at the begining of this list.
[中]在此列表的开头插入给定的指令。

代码示例

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

m.instructions.insert(mn, nLdc);

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

@Override
public void add(final Object o) {
 if (nextInsn != null) {
  InsnList.this.insertBefore(nextInsn, (AbstractInsnNode) o);
 } else if (previousInsn != null) {
  InsnList.this.insert(previousInsn, (AbstractInsnNode) o);
 } else {
  InsnList.this.add((AbstractInsnNode) o);
 }
 previousInsn = (AbstractInsnNode) o;
 remove = null;
}

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

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

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

public void add(Object o) {
  if (next != null) {
    InsnList.this.insertBefore(next, (AbstractInsnNode) o);
  } else if (prev != null) {
    InsnList.this.insert(prev, (AbstractInsnNode) o);
  } else {
    InsnList.this.add((AbstractInsnNode) o);
  }
  prev = (AbstractInsnNode) o;
  remove = null;
}

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

public InsnListBuilder insert(AbstractInsnNode node) {
  insn.insert(node);
  return this;
}

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

public static SpecificMethodNodeTransformer instructionsInserter(String target, int priority, Function<InsnList, AbstractInsnNode> where, InsnList insn, boolean before) {
  return instructionsTransformer(priority, target, instructions -> {
    if (before) instructions.insertBefore(where.apply(instructions), insn);
    else instructions.insert(where.apply(instructions), insn);
  });
}

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

public InsnListBuilder insert(InsnList insn) {
  this.insn.insert(insn);
  return this;
}

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

public static SpecificMethodNodeTransformer instructionsInserter(String target, int priority, Function<AbstractInsnNode, Pair<InsnList, Boolean>> inserter) {
  return instructionsTransformer(priority, target, instructions -> {
    for (AbstractInsnNode node : instructions.toArray()) {
      Pair<InsnList, Boolean> pair = inserter.apply(node);
      if (pair != null) if (pair.getRight()) instructions.insertBefore(node, pair.getLeft());
      else instructions.insert(node, pair.getLeft());
    }
  });
}

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

public CodeBlock prepend(final CodeBlock codeBlock)
{
  if (codeBlock.returns())
    returns = true;
  annotations.addAll(codeBlock.annotations);
  instructionList.insert(codeBlock.instructionList);
  return this;
}

代码示例来源:origin: qmx/jitescript

public CodeBlock prepend(final CodeBlock codeBlock) {
  if (codeBlock.returns())
    returns = true;
  annotations.addAll(codeBlock.annotations);
  instructionList.insert(codeBlock.instructionList);
  return this;
}

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

public static SpecificMethodNodeTransformer instructionsBeginningInserter(String target, int priority, InsnList insn) {
  return instructionsTransformer(priority, target, instructions -> instructions.insert(insn));
}

代码示例来源: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: org.renjin/gcc-bridge-compiler

/**
 * Inserts a new instruction after the current position. 
 *
 * <p>Does not change the current instruction pointer.</p>
 *
 * @param node the node to insert
 */
public void insert(AbstractInsnNode... nodes) {
 InsnList newList = new InsnList();
 for (AbstractInsnNode node : nodes) {
  newList.add(node);
 }
 list.insert(current, newList);
}

代码示例来源: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: 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 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: 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: org.parboiled/parboiled-java

protected void convertXLoads(InstructionGroup group) {
  String owner = group.getGroupClassType().getInternalName();
  for (InstructionGraphNode node : group.getNodes()) {
    if (!node.isXLoad()) continue;
    VarInsnNode insn = (VarInsnNode) node.getInstruction();
    FieldNode field = group.getFields().get(insn.var);
    // insert the correct GETFIELD after the xLoad
    group.getInstructions().insert(insn, new FieldInsnNode(GETFIELD, owner, field.name, field.desc));
    // change the load to ALOAD 0
    group.getInstructions().set(insn, new VarInsnNode(ALOAD, 0));
  }
}

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

private static byte[] transformRenderBoat(byte[] basicClass) {
  log("Transforming RenderBoat");
  MethodSignature sig = new MethodSignature("doRender", "func_188300_b", "b", "(Lnet/minecraft/entity/item/EntityBoat;DDDFF)V");
  return transform(basicClass, Pair.of(sig, combine(
      (AbstractInsnNode node) -> { // Filter
        return (node.getOpcode() == Opcodes.INVOKEVIRTUAL || node.getOpcode() == Opcodes.INVOKEINTERFACE)
            && checkDesc(((MethodInsnNode) node).desc, "(Lnet/minecraft/entity/Entity;FFFFFF)V");
      },
      (MethodNode method, AbstractInsnNode node) -> { // Action
        InsnList newInstructions = new InsnList();
        newInstructions.add(new VarInsnNode(Opcodes.ALOAD, 1));
        newInstructions.add(new VarInsnNode(Opcodes.FLOAD, 9));
        newInstructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, ASM_HOOKS, "renderBannerOnBoat", "(Lnet/minecraft/entity/item/EntityBoat;F)V"));
        method.instructions.insert(node, newInstructions);
        return true;
      })));
}

相关文章