Class LiteralNode.ArrayLiteralNode

All Implemented Interfaces:
LexicalContextNode, Cloneable
Enclosing class:
LiteralNode<T>

public static final class LiteralNode.ArrayLiteralNode extends LiteralNode<Expression[]> implements LexicalContextNode
Array literal node class.
  • Constructor Details

    • ArrayLiteralNode

      protected ArrayLiteralNode(long token, int finish, Expression[] value)
      Constructor
      Parameters:
      token - token
      finish - finish
      value - array literal value, a Node array
    • ArrayLiteralNode

      protected ArrayLiteralNode(long token, int finish, Expression[] value, boolean hasSpread, boolean hasTrailingComma)
      Constructor
      Parameters:
      token - token
      finish - finish
      value - array literal value, a Node array
      hasSpread - true if the array has a spread element
      hasTrailingComma - true if the array literal has a comma after the last element
  • Method Details

    • isArray

      public boolean isArray()
      Description copied from class: LiteralNode
      Test if the value is an array
      Overrides:
      isArray in class LiteralNode<Expression[]>
      Returns:
      True if value is an array
    • hasSpread

      public boolean hasSpread()
    • hasTrailingComma

      public boolean hasTrailingComma()
    • getElementExpressions

      public List<Expression> getElementExpressions()
      Returns a list of array element expressions. Note that empty array elements manifest themselves as null.
      Overrides:
      getElementExpressions in class LiteralNode<Expression[]>
      Returns:
      a list of array element expressions.
    • accept

      public Node accept(NodeVisitor<? extends LexicalContext> visitor)
      Description copied from class: LiteralNode
      Assist in IR navigation.
      Specified by:
      accept in interface LexicalContextNode
      Overrides:
      accept in class LiteralNode<Expression[]>
      Parameters:
      visitor - IR navigating visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required
    • accept

      public <R> R accept(TranslatorNodeVisitor<? extends LexicalContext, R> visitor)
      Description copied from class: Node
      Provides a means to navigate the IR.
      Specified by:
      accept in interface LexicalContextNode
      Overrides:
      accept in class LiteralNode<Expression[]>
      Parameters:
      visitor - Node visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required
    • accept

      public Node accept(LexicalContext lc, NodeVisitor<? extends LexicalContext> visitor)
      Description copied from interface: LexicalContextNode
      Accept function for the node given a lexical context. It must be prepared to replace itself if present in the lexical context
      Specified by:
      accept in interface LexicalContextNode
      Parameters:
      lc - lexical context
      visitor - node visitor
      Returns:
      new node or same node depending on state change
    • accept

      public <R> R accept(LexicalContext lc, TranslatorNodeVisitor<? extends LexicalContext, R> visitor)
      Specified by:
      accept in interface LexicalContextNode
    • toString

      public void toString(StringBuilder sb, boolean printType)
      Description copied from class: Node
      Print logic that decides whether to show the optimistic type or not - for example it should not be printed after just parse, when it hasn't been computed, or has been set to a trivially provable value
      Overrides:
      toString in class LiteralNode<Expression[]>
      Parameters:
      sb - string builder
      printType - print type?