Class VariableTable


  • public final class VariableTable
    extends java.lang.Object
    Tracks extra variables used for instrumentation as well as arguments passed in to a method.
    • Constructor Detail

      • VariableTable

        public VariableTable​(org.objectweb.asm.tree.ClassNode classNode,
                             org.objectweb.asm.tree.MethodNode methodNode)
        Constructs a VariableTable object.
        Parameters:
        classNode - class that methodeNode resides in
        methodNode - 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 - if index is not the index of an argument
      • acquireExtra

        public VariableTable.Variable acquireExtra​(java.lang.Class<?> type)
        Equivalent to calling acquireExtra(Type.getType(type)).
        Parameters:
        type - type which variable is for
        Returns:
        new variable
        Throws:
        java.lang.NullPointerException - if any argument is null
      • acquireExtra

        public VariableTable.Variable acquireExtra​(org.objectweb.asm.Type type)
        Acquire a new variable for use when instrumenting some code within the method this VariableTable is for.
        Parameters:
        type - type which variable is for
        Returns:
        new variable
        Throws:
        java.lang.NullPointerException - if any argument is null
        java.lang.IllegalArgumentException - if type is of sort of Type.VOID or Type.METHOD
      • releaseExtra

        public void releaseExtra​(VariableTable.Variable variable)
        Release a variable that was acquired with acquireExtra(org.objectweb.asm.Type).
        Parameters:
        variable - variable to release
        Throws:
        java.lang.NullPointerException - if any argument is null
        java.lang.IllegalArgumentException - if variable wasn't acquired from this object, or if variable refers to an argument, or if variable has already been released
      • getArgCount

        public int getArgCount()
        Get number of arguments.
        Returns:
        number of arguments