porffor 0.18.15 → 0.18.17

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.
@@ -46,6 +46,103 @@ export const __Array_prototype_slice = (_this: any[], start: number, end: number
46
46
  return out;
47
47
  };
48
48
 
49
+ export const __Array_prototype_splice = (_this: any[], start: number, deleteCount: any, ...items: any[]) => {
50
+ const len: i32 = _this.length;
51
+
52
+ start |= 0;
53
+ if (start < 0) {
54
+ start = len + start;
55
+ if (start < 0) start = 0;
56
+ }
57
+ if (start > len) start = len;
58
+
59
+ if (Porffor.rawType(deleteCount) == Porffor.TYPES.undefined) deleteCount = len - start;
60
+ deleteCount |= 0;
61
+
62
+ if (deleteCount < 0) deleteCount = 0;
63
+ if (deleteCount > len - start) deleteCount = len - start;
64
+
65
+ // read values to be deleted into out
66
+ let out: any[] = Porffor.allocate();
67
+ out.length = deleteCount;
68
+
69
+ let outPtr: i32 = Porffor.wasm`local.get ${out}`;
70
+ let thisPtr: i32 = Porffor.wasm`local.get ${_this}` + start * 9;
71
+ let thisPtrEnd: i32 = thisPtr + deleteCount * 9;
72
+
73
+ while (thisPtr < thisPtrEnd) {
74
+ Porffor.wasm.f64.store(outPtr, Porffor.wasm.f64.load(thisPtr, 0, 4), 0, 4);
75
+ Porffor.wasm.i32.store8(outPtr + 8, Porffor.wasm.i32.load8_u(thisPtr + 8, 0, 4), 0, 4);
76
+
77
+ thisPtr += 9;
78
+ outPtr += 9;
79
+ }
80
+
81
+ // update this length
82
+ const itemsLen: i32 = items.length;
83
+ _this.length = len - deleteCount + itemsLen;
84
+
85
+ // remove deleted values via memory.copy shifting values in mem
86
+ Porffor.wasm`;; ptr = ptr(_this) + 4 + (start * 9)
87
+ local #splice_ptr i32
88
+ local.get ${_this}
89
+ i32.to_u
90
+ i32.const 4
91
+ i32.add
92
+ local.get ${start}
93
+ i32.to_u
94
+ i32.const 9
95
+ i32.mul
96
+ i32.add
97
+ local.set #splice_ptr
98
+
99
+ ;; dst = ptr + itemsLen * 9
100
+ local.get #splice_ptr
101
+ local.get ${itemsLen}
102
+ i32.to_u
103
+ i32.const 9
104
+ i32.mul
105
+ i32.add
106
+
107
+ ;; src = ptr + deleteCount * 9
108
+ local.get #splice_ptr
109
+ local.get ${deleteCount}
110
+ i32.to_u
111
+ i32.const 9
112
+ i32.mul
113
+ i32.add
114
+
115
+ ;; size = (len - start - deleteCount) * 9
116
+ local.get ${len}
117
+ i32.to_u
118
+ local.get ${start}
119
+ i32.to_u
120
+ local.get ${deleteCount}
121
+ i32.to_u
122
+ i32.sub
123
+ i32.sub
124
+ i32.const 9
125
+ i32.mul
126
+
127
+ memory.copy 0 0`;
128
+
129
+ if (itemsLen > 0) {
130
+ let itemsPtr: i32 = Porffor.wasm`local.get ${items}`;
131
+ thisPtr = Porffor.wasm`local.get ${_this}` + start * 9;
132
+ thisPtrEnd = thisPtr + itemsLen * 9;
133
+
134
+ while (thisPtr < thisPtrEnd) {
135
+ Porffor.wasm.f64.store(thisPtr, Porffor.wasm.f64.load(itemsPtr, 0, 4), 0, 4);
136
+ Porffor.wasm.i32.store8(thisPtr + 8, Porffor.wasm.i32.load8_u(itemsPtr + 8, 0, 4), 0, 4);
137
+
138
+ thisPtr += 9;
139
+ itemsPtr += 9;
140
+ }
141
+ }
142
+
143
+ return out;
144
+ };
145
+
49
146
  // @porf-typed-array
