123456789_123456789_123456789_123456789_123456789_

Class: Prism::DesugarOrWriteNode

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, DSL
Inherits: Object
Defined in: lib/prism/desugar_compiler.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(node, default_source, read_class, write_class, **arguments) ⇒ DesugarOrWriteNode

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 135

def initialize(node, default_source, read_class, write_class, **arguments)
  @node = node
  @default_source = default_source
  @read_class = read_class
  @write_class = write_class
  @arguments = arguments
end

Instance Attribute Details

#arguments (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 133

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#default_source (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 133

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#node (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 133

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#read_class (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 133

attr_reader :node, :default_source, :read_class, :write_class, :arguments

#write_class (readonly)

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 133

attr_reader :node, :default_source, :read_class, :write_class, :arguments

Instance Method Details

#compile

Desugar x ||= y to x || x = y

[ GitHub ]

  
# File 'lib/prism/desugar_compiler.rb', line 144

def compile
  or_node(
    location: node.location,
    left: public_send(read_class, location: node.name_loc, **arguments),
    right: public_send(
      write_class,
      location: node.location,
      **arguments,
      name_loc: node.name_loc,
      value: node.value,
      operator_loc: node.operator_loc
    ),
    operator_loc: node.operator_loc
  )
end