Class VariableTableEntry

  • All Implemented Interfaces:
    CodeElement

    public class VariableTableEntry
    extends java.lang.Object
    implements CodeElement
    An entry in the variable table representing a CFG variable identified by its index, containing the information about the source file, line and column where the variable is defined.
    • Constructor Detail

      • VariableTableEntry

        public VariableTableEntry​(CodeLocation location,
                                  int index,
                                  java.lang.String name)
        Builds an untyped variable table entry, identified by its index. Its type is unknown (i.e. it is {#link Untyped#INSTANCE}).
        Parameters:
        location - the location of this variable
        index - the index of the variable entry
        name - the name of this variable
      • VariableTableEntry

        public VariableTableEntry​(CodeLocation location,
                                  int index,
                                  Statement scopeStart,
                                  Statement scopeEnd,
                                  java.lang.String name)
        Builds an untyped variable table entry, identified by its index. Its type is unknown (i.e. it is {#link Untyped#INSTANCE}).
        Parameters:
        location - the location of this variable
        index - the index of the variable entry
        scopeStart - the statement where this variable is first visible, null means that this variable is visible since the beginning of the cfg
        scopeEnd - the statement where this variable is last visible, null means that this variable is visible until the end of the cfg
        name - the name of this variable
      • VariableTableEntry

        public VariableTableEntry​(CodeLocation location,
                                  int index,
                                  Statement scopeStart,
                                  Statement scopeEnd,
                                  java.lang.String name,
                                  Type staticType)
        Builds the variable table entry, identified by its index, representing a variable defined at the given location in the program.
        Parameters:
        location - the location where the expression is defined within the program
        index - the index of the variable entry
        scopeStart - the statement where this variable is first visible, null means that this variable is visible since the beginning of the cfg
        scopeEnd - the statement where this variable is last visible, null means that this variable is visible until the end of the cfg
        name - the name of this variable
        staticType - the type of this variable. If unknown, use Untyped.INSTANCE
      • VariableTableEntry

        public VariableTableEntry​(CodeLocation location,
                                  int index,
                                  Statement scopeStart,
                                  Statement scopeEnd,
                                  java.lang.String name,
                                  Type staticType,
                                  Annotations annotations)
        Builds the variable table entry with its annotations, identified by its index, representing a variable defined at the given location in the program.
        Parameters:
        location - the location where the expression is defined within the program
        index - the index of the variable entry
        scopeStart - the statement where this variable is first visible, null means that this variable is visible since the beginning of the cfg
        scopeEnd - the statement where this variable is last visible, null means that this variable is visible until the end of the cfg
        name - the name of this variable
        staticType - the type of this variable. If unknown, use Untyped.INSTANCE
        annotations - the annotations of this variable
    • Method Detail

      • getIndex

        public int getIndex()
        Yields the index of this variable.
        Returns:
        the index of this variable
      • setIndex

        public void setIndex​(int index)
        Sets the index of this variable.
        Parameters:
        index - the new index of this variable
      • getScopeStart

        public Statement getScopeStart()
        Yields the statement where this variable is first visible. null means that this variable is visible since the beginning of the cfg.
        Returns:
        the scope start, or null
      • setScopeStart

        public void setScopeStart​(Statement scopeStart)
        Sets the statement where this variable is first visible. null means that this variable is visible since the beginning of the cfg. Changing the starting scope should be performed whenever the starting scope is removed from the cfg due to simplifications or code transformations.
        Parameters:
        scopeStart - the scope start, or null
      • getScopeEnd

        public Statement getScopeEnd()
        Yields the statement where this variable is last visible. null means that this variable is visible until the end of the cfg.
        Returns:
        the scope end, or null
      • setScopeEnd

        public void setScopeEnd​(Statement scopeEnd)
        Sets the statement where this variable is last visible. null means that this variable is visible until the end of the cfg. Changing the ending scope should be performed whenever the ending scope is removed from the cfg due to simplifications or code transformations.
        Parameters:
        scopeEnd - the scope end, or null
      • getName

        public java.lang.String getName()
        Yields the name of this variable.
        Returns:
        the name of this variable
      • getStaticType

        public Type getStaticType()
        Yields the static type of this variable.
        Returns:
        the static type of this variable
      • createReference

        public VariableRef createReference​(CFG cfg)
        Creates a VariableRef for the variable depicted by this entry, happening in the given CFG at the location of its descriptor.
        Parameters:
        cfg - the cfg that the returned variable reference will be linked to
        Returns:
        a reference to the variable depicted by this entry
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getLocation

        public CodeLocation getLocation()
        Description copied from interface: CodeElement
        Yields the location where this code element appears in the program.
        Specified by:
        getLocation in interface CodeElement
        Returns:
        the location where this code element appears in the program
      • getAnnotations

        public Annotations getAnnotations()
        Yields the annotations of this variable.
        Returns:
        the annotations of this variable
      • addAnnotation

        public void addAnnotation​(Annotation ann)
        Adds an annotation to the annotations of this variable table entry.
        Parameters:
        ann - the annotation to be added