50
147
  export const __Array_prototype_fill = (_this: any[], value: any, start: any, end: any) => {
51
148
  const len: i32 = _this.length;
@@ -236,6 +236,16 @@ export const BuiltinFuncs = function() {
236
236
  locals: [124,124,127,124,124,124,124],
237
237
  localNames: ["_this","_this#type","start","start#type","end","end#type","len","out","#last_type","outPtr","thisPtr","thisPtrEnd","__length_setter_tmp"],
238
238
  };
239
+ this.__Array_prototype_splice = {
240
+ wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,8],[32,2],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[34,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,8],[32,2],[160],[34,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[33,2],[11],[11],[32,2],[32,8],[100],[4,64],[32,8],[33,2],[11],[32,4],[32,5],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,8],[32,2],[161],[34,4],[65,0],[33,5],[26],[11],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[34,4],[65,0],[33,5],[26],[32,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[34,4],[65,0],[33,5],[26],[11],[32,4],[32,8],[32,2],[161],[100],[4,64],[32,8],[32,2],[161],[34,4],[65,0],[33,5],[26],[11],[16, builtin('__Porffor_allocate')],[33,10],[34,9],[252,3],[32,4],[34,11],[252,3],[54,1,0],[32,9],[33,12],[32,0],[32,2],[68,0,0,0,0,0,0,34,64],[162],[160],[34,13],[32,4],[68,0,0,0,0,0,0,34,64],[162],[160],[33,14],[3,64],[32,13],[32,14],[99],[4,64],[32,12],[252,2],[32,13],[252,2],[43,0,4],[57,0,4],[32,12],[68,0,0,0,0,0,0,32,64],[160],[252,2],[32,13],[68,0,0,0,0,0,0,32,64],[160],[252,2],[45,0,4],[58,0,4],[32,13],[68,0,0,0,0,0,0,34,64],[160],[33,13],[32,12],[68,0,0,0,0,0,0,34,64],[160],[33,12],[12,1],[11],[11],[32,6],[252,3],[40,1,0],[184],[33,15],[32,0],[252,3],[32,8],[32,4],[161],[32,15],[160],[34,11],[252,3],[54,1,0],[32,0],[252,3],[65,4],[106],[32,2],[252,3],[65,9],[108],[106],[34,16],[32,15],[252,3],[65,9],[108],[106],[32,16],[32,4],[252,3],[65,9],[108],[106],[32,8],[252,3],[32,2],[252,3],[32,4],[252,3],[107],[107],[65,9],[108],[252,10,0,0],[32,15],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,6],[33,17],[32,0],[32,2],[68,0,0,0,0,0,0,34,64],[162],[160],[34,13],[32,15],[68,0,0,0,0,0,0,34,64],[162],[160],[33,14],[3,64],[32,13],[32,14],[99],[4,64],[32,13],[252,2],[32,17],[252,2],[43,0,4],[57,0,4],[32,13],[68,0,0,0,0,0,0,32,64],[160],[252,2],[32,17],[68,0,0,0,0,0,0,32,64],[160],[252,2],[45,0,4],[58,0,4],[32,13],[68,0,0,0,0,0,0,34,64],[160],[33,13],[32,17],[68,0,0,0,0,0,0,34,64],[160],[33,17],[12,1],[11],[11],[11],[32,9],[65,208,0],[15]],
241
+ params: [124,127,124,127,124,127,124,127],
242
+ typedParams: true,
243
+ returns: [124,127],
244
+ typedReturns: true,
245
+ locals: [124,124,127,124,124,124,124,124,127,124],
246
+ localNames: ["_this","_this#type","start","start#type","deleteCount","deleteCount#type","items","items#type","len","out","#last_type","__length_setter_tmp","outPtr","thisPtr","thisPtrEnd","itemsLen","#splice_ptr","itemsPtr"],
247
+ hasRestArgument: true,
248
+ };
239
249
  this.__Array_prototype_fill = {
240
250
  wasm: (scope, {builtin,}) => [[32,0],[252,3],[40,1,0],[184],[33,8],[32,4],[32,5],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[97],[4,64],[68,0,0,0,0,0,0,0,0],[34,4],[65,0],[33,5],[26],[11],[32,6],[32,7],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,8],[34,6],[65,0],[33,7],[26],[11],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[34,4],[65,0],[33,5],[26],[32,6],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[34,6],[65,0],[33,7],[26],[32,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,8],[32,4],[160],[34,4],[65,0],[33,5],[26],[32,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[34,4],[65,0],[33,5],[26],[11],[11],[32,4],[32,8],[100],[4,64],[32,8],[34,4],[65,0],[33,5],[26],[11],[32,6],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,8],[32,6],[160],[34,6],[65,0],[33,7],[26],[32,6],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[34,6],[65,0],[33,7],[26],[11],[11],[32,6],[32,8],[100],[4,64],[32,8],[34,6],[65,0],[33,7],[26],[11],[32,4],[33,9],[3,64],[32,9],[32,6],[99],[4,64],[32,0],[252,3],[32,9],[252,3],[65,9],[108],[106],[34,11],[32,2],[34,10],[57,0,4],[32,11],[32,3],[58,0,12],[32,9],[68,0,0,0,0,0,0,240,63],[160],[33,9],[12,1],[11],[11],[32,0],[65,208,0],[15]],
241
251
  params: [124,127,124,127,124,127,124,127],
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.18.15+60ee60319",
4
+ "version": "0.18.17+4d4df7afe",
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.18.15+60ee60319';
3
+ globalThis.version = '0.18.17+4d4df7afe';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {