public class Target extends java.lang.Object implements java.lang.Comparable<Target>, java.lang.Iterable<org.objectweb.asm.tree.AbstractInsnNode>
| Modifier and Type | Class and Description |
|---|---|
class |
Target.Extension
A stateful extension of stack or locals space for a target method which
can be applied.
|
| Modifier and Type | Field and Description |
|---|---|
org.objectweb.asm.Type[] |
arguments
Method arguments
|
org.objectweb.asm.tree.ClassNode |
classNode
Target class node
|
org.objectweb.asm.tree.InsnList |
insns
Method instructions
|
boolean |
isCtor
True if the method is a constructor
|
boolean |
isStatic
True if the method is static
|
org.objectweb.asm.tree.MethodNode |
method
Target method
|
org.objectweb.asm.Type |
returnType
Return type computed from the method descriptor
|
| Constructor and Description |
|---|
Target(org.objectweb.asm.tree.ClassNode classNode,
org.objectweb.asm.tree.MethodNode method)
Make a new Target for the supplied method
|
| Modifier and Type | Method and Description |
|---|---|
InjectionNodes.InjectionNode |
addInjectionNode(org.objectweb.asm.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
|
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) |
Target.Extension |
extendLocals()
Creates a new locals extension.
|
Target.Extension |
extendStack()
Creates a new stack extension.
|
Bytecode.DelegateInitialiser |
findDelegateInitNode()
Find the call to super() or this() in a constructor.
|
org.objectweb.asm.tree.MethodInsnNode |
findInitNodeFor(org.objectweb.asm.tree.TypeInsnNode newNode)
Find the first <init> invocation after the specified
NEW insn
|
int[] |
generateArgMap(org.objectweb.asm.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.objectweb.asm.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.objectweb.asm.Type[] locals,
org.objectweb.asm.Type[] argumentTypes,
int startIndex,
int extra)
Get the callback descriptor
|
java.lang.String |
getCallbackDescriptor(org.objectweb.asm.Type[] locals,
org.objectweb.asm.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.objectweb.asm.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.objectweb.asm.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.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.InsnList insns)
Insert the supplied instructions before the specified instruction
|
void |
insertBefore(InjectionNodes.InjectionNode location,
org.objectweb.asm.tree.InsnList insns)
Insert the supplied instructions before the specified instruction
|
java.util.Iterator<org.objectweb.asm.tree.AbstractInsnNode> |
iterator() |
void |
removeNode(org.objectweb.asm.tree.AbstractInsnNode insn)
Remove the specified instruction from the target and mark it as removed
for injections
|
void |
replaceNode(org.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.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.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.AbstractInsnNode champion,
org.objectweb.asm.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.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.InsnList insns)
Replace an instruction in this target with the specified instructions and
mark the original node as removed
|
java.lang.String |
toString() |
void |
wrapNode(org.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.AbstractInsnNode champion,
org.objectweb.asm.tree.InsnList before,
org.objectweb.asm.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.objectweb.asm.tree.ClassNode classNode
public final org.objectweb.asm.tree.MethodNode method
public final org.objectweb.asm.tree.InsnList insns
public final boolean isStatic
public final boolean isCtor
public final org.objectweb.asm.Type[] arguments
public final org.objectweb.asm.Type returnType
public Target(org.objectweb.asm.tree.ClassNode classNode,
org.objectweb.asm.tree.MethodNode method)
method - target methodpublic InjectionNodes.InjectionNode addInjectionNode(org.objectweb.asm.tree.AbstractInsnNode node)
node - Instruction node to addpublic InjectionNodes.InjectionNode getInjectionNode(org.objectweb.asm.tree.AbstractInsnNode node)
node - instruction nodepublic int getMaxLocals()
public int getMaxStack()
public int getCurrentMaxLocals()
public int getCurrentMaxStack()
public int allocateLocal()
Note that allocating a local differs from extending
locals (see extendLocals()) in that the allocation immediately
increases the target max locals and returns the new index of the local
just allocated. Extending locals is used for temporary localised
extensions to the locals table for the purposes of injectors.
public int allocateLocals(int locals)
Note that allocating locals differs from extending
locals (see extendLocals()) in that the allocation immediately
increases the target max locals and returns the new index of the local
just allocated. Extending locals is used for temporary localised
extensions to the locals table for the purposes of injectors.
locals - number of locals to allocatepublic Target.Extension extendLocals()
public Target.Extension extendStack()
public int[] generateArgMap(org.objectweb.asm.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.objectweb.asm.Type[] locals,
org.objectweb.asm.Type[] argumentTypes)
locals - Local variable typesargumentTypes - Argument typespublic java.lang.String getCallbackDescriptor(boolean captureLocals,
org.objectweb.asm.Type[] locals,
org.objectweb.asm.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.objectweb.asm.tree.AbstractInsnNode insn)
insn - instruction to locate, must exist in the targetpublic org.objectweb.asm.tree.AbstractInsnNode get(int index)
index - opcode indexpublic java.util.Iterator<org.objectweb.asm.tree.AbstractInsnNode> iterator()
iterator in interface java.lang.Iterable<org.objectweb.asm.tree.AbstractInsnNode>public org.objectweb.asm.tree.MethodInsnNode findInitNodeFor(org.objectweb.asm.tree.TypeInsnNode newNode)
newNode - NEW insnpublic Bytecode.DelegateInitialiser findDelegateInitNode()
public void insertBefore(InjectionNodes.InjectionNode location, org.objectweb.asm.tree.InsnList insns)
location - Instruction to insert beforeinsns - Instructions to insertpublic void insertBefore(org.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.InsnList insns)
location - Instruction to insert beforeinsns - Instructions to insertpublic void replaceNode(org.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.AbstractInsnNode insn)
location - Instruction to replaceinsn - Instruction to replace withpublic void replaceNode(org.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.AbstractInsnNode champion,
org.objectweb.asm.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.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.AbstractInsnNode champion,
org.objectweb.asm.tree.InsnList before,
org.objectweb.asm.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.objectweb.asm.tree.AbstractInsnNode location,
org.objectweb.asm.tree.InsnList insns)
location - Instruction to replaceinsns - Instructions to replace withpublic void removeNode(org.objectweb.asm.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