porffor 0.49.10 → 0.49.11
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 +19 -10
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -50,6 +50,7 @@ const cacheAst = (decl, wasm) => {
|
|
50
50
|
let indirectFuncs = [];
|
51
51
|
const funcRef = func => {
|
52
52
|
func.generate?.();
|
53
|
+
func.referenced = true;
|
53
54
|
|
54
55
|
if (globalThis.precompile) return [
|
55
56
|
[ Opcodes.const, 'funcref', func.name ]
|
@@ -2532,6 +2533,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2532
2533
|
|
2533
2534
|
const func = funcByIndex(idx);
|
2534
2535
|
|
2536
|
+
if (func && !decl._new) func.onlyNew = false;
|
2537
|
+
|
2535
2538
|
// generate func
|
2536
2539
|
if (func) func.generate?.();
|
2537
2540
|
|
@@ -2664,16 +2667,22 @@ const generateThis = (scope, decl) => {
|
|
2664
2667
|
];
|
2665
2668
|
|
2666
2669
|
return [
|
2667
|
-
// default this to globalThis
|
2668
|
-
[
|
2669
|
-
|
2670
|
-
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2676
|
-
|
2670
|
+
// default this to globalThis unless only new func
|
2671
|
+
[ null, () => {
|
2672
|
+
if (scope.onlyNew !== false && !scope.referenced) return [];
|
2673
|
+
|
2674
|
+
return [
|
2675
|
+
[ Opcodes.local_get, scope.locals['#this#type'].idx ],
|
2676
|
+
...number(TYPES.undefined, Valtype.i32),
|
2677
|
+
[ Opcodes.i32_eq ],
|
2678
|
+
[ Opcodes.if, Blocktype.void ],
|
2679
|
+
...generate(scope, { type: 'Identifier', name: 'globalThis' }),
|
2680
|
+
[ Opcodes.local_set, scope.locals['#this'].idx ],
|
2681
|
+
...getType(scope, 'globalThis'),
|
2682
|
+
[ Opcodes.local_set, scope.locals['#this#type'].idx ],
|
2683
|
+
[ Opcodes.end ]
|
2684
|
+
];
|
2685
|
+
}, 0 ],
|
2677
2686
|
|
2678
2687
|
[ Opcodes.local_get, scope.locals['#this'].idx ],
|
2679
2688
|
...setLastType(scope, [ [ Opcodes.local_get, scope.locals['#this#type'].idx ] ])
|
package/package.json
CHANGED