Class: Prism::LocalVariableAndWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::LocalVariableAndWriteNode
- Defined in:
- lib/prism/node.rb,
lib/prism/desugar_compiler.rb,
sig/generated/prism/node.rbs,
sig/generated/prism/desugar_compiler.rbs,
ext/prism/api_node.c
Overview
Represents the use of the &&= operator for assignment to a local variable.
target &&= value
^^^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :local_variable_and_write_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#child_nodes ⇒ Array[node?]
(also: #deconstruct)
See Node.child_nodes.
-
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
-
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name_loc: self.name_loc, operator_loc: self.operator_loc, value: self.value, name: self.name, depth: self.depth) ⇒ LocalVariableAndWriteNode
:call-seq: copy(**fields) -> LocalVariableAndWriteNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#depth ⇒ Integer
:call-seq: depth -> Integer.
-
#desugar ⇒ node
: () -> node.
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, name_loc, operator_loc, value, name, depth) ⇒ LocalVariableAndWriteNode
constructor
Initialize a new LocalVariableAndWriteNode node.
-
#inspect ⇒ String
: () -> String.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#name_loc ⇒ Location
:category: Locations :call-seq: name_loc -> Location.
-
#operator ⇒ String
:call-seq: operator -> String.
-
#operator_loc ⇒ Location
:category: Locations :call-seq: operator_loc -> Location.
-
#save_name_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
-
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
-
#type ⇒ :local_variable_and_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, name_loc, operator_loc, value, name, depth) ⇒ LocalVariableAndWriteNode
Initialize a new LocalVariableAndWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location operator_loc, Prism::node value, Symbol name, Integer depth) -> void
21392 21393 21394 21395 21396 21397 21398 21399 21400 21401 21402 |
# File 'lib/prism/node.rb', line 21392 def initialize(source, node_id, location, flags, name_loc, operator_loc, value, name, depth) @source = source @node_id = node_id @location = location @flags = flags @name_loc = name_loc @operator_loc = operator_loc @value = value @name = name @depth = depth end |
Class Method Details
.type ⇒ :local_variable_and_write_node
See Node.type.
: () -> :local_variable_and_write_node
21486 21487 21488 |
# File 'lib/prism/node.rb', line 21486 def self.type :local_variable_and_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
21586 21587 21588 21589 21590 21591 21592 21593 |
# File 'lib/prism/node.rb', line 21586 def ===(other) # :nodoc: other.is_a?(LocalVariableAndWriteNode) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) && (value === other.value) && (name === other.name) && (depth === other.depth) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
21418 21419 21420 |
# File 'lib/prism/node.rb', line 21418 def accept(visitor) visitor.visit_local_variable_and_write_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
21425 21426 21427 |
# File 'lib/prism/node.rb', line 21425 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
21442 21443 21444 |
# File 'lib/prism/node.rb', line 21442 def compact_child_nodes [value] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name_loc: self.name_loc, operator_loc: self.operator_loc, value: self.value, name: self.name, depth: self.depth) ⇒ LocalVariableAndWriteNode
:call-seq:
copy(**fields) -> LocalVariableAndWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?depth: Integer) -> LocalVariableAndWriteNode
21452 21453 21454 |
# File 'lib/prism/node.rb', line 21452 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name_loc: self.name_loc, operator_loc: self.operator_loc, value: self.value, name: self.name, depth: self.depth) LocalVariableAndWriteNode.new(source, node_id, location, flags, name_loc, operator_loc, value, name, depth) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 21471 21472 21473 21474 |
# File 'lib/prism/node.rb', line 21459 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location name_loc operator_loc value name depth operator]).each_with_object( {} #: Hash[Symbol, untyped] ) do |key, deconstructed| case key when :node_id then deconstructed[:node_id] = self.node_id when :location then deconstructed[:location] = self.location when :name_loc then deconstructed[:name_loc] = self.name_loc when :operator_loc then deconstructed[:operator_loc] = self.operator_loc when :value then deconstructed[:value] = self.value when :name then deconstructed[:name] = self.name when :depth then deconstructed[:depth] = self.depth when :operator then deconstructed[:operator] = self.operator end end end |
#depth ⇒ Integer
:call-seq:
depth -> Integer
Returns the depth attribute.
: () -> Integer
21567 21568 21569 |
# File 'lib/prism/node.rb', line 21567 def depth @depth end |
#desugar ⇒ node
: () -> node
276 277 278 |
# File 'lib/prism/desugar_compiler.rb', line 276 def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :local_variable_read_node, :local_variable_write_node, name: name, depth: depth).compile end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
21433 21434 21435 21436 21437 |
# File 'lib/prism/node.rb', line 21433 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
21491 21492 21493 |
# File 'lib/prism/node.rb', line 21491 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Returns the name attribute.
: () -> Symbol
21557 21558 21559 |
# File 'lib/prism/node.rb', line 21557 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
Returns the Location represented by name_loc.
: () -> Location
21504 21505 21506 21507 21508 |
# File 'lib/prism/node.rb', line 21504 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#operator ⇒ String
:call-seq:
operator -> String
Slice the location of operator_loc from the source.
: () -> String
21579 21580 21581 |
# File 'lib/prism/node.rb', line 21579 def operator operator_loc.slice end |
#operator_loc ⇒ Location
:category: Locations :call-seq:
operator_loc -> Location
Returns the Location represented by operator_loc.
: () -> Location
21526 21527 21528 21529 21530 |
# File 'lib/prism/node.rb', line 21526 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_name_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the name_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
21515 21516 21517 |
# File 'lib/prism/node.rb', line 21515 def save_name_loc(repository) repository.enter(node_id, :name_loc) end |
#save_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
21537 21538 21539 |
# File 'lib/prism/node.rb', line 21537 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ :local_variable_and_write_node
See Node#type.
: () -> :local_variable_and_write_node
21479 21480 21481 |
# File 'lib/prism/node.rb', line 21479 def type :local_variable_and_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Returns the value attribute.
: () -> Prism::node
21547 21548 21549 |
# File 'lib/prism/node.rb', line 21547 def value @value end |