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.
@@ -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 empty object
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(NULL),
1800
- ...number(TYPES.object, Valtype.i32)
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
- Opcodes.i32_to_u,
2610
- [ Opcodes.i32_eqz ],
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
- [ Opcodes.local_get, scope.locals['#this#type'].idx ],
2613
- ...number(TYPES.object, Valtype.i32),
2614
- [ Opcodes.i32_eq ],
2615
- [ Opcodes.if, Blocktype.void ],
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.37.31+587ce769f",
4
+ "version": "0.37.32+fde2c20c4",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
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 = (node) => {
15
+ const doesSucceedZero = node => {
16
16
  for (const n of node.body) {
17
- if (n.type === "Group") {
18
- if (!doesSucceedZero(node)) return false;
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
 
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.37.31+587ce769f';
3
+ globalThis.version = '0.37.32+fde2c20c4';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {