Skip to content

Commit

Permalink
Add boot_module() to runtime as it differs from boot_class()
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 22, 2013
1 parent ccd4c23 commit 225fb45
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions corelib/runtime.js
Expand Up @@ -119,8 +119,7 @@
}
}
else {
klass = boot_class(ClassClass, constructor);
klass._proto = {_klass: klass};
klass = boot_module(ClassClass, constructor)
klass._name = (base === ObjectClass ? id : base._name + '::' + id);
klass._mod$ = true;

Expand All @@ -132,6 +131,33 @@
return klass;
};

function boot_module(superklass) {
// module itself
function OpalModule() {
this._id = unique_id++;
}

var mtor = function() {};
mtor.prototype = superklass.constructor.prototype;

OpalModule.prototype = new mtor();
var prototype = OpalModule.prototype;

prototype._alloc = constructor;
prototype._isClass = true;
prototype.constructor = OpalModule;
prototype._super = superklass;
prototype._methods = [];

var klass = new OpalModule();

// method table (_proto) for a module can be a simple js object as
// we dont inherit methods, and we dont ever instantialize it.
klass._proto = {};

return klass;
}

// Boot a base class (makes instances).
var boot_defclass = function(id, constructor, superklass) {
if (superklass) {
Expand Down

0 comments on commit 225fb45

Please sign in to comment.