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,Node<Statement,Edge,CFG>,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, Type type)Builds the variable reference, identified by its name, happening at the given location in the program.VariableRef(CFG cfg, java.lang.String name)Builds the untyped variable reference, identified by its name.VariableRef(CFG cfg, java.lang.String name, Type type)Builds a typed variable reference, identified by its name and its type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <V> booleanaccept(GraphVisitor<CFG,Statement,Edge,V> visitor, V tool)Accepts the givenGraphVisitor.java.lang.StringgetName()Yields the name of this variable.VariablegetVariable()Yields aVariablerepresenting the referenced variable.inthashCode()booleanisEqualTo(Statement st)Checks if this node is effectively equal to the given one, that is, if they have the same structure while potentially being different instances.<A extends AbstractState<A,H,V>,H extends HeapDomain<H>,V extends ValueDomain<V>>
AnalysisState<A,H,V>semantics(AnalysisState<A,H,V> entryState, CallGraph callGraph, StatementStore<A,H,V> expressions)Computes the semantics of the statement, expressing how semantic information is transformed by the execution of this statement.intsetOffset(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.StringtoString()-
Methods inherited from class it.unive.lisa.program.cfg.statement.Expression
getDynamicType, getMetaVariables, getParentStatement, getRootStatement, getRuntimeTypes, getStaticType, setParentStatement, setRuntimeTypes
-
Methods inherited from class it.unive.lisa.program.cfg.statement.Statement
compareTo, equals, getCFG, getLocation, getOffset, stopsExecution, throwsError
-
-
-
-
Constructor Detail
-
VariableRef
public VariableRef(CFG cfg, java.lang.String name)
Builds the untyped variable reference, identified by its name. The location where this variable reference happens is unknown (i.e. no source file/line/column is available) and its type isUntyped.INSTANCE.- Parameters:
cfg- the cfg that this expression belongs toname- the name of this variable
-
VariableRef
public VariableRef(CFG cfg, java.lang.String name, Type type)
Builds a typed variable reference, identified by its name and its type. The location where this variable reference happens is unknown (i.e. no source file/line/column is available).- Parameters:
cfg- the cfg that this expression belongs toname- the name of this variabletype- the type of this variable
-
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 source file. If unknown, usenullname- the name of this variabletype- the type of this variable
-
-
Method Detail
-
setOffset
public int setOffset(int offset)
Description copied from interface:NodeSets 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:
hashCodein classExpression
-
isEqualTo
public boolean isEqualTo(Statement st)
Description copied from interface:NodeChecks if this node is effectively equal to the given one, that is, if they have the same structure while potentially being different instances.
-
getVariable
public Variable getVariable()
Yields aVariablerepresenting the referenced variable.- Returns:
- the expression representing the variable
-
semantics
public <A extends AbstractState<A,H,V>,H extends HeapDomain<H>,V extends ValueDomain<V>> AnalysisState<A,H,V> semantics(AnalysisState<A,H,V> entryState, CallGraph callGraph, StatementStore<A,H,V> expressions) throws SemanticException
Description copied from class:StatementComputes the 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.semantics(AnalysisState, CallGraph, StatementStore)of each nestedExpression, saving the result of each call inexpressions.- Specified by:
semanticsin classStatement- Type Parameters:
A- the type ofAbstractStateH- the type of theHeapDomainV- the type of theValueDomain- Parameters:
entryState- the entry state that represents the abstract values of each program variable and memory location when the execution reaches this statementcallGraph- the call graph of the program to analyzeexpressions- the cache where analysis states of intermediate expressions must be stored- Returns:
- the
AnalysisStaterepresenting 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:NodeAccepts 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 thatvisitorcan use- Parameters:
visitor- the visitor that is visiting theGraphcontaining this nodetool- the auxiliary tool thatvisitorcan use- Returns:
- whether or not the visiting should stop when this call returns, as decided by the visitor itself
-
-