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-3.0.6 lib/ruby2js/filter/return.rb
ruby2js-3.0.5 lib/ruby2js/filter/return.rb
ruby2js-3.0.4 lib/ruby2js/filter/return.rb
ruby2js-3.0.3 lib/ruby2js/filter/return.rb
ruby2js-3.0.2 lib/ruby2js/filter/return.rb
ruby2js-3.0.1 lib/ruby2js/filter/return.rb
ruby2js-3.0.0 lib/ruby2js/filter/return.rb
ruby2js-2.1.24 lib/ruby2js/filter/return.rb
ruby2js-2.1.23 lib/ruby2js/filter/return.rb
ruby2js-2.1.22 lib/ruby2js/filter/return.rb
ruby2js-2.1.21 lib/ruby2js/filter/return.rb
ruby2js-2.1.20 lib/ruby2js/filter/return.rb
ruby2js-2.1.19 lib/ruby2js/filter/return.rb
ruby2js-2.1.18 lib/ruby2js/filter/return.rb
ruby2js-2.1.17 lib/ruby2js/filter/return.rb
ruby2js-2.1.16 lib/ruby2js/filter/return.rb
ruby2js-2.1.15 lib/ruby2js/filter/return.rb
ruby2js-2.1.14 lib/ruby2js/filter/return.rb
ruby2js-2.1.13 lib/ruby2js/filter/return.rb
ruby2js-2.1.12 lib/ruby2js/filter/return.rb