Improve demangling of class methods when using the loader (#363)

This commit is contained in:
kazuya kawaguchi
2018-12-08 01:20:28 +09:00
committed by Daniel Wirtz
parent 934f05eed9
commit 429435c5b1
2 changed files with 21 additions and 3 deletions

View File

@ -265,7 +265,7 @@ function demangle(exports, baseModule) {
let classElem = curr[className];
if (typeof classElem === "undefined" || !classElem.prototype) {
let ctor = function(...args) {
return ctor.wrap(ctor.prototype.constructor(...args));
return ctor.wrap(ctor.prototype.constructor(0, ...args));
};
ctor.prototype = {};
ctor.wrap = function(thisValue) {
@ -289,7 +289,16 @@ function demangle(exports, baseModule) {
});
}
} else {
curr[name] = wrapFunction(elem, setargc);
if (name === 'constructor') {
curr[name] = wrapFunction(elem, setargc);
} else { // for methods
Object.defineProperty(curr, name, {
value: function (...args) {
setargc(args.length);
return elem(this.this, ...args);
}
});
}
}
} else {
if (/^(get|set):/.test(name)) {