Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5913b8d5c5dd
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e23773415a82
Choose a head ref
  • 4 commits
  • 1 file changed
  • 1 contributor

Commits on Sep 1, 2014

  1. Copy the full SHA
    db33eb0 View commit details
  2. Cleanup code layout of runtime

    elia committed Sep 1, 2014
    Copy the full SHA
    d894620 View commit details
  3. Expose bridged classes list

    elia committed Sep 1, 2014

    Verified

    This commit was signed with the committer’s verified signature.
    eadwu Edmund Wu
    Copy the full SHA
    713b7c2 View commit details
  4. Missing comments and semicolons

    elia committed Sep 1, 2014

    Verified

    This commit was signed with the committer’s verified signature.
    eadwu Edmund Wu
    Copy the full SHA
    e237734 View commit details
Showing with 62 additions and 60 deletions.
  1. +62 −60 opal/corelib/runtime.js
122 changes: 62 additions & 60 deletions opal/corelib/runtime.js
Original file line number Diff line number Diff line change
@@ -2,35 +2,8 @@
// The Opal object that is exposed globally
var Opal = this.Opal = {};

// The actual class for BasicObject
var RubyBasicObject;

// The actual Object class
var RubyObject;

// The actual Module class
var RubyModule;

// The actual Class class
var RubyClass;

// Constructor for instances of BasicObject
function BasicObject(){}

// Constructor for instances of Object
function Object(){}

// Constructor for instances of Class
function Class(){}

// Constructor for instances of Module
function Module(){}

// Constructor for instances of NilClass (nil)
function NilClass(){}

// All bridged classes - keep track to donate methods from Object
var bridged_classes = [];
var bridged_classes = Opal.bridged_classes = [];

// TopScope is used for inheriting constants from the top scope
var TopScope = function(){};
@@ -39,8 +12,9 @@
TopScope.prototype = Opal;

// To inherit scopes
Opal.constructor = TopScope;
Opal.constructor = TopScope;

// List top scope constants
Opal.constants = [];

// This is a useful reference to global object inside ruby files
@@ -64,6 +38,7 @@
// Globals table
Opal.gvars = {};

// Get constants
Opal.get = function(name) {
var constant = this[name];

@@ -454,7 +429,7 @@
var stub = stubs[i];

for (var j = 0; j < subscribers.length; j++) {
subscriber = subscribers[j]
subscriber = subscribers[j];
if (!subscriber[stub]) {
subscriber[stub] = true;
add_stub_for(subscriber, stub);
@@ -468,7 +443,7 @@
*
* @default [Prototype List] BasicObject.prototype
*/
Opal.stub_subscribers = [BasicObject.prototype]
Opal.stub_subscribers = [BasicObject.prototype];

/*
* Actually add a method_missing stub function to the given prototype for the
@@ -867,7 +842,7 @@
};


// Module loading
// Require system
// --------------

Opal.mark_as_loaded = function(filename) {
@@ -878,7 +853,7 @@
} else {
return false;
}
}
};
Opal.loaded_features = ['corelib/runtime.js'];
Opal.require_table = {'corelib/runtime.js': true};
Opal.modules = {};
@@ -916,45 +891,74 @@
// Initialization
// --------------

// The actual class for BasicObject
var RubyBasicObject;

// The actual Object class
var RubyObject;

// The actual Module class
var RubyModule;

// The actual Class class
var RubyClass;

// Constructor for instances of BasicObject
function BasicObject(){}

// Constructor for instances of Object
function Object(){}

// Constructor for instances of Class
function Class(){}

// Constructor for instances of Module
function Module(){}

// Constructor for instances of NilClass (nil)
function NilClass(){}

// Constructors for *instances* of core objects
// (id, constructor, superklass)
boot_defclass('BasicObject', BasicObject);
boot_defclass('Object', Object, BasicObject);
boot_defclass('Module', Module, Object);
boot_defclass('Class', Class, Module);
boot_defclass('Object', Object, BasicObject);
boot_defclass('Module', Module, Object);
boot_defclass('Class', Class, Module);

// Constructors for *classes* of core objects
// boot_makemeta(id, constructor, superklass)
RubyBasicObject = boot_makemeta('BasicObject', BasicObject, Class);
RubyObject = boot_makemeta('Object', Object, RubyBasicObject.constructor);
RubyModule = boot_makemeta('Module', Module, RubyObject.constructor);
RubyClass = boot_makemeta('Class', Class, RubyModule.constructor);
RubyObject = boot_makemeta('Object', Object, RubyBasicObject.constructor);
RubyModule = boot_makemeta('Module', Module, RubyObject.constructor);
RubyClass = boot_makemeta('Class', Class, RubyModule.constructor);

// Fix booted classes to use their metaclass
RubyBasicObject._klass = RubyClass;
RubyObject._klass = RubyClass;
RubyModule._klass = RubyClass;
RubyClass._klass = RubyClass;
RubyObject._klass = RubyClass;
RubyModule._klass = RubyClass;
RubyClass._klass = RubyClass;

// Fix superclasses of booted classes
RubyBasicObject._super = null;
RubyObject._super = RubyBasicObject;
RubyModule._super = RubyObject;
RubyClass._super = RubyModule;
RubyObject._super = RubyBasicObject;
RubyModule._super = RubyObject;
RubyClass._super = RubyModule;

// Internally, Object acts like a module as it is "included" into bridged
// classes. In other words, we donate methods from Object into our bridged
// classes as their prototypes don't inherit from our root Object, so they
// act like module includes.
RubyObject.__dep__ = bridged_classes;

Opal.base = RubyObject;
RubyBasicObject._scope = RubyObject._scope = Opal;
Opal.base = RubyObject;
RubyBasicObject._scope = RubyObject._scope = Opal;
RubyBasicObject._orig_scope = RubyObject._orig_scope = Opal;
Opal.Kernel = RubyObject;
Opal.Kernel = RubyObject;

RubyModule._scope = RubyObject._scope;
RubyClass._scope = RubyObject._scope;
RubyModule._scope = RubyObject._scope;
RubyModule._orig_scope = RubyObject._orig_scope;
RubyClass._orig_scope = RubyObject._orig_scope;
RubyClass._scope = RubyObject._scope;
RubyClass._orig_scope = RubyObject._orig_scope;

RubyObject._proto.toString = function() {
return this.$to_s();
@@ -972,18 +976,16 @@
Opal.breaker = new Error('unexpected break');
Opal.returner = new Error('unexpected return');

bridge_class('Array', Array);
bridge_class('Boolean', Boolean);
bridge_class('Numeric', Number);
bridge_class('String', String);
bridge_class('Proc', Function);
bridge_class('Array', Array);
bridge_class('Boolean', Boolean);
bridge_class('Numeric', Number);
bridge_class('String', String);
bridge_class('Proc', Function);
bridge_class('Exception', Error);
bridge_class('Regexp', RegExp);
bridge_class('Time', Date);
bridge_class('Regexp', RegExp);
bridge_class('Time', Date);

TypeError._super = Error;


}).call(this);

if (typeof(global) !== 'undefined') {