Class: Prism::GlobalVariableOperatorWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::GlobalVariableOperatorWriteNode
- 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 global variable using an operator that isn't =.
$target += value
^^^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :global_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: self.name, name_loc: self.name_loc, binary_operator_loc: self.binary_operator_loc, value: self.value, binary_operator: self.binary_operator) ⇒ GlobalVariableOperatorWriteNode
:call-seq: copy(**fields) -> GlobalVariableOperatorWriteNode.
-
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped].
-
#desugar ⇒ node
: () -> node.
-
#each_child_node {|arg0| ... } ⇒ Object
See Node.each_child_node.
-
#initialize(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator) ⇒ GlobalVariableOperatorWriteNode
constructor
Initialize a new GlobalVariableOperatorWriteNode 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 ⇒ :global_variable_operator_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator) ⇒ GlobalVariableOperatorWriteNode
Initialize a new GlobalVariableOperatorWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location binary_operator_loc, Prism::node value, Symbol binary_operator) -> void
14155 14156 14157 14158 14159 14160 14161 14162 14163 14164 14165 |
# File 'lib/prism/node.rb', line 14155 def initialize(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @binary_operator_loc = binary_operator_loc @value = value @binary_operator = binary_operator end |
Class Method Details
.type ⇒ :global_variable_operator_write_node
See Node.type.
: () -> :global_variable_operator_write_node
14248 14249 14250 |
# File 'lib/prism/node.rb', line 14248 def self.type :global_variable_operator_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
14338 14339 14340 14341 14342 14343 14344 14345 |
# File 'lib/prism/node.rb', line 14338 def ===(other) # :nodoc: other.is_a?(GlobalVariableOperatorWriteNode) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (binary_operator_loc.nil? == other.binary_operator_loc.nil?) && (value === other.value) && (binary_operator === other.binary_operator) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
14181 14182 14183 |
# File 'lib/prism/node.rb', line 14181 def accept(visitor) visitor.visit_global_variable_operator_write_node(self) end |
#binary_operator ⇒ Symbol
:call-seq:
binary_operator -> Symbol
Returns the binary_operator attribute.
: () -> Symbol
14329 14330 14331 |
# File 'lib/prism/node.rb', line 14329 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
14298 14299 14300 14301 14302 |
# File 'lib/prism/node.rb', line 14298 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
14188 14189 14190 |
# File 'lib/prism/node.rb', line 14188 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
14205 14206 14207 |
# File 'lib/prism/node.rb', line 14205 def compact_child_nodes [value] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, binary_operator_loc: self.binary_operator_loc, value: self.value, binary_operator: self.binary_operator) ⇒ GlobalVariableOperatorWriteNode
:call-seq:
copy(**fields) -> GlobalVariableOperatorWriteNode
Creates a copy of self with the given fields, using self as the template.
: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?binary_operator_loc: Location, ?value: Prism::node, ?binary_operator: Symbol) -> GlobalVariableOperatorWriteNode
14215 14216 14217 |
# File 'lib/prism/node.rb', line 14215 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, binary_operator_loc: self.binary_operator_loc, value: self.value, binary_operator: self.binary_operator) GlobalVariableOperatorWriteNode.new(source, node_id, location, flags, name, name_loc, binary_operator_loc, value, binary_operator) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
14222 14223 14224 14225 14226 14227 14228 14229 14230 14231 14232 14233 14234 14235 14236 |
# File 'lib/prism/node.rb', line 14222 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location name name_loc binary_operator_loc value binary_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 then deconstructed[:name] = self.name 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 :binary_operator then deconstructed[:binary_operator] = self.binary_operator end end end |
#desugar ⇒ node
: () -> node
248 249 250 |
# File 'lib/prism/desugar_compiler.rb', line 248 def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :global_variable_read_node, :global_variable_write_node, name: name).compile end |
#each_child_node ⇒ Enumerator[node, void] #each_child_node ⇒ void
See Node.each_child_node.
: () -> Enumerator[node, void] : () { (node) -> void } -> void
14196 14197 14198 14199 14200 |
# File 'lib/prism/node.rb', line 14196 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
14253 14254 14255 |
# File 'lib/prism/node.rb', line 14253 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Returns the name attribute.
: () -> Symbol
14265 14266 14267 |
# File 'lib/prism/node.rb', line 14265 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
Returns the Location represented by name_loc.
: () -> Location
14276 14277 14278 14279 14280 |
# File 'lib/prism/node.rb', line 14276 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
14309 14310 14311 |
# File 'lib/prism/node.rb', line 14309 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
14287 14288 14289 |
# File 'lib/prism/node.rb', line 14287 def save_name_loc(repository) repository.enter(node_id, :name_loc) end |
#type ⇒ :global_variable_operator_write_node
See Node#type.
: () -> :global_variable_operator_write_node
14241 14242 14243 |
# File 'lib/prism/node.rb', line 14241 def type :global_variable_operator_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Returns the value attribute.
: () -> Prism::node
14319 14320 14321 |
# File 'lib/prism/node.rb', line 14319 def value @value end |