Class: Prism::ConstantOperatorWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ConstantOperatorWriteNode
- 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 constant using an operator that isn't =.
Target += value
^^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :constant_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) ⇒ ConstantOperatorWriteNode
:call-seq: copy(**fields) -> ConstantOperatorWriteNode.
-
#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) ⇒ ConstantOperatorWriteNode
constructor
Initialize a new ConstantOperatorWriteNode 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 ⇒ :constant_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) ⇒ ConstantOperatorWriteNode
Initialize a new ConstantOperatorWriteNode 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
8602 8603 8604 8605 8606 8607 8608 8609 8610 8611 8612 |
# File 'lib/prism/node.rb', line 8602 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 ⇒ :constant_operator_write_node
See Node.type.
: () -> :constant_operator_write_node
8695 8696 8697 |
# File 'lib/prism/node.rb', line 8695 def self.type :constant_operator_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
8785 8786 8787 8788 8789 8790 8791 8792 |
# File 'lib/prism/node.rb', line 8785 def ===(other) # :nodoc: other.is_a?(ConstantOperatorWriteNode) && (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
8628 8629 8630 |
# File 'lib/prism/node.rb', line 8628 def accept(visitor) visitor.visit_constant_operator_write_node(self) end |
#binary_operator ⇒ Symbol
:call-seq:
binary_operator -> Symbol
Returns the binary_operator attribute.
: () -> Symbol
8776 8777 8778 |
# File 'lib/prism/node.rb', line 8776 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
8745 8746 8747 8748 8749 |
# File 'lib/prism/node.rb', line 8745 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
8635 8636 8637 |
# File 'lib/prism/node.rb', line 8635 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
8652 8653 8654 |
# File 'lib/prism/node.rb', line 8652 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) ⇒ ConstantOperatorWriteNode
:call-seq:
copy(**fields) -> ConstantOperatorWriteNode
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) -> ConstantOperatorWriteNode
8662 8663 8664 |
# File 'lib/prism/node.rb', line 8662 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) ConstantOperatorWriteNode.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]
8669 8670 8671 8672 8673 8674 8675 8676 8677 8678 8679 8680 8681 8682 8683 |
# File 'lib/prism/node.rb', line 8669 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
227 228 229 |
# File 'lib/prism/desugar_compiler.rb', line 227 def desugar # :nodoc: DesugarOperatorWriteNode.new(self, source, :constant_read_node, :constant_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
8643 8644 8645 8646 8647 |
# File 'lib/prism/node.rb', line 8643 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
8700 8701 8702 |
# File 'lib/prism/node.rb', line 8700 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Returns the name attribute.
: () -> Symbol
8712 8713 8714 |
# File 'lib/prism/node.rb', line 8712 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
Returns the Location represented by name_loc.
: () -> Location
8723 8724 8725 8726 8727 |
# File 'lib/prism/node.rb', line 8723 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
8756 8757 8758 |
# File 'lib/prism/node.rb', line 8756 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
8734 8735 8736 |
# File 'lib/prism/node.rb', line 8734 def save_name_loc(repository) repository.enter(node_id, :name_loc) end |
#type ⇒ :constant_operator_write_node
See Node#type.
: () -> :constant_operator_write_node
8688 8689 8690 |
# File 'lib/prism/node.rb', line 8688 def type :constant_operator_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Returns the value attribute.
: () -> Prism::node
8766 8767 8768 |
# File 'lib/prism/node.rb', line 8766 def value @value end |