Skip to content

Commit

Permalink
[js] Set the method_cache on a knowhow metaobj to make nqp::can work.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Oct 27, 2015
1 parent a23e6c1 commit a513828
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/vm/js/nqp-runtime/bootstrap.js
Expand Up @@ -6,6 +6,8 @@ var STable = require('./sixmodel.js').STable;

var repr = new reprs.KnowHOWREPR();

var CodeRef = require('./code-ref.js');

var core = new SerializationContext('__6MODEL_CORE__');
core.description = 'core SC';

Expand Down Expand Up @@ -65,10 +67,25 @@ KnowHOW_HOW.id = 'KnowHOW_HOW';
KnowHOW._STable.id = 'KnowHOW';
KnowHOW._STable.HOW = KnowHOW_HOW;

KnowHOW._STable.method_cache = {};
KnowHOW_HOW._STable.method_cache = {};

function add_knowhow_how_method(name, method) {
/* TODO - think if setting the object cache would be better */
var code_ref = new CodeRef(name);
code_ref.$call = function(ctx, _NAMED, self) {
var args = Array.prototype.slice.call(arguments, 3);
args.unshift(ctx);
args.unshift(_NAMED);

return method.apply(self, args);
};

KnowHOW_HOW._STable.obj_constructor.prototype[name] = method;
KnowHOW._STable.obj_constructor.prototype[name] = method;

KnowHOW._STable.method_cache[name] = code_ref;
KnowHOW_HOW._STable.method_cache[name] = method;
}

add_knowhow_how_method('name', function() {
Expand Down

0 comments on commit a513828

Please sign in to comment.