Class VariableTable
java.lang.Object
com.offbynull.coroutines.instrumenter.asm.VariableTable
Tracks extra variables used for instrumentation as well as arguments passed in to a method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal class
Represents an entry within the local variable table of a method. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<VariableTable.Variable> private int
private List
<VariableTable.Variable> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
VariableTable
(boolean isStatic, org.objectweb.asm.Type objectType, org.objectweb.asm.Type methodType, int maxLocals) VariableTable
(org.objectweb.asm.tree.ClassNode classNode, org.objectweb.asm.tree.MethodNode methodNode) Constructs aVariableTable
object. -
Method Summary
Modifier and TypeMethodDescriptionacquireExtra
(Class<?> type) Equivalent to callingacquireExtra(Type.getType(type))
.acquireExtra
(org.objectweb.asm.Type type) Acquire a new variable for use when instrumenting some code within the method thisVariableTable
is for.int
Get number of arguments.getArgument
(int index) Get the variable for an argument passed in to the method.void
releaseExtra
(VariableTable.Variable variable) Release a variable that was acquired withacquireExtra(org.objectweb.asm.Type)
.
-
Field Details
-
argVars
-
extraOffset
private int extraOffset -
extraVars
-
-
Constructor Details
-
VariableTable
public VariableTable(org.objectweb.asm.tree.ClassNode classNode, org.objectweb.asm.tree.MethodNode methodNode) Constructs aVariableTable
object.- Parameters:
classNode
- class thatmethodeNode
resides inmethodNode
- method this variable table is for
-
VariableTable
private VariableTable(boolean isStatic, org.objectweb.asm.Type objectType, org.objectweb.asm.Type methodType, int maxLocals)
-
-
Method Details
-
getArgument
Get the variable for an argument passed in to the method. Remember that if the method is static, arguments start at 0th index in the local variables table. If it isn't static, they start at 1 (0th would be "this").Values returned by this method must never be passed in to
releaseExtra(com.offbynull.coroutines.instrumenter.asm.VariableTable.Variable)
.- Parameters:
index
- index of argument- Returns:
VariableTable.Variable
object that represents the argument- Throws:
IllegalArgumentException
- ifindex
is not the index of an argument
-
acquireExtra
Equivalent to callingacquireExtra(Type.getType(type))
.- Parameters:
type
- type which variable is for- Returns:
- new variable
- Throws:
NullPointerException
- if any argument isnull
-
acquireExtra
Acquire a new variable for use when instrumenting some code within the method thisVariableTable
is for.- Parameters:
type
- type which variable is for- Returns:
- new variable
- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- iftype
is of sort ofType.VOID
orType.METHOD
-
releaseExtra
Release a variable that was acquired withacquireExtra(org.objectweb.asm.Type)
.- Parameters:
variable
- variable to release- Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- ifvariable
wasn't acquired from this object, or ifvariable
refers to an argument, or ifvariable
has already been released
-
getArgCount
public int getArgCount()Get number of arguments.- Returns:
- number of arguments
-