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



3996
3997
3998
3999
4000
4001
4002
4003
# File 'lib/yarp/node.rb', line 3996

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



3981
3982
3983
# File 'lib/yarp/node.rb', line 3981

def constant_id
  @constant_id
end

#depthObject (readonly)

attr_reader depth: Integer



3984
3985
3986
# File 'lib/yarp/node.rb', line 3984

def depth
  @depth
end

#name_locObject (readonly)

attr_reader name_loc: Location



3990
3991
3992
# File 'lib/yarp/node.rb', line 3990

def name_loc
  @name_loc
end

#operator_locObject (readonly)

attr_reader operator_loc: Location?



3993
3994
3995
# File 'lib/yarp/node.rb', line 3993

def operator_loc
  @operator_loc
end

#valueObject (readonly)

attr_reader value: Node?



3987
3988
3989
# File 'lib/yarp/node.rb', line 3987

def value
  @value
end

Instance Method Details

#accept(visitor) ⇒ Object

def accept: (visitor: Visitor) -> void



4006
4007
4008
# File 'lib/yarp/node.rb', line 4006

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

#child_nodesObject Also known as: deconstruct

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



4012
4013
4014
# File 'lib/yarp/node.rb', line 4012

def child_nodes
  [value]
end

#deconstruct_keys(keys) ⇒ Object

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



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

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



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

def name
  name_loc.slice
end

#operatorObject

def operator: () -> String?



4030
4031
4032
# File 'lib/yarp/node.rb', line 4030

def operator
  operator_loc&.slice
end