Sha256: 47cd11a04d65731729a0db27ce7ae257bdebfdce3ca6ccaa9fea78481600245b

Contents?: true

Size: 1 KB

Versions: 16

Compression:

Stored size: 1 KB

Contents

module Ruby2JS
  class Converter

    # (kwbegin
    #   (ensure
    #     (rescue
    #      (send nil :a)
    #      (resbody nil nil
    #        (send nil :b)) nil)
    #    (send nil :c)))

    handle :kwbegin do |*children|
      block = children.first
      if block.type == :ensure
        block, finally = block.children
      else
        finally = nil
      end

      if block and block.type == :rescue
        body, recover, otherwise = block.children
        raise NotImplementedError, "block else" if otherwise
        exception, name, recovery = recover.children
        raise NotImplementedError, parse(exception) if exception
      else
        body = block
      end

      output = "try {#@nl#{ parse body }#@nl}"

      if recovery
        output += " catch (#{ parse name }) {#@nl#{ parse recovery }#@nl}"
      end

      output += " finally {#@nl#{ parse finally }#@nl}" if finally

      if recovery or finally
        output
      else
        parse s(:begin, *children)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ruby2js-1.9.2 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.9.1 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.9.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.8.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.7.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.6.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.5.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.4.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.3.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.2.0 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.1.5 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.1.4 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.1.3 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.1.2 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.1.1 lib/ruby2js/converter/kwbegin.rb
ruby2js-1.1.0 lib/ruby2js/converter/kwbegin.rb