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) click to toggle source

Initialize a new ShareableConstantNode node.

# File lib/prism/node.rb, line 14394
def initialize(source, node_id, location, flags, write)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @write = write
end
type() click to toggle source

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

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

Public Instance Methods

===(other) click to toggle source

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

# File lib/prism/node.rb, line 14469
def ===(other)
  other.is_a?(ShareableConstantNode) &&
    (flags === other.flags) &&
    (write === other.write)
end
accept(visitor) click to toggle source

def accept: (Visitor visitor) -> void

# File lib/prism/node.rb, line 14403
def accept(visitor)
  visitor.visit_shareable_constant_node(self)
end
child_nodes() click to toggle source

def child_nodes: () -> Array[nil | Node]

# File lib/prism/node.rb, line 14408
def child_nodes
  [write]
end
Also aliased as: deconstruct
comment_targets() click to toggle source

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

# File lib/prism/node.rb, line 14418
def comment_targets
  [write] #: Array[Prism::node | Location]
end
compact_child_nodes() click to toggle source

def compact_child_nodes: () -> Array

# File lib/prism/node.rb, line 14413
def compact_child_nodes
  [write]
end
copy(node_id: self.node_id, location: self.location, flags: self.flags, write: self.write) click to toggle source

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

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

def deconstruct: () -> Array[nil | Node]

Alias for: child_nodes
deconstruct_keys(keys) click to toggle source

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

# File lib/prism/node.rb, line 14431
def deconstruct_keys(keys)
  { node_id: node_id, location: location, write: write }
end
experimental_copy?() click to toggle source

def experimental_copy?: () -> bool

# File lib/prism/node.rb, line 14446
def experimental_copy?
  flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_COPY)
end
experimental_everything?() click to toggle source

def experimental_everything?: () -> bool

# File lib/prism/node.rb, line 14441
def experimental_everything?
  flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_EVERYTHING)
end
inspect() click to toggle source

def inspect -> String

# File lib/prism/node.rb, line 14453
def inspect
  InspectVisitor.compose(self)
end
literal?() click to toggle source

def literal?: () -> bool

# File lib/prism/node.rb, line 14436
def literal?
  flags.anybits?(ShareableConstantNodeFlags::LITERAL)
end
type() click to toggle source

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

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