Package org.jruby.ast

Class RootNode

java.lang.Object
org.jruby.ast.Node
org.jruby.ast.RootNode
All Implemented Interfaces:
ParseResult

public class RootNode extends Node implements ParseResult
Represents the top of the AST. This is a node not present in MRI. It was created to hold the top-most static scope in an easy to grab way and it also exists to hold BEGIN and END nodes. These can then be interpreted/compiled in the same places as the rest of the code.
  • Constructor Details

  • Method Details

    • getNodeType

      public NodeType getNodeType()
      Specified by:
      getNodeType in class Node
      Returns:
      the nodeId
    • getDynamicScope

      public DynamicScope getDynamicScope()
      Return the dynamic scope for this AST. The variable backed by this is transient so for serialization this is null. In that case we use staticScope to rebuild the dynamic scope. The real reason for this method is supporting bindings+eval. We need to pass our live dynamic scope in so when we eval we can use that dynamic scope.
      Specified by:
      getDynamicScope in interface ParseResult
      Returns:
      dynamic scope of this AST
    • getStaticScope

      public StaticScope getStaticScope()
      The static scoping relationships that should get set first thing before interpretation of the code represented by this AST. Actually, we use getScope first since that also can contain a live dynamic scope. We rely on this method only for interpreting a root node from a serialized format.
      Specified by:
      getStaticScope in interface ParseResult
      Returns:
      the top static scope for the AST
    • getFile

      public String getFile()
      Specified by:
      getFile in interface ParseResult
      Overrides:
      getFile in class Node
    • getCoverageMode

      public int getCoverageMode()
      Specified by:
      getCoverageMode in interface ParseResult
    • getBodyNode

      public Node getBodyNode()
      First real AST node to be interpreted
      Returns:
      real top AST node
    • accept

      public <T> T accept(NodeVisitor<T> iVisitor)
      Specified by:
      accept in class Node
    • childNodes

      public List<Node> childNodes()
      Specified by:
      childNodes in class Node
    • executesOnce

      public boolean executesOnce()
      Overrides:
      executesOnce in class Node
      Returns:
      is it possible this node will execute only once. Note: This is not comprehensive. It is used to look from root node down to class/module nodes to make sure that narrow case can execute once. It is possible much deeper down the tree some nodes can only execute once but it will be marked as false because that case is not what this is for.
    • getAST

      public Object getAST()
      Specified by:
      getAST in interface ParseResult
    • getEncoding

      public org.jcodings.Encoding getEncoding()
      Specified by:
      getEncoding in interface ParseResult