mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-25 15:12:12 +00:00
Use a symbol for the this pointer on wrapped loader classes, see #363
This commit is contained in:
parent
429435c5b1
commit
86c084a519
@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const hasBigInt64 = typeof BigUint64Array !== "undefined";
|
const hasBigInt64 = typeof BigUint64Array !== "undefined";
|
||||||
|
const thisPtr = Symbol();
|
||||||
|
|
||||||
/** Gets a string from an U32 and an U16 view on a memory. */
|
/** Gets a string from an U32 and an U16 view on a memory. */
|
||||||
function getStringImpl(U32, U16, ptr) {
|
function getStringImpl(U32, U16, ptr) {
|
||||||
@ -269,7 +270,7 @@ function demangle(exports, baseModule) {
|
|||||||
};
|
};
|
||||||
ctor.prototype = {};
|
ctor.prototype = {};
|
||||||
ctor.wrap = function(thisValue) {
|
ctor.wrap = function(thisValue) {
|
||||||
return Object.create(ctor.prototype, { "this": { value: thisValue, writable: false } });
|
return Object.create(ctor.prototype, { [thisPtr]: { value: thisValue, writable: false } });
|
||||||
};
|
};
|
||||||
if (classElem) Object.getOwnPropertyNames(classElem).forEach(name =>
|
if (classElem) Object.getOwnPropertyNames(classElem).forEach(name =>
|
||||||
Object.defineProperty(ctor, name, Object.getOwnPropertyDescriptor(classElem, name))
|
Object.defineProperty(ctor, name, Object.getOwnPropertyDescriptor(classElem, name))
|
||||||
@ -283,8 +284,8 @@ function demangle(exports, baseModule) {
|
|||||||
let getter = exports[internalName.replace("set:", "get:")];
|
let getter = exports[internalName.replace("set:", "get:")];
|
||||||
let setter = exports[internalName.replace("get:", "set:")];
|
let setter = exports[internalName.replace("get:", "set:")];
|
||||||
Object.defineProperty(curr, name, {
|
Object.defineProperty(curr, name, {
|
||||||
get: function() { return getter(this.this); },
|
get: function() { return getter(this[thisPtr]); },
|
||||||
set: function(value) { setter(this.this, value); },
|
set: function(value) { setter(this[thisPtr], value); },
|
||||||
enumerable: true
|
enumerable: true
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -295,7 +296,7 @@ function demangle(exports, baseModule) {
|
|||||||
Object.defineProperty(curr, name, {
|
Object.defineProperty(curr, name, {
|
||||||
value: function (...args) {
|
value: function (...args) {
|
||||||
setargc(args.length);
|
setargc(args.length);
|
||||||
return elem(this.this, ...args);
|
return elem(this[thisPtr], ...args);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user