Class: YARP::ProgramNode
- Inherits:
-
YARPNode
- Object
- YARPNode
- YARP::ProgramNode
- Defined in:
- lib/yarp/node.rb,
ext/yarp/api_node.c
Overview
The top level node of any parse tree.
Instance Attribute Summary collapse
-
#locals ⇒ Object
readonly
attr_reader locals: Array.
-
#statements ⇒ Object
readonly
attr_reader statements: StatementsNode.
Instance Method Summary collapse
-
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#copy(**params) ⇒ Object
def copy: (**params) -> ProgramNode.
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(locals, statements, location) ⇒ ProgramNode
constructor
def initialize: (locals: Array, statements: StatementsNode, location: Location) -> void.
Constructor Details
#initialize(locals, statements, location) ⇒ ProgramNode
def initialize: (locals: Array, statements: StatementsNode, location: Location) -> void
6167 6168 6169 6170 6171 |
# File 'lib/yarp/node.rb', line 6167 def initialize(locals, statements, location) @locals = locals @statements = statements @location = location end |
Instance Attribute Details
#locals ⇒ Object (readonly)
attr_reader locals: Array
6161 6162 6163 |
# File 'lib/yarp/node.rb', line 6161 def locals @locals end |
#statements ⇒ Object (readonly)
attr_reader statements: StatementsNode
6164 6165 6166 |
# File 'lib/yarp/node.rb', line 6164 def statements @statements end |
Instance Method Details
#accept(visitor) ⇒ Object
def accept: (visitor: Visitor) -> void
6174 6175 6176 |
# File 'lib/yarp/node.rb', line 6174 def accept(visitor) visitor.visit_program_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
6179 6180 6181 |
# File 'lib/yarp/node.rb', line 6179 def child_nodes [statements] end |
#copy(**params) ⇒ Object
def copy: (**params) -> ProgramNode
6184 6185 6186 6187 6188 6189 6190 |
# File 'lib/yarp/node.rb', line 6184 def copy(**params) ProgramNode.new( params.fetch(:locals) { locals }, params.fetch(:statements) { statements }, params.fetch(:location) { location }, ) end |