porffor 0.37.0 → 0.37.2

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.
@@ -1691,12 +1691,7 @@ const setObjProp = (obj, prop, value) => {
1691
1691
  });
1692
1692
  };
1693
1693
 
1694
- const createThisArg = (scope, decl, knownThis = undefined) => {
1695
- if (knownThis) {
1696
- // todo: check compliance
1697
- return knownThis;
1698
- }
1699
-
1694
+ const createThisArg = (scope, decl) => {
1700
1695
  const name = mapName(decl.callee?.name);
1701
1696
  if (decl._new) {
1702
1697
  // if precompiling or builtin func, just make empty object
@@ -2258,8 +2253,8 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2258
2253
  let getCalleeObj = undefined;
2259
2254
  let initCalleeObj = undefined;
2260
2255
 
2261
- // hack: this should be more thorough, Function.bind, etc.
2262
- if (decl.callee.type == 'MemberExpression') {
2256
+ // hack: this should be more thorough, Function.bind, etc
2257
+ if (decl.callee.type == 'MemberExpression' && !decl._new) {
2263
2258
  const callee = localTmp(scope, '#indirect_callee_obj', Valtype.f64);
2264
2259
  initCalleeObj = [
2265
2260
  ...generate(scope, decl.callee.object),
@@ -2274,12 +2269,12 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2274
2269
  ];
2275
2270
  }
2276
2271
 
2277
- let callee = decl.callee, callAsNew = decl._new, overrideThisWasm = decl._thisWasm;
2272
+ let callee = decl.callee, callAsNew = decl._new;
2278
2273
  if (callee.type === 'Super') {
2279
2274
  // call super constructor with direct super() call
2280
2275
  callee = getObjProp(callee, 'constructor');
2281
2276
  callAsNew = true;
2282
- overrideThisWasm = [
2277
+ knownThis = [
2283
2278
  ...generate(scope, { type: 'ThisExpression' }),
2284
2279
  ...getNodeType(scope, { type: 'ThisExpression' })
2285
2280
  ];
@@ -2289,7 +2284,7 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2289
2284
  [ Opcodes.local_get, funcLocal ],
2290
2285
  Opcodes.i32_from_u
2291
2286
  ], callAsNew);
2292
- const thisWasm = overrideThisWasm ?? createThisArg(scope, decl, knownThis);
2287
+ const thisWasm = knownThis ?? createThisArg(scope, decl);
2293
2288
 
2294
2289
  const gen = argc => {
2295
2290
  const argsOut = [];
@@ -3834,7 +3829,7 @@ const generateFor = (scope, decl) => {
3834
3829
 
3835
3830
  out.push([ Opcodes.br, 1 ]);
3836
3831
  out.push([ Opcodes.end ], [ Opcodes.end ]);
3837
- depth.pop(); depth.pop();
3832
+ depth.pop(); depth.pop(); depth.pop();
3838
3833
 
3839
3834
  return out;
3840
3835
  };
@@ -4266,6 +4261,7 @@ const generateForOf = (scope, decl) => {
4266
4261
  depth.pop();
4267
4262
  depth.pop();
4268
4263
  depth.pop();
4264
+ depth.pop();
4269
4265
 
4270
4266
  return out;
4271
4267
  };
@@ -4385,6 +4381,7 @@ const generateForIn = (scope, decl) => {
4385
4381
  depth.pop();
4386
4382
  depth.pop();
4387
4383
  depth.pop();
4384
+ depth.pop();
4388
4385
 
4389
4386
  return typeSwitch(scope, getNodeType(scope, decl.right), {
4390
4387
  // fast path for objects
@@ -4533,7 +4530,7 @@ const generateBreak = (scope, decl) => {
4533
4530
  })[type];
4534
4531
 
4535
4532
  return [
4536
- [ Opcodes.br, ...signedLEB128(depth.length - target - offset) ]
4533
+ [ Opcodes.br, ...unsignedLEB128(depth.length - target - offset) ]
4537
4534
  ];
4538
4535
  };
4539
4536
 
@@ -4554,7 +4551,7 @@ const generateContinue = (scope, decl) => {
4554
4551
  })[type];
4555
4552
 
4556
4553
  return [
4557
- [ Opcodes.br, ...signedLEB128(depth.length - target - offset) ]
4554
+ [ Opcodes.br, ...unsignedLEB128(depth.length - target - offset) ]
4558
4555
  ];
4559
4556
  };
4560
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.37.0+44ce75202",
4
+ "version": "0.37.2+c66ebc0c6",
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.37.0+44ce75202';
3
+ globalThis.version = '0.37.2+c66ebc0c6';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {