porffor 0.21.8 → 0.22.0

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.
@@ -391,7 +391,10 @@ export const __Object_isSealed = (obj: any): any => {
391
391
 
392
392
 
393
393
  export const __Object_getOwnPropertyDescriptor = (obj: any, prop: any): any => {
394
- if (!Porffor.object.isObjectOrSymbol(obj)) throw new TypeError('Object should be an object or symbol');
394
+ // todo: support non-pure-objects
395
+ if (Porffor.rawType(obj) != Porffor.TYPES.object) {
396
+ return undefined;
397
+ }
395
398
 
396
399
  const p: any = ecma262.ToPropertyKey(prop);
397
400
  const entryPtr: i32 = Porffor.object.lookup(obj, p);
@@ -424,6 +427,80 @@ local.set ${value+1}`;
424
427
  return out;
425
428
  };
426
429
 
430
+ export const __Object_getOwnPropertyDescriptors = (obj: any): any => {
431
+ const out: object = {};
432
+
433
+ // todo: support non-pure-objects
434
+ if (Porffor.rawType(obj) != Porffor.TYPES.object) {
435
+ return out;
436
+ }
437
+
438
+ for (const x in obj) {
439
+ out[x] = __Object_getOwnPropertyDescriptor(obj, x);
440
+ }
441
+
442
+ return out;
443
+ };
444
+
445
+
446
+ export const __Object_getOwnPropertyNames = (obj: any): any[] => {
447
+ if (obj == null) throw new TypeError('Argument is nullish, expected object');
448
+
449
+ const out: any[] = Porffor.allocate();
450
+
451
+ const t: i32 = Porffor.rawType(obj);
452
+ if (t == Porffor.TYPES.object) {
453
+ let ptr: i32 = Porffor.wasm`local.get ${obj}` + 5;
454
+ const endPtr: i32 = ptr + Porffor.wasm.i32.load(obj, 0, 0) * 14;
455
+
456
+ let i: i32 = 0;
457
+ for (; ptr < endPtr; ptr += 14) {
458
+ let key: any;
459
+ Porffor.wasm`local raw i32
460
+ local.get ${ptr}
461
+ i32.to_u
462
+ i32.load 0 0
463
+ local.set raw
464
+
465
+ local.get raw
466
+ i32.const 31
467
+ i32.shr_u
468
+ if 127
469
+ i32.const 67
470
+ local.set ${key+1}
471
+
472
+ local.get raw
473
+ i32.const 2147483647
474
+ i32.and
475
+ else
476
+ i32.const 195
477
+ local.set ${key+1}
478
+
479
+ local.get raw
480
+ end
481
+ i32.from_u
482
+ local.set ${key}`;
483
+
484
+ out[i++] = key;
485
+ }
486
+
487
+ out.length = i;
488
+ } else if (Porffor.fastOr(
489
+ t == Porffor.TYPES.array,
490
+ t == Porffor.TYPES.bytestring,
491
+ t == Porffor.TYPES.string
492
+ )) {
493
+ const len: i32 = obj.length;
494
+ out.length = len;
495
+
496
+ for (let i: i32 = 0; i < len; i++) {
497
+ out[i] = __Number_prototype_toString(i);
498
+ }
499
+ }
500
+
501
+ return out;
502
+ };
503
+
427
504
 
428
505
  export const __Object_prototype_toString = (_this: object) => {
429
506
  let out: bytestring = '[object Object]';
@@ -1780,10 +1780,22 @@ export const BuiltinFuncs = function() {
1780
1780
  locals: [127,124,127], localNames: ["obj","obj#type","#last_type","#logicinner_tmp","#typeswitch_tmp"],
1781
1781
  };
1782
1782
  this.__Object_getOwnPropertyDescriptor = {
1783
- wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[32,1],[16, ...builtin('__Porffor_object_isObjectOrSymbol')],[33,4],[183],[33,5],[32,4],[33,6],[2,124],[32,6],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,5],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,6],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,5],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,5],[68,0,0,0,0,0,0,0,0],[97],[184],[11,"TYPESWITCH_end"],[252,3],[4,64],...internalThrow(scope, 'TypeError', `Object should be an object or symbol`),[11],[32,2],[32,3],[16, ...builtin('__ecma262_ToPropertyKey')],[33,8],[33,7],[32,0],[252,2],[32,1],[32,7],[252,2],[32,8],[16, ...builtin('__Porffor_object_lookup')],[33,4],[183],[34,9],[68,0,0,0,0,0,0,240,191],[97],[4,64],[68,0,0,0,0,0,0,0,0],[65,128,1],[15],[11],[16, ...builtin('__Porffor_allocate')],[184],[33,10],[32,9],[252,2],[47,0,12],[183],[33,11],[32,10],[33,14],[16, ...builtin('__Porffor_allocate')],[34,16],[65,12],[54,1,0],[32,16],[65,227,0],[58,0,4],[32,16],[65,239,0],[58,0,5],[32,16],[65,238,0],[58,0,6],[32,16],[65,230,0],[58,0,7],[32,16],[65,233,0],[58,0,8],[32,16],[65,231,0],[58,0,9],[32,16],[65,245,0],[58,0,10],[32,16],[65,242,0],[58,0,11],[32,16],[65,225,0],[58,0,12],[32,16],[65,226,0],[58,0,13],[32,16],[65,236,0],[58,0,14],[32,16],[65,229,0],[58,0,15],[32,16],[184],[33,15],[32,14],[252,3],[65,7],[32,15],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,17],[252,3],[32,17],[32,11],[68,0,0,0,0,0,0,0,64],[16, ...builtin('f64_&')],[252,2],[69],[69],[183],[65,2],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,10],[33,14],[16, ...builtin('__Porffor_allocate')],[34,16],[65,10],[54,1,0],[32,16],[65,229,0],[58,0,4],[32,16],[65,238,0],[58,0,5],[32,16],[65,245,0],[58,0,6],[32,16],[65,237,0],[58,0,7],[32,16],[65,229,0],[58,0,8],[32,16],[65,242,0],[58,0,9],[32,16],[65,225,0],[58,0,10],[32,16],[65,226,0],[58,0,11],[32,16],[65,236,0],[58,0,12],[32,16],[65,229,0],[58,0,13],[32,16],[184],[33,15],[32,14],[252,3],[65,7],[32,15],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,17],[252,3],[32,17],[32,11],[68,0,0,0,0,0,0,16,64],[16, ...builtin('f64_&')],[252,2],[69],[69],[183],[65,2],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,11],[68,0,0,0,0,0,0,240,63],[16, ...builtin('f64_&')],[252,3],[4,64],[32,10],[65,7],[15],[11],[32,9],[252,2],[43,0,4],[33,18],[65,1],[33,19],[32,11],[252,3],[65,8],[118],[33,19],[32,10],[33,14],[16, ...builtin('__Porffor_allocate')],[34,16],[65,8],[54,1,0],[32,16],[65,247,0],[58,0,4],[32,16],[65,242,0],[58,0,5],[32,16],[65,233,0],[58,0,6],[32,16],[65,244,0],[58,0,7],[32,16],[65,225,0],[58,0,8],[32,16],[65,226,0],[58,0,9],[32,16],[65,236,0],[58,0,10],[32,16],[65,229,0],[58,0,11],[32,16],[184],[33,15],[32,14],[252,3],[65,7],[32,15],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,17],[252,3],[32,17],[32,11],[68,0,0,0,0,0,0,32,64],[16, ...builtin('f64_&')],[252,2],[69],[69],[183],[65,2],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,10],[33,14],[16, ...builtin('__Porffor_allocate')],[34,16],[65,5],[54,1,0],[32,16],[65,246,0],[58,0,4],[32,16],[65,225,0],[58,0,5],[32,16],[65,236,0],[58,0,6],[32,16],[65,245,0],[58,0,7],[32,16],[65,229,0],[58,0,8],[32,16],[184],[33,15],[32,14],[252,3],[65,7],[32,15],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,17],[252,3],[32,17],[32,18],[32,19],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,10],[65,7],[15]],
1783
+ wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,28,64],[98],[4,64],[68,0,0,0,0,0,0,0,0],[65,128,1],[15],[11],[32,2],[32,3],[16, ...builtin('__ecma262_ToPropertyKey')],[33,5],[33,4],[32,0],[252,2],[32,1],[32,4],[252,2],[32,5],[16, ...builtin('__Porffor_object_lookup')],[33,6],[183],[34,7],[68,0,0,0,0,0,0,240,191],[97],[4,64],[68,0,0,0,0,0,0,0,0],[65,128,1],[15],[11],[16, ...builtin('__Porffor_allocate')],[184],[33,8],[32,7],[252,2],[47,0,12],[183],[33,9],[32,8],[33,12],[16, ...builtin('__Porffor_allocate')],[34,14],[65,12],[54,1,0],[32,14],[65,227,0],[58,0,4],[32,14],[65,239,0],[58,0,5],[32,14],[65,238,0],[58,0,6],[32,14],[65,230,0],[58,0,7],[32,14],[65,233,0],[58,0,8],[32,14],[65,231,0],[58,0,9],[32,14],[65,245,0],[58,0,10],[32,14],[65,242,0],[58,0,11],[32,14],[65,225,0],[58,0,12],[32,14],[65,226,0],[58,0,13],[32,14],[65,236,0],[58,0,14],[32,14],[65,229,0],[58,0,15],[32,14],[184],[33,13],[32,12],[252,3],[65,7],[32,13],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,15],[252,3],[32,15],[32,9],[68,0,0,0,0,0,0,0,64],[16, ...builtin('f64_&')],[252,2],[69],[69],[183],[65,2],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,8],[33,12],[16, ...builtin('__Porffor_allocate')],[34,14],[65,10],[54,1,0],[32,14],[65,229,0],[58,0,4],[32,14],[65,238,0],[58,0,5],[32,14],[65,245,0],[58,0,6],[32,14],[65,237,0],[58,0,7],[32,14],[65,229,0],[58,0,8],[32,14],[65,242,0],[58,0,9],[32,14],[65,225,0],[58,0,10],[32,14],[65,226,0],[58,0,11],[32,14],[65,236,0],[58,0,12],[32,14],[65,229,0],[58,0,13],[32,14],[184],[33,13],[32,12],[252,3],[65,7],[32,13],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,15],[252,3],[32,15],[32,9],[68,0,0,0,0,0,0,16,64],[16, ...builtin('f64_&')],[252,2],[69],[69],[183],[65,2],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,9],[68,0,0,0,0,0,0,240,63],[16, ...builtin('f64_&')],[252,3],[4,64],[32,8],[65,7],[15],[11],[32,7],[252,2],[43,0,4],[33,16],[65,1],[33,17],[32,9],[252,3],[65,8],[118],[33,17],[32,8],[33,12],[16, ...builtin('__Porffor_allocate')],[34,14],[65,8],[54,1,0],[32,14],[65,247,0],[58,0,4],[32,14],[65,242,0],[58,0,5],[32,14],[65,233,0],[58,0,6],[32,14],[65,244,0],[58,0,7],[32,14],[65,225,0],[58,0,8],[32,14],[65,226,0],[58,0,9],[32,14],[65,236,0],[58,0,10],[32,14],[65,229,0],[58,0,11],[32,14],[184],[33,13],[32,12],[252,3],[65,7],[32,13],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,15],[252,3],[32,15],[32,9],[68,0,0,0,0,0,0,32,64],[16, ...builtin('f64_&')],[252,2],[69],[69],[183],[65,2],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,8],[33,12],[16, ...builtin('__Porffor_allocate')],[34,14],[65,5],[54,1,0],[32,14],[65,246,0],[58,0,4],[32,14],[65,225,0],[58,0,5],[32,14],[65,236,0],[58,0,6],[32,14],[65,245,0],[58,0,7],[32,14],[65,229,0],[58,0,8],[32,14],[184],[33,13],[32,12],[252,3],[65,7],[32,13],[65,195,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,15],[252,3],[32,15],[32,16],[32,17],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,8],[65,7],[15]],
1784
1784
  params: [124,127,124,127], typedParams: 1,
1785
1785
  returns: [124,127], typedReturns: 1,
1786
- locals: [127,124,127,124,127,124,124,124,124,127,124,124,127,127,124,127], localNames: ["obj","obj#type","prop","prop#type","#last_type","#logicinner_tmp","#typeswitch_tmp","p","p#type","entryPtr","out","tail","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#makearray_pointer_tmp","#swap","value","value#type"],
1786
+ locals: [124,127,127,124,124,124,124,127,124,124,127,127,124,127], localNames: ["obj","obj#type","prop","prop#type","p","p#type","#last_type","entryPtr","out","tail","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#makearray_pointer_tmp","#swap","value","value#type"],
1787
+ };
1788
+ this.__Object_getOwnPropertyDescriptors = {
1789
+ wasm: (scope, {builtin,internalThrow}) => [[16, ...builtin('__Porffor_allocate')],[184],[33,2],[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,28,64],[98],[4,64],[32,2],[65,7],[15],[11],[32,0],[252,3],[33,3],[65,0],[33,5],[32,3],[40,1,0],[34,4],[4,64],[32,1],[33,15],[2,64],[32,15],[65,7],[70],[4,64,"TYPESWITCH|Object"],[3,64],[32,3],[40,0,5],[34,8],[65,31],[118],[4,127],[32,8],[65,255,255,255,255,7],[113],[33,8],[65,67],[5],[65,195,1],[11],[33,7],[32,8],[184],[33,6],[2,64],[32,2],[33,11],[32,6],[33,12],[32,11],[252,3],[65,7],[32,12],[32,7],[16, ...builtin('__ecma262_ToPropertyKey')],[33,14],[252,3],[32,14],[32,0],[32,1],[32,6],[32,7],[16, ...builtin('__Object_getOwnPropertyDescriptor')],[34,13],[16, ...builtin('__Porffor_object_set')],[26],[26],[32,3],[65,14],[106],[33,3],[32,5],[65,1],[106],[34,5],[32,4],[71],[13,1],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `Tried for..in on unsupported type`),[11,"TYPESWITCH_end"],[11],[32,2],[65,7],[15]],
1790
+ params: [124,127], typedParams: 1,
1791
+ returns: [124,127], typedReturns: 1,
1792
+ locals: [124,127,127,127,124,127,127,124,127,124,124,127,127,127], localNames: ["obj","obj#type","out","#forin_base_pointer","#forin_length","#forin_counter","x","x#type","#forin_tmp","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#last_type","#swap","#typeswitch_tmp"],
1793
+ };
1794
+ this.__Object_getOwnPropertyNames = {
1795
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[33,2],[32,1],[33,3],[2,127],[32,3],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,2],[68,0,0,0,0,0,0,0,0],[97],[12,1],[11],[32,3],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],[65,1],[12,1],[11],[65,0],[11,"TYPESWITCH_end"],[4,64],...internalThrow(scope, 'TypeError', `Argument is nullish, expected object`),[11],[16, ...builtin('__Porffor_allocate')],[183],[33,4],[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[34,5],[68,0,0,0,0,0,0,28,64],[97],[4,64],[32,0],[68,0,0,0,0,0,0,20,64],[160],[34,6],[32,0],[252,2],[40,0,0],[183],[68,0,0,0,0,0,0,44,64],[162],[160],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[3,64],[32,6],[32,7],[99],[4,64],[32,6],[252,3],[40,0,0],[34,11],[65,31],[118],[4,127],[65,195,0],[33,10],[32,11],[65,255,255,255,255,7],[113],[5],[65,195,1],[33,10],[32,11],[11],[184],[33,9],[32,4],[33,14],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[33,15],[32,14],[252,3],[32,15],[252,3],[65,9],[108],[106],[34,13],[32,9],[34,12],[57,0,4],[32,13],[32,10],[58,0,12],[32,6],[68,0,0,0,0,0,0,44,64],[160],[34,6],[12,1],[11],[11],[32,4],[252,3],[32,8],[34,17],[252,3],[54,1,0],[5],[32,5],[68,0,0,0,0,0,0,84,64],[97],[32,5],[68,0,0,0,0,0,96,104,64],[97],[114],[32,5],[68,0,0,0,0,0,192,80,64],[97],[114],[4,64],[32,0],[252,3],[40,1,0],[184],[33,18],[32,4],[252,3],[32,18],[34,17],[252,3],[54,1,0],[68,0,0,0,0,0,0,0,0],[33,8],[3,64],[32,8],[32,18],[99],[4,64],[32,4],[33,14],[32,8],[33,15],[32,14],[252,3],[32,15],[252,3],[65,9],[108],[106],[34,13],[32,8],[65,1],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('__Number_prototype_toString')],[33,19],[34,12],[57,0,4],[32,13],[32,19],[58,0,12],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[12,1],[11],[11],[11],[11],[32,4],[65,208,0],[15]],
1796
+ params: [124,127], typedParams: 1,
1797
+ returns: [124,127], typedReturns: 1,
1798
+ locals: [124,127,124,124,124,124,124,124,127,127,124,127,124,124,127,124,124,127], localNames: ["obj","obj#type","#logicinner_tmp","#typeswitch_tmp","out","t","ptr","endPtr","i","key","key#type","raw","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#swap","__length_setter_tmp","len","#last_type"],
1787
1799
  };
1788
1800
  this.__Object_prototype_toString = {
1789
1801
  wasm: (scope, {allocPage}) => [...number(allocPage(scope, 'bytestring: __Object_prototype_toString/out', 'i8') * pageSize, 124),[34,2],[65,195,1],[15]],
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.21.8+288c31477",
4
+ "version": "0.22.0+f5847bc93",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.21.8+288c31477';
3
+ globalThis.version = '0.22.0+f5847bc93';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {