Package ftbsc.lll.utils
Class InsnListUtils
java.lang.Object
ftbsc.lll.utils.InsnListUtils
A collection of utilities for manipulating
InsnLists.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.objectweb.asm.tree.InsnListbetween(org.objectweb.asm.tree.AbstractInsnNode startNode, org.objectweb.asm.tree.AbstractInsnNode endNode) Creates a sublist with all the nodes between the given extremes.static voidcut(org.objectweb.asm.tree.InsnList list, int amount, boolean reverse) Cut a number of nodes from the list.static org.objectweb.asm.tree.InsnListof(org.objectweb.asm.tree.AbstractInsnNode... nodes) Factory method that builds anInsnListwith the given nodes.static booleanreplace(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 voidreplaceNode(org.objectweb.asm.tree.InsnList list, org.objectweb.asm.tree.AbstractInsnNode oldNode, org.objectweb.asm.tree.AbstractInsnNode newNode) Replaces a node with another one.
-
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 anInsnListwith 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-nullendNode- 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 onoldNode- node to replacenewNode- 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 onopcode- the opcode to replacenewNode- the replacement nodereverse- whether the search should be done from the endamount- 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 onamount- how many nodes to cutreverse- true if it should cut from the end, false otherwise
-