Sha256: 929fcc0661ab92dcb03fd5563c0d7fe90198d51236a7a32da1c2fee8623829bf

Contents?: true

Size: 690 Bytes

Versions: 92

Compression:

Stored size: 690 Bytes

Contents

require 'ruby2js'

module Ruby2JS
  module Filter
    module Return
      include SEXP

      EXPRESSIONS = [ :array, :float, :hash, :if, :int, :lvar, :nil, :send ]

      def on_block(node)
        children = process_all(node.children)

        children[-1] = s(:nil) if children.last == nil

        node.updated nil, [*node.children[0..1],
          s(:autoreturn, *children[2..-1])]
      end

      def on_def(node)
        children = process_all(node.children[1..-1])

        children[-1] = s(:nil) if children.last == nil

        node.updated nil, [node.children[0], children.first,
          s(:autoreturn, *children[1..-1])]
      end
    end

    DEFAULTS.push Return
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
ruby2js-2.0.10 lib/ruby2js/filter/return.rb
ruby2js-2.0.9 lib/ruby2js/filter/return.rb
ruby2js-2.0.8 lib/ruby2js/filter/return.rb
ruby2js-2.0.7 lib/ruby2js/filter/return.rb
ruby2js-2.0.6 lib/ruby2js/filter/return.rb
ruby2js-2.0.5 lib/ruby2js/filter/return.rb
ruby2js-2.0.4 lib/ruby2js/filter/return.rb
ruby2js-2.0.3 lib/ruby2js/filter/return.rb
ruby2js-2.0.2 lib/ruby2js/filter/return.rb
ruby2js-2.0.1 lib/ruby2js/filter/return.rb
ruby2js-2.0.0 lib/ruby2js/filter/return.rb
ruby2js-1.15.1 lib/ruby2js/filter/return.rb
ruby2js-1.15.0 lib/ruby2js/filter/return.rb
ruby2js-1.14.1 lib/ruby2js/filter/return.rb
ruby2js-1.14.0 lib/ruby2js/filter/return.rb
ruby2js-1.13.1 lib/ruby2js/filter/return.rb
ruby2js-1.13.0 lib/ruby2js/filter/return.rb
ruby2js-1.12.2 lib/ruby2js/filter/return.rb
ruby2js-1.12.1 lib/ruby2js/filter/return.rb
ruby2js-1.12.0 lib/ruby2js/filter/return.rb