porffor 0.50.11 → 0.50.13

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.
@@ -771,10 +771,14 @@ const truthy = (scope, wasm, type, intIn = false, intOut = false, forceTruthyMod
771
771
  if (truthyMode === 'full') return [
772
772
  // if value != 0 or NaN
773
773
  ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
774
- ...(intIn ? [] : [ Opcodes.i32_to ]),
775
-
776
- [ Opcodes.i32_eqz ],
777
- [ Opcodes.i32_eqz ],
774
+ ...(intIn ? [
775
+ ...number(0, Valtype.i32),
776
+ [ Opcodes.i32_ne ]
777
+ ] : [
778
+ [ Opcodes.f64_abs ],
779
+ [ Opcodes.f64_const, 0 ],
780
+ [ Opcodes.f64_gt ]
781
+ ]),
778
782
 
779
783
  ...(intOut ? [] : [ Opcodes.i32_from ]),
780
784
  ];
@@ -6243,6 +6247,7 @@ const generateTaggedTemplate = (scope, decl, global = false, name = undefined) =
6243
6247
  __Porffor_wasm: str => {
6244
6248
  let out = [];
6245
6249
 
6250
+ str = str.replaceAll('\\n', '\n');
6246
6251
  for (const line of str.split('\n')) {
6247
6252
  const asm = line.trim().split(';;')[0].split(' ').filter(x => x);
6248
6253
  if (!asm[0]) continue; // blank
@@ -6263,8 +6268,8 @@ const generateTaggedTemplate = (scope, decl, global = false, name = undefined) =
6263
6268
  if (!Array.isArray(inst)) inst = [ inst ];
6264
6269
 
6265
6270
  const immediates = asm.slice(1).map(x => {
6266
- const int = parseInt(x);
6267
- if (Number.isNaN(int)) {
6271
+ const n = parseFloat(x);
6272
+ if (Number.isNaN(n) && x !== 'NaN') {
6268
6273
  if (builtinFuncs[x]) {
6269
6274
  if (funcIndex[x] == null) includeBuiltin(scope, x);
6270
6275
  return funcIndex[x];
@@ -6272,7 +6277,8 @@ const generateTaggedTemplate = (scope, decl, global = false, name = undefined) =
6272
6277
 
6273
6278
  return scope.locals[x]?.idx ?? globals[x].idx;
6274
6279
  }
6275
- return int;
6280
+
6281
+ return n;
6276
6282
  });
6277
6283
 
6278
6284
  const encodeFunc = ({
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.50.11",
4
+ "version": "0.50.13",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/porf CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/bin/sh
2
- node runner/index.js "$@"
2
+ node "$(dirname "$0")/runner/index.js" "$@"
3
3
  # deno run -A runner/index.js "$@"
4
4
  # bun runner/index.js "$@"
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.50.11';
3
+ globalThis.version = '0.50.13';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {