Class ControlFlowStructure

  • Direct Known Subclasses:
    IfThenElse, Loop

    public abstract class ControlFlowStructure
    extends java.lang.Object
    A control flow structure of a CFG.
    • Field Detail

      • cfgMatrix

        protected final NodeList<CFG,​Statement,​Edge> cfgMatrix
        The matrix of the cfg containing this structure.
    • Constructor Detail

      • ControlFlowStructure

        protected ControlFlowStructure​(NodeList<CFG,​Statement,​Edge> cfgMatrix,
                                       Statement condition,
                                       Statement firstFollower)
        Builds the structure.
        Parameters:
        cfgMatrix - the matrix of the cfg containing this structure
        condition - the condition of the structure
        firstFollower - the first statement after the structure exits
    • Method Detail

      • getCondition

        public final Statement getCondition()
        Yields the condition of this structure.
        Returns:
        the condition
      • getFirstFollower

        public final Statement getFirstFollower()
        Yields the first follower of this structure, that is, the first statement after the conditional structure exits.
        Returns:
        the follower
      • setFirstFollower

        public void setFirstFollower​(Statement firstFollower)
        Sets the first follower of this structure, that is, the first statement after the conditional structure exits.
        Parameters:
        firstFollower - the new follower
      • allStatements

        public final java.util.Collection<Statement> allStatements()
        Yields all the Statements contained in this structure, including the condition and the first follower.
        Returns:
        the statements of the body of this structure
      • bodyStatements

        protected abstract java.util.Collection<Statement> bodyStatements()
        Yields all the Statements contained in the body of this structure (thus excluding the condition and the first follower).
        Returns:
        the statements of the body of this structure
      • contains

        public abstract boolean contains​(Statement st)
        Yields true if the given statement is part of the body of this structure. Note that this method will return false if st is either the condition of the first follower of this structure.
        Parameters:
        st - the statement to check
        Returns:
        true if st is in the body of this structure
      • simplify

        public abstract void simplify()
        Simplifies this structure, removing all NoOps from its body.
      • distance

        public int distance​(Statement st)
        Yields the minimum distance, in terms of number of edges to traverse, between the condition of this structure and the given node. If st is not in this structure, this method returns -1. If the distance is greater than Integer.MAX_VALUE, Integer.MAX_VALUE is returned.
        Parameters:
        st - the node to reach starting at the condition
        Returns:
        the minimum distance, in terms of number of edges to traverse, between the condition and the given node
      • getCompleteStructure

        public NodeList<CFG,​Statement,​Edge> getCompleteStructure()
        Yields an NodeList containing the full structure (nodes and edges) represented by this conditional structure. The returned matrix will also contain the condition and the first follower, if any.
        Returns:
        the matrix containing the full structure
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public abstract java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getTargetedStatements

        public abstract java.util.Collection<Statement> getTargetedStatements()
        Yields all the statements that are targeted by some node in this structure. This always comprises destination nodes of conditional branches, and join points where more than one branch converge. Equivalently, these can be characterized as targets of conditional or unconditional branches and followers of conditional or unconditional branches.
        Returns:
        the targeted statements