porffor 0.36.7 → 0.37.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.
@@ -248,7 +248,8 @@ const generate = (scope, decl, global = false, name = undefined, valueUnused = f
248
248
 
249
249
  const encodeFunc = ({
250
250
  [Opcodes.f64_const]: x => x,
251
- [Opcodes.if]: unsignedLEB128
251
+ [Opcodes.if]: unsignedLEB128,
252
+ [Opcodes.loop]: unsignedLEB128
252
253
  })[inst[0]] ?? signedLEB128;
253
254
  out.push([ ...inst, ...immediates.flatMap(x => encodeFunc(x)) ]);
254
255
  }
@@ -1690,12 +1691,7 @@ const setObjProp = (obj, prop, value) => {
1690
1691
  });
1691
1692
  };
1692
1693
 
1693
- const createThisArg = (scope, decl, knownThis = undefined) => {
1694
- if (knownThis) {
1695
- // todo: check compliance
1696
- return knownThis;
1697
- }
1698
-
1694
+ const createThisArg = (scope, decl) => {
1699
1695
  const name = mapName(decl.callee?.name);
1700
1696
  if (decl._new) {
1701
1697
  // if precompiling or builtin func, just make empty object
@@ -2273,12 +2269,12 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2273
2269
  ];
2274
2270
  }
2275
2271
 
2276
- let callee = decl.callee, callAsNew = decl._new, overrideThisWasm = decl._thisWasm;
2272
+ let callee = decl.callee, callAsNew = decl._new;
2277
2273
  if (callee.type === 'Super') {
2278
2274
  // call super constructor with direct super() call
2279
2275
  callee = getObjProp(callee, 'constructor');
2280
2276
  callAsNew = true;
2281
- overrideThisWasm = [
2277
+ knownThis = [
2282
2278
  ...generate(scope, { type: 'ThisExpression' }),
2283
2279
  ...getNodeType(scope, { type: 'ThisExpression' })
2284
2280
  ];
@@ -2288,7 +2284,7 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2288
2284
  [ Opcodes.local_get, funcLocal ],
2289
2285
  Opcodes.i32_from_u
2290
2286
  ], callAsNew);
2291
- const thisWasm = overrideThisWasm ?? createThisArg(scope, decl, knownThis);
2287
+ const thisWasm = knownThis ?? createThisArg(scope, decl);
2292
2288
 
2293
2289
  const gen = argc => {
2294
2290
  const argsOut = [];
@@ -3833,7 +3829,7 @@ const generateFor = (scope, decl) => {
3833
3829
 
3834
3830
  out.push([ Opcodes.br, 1 ]);
3835
3831
  out.push([ Opcodes.end ], [ Opcodes.end ]);
3836
- depth.pop(); depth.pop();
3832
+ depth.pop(); depth.pop(); depth.pop();
3837
3833
 
3838
3834
  return out;
3839
3835
  };
@@ -4265,6 +4261,7 @@ const generateForOf = (scope, decl) => {
4265
4261
  depth.pop();
4266
4262
  depth.pop();
4267
4263
  depth.pop();
4264
+ depth.pop();
4268
4265
 
4269
4266
  return out;
4270
4267
  };
@@ -4384,6 +4381,7 @@ const generateForIn = (scope, decl) => {
4384
4381
  depth.pop();
4385
4382
  depth.pop();
4386
4383
  depth.pop();
4384
+ depth.pop();
4387
4385
 
4388
4386
  return typeSwitch(scope, getNodeType(scope, decl.right), {
4389
4387
  // fast path for objects
@@ -4532,7 +4530,7 @@ const generateBreak = (scope, decl) => {
4532
4530
  })[type];
4533
4531
 
4534
4532
  return [
4535
- [ Opcodes.br, ...signedLEB128(depth.length - target - offset) ]
4533
+ [ Opcodes.br, ...unsignedLEB128(depth.length - target - offset) ]
4536
4534
  ];
4537
4535
  };
4538
4536
 
@@ -4553,7 +4551,7 @@ const generateContinue = (scope, decl) => {
4553
4551
  })[type];
4554
4552
 
4555
4553
  return [
4556
- [ Opcodes.br, ...signedLEB128(depth.length - target - offset) ]
4554
+ [ Opcodes.br, ...unsignedLEB128(depth.length - target - offset) ]
4557
4555
  ];
4558
4556
  };
4559
4557
 
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.36.7+e872827a7",
4
+ "version": "0.37.1+9d9c67653",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
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.36.7+e872827a7';
3
+ globalThis.version = '0.37.1+9d9c67653';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {