Class: YARP::GlobalVariableWriteNode

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

Overview

Represents writing to a global variable.

$foo = 1
^^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_loc, operator_loc, value, location) ⇒ GlobalVariableWriteNode

def initialize: (name_loc: Location, operator_loc: Location?, value: Node?, location: Location) -> void



2790
2791
2792
2793
2794
2795
# File 'lib/yarp/node.rb', line 2790

def initialize(name_loc, operator_loc, value, location)
  @name_loc = name_loc
  @operator_loc = operator_loc
  @value = value
  @location = location
end

Instance Attribute Details

#name_locObject (readonly)

attr_reader name_loc: Location



2781
2782
2783
# File 'lib/yarp/node.rb', line 2781

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



2784
2785
2786
# File 'lib/yarp/node.rb', line 2784

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



2787
2788
2789
# File 'lib/yarp/node.rb', line 2787

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



2798
2799
2800
# File 'lib/yarp/node.rb', line 2798

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

#child_nodesObject Also known as: deconstruct

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



2803
2804
2805
# File 'lib/yarp/node.rb', line 2803

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



2811
2812
2813
# File 'lib/yarp/node.rb', line 2811

def deconstruct_keys(keys)
  { name_loc: name_loc, operator_loc: operator_loc, value: value, location: location }
end

#nameObject

def name: () -> String



2816
2817
2818
# File 'lib/yarp/node.rb', line 2816

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String?



2821
2822
2823
# File 'lib/yarp/node.rb', line 2821

def operator
  operator_loc&.slice
end