Class VariableRef
- java.lang.Object
-
- it.unive.lisa.program.cfg.statement.Statement
-
- it.unive.lisa.program.cfg.statement.Expression
-
- it.unive.lisa.program.cfg.statement.VariableRef
-
- All Implemented Interfaces:
ProgramPoint
,CodeElement
,CodeNode<CFG,Statement,Edge>
,Node<CFG,Statement,Edge>
,java.lang.Comparable<Statement>
public class VariableRef extends Expression
A reference to a variable of the current CFG, identified by its name.
-
-
Constructor Summary
Constructors Constructor Description VariableRef(CFG cfg, CodeLocation location, java.lang.String name)
Builds the untyped variable reference, identified by its name.VariableRef(CFG cfg, CodeLocation location, java.lang.String name, Type type)
Builds the variable reference, identified by its name, happening at the given location in the program.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> boolean
accept(GraphVisitor<CFG,Statement,Edge,V> visitor, V tool)
Accepts the givenGraphVisitor
.boolean
equals(java.lang.Object obj)
<A extends AbstractState<A>>
AnalysisState<A>forwardSemantics(AnalysisState<A> entryState, InterproceduralAnalysis<A> interprocedural, StatementStore<A> expressions)
Computes the forward semantics of the statement, expressing how semantic information is transformed by the execution of this statement.Annotations
getAnnotations()
Yields the annotations of this variable, retrieved from the variable table of the cfg this variable belongs to.java.lang.String
getName()
Yields the name of this variable.Variable
getVariable()
Yields aVariable
representing the referenced variable.int
hashCode()
int
setOffset(int offset)
Sets the offset of this node to the given value, and then proceeds by setting the one of its nested nodes (if any) to subsequent values.java.lang.String
toString()
-
Methods inherited from class it.unive.lisa.program.cfg.statement.Expression
getMetaVariables, getParentStatement, getRootStatement, getStatementEvaluatedAfter, getStatementEvaluatedBefore, getStaticType, setParentStatement
-
Methods inherited from class it.unive.lisa.program.cfg.statement.Statement
backwardSemantics, compareTo, getCFG, getEvaluationPredecessor, getEvaluationSuccessor, getLocation, getOffset, stopsExecution, throwsError
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.program.cfg.ProgramPoint
getProgram
-
-
-
-
Constructor Detail
-
VariableRef
public VariableRef(CFG cfg, CodeLocation location, java.lang.String name)
Builds the untyped variable reference, identified by its name. The type of this variable reference isUntyped.INSTANCE
.- Parameters:
cfg
- the cfg that this expression belongs tolocation
- the location of this variable referencename
- the name of this variable reference
-
VariableRef
public VariableRef(CFG cfg, CodeLocation location, java.lang.String name, Type type)
Builds the variable reference, identified by its name, happening at the given location in the program.- Parameters:
cfg
- the cfg that this expression belongs tolocation
- the location where the expression is defined within the programname
- the name of this variabletype
- the type of this variable
-
-
Method Detail
-
setOffset
public int setOffset(int offset)
Description copied from interface:CodeNode
Sets the offset of this node to the given value, and then proceeds by setting the one of its nested nodes (if any) to subsequent values. The last offset used is returned.- Parameters:
offset
- the offset to set- Returns:
- the last offset used while setting the offsets of nested nodes
-
getName
public java.lang.String getName()
Yields the name of this variable.- Returns:
- the name of this variable
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classExpression
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classExpression
-
getVariable
public Variable getVariable()
Yields aVariable
representing the referenced variable.- Returns:
- the expression representing the variable
-
forwardSemantics
public <A extends AbstractState<A>> AnalysisState<A> forwardSemantics(AnalysisState<A> entryState, InterproceduralAnalysis<A> interprocedural, StatementStore<A> expressions) throws SemanticException
Description copied from class:Statement
Computes the forward semantics of the statement, expressing how semantic information is transformed by the execution of this statement. This method is also responsible for recursively invoking theStatement.forwardSemantics(AnalysisState, InterproceduralAnalysis, StatementStore)
of each nestedExpression
, saving the result of each call inexpressions
.- Specified by:
forwardSemantics
in classStatement
- Type Parameters:
A
- the type ofAbstractState
- Parameters:
entryState
- the entry state that represents the abstract values of each program variable and memory location when the execution reaches this statementinterprocedural
- the interprocedural analysis of the program to analyzeexpressions
- the cache where analysis states of intermediate expressions must be stored- Returns:
- the
AnalysisState
representing the abstract result of the execution of this statement - Throws:
SemanticException
- if something goes wrong during the computation
-
accept
public <V> boolean accept(GraphVisitor<CFG,Statement,Edge,V> visitor, V tool)
Description copied from interface:Node
Accepts the givenGraphVisitor
. Implementors of this method are responsible for invokingGraphVisitor.visit(Object, Graph, Node)
on this node afterNode.accept(GraphVisitor, Object)
has been invoked on all nested nodes, if any. The visiting should stop at the first of such calls that returnfalse
.- Type Parameters:
V
- the type of auxiliary tool thatvisitor
can use- Parameters:
visitor
- the visitor that is visiting theGraph
containing this nodetool
- the auxiliary tool thatvisitor
can use- Returns:
- whether or not the visiting should stop when this call returns, as decided by the visitor itself
-
getAnnotations
public Annotations getAnnotations()
Yields the annotations of this variable, retrieved from the variable table of the cfg this variable belongs to.- Returns:
- the annotations of this variable.
-
-