Package it.unive.lisa.analysis
Class SimpleAbstractState<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<SimpleAbstractState<H,V,T>>
-
- it.unive.lisa.analysis.SimpleAbstractState<H,V,T>
-
- Type Parameters:
H- the type ofHeapDomainembedded in this stateV- the type ofValueDomainembedded in this stateT- the type ofTypeDomainembedded in this state
- All Implemented Interfaces:
AbstractState<SimpleAbstractState<H,V,T>,H,V,T>,Lattice<SimpleAbstractState<H,V,T>>,SemanticDomain<SimpleAbstractState<H,V,T>,SymbolicExpression,Identifier>
public class SimpleAbstractState<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>> extends BaseLattice<SimpleAbstractState<H,V,T>> implements AbstractState<SimpleAbstractState<H,V,T>,H,V,T>
An abstract state of the analysis, composed by a heap state modeling the memory layout and a value state modeling values of program variables and memory locations.
-
-
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.AbstractState
HEAP_REPRESENTATION_KEY, TYPE_REPRESENTATION_KEY, VALUE_REPRESENTATION_KEY
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description SimpleAbstractState(H heapState, V valueState, T typeState)Builds a new abstract state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SimpleAbstractState<H,V,T>assign(Identifier id, SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, whereidhas been assigned tovalue.SimpleAbstractState<H,V,T>assume(SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, modified by assuming that the given expression holds.SimpleAbstractState<H,V,T>bottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)SimpleAbstractState<H,V,T>forgetIdentifier(Identifier id)Forgets anIdentifier.SimpleAbstractState<H,V,T>forgetIdentifiersIf(java.util.function.Predicate<Identifier> test)Forgets allIdentifiers that match the given predicate.<D> DgetDomainInstance(java.lang.Class<D> domain)Yields the instance of a specific domain, of classdomain, contained inside the domain.HgetHeapState()Yields the instance ofHeapDomainthat contains the information on heap structures contained in this abstract state.TgetTypeState()Yields the instance ofValueDomainandTypeDomainthat contains the information on runtime types of program variables and concretized memory locations.VgetValueState()Yields the instance ofValueDomainthat contains the information on values of program variables and concretized 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(SimpleAbstractState<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.SimpleAbstractState<H,V,T>lubAux(SimpleAbstractState<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.SimpleAbstractState<H,V,T>popScope(ScopeToken scope)Pops the scope identified by the given token from the domain.SimpleAbstractState<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.SimpleAbstractState<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.SimpleAbstractState<H,V,T>top()Yields the top element of this lattice.java.lang.StringtoString()SimpleAbstractState<H,V,T>wideningAux(SimpleAbstractState<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.Lattice
lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifiers
-
-
-
-
Constructor Detail
-
SimpleAbstractState
public SimpleAbstractState(H heapState, V valueState, T typeState)
Builds a new abstract state.- Parameters:
heapState- the domain containing information regarding heap structuresvalueState- the domain containing information regarding values of program variables and concretized memory locationstypeState- the domain containing information regarding runtime types of program variables and concretized memory locations
-
-
Method Detail
-
getHeapState
public H getHeapState()
Description copied from interface:AbstractStateYields the instance ofHeapDomainthat contains the information on heap structures contained in this abstract state.- Specified by:
getHeapStatein interfaceAbstractState<SimpleAbstractState<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- Returns:
- the heap domain
-
getValueState
public V getValueState()
Description copied from interface:AbstractStateYields the instance ofValueDomainthat contains the information on values of program variables and concretized memory locations.- Specified by:
getValueStatein interfaceAbstractState<SimpleAbstractState<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- Returns:
- the value domain
-
getTypeState
public T getTypeState()
Description copied from interface:AbstractStateYields the instance ofValueDomainandTypeDomainthat contains the information on runtime types of program variables and concretized memory locations.- Specified by:
getTypeStatein interfaceAbstractState<SimpleAbstractState<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- Returns:
- the type domain
-
assign
public SimpleAbstractState<H,V,T> assign(Identifier id, SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, whereidhas been assigned tovalue.- Specified by:
assignin interfaceSemanticDomain<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- Parameters:
id- the identifier to assign the value toexpression- 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
-
smallStepSemantics
public SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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 SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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 SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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 SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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 SimpleAbstractState<H,V,T> lubAux(SimpleAbstractState<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<SimpleAbstractState<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 SimpleAbstractState<H,V,T> wideningAux(SimpleAbstractState<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))
BaseLattice.lubAux(BaseLattice), and is thus safe for finite lattices and ACC ones.- Overrides:
wideningAuxin classBaseLattice<SimpleAbstractState<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(SimpleAbstractState<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<SimpleAbstractState<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 SimpleAbstractState<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.- Specified by:
topin interfaceLattice<H extends HeapDomain<H>>- Returns:
- the top element
-
bottom
public SimpleAbstractState<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.- Specified by:
bottomin interfaceLattice<H extends HeapDomain<H>>- Returns:
- the bottom element
-
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.- Specified by:
isTopin interfaceLattice<H extends HeapDomain<H>>- Returns:
trueif this is the top of the lattice
-
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.- Specified by:
isBottomin interfaceLattice<H extends HeapDomain<H>>- Returns:
trueif this is the bottom of the lattice
-
forgetIdentifier
public SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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
-
forgetIdentifiersIf
public SimpleAbstractState<H,V,T> forgetIdentifiersIf(java.util.function.Predicate<Identifier> test) throws SemanticException
Description copied from interface:SemanticDomainForgets allIdentifiers that match the given predicate. This means that all information regarding the those identifiers will be lost. This method should be invoked whenever an identifier gets out of scope.- Specified by:
forgetIdentifiersIfin interfaceSemanticDomain<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- Parameters:
test- the test to identify the targets of the removal- Returns:
- the semantic domain without information about the ids
- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<SimpleAbstractState<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- Returns:
- the representation
-
toString
public java.lang.String toString()
- Specified by:
toStringin classBaseLattice<SimpleAbstractState<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<H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>- 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
-
-