porffor 0.25.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/codegen.js +15 -9
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -1772,10 +1772,10 @@ const RTArrayUtil = {
|
|
1772
1772
|
]
|
1773
1773
|
};
|
1774
1774
|
|
1775
|
-
const createNewTarget = (scope, decl, idx) => {
|
1775
|
+
const createNewTarget = (scope, decl, idx = 0) => {
|
1776
1776
|
if (decl._new) {
|
1777
1777
|
return [
|
1778
|
-
...number(idx),
|
1778
|
+
...(typeof idx === 'number' ? number(idx) : idx),
|
1779
1779
|
...number(TYPES.function, Valtype.i32)
|
1780
1780
|
];
|
1781
1781
|
}
|
@@ -1786,7 +1786,7 @@ const createNewTarget = (scope, decl, idx) => {
|
|
1786
1786
|
];
|
1787
1787
|
};
|
1788
1788
|
|
1789
|
-
const createThisArg = (scope, decl,
|
1789
|
+
const createThisArg = (scope, decl, knownThis = undefined) => {
|
1790
1790
|
if (knownThis) {
|
1791
1791
|
// todo: check compliance
|
1792
1792
|
return knownThis;
|
@@ -2248,6 +2248,12 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2248
2248
|
];
|
2249
2249
|
}
|
2250
2250
|
|
2251
|
+
const newTargetWasm = decl._newTargetWasm ?? createNewTarget(scope, decl, [
|
2252
|
+
[ Opcodes.local_get, funcLocal ],
|
2253
|
+
Opcodes.i32_from_u
|
2254
|
+
]);
|
2255
|
+
const thisWasm = decl._thisWasm ?? createThisArg(scope, decl, knownThis);
|
2256
|
+
|
2251
2257
|
const gen = argc => {
|
2252
2258
|
const argsOut = [];
|
2253
2259
|
for (let i = 0; i < argc; i++) {
|
@@ -2273,8 +2279,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2273
2279
|
// no type return
|
2274
2280
|
checkFlag(0b10, [
|
2275
2281
|
// no type return & constr
|
2276
|
-
...
|
2277
|
-
...
|
2282
|
+
...newTargetWasm,
|
2283
|
+
...thisWasm,
|
2278
2284
|
...argsOut,
|
2279
2285
|
[ Opcodes.local_get, funcLocal ],
|
2280
2286
|
[ Opcodes.call_indirect, argc + 2, 0, 'no_type_return' ],
|
@@ -2288,8 +2294,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2288
2294
|
// type return
|
2289
2295
|
checkFlag(0b10, [
|
2290
2296
|
// type return & constr
|
2291
|
-
...
|
2292
|
-
...
|
2297
|
+
...newTargetWasm,
|
2298
|
+
...thisWasm,
|
2293
2299
|
...argsOut,
|
2294
2300
|
[ Opcodes.local_get, funcLocal ],
|
2295
2301
|
[ Opcodes.call_indirect, argc + 2, 0 ],
|
@@ -2371,8 +2377,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2371
2377
|
}
|
2372
2378
|
|
2373
2379
|
if (func && func.constr) {
|
2374
|
-
out.push(...createNewTarget(scope, decl, idx - importedFuncs.length));
|
2375
|
-
out.push(...createThisArg(scope, decl
|
2380
|
+
out.push(...(decl._newTargetWasm ?? createNewTarget(scope, decl, idx - importedFuncs.length)));
|
2381
|
+
out.push(...(decl._thisWasm ?? createThisArg(scope, decl)));
|
2376
2382
|
paramOffset += 4;
|
2377
2383
|
}
|
2378
2384
|
|
package/package.json
CHANGED