Class: Ikra::AST::RootNode
- Defined in:
- lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb
Overview
Need to wrap block bodies in RootNode, so that the first node can be replaced if necessary (LastStatementReturnsVisitor)
Constant Summary
Constants inherited from TreeNode
Instance Attribute Summary collapse
-
#single_child ⇒ Object
readonly
Returns the value of attribute single_child.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #clone ⇒ Object
-
#initialize(single_child:) ⇒ RootNode
constructor
A new instance of RootNode.
- #to_s ⇒ Object
Methods inherited from TreeNode
#==, #enclosing_class, #find_behavior_node, #get_type, #is_begin_node?, #merge_union_type, #register_type_change, #replace, #replace_child, #symbol_table
Methods inherited from Node
Constructor Details
#initialize(single_child:) ⇒ RootNode
Returns a new instance of RootNode.
266 267 268 269 |
# File 'lib/ast/nodes.rb', line 266 def initialize(single_child:) @single_child = single_child single_child.parent = self end |
Instance Attribute Details
#single_child ⇒ Object (readonly)
Returns the value of attribute single_child.
264 265 266 |
# File 'lib/ast/nodes.rb', line 264 def single_child @single_child end |
Instance Method Details
#accept(visitor) ⇒ Object
44 45 46 |
# File 'lib/ast/visitor.rb', line 44 def accept(visitor) visitor.visit_root_node(self) end |
#clone ⇒ Object
271 272 273 |
# File 'lib/ast/nodes.rb', line 271 def clone return RootNode.new(single_child: @single_child.clone) end |
#to_s ⇒ Object
40 41 42 |
# File 'lib/ast/printer.rb', line 40 def to_s return "[RootNode: #{single_child.to_s}]" end |