Class SetLattice<S extends SetLattice<S,​E>,​E>

  • Type Parameters:
    S - the concrete instance of SetLattice
    E - 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
    • ...
    Widening on instances of this lattice depends on the cardinality of the domain of the underlying elements. The provided implementation behave as the domain is finite, thus invoking the lub. Set lattices defined on infinite domains must implement a coherent widening logic.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SetLattice​(java.util.Set<E> elements)
      Builds the lattice.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(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.
      boolean equals​(java.lang.Object obj)  
      S glb​(S other)
      Performs the greatest lower bound between this set lattice element and the given one.
      int hashCode()  
      boolean isEmpty()
      Returns true if this set contains no elements.
      java.util.Iterator<E> iterator()  
      protected boolean lessOrEqualAux​(S other)
      Yields true if 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 S lubAux​(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 S mk​(java.util.Set<E> set)
      Utility for creating a concrete instance of SetLattice given a set.
      int size()
      Returns the number of elements in this lattice (its cardinality).
      java.lang.String toString()  
      protected S wideningAux​(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 java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • 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 of SetLattice given 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 SetLattice containing the elements of the given set
      • lubAux

        protected S lubAux​(S other)
                    throws SemanticException
        Description copied from class: BaseLattice
        Performs 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:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        lubAux in class BaseLattice<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: BaseLattice
        Performs 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:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        wideningAux in class BaseLattice<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: BaseLattice
        Yields true if 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:
        • other is not null
        • other is neither top nor bottom
        • this is neither top nor bottom
        • this and other are not the same object (according both to == and to Object.equals(Object))
        Specified by:
        lessOrEqualAux in class BaseLattice<S extends SetLattice<S,​E>>
        Parameters:
        other - the other lattice element
        Returns:
        true if 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:
        true if the element is contained in this set, false otherwise.
      • 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.
      • iterator

        public java.util.Iterator<E> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<S extends SetLattice<S,​E>>
      • size

        public int size()
        Returns the number of elements in this lattice (its cardinality). If this lattice contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Returns:
        the number of elements in this lattice (its cardinality)
      • isEmpty

        public boolean isEmpty()
        Returns true if this set contains no elements.
        Returns:
        true if this set contains no elements