Class: Prism::ConstantAndWriteNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ConstantAndWriteNode
- Defined in:
- lib/prism/node.rb,
lib/prism/desugar_compiler.rb,
ext/prism/api_node.c
Overview
Represents the use of the ‘&&=` operator for assignment to a constant.
Target &&= value
^^^^^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
attr_reader name: Symbol.
-
#value ⇒ Object
readonly
attr_reader value: Prism::node.
Class Method Summary collapse
-
.type ⇒ Object
Return a symbol representation of this node type.
Instance Method Summary collapse
-
#===(other) ⇒ Object
Implements case-equality for the node.
-
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void.
-
#child_nodes ⇒ Object
(also: #deconstruct)
def child_nodes: () -> Array[nil | Node].
-
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location].
-
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array.
-
#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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol, name_loc: Location, operator_loc: Location, value: Prism::node }.
-
#desugar ⇒ Object
:nodoc:.
-
#initialize(source, node_id, location, flags, name, name_loc, operator_loc, value) ⇒ ConstantAndWriteNode
constructor
Initialize a new ConstantAndWriteNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#name_loc ⇒ Object
attr_reader name_loc: Location.
-
#operator ⇒ Object
def operator: () -> String.
-
#operator_loc ⇒ Object
attr_reader operator_loc: Location.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, name, name_loc, operator_loc, value) ⇒ ConstantAndWriteNode
Initialize a new ConstantAndWriteNode node.
3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 |
# File 'lib/prism/node.rb', line 3918 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 |
Instance Attribute Details
#name ⇒ Object (readonly)
attr_reader name: Symbol
3963 3964 3965 |
# File 'lib/prism/node.rb', line 3963 def name @name end |
#value ⇒ Object (readonly)
attr_reader value: Prism::node
3980 3981 3982 |
# File 'lib/prism/node.rb', line 3980 def value @value end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
3998 3999 4000 |
# File 'lib/prism/node.rb', line 3998 def self.type :constant_and_write_node end |
Instance Method Details
#===(other) ⇒ Object
Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.
4004 4005 4006 4007 4008 4009 4010 |
# File 'lib/prism/node.rb', line 4004 def ===(other) other.is_a?(ConstantAndWriteNode) && (name === other.name) && (name_loc.nil? == other.name_loc.nil?) && (operator_loc.nil? == other.operator_loc.nil?) && (value === other.value) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
3930 3931 3932 |
# File 'lib/prism/node.rb', line 3930 def accept(visitor) visitor.visit_constant_and_write_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array[nil | Node]
3935 3936 3937 |
# File 'lib/prism/node.rb', line 3935 def child_nodes [value] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
3945 3946 3947 |
# File 'lib/prism/node.rb', line 3945 def comment_targets [name_loc, operator_loc, value] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
3940 3941 3942 |
# File 'lib/prism/node.rb', line 3940 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) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?name: Symbol, ?name_loc: Location, ?operator_loc: Location, ?value: Prism::node) -> ConstantAndWriteNode
3950 3951 3952 |
# File 'lib/prism/node.rb', line 3950 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) ConstantAndWriteNode.new(source, node_id, location, flags, name, name_loc, operator_loc, value) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, name: Symbol, name_loc: Location, operator_loc: Location, value: Prism::node }
3958 3959 3960 |
# File 'lib/prism/node.rb', line 3958 def deconstruct_keys(keys) { node_id: node_id, location: location, name: name, name_loc: name_loc, operator_loc: operator_loc, value: value } end |
#desugar ⇒ Object
:nodoc:
182 183 184 |
# File 'lib/prism/desugar_compiler.rb', line 182 def desugar # :nodoc: DesugarAndWriteNode.new(self, source, :constant_read_node, :constant_write_node, name: name).compile end |
#inspect ⇒ Object
def inspect -> String
3988 3989 3990 |
# File 'lib/prism/node.rb', line 3988 def inspect InspectVisitor.compose(self) end |
#name_loc ⇒ Object
attr_reader name_loc: Location
3966 3967 3968 3969 3970 |
# File 'lib/prism/node.rb', line 3966 def name_loc location = @name_loc return location if location.is_a?(Location) @name_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#operator ⇒ Object
def operator: () -> String
3983 3984 3985 |
# File 'lib/prism/node.rb', line 3983 def operator operator_loc.slice end |
#operator_loc ⇒ Object
attr_reader operator_loc: Location
3973 3974 3975 3976 3977 |
# File 'lib/prism/node.rb', line 3973 def operator_loc location = @operator_loc return location if location.is_a?(Location) @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
3993 3994 3995 |
# File 'lib/prism/node.rb', line 3993 def type :constant_and_write_node end |