Package it.unive.lisa.analysis
Class AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<AnalysisState<A,H,V,T>>
-
- it.unive.lisa.analysis.AnalysisState<A,H,V,T>
-
- Type Parameters:
A- the type ofAbstractStateembedded in this stateH- the type ofHeapDomainembedded in the abstract stateV- the type ofValueDomainembedded in the abstract stateT- the type ofTypeDomainembedded in the abstract state
- All Implemented Interfaces:
Lattice<AnalysisState<A,H,V,T>>,SemanticDomain<AnalysisState<A,H,V,T>,SymbolicExpression,Identifier>
public class AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>> extends BaseLattice<AnalysisState<A,H,V,T>> implements SemanticDomain<AnalysisState<A,H,V,T>,SymbolicExpression,Identifier>
The abstract analysis state at a given program point. An analysis state is composed by anAbstractStatemodeling the abstract values of program variables and heap locations, and a collection ofSymbolicExpressions keeping trace of what has been evaluated and is available for later computations, but is not stored in memory (i.e. the stack).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.SemanticDomain
SemanticDomain.Satisfiability
-
-
Field Summary
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description AnalysisState(A state, ExpressionSet<SymbolicExpression> computedExpressions)Builds a new state.AnalysisState(A state, ExpressionSet<SymbolicExpression> computedExpressions, SymbolAliasing aliasing)Builds a new state.AnalysisState(A state, SymbolicExpression computedExpression)Builds a new state.AnalysisState(A state, SymbolicExpression computedExpression, SymbolAliasing aliasing)Builds a new state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AnalysisState<A,H,V,T>alias(Symbol toAlias, Symbol alias)Registers an alias for the given symbol.AnalysisState<A,H,V,T>assign(SymbolicExpression id, SymbolicExpression expression, ProgramPoint pp)Yields a copy of this analysis state, where the symbolic expressionidhas been assigned tovalue: ifidis not anIdentifier, then it is rewritten before performing the assignment.AnalysisState<A,H,V,T>assign(Identifier id, SymbolicExpression value, ProgramPoint pp)Yields a copy of this domain, whereidhas been assigned tovalue.AnalysisState<A,H,V,T>assume(SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, modified by assuming that the given expression holds.AnalysisState<A,H,V,T>bottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)AnalysisState<A,H,V,T>forgetIdentifier(Identifier id)Forgets anIdentifier.SymbolAliasinggetAliasing()Yields the symbol aliasing information, that can be used to resolve targets of calls when the names used in the call are different from the ones in the target's signature.ExpressionSet<SymbolicExpression>getComputedExpressions()Yields the last computed expression.<D> DgetDomainInstance(java.lang.Class<D> domain)Yields the instance of a specific domain, of classdomain, contained inside the domain.AgetState()Yields theAbstractStateembedded into this analysis state, containing abstract values for program variables and memory locations.inthashCode()booleanisBottom()Yieldstrueif and only if this object represents the bottom of the lattice.booleanisTop()Yieldstrueif and only if this object represents the top of the lattice.booleanlessOrEqualAux(AnalysisState<A,H,V,T> other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.AnalysisState<A,H,V,T>lubAux(AnalysisState<A,H,V,T> other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.AnalysisState<A,H,V,T>popScope(ScopeToken scope)Pops the scope identified by the given token from the domain.AnalysisState<A,H,V,T>pushScope(ScopeToken scope)Pushes a new scope, identified by the give token, in the domain.DomainRepresentationrepresentation()Yields aDomainRepresentationof the information contained in this domain's instance.SemanticDomain.Satisfiabilitysatisfies(SymbolicExpression expression, ProgramPoint pp)Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSemanticDomain.Satisfiability.AnalysisState<A,H,V,T>smallStepSemantics(SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression.AnalysisState<A,H,V,T>top()Yields the top element of this lattice.java.lang.StringtoString()DomainRepresentationtypeRepresentation()Yields aDomainRepresentationof the information contained in this domain's instance.AnalysisState<A,H,V,T>wideningAux(AnalysisState<A,H,V,T> other)Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifiers
-
-
-
-
Constructor Detail
-
AnalysisState
public AnalysisState(A state, SymbolicExpression computedExpression)
Builds a new state.- Parameters:
state- theAbstractStateto embed in this analysis statecomputedExpression- the expression that has been computed
-
AnalysisState
public AnalysisState(A state, SymbolicExpression computedExpression, SymbolAliasing aliasing)
Builds a new state.- Parameters:
state- theAbstractStateto embed in this analysis statecomputedExpression- the expression that has been computedaliasing- the symbol aliasing information
-
AnalysisState
public AnalysisState(A state, ExpressionSet<SymbolicExpression> computedExpressions)
Builds a new state.- Parameters:
state- theAbstractStateto embed in this analysis statecomputedExpressions- the expressions that have been computed
-
AnalysisState
public AnalysisState(A state, ExpressionSet<SymbolicExpression> computedExpressions, SymbolAliasing aliasing)
Builds a new state.- Parameters:
state- theAbstractStateto embed in this analysis statecomputedExpressions- the expressions that have been computedaliasing- the symbol aliasing information
-
-
Method Detail
-
getState
public A getState()
Yields theAbstractStateembedded into this analysis state, containing abstract values for program variables and memory locations.- Returns:
- the abstract state
-
getAliasing
public SymbolAliasing getAliasing()
Yields the symbol aliasing information, that can be used to resolve targets of calls when the names used in the call are different from the ones in the target's signature.- Returns:
- the aliasing information
-
getComputedExpressions
public ExpressionSet<SymbolicExpression> getComputedExpressions()
Yields the last computed expression. This is an instance ofSymbolicExpressionthat will contain markers for all abstract values that would be present on the stack, as well as variable identifiers for values that should be read from the state. These are tied together in a form of expression that abstract domains are able to interpret. The collection returned by this method usually contains one expression, but instances created through lattice operations (e.g., lub) might contain more.- Returns:
- the last computed expression
-
alias
public AnalysisState<A,H,V,T> alias(Symbol toAlias, Symbol alias)
Registers an alias for the given symbol. Any previous aliases will be deleted.- Parameters:
toAlias- the symbol being aliasedalias- the alias fortoAlias- Returns:
- a copy of this analysis state, with the new alias
-
assign
public AnalysisState<A,H,V,T> assign(Identifier id, SymbolicExpression value, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, whereidhas been assigned tovalue.- Specified by:
assignin interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
id- the identifier to assign the value tovalue- the expression to assignpp- the program point that where this operation is being evaluated- Returns:
- a copy of this domain, modified by the assignment
- Throws:
SemanticException- if an error occurs during the computation
-
assign
public AnalysisState<A,H,V,T> assign(SymbolicExpression id, SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Yields a copy of this analysis state, where the symbolic expressionidhas been assigned tovalue: ifidis not anIdentifier, then it is rewritten before performing the assignment.- Parameters:
id- the symbolic expression to be assignedexpression- the expression to assignpp- the program point that where this operation is being evaluated- Returns:
- a copy of this analysis state, modified by the assignment
- Throws:
SemanticException- if an error occurs during the computation
-
smallStepSemantics
public AnalysisState<A,H,V,T> smallStepSemantics(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression.- Specified by:
smallStepSemanticsin interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
expression- the expression whose semantics need to be computedpp- the program point that where this operation is being evaluated- Returns:
- a copy of this domain, modified accordingly to the semantics of
expression - Throws:
SemanticException- if an error occurs during the computation
-
assume
public AnalysisState<A,H,V,T> assume(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, modified by assuming that the given expression holds. It is required that the returned domain is in relation with this one. A safe (but imprecise) implementation of this method can always returnthis.- Specified by:
assumein interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
expression- the expression to assume to hold.pp- the program point that where this operation is being evaluated- Returns:
- the (optionally) modified copy of this domain
- Throws:
SemanticException- if an error occurs during the computation
-
satisfies
public SemanticDomain.Satisfiability satisfies(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainChecks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSemanticDomain.Satisfiability.- Specified by:
satisfiesin interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
expression- the expression whose satisfiability is to be evaluatedpp- the program point that where this operation is being evaluated- Returns:
SemanticDomain.Satisfiability.SATISFIEDis the expression is satisfied by the values of this domain,SemanticDomain.Satisfiability.NOT_SATISFIEDif it is not satisfied, orSemanticDomain.Satisfiability.UNKNOWNif it is either impossible to determine if it satisfied, or if it is satisfied by some values and not by some others (this is equivalent to a TOP boolean value)- Throws:
SemanticException- if an error occurs during the computation
-
pushScope
public AnalysisState<A,H,V,T> pushScope(ScopeToken scope) throws SemanticException
Description copied from interface:SemanticDomainPushes a new scope, identified by the give token, in the domain. This causes information about all variables not associated with a scope (and thus visible) to be mapped to the given scope and hidden away, until the scope is popped withSemanticDomain.popScope(ScopeToken).- Specified by:
pushScopein interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
scope- the token identifying the scope to push- Returns:
- a copy of this domain where the local variables have been hidden
- Throws:
SemanticException- if an error occurs during the computation
-
popScope
public AnalysisState<A,H,V,T> popScope(ScopeToken scope) throws SemanticException
Description copied from interface:SemanticDomainPops the scope identified by the given token from the domain. This causes all the visible variables (i.e. that are not mapped to a scope) to be removed from the domain, while the local variables that were associated to the given scope token (and thus hidden) will become visible again.- Specified by:
popScopein interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
scope- the token of the scope to be restored- Returns:
- a copy of this domain where the local variables have been removed, while the variables mapped to the given scope are visible again
- Throws:
SemanticException- if an error occurs during the computation
-
lubAux
public AnalysisState<A,H,V,T> lubAux(AnalysisState<A,H,V,T> other) throws SemanticException
Description copied from class:BaseLatticePerforms the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lubAuxin classBaseLattice<AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
public AnalysisState<A,H,V,T> wideningAux(AnalysisState<A,H,V,T> other) throws SemanticException
Description copied from class:BaseLatticePerforms the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
wideningAuxin classBaseLattice<AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqualAux
public boolean lessOrEqualAux(AnalysisState<A,H,V,T> other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lessOrEqualAuxin classBaseLattice<AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
top
public AnalysisState<A,H,V,T> top()
Description copied from interface:LatticeYields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()accordingly to provide a coherent test.
-
bottom
public AnalysisState<A,H,V,T> bottom()
Description copied from interface:LatticeYields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()accordingly to provide a coherent test.
-
isTop
public boolean isTop()
Description copied from interface:LatticeYieldstrueif and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.top(), thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
-
isBottom
public boolean isBottom()
Description copied from interface:LatticeYieldstrueif and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.bottom(), thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.
-
forgetIdentifier
public AnalysisState<A,H,V,T> forgetIdentifier(Identifier id) throws SemanticException
Description copied from interface:SemanticDomainForgets anIdentifier. This means that all information regarding the givenidwill be lost. This method should be invoked whenever an identifier gets out of scope.- Specified by:
forgetIdentifierin interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Parameters:
id- the identifier to forget- Returns:
- the semantic domain without information about the given id
- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>
-
representation
public DomainRepresentation representation()
Description copied from interface:SemanticDomainYields aDomainRepresentationof the information contained in this domain's instance.- Specified by:
representationin interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Returns:
- the representation
-
typeRepresentation
public DomainRepresentation typeRepresentation()
Yields aDomainRepresentationof the information contained in this domain's instance. This differs fromrepresentation()by using invokingAbstractState.typeRepresentation()instead ofSemanticDomain.representation()on the abstract state contained inside this analysis state.- Returns:
- the representation
-
toString
public java.lang.String toString()
- Specified by:
toStringin classBaseLattice<AnalysisState<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>
-
getDomainInstance
public <D> D getDomainInstance(java.lang.Class<D> domain)
Description copied from interface:SemanticDomainYields the instance of a specific domain, of classdomain, contained inside the domain. If this domain is an instance of the specified class, thenthisis returned. Otherwise, inner domains are recursively checked (enabling retrieval of semantic domains through Cartesian products or other types of combinations), returning the first that is instance ofdomain.
The default implementation of this method returnsthisifdomain.isAssignableFrom(getClass()) == true, otherwise it returnsnull.- Specified by:
getDomainInstancein interfaceSemanticDomain<A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>>- Type Parameters:
D- the type of domain to retrieve- Parameters:
domain- the class of the domain instance to retrieve- Returns:
- the instance of that domain, or
null
-
-