class Prism::ShareableConstantNode - Documentation for Ruby 4.1
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 }
    ^^^^^^^^^^^^

### Public Class Methods

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

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

### Public Instance Methods

write → ConstantWriteNode | ConstantAndWriteNode | ConstantOrWriteNode | ConstantOperatorWriteNode | ConstantPathWriteNode | ConstantPathAndWriteNode | ConstantPathOrWriteNode | ConstantPathOperatorWriteNode
Source

    # File lib/prism/node.rb, line 28015
    def write
      @write
    end

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

## Flags

### Public Instance Methods

experimental_copy? ()
Source

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

constant writes that should be modified with shareable constant value experimental copy

experimental_everything? ()
Source

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

constant writes that should be modified with shareable constant value experimental everything

literal? ()
Source

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

constant writes that should be modified with shareable constant value literal

## Node Interface

These methods are present on all subclasses of `Node`. Read the node interface docs for more information.

### Public Class Methods

type ()
Source

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

See `Node.type`.

### Public Instance Methods

accept (visitor)
Source

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

See `Node.accept`.

child_nodes ()
Source

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

See `Node.child_nodes`.

Also aliased as: deconstruct
comment_targets ()
Source

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

See `Node.comment_targets`.

compact_child_nodes ()
Source

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

See `Node.compact_child_nodes`.

copy(**fields) → ShareableConstantNode
Source

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

Creates a copy of self with the given fields, using self as the template.

deconstruct ()
Alias for: child_nodes
each_child_node () { |write| ... }
Source

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

      yield write
    end

See `Node.each_child_node`.

type ()
Source

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

See `Node#type`.

## Repository

Methods related to `Relocation`.

## Slicing