Class RegularBlockImpl

All Implemented Interfaces:
Block, RegularBlock, SingleSuccessorBlock, org.plumelib.util.UniqueId

public class RegularBlockImpl extends SingleSuccessorBlockImpl implements RegularBlock
Implementation of a regular basic block.
  • Field Details

    • contents

      protected final List<Node> contents
      Internal representation of the contents.
  • Constructor Details

    • RegularBlockImpl

      public RegularBlockImpl()
      Initialize an empty basic block to be filled with contents and linked to other basic blocks later.
  • Method Details

    • addNode

      public void addNode(Node t)
      Add a node to the contents of this basic block.
    • addNodes

      public void addNodes(List<? extends Node> ts)
      Add multiple nodes to the contents of this basic block.
    • getNodes

      public List<Node> getNodes()
      Returns the nodes contained within this basic block. The list may be empty.

      The following invariant holds.

       forall n in getNodes() :: n.getBlock() == this
       

      This implementation returns an non-empty list.

      Specified by:
      getNodes in interface Block
      Returns:
      the nodes contained within this basic block
    • getLastNode

      public @Nullable Node getLastNode()
      Description copied from interface: Block
      Returns the last node of this block, or null if none.
      Specified by:
      getLastNode in interface Block
      Returns:
      the last node of this block or null
    • getRegularSuccessor

      public @Nullable BlockImpl getRegularSuccessor()
      Description copied from interface: RegularBlock
      Returns the regular successor block.
      Specified by:
      getRegularSuccessor in interface RegularBlock
      Returns:
      the regular successor block
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: RegularBlock
      Is this block empty (i.e., does it not contain any contents).
      Specified by:
      isEmpty in interface RegularBlock