Package it.unive.lisa.analysis.dataflow
Class DataflowDomain<D extends DataflowDomain<D,E>,E extends DataflowElement<D,E>>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<D>
-
- it.unive.lisa.analysis.dataflow.DataflowDomain<D,E>
-
- Type Parameters:
D- the concrete type ofDataflowDomainE- the concrete type ofDataflowElementcontained in this domain
- All Implemented Interfaces:
Lattice<D>,SemanticDomain<D,ValueExpression,Identifier>,ValueDomain<D>
- Direct Known Subclasses:
DefiniteForwardDataflowDomain,PossibleForwardDataflowDomain
public abstract class DataflowDomain<D extends DataflowDomain<D,E>,E extends DataflowElement<D,E>> extends BaseLattice<D> implements ValueDomain<D>
A dataflow domain that collects instances ofDataflowElement. A dataflow domain is a value domain that is represented as a set of elements, that can be retrieved throughgetDataflowElements().
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.SemanticDomain
SemanticDomain.Satisfiability
-
-
Field Summary
Fields Modifier and Type Field Description EdomainThe underlying domain.-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description DataflowDomain(E domain, java.util.Set<E> elements, boolean isTop, boolean isBottom)Builds the domain.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Dassign(Identifier id, ValueExpression expression, ProgramPoint pp)Yields a copy of this domain, whereidhas been assigned tovalue.Dassume(ValueExpression expression, ProgramPoint pp)Yields a copy of this domain, modified by assuming that the given expression holds.Dbottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)DforgetIdentifier(Identifier id)Forgets anIdentifier.DforgetIdentifiersIf(java.util.function.Predicate<Identifier> test)Forgets allIdentifiers that match the given predicate.java.util.Set<E>getDataflowElements()Yields theDataflowElements contained in this domain instance.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.abstract Dmk(E domain, java.util.Set<E> elements, boolean isTop, boolean isBottom)Utility for creating a concrete instance ofDataflowDomaingiven its core fields.DpopScope(ScopeToken scope)Pops the scope identified by the given token from the domain.DpushScope(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(ValueExpression expression, ProgramPoint pp)Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSemanticDomain.Satisfiability.DsmallStepSemantics(ValueExpression expression, ProgramPoint pp)Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression.Dtop()Yields the top element of this lattice.java.lang.StringtoString()-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lessOrEqualAux, lub, lubAux, widening, wideningAux
-
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, getDomainInstance
-
Methods inherited from interface it.unive.lisa.analysis.value.ValueDomain
applySubstitution
-
-
-
-
Field Detail
-
domain
public final E extends DataflowElement<D,E> domain
The underlying domain.
-
-
Constructor Detail
-
DataflowDomain
public DataflowDomain(E domain, java.util.Set<E> elements, boolean isTop, boolean isBottom)
Builds the domain.- Parameters:
domain- a singleton instance to be used during semantic operations to perform kill and gen operationselements- the set of elements contained in this domainisTop- whether or not this domain is the top of the latticeisBottom- whether or not this domain is the bottom of the lattice
-
-
Method Detail
-
mk
public abstract D mk(E domain, java.util.Set<E> elements, boolean isTop, boolean isBottom)
Utility for creating a concrete instance ofDataflowDomaingiven its core fields.- Parameters:
domain- the underlying domainelements- the elements contained in the instance to be createdisTop- whether the created domain is the top element of the latticeisBottom- whether the created domain is the bottom element of the lattice- Returns:
- the concrete instance of domain
-
assign
public D assign(Identifier id, ValueExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, whereidhas been assigned tovalue.- Specified by:
assignin interfaceSemanticDomain<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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 D smallStepSemantics(ValueExpression 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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 D assume(ValueExpression 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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 D 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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 D 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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
-
satisfies
public SemanticDomain.Satisfiability satisfies(ValueExpression 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<D extends DataflowDomain<D,E>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<D extends DataflowDomain<D,E>>
-
representation
public DomainRepresentation representation()
Description copied from interface:SemanticDomainYields aDomainRepresentationof the information contained in this domain's instance.- Specified by:
representationin interfaceSemanticDomain<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- Returns:
- the representation
-
top
public D 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.
-
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.
-
bottom
public D 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.
-
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.
-
getDataflowElements
public final java.util.Set<E> getDataflowElements()
Yields theDataflowElements contained in this domain instance.- Returns:
- the elements
-
pushScope
public D 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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 D 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<D extends DataflowDomain<D,E>,ValueExpression,Identifier>- 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
-
toString
public final java.lang.String toString()
- Specified by:
toStringin classBaseLattice<D extends DataflowDomain<D,E>>
-
-