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: 53b1a02cdcc0
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2f9235a05939
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Sep 27, 2014

  1. Copy the full SHA
    de6eb6c View commit details
  2. Copy the full SHA
    2f9235a View commit details
Showing with 28 additions and 22 deletions.
  1. +1 −15 opal/corelib/kernel.rb
  2. +27 −7 opal/corelib/runtime.js
16 changes: 1 addition & 15 deletions opal/corelib/kernel.rb
Original file line number Diff line number Diff line change
@@ -515,21 +515,7 @@ def singleton_class
}
if (self.$$is_class) {
var meta = new $opal.Class.$$alloc;
meta.$$class = $opal.Class;
// FIXME - is this right? (probably - methods defined on
// class' singleton should also go to subclasses?)
//
// @elia says: Actually a class' singleton inherits from its superclass'
// singleton that in turn inherits from Class;
meta.$$proto = self.constructor.prototype;
meta.$$is_singleton = true;
meta.$$inc = [];
meta.$$methods = [];
meta.$$scope = self.$$scope;
return $opal.build_class_singleton_class(self);
}
else {
34 changes: 27 additions & 7 deletions opal/corelib/runtime.js
Original file line number Diff line number Diff line change
@@ -181,11 +181,11 @@
*/
function boot_class_object(superklass, alloc) {
//
var mtor = function() {};
mtor.prototype = superklass.constructor.prototype;
var singleton_class = function() {};
singleton_class.prototype = superklass.constructor.prototype;

function OpalClass() {}
OpalClass.prototype = new mtor();
OpalClass.prototype = new singleton_class();

var klass = new OpalClass();

@@ -306,6 +306,26 @@
return module;
}

/*
* Build the singleton class for an existing class.
*
* NOTE: Actually in MRI a class' singleton class inherits from its
* superclass' singleton class which in turn inherits from Class;
*/
Opal.build_class_singleton_class = function (klass) {
var meta = new $opal.Class.$$alloc;
meta.$$class = $opal.Class;

meta.$$proto = klass.constructor.prototype;

meta.$$is_singleton = true;
meta.$$inc = [];
meta.$$methods = [];
meta.$$scope = klass.$$scope;

return meta;
}

Opal.append_features = function(module, klass) {
var included = klass.$$inc;

@@ -376,12 +396,12 @@
// Boot the actual (meta?) classes of core classes
function boot_makemeta(id, constructor, superklass) {

var mtor = function() {};
mtor.prototype = superklass.prototype;
mtor.displayName = id;
var singleton_class = function() {};
singleton_class.prototype = superklass.prototype;
singleton_class.displayName = id;

function OpalClass() {}
OpalClass.prototype = new mtor();
OpalClass.prototype = new singleton_class();

var klass = new OpalClass();