porffor 0.18.15 → 0.18.16

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,105 @@ 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`;; setup
87
+ local #splice_ptr i32
88
+
89
+ ;; ptr = ptr(_this) + 4 + (start * 9)
90
+ local.get ${_this}
91
+ i32.to_u
92
+ i32.const 4
93
+ i32.add
94
+ local.get ${start}
95
+ i32.to_u
96
+ i32.const 9
97
+ i32.mul
98
+ i32.add
99
+ local.set #splice_ptr
100
+
101
+ ;; dst = ptr + itemsLen * 9
102
+ local.get #splice_ptr
103
+ local.get ${itemsLen}
104
+ i32.to_u
105
+ i32.const 9
106
+ i32.mul
107
+ i32.add
108
+
109
+ ;; src = ptr + deleteCount * 9
110
+ local.get #splice_ptr
111
+ local.get ${deleteCount}
112
+ i32.to_u
113
+ i32.const 9
114
+ i32.mul
115
+ i32.add
116
+
117
+ ;; size = (len - start - deleteCount) * 9
118
+ local.get ${len}
119
+ i32.to_u
120
+ local.get ${start}
121
+ i32.to_u
122
+ local.get ${deleteCount}
123
+ i32.to_u
124
+ i32.sub
125
+ i32.sub
126
+ i32.const 9
127
+ i32.mul
128
+
129
+ memory.copy 0 0`;
130
+
131
+ if (itemsLen > 0) {
132
+ let itemsPtr: i32 = Porffor.wasm`local.get ${items}`;
133
+ thisPtr = Porffor.wasm`local.get ${_this}` + start * 9;
134
+ thisPtrEnd = thisPtr + itemsLen * 9;
135
+
136
+ while (thisPtr < thisPtrEnd) {
137
+ Porffor.wasm.f64.store(thisPtr, Porffor.wasm.f64.load(itemsPtr, 0, 4), 0, 4);
138
+ Porffor.wasm.i32.store8(thisPtr + 8, Porffor.wasm.i32.load8_u(itemsPtr + 8, 0, 4), 0, 4);
139
+
140
+ thisPtr += 9;
141
+ itemsPtr += 9;
142
+ }
143
+ }
144
+
145
+ return out;
146
+ };
147
+
49
148
  // @porf-typed-array
50
149
  export const __Array_prototype_fill = (_this: any[], value: any, start: any, end: any) => {
51
150
  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.16+031bc17dd",
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.16+031bc17dd';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {