Package it.unive.lisa.analysis.lattices
Class ExpressionSet<T extends SymbolicExpression>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<S>
-
- it.unive.lisa.analysis.lattices.SetLattice<ExpressionSet<T>,T>
-
- it.unive.lisa.analysis.lattices.ExpressionSet<T>
-
- Type Parameters:
T- the type of the tracked symbolic expressions
- All Implemented Interfaces:
Lattice<ExpressionSet<T>>,java.lang.Iterable<T>
public class ExpressionSet<T extends SymbolicExpression> extends SetLattice<ExpressionSet<T>,T>
A set lattice containing a set of symbolic expressions.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.lattices.SetLattice
elements
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description ExpressionSet()Builds the empty set lattice element.ExpressionSet(java.util.Set<T> set)Builds a set lattice element.ExpressionSet(T exp)Builds a singleton set lattice element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressionSet<T>bottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)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.protected ExpressionSet<T>lubAux(ExpressionSet<T> other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.protected ExpressionSet<T>mk(java.util.Set<T> set)Utility for creating a concrete instance ofSetLatticegiven a set.ExpressionSet<SymbolicExpression>popScope(ScopeToken token)Pops the scope identified by the given token from the set.ExpressionSet<SymbolicExpression>pushScope(ScopeToken token)Pushes a new scope, identified by the give token, in the set.ExpressionSet<T>top()Yields the top element of this lattice.-
Methods inherited from class it.unive.lisa.analysis.lattices.SetLattice
contains, elements, glb, isEmpty, iterator, lessOrEqualAux, size, toString, wideningAux
-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
-
-
-
Constructor Detail
-
ExpressionSet
public ExpressionSet()
Builds the empty set lattice element.
-
ExpressionSet
public ExpressionSet(T exp)
Builds a singleton set lattice element.- Parameters:
exp- the expression
-
ExpressionSet
public ExpressionSet(java.util.Set<T> set)
Builds a set lattice element.- Parameters:
set- the set of expression
-
-
Method Detail
-
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.- Returns:
trueif this is the top of the lattice
-
top
public ExpressionSet<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.- Returns:
- the top element
-
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.- Returns:
trueif this is the bottom of the lattice
-
bottom
public ExpressionSet<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.- Returns:
- the bottom element
-
mk
protected ExpressionSet<T> mk(java.util.Set<T> set)
Description copied from class:SetLatticeUtility for creating a concrete instance ofSetLatticegiven a set. This decouples the instance of set used during computation of the elements to put in the lattice from the actual type of set underlying the lattice.- Specified by:
mkin classSetLattice<ExpressionSet<T extends SymbolicExpression>,T extends SymbolicExpression>- Parameters:
set- the set containing the elements that must be included in the lattice instance- Returns:
- a new concrete instance of
SetLatticecontaining the elements of the given set
-
hashCode
public int hashCode()
- Overrides:
hashCodein classSetLattice<ExpressionSet<T extends SymbolicExpression>,T extends SymbolicExpression>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classSetLattice<ExpressionSet<T extends SymbolicExpression>,T extends SymbolicExpression>
-
lubAux
protected ExpressionSet<T> lubAux(ExpressionSet<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))
- Overrides:
lubAuxin classSetLattice<ExpressionSet<T extends SymbolicExpression>,T extends SymbolicExpression>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
pushScope
public ExpressionSet<SymbolicExpression> pushScope(ScopeToken token) throws SemanticException
Pushes a new scope, identified by the give token, in the set. This recursively invokesSymbolicExpression.pushScope(ScopeToken)on all elements of the set (return type is forced toExpressionSet<SymbolicExpression>since this operation returns the root of the hierarchy).- Parameters:
token- the token identifying the scope to push- Returns:
- a copy of this set where the expressions have the given scope pushed
- Throws:
SemanticException- if an error occurs during the computation
-
popScope
public ExpressionSet<SymbolicExpression> popScope(ScopeToken token) throws SemanticException
Pops the scope identified by the given token from the set. This recursively invokesSymbolicExpression.popScope(ScopeToken)on all elements of the set (return type is forced toExpressionSet<SymbolicExpression>since this operation returns the root of the hierarchy).- Parameters:
token- the token of the scope to be restored- Returns:
- a copy of this domain where the the expressions have the given scope popped
- Throws:
SemanticException- if an error occurs during the computation
-
-