Package it.unive.lisa.program.cfg
Class VariableTableEntry
- java.lang.Object
-
- it.unive.lisa.program.cfg.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 Summary
Constructors Constructor Description VariableTableEntry(CodeLocation location, int index, Statement scopeStart, Statement scopeEnd, java.lang.String name)Builds an untyped variable table entry, identified by its index.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.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.VariableTableEntry(CodeLocation location, int index, java.lang.String name)Builds an untyped variable table entry, identified by its index.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAnnotation(Annotation ann)Adds an annotation to the annotations of this variable table entry.VariableRefcreateReference(CFG cfg)Creates aVariableReffor the variable depicted by this entry, happening in the givenCFGat the location of its descriptor.booleanequals(java.lang.Object obj)AnnotationsgetAnnotations()Yields the annotations of this variable.intgetIndex()Yields the index of this variable.CodeLocationgetLocation()Yields the location where this code element appears in the program.java.lang.StringgetName()Yields the name of this variable.StatementgetScopeEnd()Yields the statement where this variable is last visible.StatementgetScopeStart()Yields the statement where this variable is first visible.TypegetStaticType()Yields the static type of this variable.inthashCode()voidsetIndex(int index)Sets the index of this variable.voidsetScopeEnd(Statement scopeEnd)Sets the statement where this variable is last visible.voidsetScopeStart(Statement scopeStart)Sets the statement where this variable is first visible.java.lang.StringtoString()
-
-
-
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 variableindex- the index of the variable entryname- 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 variableindex- the index of the variable entryscopeStart- the statement where this variable is first visible,nullmeans that this variable is visible since the beginning of the cfgscopeEnd- the statement where this variable is last visible,nullmeans that this variable is visible until the end of the cfgname- 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 programindex- the index of the variable entryscopeStart- the statement where this variable is first visible,nullmeans that this variable is visible since the beginning of the cfgscopeEnd- the statement where this variable is last visible,nullmeans that this variable is visible until the end of the cfgname- the name of this variablestaticType- the type of this variable. If unknown, useUntyped.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 programindex- the index of the variable entryscopeStart- the statement where this variable is first visible,nullmeans that this variable is visible since the beginning of the cfgscopeEnd- the statement where this variable is last visible,nullmeans that this variable is visible until the end of the cfgname- the name of this variablestaticType- the type of this variable. If unknown, useUntyped.INSTANCEannotations- 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.nullmeans 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.nullmeans 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, ornull
-
getScopeEnd
public Statement getScopeEnd()
Yields the statement where this variable is last visible.nullmeans 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.nullmeans 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, ornull
-
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 aVariableReffor the variable depicted by this entry, happening in the givenCFGat 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getLocation
public CodeLocation getLocation()
Description copied from interface:CodeElementYields the location where this code element appears in the program.- Specified by:
getLocationin interfaceCodeElement- 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
-
-