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 void
addAnnotation(Annotation ann)
Adds an annotation to the annotations of this variable table entry.VariableRef
createReference(CFG cfg)
Creates aVariableRef
for the variable depicted by this entry, happening in the givenCFG
at the location of its descriptor.boolean
equals(java.lang.Object obj)
Annotations
getAnnotations()
Yields the annotations of this variable.int
getIndex()
Yields the index of this variable.CodeLocation
getLocation()
Yields the location where this code element appears in the program.java.lang.String
getName()
Yields the name of this variable.Statement
getScopeEnd()
Yields the statement where this variable is last visible.Statement
getScopeStart()
Yields the statement where this variable is first visible.Type
getStaticType()
Yields the static type of this variable.int
hashCode()
void
setIndex(int index)
Sets the index of this variable.void
setScopeEnd(Statement scopeEnd)
Sets the statement where this variable is last visible.void
setScopeStart(Statement scopeStart)
Sets the statement where this variable is first visible.java.lang.String
toString()
-
-
-
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,null
means that this variable is visible since the beginning of the cfgscopeEnd
- the statement where this variable is last visible,null
means 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,null
means that this variable is visible since the beginning of the cfgscopeEnd
- the statement where this variable is last visible,null
means 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,null
means that this variable is visible since the beginning of the cfgscopeEnd
- the statement where this variable is last visible,null
means 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
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, ornull
-
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, 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 aVariableRef
for the variable depicted by this entry, happening in the givenCFG
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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.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 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
-
-