Class VariableTable
- java.lang.Object
-
- com.offbynull.coroutines.instrumenter.asm.VariableTable
-
public final class VariableTable extends java.lang.ObjectTracks extra variables used for instrumentation as well as arguments passed in to a method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classVariableTable.VariableRepresents an entry within the local variable table of a method.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<VariableTable.Variable>argVarsprivate intextraOffsetprivate java.util.List<VariableTable.Variable>extraVars
-
Constructor Summary
Constructors Modifier Constructor Description privateVariableTable(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 aVariableTableobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VariableTable.VariableacquireExtra(java.lang.Class<?> type)Equivalent to callingacquireExtra(Type.getType(type)).VariableTable.VariableacquireExtra(org.objectweb.asm.Type type)Acquire a new variable for use when instrumenting some code within the method thisVariableTableis for.intgetArgCount()Get number of arguments.VariableTable.VariablegetArgument(int index)Get the variable for an argument passed in to the method.voidreleaseExtra(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 aVariableTableobject.- Parameters:
classNode- class thatmethodeNoderesides 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.Variableobject that represents the argument- Throws:
java.lang.IllegalArgumentException- ifindexis 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 thisVariableTableis for.- Parameters:
type- type which variable is for- Returns:
- new variable
- Throws:
java.lang.NullPointerException- if any argument isnulljava.lang.IllegalArgumentException- iftypeis of sort ofType.VOIDorType.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 isnulljava.lang.IllegalArgumentException- ifvariablewasn't acquired from this object, or ifvariablerefers to an argument, or ifvariablehas already been released
-
getArgCount
public int getArgCount()
Get number of arguments.- Returns:
- number of arguments
-
-