Module dev.civl.abc

Interface SequenceNode<T extends ASTNode>

All Superinterfaces:
ASTNode, Iterable<T>
All Known Subinterfaces:
ChooseStatementNode, CompoundInitializerNode, CompoundStatementNode, DeclarationListNode, DesignationNode

public interface SequenceNode<T extends ASTNode> extends ASTNode, Iterable<T>
A node in which all children have type T.
  • Method Details

    • addSequenceChild

      int addSequenceChild(T child)
      Appends the given node to the child list of this sequence node. In the pre-state, the given node must have no parent. In the post-state, the given node will have its parent set to this node.
      Parameters:
      child - a node of type T which does not currently have a parent
      Returns:
      the index of the child after it is added, which equals the number of children of this node in the prestate (i.e., before the method executes)
    • getSequenceChild

      T getSequenceChild(int i)
      Returns the child at position i, indexed from 0. This may be null.
      Parameters:
      i - an integer in the range [0,n), where n is the number of children of this sequence node
      Returns:
      the child at index i, which may be null
    • setSequenceChild

      T setSequenceChild(int i, T child)
      Sets the child at index i to the given node. The index i may be any nonnegative integer. If the index refers to a point beyond the current extent of the child list, null children are added until the list is long enough. Otherwise the old child at index i will be replaced by the new. If the old child was not null, it will become free, i.e., its parent field will be set to null.
      Parameters:
      i - a nonnegative integer
      child - a node of type T which does not currently have a parent
      Returns:
      the old node in position i (could be null)
    • copy

      SequenceNode<T> copy()
      Description copied from interface: ASTNode
      Returns a deep copy of this AST node. The node and all of its descendants will be cloned. The cloning does not copy analysis or attribute information.
      Specified by:
      copy in interface ASTNode
      Returns:
      deep copy of this node
    • removeChild

      T removeChild(int index)
      Description copied from interface: ASTNode

      Removes the child at given index from this node.

      The index must be in the range [0,n-1], where n is the value returned by ASTNode.numChildren() in the pre-state (i.e., before this method is invoked). If there is no child at the given index (i.e., child is null), this is a no-op.

      If the removed child is non-null, its parent is set to null.

      Specified by:
      removeChild in interface ASTNode
      Parameters:
      index - nonnegative integer in the range [0,n-1], where n is the number of children before executing this method
      Returns:
      the child that was removed (may be null)
    • insertChildren

      void insertChildren(int index, List<T> list)
      Inserts a sequence of nodes into the child sequence of this node. Any children after the given index will be shifted up in index.
      Parameters:
      index - an integer in [0,numChildren]
      list - a non-null list of free nodes of type T, any of which may be null
    • shiftRemoveChild

      T shiftRemoveChild(int index)
      Removes the child at the index from the list completely, shifting all children in front of it back by one. Returns the child that was pulled from the list.
      Parameters:
      index - an integer in [0,numChildren)
      Returns:
      The child that was removed from the list.