Class BinaryNode

All Implemented Interfaces:
Assignment<Expression>, Cloneable

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

    • BinaryNode

      public BinaryNode(long token, Expression lhs, Expression rhs)
      Constructor
      Parameters:
      token - token
      lhs - left hand side
      rhs - right hand side
  • Method Details

    • isComparison

      public boolean isComparison()
      Returns true if the node is a comparison operation (either equality, inequality, or relational).
      Returns:
      true if the node is a comparison operation.
    • isRelational

      public boolean isRelational()
      Returns true if the node is a relational operation (less than (or equals), greater than (or equals)).
      Returns:
      true if the node is a relational operation.
    • isLogical

      public boolean isLogical()
      Returns true if the node is a logical operation.
      Returns:
      true if the node is a logical operation.
    • isLogical

      public static boolean isLogical(TokenType tokenType)
      Returns true if the token type represents a logical operation.
      Parameters:
      tokenType - the token type
      Returns:
      true if the token type represents a logical operation.
    • isAssignment

      public boolean isAssignment()
      Check if this node is an assignment
      Overrides:
      isAssignment in class Node
      Returns:
      true if this node assigns a value
    • 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
    • isAlwaysFalse

      public boolean isAlwaysFalse()
      Description copied from class: Expression
      Returns true if the runtime value of this expression is always false when converted to boolean as per ECMAScript ToBoolean conversion. Used in control flow calculations.
      Overrides:
      isAlwaysFalse in class Expression
      Returns:
      true if this expression's runtime value converted to boolean is always false.
    • isAlwaysTrue

      public boolean isAlwaysTrue()
      Description copied from class: Expression
      Returns true if the runtime value of this expression is always true when converted to boolean as per ECMAScript ToBoolean conversion. Used in control flow calculations.
      Overrides:
      isAlwaysTrue in class Expression
      Returns:
      true if this expression's runtime value converted to boolean is always true.
    • 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?
    • getLhs

      public Expression getLhs()
      Get the left hand side expression for this node
      Returns:
      the left hand side expression
    • getRhs

      public Expression getRhs()
      Get the right hand side expression for this node
      Returns:
      the left hand side expression
    • setLHS

      public BinaryNode setLHS(Expression lhs)
      Set the left hand side expression for this node
      Parameters:
      lhs - new left hand side expression
      Returns:
      a node equivalent to this one except for the requested change.
    • setRHS

      public BinaryNode setRHS(Expression rhs)
      Set the right hand side expression for this node
      Parameters:
      rhs - new left hand side expression
      Returns:
      a node equivalent to this one except for the requested change.