Package org.jruby.ast
Class RootNode
java.lang.Object
org.jruby.ast.Node
org.jruby.ast.RootNode
- All Implemented Interfaces:
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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Nodeprivate final intprivate final Stringprivate final DynamicScopeprivate final StaticScopeFields inherited from class org.jruby.ast.Node
containsVariableAssignment, EMPTY_LIST, newline -
Constructor Summary
ConstructorsConstructorDescriptionRootNode(int line, DynamicScope scope, Node bodyNode, String file) RootNode(int line, DynamicScope scope, Node bodyNode, String file, int coverageMode) -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(NodeVisitor<T> iVisitor) intbooleanFirst real AST node to be interpretedgetFile()getScope()Return the dynamic scope for this AST.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
containsVariableAssignment, createList, createList, createList, createList, findFirstChild, getLine, getNodeName, isNewline, isNil, needsDefinitionCheck, setLine, setNewline, toString, toString, toStringExtraInfo, toStringInternal, unsetNewlineMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jruby.ParseResult
getLine
-
Field Details
-
scope
-
staticScope
-
bodyNode
-
file
-
coverageMode
private final int coverageMode
-
-
Constructor Details
-
RootNode
-
RootNode
-
-
Method Details
-
getNodeType
- Specified by:
getNodeTypein classNode- Returns:
- the nodeId
-
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
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:
getStaticScopein interfaceParseResult- Returns:
- the top static scope for the AST
-
getFile
- Specified by:
getFilein interfaceParseResult- Overrides:
getFilein classNode
-
getBodyNode
First real AST node to be interpreted- Returns:
- real top AST node
-
accept
-
childNodes
- Specified by:
childNodesin classNode
-
coverageMode
public int coverageMode() -
executesOnce
public boolean executesOnce()- Overrides:
executesOncein classNode- 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.
-