class Prism::ShareableConstantNode - Documentation for Ruby 4.0
Description: class Prism::ShareableConstantNode: This node wraps a constant write to indicate that when the value is written, it should have its shareability state modified.
Keywords: ruby,class,Prism::ShareableConstantNode

🔍

No recent searches

# class Prism::ShareableConstantNode

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 }
    ^^^^^^^^^^^^

### Attributes

write [R]

The constant write that should be modified with the shareability state.

### Public Class Methods

new (source, node_id, location, flags, write)
Source

    # File lib/prism/node.rb, line 17422
    def initialize(source, node_id, location, flags, write)
      @source = source
      @node_id = node_id
      @location = location
      @flags = flags
      @write = write
    end

Initialize a new `ShareableConstantNode` node.

type ()
Source

    # File lib/prism/node.rb, line 17499
    def self.type
      :shareable_constant_node
    end

Return a symbol representation of this node type. See `Node::type`.

### Public Instance Methods

=== (other)
Source

    # File lib/prism/node.rb, line 17505
    def ===(other)
      other.is_a?(ShareableConstantNode) &&
        (flags === other.flags) &&
        (write === other.write)
    end

Implements case-equality for the node. This is effectively == but without comparing the value of locations. Locations are checked only for presence.

accept (visitor)
Source

    # File lib/prism/node.rb, line 17431
    def accept(visitor)
      visitor.visit_shareable_constant_node(self)
    end

def accept: (`Visitor` visitor) -> void

child_nodes ()
Source

    # File lib/prism/node.rb, line 17436
    def child_nodes
      [write]
    end

def `child_nodes`: () -> Array

Also aliased as: deconstruct
comment_targets ()
Source

    # File lib/prism/node.rb, line 17453
    def comment_targets
      [write] #: Array[Prism::node | Location]
    end

def `comment_targets`: () -> Array[Node | Location]

compact_child_nodes ()
Source

    # File lib/prism/node.rb, line 17448
    def compact_child_nodes
      [write]
    end

def `compact_child_nodes`: () -> Array

copy (node_id: self.node_id, location: self.location, flags: self.flags, write: self.write)
Source

    # File lib/prism/node.rb, line 17458
    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

def copy: (?node_id: `Integer`, ?location: `Location`, ?flags: `Integer`, ?write: `ConstantWriteNode` | `ConstantAndWriteNode` | `ConstantOrWriteNode` | `ConstantOperatorWriteNode` | `ConstantPathWriteNode` | `ConstantPathAndWriteNode` | `ConstantPathOrWriteNode` | `ConstantPathOperatorWriteNode`) -> `ShareableConstantNode`

deconstruct ()

def deconstruct: () -> Array

Alias for: child_nodes
deconstruct_keys (keys)
Source

    # File lib/prism/node.rb, line 17466
    def deconstruct_keys(keys)
      { node_id: node_id, location: location, write: write }
    end

def `deconstruct_keys`: (Array keys) -> { node_id: `Integer`, location: `Location`, write: `ConstantWriteNode` | `ConstantAndWriteNode` | `ConstantOrWriteNode` | `ConstantOperatorWriteNode` | `ConstantPathWriteNode` | `ConstantPathAndWriteNode` | `ConstantPathOrWriteNode` | `ConstantPathOperatorWriteNode` }

each_child_node () { |write| ... }
Source

    # File lib/prism/node.rb, line 17441
    def each_child_node
      return to_enum(:each_child_node) unless block_given?

      yield write
    end

def `each_child_node`: () { (Prism::node) -> void } -> void | () -> Enumerator

experimental_copy? ()
Source

    # File lib/prism/node.rb, line 17481
    def experimental_copy?
      flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_COPY)
    end

def experimental_copy?: () -> bool

experimental_everything? ()
Source

    # File lib/prism/node.rb, line 17476
    def experimental_everything?
      flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_EVERYTHING)
    end

def experimental_everything?: () -> bool

inspect ()
Source

    # File lib/prism/node.rb, line 17489
    def inspect
      InspectVisitor.compose(self)
    end

def inspect -> `String`

literal? ()
Source

    # File lib/prism/node.rb, line 17471
    def literal?
      flags.anybits?(ShareableConstantNodeFlags::LITERAL)
    end

def literal?: () -> bool

type ()
Source

    # File lib/prism/node.rb, line 17494
    def type
      :shareable_constant_node
    end

Return a symbol representation of this node type. See `Node#type`.