Skip to content

Commit

Permalink
Use IClass for searching up super() tree
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Sep 25, 2013
1 parent 2f65eed commit e1f587d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion corelib/kernel.rb
Expand Up @@ -107,7 +107,7 @@ def define_singleton_method(name, &body)

def dup
copy = self.class.allocate

%x{
for (var name in #{self}) {
if (name.charAt(0) !== '$') {
Expand Down
10 changes: 10 additions & 0 deletions corelib/module.rb
Expand Up @@ -78,6 +78,16 @@ def append_features(klass)
module.__dep__.push(klass);
// iclass
var iclass = {
_proto: module._proto,
__parent: klass.__parent,
name: module._name,
__iclass: true
};
klass.__parent = iclass;
var donator = module._proto,
prototype = klass._proto,
methods = module._methods;
Expand Down
25 changes: 7 additions & 18 deletions corelib/runtime.js
Expand Up @@ -242,28 +242,18 @@
result._proto = constructor.prototype;

return result;

return constructor;
};

var bridge_class = function(name, constructor) {
var klass = boot_class(ObjectClass, constructor);
var i, length, m;

constructor.prototype.constructor = constructor;

constructor._super = Object;
constructor.constructor = Class;
constructor._methods = [];
constructor.__inc__ = [];
var klass = boot_class(ObjectClass, constructor), idx, length, mid;

bridged_classes.push(klass);

var table = ObjectClass._proto, methods = ObjectClass._methods;

for (i = 0, length = methods.length; i < length; i++) {
m = methods[i];
constructor.prototype[m] = table[m];
for (idx = 0, len = methods.length; idx < len; idx++) {
mid = methods[idx];
constructor.prototype[mid] = table[mid];
}

klass._name = name;
Expand Down Expand Up @@ -336,9 +326,6 @@
var find_obj_super_dispatcher = function(obj, jsid, current_func) {
var klass = obj._klass;

// current method we are inside
var current;

while (klass) {
if (klass._proto['$' + jsid] === current_func) {
// ok
Expand All @@ -357,7 +344,9 @@

// else, let's find the next one
while (klass) {
if (klass._proto['$' + jsid]) {
var working = klass._proto['$' + jsid];

if (working && working !== current_func) {
// ok
break;
}
Expand Down

0 comments on commit e1f587d

Please sign in to comment.