Class: Prism::DesugarOperatorWriteNode
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
- #arguments readonly
- #default_source readonly
- #node readonly
- #read_class readonly
- #write_class readonly
Instance Method Summary
-
#compile
Desugar
x += y
tox = x + y
.
Constructor Details
.new(node, default_source, read_class, write_class, **arguments) ⇒ DesugarOperatorWriteNode
# File 'lib/prism/desugar_compiler.rb', line 91
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 89
attr_reader :node, :default_source, :read_class, :write_class, :arguments
#default_source (readonly)
[ GitHub ]# File 'lib/prism/desugar_compiler.rb', line 89
attr_reader :node, :default_source, :read_class, :write_class, :arguments
#node (readonly)
[ GitHub ]# File 'lib/prism/desugar_compiler.rb', line 89
attr_reader :node, :default_source, :read_class, :write_class, :arguments
#read_class (readonly)
[ GitHub ]# File 'lib/prism/desugar_compiler.rb', line 89
attr_reader :node, :default_source, :read_class, :write_class, :arguments
#write_class (readonly)
[ GitHub ]# File 'lib/prism/desugar_compiler.rb', line 89
attr_reader :node, :default_source, :read_class, :write_class, :arguments
Instance Method Details
#compile
Desugar x += y
to x = x + y
# File 'lib/prism/desugar_compiler.rb', line 100
def compile binary_operator_loc = node.binary_operator_loc.chop public_send( write_class, location: node.location, **arguments, name_loc: node.name_loc, value: call_node( location: node.location, receiver: public_send( read_class, location: node.name_loc, **arguments ), name: binary_operator_loc.slice.to_sym, message_loc: binary_operator_loc, arguments: arguments_node( location: node.value.location, arguments: [node.value] ) ), operator_loc: node.binary_operator_loc.copy( start_offset: node.binary_operator_loc.end_offset - 1, length: 1 ) ) end