Package it.unive.lisa.analysis.impl.heap
Class TypeBasedHeap
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<H>
-
- it.unive.lisa.analysis.heap.BaseHeapDomain<TypeBasedHeap>
-
- it.unive.lisa.analysis.impl.heap.TypeBasedHeap
-
- All Implemented Interfaces:
HeapDomain<TypeBasedHeap>,HeapSemanticOperation,Lattice<TypeBasedHeap>,SemanticDomain<TypeBasedHeap,SymbolicExpression,Identifier>
public class TypeBasedHeap extends BaseHeapDomain<TypeBasedHeap>
A type-based heap implementation that abstracts heap locations depending on their types, i.e., all the heap locations with the same type are abstracted into a single unique identifier.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.heap.HeapSemanticOperation
HeapSemanticOperation.HeapReplacement
-
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 TypeBasedHeap()Builds a new instance of TypeBasedHeap, with an unique rewritten expressionSkip.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TypeBasedHeapassign(Identifier id, SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, whereidhas been assigned tovalue.TypeBasedHeapassume(SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, modified by assuming that the given expression holds.TypeBasedHeapbottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)TypeBasedHeapforgetIdentifier(Identifier id)Forgets anIdentifier.java.util.List<HeapSemanticOperation.HeapReplacement>getSubstitution()Yields the substitution, in the form of a list ofHeapSemanticOperation.HeapReplacements that must be processed in their order of appearance, that the creation of this heap domain caused.inthashCode()protected booleanlessOrEqualAux(TypeBasedHeap 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.protected TypeBasedHeaplubAux(TypeBasedHeap other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.protected TypeBasedHeapmk(TypeBasedHeap reference)Creates a new instance of this domain containing the same abstract information of reference.DomainRepresentationrepresentation()Yields aDomainRepresentationof the information contained in this domain's instance.ExpressionSet<ValueExpression>rewrite(SymbolicExpression expression, ProgramPoint pp)Rewrites aSymbolicExpression, getting rid of the parts that access heap structures, substituting them with syntheticHeapLocations representing the accessed locations.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.protected TypeBasedHeapsemanticsOf(HeapExpression expression, ProgramPoint pp)Yields a new instance of this domain, built by evaluating the semantics of the given heap expression.TypeBasedHeaptop()Yields the top element of this lattice.protected TypeBasedHeapwideningAux(TypeBasedHeap 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.heap.BaseHeapDomain
popScope, pushScope, smallStepSemantics, toString
-
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.heap.HeapDomain
rewriteAll
-
Methods inherited from interface it.unive.lisa.analysis.Lattice
isBottom, isTop, lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifiers
-
-
-
-
Constructor Detail
-
TypeBasedHeap
public TypeBasedHeap()
Builds a new instance of TypeBasedHeap, with an unique rewritten expressionSkip.
-
-
Method Detail
-
rewrite
public ExpressionSet<ValueExpression> rewrite(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:HeapDomainRewrites aSymbolicExpression, getting rid of the parts that access heap structures, substituting them with syntheticHeapLocations representing the accessed locations. The expression returned by this method should not containHeapExpressions.
If no rewriting is necessary, the input expression can be returned instead.- Parameters:
expression- the expression to rewritepp- the program point that where this expression is being rewritten- Returns:
- the rewritten expression, or the original one
- Throws:
SemanticException- if something goes wrong during the rewriting
-
assign
public TypeBasedHeap assign(Identifier id, SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, whereidhas been assigned tovalue.- 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
-
assume
public TypeBasedHeap 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.- 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
-
forgetIdentifier
public TypeBasedHeap 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.- 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
-
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.- 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
-
representation
public DomainRepresentation representation()
Description copied from interface:SemanticDomainYields aDomainRepresentationof the information contained in this domain's instance.- Returns:
- the representation
-
top
public TypeBasedHeap 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.- Returns:
- the top element
-
bottom
public TypeBasedHeap 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.- Returns:
- the bottom element
-
getSubstitution
public java.util.List<HeapSemanticOperation.HeapReplacement> getSubstitution()
Description copied from interface:HeapSemanticOperationYields the substitution, in the form of a list ofHeapSemanticOperation.HeapReplacements that must be processed in their order of appearance, that the creation of this heap domain caused. This substitution mapsIdentifiers in the pre-state toIdentifiers in the post state. If no substitution needs to be applied, this method should return an empty list.- Returns:
- the list of replacements
-
mk
protected TypeBasedHeap mk(TypeBasedHeap reference)
Description copied from class:BaseHeapDomainCreates a new instance of this domain containing the same abstract information of reference. The returned object is effectively a new instance, meaning that all substitutions should be cleared. If this domain does not apply substitutions, it is fine to returnthis.- Specified by:
mkin classBaseHeapDomain<TypeBasedHeap>- Parameters:
reference- the domain whose abstract information needs to be copied- Returns:
- a new instance of this domain
-
semanticsOf
protected TypeBasedHeap semanticsOf(HeapExpression expression, ProgramPoint pp) throws SemanticException
Description copied from class:BaseHeapDomainYields a new instance of this domain, built by evaluating the semantics of the given heap expression.- Specified by:
semanticsOfin classBaseHeapDomain<TypeBasedHeap>- Parameters:
expression- the expression to evaluatepp- the program point that where this expression is being evaluated- Returns:
- a new instance of this domain
- Throws:
SemanticException- if an error occurs during the computation
-
lubAux
protected TypeBasedHeap lubAux(TypeBasedHeap 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<TypeBasedHeap>- 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
protected TypeBasedHeap wideningAux(TypeBasedHeap 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<TypeBasedHeap>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqualAux
protected boolean lessOrEqualAux(TypeBasedHeap 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<TypeBasedHeap>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<TypeBasedHeap>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<TypeBasedHeap>
-
-