Package it.unive.lisa.analysis.lattices
Class SetLattice<S extends SetLattice<S,E>,E>
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<S>
-
- it.unive.lisa.analysis.lattices.SetLattice<S,E>
-
- Type Parameters:
S- the concrete instance ofSetLatticeE- the type of elements of the domain of this lattice
- All Implemented Interfaces:
Lattice<S>,java.lang.Iterable<E>
- Direct Known Subclasses:
AllocationSites,ExpressionSet
public abstract class SetLattice<S extends SetLattice<S,E>,E> extends BaseLattice<S> implements java.lang.Iterable<E>
A generic set lattice containing a set of elements. Lattice operations correspond to standard set operations:- the lub is the set union
- the ≤ is the set inclusion
- ...
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<E>elementsThe set of elements contained in the lattice.-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSetLattice(java.util.Set<E> elements)Builds the lattice.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontains(E elem)Checks whether an element is contained in this set.java.util.Set<E>elements()Yields the set of elements contained in this lattice element.booleanequals(java.lang.Object obj)Sglb(S other)Performs the greatest lower bound between this set lattice element and the given one.inthashCode()booleanisEmpty()Returnstrueif this set contains no elements.java.util.Iterator<E>iterator()protected booleanlessOrEqualAux(S 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 SlubAux(S other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.protected abstract Smk(java.util.Set<E> set)Utility for creating a concrete instance ofSetLatticegiven a set.intsize()Returns the number of elements in this lattice (its cardinality).java.lang.StringtoString()protected SwideningAux(S 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.BaseLattice
lessOrEqual, lub, widening
-
-
-
-
Field Detail
-
elements
protected java.util.Set<E> elements
The set of elements contained in the lattice.
-
-
Constructor Detail
-
SetLattice
protected SetLattice(java.util.Set<E> elements)
Builds the lattice.- Parameters:
elements- the elements that are contained in the lattice
-
-
Method Detail
-
mk
protected abstract S mk(java.util.Set<E> set)
Utility 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.- 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
-
lubAux
protected S lubAux(S 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<S extends SetLattice<S,E>>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
glb
public final S glb(S other) throws SemanticException
Performs the greatest lower bound between this set lattice element and the given one.- Parameters:
other- the other set lattice element- Returns:
- the greatest lower bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
protected S wideningAux(S 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<S extends SetLattice<S,E>>- 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(S 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<S extends SetLattice<S,E>>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
contains
public boolean contains(E elem)
Checks whether an element is contained in this set.- Parameters:
elem- the element- Returns:
trueif the element is contained in this set,falseotherwise.
-
elements
public java.util.Set<E> elements()
Yields the set of elements contained in this lattice element.- Returns:
- the set of elements contained in this lattice element.
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<S extends SetLattice<S,E>>
-
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<S extends SetLattice<S,E>>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<S extends SetLattice<S,E>>
-
toString
public final java.lang.String toString()
- Specified by:
toStringin classBaseLattice<S extends SetLattice<S,E>>
-
size
public int size()
Returns the number of elements in this lattice (its cardinality). If this lattice contains more thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of elements in this lattice (its cardinality)
-
isEmpty
public boolean isEmpty()
Returnstrueif this set contains no elements.- Returns:
trueif this set contains no elements
-
-