Class: Ikra::AST::ProgramNode
- Defined in:
- lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
First block is program entry point.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
Attributes inherited from Node
Instance Method Summary collapse
- #==(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #clone ⇒ Object
- #hash ⇒ Object
-
#initialize(blocks: [], classes: []) ⇒ ProgramNode
constructor
A new instance of ProgramNode.
- #to_s ⇒ Object
Methods inherited from Node
Constructor Details
#initialize(blocks: [], classes: []) ⇒ ProgramNode
Returns a new instance of ProgramNode.
24 25 26 27 |
# File 'lib/ast/nodes.rb', line 24 def initialize(blocks: [], classes: []) @blocks = blocks @classes = classes end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
First block is program entry point
21 22 23 |
# File 'lib/ast/nodes.rb', line 21 def blocks @blocks end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
22 23 24 |
# File 'lib/ast/nodes.rb', line 22 def classes @classes end |
Instance Method Details
#==(other) ⇒ Object
35 36 37 |
# File 'lib/ast/nodes.rb', line 35 def ==(other) return super(other) && blocks == other.blocks && classes == other.classes end |
#accept(visitor) ⇒ Object
12 13 14 15 16 |
# File 'lib/ast/visitor.rb', line 12 def accept(visitor) def accept(visitor) return visitor.visit_program_node(self) end end |
#clone ⇒ Object
29 30 31 32 33 |
# File 'lib/ast/nodes.rb', line 29 def clone return ProgramNode.new( blocks: @blocks.map do |b| b.clone end, classes: @classes.map do |c| c.clone end) end |
#hash ⇒ Object
39 40 41 |
# File 'lib/ast/nodes.rb', line 39 def hash return (blocks.hash + classes.hash) % 4524321 end |
#to_s ⇒ Object
10 11 12 |
# File 'lib/ast/printer.rb', line 10 def to_s return "[ProgramNode: #{blocks.to_s}; #{classes.to_s}]" end |