Class Jump

  • All Implemented Interfaces:
    java.lang.Comparable<AstNode>, java.lang.Iterable<Node>
    Direct Known Subclasses:
    BreakStatement, ContinueStatement, Label, Scope, SwitchStatement

    public class Jump
    extends AstNode
    Used for code generation. During codegen, the AST is transformed into an Intermediate Representation (IR) in which loops, ifs, switches and other control-flow statements are rewritten as labeled jumps. If the parser is set to IDE-mode, the resulting AST will not contain any instances of this class.
    • Field Detail

      • target

        public Node target
    • Constructor Detail

      • Jump

        public Jump()
      • Jump

        public Jump​(int nodeType)
      • Jump

        public Jump​(int type,
                    int lineno)
      • Jump

        public Jump​(int type,
                    Node child)
      • Jump

        public Jump​(int type,
                    Node child,
                    int lineno)
    • Method Detail

      • getJumpStatement

        public Jump getJumpStatement()
      • setJumpStatement

        public void setJumpStatement​(Jump jumpStatement)
      • getDefault

        public Node getDefault()
      • setDefault

        public void setDefault​(Node defaultTarget)
      • getFinally

        public Node getFinally()
      • setFinally

        public void setFinally​(Node finallyTarget)
      • getLoop

        public Jump getLoop()
      • setLoop

        public void setLoop​(Jump loop)
      • getContinue

        public Node getContinue()
      • setContinue

        public void setContinue​(Node continueTarget)
      • visit

        public void visit​(NodeVisitor visitor)
        Jumps are only used directly during code generation, and do not support this interface.
        Specified by:
        visit in class AstNode
        Parameters:
        visitor - the object to call with this node and its children
        Throws:
        java.lang.UnsupportedOperationException
      • toSource

        public java.lang.String toSource​(int depth)
        Description copied from class: AstNode
        Emits source code for this node. Callee is responsible for calling this function recursively on children, incrementing indent as appropriate.

        Note: if the parser was in error-recovery mode, some AST nodes may have null children that are expected to be non-null when no errors are present. In this situation, the behavior of the toSource method is undefined: toSource implementations may assume that the AST node is error-free, since it is intended to be invoked only at runtime after a successful parse.

        Specified by:
        toSource in class AstNode
        Parameters:
        depth - the current recursion depth, typically beginning at 0 when called on the root node.