Class: Prism::InstanceVariableAndWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::InstanceVariableAndWriteNode
- 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 an instance variable.
^^^^^^^^^^^^^^^^^
Class Method Summary collapse
-
.type ⇒ :instance_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: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc, value: self.value) ⇒ InstanceVariableAndWriteNode
:call-seq: copy(**fields) -> InstanceVariableAndWriteNode.
-
#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, operator_loc, value) ⇒ InstanceVariableAndWriteNode
constructor
Initialize a new InstanceVariableAndWriteNode 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 ⇒ :instance_variable_and_write_node
See
Node#type. -
#value ⇒ Prism::node
:call-seq: value -> Node.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, operator_loc, value) ⇒ InstanceVariableAndWriteNode
Initialize a new InstanceVariableAndWriteNode node.
: (Source source, Integer node_id, Location location, Integer flags, Symbol name, Location name_loc, Location operator_loc, Prism::node value) -> void
17992 17993 17994 17995 17996 17997 17998 17999 18000 18001 |
# File 'lib/prism/node.rb', line 17992 def initialize(source, node_id, location, flags, name, name_loc, operator_loc, value) @source = source @node_id = node_id @location = location @flags = flags @name = name @name_loc = name_loc @operator_loc = operator_loc @value = value end |
Class Method Details
.type ⇒ :instance_variable_and_write_node
See Node.type.
: () -> :instance_variable_and_write_node
18084 18085 18086 |
# File 'lib/prism/node.rb', line 18084 def self.type :instance_variable_and_write_node end |
Instance Method Details
#===(other) ⇒ boolish
: (untyped other) -> boolish
18174 18175 18176 18177 18178 18179 18180 |
# File 'lib/prism/node.rb', line 18174 def ===(other) # :nodoc: other.is_a?(InstanceVariableAndWriteNode) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) && (value === other.value) end |
#accept(visitor) ⇒ Object
See Node.accept.
: (_Visitor visitor) -> untyped
18017 18018 18019 |
# File 'lib/prism/node.rb', line 18017 def accept(visitor) visitor.visit_instance_variable_and_write_node(self) end |
#child_nodes ⇒ Array[node?] Also known as: deconstruct
See Node.child_nodes.
: () -> Array
18024 18025 18026 |
# File 'lib/prism/node.rb', line 18024 def child_nodes [value] end |
#compact_child_nodes ⇒ Array[node]
See Node.compact_child_nodes.
: () -> Array
18041 18042 18043 |
# File 'lib/prism/node.rb', line 18041 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, operator_loc: self.operator_loc, value: self.value) ⇒ InstanceVariableAndWriteNode
:call-seq:
copy(**fields) -> InstanceVariableAndWriteNode
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, ?operator_loc: Location, ?value: Prism::node) -> InstanceVariableAndWriteNode
18051 18052 18053 |
# File 'lib/prism/node.rb', line 18051 def copy(node_id: self.node_id, location: self.location, flags: self.flags, name: self.name, name_loc: self.name_loc, operator_loc: self.operator_loc, value: self.value) InstanceVariableAndWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value) end |
#deconstruct_keys(keys) ⇒ Hash[Symbol, untyped]
: (Array? keys) -> Hash[Symbol, untyped]
18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 18071 18072 |
# File 'lib/prism/node.rb', line 18058 def deconstruct_keys(keys) # :nodoc: (keys || %i[node_id location name name_loc operator_loc value 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 :operator_loc then deconstructed[:operator_loc] = self.operator_loc when :value then deconstructed[:value] = self.value when :operator then deconstructed[:operator] = self.operator end end end |
#desugar ⇒ node
: () -> node
255 256 257 |
# File 'lib/prism/desugar_compiler.rb', line 255 def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :instance_variable_read_node, :instance_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
18032 18033 18034 18035 18036 |
# File 'lib/prism/node.rb', line 18032 def each_child_node(&blk) return to_enum(:each_child_node) unless block_given? yield value end |
#inspect ⇒ String
: () -> String
18089 18090 18091 |
# File 'lib/prism/node.rb', line 18089 def inspect # :nodoc: InspectVisitor.compose(self) end |
#name ⇒ Symbol
:call-seq:
name -> Symbol
Returns the name attribute.
: () -> Symbol
18101 18102 18103 |
# File 'lib/prism/node.rb', line 18101 def name @name end |
#name_loc ⇒ Location
:category: Locations :call-seq:
name_loc -> Location
Returns the Location represented by name_loc.
: () -> Location
18112 18113 18114 18115 18116 |
# File 'lib/prism/node.rb', line 18112 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
18167 18168 18169 |
# File 'lib/prism/node.rb', line 18167 def operator operator_loc.slice end |
#operator_loc ⇒ Location
:category: Locations :call-seq:
operator_loc -> Location
Returns the Location represented by operator_loc.
: () -> Location
18134 18135 18136 18137 18138 |
# File 'lib/prism/node.rb', line 18134 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
18123 18124 18125 |
# File 'lib/prism/node.rb', line 18123 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
18145 18146 18147 |
# File 'lib/prism/node.rb', line 18145 def save_operator_loc(repository) repository.enter(node_id, :operator_loc) end |
#type ⇒ :instance_variable_and_write_node
See Node#type.
: () -> :instance_variable_and_write_node
18077 18078 18079 |
# File 'lib/prism/node.rb', line 18077 def type :instance_variable_and_write_node end |
#value ⇒ Prism::node
:call-seq:
value -> Node
Returns the value attribute.
: () -> Prism::node
18155 18156 18157 |
# File 'lib/prism/node.rb', line 18155 def value @value end |