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.dataflow.DataflowDomain<D,E>
-
- Type Parameters:
D
- the concrete type ofDataflowDomain
E
- the concrete type ofDataflowElement
contained in this domain
- All Implemented Interfaces:
BaseLattice<D>
,Lattice<D>
,ScopedObject<D>
,SemanticDomain<D,ValueExpression,Identifier>
,ValueDomain<D>
,ValueOracle
,StructuredObject
- Direct Known Subclasses:
DefiniteDataflowDomain
,PossibleDataflowDomain
public abstract class DataflowDomain<D extends DataflowDomain<D,E>,E extends DataflowElement<D,E>> extends java.lang.Object implements BaseLattice<D>, 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()
.
-
-
Field Summary
Fields Modifier and Type Field Description E
domain
The 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 D
assign(Identifier id, ValueExpression expression, ProgramPoint pp, SemanticOracle oracle)
Yields a copy of this domain, whereid
has been assigned tovalue
.D
assume(ValueExpression expression, ProgramPoint src, ProgramPoint dest, SemanticOracle oracle)
Yields a copy of this domain, modified by assuming that the given expression holds.D
bottom()
Yields the bottom element of this lattice.boolean
equals(java.lang.Object obj)
D
forgetIdentifier(Identifier id)
Forgets anIdentifier
.D
forgetIdentifiersIf(java.util.function.Predicate<Identifier> test)
Forgets allIdentifier
s that match the given predicate.java.util.Set<E>
getDataflowElements()
Yields theDataflowElement
s contained in this domain instance.int
hashCode()
boolean
isBottom()
Yieldstrue
if and only if this object represents the bottom of the lattice.boolean
isTop()
Yieldstrue
if and only if this object represents the top of the lattice.boolean
knowsIdentifier(Identifier id)
Yieldstrue
if this instance is currently tracking abstract information for the given identifier.abstract D
mk(E domain, java.util.Set<E> elements, boolean isTop, boolean isBottom)
Utility for creating a concrete instance ofDataflowDomain
given its core fields.D
popScope(ScopeToken scope)
Pops the scope identified by the given token from this object.D
pushScope(ScopeToken scope)
Pushes a new scope, identified by the give token, in this object.StructuredRepresentation
representation()
Yields aStructuredRepresentation
of the information contained in this object's instance.Satisfiability
satisfies(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle)
Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSatisfiability
.D
smallStepSemantics(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle)
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.D
top()
Yields the top element of this lattice.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.BaseLattice
glb, glbAux, lessOrEqual, lessOrEqualAux, lub, lubAux, narrowing, narrowingAux, widening, wideningAux
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifiers, getAllDomainInstances, getDomainInstance
-
Methods inherited from interface it.unive.lisa.analysis.value.ValueDomain
applyReplacement
-
-
-
-
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 ofDataflowDomain
given 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, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, whereid
has been assigned tovalue
.- Specified by:
assign
in 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 evaluatedoracle
- the oracle for inter-domain communication- 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, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.- Specified by:
smallStepSemantics
in 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 evaluatedoracle
- the oracle for inter-domain communication- 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 src, ProgramPoint dest, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Yields 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:
assume
in interfaceSemanticDomain<D extends DataflowDomain<D,E>,ValueExpression,Identifier>
- Parameters:
expression
- the expression to assume to hold.src
- the program point that where this operation is being evaluated, corresponding to the one that generated the given expressiondest
- the program point where the execution will move after the expression has been assumedoracle
- the oracle for inter-domain communication- 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:SemanticDomain
Forgets anIdentifier
. This means that all information regarding the givenid
will be lost. This method should be invoked whenever an identifier gets out of scope.- Specified by:
forgetIdentifier
in 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:SemanticDomain
Forgets allIdentifier
s 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:
forgetIdentifiersIf
in 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 Satisfiability satisfies(ValueExpression expression, ProgramPoint pp, SemanticOracle oracle) throws SemanticException
Description copied from interface:SemanticDomain
Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSatisfiability
.- Specified by:
satisfies
in 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 evaluatedoracle
- the oracle for inter-domain communication- Returns:
Satisfiability.SATISFIED
is the expression is satisfied by the values of this domain,Satisfiability.NOT_SATISFIED
if it is not satisfied, orSatisfiability.UNKNOWN
if 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:
hashCode
in interfaceBaseLattice<D extends DataflowDomain<D,E>>
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfaceBaseLattice<D extends DataflowDomain<D,E>>
- Overrides:
equals
in classjava.lang.Object
-
representation
public StructuredRepresentation representation()
Description copied from interface:StructuredObject
Yields aStructuredRepresentation
of the information contained in this object's instance.- Specified by:
representation
in interfaceStructuredObject
- Returns:
- the representation
-
top
public D top()
Description copied from interface:Lattice
Yields 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:Lattice
Yieldstrue
if and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthis
and 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:Lattice
Yields 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:Lattice
Yieldstrue
if and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthis
and 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 theDataflowElement
s contained in this domain instance.- Returns:
- the elements
-
pushScope
public D pushScope(ScopeToken scope) throws SemanticException
Description copied from interface:ScopedObject
Pushes a new scope, identified by the give token, in this object. This causes 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 withScopedObject.popScope(ScopeToken)
.- Specified by:
pushScope
in interfaceScopedObject<D extends DataflowDomain<D,E>>
- Parameters:
scope
- the token identifying the scope to push- Returns:
- a copy of this object where the local unscoped 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:ScopedObject
Pops the scope identified by the given token from this object. This causes all the visible variables (i.e. that are not mapped to a scope) to be removed, while the local variables that were associated to the given scope token (and thus hidden) will become visible again.- Specified by:
popScope
in interfaceScopedObject<D extends DataflowDomain<D,E>>
- Parameters:
scope
- the token of the scope to be restored- Returns:
- a copy of this object 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:
toString
in interfaceBaseLattice<D extends DataflowDomain<D,E>>
- Overrides:
toString
in classjava.lang.Object
-
knowsIdentifier
public boolean knowsIdentifier(Identifier id)
Description copied from interface:SemanticDomain
Yieldstrue
if this instance is currently tracking abstract information for the given identifier.- Specified by:
knowsIdentifier
in interfaceSemanticDomain<D extends DataflowDomain<D,E>,ValueExpression,Identifier>
- Parameters:
id
- the identifier- Returns:
- whether or not this domain knows about
id
-
-