Class: Prism::LocalVariableOperatorWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::LocalVariableOperatorWriteNode
- 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 assigning to a local variable using an operator that isn't =.
target += value
^^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :local_variable_operator_write_node
See
Node.type.
Instance Method Summary collapse
-
#===(other) ⇒ boolish
: (untyped other) -> boolish.
-
#accept(visitor) ⇒ Object
See Node.accept.
-
#binary_operator ⇒ Symbol
:call-seq: binary_operator -> Symbol.
-
#binary_operator_loc ⇒ Location
:category: Locations :call-seq: binary_operator_loc -> Location.
-
#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, binary_operator_loc: self.binary_operator_loc, value: self.value, name: self.name, binary_operator: self.binary_operator, depth: self.depth) ⇒ LocalVariableOperatorWriteNode
:call-seq: copy(**fields) -> LocalVariableOperatorWriteNode.
-
#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, binary_operator_loc, value, name, binary_operator, depth) ⇒ LocalVariableOperatorWriteNode
constructor
Initialize a new LocalVariableOperatorWriteNode node.
-
#inspect ⇒ String
: () -> String.
-
#name ⇒ Symbol
:call-seq: name -> Symbol.
-
#name_loc ⇒ Location
:category: Locations :call-seq: name_loc -> Location.
-
#save_binary_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
-
#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.
-
#type ⇒ :local_variable_operator_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, name_loc, binary_operator_loc, value, name, binary_operator, depth) ⇒ LocalVariableOperatorWriteNode
Initialize a new LocalVariableOperatorWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol name, Symbol binary_operator, Integer depth) -> void
21615 21616 21617 21618 21619 21620 21621 21622 21623 21624 21625 21626 |
# File 'lib/prism/node.rb', line 21615 def initialize(source, node_id, location, flags, name_loc, binary_operator_loc, value, name, binary_operator, depth) @source = source @node_id = node_id @location = location @flags = flags @name_loc = name_loc @binary_operator_loc = binary_operator_loc @value = value @name = name @binary_operator = binary_operator @depth = depth end |
Class Method Details
.type ⇒ :local_variable_operator_write_node
See Node.type.
: () -> :local_variable_operator_write_node
21710 21711 21712 |
# File 'lib/prism/node.rb', line 21710 def self.type :local_variable_operator_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
21810 21811 21812 21813 21814 21815 21816 21817 21818 |
# File 'lib/prism/node.rb', line 21810 def ===(other) # :nodoc: other.is_a?(LocalVariableOperatorWriteNode) && (name_loc.nil? == other.name_loc.nil?) && (binary_operator_loc.nil? == other.binary_operator_loc.nil?) && (value === other.value) && (name === other.name) && (binary_operator === other.binary_operator) && (depth === other.depth) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
21642 21643 21644 |
# File 'lib/prism/node.rb', line 21642 def accept(visitor) visitor.visit_local_variable_operator_write_node(self) end |
#binary_operator ⇒ Symbol
:call-seq:
binary_operator -> Symbol
Returns the binary_operator attribute.
: () -> Symbol
21791 21792 21793 |
# File 'lib/prism/node.rb', line 21791 def binary_operator @binary_operator end |
#binary_operator_loc ⇒ Location
:category: Locations :call-seq:
binary_operator_loc -> Location
Returns the Location represented by binary_operator_loc.
: () -> Location
21750 21751 21752 21753 21754 |
# File 'lib/prism/node.rb', line 21750 def binary_operator_loc location = @binary_operator_loc return location if location.is_a?(Location) @binary_operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
21649 21650 21651 |
# File 'lib/prism/node.rb', line 21649 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
21666 21667 21668 |
# File 'lib/prism/node.rb', line 21666 def compact_child_nodes [value] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name_loc: self.name_loc, binary_operator_loc: self.binary_operator_loc, value: self.value, name: self.name, binary_operator: self.binary_operator, depth: self.depth) ⇒ LocalVariableOperatorWriteNode
:call-seq:
copy(**fields) -> LocalVariableOperatorWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?name: Symbol, ?binary_operator: Symbol, ?depth: Integer) -> LocalVariableOperatorWriteNode
21676 21677 21678 |
# File 'lib/prism/node.rb', line 21676 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name_loc: self.name_loc, binary_operator_loc: self.binary_operator_loc, value: self.value, name: self.name, binary_operator: self.binary_operator, depth: self.depth) LocalVariableOperatorWriteNode.new(source, node_id, location, flags, name_loc, binary_operator_loc, value, name, binary_operator, depth) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
21683 21684 21685 21686 21687 21688 21689 21690 21691 21692 21693 21694 21695 21696 21697 21698 |
# File 'lib/prism/node.rb', line 21683 def deconstruct_keys(keys) # :nodoc: (keys || i[node_id location name_loc binary_operator_loc value name binary_operator depth]).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 :binary_operator_loc then deconstructed[:binary_operator_loc] = self.binary_operator_loc when :value then deconstructed[:value] = self.value when :name then deconstructed[:name] = self.name when :binary_operator then deconstructed[:binary_operator] = self.binary_operator when :depth then deconstructed[:depth] = self.depth end end end |
#depth ⇒ Integer
:call-seq:
depth -> Integer
Returns the depth attribute.
: () -> Integer
21801 21802 21803 |
# File 'lib/prism/node.rb', line 21801 def depth @depth end |
#desugar ⇒ node
: () -> node
290 291 292 |
# File 'lib/prism/desugar_compiler.rb', line 290 def desugar # :nodoc: DesugarOperatorWriteNode.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
21657 21658 21659 21660 21661 |
# File 'lib/prism/node.rb', line 21657 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
21715 21716 21717 |
# File 'lib/prism/node.rb', line 21715 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Returns the name attribute.
: () -> Symbol
21781 21782 21783 |
# File 'lib/prism/node.rb', line 21781 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
Returns the Location represented by name_loc.
: () -> Location
21728 21729 21730 21731 21732 |
# File 'lib/prism/node.rb', line 21728 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#save_binary_operator_loc(repository) ⇒ Relocation::Entry
:category: Repository Save the binary_operator_loc location using the given saved source so that it can be retrieved later.
: (_Repository repository) -> Relocation::Entry
21761 21762 21763 |
# File 'lib/prism/node.rb', line 21761 def save_binary_operator_loc(repository) repository.enter(node_id, :binary_operator_loc) 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
21739 21740 21741 |
# File 'lib/prism/node.rb', line 21739 def save_name_loc(repository) repository.enter(node_id, :name_loc) end |
#type ⇒ :local_variable_operator_write_node
See Node#type.
: () -> :local_variable_operator_write_node
21703 21704 21705 |
# File 'lib/prism/node.rb', line 21703 def type :local_variable_operator_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Returns the value attribute.
: () -> Prism::node
21771 21772 21773 |
# File 'lib/prism/node.rb', line 21771 def value @value end |