Class: YARP::LocalVariableWriteNode

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

Overview

Represents writing to a local variable.

foo = 1
^^^^^^^

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, depth, name_loc, value, operator_loc, location) ⇒ LocalVariableWriteNode

def initialize: (name: Symbol, depth: Integer, name_loc: Location, value: Node, operator_loc: Location, location: Location) -> void



5109
5110
5111
5112
5113
5114
5115
5116
# File 'lib/yarp/node.rb', line 5109

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

Instance Attribute Details

#depthObject (readonly)

attr_reader depth: Integer



5097
5098
5099
# File 'lib/yarp/node.rb', line 5097

def depth
  @depth
end

#nameObject (readonly)

attr_reader name: Symbol



5094
5095
5096
# File 'lib/yarp/node.rb', line 5094

def name
  @name
end

#name_locObject (readonly)

attr_reader name_loc: Location



5100
5101
5102
# File 'lib/yarp/node.rb', line 5100

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location



5106
5107
5108
# File 'lib/yarp/node.rb', line 5106

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node



5103
5104
5105
# File 'lib/yarp/node.rb', line 5103

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



5119
5120
5121
# File 'lib/yarp/node.rb', line 5119

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

#child_nodesObject Also known as: deconstruct

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



5124
5125
5126
# File 'lib/yarp/node.rb', line 5124

def child_nodes
  [value]
end

#copy(**params) ⇒ Object

def copy: (**params) -> LocalVariableWriteNode



5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
# File 'lib/yarp/node.rb', line 5129

def copy(**params)
  LocalVariableWriteNode.new(
    params.fetch(:name) { name },
    params.fetch(:depth) { depth },
    params.fetch(:name_loc) { name_loc },
    params.fetch(:value) { value },
    params.fetch(:operator_loc) { operator_loc },
    params.fetch(:location) { location },
  )
end

#deconstruct_keys(keys) ⇒ Object

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



5144
5145
5146
# File 'lib/yarp/node.rb', line 5144

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

#operatorObject

def operator: () -> String



5149
5150
5151
# File 'lib/yarp/node.rb', line 5149

def operator
  operator_loc.slice
end