Sha256: 7b177c1341856e9ff17eac443e2ae8defe9f08fc6b45e73cff8c68f5397bf90e
Contents?: true
Size: 977 Bytes
Versions: 7
Compression:
Stored size: 977 Bytes
Contents
# frozen_string_literal: true require 'opal/nodes/scope' module Opal module Nodes class ModuleNode < ScopeNode handle :module children :cid, :body def compile name, base = name_and_base helper :module push "(function($base, $parent_nesting) {" line " var $#{name}, self = $#{name} = $module($base, '#{name}');" in_scope do scope.name = name add_temp "#{scope.proto} = self.$$proto" add_temp '$nesting = [self].concat($parent_nesting)' body_code = stmt(body || s(:nil)) empty_line line scope.to_vars line body_code end line "})(", base, ", $nesting)" end # cid is always s(:const, scope_sexp_or_nil, :ConstName) def name_and_base base, name = cid.children if base.nil? [name, '$nesting[0]'] else [name, expr(base)] end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems