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(constant_id, depth, value, name_loc, operator_loc, location) ⇒ LocalVariableWriteNode

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



4029
4030
4031
4032
4033
4034
4035
4036
# File 'lib/yarp/node.rb', line 4029

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

Instance Attribute Details

#constant_idObject (readonly)

attr_reader constant_id: Symbol



4014
4015
4016
# File 'lib/yarp/node.rb', line 4014

def constant_id
  @constant_id
end

#depthObject (readonly)

attr_reader depth: Integer



4017
4018
4019
# File 'lib/yarp/node.rb', line 4017

def depth
  @depth
end

#name_locObject (readonly)

attr_reader name_loc: Location



4023
4024
4025
# File 'lib/yarp/node.rb', line 4023

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



4026
4027
4028
# File 'lib/yarp/node.rb', line 4026

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



4020
4021
4022
# File 'lib/yarp/node.rb', line 4020

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4039
4040
4041
# File 'lib/yarp/node.rb', line 4039

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

#child_nodesObject Also known as: deconstruct

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



4044
4045
4046
# File 'lib/yarp/node.rb', line 4044

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



4052
4053
4054
# File 'lib/yarp/node.rb', line 4052

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

#nameObject

def name: () -> String



4057
4058
4059
# File 'lib/yarp/node.rb', line 4057

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String?



4062
4063
4064
# File 'lib/yarp/node.rb', line 4062

def operator
  operator_loc&.slice
end