porffor 0.30.2 → 0.30.3

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.
@@ -669,7 +669,7 @@ export const __Object_prototype_valueOf = (_this: any) => {
669
669
 
670
670
 
671
671
  export const __Porffor_object_spread = (dst: object, src: any): object => {
672
- if (src == null) return;
672
+ if (src == null) return dst;
673
673
 
674
674
  // todo/perf: optimize this (and assign) for object instead of reading over object 2x
675
675
  const keys: any[] = __Object_keys(src);
@@ -681,5 +681,25 @@ export const __Porffor_object_spread = (dst: object, src: any): object => {
681
681
  Porffor.object.expr.init(dst, keys[i], vals[i]);
682
682
  }
683
683
 
684
+ return dst;
685
+ };
686
+
687
+ export const __Porffor_object_rest = (dst: object, src: any, ...blocklist: any[]): object => {
688
+ if (src == null) return dst;
689
+
690
+ // todo: use ToPropertyKey on blocklist?
691
+
692
+ // todo/perf: optimize this (and assign) for object instead of reading over object 2x
693
+ const keys: any[] = __Object_keys(src);
694
+ const vals: any[] = __Object_values(src);
695
+
696
+ const len: i32 = keys.length;
697
+ for (let i: i32 = 0; i < len; i++) {
698
+ const k: any = keys[i];
699
+ if (blocklist.includes(k)) continue;
700
+
701
+ Porffor.object.expr.init(dst, k, vals[i]);
702
+ }
703
+
684
704
  return dst;
685
705
  };
@@ -1915,11 +1915,18 @@ export const BuiltinFuncs = function() {
1915
1915
  locals: [], localNames: ["_this","_this#type"],
1916
1916
  };
1917
1917
  this.__Porffor_object_spread = {
1918
- wasm: (scope, {builtin}) => [[32,2],[33,4],[32,3],[33,5],[2,127],[32,5],[65,0],[70],[4,64,"TYPESWITCH|empty"],[65,1],[12,1],[11],[32,5],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,4],[68,0,0,0,0,0,0,0,0],[97],[12,1],[11],[32,5],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],[65,1],[12,1],[11],[65,0],[11,"TYPESWITCH_end"],[4,64],[68,0,0,0,0,0,0,0,0],[65,128,1],[15],[11],[32,2],[32,3],[16, builtin('__Object_keys')],[26],[33,6],[32,2],[32,3],[16, builtin('__Object_values')],[26],[33,8],[32,6],[252,3],[40,1,0],[184],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[3,64],[32,10],[32,9],[99],[4,64],[32,0],[252,2],[65,7],[32,6],[33,11],[32,10],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[33,7],[252,2],[32,7],[32,8],[33,11],[32,10],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[34,7],[16, builtin('__Porffor_object_expr_init')],[33,7],[183],[26],[32,10],[68,0,0,0,0,0,0,240,63],[160],[33,10],[12,1],[11],[11],[32,0],[65,7],[15]],
1918
+ wasm: (scope, {builtin}) => [[32,2],[33,4],[32,3],[33,5],[2,127],[32,5],[65,0],[70],[4,64,"TYPESWITCH|empty"],[65,1],[12,1],[11],[32,5],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,4],[68,0,0,0,0,0,0,0,0],[97],[12,1],[11],[32,5],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],[65,1],[12,1],[11],[65,0],[11,"TYPESWITCH_end"],[4,64],[32,0],[65,7],[15],[11],[32,2],[32,3],[16, builtin('__Object_keys')],[26],[33,6],[32,2],[32,3],[16, builtin('__Object_values')],[26],[33,8],[32,6],[252,3],[40,1,0],[184],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[3,64],[32,10],[32,9],[99],[4,64],[32,0],[252,2],[65,7],[32,6],[33,11],[32,10],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[33,7],[252,2],[32,7],[32,8],[33,11],[32,10],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[34,7],[16, builtin('__Porffor_object_expr_init')],[33,7],[183],[26],[32,10],[68,0,0,0,0,0,0,240,63],[160],[33,10],[12,1],[11],[11],[32,0],[65,7],[15]],
1919
1919
  params: [124,127,124,127], typedParams: 1,
1920
1920
  returns: [124,127], typedReturns: 1,
1921
1921
  locals: [124,127,124,127,124,124,124,124,124,127,127,127], localNames: ["dst","dst#type","src","src#type","#logicinner_tmp","#typeswitch_tmp1","keys","#last_type","vals","len","i","#member_obj","#member_prop","#loadArray_offset","#member_allocd","#swap"],
1922
1922
  };
