Class: Prism::ShareableConstantNode
- Inherits:
-
PrismNode
- Object
- PrismNode
- Prism::ShareableConstantNode
- Defined in:
- lib/prism/node.rb,
ext/prism/api_node.c
Overview
This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
# shareable_constant_value: literal
C = { a: 1 }
^^^^^^^^^^^^
Instance Attribute Summary collapse
-
#write ⇒ Object
readonly
The constant write that should be modified with the shareability state.
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.
-
#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, write: self.write) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) -> ShareableConstantNode.
-
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode }.
-
#experimental_copy? ⇒ Boolean
def experimental_copy?: () -> bool.
-
#experimental_everything? ⇒ Boolean
def experimental_everything?: () -> bool.
-
#initialize(source, node_id, location, flags, write) ⇒ ShareableConstantNode
constructor
Initialize a new ShareableConstantNode node.
-
#inspect ⇒ Object
def inspect -> String.
-
#literal? ⇒ Boolean
def literal?: () -> bool.
-
#type ⇒ Object
Return a symbol representation of this node type.
Constructor Details
#initialize(source, node_id, location, flags, write) ⇒ ShareableConstantNode
Initialize a new ShareableConstantNode node.
16408 16409 16410 16411 16412 16413 16414 |
# File 'lib/prism/node.rb', line 16408 def initialize(source, node_id, location, flags, write) @source = source @node_id = node_id @location = location @flags = flags @write = write end |
Instance Attribute Details
#write ⇒ Object (readonly)
The constant write that should be modified with the shareability state.
16465 16466 16467 |
# File 'lib/prism/node.rb', line 16465 def write @write end |
Class Method Details
.type ⇒ Object
Return a symbol representation of this node type. See ‘Node::type`.
16478 16479 16480 |
# File 'lib/prism/node.rb', line 16478 def self.type :shareable_constant_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.
16484 16485 16486 16487 16488 |
# File 'lib/prism/node.rb', line 16484 def ===(other) other.is_a?(ShareableConstantNode) && (flags === other.flags) && (write === other.write) end |
#accept(visitor) ⇒ Object
def accept: (Visitor visitor) -> void
16417 16418 16419 |
# File 'lib/prism/node.rb', line 16417 def accept(visitor) visitor.visit_shareable_constant_node(self) end |
#child_nodes ⇒ Object Also known as: deconstruct
def child_nodes: () -> Array
16422 16423 16424 |
# File 'lib/prism/node.rb', line 16422 def child_nodes [write] end |
#comment_targets ⇒ Object
def comment_targets: () -> Array[Node | Location]
16432 16433 16434 |
# File 'lib/prism/node.rb', line 16432 def comment_targets [write] #: Array[Prism::node | Location] end |
#compact_child_nodes ⇒ Object
def compact_child_nodes: () -> Array
16427 16428 16429 |
# File 'lib/prism/node.rb', line 16427 def compact_child_nodes [write] end |
#copy(node_id: self.node_id, location: self.location, flags: self.flags, write: self.write) ⇒ Object
def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode) -> ShareableConstantNode
16437 16438 16439 |
# File 'lib/prism/node.rb', line 16437 def copy(node_id: self.node_id, location: self.location, flags: self.flags, write: self.write) ShareableConstantNode.new(source, node_id, location, flags, write) end |
#deconstruct_keys(keys) ⇒ Object
def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, write: ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode }
16445 16446 16447 |
# File 'lib/prism/node.rb', line 16445 def deconstruct_keys(keys) { node_id: node_id, location: location, write: write } end |
#experimental_copy? ⇒ Boolean
def experimental_copy?: () -> bool
16460 16461 16462 |
# File 'lib/prism/node.rb', line 16460 def experimental_copy? flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_COPY) end |
#experimental_everything? ⇒ Boolean
def experimental_everything?: () -> bool
16455 16456 16457 |
# File 'lib/prism/node.rb', line 16455 def experimental_everything? flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_EVERYTHING) end |
#inspect ⇒ Object
def inspect -> String
16468 16469 16470 |
# File 'lib/prism/node.rb', line 16468 def inspect InspectVisitor.compose(self) end |
#literal? ⇒ Boolean
def literal?: () -> bool
16450 16451 16452 |
# File 'lib/prism/node.rb', line 16450 def literal? flags.anybits?(ShareableConstantNodeFlags::LITERAL) end |
#type ⇒ Object
Return a symbol representation of this node type. See ‘Node#type`.
16473 16474 16475 |
# File 'lib/prism/node.rb', line 16473 def type :shareable_constant_node end |