porffor 0.14.0-bb0b06c17 → 0.14.0-bd4ccfc7d

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/CONTRIBUTING.md CHANGED
@@ -98,7 +98,7 @@ Loads the character code at the pointer `pointer` **for a String**.[^1]
98
98
  Porffor.wasm.i32.store(pointer, length, 0, 0)
99
99
  ```
100
100
 
101
- Stores the length `length` at pointer `pointer`, setting the length of an object. This is mostly unneeded today as you can just do `obj.length = length`. [^2]
101
+ Stores the length `length` at pointer `pointer`, setting the length of an object. This is mostly unneeded today as you can just do `obj.length = length`. (The `0, 4` args are necessary for the Wasm instruction, but you don't need to worry about them (`0` alignment, `0` byte offset).
102
102
 
103
103
  <br>
104
104
 
@@ -198,11 +198,13 @@ Store the character code into the `out` pointer variable, and increment it.
198
198
 
199
199
  ## Porffor-specific TS notes
200
200
 
201
- - For declaring variables, you must use explicit type annotations currently (eg `let a: number = 1`, not `let a = 1`)
201
+ - For declaring variables, you must use explicit type annotations currently (eg `let a: number = 1`, not `let a = 1`).
202
202
  - You might spot `Porffor.fastOr`/`Porffor.fastAnd`, these are non-short circuiting versions of `||`/`&&`, taking any number of conditions as arguments. You shouldn't don't need to use or worry about these.
203
- - **There are ~no objects, you cannot use them/literals.**
203
+ - **There are ~no objects, you cannot use them.**
204
204
  - Attempt to avoid string/array-heavy code and use more variables instead if possible, easier on memory and CPU/perf.
205
205
  - Do not set a return type for prototype methods, it can cause errors/unexpected results.
206
+ - You cannot use other functions in the file not exported, or variables not inside the current function.
207
+ - `if (...)` uses a fast truthy implementation which is not spec-compliant as most conditions should be strictly checked. To use spec-compliant behavior, use `if (Boolean(...))`.
206
208
 
207
209
  <br>
208
210
 
@@ -255,6 +257,4 @@ It will also log new passes/fails. Be careful as sometimes the overall passes ca
255
257
 
256
258
  <br>
257
259
 
258
- [^1]: The `0, 4` args are necessary for the Wasm instruction, but you don't need to worry about them (`0` alignment, `4` byte offset for length).
259
-
260
- [^2]: The `0, 4` args are necessary for the Wasm instruction, but you don't need to worry about them (`0` alignment, `0` byte offset).
260
+ [^1]: The `0, 4` args are necessary for the Wasm instruction, but you don't need to worry about them (`0` alignment, `4` byte offset for length).
package/README.md CHANGED
@@ -14,7 +14,7 @@ Porffor is primarily built from scratch, the only thing that is not is the parse
14
14
  Expect nothing to work! Only very limited JS is currently supported. See files in `bench` for examples.
15
15
 
16
16
  ### Install
17
- **`npm install -g porffor`**. It's that easy (hopefully) :)
17
+ **`npm install -g porffor@latest`**. It's that easy (hopefully) :)
18
18
 
19
19
  ### Trying a REPL
20
20
  **`porf`**. Just run it with no script file argument.
@@ -266,8 +266,6 @@ Basically none right now (other than giving people headaches). Potential ideas:
266
266
  No particular order and no guarentees, just what could happen soon™
267
267
 
268
268
  - Arrays
269
- - More of `Array` prototype
270
- - Arrays/strings inside arrays
271
269
  - Destructuring
272
270
  - Objects
273
271
  - Basic object expressions (eg `{}`, `{ a: 0 }`)
@@ -315,16 +313,10 @@ Porffor intentionally does not use Wasm proposals which are not commonly impleme
315
313
 
316
314
  - Multi-value **(required)**
317
315
  - Non-trapping float-to-int conversions **(required)**
318
- - Bulk memory operations (required, but uncommonly used)
319
- - Exception handling (optional, for errors)
316
+ - Bulk memory operations (optional, can get away without sometimes)
317
+ - Exception handling (optional, only for errors)
320
318
  - Tail calls (opt-in, off by default)
321
319
 
322
- ## Isn't this the same as AssemblyScript/other Wasm langs?
323
- No. they are not alike at all internally and have very different goals/ideals:
324
- - Porffor is made as a generic JS engine, not for Wasm stuff specifically
325
- - Porffor primarily consumes JS
326
- - Porffor is written in pure JS and compiles itself, not using Binaryen/etc
327
- - (Also I didn't know it existed when I started this, lol)
328
320
 
329
321
  ## FAQ
330
322
 
@@ -338,5 +330,9 @@ No. they are not alike at all internally and have very different goals/ideals:
338
330
  ### 2. Why at all?
339
331
  Yes!
340
332
 
341
- ### 3. But what about spec compliance?
342
- Lol, no. (sorry.)
333
+ ## 3. Isn't this the same as AssemblyScript/other Wasm langs?
334
+ No. they are not alike at all internally and have very different goals/ideals:
335
+ - Porffor is made as a generic JS engine, not for Wasm stuff specifically
336
+ - Porffor primarily consumes JS
337
+ - Porffor is written in pure JS and compiles itself, not using Binaryen/etc
338
+ - (Also I didn't know it existed when I started this, lol)
package/compiler/2c.js CHANGED
@@ -119,6 +119,9 @@ const removeBrackets = str => {
119
119
  };
120
120
 
121
121
  export default ({ funcs, globals, tags, data, exceptions, pages }) => {
122
+ // fix declaring order for c
123
+ funcs.reverse();
124
+
122
125
  const invOperatorOpcode = Object.values(operatorOpcode).reduce((acc, x) => {
123
126
  for (const k in x) {
124
127
  acc[x[k]] = k;
@@ -156,6 +159,11 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
156
159
  prependMain.set('_data', data.map(x => `memcpy(_memory + ${x.offset}, (unsigned char[]){${x.bytes.join(',')}}, ${x.bytes.length});`).join('\n'));
157
160
  }
158
161
 
162
+ if (importFuncs.find(x => x.name === '__Porffor_readArgv')) {
163
+ prepend.set('argv', `int _argc; char** _argv;`);
164
+ prependMain.set('argv', `_argc = argc; _argv = argv;`);
165
+ }
166
+
159
167
  if (out) out += '\n';
160
168
 
161
169
  let depth = 1;
@@ -199,6 +207,8 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
199
207
  depth = 1;
200
208
  brDepth = 0;
201
209
 
210
+ let retTmpId = 0;
211
+
202
212
  const invLocals = inv(f.locals, x => x.idx);
203
213
 
204
214
  for (const x in invLocals) {
@@ -207,8 +217,9 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
207
217
 
208
218
  const returns = f.returns.length > 0;
209
219
 
210
- const shouldInline = f.internal;
211
- out += `${f.name === 'main' ? 'int' : (f.internal ? (returns ? CValtype.f64 : 'void') : 'struct ReturnValue')} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')}) {\n`;
220
+ const shouldInline = false; // f.internal;
221
+ if (f.name === 'main') out += `int main(${prependMain.has('argv') ? 'int argc, char* argv[]' : ''}) {\n`;
222
+ else out += `${f.internal ? (returns ? CValtype.f64 : 'void') : 'struct ReturnValue'} ${shouldInline ? 'inline ' : ''}${sanitize(f.name)}(${f.params.map((x, i) => `${CValtype[x]} ${invLocals[i]}`).join(', ')}) {\n`;
212
223
 
