Class UnaryNode

All Implemented Interfaces:
Assignment<Expression>, Cloneable

public final class UnaryNode extends Expression implements Assignment<Expression>
UnaryNode nodes represent single operand operations.
  • Constructor Details

    • UnaryNode

      public UnaryNode(long token, Expression rhs)
      Constructor
      Parameters:
      token - token
      rhs - expression
    • UnaryNode

      public UnaryNode(long token, int start, int finish, Expression expression)
      Constructor
      Parameters:
      token - token
      start - start
      finish - finish
      expression - expression
  • Method Details

    • isAssignment

      public boolean isAssignment()
      Is this an assignment - i.e. that mutates something such as a++
      Overrides:
      isAssignment in class Node
      Returns:
      true if assignment
    • isSelfModifying

      public boolean isSelfModifying()
      Description copied from class: Expression
      Is this a self modifying assignment?
      Overrides:
      isSelfModifying in class Expression
      Returns:
      true if self modifying, e.g. a++, or a*= 17
    • getAssignmentDest

      public Expression getAssignmentDest()
      Description copied from interface: Assignment
      Get assignment destination.
      Specified by:
      getAssignmentDest in interface Assignment<Expression>
      Returns:
      the assignment destination node
    • getAssignmentSource

      public Expression getAssignmentSource()
      Description copied from interface: Assignment
      Get the assignment source.
      Specified by:
      getAssignmentSource in interface Assignment<Expression>
      Returns:
      the assignment source node
    • accept

      public Node accept(NodeVisitor<? extends LexicalContext> visitor)
      Assist in IR navigation.
      Specified by:
      accept in class Node
      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 class Node
      Parameters:
      visitor - Node visitor.
      Returns:
      node the node or its replacement after visitation, null if no further visitations are required
    • 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
      Specified by:
      toString in class Node
      Parameters:
      sb - string builder
      printType - print type?
    • getExpression

      public Expression getExpression()
      Get the right hand side of this if it is inherited by a binary expression, or just the expression itself if still Unary
      Returns:
      right hand side or expression node
      See Also:
    • setExpression

      public UnaryNode setExpression(Expression expression)
      Reset the right hand side of this if it is inherited by a binary expression, or just the expression itself if still Unary
      Parameters:
      expression - right hand side or expression node
      Returns:
      a node equivalent to this one except for the requested change.
      See Also: