porffor 0.14.0-b880d42f1 → 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
 
@@ -257,6 +257,4 @@ It will also log new passes/fails. Be careful as sometimes the overall passes ca
257
257
 
258
258
  <br>
259
259
 
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).
261
-
262
- [^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
@@ -207,6 +207,8 @@ export default ({ funcs, globals, tags, data, exceptions, pages }) => {
207
207
  depth = 1;
208
208
  brDepth = 0;
209
209
 
210
+ let retTmpId = 0;
211
+
210
212
  const invLocals = inv(f.locals, x => x.idx);
211
213
 
212
214
  for (const x in invLocals) {
@@ -537,7 +539,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
537
539
  if (func.internal) {
538
540
  vals.push(`${sanitize(func.name)}(${args.join(', ')})`);
539
541
  } else {
540
- line(`const struct ReturnValue _ = ${sanitize(func.name)}(${args.join(', ')})`);
542
+ line(`const struct ReturnValue _${retTmpId++} = ${sanitize(func.name)}(${args.join(', ')})`);
541
543
  vals.push(`_.value`);
542
544
  vals.push(`_.type`);
543
545
  }
@@ -0,0 +1,4 @@
1
+ export const __console_clear = (): void => {
2
+ const clear: bytestring = '\x1b[2J';
3
+ console.log(clear);
4
+ };
@@ -185,4 +185,15 @@ export const Set$constructor = (iterable: any): Set => {
185
185
  }
186
186
 
187
187
  return out;
188
- };
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
+ };
@@ -20,7 +20,6 @@ export const Symbol = (description: any): Symbol => {
20
20
  return __Porffor_symbol_descStore(true, description) + 1;
21
21
  };
22
22
 
23
- // todo: this should be a getter somehow not a method
24
23
  export const __Symbol_prototype_description$get = (_this: Symbol) => {
25
24
  const description: bytestring = __Porffor_symbol_descStore(false,
26
25
  Porffor.wasm`local.get ${_this}` - 1);
@@ -1095,16 +1095,5 @@ export const BuiltinFuncs = function() {
1095
1095
  ]
1096
1096
  };
1097
1097
 
1098
-
1099
- this.__fs_readFileSync = {
1100
- params: [ valtypeBinary, valtypeBinary ],
1101
- locals: [],
1102
- returns: [ valtypeBinary ],
1103
- returnType: TYPES.bytestring,
1104
- wasm: [
1105
- [ Opcodes.call, importedFuncs.__Porffor_readFile ],
1106
- ]
1107
- };
1108
-
1109
1098
  GeneratedBuiltins.BuiltinFuncs.call(this);
1110
1099
  };
@@ -675,6 +675,8 @@ const truthy = (scope, wasm, type, intIn = false, intOut = false, forceTruthyMod
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
 
@@ -2579,7 +2581,11 @@ const generateUnary = (scope, decl) => {
2579
2581
  ];
2580
2582
 
2581
2583
  case '!':
2582
- // todo/perf: optimize !!
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
+ }
2583
2589
  // !=
2584
2590
  return falsy(scope, generate(scope, decl.argument), getNodeType(scope, decl.argument), false, false);
2585
2591
 
@@ -3018,6 +3024,44 @@ const generateForOf = (scope, decl) => {
3018
3024
  [ Opcodes.end ],
3019
3025
  [ Opcodes.end ]
3020
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
+ ],
3021
3065
  default: internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`)
3022
3066
  }, Blocktype.void));
3023
3067
 
@@ -3429,19 +3473,8 @@ const withType = (scope, wasm, type) => [
3429
3473
 
3430
3474
  const generateMember = (scope, decl, _global, _name) => {
3431
3475
  const name = decl.object.name;
3432
-
3433
- // hack: process.argv[n]
3434
- if (name === '__process_argv') {
3435
- const setPointer = scope.arrays?.get(_name);
3436
-
3437
- return [
3438
- ...number(decl.property.value - 1),
3439
- ...(setPointer ? number(setPointer) : allocPage(scope, `__process_argv out (${randId()})`)),
3440
- [ Opcodes.call, importedFuncs.__Porffor_readArgv ]
3441
- ];
3442
- }
3443
-
3444
3476
  const pointer = scope.arrays?.get(name);
3477
+
3445
3478
  const aotPointer = Prefs.aotPointerOpt && pointer;
3446
3479
 
3447
3480
  // hack: .name
@@ -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) {
@@ -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: [],
@@ -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,6 +1747,15 @@ 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
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],
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, '-flto=thin', '-march=native', '-s', '-ffast-math', '-fno-exceptions', '-fno-ident', '-fno-asynchronous-unwind-tables', '-ffunction-sections', '-fdata-sections', '-Wl,--gc-sections' ];
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/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-b880d42f1",
4
+ "version": "0.14.0-bd4ccfc7d",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {