porffor 0.37.31 → 0.37.32
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/builtins_precompiled.js +146 -146
- package/compiler/codegen.js +14 -18
- package/package.json +1 -1
- package/rhemyn/compile.js +5 -3
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -1733,7 +1733,7 @@ const aliasPrimObjsBC = bc => {
|
|
1733
1733
|
const createThisArg = (scope, decl) => {
|
1734
1734
|
const name = mapName(decl.callee?.name);
|
1735
1735
|
if (decl._new) {
|
1736
|
-
// if precompiling or builtin func, just make
|
1736
|
+
// if precompiling or builtin func, just make it null as unused
|
1737
1737
|
if (globalThis.precompile || Object.hasOwn(builtinFuncs, name)) return [
|
1738
1738
|
...number(NULL),
|
1739
1739
|
...number(TYPES.object, Valtype.i32)
|
@@ -1793,11 +1793,12 @@ const createThisArg = (scope, decl) => {
|
|
1793
1793
|
];
|
1794
1794
|
}
|
1795
1795
|
|
1796
|
-
// do not generate globalThis now,
|
1796
|
+
// undefined do not generate globalThis now,
|
1797
1797
|
// do it dynamically in generateThis in the func later
|
1798
|
+
// (or not for strict mode)
|
1798
1799
|
return [
|
1799
|
-
...number(
|
1800
|
-
...number(TYPES.
|
1800
|
+
...number(UNDEFINED),
|
1801
|
+
...number(TYPES.undefined, Valtype.i32)
|
1801
1802
|
];
|
1802
1803
|
}
|
1803
1804
|
};
|
@@ -2597,27 +2598,22 @@ const generateThis = (scope, decl) => {
|
|
2597
2598
|
];
|
2598
2599
|
}
|
2599
2600
|
|
2600
|
-
// opt: do not check for pure constructors
|
2601
|
-
if (scope._onlyConstr || scope._onlyThisMethod || decl._noGlobalThis) return [
|
2601
|
+
// opt: do not check for pure constructors or strict mode
|
2602
|
+
if ((!globalThis.precompile && scope.strict) || scope._onlyConstr || scope._onlyThisMethod || decl._noGlobalThis) return [
|
2602
2603
|
[ Opcodes.local_get, scope.locals['#this'].idx ],
|
2603
2604
|
...setLastType(scope, [ [ Opcodes.local_get, scope.locals['#this#type'].idx ] ])
|
2604
2605
|
];
|
2605
2606
|
|
2606
2607
|
return [
|
2607
2608
|
// default this to globalThis
|
2608
|
-
[ Opcodes.local_get, scope.locals['#this'].idx ],
|
2609
|
-
|
2610
|
-
[ Opcodes.
|
2609
|
+
[ Opcodes.local_get, scope.locals['#this#type'].idx ],
|
2610
|
+
...number(TYPES.undefined, Valtype.i32),
|
2611
|
+
[ Opcodes.i32_eq ],
|
2611
2612
|
[ Opcodes.if, Blocktype.void ],
|
2612
|
-
|
2613
|
-
|
2614
|
-
|
2615
|
-
[ Opcodes.
|
2616
|
-
...generate(scope, { type: 'Identifier', name: 'globalThis' }),
|
2617
|
-
[ Opcodes.local_set, scope.locals['#this'].idx ],
|
2618
|
-
...getType(scope, 'globalThis'),
|
2619
|
-
[ Opcodes.local_set, scope.locals['#this#type'].idx ],
|
2620
|
-
[ Opcodes.end ],
|
2613
|
+
...generate(scope, { type: 'Identifier', name: 'globalThis' }),
|
2614
|
+
[ Opcodes.local_set, scope.locals['#this'].idx ],
|
2615
|
+
...getType(scope, 'globalThis'),
|
2616
|
+
[ Opcodes.local_set, scope.locals['#this#type'].idx ],
|
2621
2617
|
[ Opcodes.end ],
|
2622
2618
|
|
2623
2619
|
[ Opcodes.local_get, scope.locals['#this'].idx ],
|
package/package.json
CHANGED
package/rhemyn/compile.js
CHANGED
@@ -12,15 +12,17 @@ const Length = 4;
|
|
12
12
|
const Tmp = 5;
|
13
13
|
const QuantifierTmp = 6; // the temporary variable used for quanitifers
|
14
14
|
|
15
|
-
const doesSucceedZero =
|
15
|
+
const doesSucceedZero = node => {
|
16
16
|
for (const n of node.body) {
|
17
|
-
if (n.type ===
|
18
|
-
if (!doesSucceedZero(
|
17
|
+
if (n.type === 'Group') {
|
18
|
+
if (!doesSucceedZero(n)) return false;
|
19
19
|
}
|
20
|
+
|
20
21
|
if (!n.quantifier || n.quantifier[0] > 0) {
|
21
22
|
return false;
|
22
23
|
}
|
23
24
|
}
|
25
|
+
|
24
26
|
return true;
|
25
27
|
}
|
26
28
|
|