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



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

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



2769
2770
2771
# File 'lib/yarp/node.rb', line 2769

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



2772
2773
2774
# File 'lib/yarp/node.rb', line 2772

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



2775
2776
2777
# File 'lib/yarp/node.rb', line 2775

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



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

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

#child_nodesObject Also known as: deconstruct

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



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

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



2800
2801
2802
# File 'lib/yarp/node.rb', line 2800

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

#nameObject

def name: () -> String



2805
2806
2807
# File 'lib/yarp/node.rb', line 2805

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String?



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

def operator
  operator_loc&.slice
end