porffor 0.50.12 → 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.
- package/compiler/codegen.js +13 -7
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/codegen.js
CHANGED
@@ -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 ? [
|
775
|
-
|
776
|
-
|
777
|
-
|
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
|
6267
|
-
if (Number.isNaN(
|
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
|
-
|
6280
|
+
|
6281
|
+
return n;
|
6276
6282
|
});
|
6277
6283
|
|
6278
6284
|
const encodeFunc = ({
|
package/package.json
CHANGED