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

Desugar ‘x &&= y` to `x && x = y`

Desugar ‘x += y` to `x = x + y`

Desugar ‘x ||= y` to `defined?(x) ? x : x = y`

Desugar ‘x ||= y` to `x || x = y`

@@foo &&= bar

becomes

@@foo && @@foo = bar

@@foo += bar

becomes

@@foo = @@foo + bar

@@foo ||= bar

becomes

defined?(@@foo) ? @@foo : @@foo = bar

Foo &&= bar

becomes

Foo && Foo = bar

Foo += bar

becomes

Foo = Foo + bar

Foo ||= bar

becomes

defined?(Foo) ? Foo : Foo = bar

$foo &&= bar

becomes

$foo && $foo = bar

$foo += bar

becomes

$foo = $foo + bar

$foo ||= bar

becomes

defined?($foo) ? $foo : $foo = bar

@foo &&= bar

becomes

@foo && @foo = bar

@foo += bar

becomes

@foo = @foo + bar

@foo ||= bar

becomes

@foo || @foo = bar

foo &&= bar

becomes

foo && foo = bar

foo += bar

becomes

foo = foo + bar

foo ||= bar

becomes

foo || foo = bar