1923
+ this.__Porffor_object_rest = {
1924
+ wasm: (scope, {builtin}) => [[32,2],[33,6],[32,3],[33,7],[2,127],[32,7],[65,0],[70],[4,64,"TYPESWITCH|empty"],[65,1],[12,1],[11],[32,7],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,6],[68,0,0,0,0,0,0,0,0],[97],[12,1],[11],[32,7],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],[65,1],[12,1],[11],[65,0],[11,"TYPESWITCH_end"],[4,64],[32,0],[65,7],[15],[11],[32,2],[32,3],[16, builtin('__Object_keys')],[26],[33,8],[32,2],[32,3],[16, builtin('__Object_values')],[26],[33,10],[32,8],[252,3],[40,1,0],[184],[33,11],[68,0,0,0,0,0,0,0,0],[33,12],[3,64],[32,12],[32,11],[99],[4,64],[2,64],[32,8],[33,15],[32,12],[34,16],[252,3],[65,9],[108],[32,15],[252,3],[106],[34,17],[43,0,4],[32,17],[45,0,12],[33,14],[33,13],[32,4],[33,20],[65,208,0],[33,21],[32,20],[32,21],[32,13],[32,14],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, builtin('__Array_prototype_includes')],[33,9],[33,6],[32,9],[33,7],[2,127],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[12,1],[11],[32,6],[252,3],[11,"TYPESWITCH_end"],[4,64],[12,1],[11],[32,0],[252,2],[65,7],[32,13],[252,2],[32,14],[32,10],[33,15],[32,12],[34,16],[252,3],[65,9],[108],[32,15],[252,3],[106],[34,17],[43,0,4],[32,17],[45,0,12],[34,9],[16, builtin('__Porffor_object_expr_init')],[33,9],[183],[26],[11],[32,12],[68,0,0,0,0,0,0,240,63],[160],[33,12],[12,1],[11],[11],[32,0],[65,7],[15]],
1925
+ params: [124,127,124,127,124,127], typedParams: 1,
1926
+ returns: [124,127], typedReturns: 1,
1927
+ locals: [124,127,124,127,124,124,124,124,127,124,124,127,127,127,124,127], localNames: ["dst","dst#type","src","src#type","blocklist","blocklist#type","#logicinner_tmp","#typeswitch_tmp1","keys","#last_type","vals","len","i","k","k#type","#member_obj","#member_prop","#loadArray_offset","#member_allocd","#swap","#proto_target","#proto_target#type"],
1928
+ hasRestArgument: 1,
1929
+ };
1923
1930
  this.__ecma262_NewPromiseReactionJob = {
1924
1931
  wasm: (scope, {builtin}) => [[65,22],[16, builtin('__Porffor_allocateBytes')],[183],[34,4],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[32,7],[252,3],[32,8],[252,3],[65,9],[108],[106],[34,6],[32,0],[34,5],[57,0,4],[32,6],[65,208,0],[58,0,12],[32,4],[33,7],[68,0,0,0,0,0,0,240,63],[33,8],[32,7],[252,3],[32,8],[252,3],[65,9],[108],[106],[34,6],[32,2],[34,5],[57,0,4],[32,6],[32,3],[58,0,12],[32,4],[65,208,0],[15]],
1925
1932
  params: [124,127,124,127], typedParams: 1,
@@ -3216,8 +3216,11 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
3216
3216
  let out = generateVarDstr(scope, 'const', tmpName, init, defaultValue, false);
3217
3217
 
3218
3218
  const properties = [...pattern.properties];
3219
+ const usedProps = [];
3219
3220
  for (const prop of properties) {
3220
3221
  if (prop.type == 'Property') { // let { foo } = {}
3222
+ usedProps.push(!prop.computed && prop.key.type !== 'Literal' ? { type: 'Literal', value: prop.key.name } : prop.key);
3223
+
3221
3224
  if (prop.value.type === 'AssignmentPattern') { // let { foo = defaultValue } = {}
3222
3225
  decls.push(
3223
3226
  ...generateVarDstr(scope, kind, prop.value.left, {
@@ -3243,11 +3246,12 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
3243
3246
  type: 'CallExpression',
3244
3247
  callee: {
3245
3248
  type: 'Identifier',
3246
- name: '__Porffor_object_spread'
3249
+ name: '__Porffor_object_rest'
3247
3250
  },
3248
3251
  arguments: [
3249
3252
  { type: 'ObjectExpression', properties: [] },
3250
- { type: 'Identifier', name: tmpName }
3253
+ { type: 'Identifier', name: tmpName },
3254
+ ...usedProps
3251
3255
  ]
3252
3256
  }, undefined, global)
3253
3257
  );
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.30.2+2e9f2148f",
4
+ "version": "0.30.3+8ee696663",
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.30.2+2e9f2148f';
3
+ globalThis.version = '0.30.3+8ee696663';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {