m.instructions.insert(mn, nLdc);
@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; }
@Override public void apply(MethodPatcher.PatchData patch, MethodNode methodNode, AbstractInsnNode location, Method method) { methodNode.instructions.insert(location, method.insnList); } },
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; }
public InsnListBuilder insert(AbstractInsnNode node) { insn.insert(node); return this; }
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); }); }
public InsnListBuilder insert(InsnList insn) { this.insn.insert(insn); return this; }
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()); } }); }
public CodeBlock prepend(final CodeBlock codeBlock) { if (codeBlock.returns()) returns = true; annotations.addAll(codeBlock.annotations); instructionList.insert(codeBlock.instructionList); return this; }
public CodeBlock prepend(final CodeBlock codeBlock) { if (codeBlock.returns()) returns = true; annotations.addAll(codeBlock.annotations); instructionList.insert(codeBlock.instructionList); return this; }
public static SpecificMethodNodeTransformer instructionsBeginningInserter(String target, int priority, InsnList insn) { return instructionsTransformer(priority, target, instructions -> instructions.insert(insn)); }
/** 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); }
/** * 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); }
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); }
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); }
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); }
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); }
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); }
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)); } }
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; }))); }