Sha256: 77d5254a0bfe4befefb167c5bc2147f92786c78aef8b63046832004f8f324a73

Contents?: true

Size: 848 Bytes

Versions: 44

Compression:

Stored size: 848 Bytes

Contents

module Ruby2JS
  class Converter

    # (zsuper)
    # 
    # (super ...)

    handle :super, :zsuper do |*args|
      unless @class_parent and @instance_method
        raise NotImplementedError, "super outside of a method"
      end

      # what to pass
      if @ast.type == :zsuper
        if @instance_method.type == :method
          args = @instance_method.children[2].children[1].children
        elsif @instance_method.type == :prop
          args = nil
        else
          args = @instance_method.children[1].children
        end
      end

      parse @class_parent

      # what to call
      if @instance_method.type != :constructor
        puts  ".prototype.#{ @instance_method.children[1].to_s.chomp('=') }"
      end

      if args
        put '.call('; parse_all s(:self), *args, join: ', '; put ')'
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
ruby2js-2.1.24 lib/ruby2js/converter/super.rb
ruby2js-2.1.23 lib/ruby2js/converter/super.rb
ruby2js-2.1.22 lib/ruby2js/converter/super.rb
ruby2js-2.1.21 lib/ruby2js/converter/super.rb
ruby2js-2.1.20 lib/ruby2js/converter/super.rb
ruby2js-2.1.19 lib/ruby2js/converter/super.rb
ruby2js-2.1.18 lib/ruby2js/converter/super.rb
ruby2js-2.1.17 lib/ruby2js/converter/super.rb
ruby2js-2.1.16 lib/ruby2js/converter/super.rb
ruby2js-2.1.15 lib/ruby2js/converter/super.rb
ruby2js-2.1.14 lib/ruby2js/converter/super.rb
ruby2js-2.1.13 lib/ruby2js/converter/super.rb
ruby2js-2.1.12 lib/ruby2js/converter/super.rb
ruby2js-2.1.11 lib/ruby2js/converter/super.rb
ruby2js-2.1.10 lib/ruby2js/converter/super.rb
ruby2js-2.1.9 lib/ruby2js/converter/super.rb
ruby2js-2.1.8 lib/ruby2js/converter/super.rb
ruby2js-2.1.7 lib/ruby2js/converter/super.rb
ruby2js-2.1.6 lib/ruby2js/converter/super.rb
ruby2js-2.1.5 lib/ruby2js/converter/super.rb