Package it.unive.lisa.analysis
Interface SemanticDomain<D extends SemanticDomain<D,E,I>,E extends SymbolicExpression,I extends Identifier>
-
- Type Parameters:
D
- the concreteSemanticDomain
instanceE
- the type ofSymbolicExpression
that this domain can processI
- the type of variableIdentifier
that this domain can handle
- All Known Subinterfaces:
AbstractState<A,H,V,T>
,HeapDomain<D>
,TypeDomain<T>
,ValueDomain<D>
- All Known Implementing Classes:
AnalysisState
,BaseHeapDomain
,DataflowDomain
,DefiniteForwardDataflowDomain
,Environment
,HeapEnvironment
,InferenceSystem
,PossibleForwardDataflowDomain
,SimpleAbstractState
,TypeEnvironment
,ValueEnvironment
public interface SemanticDomain<D extends SemanticDomain<D,E,I>,E extends SymbolicExpression,I extends Identifier>
A domain able to determine how abstract information evolves thanks to the semantics of statements and expressions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
SemanticDomain.Satisfiability
The satisfiability of an expression.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description D
assign(I id, E expression, ProgramPoint pp)
Yields a copy of this domain, whereid
has been assigned tovalue
.D
assume(E expression, ProgramPoint pp)
Yields a copy of this domain, modified by assuming that the given expression holds.D
forgetIdentifier(Identifier id)
Forgets anIdentifier
.default D
forgetIdentifiers(java.lang.Iterable<Identifier> ids)
Forgets all the givenIdentifier
s.D
forgetIdentifiersIf(java.util.function.Predicate<Identifier> test)
Forgets allIdentifier
s that match the given predicate.default <T> T
getDomainInstance(java.lang.Class<T> domain)
Yields the instance of a specific domain, of classdomain
, contained inside the domain.D
popScope(ScopeToken token)
Pops the scope identified by the given token from the domain.D
pushScope(ScopeToken token)
Pushes a new scope, identified by the give token, in the domain.DomainRepresentation
representation()
Yields aDomainRepresentation
of the information contained in this domain's instance.SemanticDomain.Satisfiability
satisfies(E expression, ProgramPoint pp)
Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSemanticDomain.Satisfiability
.D
smallStepSemantics(E expression, ProgramPoint pp)
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.
-
-
-
Method Detail
-
assign
D assign(I id, E expression, ProgramPoint pp) throws SemanticException
Yields a copy of this domain, whereid
has 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
-
smallStepSemantics
D smallStepSemantics(E expression, ProgramPoint pp) throws SemanticException
Yields a copy of this domain, that has been modified accordingly to the semantics of the givenexpression
.- 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
D assume(E expression, ProgramPoint pp) throws SemanticException
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
.- 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
D forgetIdentifier(Identifier id) throws SemanticException
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.- 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
D forgetIdentifiersIf(java.util.function.Predicate<Identifier> test) throws SemanticException
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.- 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
-
forgetIdentifiers
default D forgetIdentifiers(java.lang.Iterable<Identifier> ids) throws SemanticException
Forgets all the givenIdentifier
s. The default implementation of this method iterates onids
, invokingforgetIdentifier(Identifier)
on each element.- Parameters:
ids
- the collection of identifiers to forget- Returns:
- the semantic domain without information about the given ids
- Throws:
SemanticException
- if an error occurs during the computation
-
satisfies
SemanticDomain.Satisfiability satisfies(E expression, ProgramPoint pp) throws SemanticException
Checks 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.SATISFIED
is the expression is satisfied by the values of this domain,SemanticDomain.Satisfiability.NOT_SATISFIED
if it is not satisfied, orSemanticDomain.Satisfiability.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
-
pushScope
D pushScope(ScopeToken token) throws SemanticException
Pushes 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 withpopScope(ScopeToken)
.- Parameters:
token
- 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
D popScope(ScopeToken token) throws SemanticException
Pops 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.- Parameters:
token
- 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
-
representation
DomainRepresentation representation()
Yields aDomainRepresentation
of the information contained in this domain's instance.- Returns:
- the representation
-
getDomainInstance
default <T> T getDomainInstance(java.lang.Class<T> domain)
Yields the instance of a specific domain, of classdomain
, contained inside the domain. If this domain is an instance of the specified class, thenthis
is 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 returnsthis
ifdomain.isAssignableFrom(getClass()) == true
, otherwise it returnsnull
.- Type Parameters:
T
- the type of domain to retrieve- Parameters:
domain
- the class of the domain instance to retrieve- Returns:
- the instance of that domain, or
null
-
-