porffor 0.18.26 → 0.18.28
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/compiler/builtins/array.ts +67 -0
- package/compiler/generated_builtins.js +23 -2
- package/compiler/prototype.js +0 -43
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -36,6 +36,57 @@ export const __Array_from = (arg: any, mapFn: any): any[] => {
|
|
36
36
|
return out;
|
37
37
|
};
|
38
38
|
|
39
|
+
export const __Array_prototype_push = (_this: any[], ...items: any[]) => {
|
40
|
+
let len: i32 = _this.length;
|
41
|
+
const itemsLen: i32 = items.length;
|
42
|
+
|
43
|
+
for (let i: i32 = 0; i < itemsLen; i++) {
|
44
|
+
_this[i + len] = items[i];
|
45
|
+
}
|
46
|
+
|
47
|
+
return _this.length = len + itemsLen;
|
48
|
+
};
|
49
|
+
|
50
|
+
export const __Array_prototype_unshift = (_this: any[], ...items: any[]) => {
|
51
|
+
let len: i32 = _this.length;
|
52
|
+
const itemsLen: i32 = items.length;
|
53
|
+
|
54
|
+
// use memory.copy to move existing elements right
|
55
|
+
Porffor.wasm`;; ptr = ptr(_this) + 4
|
56
|
+
local #splice_ptr i32
|
57
|
+
local.get ${_this}
|
58
|
+
i32.to_u
|
59
|
+
i32.const 4
|
60
|
+
i32.add
|
61
|
+
local.set #splice_ptr
|
62
|
+
|
63
|
+
;; dst = ptr + itemsLen * 9
|
64
|
+
local.get #splice_ptr
|
65
|
+
local.get ${itemsLen}
|
66
|
+
i32.to_u
|
67
|
+
i32.const 9
|
68
|
+
i32.mul
|
69
|
+
i32.add
|
70
|
+
|
71
|
+
;; src = ptr
|
72
|
+
local.get #splice_ptr
|
73
|
+
|
74
|
+
;; size = len * 9
|
75
|
+
local.get ${len}
|
76
|
+
i32.to_u
|
77
|
+
i32.const 9
|
78
|
+
i32.mul
|
79
|
+
|
80
|
+
memory.copy 0 0`;
|
81
|
+
|
82
|
+
// write to now empty elements
|
83
|
+
for (let i: i32 = 0; i < itemsLen; i++) {
|
84
|
+
_this[i] = items[i];
|
85
|
+
}
|
86
|
+
|
87
|
+
return _this.length = len + itemsLen;
|
88
|
+
};
|
89
|
+
|
39
90
|
export const __Array_prototype_slice = (_this: any[], start: number, end: number) => {
|
40
91
|
const len: i32 = _this.length;
|
41
92
|
if (Porffor.rawType(end) == Porffor.TYPES.undefined) end = len;
|
@@ -382,6 +433,22 @@ export const __Array_prototype_map = (_this: any[], callbackFn: any) => {
|
|
382
433
|
return out;
|
383
434
|
};
|
384
435
|
|
436
|
+
export const __Array_prototype_flatMap = (_this: any[], callbackFn: any) => {
|
437
|
+
const len: i32 = _this.length;
|
438
|
+
const out: any[] = Porffor.allocate();
|
439
|
+
|
440
|
+
let i: i32 = 0, j: i32 = 0;
|
441
|
+
while (i < len) {
|
442
|
+
let x: any = callbackFn(_this[i], i++, _this);
|
443
|
+
if (Porffor.rawType(x) == Porffor.TYPES.array) {
|
444
|
+
for (const y of x) out[j++] = y;
|
445
|
+
} else out[j++] = x;
|
446
|
+
}
|
447
|
+
|
448
|
+
out.length = j;
|
449
|
+
return out;
|
450
|
+
};
|
451
|
+
|
385
452
|
// @porf-typed-array
|
386
453
|
export const __Array_prototype_find = (_this: any[], callbackFn: any) => {
|
387
454
|
const len: i32 = _this.length;
|
@@ -165,6 +165,20 @@ export const BuiltinFuncs = function() {
|
|
165
165
|
locals: [124,127,124,124,127,124,127,124,124,127,127,127,127,124,127,124,127,127,124,127,124,127,124,127,127,124], localNames: ["arg","arg#type","mapFn","mapFn#type","out","#last_type","len","type","type#type","hasMapFn","hasMapFn#type","i","#logicinner_tmp","#typeswitch_tmp","forof_base_pointer","forof_length","forof_counter","x","x#type","#member_setter_val_tmp","#member_setter_ptr_tmp","#indirect_arg0_type","#indirect_arg0_val","#indirect_arg1_type","#indirect_arg1_val","#indirect_arg2_type","#indirect_arg2_val","#indirect_func","#indirect_flags","__length_setter_tmp"],
|
166
166
|
table: 1,
|
167
167
|
};
|
168
|
+
this.__Array_prototype_push = {
|
169
|
+
wasm: (scope, {}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[32,2],[252,3],[40,1,0],[184],[33,5],[68,0,0,0,0,0,0,0,0],[33,6],[3,64],[32,6],[32,5],[99],[4,64],[32,0],[252,3],[32,6],[32,4],[160],[252,3],[65,9],[108],[106],[34,8],[32,6],[252,3],[65,9],[108],[32,2],[252,3],[106],[34,9],[43,0,4],[32,9],[45,0,12],[33,10],[34,7],[57,0,4],[32,8],[32,10],[58,0,12],[32,6],[68,0,0,0,0,0,0,240,63],[160],[33,6],[12,1],[11],[11],[32,0],[252,3],[32,4],[32,5],[160],[34,11],[252,3],[54,1,0],[32,11],[65,0],[15]],
|
170
|
+
params: [124,127,124,127], typedParams: 1,
|
171
|
+
returns: [124,127], typedReturns: 1,
|
172
|
+
locals: [124,124,124,124,127,127,127,124], localNames: ["_this","_this#type","items","items#type","len","itemsLen","i","#member_setter_val_tmp","#member_setter_ptr_tmp","#loadArray_offset","#last_type","__length_setter_tmp"],
|
173
|
+
hasRestArgument: 1,
|
174
|
+
};
|
175
|
+
this.__Array_prototype_unshift = {
|
176
|
+
wasm: (scope, {}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[32,2],[252,3],[40,1,0],[184],[33,5],[32,0],[252,3],[65,4],[106],[34,6],[32,5],[252,3],[65,9],[108],[106],[32,6],[32,4],[252,3],[65,9],[108],[252,10,0,0],[68,0,0,0,0,0,0,0,0],[33,7],[3,64],[32,7],[32,5],[99],[4,64],[32,0],[252,3],[32,7],[252,3],[65,9],[108],[106],[34,9],[32,7],[252,3],[65,9],[108],[32,2],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[33,11],[34,8],[57,0,4],[32,9],[32,11],[58,0,12],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[12,1],[11],[11],[32,0],[252,3],[32,4],[32,5],[160],[34,12],[252,3],[54,1,0],[32,12],[65,0],[15]],
|
177
|
+
params: [124,127,124,127], typedParams: 1,
|
178
|
+
returns: [124,127], typedReturns: 1,
|
179
|
+
locals: [124,124,127,124,124,127,127,127,124], localNames: ["_this","_this#type","items","items#type","len","itemsLen","#splice_ptr","i","#member_setter_val_tmp","#member_setter_ptr_tmp","#loadArray_offset","#last_type","__length_setter_tmp"],
|
180
|
+
hasRestArgument: 1,
|
181
|
+
};
|
168
182
|
this.__Array_prototype_slice = {
|
169
183
|
wasm: (scope, {builtin}) => [[32,0],[252,3],[40,1,0],[184],[33,6],[32,4],[65,0],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,8,64],[97],[4,64],[32,6],[33,4],[11],[32,2],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,2],[32,4],[68,0,0,0,0,0,0,0,0],[16, builtin('f64_|')],[33,4],[32,2],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[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,6],[100],[4,64],[32,6],[33,2],[11],[32,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,6],[32,4],[160],[34,4],[68,0,0,0,0,0,0,0,0],[99],[4,64],[68,0,0,0,0,0,0,0,0],[33,4],[11],[11],[32,4],[32,6],[100],[4,64],[32,6],[33,4],[11],[16, builtin('__Porffor_allocate')],[33,8],[33,7],[32,2],[32,4],[100],[4,64],[32,7],[65,208,0],[15],[11],[32,7],[33,9],[32,0],[34,10],[32,4],[68,0,0,0,0,0,0,34,64],[162],[160],[33,11],[32,10],[32,2],[68,0,0,0,0,0,0,34,64],[162],[160],[33,10],[3,64],[32,10],[32,11],[99],[4,64],[32,9],[252,2],[32,10],[252,2],[43,0,4],[57,0,4],[32,9],[252,2],[32,10],[252,2],[45,0,12],[58,0,12],[32,10],[68,0,0,0,0,0,0,34,64],[160],[33,10],[32,9],[68,0,0,0,0,0,0,34,64],[160],[33,9],[12,1],[11],[11],[32,7],[252,3],[32,4],[32,2],[161],[34,12],[252,3],[54,1,0],[32,7],[65,208,0],[15]],
|
170
184
|
params: [124,127,124,127,124,127], typedParams: 1,
|
@@ -248,6 +262,13 @@ export const BuiltinFuncs = function() {
|
|
248
262
|
locals: [124,124,127,124,124,124,127,127,127,124,127,124,127,124,127,127,127], localNames: ["_this","_this#type","callbackFn","callbackFn#type","len","out","#last_type","__length_setter_tmp","i","#member_setter_val_tmp","#member_setter_ptr_tmp","#loadArray_offset","#indirect_arg0_type","#indirect_arg0_val","#indirect_arg1_type","#indirect_arg1_val","#indirect_arg2_type","#indirect_arg2_val","#indirect_func","#indirect_flags","#typeswitch_tmp"],
|
249
263
|
table: 1,
|
250
264
|
};
|
265
|
+
this.__Array_prototype_flatMap = {
|
266
|
+
wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[16, builtin('__Porffor_allocate')],[33,6],[33,5],[68,0,0,0,0,0,0,0,0],[33,7],[68,0,0,0,0,0,0,0,0],[33,8],[3,64],[32,7],[32,4],[99],[4,64],[32,3],[33,20],[2,124],[32,20],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,11],[43,0,4],[32,11],[45,0,12],[34,6],[33,12],[33,13],[32,7],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[32,6],[33,14],[33,15],[32,0],[65,208,0],[33,16],[33,17],[32,2],[252,3],[34,18],[65,3],[108],[65,2],[106],[45,0,0,"read func lut"],[34,19],[65,2],[113],[69],[65,0],[113],[4,64],...internalThrow(scope, 'TypeError', `callbackFn is not a constructor`),[11],[2,124],[2,64],[2,64],[2,64],[2,64],[32,18],[65,3],[108],[47,0,0,"read func lut"],[14,4,0,1,2,3,0],[11],[32,19],[65,1],[113],[4,124],[32,19],[65,2],[113],[4,124],[65,0],[32,18],[17,0,0,"no_type_return","constr"],[5],[32,18],[17,0,0,"no_type_return"],[11],[5],[32,19],[65,2],[113],[4,124],[65,0],[32,18],[17,0,0,"constr"],[33,6],[5],[32,18],[17,0,0],[33,6],[11],[11],[12,3],[11],[32,19],[65,1],[113],[4,124],[32,19],[65,2],[113],[4,124],[65,0],[32,13],[32,12],[32,18],[17,1,0,"no_type_return","constr"],[5],[32,13],[32,12],[32,18],[17,1,0,"no_type_return"],[11],[5],[32,19],[65,2],[113],[4,124],[65,0],[32,13],[32,12],[32,18],[17,1,0,"constr"],[33,6],[5],[32,13],[32,12],[32,18],[17,1,0],[33,6],[11],[11],[12,2],[11],[32,19],[65,1],[113],[4,124],[32,19],[65,2],[113],[4,124],[65,0],[32,13],[32,12],[32,15],[32,14],[32,18],[17,2,0,"no_type_return","constr"],[5],[32,13],[32,12],[32,15],[32,14],[32,18],[17,2,0,"no_type_return"],[11],[5],[32,19],[65,2],[113],[4,124],[65,0],[32,13],[32,12],[32,15],[32,14],[32,18],[17,2,0,"constr"],[33,6],[5],[32,13],[32,12],[32,15],[32,14],[32,18],[17,2,0],[33,6],[11],[11],[12,1],[11],[32,19],[65,1],[113],[4,124],[32,19],[65,2],[113],[4,124],[65,0],[32,13],[32,12],[32,15],[32,14],[32,17],[32,16],[32,18],[17,3,0,"no_type_return","constr"],[5],[32,13],[32,12],[32,15],[32,14],[32,17],[32,16],[32,18],[17,3,0,"no_type_return"],[11],[5],[32,19],[65,2],[113],[4,124],[65,0],[32,13],[32,12],[32,15],[32,14],[32,17],[32,16],[32,18],[17,3,0,"constr"],[33,6],[5],[32,13],[32,12],[32,15],[32,14],[32,17],[32,16],[32,18],[17,3,0],[33,6],[11],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,9],[32,6],[33,10],[32,9],[32,10],[16, builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,84,64],[97],[4,64],[32,9],[252,3],[33,21],[65,0],[33,23],[32,21],[40,1,0],[33,22],[32,10],[33,20],[2,64],[32,20],[65,19],[70],[4,64,"TYPESWITCH|Set"],[3,64],[32,21],[43,0,4],[32,21],[45,0,12],[33,25],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,21],[65,9],[106],[33,21],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[65,194,0],[33,25],[65,0],[65,1],[54,0,0],[3,64],[65,0],[32,21],[47,0,4],[59,0,4],[68,0,0,0,0,0,0,0,0],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,21],[65,2],[106],[33,21],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[3,64],[32,21],[43,0,4],[32,21],[45,0,12],[33,25],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,21],[65,9],[106],[33,21],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,215,0],[70],[4,64,"TYPESWITCH|Uint8Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[106],[45,0,4],[184],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,216,0],[70],[4,64,"TYPESWITCH|Int8Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[106],[44,0,4],[183],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,217,0],[70],[4,64,"TYPESWITCH|Uint8ClampedArray"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[106],[45,0,4],[184],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,218,0],[70],[4,64,"TYPESWITCH|Uint16Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[65,2],[108],[106],[47,0,4],[184],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,219,0],[70],[4,64,"TYPESWITCH|Int16Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[65,2],[108],[106],[46,0,4],[183],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,220,0],[70],[4,64,"TYPESWITCH|Uint32Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[65,4],[108],[106],[40,0,4],[184],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,221,0],[70],[4,64,"TYPESWITCH|Int32Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[65,4],[108],[106],[40,0,4],[183],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,222,0],[70],[4,64,"TYPESWITCH|Float32Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[65,4],[108],[106],[42,0,4],[187],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,223,0],[70],[4,64,"TYPESWITCH|Float64Array"],[65,0],[33,25],[3,64],[32,21],[40,0,4],[32,23],[65,8],[108],[106],[43,0,4],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],[32,20],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[65,194,1],[33,25],[65,0],[65,1],[54,0,0],[3,64],[65,0],[32,21],[32,23],[106],[45,0,4],[58,0,4],[68,0,0,0,0,0,0,0,0],[33,24],[2,64],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,24],[34,26],[57,0,4],[32,27],[32,25],[58,0,12],[32,23],[65,1],[106],[34,23],[32,22],[71],[13,1],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`),[11,"TYPESWITCH_end"],[5],[32,5],[252,3],[32,8],[32,8],[68,0,0,0,0,0,0,240,63],[160],[33,8],[252,3],[65,9],[108],[106],[34,27],[32,9],[34,26],[57,0,4],[32,27],[32,10],[58,0,12],[11],[12,1],[11],[11],[32,5],[252,3],[32,8],[34,28],[252,3],[54,1,0],[32,5],[65,208,0],[15]],
|
267
|
+
params: [124,127,124,127], typedParams: 1,
|
268
|
+
returns: [124,127], typedReturns: 1,
|
269
|
+
locals: [124,124,127,124,124,124,127,127,127,124,127,124,127,124,127,127,127,127,127,127,124,127,124,127,124], localNames: ["_this","_this#type","callbackFn","callbackFn#type","len","out","#last_type","i","j","x","x#type","#loadArray_offset","#indirect_arg0_type","#indirect_arg0_val","#indirect_arg1_type","#indirect_arg1_val","#indirect_arg2_type","#indirect_arg2_val","#indirect_func","#indirect_flags","#typeswitch_tmp","forof_base_pointer","forof_length","forof_counter","y","y#type","#member_setter_val_tmp","#member_setter_ptr_tmp","__length_setter_tmp"],
|
270
|
+
table: 1,
|
271
|
+
};
|
251
272
|
this.__Array_prototype_find = {
|
252
273
|
wasm: (scope, {internalThrow}) => [[32,0],[252,3],[40,1,0],[184],[33,4],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,4],[99],[4,64],[32,5],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,8],[43,0,4],[32,8],[45,0,12],[33,9],[33,6],[32,9],[33,7],[32,3],[33,18],[2,124],[32,18],[65,5],[70],[4,64,"TYPESWITCH|Function"],[32,6],[32,7],[33,10],[33,11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[32,9],[33,12],[33,13],[32,0],[65,208,0],[33,14],[33,15],[32,2],[252,3],[34,16],[65,3],[108],[65,2],[106],[45,0,0,"read func lut"],[34,17],[65,2],[113],[69],[65,0],[113],[4,64],...internalThrow(scope, 'TypeError', `callbackFn is not a constructor`),[11],[2,124],[2,64],[2,64],[2,64],[2,64],[32,16],[65,3],[108],[47,0,0,"read func lut"],[14,4,0,1,2,3,0],[11],[32,17],[65,1],[113],[4,124],[32,17],[65,2],[113],[4,124],[65,0],[32,16],[17,0,0,"no_type_return","constr"],[5],[32,16],[17,0,0,"no_type_return"],[11],[5],[32,17],[65,2],[113],[4,124],[65,0],[32,16],[17,0,0,"constr"],[33,9],[5],[32,16],[17,0,0],[33,9],[11],[11],[12,3],[11],[32,17],[65,1],[113],[4,124],[32,17],[65,2],[113],[4,124],[65,0],[32,11],[32,10],[32,16],[17,1,0,"no_type_return","constr"],[5],[32,11],[32,10],[32,16],[17,1,0,"no_type_return"],[11],[5],[32,17],[65,2],[113],[4,124],[65,0],[32,11],[32,10],[32,16],[17,1,0,"constr"],[33,9],[5],[32,11],[32,10],[32,16],[17,1,0],[33,9],[11],[11],[12,2],[11],[32,17],[65,1],[113],[4,124],[32,17],[65,2],[113],[4,124],[65,0],[32,11],[32,10],[32,13],[32,12],[32,16],[17,2,0,"no_type_return","constr"],[5],[32,11],[32,10],[32,13],[32,12],[32,16],[17,2,0,"no_type_return"],[11],[5],[32,17],[65,2],[113],[4,124],[65,0],[32,11],[32,10],[32,13],[32,12],[32,16],[17,2,0,"constr"],[33,9],[5],[32,11],[32,10],[32,13],[32,12],[32,16],[17,2,0],[33,9],[11],[11],[12,1],[11],[32,17],[65,1],[113],[4,124],[32,17],[65,2],[113],[4,124],[65,0],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,3,0,"no_type_return","constr"],[5],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,3,0,"no_type_return"],[11],[5],[32,17],[65,2],[113],[4,124],[65,0],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,3,0,"constr"],[33,9],[5],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,3,0],[33,9],[11],[11],[11],[12,1],[11],...internalThrow(scope, 'TypeError', `callbackFn is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[33,19],[32,9],[33,18],[2,124],[32,18],[65,194,0],[70],[4,64,"TYPESWITCH|String"],[32,19],[252,3],[40,1,0],[184],[12,1],[11],[32,18],[65,194,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,19],[252,3],[40,1,0],[184],[12,1],[11],[32,19],[252,2],[69],[69],[183],[11,"TYPESWITCH_end"],[252,3],[4,64],[32,6],[32,7],[15],[11],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
|
253
274
|
params: [124,127,124,127], typedParams: 1,
|
@@ -1400,10 +1421,10 @@ export const BuiltinFuncs = function() {
|
|
1400
1421
|
locals: [], localNames: ["_this","_this#type"],
|
1401
1422
|
};
|
1402
1423
|
this.__Set_prototype_values = {
|
1403
|
-
wasm: (scope, {builtin}) => [[32,0],[252,2],[40,0,0],[183],[33,2],[16, builtin('__Porffor_allocate')],[33,4],[33,3],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,2],[99],[4,64],[32,0],[65,19],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,4],[33,6],[32,4],[33,7],[32,3],[
|
1424
|
+
wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[40,0,0],[183],[33,2],[16, builtin('__Porffor_allocate')],[33,4],[33,3],[68,0,0,0,0,0,0,0,0],[33,5],[3,64],[32,5],[32,2],[99],[4,64],[2,64],[32,0],[65,19],[32,5],[65,0],[16, builtin('__Porffor_set_read')],[33,4],[33,6],[32,4],[33,7],[32,3],[33,8],[65,208,0],[34,9],[33,10],[2,124],[32,10],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[32,8],[32,9],[65,4],[65,1],[54,1,0],[65,4],[32,6],[57,0,4],[65,4],[32,7],[58,0,12],[68,0,0,0,0,0,0,16,64],[65,208,0],[16, builtin('__Array_prototype_push')],[33,4],[12,1],[11],...internalThrow(scope, 'TypeError', `'push' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[26],[11],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[12,1],[11],[11],[32,3],[65,208,0],[15]],
|
1404
1425
|
params: [124,127], typedParams: 1,
|
1405
1426
|
returns: [124,127], typedReturns: 1,
|
1406
|
-
locals: [124,124,127,124,124,127,
|
1427
|
+
locals: [124,124,127,124,124,127,124,127,127], localNames: ["_this","_this#type","size","out","#last_type","i","val","val#type","#proto_target","#proto_target#type","#typeswitch_tmp"],
|
1407
1428
|
};
|
1408
1429
|
this.__Set_prototype_keys = {
|
1409
1430
|
wasm: (scope, {builtin}) => [[32,0],[65,19],[16, builtin('__Set_prototype_values')],[34,2],[15]],
|
package/compiler/prototype.js
CHANGED
@@ -60,46 +60,6 @@ export const PrototypeFuncs = function() {
|
|
60
60
|
[ Opcodes.i32_load8_u, 0, ValtypeSize.i32 + ValtypeSize[valtype] ]
|
61
61
|
],
|
62
62
|
|
63
|
-
// todo: only for 1 argument
|
64
|
-
push: (pointer, length, wNewMember, wType, iTmp, _2, _3, unusedValue) => [
|
65
|
-
// get memory offset of array at last index (length)
|
66
|
-
...length.getCachedI32(),
|
67
|
-
...number(ValtypeSize[valtype] + 1, Valtype.i32),
|
68
|
-
[ Opcodes.i32_mul ],
|
69
|
-
...pointer,
|
70
|
-
[ Opcodes.i32_add ],
|
71
|
-
[ Opcodes.local_set, iTmp ],
|
72
|
-
|
73
|
-
// store value
|
74
|
-
[ Opcodes.local_get, iTmp ],
|
75
|
-
...wNewMember,
|
76
|
-
[ Opcodes.store, 0, ValtypeSize.i32 ],
|
77
|
-
|
78
|
-
// store type
|
79
|
-
[ Opcodes.local_get, iTmp ],
|
80
|
-
...wType,
|
81
|
-
[ Opcodes.i32_store8, 0, ValtypeSize.i32 + ValtypeSize[valtype] ],
|
82
|
-
|
83
|
-
// bump array length by 1 and return it
|
84
|
-
...length.setI32([
|
85
|
-
...length.getCachedI32(),
|
86
|
-
...number(1, Valtype.i32),
|
87
|
-
[ Opcodes.i32_add ],
|
88
|
-
|
89
|
-
...(unusedValue() ? [] : [
|
90
|
-
...length.setCachedI32(),
|
91
|
-
...length.getCachedI32(),
|
92
|
-
])
|
93
|
-
]),
|
94
|
-
|
95
|
-
...(unusedValue() ? [] : [
|
96
|
-
...length.getCachedI32(),
|
97
|
-
Opcodes.i32_from_u
|
98
|
-
])
|
99
|
-
|
100
|
-
// ...length.get()
|
101
|
-
],
|
102
|
-
|
103
63
|
pop: (pointer, length, _1, _2, iTmp, _3, _4, unusedValue) => [
|
104
64
|
// if length == 0, noop
|
105
65
|
...length.getCachedI32(),
|
@@ -212,9 +172,6 @@ export const PrototypeFuncs = function() {
|
|
212
172
|
};
|
213
173
|
|
214
174
|
this[TYPES.array].at.local = Valtype.i32;
|
215
|
-
this[TYPES.array].push.returnType = TYPES.number;
|
216
|
-
this[TYPES.array].push.noArgRetLength = true;
|
217
|
-
this[TYPES.array].push.local = Valtype.i32;
|
218
175
|
this[TYPES.array].pop.local = Valtype.i32;
|
219
176
|
|
220
177
|
this[TYPES.string] = {
|
package/package.json
CHANGED