Module: __JS__::Opal
- Defined in:
- opal/opal/corelib/runtime.js.rb
Overview
This module is just a placeholder for showing the documentation of the
internal JavaScript runtime. The methods you'll find defined below
are actually JavaScript functions attached to the Opal
global object
Class Method Summary collapse
-
.const_get_name ⇒ Object
Get the constant in the scope of the current cref.
-
.const_lookup_ancestors ⇒ Object
Walk up the ancestors chain looking for the constant.
-
.const_lookup_nesting ⇒ Object
Walk up the nesting array looking for the constant.
-
.const_lookup_Object ⇒ Object
Walk up Object's ancestors chain looking for the constant, but only if cref is missing or a module.
-
.const_missing ⇒ Object
Call const_missing if nothing else worked.
-
.create_dummy_iclass ⇒ Object
Dummy iclass doesn't receive updates when the module gets a new method.
-
.top_define_method ⇒ Object
Foward calls to define_method on the top object to Object.
Class Method Details
.const_get_name ⇒ Object
Get the constant in the scope of the current cref
7 8 9 10 11 12 13 |
# File 'opal/opal/corelib/runtime.js.rb', line 7 def self.const_get_name(*) <<-JAVASCRIPT function const_get_name(cref, name) { if (cref) return cref.$$const[name]; } JAVASCRIPT end |
.const_lookup_ancestors ⇒ Object
Walk up the ancestors chain looking for the constant
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'opal/opal/corelib/runtime.js.rb', line 36 def self.const_lookup_ancestors(*) <<-JAVASCRIPT function const_lookup_ancestors(cref, name) { var i, ii, ancestors; if (cref == null) return; ancestors = Opal.ancestors(cref); for (i = 0, ii = ancestors.length; i < ii; i++) { if (ancestors[i].$$const && $has_own.call(ancestors[i].$$const, name)) { return ancestors[i].$$const[name]; } } } JAVASCRIPT end |
.const_lookup_nesting ⇒ Object
Walk up the nesting array looking for the constant
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'opal/opal/corelib/runtime.js.rb', line 17 def self.const_lookup_nesting(*) <<-JAVASCRIPT function const_lookup_nesting(nesting, name) { var i, ii, constant; if (nesting.length === 0) return; // If the nesting is not empty the constant is looked up in its elements // and in order. The ancestors of those elements are ignored. for (i = 0, ii = nesting.length; i < ii; i++) { constant = nesting[i].$$const[name]; if (constant != null) return constant; } } JAVASCRIPT end |
.const_lookup_Object ⇒ Object
Walk up Object's ancestors chain looking for the constant, but only if cref is missing or a module.
57 58 59 60 61 62 63 64 65 |
# File 'opal/opal/corelib/runtime.js.rb', line 57 def self.const_lookup_Object(*) <<-JAVASCRIPT function const_lookup_Object(cref, name) { if (cref == null || cref.$$is_module) { return const_lookup_ancestors(_Object, name); } } JAVASCRIPT end |
.const_missing ⇒ Object
Call const_missing if nothing else worked
69 70 71 72 73 74 75 76 77 |
# File 'opal/opal/corelib/runtime.js.rb', line 69 def self.const_missing(*) <<-JAVASCRIPT function const_missing(cref, name, skip_missing) { if (!skip_missing) { return (cref || _Object).$const_missing(name); } } JAVASCRIPT end |
.create_dummy_iclass ⇒ Object
Dummy iclass doesn't receive updates when the module gets a new method.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'opal/opal/corelib/runtime.js.rb', line 81 def self.create_dummy_iclass(*) <<-JAVASCRIPT function create_dummy_iclass(module) { var iclass = {}, proto = module.$$prototype; if (proto.hasOwnProperty('$$dummy')) { proto = proto.$$define_methods_on; } var props = Object.getOwnPropertyNames(proto), length = props.length, i; for (i = 0; i < length; i++) { var prop = props[i]; $defineProperty(iclass, prop, proto[prop]); } $defineProperty(iclass, '$$iclass', true); $defineProperty(iclass, '$$module', module); return iclass; } JAVASCRIPT end |
.top_define_method ⇒ Object
Foward calls to define_method on the top object to Object
109 110 111 112 113 114 115 116 117 118 |
# File 'opal/opal/corelib/runtime.js.rb', line 109 def self.top_define_method(*) <<-JAVASCRIPT function top_define_method() { var args = Opal.slice.call(arguments, 0, arguments.length); var block = top_define_method.$$p; top_define_method.$$p = null; return Opal.send(_Object, 'define_method', args, block) }; JAVASCRIPT end |