Class: Ikra::AST::ForNode
- Defined in:
- lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb
Constant Summary
Constants inherited from TreeNode
Instance Attribute Summary collapse
-
#body_stmts ⇒ Object
readonly
Returns the value of attribute body_stmts.
-
#iterator_identifier ⇒ Object
readonly
Returns the value of attribute iterator_identifier.
-
#range_from ⇒ Object
readonly
Returns the value of attribute range_from.
-
#range_to ⇒ Object
readonly
Returns the value of attribute range_to.
Attributes inherited from Node
Instance Method Summary collapse
- #accept(visitor) ⇒ Object
- #clone ⇒ Object
-
#initialize(iterator_identifier:, range_from:, range_to:, body_stmts: BeginNode.new) ⇒ ForNode
constructor
A new instance of ForNode.
- #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(iterator_identifier:, range_from:, range_to:, body_stmts: BeginNode.new) ⇒ ForNode
Returns a new instance of ForNode.
443 444 445 446 447 448 449 450 451 452 |
# File 'lib/ast/nodes.rb', line 443 def initialize(iterator_identifier:, range_from:, range_to:, body_stmts: BeginNode.new) @iterator_identifier = iterator_identifier @range_from = range_from @range_to = range_to @body_stmts = body_stmts range_from.parent = self range_to.parent = self body_stmts.parent = self end |
Instance Attribute Details
#body_stmts ⇒ Object (readonly)
Returns the value of attribute body_stmts.
441 442 443 |
# File 'lib/ast/nodes.rb', line 441 def body_stmts @body_stmts end |
#iterator_identifier ⇒ Object (readonly)
Returns the value of attribute iterator_identifier.
438 439 440 |
# File 'lib/ast/nodes.rb', line 438 def iterator_identifier @iterator_identifier end |
#range_from ⇒ Object (readonly)
Returns the value of attribute range_from.
439 440 441 |
# File 'lib/ast/nodes.rb', line 439 def range_from @range_from end |
#range_to ⇒ Object (readonly)
Returns the value of attribute range_to.
440 441 442 |
# File 'lib/ast/nodes.rb', line 440 def range_to @range_to end |
Instance Method Details
#accept(visitor) ⇒ Object
128 129 130 |
# File 'lib/ast/visitor.rb', line 128 def accept(visitor) visitor.visit_for_node(self) end |
#clone ⇒ Object
454 455 456 457 458 459 460 |
# File 'lib/ast/nodes.rb', line 454 def clone return ForNode.new( iterator_identifier: @iterator_identifier, range_from: @range_from.clone, range_to: @range_to.clone, body_stmts: @body_stmts.clone) end |
#to_s ⇒ Object
120 121 122 |
# File 'lib/ast/printer.rb', line 120 def to_s return "[ForNode: #{iterator_identifier.to_s} := #{range_from.to_s}...#{range_to.to_s}, #{body_stmts.to_s}]" end |