123456789_123456789_123456789_123456789_123456789_

Class: Prism::ShareableConstantNode

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, PrismNode
Instance Chain:
self, PrismNode
Inherits: PrismNode
  • ::Object
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 }
^^^^^^^^^^^^

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(source, node_id, location, flags, write) ⇒ ShareableConstantNode

Initialize a new ShareableConstantNode node.

[ GitHub ]

  
# 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

Class Method Details

.type

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

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14463

def self.type
  :shareable_constant_node
end

Instance Attribute Details

#experimental_copy? ⇒ Boolean (readonly)

def experimental_copy?: () -> bool

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14446

def experimental_copy?
  flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_COPY)
end

#experimental_everything? ⇒ Boolean (readonly)

def experimental_everything?: () -> bool

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14441

def experimental_everything?
  flags.anybits?(ShareableConstantNodeFlags::EXPERIMENTAL_EVERYTHING)
end

#literal? ⇒ Boolean (readonly)

def literal?: () -> bool

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14436

def literal?
  flags.anybits?(ShareableConstantNodeFlags::LITERAL)
end

#write (readonly)

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

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14451

attr_reader :write

Instance Method Details

#===(other)

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

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14469

def ===(other)
  other.is_a?(ShareableConstantNode) &&
    (flags === other.flags) &&
    (write === other.write)
end

#accept(visitor)

def accept: (Visitor visitor) -> void

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14403

def accept(visitor)
  visitor.visit_shareable_constant_node(self)
end

#child_nodes Also known as: #deconstruct

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

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14408

def child_nodes
  [write]
end

#comment_targets

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

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14418

def comment_targets
  [write] #: Array[Prism::node | Location]
end

#compact_child_nodes

def compact_child_nodes: () -> Array

[ GitHub ]

  
# 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)

[ GitHub ]

  
# 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

Alias for #child_nodes.

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14428

alias deconstruct child_nodes

#deconstruct_keys(keys)

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14431

def deconstruct_keys(keys)
  { node_id: node_id, location: location, write: write }
end

#inspect

def inspect -> String

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14453

def inspect
  InspectVisitor.compose(self)
end

#type

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

[ GitHub ]

  
# File 'lib/prism/node.rb', line 14458

def type
  :shareable_constant_node
end