Class LocalVariable

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, Node, Constants

    public final class LocalVariable
    extends java.lang.Object
    implements Constants, java.lang.Cloneable, Node, java.io.Serializable
    This class represents a local variable within a method. It contains its scope, name, signature and index on the method's frame.
    Version:
    $Id: LocalVariable.java 386056 2006-03-15 11:31:56Z tcurdt $
    Author:
    M. Dahm
    See Also:
    LocalVariableTable, Serialized Form
    • Constructor Detail

      • LocalVariable

        public LocalVariable​(LocalVariable c)
        Initialize from another object. Note that both objects use the same references (shallow copy). Use copy() for a physical copy.
      • LocalVariable

        public LocalVariable​(int start_pc,
                             int length,
                             int name_index,
                             int signature_index,
                             int index,
                             ConstantPool constant_pool)
        Parameters:
        start_pc - Range in which the variable
        length - ... is valid
        name_index - Index in constant pool of variable name
        signature_index - Index of variable's signature
        index - Variable is `index'th local variable on the method's frame
        constant_pool - Array of constants
    • Method Detail

      • accept

        public void accept​(Visitor v)
        Called by objects that are traversing the nodes of the tree implicitely defined by the contents of a Java class. I.e., the hierarchy of methods, fields, attributes, etc. spawns a tree of objects.
        Specified by:
        accept in interface Node
        Parameters:
        v - Visitor object
      • dump

        public final void dump​(java.io.DataOutputStream file)
                        throws java.io.IOException
        Dump local variable to file stream in binary format.
        Parameters:
        file - Output file stream
        Throws:
        java.io.IOException
      • getConstantPool

        public final ConstantPool getConstantPool()
        Returns:
        Constant pool used by this object.
      • getLength

        public final int getLength()
        Returns:
        Variable is valid within getStartPC() .. getStartPC()+getLength()
      • getName

        public final java.lang.String getName()
        Returns:
        Variable name.
      • getNameIndex

        public final int getNameIndex()
        Returns:
        Index in constant pool of variable name.
      • getSignature

        public final java.lang.String getSignature()
        Returns:
        Signature.
      • getSignatureIndex

        public final int getSignatureIndex()
        Returns:
        Index in constant pool of variable signature.
      • getIndex

        public final int getIndex()
        Returns:
        index of register where variable is stored
      • getStartPC

        public final int getStartPC()
        Returns:
        Start of range where he variable is valid
      • setConstantPool

        public final void setConstantPool​(ConstantPool constant_pool)
        Parameters:
        constant_pool - Constant pool to be used for this object.
      • setLength

        public final void setLength​(int length)
        Parameters:
        length - the length of this local variable
      • setNameIndex

        public final void setNameIndex​(int name_index)
        Parameters:
        name_index - the index into the constant pool for the name of this variable
      • setSignatureIndex

        public final void setSignatureIndex​(int signature_index)
        Parameters:
        signature_index - the index into the constant pool for the signature of this variable
      • setIndex

        public final void setIndex​(int index)
        Parameters:
        index - the index in the local variable table of this variable
      • setStartPC

        public final void setStartPC​(int start_pc)
        Parameters:
        start_pc - Specify range where the local variable is valid.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        string representation.
      • copy

        public LocalVariable copy()
        Returns:
        deep copy of this object