213
224
  if (f.name === 'main') {
214
225
  out += [...prependMain.values()].join('\n');
@@ -459,6 +470,60 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
459
470
  winIncludes.set('windows.h', true);
460
471
  break;
461
472
 
473
+ case '__Porffor_readArgv':
474
+ includes.set('stdlib.h', true);
475
+
476
+ prepend.set('__Porffor_readArgv',
477
+ `void __Porffor_readArgv(u32 index, u32 outPtr) {
478
+ if (index >= _argc) {
479
+ printf("expected %d arguments\\n", index);
480
+ exit(1);
481
+ }
482
+
483
+ char* arg = _argv[index];
484
+
485
+ u32 read = 0;
486
+ char* out = _memory + outPtr + 4;
487
+ char ch;
488
+ while ((ch = *(arg++)) != 0) {
489
+ out[read++] = ch;
490
+ }
491
+
492
+ memcpy(_memory + outPtr, &read, sizeof(read));
493
+ }`);
494
+
495
+ line(`__Porffor_readArgv((u32)(${vals.at(-2)}), (u32)(${vals.pop()}))`);
496
+ vals.pop();
497
+ break;
498
+
499
+ case '__Porffor_readFile':
500
+ includes.set('stdio.h', true);
501
+ includes.set('stdlib.h', true);
502
+
503
+ prepend.set('__Porffor_readFile',
504
+ `void __Porffor_readFile(u32 pathPtr, u32 outPtr) {
505
+ char* path = _memory + pathPtr + 4;
506
+ FILE* fp = fopen(path, "r");
507
+ if (fp == NULL) {
508
+ printf("failed to open file: %s\\n", path);
509
+ exit(1);
510
+ }
511
+
512
+ u32 read = 0;
513
+ char* out = _memory + outPtr + 4;
514
+ char ch;
515
+ while ((ch = fgetc(fp)) != EOF) {
516
+ out[read++] = ch;
517
+ }
518
+
519
+ fclose(fp);
520
+
521
+ memcpy(_memory + outPtr, &read, sizeof(read));
522
+ }`);
523
+ line(`__Porffor_readFile((u32)(${vals.at(-2)}), (u32)(${vals.pop()}))`);
524
+ vals.pop();
525
+ break;
526
+
462
527
  default:
463
528
  log.warning('2c', `unimplemented import: ${importFunc.name}`);
464
529
  break;
@@ -474,7 +539,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
474
539
  if (func.internal) {
475
540
  vals.push(`${sanitize(func.name)}(${args.join(', ')})`);
476
541
  } else {
477
- line(`const struct ReturnValue _ = ${sanitize(func.name)}(${args.join(', ')})`);
542
+ line(`const struct ReturnValue _${retTmpId++} = ${sanitize(func.name)}(${args.join(', ')})`);
478
543
  vals.push(`_.value`);
479
544
  vals.push(`_.type`);
480
545
  }
@@ -1,4 +1,5 @@
1
1
  // @porf --valtype=i32
2
+ import type {} from './porffor.d.ts';
2
3
 
3
4
  export const __String_prototype_trimLeft = (_this: string) => {
4
5
  return __String_prototype_trimStart(_this);
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  export const __Array_isArray = (x: unknown): boolean =>
2
4
  // Porffor.wasm`local.get ${x+1}` == Porffor.TYPES.array;
3
5
  Porffor.rawType(x) == Porffor.TYPES.array;
@@ -162,7 +164,7 @@ export const __Array_prototype_filter = (_this: any[], callbackFn: any) => {
162
164
  let i: i32 = 0;
163
165
  while (i < len) {
164
166
  const el: any = _this[i];
165
- if (callbackFn(el, i++, _this)) out.push(el);
167
+ if (Boolean(callbackFn(el, i++, _this))) out.push(el);
166
168
  }
167
169
 
168
170
  return out;
@@ -185,7 +187,7 @@ export const __Array_prototype_find = (_this: any[], callbackFn: any) => {
185
187
  let i: i32 = 0;
186
188
  while (i < len) {
187
189
  const el: any = _this[i];
188
- if (callbackFn(el, i++, _this)) return el;
190
+ if (Boolean(callbackFn(el, i++, _this))) return el;
189
191
  }
190
192
  };
191
193
 
@@ -193,7 +195,7 @@ export const __Array_prototype_findLast = (_this: any[], callbackFn: any) => {
193
195
  let i: i32 = _this.length;
194
196
  while (i > 0) {
195
197
  const el: any = _this[--i];
196
- if (callbackFn(el, i, _this)) return el;
198
+ if (Boolean(callbackFn(el, i, _this))) return el;
197
199
  }
198
200
  };
199
201
 
@@ -201,14 +203,14 @@ export const __Array_prototype_findIndex = (_this: any[], callbackFn: any) => {
201
203
  const len: i32 = _this.length;
202
204
  let i: i32 = 0;
203
205
  while (i < len) {
204
- if (callbackFn(_this[i], i++, _this)) return i;
206
+ if (Boolean(callbackFn(_this[i], i++, _this))) return i;
205
207
  }
206
208
  };
207
209
 
208
210
  export const __Array_prototype_findLastIndex = (_this: any[], callbackFn: any) => {
209
211
  let i: i32 = _this.length;
210
212
  while (i > 0) {
211
- if (callbackFn(_this[--i], i, _this)) return i;
213
+ if (Boolean(callbackFn(_this[--i], i, _this))) return i;
212
214
  }
213
215
  };
214
216
 
@@ -216,7 +218,7 @@ export const __Array_prototype_every = (_this: any[], callbackFn: any) => {
216
218
  const len: i32 = _this.length;
217
219
  let i: i32 = 0;
218
220
  while (i < len) {
219
- if (!callbackFn(_this[i], i++, _this)) return false;
221
+ if (!Boolean(callbackFn(_this[i], i++, _this))) return false;
220
222
  }
221
223
 
222
224
  return true;
@@ -1,4 +1,5 @@
1
1
  // @porf --valtype=i32
2
+ import type {} from './porffor.d.ts';
2
3
 
3
4
  export const btoa = (input: bytestring): bytestring => {
4
5
  const keyStr: bytestring = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // 20.3.3.2 Boolean.prototype.toString ()
2
4
  // https://tc39.es/ecma262/#sec-boolean.prototype.tostring
3
5
  export const __Boolean_prototype_toString = (_this: boolean) => {
@@ -0,0 +1,4 @@
1
+ export const __console_clear = (): void => {
2
+ const clear: bytestring = '\x1b[2J';
3
+ console.log(clear);
4
+ };
@@ -1,4 +1,5 @@
1
1
  // @porf --valtype=i32
2
+ import type {} from './porffor.d.ts';
2
3
 
3
4
  export const __crypto_randomUUID = (): bytestring => {
4
5
  let bytes: bytestring = '................';
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // 21.4.1.3 Day (t)
2
4
  // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-day
3
5
  // 1. Return 𝔽(floor(ℝ(t / msPerDay))).
@@ -1,6 +1,5 @@
1
1
  // @porf --valtype=i32
2
-
3
- import type {} from './porffor';
2
+ import type {} from './porffor.d.ts';
4
3
 
5
4
  export const escape = (input: string|bytestring): bytestring => {
6
5
  // we have no byte array yet so use bytestring with 0x00 and 0x01 via escape characters
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  export const __Function_prototype_toString = (_this: Function) => {
2
4
  // todo: actually use source
3
5
  let out: bytestring = 'function () {}';
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // radix: number|any for rawType check
2
4
  // export const parseInt = (input: string|bytestring, radix: number|any): f64 => {
3
5
  export const parseInt = (input: string|bytestring, radix: number): f64 => {
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // todo: use any and Number(x) in all these later
2
4
  // todo: specify the rest of this file later
3
5
  // todo/perf: make i32 variants later
@@ -17,7 +19,7 @@ export const __Math_exp = (x: number): number => {
17
19
  const k: number = Math.floor(x / Math.LN2);
18
20
  const r: number = x - k * Math.LN2;
19
21
 
20
- // Horner's method
22
+ // Taylor series via Horner's method
21
23
  let term: number = r;
22
24
  let sum: number = 1 + r;
23
25
  let i: number = 2;
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // radix: number|any for rawType check
2
4
  export const __Number_prototype_toString = (_this: number, radix: number|any) => {
3
5
  let out: bytestring = '';
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  export const __Object_prototype_toString = (_this: object) => {
2
4
  let out: bytestring = '[object Object]';
3
5
  return out;
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  // dark wasm magic for dealing with memory, sorry.
2
4
  export const __Porffor_allocate = (): number => {
3
5
  Porffor.wasm`i32.const 1
@@ -183,4 +185,15 @@ export const Set$constructor = (iterable: any): Set => {
183
185
  }
184
186
 
185
187
  return out;
186
- };
188
+ };
189
+
190
+ export const __Set_prototype_union = (_this: Set, other: any) => {
191
+ if (Porffor.rawType(other) != Porffor.TYPES.set) {
192
+ throw new TypeError("Set.union requires 'Set'");
193
+ }
194
+ const out: Set = new Set(_this);
195
+ for (const x of other) {
196
+ out.add(x);
197
+ }
198
+ return out;
199
+ };
@@ -1,4 +1,5 @@
1
1
  // @porf --valtype=i32
2
+ import type {} from './porffor.d.ts';
2
3
 
3
4
  export const __String_fromCharCode = (code: i32) => {
4
5
  // todo: support >1 arg
@@ -1,3 +1,5 @@
1
+ import type {} from './porffor.d.ts';
2
+
1
3
  export const __Porffor_symbol_descStore = (op: boolean, value: any): any => {
2
4
  const ptr: bytestring = '';
3
5
 
@@ -18,7 +20,6 @@ export const Symbol = (description: any): Symbol => {
18
20
  return __Porffor_symbol_descStore(true, description) + 1;
19
21
  };
20
22
 
21
- // todo: this should be a getter somehow not a method
22
23
  export const __Symbol_prototype_description$get = (_this: Symbol) => {
23
24
  const description: bytestring = __Porffor_symbol_descStore(false,
24
25
  Porffor.wasm`local.get ${_this}` - 1);
@@ -40,6 +40,18 @@ export const importedFuncs = [
40
40
  import: 'z',
41
41
  params: 1,
42
42
  returns: 0
43
+ },
44
+ {
45
+ name: '__Porffor_readArgv',
46
+ import: 'w',
47
+ params: 2,
48
+ returns: 0
49
+ },
50
+ {
51
+ name: '__Porffor_readFile',
52
+ import: 'q',
53
+ params: 2,
54
+ returns: 0
43
55
  }
44
56
  ];
45
57
 
@@ -363,7 +363,7 @@ const localTmp = (scope, name, type = valtypeBinary) => {
363
363
  };
364
364
 
365
365
  const isIntOp = op => op && ((op[0] >= 0x45 && op[0] <= 0x4f) || (op[0] >= 0x67 && op[0] <= 0x78) || op[0] === 0x41);
366
- const isFloatToIntOp = op => op && (op[0] >= 0xb7 && op[0] <= 0xba);
366
+ const isIntToFloatOp = op => op && (op[0] >= 0xb7 && op[0] <= 0xba);
367
367
 
368
368
  const performLogicOp = (scope, op, left, right, leftType, rightType) => {
369
369
  const checks = {
@@ -380,10 +380,10 @@ const performLogicOp = (scope, op, left, right, leftType, rightType) => {
380
380
 
381
381
  // if we can, use int tmp and convert at the end to help prevent unneeded conversions
382
382
  // (like if we are in an if condition - very common)
383
- const leftIsInt = isFloatToIntOp(left[left.length - 1]);
384
- const rightIsInt = isFloatToIntOp(right[right.length - 1]);
383
+ const leftWasInt = isIntToFloatOp(left[left.length - 1]);
384
+ const rightWasInt = isIntToFloatOp(right[right.length - 1]);
385
385
 
386
- const canInt = leftIsInt && rightIsInt;
386
+ const canInt = leftWasInt && rightWasInt;
387
387
 
388
388
  if (canInt) {
389
389
  // remove int -> float conversions from left and right
@@ -648,9 +648,9 @@ const compareStrings = (scope, left, right, bytestrings = false) => {
648
648
  [ Opcodes.i32_add ],
649
649
  [ Opcodes.local_tee, index ],
650
650
 
651
- // if index != index end (length * sizeof valtype), loop
651
+ // if index < index end (length * sizeof valtype), loop
652
652
  [ Opcodes.local_get, indexEnd ],
653
- [ Opcodes.i32_ne ],
653
+ [ Opcodes.i32_lt_s ],
654
654
  [ Opcodes.br_if, 0 ],
655
655
  [ Opcodes.end ],
656
656
 
@@ -668,57 +668,50 @@ const compareStrings = (scope, left, right, bytestrings = false) => {
668
668
  ];
669
669
  };
670
670
 
671
- const truthy = (scope, wasm, type, intIn = false, intOut = false) => {
672
- if (isFloatToIntOp(wasm[wasm.length - 1])) return [
671
+ const truthy = (scope, wasm, type, intIn = false, intOut = false, forceTruthyMode = undefined) => {
672
+ if (isIntToFloatOp(wasm[wasm.length - 1])) return [
673
673
  ...wasm,
674
674
  ...(!intIn && intOut ? [ Opcodes.i32_to_u ] : [])
675
675
  ];
676
676
  // if (isIntOp(wasm[wasm.length - 1])) return [ ...wasm ];
677
677
 
678
+ // todo/perf: use knownType and custom bytecode here instead of typeSwitch
679
+
678
680
  const useTmp = knownType(scope, type) == null;
679
681
  const tmp = useTmp && localTmp(scope, `#logicinner_tmp${intIn ? '_int' : ''}`, intIn ? Valtype.i32 : valtypeBinary);
680
682
 
681
- const def = [
682
- // if value != 0
683
- ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
683
+ const def = (truthyMode => {
684
+ if (truthyMode === 'full') return [
685
+ // if value != 0 or NaN
686
+ ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
687
+ ...(intIn ? [ ] : [ Opcodes.i32_to ]),
684
688
 
685
- // ...(intIn ? [ [ Opcodes.i32_eqz ] ] : [ ...Opcodes.eqz ]),
686
- // [ Opcodes.i32_eqz ],
689
+ [ Opcodes.i32_eqz ],
690
+ [ Opcodes.i32_eqz ],
687
691
 
688
- // ...(intIn ? [
689
- // ...number(0, Valtype.i32),
690
- // [ Opcodes.i32_gt_s ]
691
- // ] : [
692
- // ...number(0),
693
- // [ Opcodes.f64_gt ]
694
- // ]),
695
-
696
- // ...(intOut ? [] : [ Opcodes.i32_from ]),
697
-
698
- // ...(intIn ? [] : [ Opcodes.i32_to ]),
699
- // [ Opcodes.if, intOut ? Valtype.i32 : valtypeBinary ],
700
- // ...number(1, intOut ? Valtype.i32 : valtypeBinary),
701
- // [ Opcodes.else ],
702
- // ...number(0, intOut ? Valtype.i32 : valtypeBinary),
703
- // [ Opcodes.end ],
704
-
705
- ...(!intOut || (intIn && intOut) ? [] : [ Opcodes.i32_to_u ]),
706
-
707
- /* Opcodes.eqz,
708
- [ Opcodes.i32_eqz ],
709
- Opcodes.i32_from */
710
- ];
692
+ ...(intOut ? [] : [ Opcodes.i32_from ]),
693
+ ];
694
+
695
+ if (truthyMode === 'no_negative') return [
696
+ // if value != 0 or NaN, non-binary output. negative numbers not truthy :/
697
+ ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
698
+ ...(intIn ? [] : [ Opcodes.i32_to ]),
699
+ ...(intOut ? [] : [ Opcodes.i32_from ])
700
+ ];
701
+
702
+ if (truthyMode === 'no_nan_negative') return [
703
+ // simpler and faster but makes NaN truthy and negative numbers not truthy,
704
+ // plus non-binary output
705
+ ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
706
+ ...(!intOut || (intIn && intOut) ? [] : [ Opcodes.i32_to_u ])
707
+ ];
708
+ })(forceTruthyMode ?? Prefs.truthy ?? 'full');
711
709
 
712
710
  return [
713
711
  ...wasm,
714
712
  ...(!useTmp ? [] : [ [ Opcodes.local_set, tmp ] ]),
715
713
 
716
714
  ...typeSwitch(scope, type, {
717
- // [TYPES.number]: def,
718
- [TYPES.array]: [
719
- // arrays are always truthy
720
- ...number(1, intOut ? Valtype.i32 : valtypeBinary)
721
- ],
722
715
  [TYPES.string]: [
723
716
  ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
724
717
  ...(intIn ? [] : [ Opcodes.i32_to_u ]),
@@ -754,10 +747,6 @@ const falsy = (scope, wasm, type, intIn = false, intOut = false) => {
754
747
  ...(!useTmp ? [] : [ [ Opcodes.local_set, tmp ] ]),
755
748
 
756
749
  ...typeSwitch(scope, type, {
757
- [TYPES.array]: [
758
- // arrays are always truthy
759
- ...number(0, intOut ? Valtype.i32 : valtypeBinary)
760
- ],
761
750
  [TYPES.string]: [
762
751
  ...(!useTmp ? [] : [ [ Opcodes.local_get, tmp ] ]),
763
752
  ...(intIn ? [] : [ Opcodes.i32_to_u ]),
@@ -1001,7 +990,7 @@ const performOp = (scope, op, left, right, leftType, rightType, _global = false,
1001
990
  // if both are true
1002
991
  [ Opcodes.i32_and ],
1003
992
  [ Opcodes.if, Blocktype.void ],
1004
- ...compareStrings(scope, [ [ Opcodes.local_get, tmpLeft ] ], [ [ Opcodes.local_get, tmpRight ] ]),
993
+ ...compareStrings(scope, [ [ Opcodes.local_get, tmpLeft ] ], [ [ Opcodes.local_get, tmpRight ] ], false),
1005
994
  ...(op === '!==' || op === '!=' ? [ [ Opcodes.i32_eqz ] ] : []),
1006
995
  [ Opcodes.br, 1 ],
1007
996
  [ Opcodes.end ],
@@ -2592,6 +2581,11 @@ const generateUnary = (scope, decl) => {
2592
2581
  ];
2593
2582
 
2594
2583
  case '!':
2584
+ const arg = decl.argument;
2585
+ if (arg.type === "UnaryExpression" && arg.operator === "!") {
2586
+ // !!x -> is x truthy
2587
+ return truthy(scope, generate(scope, arg.argument), getNodeType(scope, arg.argument), false, false);
2588
+ }
2595
2589
  // !=
2596
2590
  return falsy(scope, generate(scope, decl.argument), getNodeType(scope, decl.argument), false, false);
2597
2591
 
@@ -3030,6 +3024,44 @@ const generateForOf = (scope, decl) => {
3030
3024
  [ Opcodes.end ],
3031
3025
  [ Opcodes.end ]
3032
3026
  ],
3027
+ [TYPES.set]: [
3028
+ [ Opcodes.loop, Blocktype.void ],
3029
+
3030
+ [ Opcodes.local_get, pointer ],
3031
+ [ Opcodes.load, 0, ...unsignedLEB128(ValtypeSize.i32) ],
3032
+
3033
+ ...setType(scope, leftName, [
3034
+ [ Opcodes.local_get, pointer ],
3035
+ [ Opcodes.i32_load8_u, 0, ...unsignedLEB128(ValtypeSize.i32 + ValtypeSize[valtype]) ],
3036
+ ]),
3037
+
3038
+ [ isGlobal ? Opcodes.global_set : Opcodes.local_set, local.idx ],
3039
+
3040
+ [ Opcodes.block, Blocktype.void ],
3041
+ [ Opcodes.block, Blocktype.void ],
3042
+ ...generate(scope, decl.body),
3043
+ [ Opcodes.end ],
3044
+
3045
+ // increment iter pointer by valtype size + 1
3046
+ [ Opcodes.local_get, pointer ],
3047
+ ...number(ValtypeSize[valtype] + 1, Valtype.i32),
3048
+ [ Opcodes.i32_add ],
3049
+ [ Opcodes.local_set, pointer ],
3050
+
3051
+ // increment counter by 1
3052
+ [ Opcodes.local_get, counter ],
3053
+ ...number(1, Valtype.i32),
3054
+ [ Opcodes.i32_add ],
3055
+ [ Opcodes.local_tee, counter ],
3056
+
3057
+ // loop if counter != length
3058
+ [ Opcodes.local_get, length ],
3059
+ [ Opcodes.i32_ne ],
3060
+ [ Opcodes.br_if, 1 ],
3061
+
3062
+ [ Opcodes.end ],
3063
+ [ Opcodes.end ]
3064
+ ],
3033
3065
  default: internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`)
3034
3066
  }, Blocktype.void));
3035
3067
 
@@ -3248,8 +3280,13 @@ const makeArray = (scope, decl, global = false, name = '$undeclared', initEmpty
3248
3280
  // todo: can we just have 1 undeclared array? probably not? but this is not really memory efficient
3249
3281
  const uniqueName = name === '$undeclared' ? name + Math.random().toString().slice(2) : name;
3250
3282
 
3251
- if (Prefs.scopedPageNames) scope.arrays.set(name, allocPage(scope, `${getAllocType(itemType)}: ${scope.name}/${uniqueName}`, itemType) * pageSize);
3252
- else scope.arrays.set(name, allocPage(scope, `${getAllocType(itemType)}: ${uniqueName}`, itemType) * pageSize);
3283
+ let page;
3284
+ if (Prefs.scopedPageNames) page = allocPage(scope, `${getAllocType(itemType)}: ${scope.name}/${uniqueName}`, itemType);
3285
+ else page = allocPage(scope, `${getAllocType(itemType)}: ${uniqueName}`, itemType);
3286
+
3287
+ // hack: use 1 for page 0 pointer for fast truthiness
3288
+ const ptr = page === 0 ? 1 : (page * pageSize);
3289
+ scope.arrays.set(name, ptr);
3253
3290
  }
3254
3291
 
3255
3292
  const pointer = scope.arrays.get(name);
@@ -3846,7 +3883,7 @@ const internalConstrs = {
3846
3883
  generate: (scope, decl) => {
3847
3884
  // todo: boolean object when used as constructor
3848
3885
  const arg = decl.arguments[0] ?? DEFAULT_VALUE;
3849
- return truthy(scope, generate(scope, arg), getNodeType(scope, arg));
3886
+ return truthy(scope, generate(scope, arg), getNodeType(scope, arg), false, false, 'full');
3850
3887
  },
3851
3888
  type: TYPES.boolean,
3852
3889
  length: 1
@@ -89,6 +89,10 @@ export default (wasm, name = '', ind = 0, locals = {}, params = [], returns = []
89
89
  if (inst[0] === Opcodes.call || inst[0] === Opcodes.return_call) {
90
90
  const callFunc = funcs.find(x => x.index === inst[1]);
91
91
  if (callFunc) out += ` ;; $${callFunc.name} ${makeSignature(callFunc.params, callFunc.returns)}`;
92
+ if (globalThis.importFuncs && inst[1] < importFuncs.length) {
93
+ const importFunc = importFuncs[inst[1]];
94
+ out += ` ;; import ${importFunc.name} ${makeSignature(new Array(importFunc.params).fill(valtypeBinary), new Array(importFunc.returns).fill(valtypeBinary),)}`;
95
+ }
92
96
  }
93
97
 
94
98
  if (inst[0] === Opcodes.local_get || inst[0] === Opcodes.local_set || inst[0] === Opcodes.local_tee) {
@@ -310,7 +310,7 @@ export const BuiltinFuncs = function() {
310
310
  table: true
311
311
  };
312
312
  this.__Array_prototype_filter = {
313
- wasm: (scope, {allocPage,internalThrow,}) => [...number(allocPage(scope, 'array: __Array_prototype_filter/out', 'f64') * pageSize, 124),[34,4],[252,3],[34,5],[65,0],[54,1,0],[32,0],[252,3],[40,1,0],[184],[33,6],[68,0,0,0,0,0,0,0,0],[33,7],[3,64],[32,7],[32,6],[99],[4,64],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[33,11],[33,8],[65,0],[33,9],[32,3],[33,19],[2,124],[32,19],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,8],[32,9],[33,12],[33,13],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[32,11],[33,14],[33,15],[32,0],[65,16],[33,16],[33,17],[32,2],[252,3],[33,18],[2,124],[2,64],[2,64],[2,64],[2,64],[32,18],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,18],[17,0,0],[33,11],[12,3],[11],[32,13],[32,12],[32,18],[17,1,0],[33,11],[12,2],[11],[32,13],[32,12],[32,15],[32,14],[32,18],[17,2,0],[33,11],[12,1],[11],[32,13],[32,12],[32,15],[32,14],[32,17],[32,16],[32,18],[17,3,0],[33,11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,20],[32,11],[33,19],[2,127],[32,19],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,20],[252,3],[40,1,0],[12,1],[11],[32,19],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,19],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,20],[252,3],[40,1,0],[12,1],[11],[32,20],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,4],[252,3],[34,22],[40,1,0],[34,21],[65,9],[108],[32,22],[106],[34,23],[32,8],[57,0,4],[32,23],[32,9],[58,0,12],[32,22],[32,21],[65,1],[106],[54,1,0],[11],[12,1],[11],[11],[32,4],[65,16],[15]],
313
+ wasm: (scope, {allocPage,internalThrow,}) => [...number(allocPage(scope, 'array: __Array_prototype_filter/out', 'f64') * pageSize, 124),[34,4],[252,3],[34,5],[65,0],[54,1,0],[32,0],[252,3],[40,1,0],[184],[33,6],[68,0,0,0,0,0,0,0,0],[33,7],[3,64],[32,7],[32,6],[99],[4,64],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[33,11],[33,8],[65,0],[33,9],[32,3],[33,19],[2,124],[32,19],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,8],[32,9],[33,12],[33,13],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[32,11],[33,14],[33,15],[32,0],[65,16],[33,16],[33,17],[32,2],[252,3],[33,18],[2,124],[2,64],[2,64],[2,64],[2,64],[32,18],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,18],[17,0,0],[33,11],[12,3],[11],[32,13],[32,12],[32,18],[17,1,0],[33,11],[12,2],[11],[32,13],[32,12],[32,15],[32,14],[32,18],[17,2,0],[33,11],[12,1],[11],[32,13],[32,12],[32,15],[32,14],[32,17],[32,16],[32,18],[17,3,0],[33,11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,20],[32,11],[33,19],[2,124],[32,19],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,20],[252,3],[40,1,0],[184],[12,1],[11],[32,19],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,20],[252,3],[40,1,0],[184],[12,1],[11],[32,20],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,4],[252,3],[34,22],[40,1,0],[34,21],[65,9],[108],[32,22],[106],[34,23],[32,8],[57,0,4],[32,23],[32,9],[58,0,12],[32,22],[32,21],[65,1],[106],[54,1,0],[11],[12,1],[11],[11],[32,4],[65,16],[15]],
314
314
  params: [124,127,124,127],
315
315
  typedParams: true,
316
316
  returns: [124,127],
@@ -330,7 +330,7 @@ export const BuiltinFuncs = function() {
330
330
  table: true
331
331
  };
332
332
  this.__Array_prototype_find = {
333
- wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,8],[43,0,4],[32,8],[45,0,12],[33,9],[33,6],[65,0],[33,7],[32,3],[33,17],[2,124],[32,17],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,6],[32,7],[33,10],[33,11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,9],[33,12],[33,13],[32,0],[65,16],[33,14],[33,15],[32,2],[252,3],[33,16],[2,124],[2,64],[2,64],[2,64],[2,64],[32,16],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,16],[17,0,0],[33,9],[12,3],[11],[32,11],[32,10],[32,16],[17,1,0],[33,9],[12,2],[11],[32,11],[32,10],[32,13],[32,12],[32,16],[17,2,0],[33,9],[12,1],[11],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,3,0],[33,9],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,18],[32,9],[33,17],[2,127],[32,17],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,18],[252,3],[40,1,0],[12,1],[11],[32,17],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,17],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,18],[252,3],[40,1,0],[12,1],[11],[32,18],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,6],[32,7],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
333
+ wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,8],[43,0,4],[32,8],[45,0,12],[33,9],[33,6],[65,0],[33,7],[32,3],[33,17],[2,124],[32,17],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,6],[32,7],[33,10],[33,11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,9],[33,12],[33,13],[32,0],[65,16],[33,14],[33,15],[32,2],[252,3],[33,16],[2,124],[2,64],[2,64],[2,64],[2,64],[32,16],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,16],[17,0,0],[33,9],[12,3],[11],[32,11],[32,10],[32,16],[17,1,0],[33,9],[12,2],[11],[32,11],[32,10],[32,13],[32,12],[32,16],[17,2,0],[33,9],[12,1],[11],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,3,0],[33,9],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,18],[32,9],[33,17],[2,124],[32,17],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,18],[252,3],[40,1,0],[184],[12,1],[11],[32,17],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,18],[252,3],[40,1,0],[184],[12,1],[11],[32,18],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,6],[32,7],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
334
334
  params: [124,127,124,127],
335
335
  typedParams: true,
336
336
  returns: [124,127],
@@ -340,7 +340,7 @@ export const BuiltinFuncs = function() {
340
340
  table: true
341
341
  };
342
342
  this.__Array_prototype_findLast = {
343
- wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[3,64],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[68,0,0,0,0,0,0,240,63],[161],[34,4],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,7],[43,0,4],[32,7],[45,0,12],[33,8],[33,5],[65,0],[33,6],[32,3],[33,16],[2,124],[32,16],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,5],[32,6],[33,9],[33,10],[32,4],[65,0],[33,11],[33,12],[32,0],[65,16],[33,13],[33,14],[32,2],[252,3],[33,15],[2,124],[2,64],[2,64],[2,64],[2,64],[32,15],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,15],[17,0,0],[33,8],[12,3],[11],[32,10],[32,9],[32,15],[17,1,0],[33,8],[12,2],[11],[32,10],[32,9],[32,12],[32,11],[32,15],[17,2,0],[33,8],[12,1],[11],[32,10],[32,9],[32,12],[32,11],[32,14],[32,13],[32,15],[17,3,0],[33,8],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,17],[32,8],[33,16],[2,127],[32,16],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,17],[252,3],[40,1,0],[12,1],[11],[32,16],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,16],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,17],[252,3],[40,1,0],[12,1],[11],[32,17],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,5],[32,6],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
343
+ wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[3,64],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[68,0,0,0,0,0,0,240,63],[161],[34,4],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,7],[43,0,4],[32,7],[45,0,12],[33,8],[33,5],[65,0],[33,6],[32,3],[33,16],[2,124],[32,16],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,5],[32,6],[33,9],[33,10],[32,4],[65,0],[33,11],[33,12],[32,0],[65,16],[33,13],[33,14],[32,2],[252,3],[33,15],[2,124],[2,64],[2,64],[2,64],[2,64],[32,15],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,15],[17,0,0],[33,8],[12,3],[11],[32,10],[32,9],[32,15],[17,1,0],[33,8],[12,2],[11],[32,10],[32,9],[32,12],[32,11],[32,15],[17,2,0],[33,8],[12,1],[11],[32,10],[32,9],[32,12],[32,11],[32,14],[32,13],[32,15],[17,3,0],[33,8],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,17],[32,8],[33,16],[2,124],[32,16],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,17],[252,3],[40,1,0],[184],[12,1],[11],[32,16],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,17],[252,3],[40,1,0],[184],[12,1],[11],[32,17],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,5],[32,6],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
344
344
  params: [124,127,124,127],
345
345
  typedParams: true,
346
346
  returns: [124,127],
@@ -350,7 +350,7 @@ export const BuiltinFuncs = function() {
350
350
  table: true
351
351
  };
352
352
  this.__Array_prototype_findIndex = {
353
- wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,3],[33,15],[2,124],[32,15],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,6],[43,0,4],[32,6],[45,0,12],[33,7],[65,0],[33,8],[33,9],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,7],[33,10],[33,11],[32,0],[65,16],[33,12],[33,13],[32,2],[252,3],[33,14],[2,124],[2,64],[2,64],[2,64],[2,64],[32,14],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,14],[17,0,0],[33,7],[12,3],[11],[32,9],[32,8],[32,14],[17,1,0],[33,7],[12,2],[11],[32,9],[32,8],[32,11],[32,10],[32,14],[17,2,0],[33,7],[12,1],[11],[32,9],[32,8],[32,11],[32,10],[32,13],[32,12],[32,14],[17,3,0],[33,7],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,16],[32,7],[33,15],[2,127],[32,15],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,16],[252,3],[40,1,0],[12,1],[11],[32,15],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,15],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,16],[252,3],[40,1,0],[12,1],[11],[32,16],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,5],[65,0],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
353
+ wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,3],[33,15],[2,124],[32,15],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,6],[43,0,4],[32,6],[45,0,12],[33,7],[65,0],[33,8],[33,9],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,7],[33,10],[33,11],[32,0],[65,16],[33,12],[33,13],[32,2],[252,3],[33,14],[2,124],[2,64],[2,64],[2,64],[2,64],[32,14],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,14],[17,0,0],[33,7],[12,3],[11],[32,9],[32,8],[32,14],[17,1,0],[33,7],[12,2],[11],[32,9],[32,8],[32,11],[32,10],[32,14],[17,2,0],[33,7],[12,1],[11],[32,9],[32,8],[32,11],[32,10],[32,13],[32,12],[32,14],[17,3,0],[33,7],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,16],[32,7],[33,15],[2,124],[32,15],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,16],[252,3],[40,1,0],[184],[12,1],[11],[32,15],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,16],[252,3],[40,1,0],[184],[12,1],[11],[32,16],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,5],[65,0],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
354
354
  params: [124,127,124,127],
355
355
  typedParams: true,
356
356
  returns: [124,127],
@@ -360,7 +360,7 @@ export const BuiltinFuncs = function() {
360
360
  table: true
361
361
  };
362
362
  this.__Array_prototype_findLastIndex = {
363
- wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[3,64],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,3],[33,14],[2,124],[32,14],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,4],[68,0,0,0,0,0,0,240,63],[161],[34,4],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,5],[43,0,4],[32,5],[45,0,12],[33,6],[65,0],[33,7],[33,8],[32,4],[65,0],[33,9],[33,10],[32,0],[65,16],[33,11],[33,12],[32,2],[252,3],[33,13],[2,124],[2,64],[2,64],[2,64],[2,64],[32,13],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,13],[17,0,0],[33,6],[12,3],[11],[32,8],[32,7],[32,13],[17,1,0],[33,6],[12,2],[11],[32,8],[32,7],[32,10],[32,9],[32,13],[17,2,0],[33,6],[12,1],[11],[32,8],[32,7],[32,10],[32,9],[32,12],[32,11],[32,13],[17,3,0],[33,6],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,15],[32,6],[33,14],[2,127],[32,14],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,15],[252,3],[40,1,0],[12,1],[11],[32,14],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,14],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,15],[252,3],[40,1,0],[12,1],[11],[32,15],[252,3],[11,"TYPESWITCH_end"],[4,64],[32,4],[65,0],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
363
+ wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[3,64],[32,4],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,3],[33,14],[2,124],[32,14],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,4],[68,0,0,0,0,0,0,240,63],[161],[34,4],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,5],[43,0,4],[32,5],[45,0,12],[33,6],[65,0],[33,7],[33,8],[32,4],[65,0],[33,9],[33,10],[32,0],[65,16],[33,11],[33,12],[32,2],[252,3],[33,13],[2,124],[2,64],[2,64],[2,64],[2,64],[32,13],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,13],[17,0,0],[33,6],[12,3],[11],[32,8],[32,7],[32,13],[17,1,0],[33,6],[12,2],[11],[32,8],[32,7],[32,10],[32,9],[32,13],[17,2,0],[33,6],[12,1],[11],[32,8],[32,7],[32,10],[32,9],[32,12],[32,11],[32,13],[17,3,0],[33,6],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,15],[32,6],[33,14],[2,124],[32,14],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,15],[252,3],[40,1,0],[184],[12,1],[11],[32,14],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,15],[252,3],[40,1,0],[184],[12,1],[11],[32,15],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,4],[65,0],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
364
364
  params: [124,127,124,127],
365
365
  typedParams: true,
366
366
  returns: [124,127],
@@ -370,7 +370,7 @@ export const BuiltinFuncs = function() {
370
370
  table: true
371
371
  };
372
372
  this.__Array_prototype_every = {
373
- wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,3],[33,15],[2,124],[32,15],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,6],[43,0,4],[32,6],[45,0,12],[33,7],[65,0],[33,8],[33,9],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,7],[33,10],[33,11],[32,0],[65,16],[33,12],[33,13],[32,2],[252,3],[33,14],[2,124],[2,64],[2,64],[2,64],[2,64],[32,14],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,14],[17,0,0],[33,7],[12,3],[11],[32,9],[32,8],[32,14],[17,1,0],[33,7],[12,2],[11],[32,9],[32,8],[32,11],[32,10],[32,14],[17,2,0],[33,7],[12,1],[11],[32,9],[32,8],[32,11],[32,10],[32,13],[32,12],[32,14],[17,3,0],[33,7],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,16],[32,7],[33,15],[2,124],[32,15],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,16],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,15],[65,16],[70],[4,64,"TYPESWITCH|Array"],[68,0,0,0,0,0,0,0,0],[12,1],[11],[32,15],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,16],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,16],[68,0,0,0,0,0,0,0,0],[97],[184],[11,"TYPESWITCH_end"],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[65,1],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,240,63],[65,1],[15]],
373
+ wasm: (scope, {internalThrow,}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,3],[33,15],[2,124],[32,15],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,6],[43,0,4],[32,6],[45,0,12],[33,7],[65,0],[33,8],[33,9],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,7],[33,10],[33,11],[32,0],[65,16],[33,12],[33,13],[32,2],[252,3],[33,14],[2,124],[2,64],[2,64],[2,64],[2,64],[32,14],[65,2],[108],[47,0,128,128,12,"read_argc"],[14,4,0,1,2,3,0],[11],[32,14],[17,0,0],[33,7],[12,3],[11],[32,9],[32,8],[32,14],[17,1,0],[33,7],[12,2],[11],[32,9],[32,8],[32,11],[32,10],[32,14],[17,2,0],[33,7],[12,1],[11],[32,9],[32,8],[32,11],[32,10],[32,13],[32,12],[32,14],[17,3,0],[33,7],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,16],[32,7],[33,15],[2,124],[32,15],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,16],[252,3],[40,1,0],[184],[12,1],[11],[32,15],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,16],[252,3],[40,1,0],[184],[12,1],[11],[32,16],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,0,0],[65,1],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,240,63],[65,1],[15]],
374
374
  params: [124,127,124,127],
375
375
  typedParams: true,
376
376
  returns: [124,127],
@@ -380,7 +380,7 @@ export const BuiltinFuncs = function() {
380
380
  table: true
381
381
  };
382
382
  this.btoa = {
383
- wasm: (scope, {allocPage,}) => [...number(allocPage(scope, 'bytestring: btoa/keyStr', 'i8') * pageSize, 127),[34,2],[33,3],[32,0],[40,1,0],[33,4],...number(allocPage(scope, 'bytestring: btoa/output', 'i8') * pageSize, 127),[34,5],[65,4],[32,4],[65,3],[109],[32,4],[65,3],[111],[69],[69],[106],[108],[34,6],[54,1,0],[32,0],[33,7],[32,5],[33,8],[32,7],[32,4],[106],[33,9],[65,0],[33,10],[3,64],[32,7],[32,9],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[33,11],[32,7],[32,9],[72],[4,127],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[65,0],[33,13],[5],[65,127],[65,0],[33,13],[11],[33,12],[32,7],[32,9],[72],[4,127],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[65,0],[33,13],[5],[65,127],[65,0],[33,13],[11],[33,14],[32,11],[65,2],[117],[33,15],[32,11],[65,3],[113],[65,4],[116],[32,12],[65,127],[70],[4,127],[65,0],[65,0],[33,13],[5],[32,12],[65,4],[117],[65,0],[33,13],[11],[114],[33,16],[32,12],[65,15],[113],[65,2],[116],[32,14],[65,127],[70],[4,127],[65,0],[65,0],[33,13],[5],[32,14],[65,6],[117],[65,0],[33,13],[11],[114],[33,17],[32,14],[65,63],[113],[33,18],[32,12],[65,127],[70],[4,64],[65,192,0],[33,17],[65,192,0],[33,18],[5],[32,14],[65,127],[70],[4,64],[65,192,0],[33,18],[11],[11],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,15],[106],[45,0,4],[58,0,4],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,16],[106],[45,0,4],[58,0,4],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,17],[106],[45,0,4],[58,0,4],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,18],[106],[45,0,4],[58,0,4],[12,1],[11],[11],[32,5],[15]],
383
+ wasm: (scope, {allocPage,}) => [...number(allocPage(scope, 'bytestring: btoa/keyStr', 'i8') * pageSize, 127),[34,2],[33,3],[32,0],[40,1,0],[33,4],...number(allocPage(scope, 'bytestring: btoa/output', 'i8') * pageSize, 127),[34,5],[65,4],[32,4],[65,3],[109],[32,4],[65,3],[111],[106],[108],[34,6],[54,1,0],[32,0],[33,7],[32,5],[33,8],[32,7],[32,4],[106],[33,9],[65,0],[33,10],[3,64],[32,7],[32,9],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[33,11],[32,7],[32,9],[72],[4,127],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[65,0],[33,13],[5],[65,127],[65,0],[33,13],[11],[33,12],[32,7],[32,9],[72],[4,127],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[65,0],[33,13],[5],[65,127],[65,0],[33,13],[11],[33,14],[32,11],[65,2],[117],[33,15],[32,11],[65,3],[113],[65,4],[116],[32,12],[65,127],[70],[4,127],[65,0],[65,0],[33,13],[5],[32,12],[65,4],[117],[65,0],[33,13],[11],[114],[33,16],[32,12],[65,15],[113],[65,2],[116],[32,14],[65,127],[70],[4,127],[65,0],[65,0],[33,13],[5],[32,14],[65,6],[117],[65,0],[33,13],[11],[114],[33,17],[32,14],[65,63],[113],[33,18],[32,12],[65,127],[70],[4,64],[65,192,0],[33,17],[65,192,0],[33,18],[5],[32,14],[65,127],[70],[4,64],[65,192,0],[33,18],[11],[11],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,15],[106],[45,0,4],[58,0,4],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,16],[106],[45,0,4],[58,0,4],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,17],[106],[45,0,4],[58,0,4],[32,8],[32,8],[65,1],[106],[33,8],[32,3],[32,18],[106],[45,0,4],[58,0,4],[12,1],[11],[11],[32,5],[15]],
384
384
  params: [127,127],
385
385
  typedParams: true,
386
386
  returns: [127],
@@ -407,6 +407,16 @@ export const BuiltinFuncs = function() {
407
407
  locals: [],
408
408
  localNames: ["_this","_this#type"],
409
409
  };
410
+ this.__console_clear = {
411
+ wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __console_clear/clear', 'i8') * pageSize, 124),[34,0],[65,18],[16, builtin('__Porffor_print')],[68,0,0,0,0,0,0,36,64],[16,1],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
412
+ params: [],
413
+ typedParams: true,
414
+ returns: [124,127],
415
+ typedReturns: true,
416
+ locals: [124],
417
+ localNames: ["clear"],
418
+ data: [{"offset":0,"bytes":[4,0,0,0,27,91,50,74]}],
419
+ };
410
420
  this.__crypto_randomUUID = {
411
421
  wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __crypto_randomUUID/bytes', 'i8') * pageSize, 127),[34,0],[34,1],[34,2],[65,16],[106],[33,3],[3,64],[32,2],[32,3],[72],[4,64],[32,2],[32,2],[65,1],[106],[33,2],[16, builtin('__Porffor_randomByte')],[58,0,4],[12,1],[11],[11],[32,1],[32,1],[45,0,10],[65,15],[113],[65,192,0],[114],[58,0,10],[32,1],[32,1],[45,0,12],[65,63],[113],[65,128,1],[114],[58,0,12],...number(allocPage(scope, 'bytestring: __crypto_randomUUID/output', 'i8') * pageSize, 127),[34,4],[33,5],[32,1],[33,6],[32,5],[65,8],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,4],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,4],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,4],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,12],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[33,5],[32,4],[15]],
412
422
  params: [],
@@ -1413,7 +1423,7 @@ export const BuiltinFuncs = function() {
1413
1423
  localNames: ["x","x#type"],
1414
1424
  };
1415
1425
  this.__Math_pow = {
1416
- wasm: (scope, {builtin,}) => [[32,2],[16, builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[32,2],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,240,63],[15],[11],[32,0],[16, builtin('__Number_isFinite')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,0],[16, builtin('__Number_isNaN')],[252,3],[4,64],[32,0],[15],[11],[32,0],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,0],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,2],[68,0,0,0,0,0,0,0,64],[16, builtin('f64_%')],[68,0,0,0,0,0,0,240,63],[97],[184],[33,4],[65,1],[33,5],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,240,127],[154],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,0,128],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,0],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,240,63],[32,0],[163],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[68,0,0,0,0,0,0,0,0],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,2],[68,0,0,0,0,0,0,0,64],[16, builtin('f64_%')],[68,0,0,0,0,0,0,240,63],[97],[184],[33,4],[65,1],[33,5],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,0,128],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,16],[70],[4,64,"TYPESWITCH|Array"],[65,1],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,240,127],[154],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,2],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,0],[16, builtin('__Math_abs')],[33,8],[65,0],[33,9],[32,8],[68,0,0,0,0,0,0,240,63],[100],[4,64],[68,0,0,0,0,0,0,240,127],[15],[11],[32,8],[68,0,0,0,0,0,0,240,63],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,2],[68,0,0,0,0,0,0,240,127],[154],[97],[4,64],[32,0],[16, builtin('__Math_abs')],[33,8],[65,0],[33,9],[32,8],[68,0,0,0,0,0,0,240,63],[100],[4,64],[68,0,0,0,0,0,0,0,0],[15],[11],[32,8],[68,0,0,0,0,0,0,240,63],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,0],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,2],[16, builtin('__Number_isInteger')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[11],[32,2],[32,0],[65,0],[16, builtin('__Math_log')],[162],[65,0],[16, builtin('__Math_exp')],[15]],
1426
+ wasm: (scope, {builtin,}) => [[32,2],[16, builtin('__Number_isNaN')],[252,3],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[32,2],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,240,63],[15],[11],[32,0],[16, builtin('__Number_isFinite')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,0],[16, builtin('__Number_isNaN')],[252,3],[4,64],[32,0],[15],[11],[32,0],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,0],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,2],[68,0,0,0,0,0,0,0,64],[16, builtin('f64_%')],[68,0,0,0,0,0,0,240,63],[97],[184],[33,4],[65,1],[33,5],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,240,127],[154],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,0,128],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,0],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,240,63],[32,0],[163],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[68,0,0,0,0,0,0,0,0],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,2],[68,0,0,0,0,0,0,0,64],[16, builtin('f64_%')],[68,0,0,0,0,0,0,240,63],[97],[184],[33,4],[65,1],[33,5],[32,2],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,0,128],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,4],[33,6],[32,5],[33,7],[2,127],[32,7],[65,2],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,240,127],[154],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,2],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,0],[16, builtin('__Math_abs')],[33,8],[65,0],[33,9],[32,8],[68,0,0,0,0,0,0,240,63],[100],[4,64],[68,0,0,0,0,0,0,240,127],[15],[11],[32,8],[68,0,0,0,0,0,0,240,63],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[68,0,0,0,0,0,0,0,0],[15],[11],[32,2],[68,0,0,0,0,0,0,240,127],[154],[97],[4,64],[32,0],[16, builtin('__Math_abs')],[33,8],[65,0],[33,9],[32,8],[68,0,0,0,0,0,0,240,63],[100],[4,64],[68,0,0,0,0,0,0,0,0],[15],[11],[32,8],[68,0,0,0,0,0,0,240,63],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[68,0,0,0,0,0,0,240,127],[15],[11],[32,0],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,2],[16, builtin('__Number_isInteger')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[68,0,0,0,0,0,0,248,127],[15],[11],[11],[32,2],[32,0],[65,0],[16, builtin('__Math_log')],[162],[65,0],[16, builtin('__Math_exp')],[15]],
1417
1427
  params: [124,127,124,127],
1418
1428
  typedParams: true,
1419
1429
  returns: [124],
@@ -1684,7 +1694,7 @@ export const BuiltinFuncs = function() {
1684
1694
  localNames: ["_this","_this#type","#last_type"],
1685
1695
  };
1686
1696
  this.__Set_prototype_has = {
1687
- wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
1697
+ wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
1688
1698
  params: [124,127,124,127],
1689
1699
  typedParams: true,
1690
1700
  returns: [124,127],
@@ -1693,7 +1703,7 @@ export const BuiltinFuncs = function() {
1693
1703
  localNames: ["_this","_this#type","value","value#type","size","i","#last_type","__tmpop_left","__tmpop_right","compare_left_pointer","compare_left_length","compare_right_pointer","compare_index","compare_index_end"],
1694
1704
  };
1695
1705
  this.__Set_prototype_add = {
1696
- wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[32,0],[65,20],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[32,0],[252,2],[32,4],[68,0,0,0,0,0,0,240,63],[160],[252,2],[54,0,0],[32,0],[65,20],[32,4],[65,0],[32,2],[32,3],[16, builtin('__Porffor_set_write')],[26],[32,0],[65,20],[15]],
1706
+ wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[32,0],[65,20],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[32,0],[252,2],[32,4],[68,0,0,0,0,0,0,240,63],[160],[252,2],[54,0,0],[32,0],[65,20],[32,4],[65,0],[32,2],[32,3],[16, builtin('__Porffor_set_write')],[26],[32,0],[65,20],[15]],
1697
1707
  params: [124,127,124,127],
1698
1708
  typedParams: true,
1699
1709
  returns: [124,127],
@@ -1702,7 +1712,7 @@ export const BuiltinFuncs = function() {
1702
1712
  localNames: ["_this","_this#type","value","value#type","size","i","#last_type","__tmpop_left","__tmpop_right","compare_left_pointer","compare_left_length","compare_right_pointer","compare_index","compare_index_end"],
1703
1713
  };
1704
1714
  this.__Set_prototype_delete = {
1705
- wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[71],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[32,0],[252,2],[32,4],[68,0,0,0,0,0,0,240,63],[161],[252,2],[54,0,0],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[65,4],[106],[34,14],[32,14],[65,9],[106],[32,4],[32,5],[161],[252,3],[65,1],[107],[65,9],[108],[252,10,0,0],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
1715
+ wasm: (scope, {builtin,}) => [[32,0],[252,2],[40,0,0],[183],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[2,64],[2,127,"string_only"],[32,0],[65,20],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,6],[34,7,"string_only"],[32,2],[34,8,"string_only"],[32,6,"string_only|start"],[65,2],[70],[32,3],[65,2],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[65,2],[108],[33,13],[3,64],[32,12],[32,9],[106],[47,0,4],[32,12],[32,11],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,2],[106],[34,12],[32,13],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11],[32,6],[65,18],[70],[32,3],[65,18],[70],[113],[4,64],[32,7],[252,3],[34,9],[32,8],[252,3],[34,11],[71],[4,127],[32,9],[40,0,0],[34,10],[32,11],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,12],[32,10],[33,13],[3,64],[32,12],[32,9],[106],[45,0,4],[32,12],[32,11],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,12],[65,1],[106],[34,12],[32,13],[72],[13,0],[11],[65,1],[5],[65,1],[11],[12,1],[11,"string_only|end"],[97],[11,"string_only"],[32,6],[32,3],[70],[113],[4,64],[32,0],[252,2],[32,4],[68,0,0,0,0,0,0,240,63],[161],[252,2],[54,0,0],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[65,4],[106],[34,14],[32,14],[65,9],[106],[32,4],[32,5],[161],[252,3],[65,1],[107],[65,9],[108],[252,10,0,0],[68,0,0,0,0,0,0,240,63],[65,1],[15],[11],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,1],[15]],
1706
1716
  params: [124,127,124,127],
1707
1717
  typedParams: true,
1708
1718
  returns: [124,127],
@@ -1729,7 +1739,7 @@ export const BuiltinFuncs = function() {
1729
1739
  localNames: [],
1730
1740
  };
1731
1741
  this.Set$constructor = {
1732
- wasm: (scope, {builtin,internalThrow,}) => [[16, builtin('__Porffor_allocate')],[33,2],[32,0],[32,1],[16, builtin('__Porffor_rawType')],[34,3],[68,0,0,0,0,0,0,48,64],[97],[32,3],[68,0,0,0,0,0,0,0,64],[97],[114],[32,3],[68,0,0,0,0,0,0,50,64],[97],[114],[32,3],[68,0,0,0,0,0,0,52,64],[97],[114],[4,64],[32,0],[252,3],[33,4],[65,0],[33,6],[32,4],[40,1,0],[33,5],[32,1],[33,10],[2,64],[32,10],[65,2],[70],[4,64,"TYPESWITCH|String"],[65,2],[33,8],[3,64],[65,0],[32,4],[47,0,4],[59,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,2],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,16],[70],[4,64,"TYPESWITCH|Array"],[3,64],[32,4],[43,0,4],[32,4],[45,0,12],[33,8],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,9],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[65,18],[33,8],[3,64],[65,0],[32,4],[32,6],[106],[45,0,4],[58,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`),[11,"TYPESWITCH_end"],[11],[32,2],[15]],
1742
+ wasm: (scope, {builtin,internalThrow,}) => [[16, builtin('__Porffor_allocate')],[33,2],[32,0],[32,1],[16, builtin('__Porffor_rawType')],[34,3],[68,0,0,0,0,0,0,48,64],[97],[32,3],[68,0,0,0,0,0,0,0,64],[97],[114],[32,3],[68,0,0,0,0,0,0,50,64],[97],[114],[32,3],[68,0,0,0,0,0,0,52,64],[97],[114],[4,64],[32,0],[252,3],[33,4],[65,0],[33,6],[32,4],[40,1,0],[33,5],[32,1],[33,10],[2,64],[32,10],[65,2],[70],[4,64,"TYPESWITCH|String"],[65,2],[33,8],[3,64],[65,0],[32,4],[47,0,4],[59,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,2],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,16],[70],[4,64,"TYPESWITCH|Array"],[3,64],[32,4],[43,0,4],[32,4],[45,0,12],[33,8],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,9],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[65,18],[33,8],[3,64],[65,0],[32,4],[32,6],[106],[45,0,4],[58,0,3],[68,0,0,0,0,0,0,240,191],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],[32,10],[65,20],[70],[4,64,"TYPESWITCH|Set"],[3,64],[32,4],[43,0,4],[32,4],[45,0,12],[33,8],[33,7],[2,64],[32,2],[65,20],[32,7],[32,8],[16, builtin('__Set_prototype_add')],[26],[26],[32,4],[65,9],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`),[11,"TYPESWITCH_end"],[11],[32,2],[15]],
1733
1743
  params: [124,127],
1734
1744
  typedParams: true,
1735
1745
  returns: [124],
@@ -1737,8 +1747,17 @@ export const BuiltinFuncs = function() {
1737
1747
  locals: [124,124,127,127,127,124,127,127,127],
1738
1748
  localNames: ["iterable","iterable#type","out","type","forof_base_pointer","forof_length","forof_counter","x","x#type","#last_type","#typeswitch_tmp"],
1739
1749
  };
1750
+ this.__Set_prototype_union = {
1751
+ wasm: (scope, {builtin,internalThrow,}) => [[32,2],[32,3],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,52,64],[98],[4,64],...internalThrow(scope, 'TypeError', `Set.union requires 'Set'`),[11],[32,0],[65,20],[16, builtin('Set$constructor')],[33,4],[32,2],[252,3],[33,5],[65,0],[33,7],[32,5],[40,1,0],[33,6],[32,3],[33,11],[2,64],[32,11],[65,2],[70],[4,64,"TYPESWITCH|String"],[65,2],[33,9],[3,64],[65,0],[32,5],[47,0,4],[59,0,3],[68,0,0,0,0,0,0,240,191],[33,8],[2,64],[32,4],[65,20],[32,8],[32,9],[16, builtin('__Set_prototype_add')],[26],[26],[32,5],[65,2],[106],[33,5],[32,7],[65,1],[106],[34,7],[32,6],[71],[13,1],[11],[11],[12,1],[11],[32,11],[65,16],[70],[4,64,"TYPESWITCH|Array"],[3,64],[32,5],[43,0,4],[32,5],[45,0,12],[33,9],[33,8],[2,64],[32,4],[65,20],[32,8],[32,9],[16, builtin('__Set_prototype_add')],[26],[26],[32,5],[65,9],[106],[33,5],[32,7],[65,1],[106],[34,7],[32,6],[71],[13,1],[11],[11],[12,1],[11],[32,11],[65,18],[70],[4,64,"TYPESWITCH|ByteString"],[65,18],[33,9],[3,64],[65,0],[32,5],[32,7],[106],[45,0,4],[58,0,3],[68,0,0,0,0,0,0,240,191],[33,8],[2,64],[32,4],[65,20],[32,8],[32,9],[16, builtin('__Set_prototype_add')],[26],[26],[32,7],[65,1],[106],[34,7],[32,6],[71],[13,1],[11],[11],[12,1],[11],[32,11],[65,20],[70],[4,64,"TYPESWITCH|Set"],[3,64],[32,5],[43,0,4],[32,5],[45,0,12],[33,9],[33,8],[2,64],[32,4],[65,20],[32,8],[32,9],[16, builtin('__Set_prototype_add')],[26],[26],[32,5],[65,9],[106],[33,5],[32,7],[65,1],[106],[34,7],[32,6],[71],[13,1],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`),[11,"TYPESWITCH_end"],[32,4],[65,20],[15]],
1752
+ params: [124,127,124,127],
1753
+ typedParams: true,
1754
+ returns: [124,127],
1755
+ typedReturns: true,
1756
+ locals: [124,127,127,127,124,127,127,127],
1757
+ localNames: ["_this","_this#type","other","other#type","out","forof_base_pointer","forof_length","forof_counter","x","x#type","#last_type","#typeswitch_tmp"],
1758
+ };
1740
1759
  this.__String_fromCharCode = {
1741
- wasm: (scope, {allocPage,}) => [[32,0],[65,128,2],[72],[4,64],...number(allocPage(scope, 'bytestring: __String_fromCharCode/out', 'i8') * pageSize, 127),[34,2],[32,0],[58,0,4],[32,2],[65,18],[15],[11],[65,0],[34,2],[34,3],[65,1],[54,1,0],[32,3],[65,46],[59,0,4],[32,2],[32,0],[59,0,4],[32,2],[65,2],[15]],
1760
+ wasm: (scope, {allocPage,}) => [[32,0],[65,128,2],[72],[4,64],...number(allocPage(scope, 'bytestring: __String_fromCharCode/out', 'i8') * pageSize, 127),[34,2],[32,0],[58,0,4],[32,2],[65,18],[15],[11],[65,1],[34,2],[34,3],[65,1],[54,1,0],[32,3],[65,46],[59,0,4],[32,2],[32,0],[59,0,4],[32,2],[65,2],[15]],
1742
1761
  params: [127,127],
1743
1762
  typedParams: true,
1744
1763
  returns: [127,127],
package/compiler/index.js CHANGED
@@ -84,7 +84,8 @@ export default (code, flags) => {
84
84
  else compiler = [ compiler ];
85
85
 
86
86
  const tmpfile = 'porffor_tmp.c';
87
- const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-march=native', '-s', '-ffast-math', '-fno-exceptions' ];
87
+ const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO ];
88
+ if (!Prefs.compiler) args.push('-flto=thin', '-march=native', '-s', '-ffast-math', '-fno-exceptions', '-fno-ident', '-fno-asynchronous-unwind-tables', '-ffunction-sections', '-fdata-sections', '-Wl,--gc-sections');
88
89
 
89
90
  const c = toc(out);
90
91
  fs.writeFileSync(tmpfile, c);
package/compiler/parse.js CHANGED
@@ -7,7 +7,7 @@ if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
7
7
  globalThis.process = { argv: ['', '', ...Deno.args], stdout: { write: str => Deno.writeAllSync(Deno.stdout, textEncoder.encode(str)) } };
8
8
  }
9
9
 
10
- const file = process.argv.slice(2).find(x => x[0] !== '-');
10
+ const file = process.argv.slice(2).find(x => x[0] !== '-' && !['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(x));
11
11
 
12
12
  // should we try to support types (while parsing)
13
13
  const types = Prefs.parseTypes || file?.endsWith('.ts');
@@ -18,9 +18,9 @@ const compile = async (file, [ _funcs, _globals ]) => {
18
18
  first = source.slice(0, source.indexOf('\n'));
19
19
  }
20
20
 
21
- let args = ['--bytestring', '--todo-time=compile', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--parse-types', '--opt-types'];
21
+ let args = ['--bytestring', '--todo-time=compile', '--truthy=no_nan_negative', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--parse-types', '--opt-types'];
22
22
  if (first.startsWith('// @porf')) {
23
- args = args.concat(first.slice('// @porf '.length).split(' '));
23
+ args = first.slice('// @porf '.length).split(' ').concat(args);
24
24
  }
25
25
  process.argv = argv.concat(args);
26
26
 
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.14.0-bb0b06c17",
4
+ "version": "0.14.0-bd4ccfc7d",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {
package/runner/index.js CHANGED
@@ -60,8 +60,10 @@ if (process.argv.includes('--help')) {
60
60
 
61
61
  let file = process.argv.slice(2).find(x => x[0] !== '-');
62
62
  if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
63
+ // remove this arg
64
+ process.argv.splice(process.argv.indexOf(file), 1);
65
+
63
66
  if (file === 'profile') {
64
- process.argv.splice(process.argv.indexOf(file), 1);
65
67
  await import('./profiler.js');
66
68
  await new Promise(() => {}); // do nothing for the rest of this file
67
69
  }
@@ -75,12 +77,11 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
75
77
  }
76
78
 
77
79
  if (file === 'debug') {
78
- process.argv.splice(process.argv.indexOf(file), 1);
79
80
  await import('./debug.js');
80
81
  await new Promise(() => {}); // do nothing for the rest of this file
81
82
  }
82
83
 
83
- file = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
84
+ file = process.argv.slice(2).find(x => x[0] !== '-');
84
85
 
85
86
  const nonOptOutFile = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
86
87
  if (nonOptOutFile) {