public class Target extends java.lang.Object implements java.lang.Comparable<Target>, java.lang.Iterable<org.spongepowered.asm.lib.tree.AbstractInsnNode>
| Modifier and Type | Field and Description |
|---|---|
org.spongepowered.asm.lib.Type[] |
arguments
Method arguments
|
org.spongepowered.asm.lib.tree.ClassNode |
classNode
Target class node
|
org.spongepowered.asm.lib.tree.InsnList |
insns
Method instructions
|
boolean |
isCtor
True if the method is a constructor
|
boolean |
isStatic
True if the method is static
|
org.spongepowered.asm.lib.tree.MethodNode |
method
Target method
|
org.spongepowered.asm.lib.Type |
returnType
Return type computed from the method descriptor
|
| Constructor and Description |
|---|
Target(org.spongepowered.asm.lib.tree.ClassNode classNode,
org.spongepowered.asm.lib.tree.MethodNode method)
Make a new Target for the supplied method
|
| Modifier and Type | Method and Description |
|---|---|
InjectionNodes.InjectionNode |
addInjectionNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
Add an injection node to this target if it does not already exist,
returns the existing node if it exists
|
void |
addLocalVariable(int index,
java.lang.String name,
java.lang.String desc)
Add an entry to the target LVT
|
void |
addToLocals(int locals)
Allocate a number of new local variables for this method
|
void |
addToStack(int stack)
Allocate a number of new stack variables for this method
|
int |
allocateLocal()
Allocate a new local variable for the method
|
int |
allocateLocals(int locals)
Allocate a number of new local variables for this method, returns the
first local variable index of the allocated range
|
int |
compareTo(Target o) |
org.spongepowered.asm.lib.tree.MethodInsnNode |
findInitNodeFor(org.spongepowered.asm.lib.tree.TypeInsnNode newNode)
Find the first <init> invocation after the specified
NEW insn
|
org.spongepowered.asm.lib.tree.MethodInsnNode |
findSuperInitNode()
Find the call to super() in a constructor.
|
int[] |
generateArgMap(org.spongepowered.asm.lib.Type[] args,
int start)
Generate an array containing local indexes for the specified args,
returns an array of identical size to the supplied array with an
allocated local index in each corresponding position
|
org.spongepowered.asm.lib.tree.AbstractInsnNode |
get(int index)
Return the instruction at the specified index
|
int[] |
getArgIndices()
Get the argument indices for this target, calculated on first use
|
java.lang.String |
getCallbackDescriptor(boolean captureLocals,
org.spongepowered.asm.lib.Type[] locals,
org.spongepowered.asm.lib.Type[] argumentTypes,
int startIndex,
int extra)
Get the callback descriptor
|
java.lang.String |
getCallbackDescriptor(org.spongepowered.asm.lib.Type[] locals,
org.spongepowered.asm.lib.Type[] argumentTypes)
Get the callback descriptor
|
java.lang.String |
getCallbackInfoClass()
Get the CallbackInfo class used for this target, based on the target
return type
|
int |
getCurrentMaxLocals()
Get the current max locals of the method
|
int |
getCurrentMaxStack()
Get the current max stack of the method
|
InjectionNodes.InjectionNode |
getInjectionNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
Get an injection node from this collection if it already exists, returns
null if the node is not tracked
|
int |
getMaxLocals()
Get the original max locals of the method
|
int |
getMaxStack()
Get the original max stack of the method
|
java.lang.String |
getSimpleCallbackDescriptor()
Get "simple" callback descriptor (descriptor with only CallbackInfo)
|
int |
indexOf(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
Return the index of the specified instruction in this instruction list
|
int |
indexOf(InjectionNodes.InjectionNode node)
Return the index of the specified instruction in this instruction list
|
void |
insertBefore(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.InsnList insns)
Insert the supplied instructions before the specified instruction
|
void |
insertBefore(InjectionNodes.InjectionNode location,
org.spongepowered.asm.lib.tree.InsnList insns)
Insert the supplied instructions before the specified instruction
|
java.util.Iterator<org.spongepowered.asm.lib.tree.AbstractInsnNode> |
iterator() |
void |
removeNode(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
Remove the specified instruction from the target and mark it as removed
for injections
|
void |
replaceNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
Replace an instruction in this target with the specified instruction and
mark the node as replaced for other injectors
|
void |
replaceNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.AbstractInsnNode champion,
org.spongepowered.asm.lib.tree.InsnList insns)
Replace an instruction in this target with the specified instructions and
mark the node as replaced with the specified champion node from the list.
|
void |
replaceNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.InsnList insns)
Replace an instruction in this target with the specified instructions and
mark the original node as removed
|
void |
setMaxLocals(int maxLocals)
Set the maxlocals for this target to the specified value, the specfied
value must be higher than the original max locals
|
void |
setMaxStack(int maxStack)
Set the max stack size for this target to the specified value, the
specfied value must be higher than the original max stack
|
java.lang.String |
toString() |
void |
wrapNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.AbstractInsnNode champion,
org.spongepowered.asm.lib.tree.InsnList before,
org.spongepowered.asm.lib.tree.InsnList after)
Wrap instruction in this target with the specified instructions and mark
the node as replaced with the specified champion node from the list.
|
public final org.spongepowered.asm.lib.tree.ClassNode classNode
public final org.spongepowered.asm.lib.tree.MethodNode method
public final org.spongepowered.asm.lib.tree.InsnList insns
public final boolean isStatic
public final boolean isCtor
public final org.spongepowered.asm.lib.Type[] arguments
public final org.spongepowered.asm.lib.Type returnType
public Target(org.spongepowered.asm.lib.tree.ClassNode classNode,
org.spongepowered.asm.lib.tree.MethodNode method)
method - target methodpublic InjectionNodes.InjectionNode addInjectionNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
node - Instruction node to addpublic InjectionNodes.InjectionNode getInjectionNode(org.spongepowered.asm.lib.tree.AbstractInsnNode node)
node - instruction nodepublic int getMaxLocals()
public int getMaxStack()
public int getCurrentMaxLocals()
public int getCurrentMaxStack()
public int allocateLocal()
public int allocateLocals(int locals)
locals - number of locals to allocatepublic void addToLocals(int locals)
locals - number of locals to allocatepublic void setMaxLocals(int maxLocals)
maxLocals - max locals value to setpublic void addToStack(int stack)
stack - number of stack entries to allocatepublic void setMaxStack(int maxStack)
maxStack - max stack value to setpublic int[] generateArgMap(org.spongepowered.asm.lib.Type[] args,
int start)
args - Argument typesstart - starting indexpublic int[] getArgIndices()
public java.lang.String getCallbackInfoClass()
public java.lang.String getSimpleCallbackDescriptor()
public java.lang.String getCallbackDescriptor(org.spongepowered.asm.lib.Type[] locals,
org.spongepowered.asm.lib.Type[] argumentTypes)
locals - Local variable typesargumentTypes - Argument typespublic java.lang.String getCallbackDescriptor(boolean captureLocals,
org.spongepowered.asm.lib.Type[] locals,
org.spongepowered.asm.lib.Type[] argumentTypes,
int startIndex,
int extra)
captureLocals - True if the callback is capturing localslocals - Local variable typesargumentTypes - Argument typesstartIndex - local index to start atextra - extra locals to includepublic java.lang.String toString()
toString in class java.lang.Objectpublic int compareTo(Target o)
compareTo in interface java.lang.Comparable<Target>public int indexOf(InjectionNodes.InjectionNode node)
node - instruction to locate, must exist in the targetpublic int indexOf(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
insn - instruction to locate, must exist in the targetpublic org.spongepowered.asm.lib.tree.AbstractInsnNode get(int index)
index - opcode indexpublic java.util.Iterator<org.spongepowered.asm.lib.tree.AbstractInsnNode> iterator()
iterator in interface java.lang.Iterable<org.spongepowered.asm.lib.tree.AbstractInsnNode>public org.spongepowered.asm.lib.tree.MethodInsnNode findInitNodeFor(org.spongepowered.asm.lib.tree.TypeInsnNode newNode)
newNode - NEW insnpublic org.spongepowered.asm.lib.tree.MethodInsnNode findSuperInitNode()
public void insertBefore(InjectionNodes.InjectionNode location, org.spongepowered.asm.lib.tree.InsnList insns)
location - Instruction to insert beforeinsns - Instructions to insertpublic void insertBefore(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.InsnList insns)
location - Instruction to insert beforeinsns - Instructions to insertpublic void replaceNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
location - Instruction to replaceinsn - Instruction to replace withpublic void replaceNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.AbstractInsnNode champion,
org.spongepowered.asm.lib.tree.InsnList insns)
location - Instruction to replacechampion - Instruction which notionally replaces the original insninsns - Instructions to actually insert (must contain champion)public void wrapNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.AbstractInsnNode champion,
org.spongepowered.asm.lib.tree.InsnList before,
org.spongepowered.asm.lib.tree.InsnList after)
location - Instruction to replacechampion - Instruction which notionally replaces the original insnbefore - Instructions to actually insert (must contain champion)after - Instructions to insert after the specified locationpublic void replaceNode(org.spongepowered.asm.lib.tree.AbstractInsnNode location,
org.spongepowered.asm.lib.tree.InsnList insns)
location - Instruction to replaceinsns - Instructions to replace withpublic void removeNode(org.spongepowered.asm.lib.tree.AbstractInsnNode insn)
insn - instruction to removepublic void addLocalVariable(int index,
java.lang.String name,
java.lang.String desc)
index - local variable indexname - local variable namedesc - local variable type