Top Description Fields Constructors Methods
org.jruby.ast

public Class RootNode

extends Node
implements ParseResult
Class Inheritance
All Implemented Interfaces
org.jruby.ParseResult
Imports
java.util.List, org.jcodings.Encoding, org.jruby.ParseResult, org.jruby.ast.visitor.NodeVisitor, org.jruby.ext.coverage.CoverageData, org.jruby.parser.StaticScope, org.jruby.runtime.DynamicScope

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.

Field Summary

Modifier and TypeField and Description
private final Node
private final int
private final String
private final transient DynamicScope
private final StaticScope
Inherited from org.jruby.ast.Node:
containsVariableAssignmentEMPTY_LISTnewline

Constructor Summary

AccessConstructor and Description
public
RootNode(int line, DynamicScope scope, Node bodyNode, String file)

public
RootNode(int line, DynamicScope scope, Node bodyNode, String file, int coverageMode)

Method Summary

Modifier and TypeMethod and Description
public <T> T
accept(NodeVisitor<T> iVisitor)

Implements abstract org.jruby.ast.Node.accept.

public List<Node>
public boolean
public Object
public Node

Returns:

real top AST node
getBodyNode
()

First real AST node to be interpreted

public int
public DynamicScope

Returns:

dynamic scope of this AST
getDynamicScope
()

Implements org.jruby.ParseResult.getDynamicScope.

Return the dynamic scope for this AST.

public Encoding
public String
public NodeType
public StaticScope

Returns:

the top static scope for the AST
getStaticScope
()

Implements org.jruby.ParseResult.getStaticScope.

The static scoping relationships that should get set first thing before interpretation of the code represented by this AST.

Inherited from org.jruby.ast.Node:
containsVariableAssignmentcreateListcreateListcreateListcreateListgetLinegetNodeNameisNewlineisNilneedsDefinitionChecksetLinesetNewlinetoStringtoStringtoStringExtraInfotoStringInternalunsetNewline

Field Detail

bodyNodeback to summary
private final Node bodyNode
coverageModeback to summary
private final int coverageMode
fileback to summary
private final String file
scopeback to summary
private final transient DynamicScope scope
staticScopeback to summary
private final StaticScope staticScope

Constructor Detail

RootNodeback to summary
public RootNode(int line, DynamicScope scope, Node bodyNode, String file)
RootNodeback to summary
public RootNode(int line, DynamicScope scope, Node bodyNode, String file, int coverageMode)

Method Detail

acceptback to summary
public <T> T accept(NodeVisitor<T> iVisitor)

Implements abstract org.jruby.ast.Node.accept.

childNodesback to summary
public List<Node> childNodes()

Implements abstract org.jruby.ast.Node.childNodes.

executesOnceback to summary
public boolean executesOnce()

Overrides org.jruby.ast.Node.executesOnce.

Returns:boolean

Doc from org.jruby.ast.Node.executesOnce.

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.

Annotations
@Override
getASTback to summary
public Object getAST()

Implements org.jruby.ParseResult.getAST.

getBodyNodeback to summary
public Node getBodyNode()

First real AST node to be interpreted

Returns:Node

real top AST node

getCoverageModeback to summary
public int getCoverageMode()

Implements org.jruby.ParseResult.getCoverageMode.

Annotations
@Override
getDynamicScopeback to summary
public DynamicScope getDynamicScope()

Implements org.jruby.ParseResult.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.

Returns:DynamicScope

dynamic scope of this AST

getEncodingback to summary
public Encoding getEncoding()

Implements org.jruby.ParseResult.getEncoding.

getFileback to summary
public String getFile()

Overrides org.jruby.ast.Node.getFile.

Implements org.jruby.ParseResult.getFile.

getNodeTypeback to summary
public NodeType getNodeType()

Implements abstract org.jruby.ast.Node.getNodeType.

Returns:NodeType

Doc from org.jruby.ast.Node.getNodeType.

the nodeId

getStaticScopeback to summary
public StaticScope getStaticScope()

Implements org.jruby.ParseResult.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:StaticScope

the top static scope for the AST