Class
DesugarCompiler
is a compiler that desugars Ruby code into a more primitive form. This is useful for consumers that want to deal with fewer node types.
Instance Methods
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 224
def visit_class_variable_and_write_node(node)
node.desugar
end
@@foo &&= bar
becomes
@@foo && @@foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 242
def visit_class_variable_operator_write_node(node)
node.desugar
end
@@foo += bar
becomes
@@foo = @@foo + bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 233
def visit_class_variable_or_write_node(node)
node.desugar
end
@@foo ||= bar
becomes
defined?(@@foo) ? @@foo : @@foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 251
def visit_constant_and_write_node(node)
node.desugar
end
Foo &&= bar
becomes
Foo && Foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 269
def visit_constant_operator_write_node(node)
node.desugar
end
Foo += bar
becomes
Foo = Foo + bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 260
def visit_constant_or_write_node(node)
node.desugar
end
Foo ||= bar
becomes
defined?(Foo) ? Foo : Foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 278
def visit_global_variable_and_write_node(node)
node.desugar
end
$foo &&= bar
becomes
$foo && $foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 296
def visit_global_variable_operator_write_node(node)
node.desugar
end
$foo += bar
becomes
$foo = $foo + bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 287
def visit_global_variable_or_write_node(node)
node.desugar
end
$foo ||= bar
becomes
defined?($foo) ? $foo : $foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 305
def visit_instance_variable_and_write_node(node)
node.desugar
end
@foo &&= bar
becomes
@foo && @foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 323
def visit_instance_variable_operator_write_node(node)
node.desugar
end
@foo += bar
becomes
@foo = @foo + bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 314
def visit_instance_variable_or_write_node(node)
node.desugar
end
@foo ||= bar
becomes
@foo || @foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 332
def visit_local_variable_and_write_node(node)
node.desugar
end
foo &&= bar
becomes
foo && foo = bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 350
def visit_local_variable_operator_write_node(node)
node.desugar
end
foo += bar
becomes
foo = foo + bar
lib/prism/desugar_compiler.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/desugar_compiler.rb, line 341
def visit_local_variable_or_write_node(node)
node.desugar
end
foo ||= bar
becomes
foo || foo = bar