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
Fields inherited from class org.jruby.ast.Node
containsVariableAssignment, 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> T
accept
(NodeVisitor<T> iVisitor) boolean
getAST()
First real AST node to be interpretedint
Return the dynamic scope for this AST.org.jcodings.Encoding
getFile()
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, getLine, getNodeName, isNewline, isNil, needsDefinitionCheck, setLine, setNewline, toString, toString, toStringExtraInfo, toStringInternal, unsetNewline
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jruby.ParseResult
getLine
-
Constructor Details
-
RootNode
-
RootNode
-
-
Method Details
-
getNodeType
- Specified by:
getNodeType
in classNode
- Returns:
- the nodeId
-
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 interfaceParseResult
- 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:
getStaticScope
in interfaceParseResult
- Returns:
- the top static scope for the AST
-
getFile
- Specified by:
getFile
in interfaceParseResult
- Overrides:
getFile
in classNode
-
getCoverageMode
public int getCoverageMode()- Specified by:
getCoverageMode
in interfaceParseResult
-
getBodyNode
First real AST node to be interpreted- Returns:
- real top AST node
-
accept
-
childNodes
- Specified by:
childNodes
in classNode
-
executesOnce
public boolean executesOnce()- Overrides:
executesOnce
in 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.
-
getAST
- Specified by:
getAST
in interfaceParseResult
-
getEncoding
public org.jcodings.Encoding getEncoding()- Specified by:
getEncoding
in interfaceParseResult
-