Class: YARP::ProgramNode

Inherits:
YARPNode
  • Object
show all
Defined in:
lib/yarp/node.rb,
ext/yarp/api_node.c

Overview

The top level node of any parse tree.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locals, statements, location) ⇒ ProgramNode

def initialize: (locals: Array, statements: Node, location: Location) -> void



4889
4890
4891
4892
4893
# File 'lib/yarp/node.rb', line 4889

def initialize(locals, statements, location)
  @locals = locals
  @statements = statements
  @location = location
end

Instance Attribute Details

#localsObject (readonly)

attr_reader locals: Array



4883
4884
4885
# File 'lib/yarp/node.rb', line 4883

def locals
  @locals
end

#statementsObject (readonly)

attr_reader statements: Node



4886
4887
4888
# File 'lib/yarp/node.rb', line 4886

def statements
  @statements
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4896
4897
4898
# File 'lib/yarp/node.rb', line 4896

def accept(visitor)
  visitor.visit_program_node(self)
end

#child_nodesObject Also known as: deconstruct

def child_nodes: () -> Array[nil | Node]



4902
4903
4904
# File 'lib/yarp/node.rb', line 4902

def child_nodes
  [statements]
end

#deconstruct_keys(keys) ⇒ Object

def deconstruct_keys: (keys: Array) -> Hash[Symbol, nil | Node | Array | String | Token | Array | Location]



4910
4911
4912
# File 'lib/yarp/node.rb', line 4910

def deconstruct_keys(keys)
  { locals: locals, statements: statements, location: location }
end