Class VariableTable
- java.lang.Object
-
- com.offbynull.coroutines.instrumenter.asm.VariableTable
-
public final class VariableTable extends java.lang.Object
Tracks extra variables used for instrumentation as well as arguments passed in to a method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
VariableTable.Variable
Represents an entry within the local variable table of a method.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<VariableTable.Variable>
argVars
private int
extraOffset
private java.util.List<VariableTable.Variable>
extraVars
-
Constructor Summary
Constructors Modifier Constructor Description private
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VariableTable.Variable
acquireExtra(java.lang.Class<?> type)
Equivalent to callingacquireExtra(Type.getType(type))
.VariableTable.Variable
acquireExtra(org.objectweb.asm.Type type)
Acquire a new variable for use when instrumenting some code within the method thisVariableTable
is for.int
getArgCount()
Get number of arguments.VariableTable.Variable
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 Detail
-
argVars
private java.util.List<VariableTable.Variable> argVars
-
extraOffset
private int extraOffset
-
extraVars
private java.util.List<VariableTable.Variable> extraVars
-
-
Constructor Detail
-
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 Detail
-
getArgument
public VariableTable.Variable getArgument(int index)
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:
java.lang.IllegalArgumentException
- ifindex
is not the index of an argument
-
acquireExtra
public VariableTable.Variable acquireExtra(java.lang.Class<?> type)
Equivalent to callingacquireExtra(Type.getType(type))
.- Parameters:
type
- type which variable is for- Returns:
- new variable
- Throws:
java.lang.NullPointerException
- if any argument isnull
-
acquireExtra
public VariableTable.Variable acquireExtra(org.objectweb.asm.Type type)
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:
java.lang.NullPointerException
- if any argument isnull
java.lang.IllegalArgumentException
- iftype
is of sort ofType.VOID
orType.METHOD
-
releaseExtra
public void releaseExtra(VariableTable.Variable variable)
Release a variable that was acquired withacquireExtra(org.objectweb.asm.Type)
.- Parameters:
variable
- variable to release- Throws:
java.lang.NullPointerException
- if any argument isnull
java.lang.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
-
-