Sha256: d682b278bbb63ca241fa0ad10f7ca07c567eb5ce1e311f1e7917e46583b5a5d8

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 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 call
      if @instance_method.type == :method
        method = ".prototype.#{ @instance_method.children[1].to_s.chomp('=') }"
      else
        method = ''
      end

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

      args = [s(:self), *args].map {|arg| parse arg}.join(', ')
      "#{ parse @class_parent }#{ method }.call(#{ args })"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby2js-1.6.0 lib/ruby2js/converter/super.rb