org.jruby.ast
Class RootNode

java.lang.Object
  extended byorg.jruby.ast.Node
      extended byorg.jruby.ast.RootNode
All Implemented Interfaces:
InstructionContext, ISourcePositionHolder, java.io.Serializable

public class RootNode
extends Node

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.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jruby.ast.Node
instruction, nodeId
 
Constructor Summary
RootNode(ISourcePosition position, DynamicScope scope, Node bodyNode)
           
 
Method Summary
 Instruction accept(NodeVisitor iVisitor)
           
 java.util.List childNodes()
           
 Node getBodyNode()
          First real AST node to be interpreted
 DynamicScope getScope()
          Return the dynamic scope for this AST.
 StaticScope getStaticScope()
          The static scoping relationships that should get set first thing before interpretation of the code represented by this AST.
 
Methods inherited from class org.jruby.ast.Node
addComment, addComments, createList, createList, createList, createList, getComments, getNodeName, getPosition, getPositionIncludingComments, hasComments, setPosition, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RootNode

public RootNode(ISourcePosition position,
                DynamicScope scope,
                Node bodyNode)
Method Detail

getScope

public DynamicScope getScope()
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.

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.

Returns:
the top static scope for the AST

getBodyNode

public Node getBodyNode()
First real AST node to be interpreted

Returns:
real top AST node

accept

public Instruction accept(NodeVisitor iVisitor)
Specified by:
accept in class Node

childNodes

public java.util.List childNodes()
Specified by:
childNodes in class Node


Copyright © 2002-2007 JRuby Team. All Rights Reserved.