Class PointBasedHeap

    • Field Detail

      • heapEnv

        protected final HeapEnvironment<AllocationSites> heapEnv
        An heap environment tracking which allocation sites are associated to each identifier.
    • Constructor Detail

      • PointBasedHeap

        public PointBasedHeap()
        Builds a new instance of field-insensitive point-based heap.
      • PointBasedHeap

        protected PointBasedHeap​(HeapEnvironment<AllocationSites> heapEnv)
        Builds a new instance of field-insensitive point-based heap from its heap environment.
        Parameters:
        heapEnv - the heap environment that this instance tracks
    • Method Detail

      • from

        protected PointBasedHeap from​(PointBasedHeap original)
        Builds a point-based heap from a reference one.
        Parameters:
        original - reference point-based heap
        Returns:
        a point-based heap build from the original one
      • assign

        public PointBasedHeap assign​(Identifier id,
                                     SymbolicExpression expression,
                                     ProgramPoint pp)
                              throws SemanticException
        Description copied from interface: SemanticDomain
        Yields a copy of this domain, where id has been assigned to value.
        Parameters:
        id - the identifier to assign the value to
        expression - the expression to assign
        pp - 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
      • assume

        public PointBasedHeap assume​(SymbolicExpression expression,
                                     ProgramPoint pp)
                              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 return this.
        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

        public PointBasedHeap forgetIdentifier​(Identifier id)
                                        throws SemanticException
        Description copied from interface: SemanticDomain
        Forgets an Identifier. This means that all information regarding the given id 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
      • top

        public PointBasedHeap 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, since Lattice.isTop() uses reference equality by default. If the value returned by this method is not a singleton, override Lattice.isTop() accordingly to provide a coherent test.
        Returns:
        the top element
      • isTop

        public boolean isTop()
        Description copied from interface: Lattice
        Yields true if and only if this object represents the top of the lattice. The default implementation of this method uses reference equality between this and the value returned by Lattice.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:
        true if this is the top of the lattice
      • bottom

        public PointBasedHeap 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, since Lattice.isBottom() uses reference equality by default. If the value returned by this method is not a singleton, override Lattice.isBottom() accordingly to provide a coherent test.
        Returns:
        the bottom element
      • isBottom

        public boolean isBottom()
        Description copied from interface: Lattice
        Yields true if and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality between this and the value returned by Lattice.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:
        true if this is the bottom of the lattice
      • mk

        public PointBasedHeap mk​(PointBasedHeap reference)
        Description copied from class: BaseHeapDomain
        Creates a new instance of this domain containing the same abstract information of reference. The returned object is effectively a new instance, meaning that all substitutions should be cleared. If this domain does not apply substitutions, it is fine to return this.
        Specified by:
        mk in class BaseHeapDomain<PointBasedHeap>
        Parameters:
        reference - the domain whose abstract information needs to be copied
        Returns:
        a new instance of this domain
      • lubAux

        protected PointBasedHeap lubAux​(PointBasedHeap 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<PointBasedHeap>
        Parameters:
        other - the other lattice element
        Returns:
        the least upper bound between this and other
        Throws:
        SemanticException - if an error occurs during the computation
      • wideningAux

        protected PointBasedHeap wideningAux​(PointBasedHeap 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<PointBasedHeap>
        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​(PointBasedHeap 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<PointBasedHeap>
        Parameters:
        other - the other lattice element
        Returns:
        true if and only if that condition holds
        Throws:
        SemanticException - if an error occurs during the computation
      • rewrite

        public ExpressionSet<ValueExpression> rewrite​(SymbolicExpression expression,
                                                      ProgramPoint pp)
                                               throws SemanticException
        Description copied from interface: HeapDomain
        Rewrites a SymbolicExpression, getting rid of the parts that access heap structures, substituting them with synthetic HeapLocations representing the accessed locations. The expression returned by this method should not contain HeapExpressions.

        If no rewriting is necessary, the input expression can be returned instead.
        Parameters:
        expression - the expression to rewrite
        pp - the program point that where this expression is being rewritten
        Returns:
        the rewritten expression, or the original one
        Throws:
        SemanticException - if something goes wrong during the rewriting
      • popScope

        public PointBasedHeap popScope​(ScopeToken scope)
                                throws SemanticException
        Description copied from interface: SemanticDomain
        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.
        Specified by:
        popScope in interface SemanticDomain<PointBasedHeap,​SymbolicExpression,​Identifier>
        Overrides:
        popScope in class BaseHeapDomain<PointBasedHeap>
        Parameters:
        scope - 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