Sha256: 73a690477a5247b10b813de2ad7ee4bfa9ff20eca6bca874d6abd9dfac7f2874
Contents?: true
Size: 880 Bytes
Versions: 39
Compression:
Stored size: 880 Bytes
Contents
require 'opal/nodes/module' module Opal module Nodes class ClassNode < ModuleNode handle :class children :cid, :sup, :body def compile name, base = name_and_base helper :klass push "(function($base, $super) {" line " function $#{name}(){};" line " var self = $#{name} = $klass($base, $super, '#{name}', $#{name});" in_scope do scope.name = name add_temp "#{scope.proto} = self.$$proto" add_temp "$scope = self.$$scope" body_code = self.body_code empty_line line scope.to_vars line body_code end line "})(", base, ", ", self.super_code, ")" end def super_code sup ? expr(sup) : 'null' end def body_code stmt(compiler.returns(body || s(:nil))) end end end end
Version data entries
39 entries across 39 versions & 3 rubygems