Class InsnListUtils

java.lang.Object
ftbsc.lll.utils.InsnListUtils

public class InsnListUtils extends Object
A collection of utilities for manipulating InsnLists.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.objectweb.asm.tree.InsnList
    between(org.objectweb.asm.tree.AbstractInsnNode startNode, org.objectweb.asm.tree.AbstractInsnNode endNode)
    Creates a sublist with all the nodes between the given extremes.
    static void
    cut(org.objectweb.asm.tree.InsnList list, int amount, boolean reverse)
    Cut a number of nodes from the list.
    static org.objectweb.asm.tree.InsnList
    of(org.objectweb.asm.tree.AbstractInsnNode... nodes)
    Factory method that builds an InsnList with the given nodes.
    static boolean
    replace(org.objectweb.asm.tree.InsnList list, int opcode, org.objectweb.asm.tree.AbstractInsnNode newNode, int amount, boolean reverse)
    Replaces n occurrences of said opcode with the given node.
    static void
    replaceNode(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.tree.AbstractInsnNode oldNode, org.objectweb.asm.tree.AbstractInsnNode newNode)
    Replaces a node with another one.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • InsnListUtils

      public InsnListUtils()
  • Method Details

    • of

      public static org.objectweb.asm.tree.InsnList of(org.objectweb.asm.tree.AbstractInsnNode... nodes)
      Factory method that builds an InsnList with the given nodes.
      Parameters:
      nodes - the nodes in question
      Returns:
      the resulting InsnList
    • between

      public static org.objectweb.asm.tree.InsnList between(org.objectweb.asm.tree.AbstractInsnNode startNode, org.objectweb.asm.tree.AbstractInsnNode endNode)
      Creates a sublist with all the nodes between the given extremes.
      Parameters:
      startNode - the starting node of the pattern, must be non-null
      endNode - the first node of the pattern, must be non-null
      Returns:
      the resulting InsnList
    • replaceNode

      public static void replaceNode(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.tree.AbstractInsnNode oldNode, org.objectweb.asm.tree.AbstractInsnNode newNode)
      Replaces a node with another one. Mostly used internally.
      Parameters:
      list - the list to perform the operation on
      oldNode - node to replace
      newNode - new node
    • replace

      public static boolean replace(org.objectweb.asm.tree.InsnList list, int opcode, org.objectweb.asm.tree.AbstractInsnNode newNode, int amount, boolean reverse)
      Replaces n occurrences of said opcode with the given node.
      Parameters:
      list - the list to perform the operation on
      opcode - the opcode to replace
      newNode - the replacement node
      reverse - whether the search should be done from the end
      amount - how many occurrences to replace, set to 0 to replace all
      Returns:
      true if anything was changed, false otherwise
    • cut

      public static void cut(org.objectweb.asm.tree.InsnList list, int amount, boolean reverse)
      Cut a number of nodes from the list.
      Parameters:
      list - the list to perform the operation on
      amount - how many nodes to cut
      reverse - true if it should cut from the end, false otherwise