Package org.jruby.ast
Class Node
java.lang.Object
org.jruby.ast.Node
- Direct Known Subclasses:
AliasNode
,AndNode
,ArgsCatNode
,ArgsNode
,ArgsPushNode
,ArgumentNode
,ArrayPatternNode
,AssignableNode
,AttrAssignNode
,BackRefNode
,BeginNode
,BlockArgNode
,BlockPassNode
,BreakNode
,CallNode
,CaseNode
,ClassNode
,ClassVarNode
,Colon3Node
,ConstNode
,DefinedNode
,DotNode
,DVarNode
,EncodingNode
,EnsureNode
,ErrorNode
,EvStrNode
,FalseNode
,FCallNode
,FindPatternNode
,FlipNode
,GlobalVarNode
,HashNode
,HashPatternNode
,IfNode
,InNode
,InstVarNode
,IterNode
,KeywordArgNode
,ListNode
,LiteralNode
,LocalVarNode
,Match2Node
,Match3Node
,MatchNode
,MethodDefNode
,ModuleNode
,NewlineNode
,NextNode
,NilNode
,NilRestArgNode
,NthRefNode
,NumericNode
,OpAsgnAndNode
,OpAsgnConstDeclNode
,OpAsgnNode
,OpAsgnOrNode
,OpElementAsgnNode
,OptArgNode
,OrNode
,PatternCaseNode
,RedoNode
,RegexpNode
,RequiredKeywordArgumentValueNode
,RescueBodyNode
,RescueNode
,RetryNode
,ReturnNode
,RootNode
,SClassNode
,SelfNode
,SplatNode
,StarNode
,StrNode
,SuperNode
,SValueNode
,SymbolNode
,TrueNode
,UndefNode
,UntilNode
,VAliasNode
,VCallNode
,WhenNode
,WhileNode
,XStrNode
,YieldNode
,ZSuperNode
Base class for all Nodes in the AST
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract <T> T
accept
(NodeVisitor<T> visitor) boolean
Does this node or one of its children contain an assignment?createList
(Node node) createList
(Node... nodes) createList
(Node node1, Node node2) createList
(Node node1, Node node2, Node node3) boolean
getFile()
int
getLine()
protected String
abstract NodeType
boolean
boolean
isNil()
Whether the node evaluates to nil and has no side effects.boolean
Check whether the given node is considered always "defined" or whether it has some form of definition check.void
setLine
(int line) void
toString()
toString
(boolean indent, int indentation) Not all interesting info in the AST is from Node data.protected String
Overridden by nodes that have additional internal state to be displated in toString.void
-
Field Details
-
containsVariableAssignment
protected boolean containsVariableAssignment -
newline
protected boolean newline
-
-
Constructor Details
-
Node
public Node(int line, boolean containsAssignment)
-
-
Method Details
-
setNewline
public void setNewline() -
unsetNewline
public void unsetNewline() -
isNewline
public boolean isNewline() -
getLine
public int getLine() -
getFile
-
setLine
public void setLine(int line) -
accept
-
childNodes
-
createList
-
createList
-
createList
-
createList
-
toString
-
toStringExtraInfo
Not all interesting info in the AST is from Node data. This method will print out anything else of note (e.g. FixnumNode's long value).- Returns:
- null for no extra info or something otherwise.
-
toString
-
toStringInternal
Overridden by nodes that have additional internal state to be displated in toString.For nodes that have it, name is handled separately, by implementing INameNode.
Child nodes are handled via iterating #childNodes.
- Returns:
- A string representing internal node state, or null if none.
-
getNodeName
-
getNodeType
- Returns:
- the nodeId
-
isNil
public boolean isNil()Whether the node evaluates to nil and has no side effects.- Returns:
- true if nil, false otherwise
-
needsDefinitionCheck
public boolean needsDefinitionCheck()Check whether the given node is considered always "defined" or whether it has some form of definition check.- Returns:
- Whether the type of node represents a possibly undefined construct
-
containsVariableAssignment
public boolean containsVariableAssignment()Does this node or one of its children contain an assignment? -
executesOnce
public boolean executesOnce()- 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.
-