porffor 0.25.3 → 0.25.5

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.
@@ -0,0 +1,293 @@
1
+ import type {} from './porffor.d.ts';
2
+
3
+ export const __ecma262_NewPromiseReactionJob = (reaction: any[], argument: any): any[] => {
4
+ const job: any[] = Porffor.allocateBytes(22); // 2 length
5
+ job[0] = reaction;
6
+ job[1] = argument;
7
+
8
+ return job;
9
+ };
10
+
11
+ const jobQueue: any[] = new Array(0);
12
+ export const __ecma262_HostEnqueuePromiseJob = (job: any[]): void => {
13
+ Porffor.fastPush(jobQueue, job);
14
+ };
15
+
16
+ // 27.2.1.8 TriggerPromiseReactions (reactions, argument)
17
+ // https://tc39.es/ecma262/#sec-triggerpromisereactions
18
+ export const __ecma262_TriggerPromiseReactions = (reactions: any[], argument: any): void => {
19
+ // 1. For each element reaction of reactions, do
20
+ for (const reaction of reactions) {
21
+ // a. Let job be NewPromiseReactionJob(reaction, argument).
22
+ // b. Perform HostEnqueuePromiseJob(job.[[Job]], job.[[Realm]]).
23
+ __ecma262_HostEnqueuePromiseJob(__ecma262_NewPromiseReactionJob(reaction, argument));
24
+ }
25
+
26
+ // 2. Return unused.
27
+ };
28
+
29
+
30
+ // 27.2.1.6 IsPromise (x)
31
+ // https://tc39.es/ecma262/#sec-ispromise
32
+ export const __ecma262_IsPromise = (x: any): boolean => {
33
+ // custom impl
34
+ return Porffor.rawType(x) == Porffor.TYPES.promise;
35
+ };
36
+
37
+ // 27.2.1.4 FulfillPromise (promise, value)
38
+ // https://tc39.es/ecma262/#sec-fulfillpromise
39
+ export const __ecma262_FulfillPromise = (promise: any[], value: any): void => {
40
+ // 1. Assert: The value of promise.[[PromiseState]] is pending.
41
+ // todo
42
+
43
+ // 2. Let reactions be promise.[[PromiseFulfillReactions]].
44
+ const reactions: any[] = promise[2]; // fulfillReactions
45
+
46
+ // 3. Set promise.[[PromiseResult]] to value.
47
+ promise[0] = value;
48
+
49
+ // 4. Set promise.[[PromiseFulfillReactions]] to undefined.
50
+ promise[2] = undefined;
51
+
52
+ // 5. Set promise.[[PromiseRejectReactions]] to undefined.
53
+ promise[3] = undefined;
54
+
55
+ // 6. Set promise.[[PromiseState]] to fulfilled.
56
+ promise[1] = 1;
57
+
58
+ // 7. Perform TriggerPromiseReactions(reactions, value).
59
+ __ecma262_TriggerPromiseReactions(reactions, value);
60
+
61
+ // 8. Return unused.
62
+ };
63
+
64
+ // 27.2.1.7 RejectPromise (promise, reason)
65
+ // https://tc39.es/ecma262/#sec-rejectpromise
66
+ export const __ecma262_RejectPromise = (promise: any[], reason: any): void => {
67
+ // 1. Assert: The value of promise.[[PromiseState]] is pending.
68
+ // todo
69
+
70
+ // 2. Let reactions be promise.[[PromiseRejectReactions]].
71
+ const reactions: any[] = promise[3]; // rejectReactions
72
+
73
+ // 3. Set promise.[[PromiseResult]] to reason.
74
+ promise[0] = reason;
75
+
76
+ // 4. Set promise.[[PromiseFulfillReactions]] to undefined.
77
+ promise[2] = undefined;
78
+
79
+ // 5. Set promise.[[PromiseRejectReactions]] to undefined.
80
+ promise[3] = undefined;
81
+
82
+ // 6. Set promise.[[PromiseState]] to rejected.
83
+ promise[1] = 2;
84
+
85
+ // 7. If promise.[[PromiseIsHandled]] is false, perform HostPromiseRejectionTracker(promise, "reject").
86
+ // unimplemented
87
+
88
+ // 8. Perform TriggerPromiseReactions(reactions, reason).
89
+ __ecma262_TriggerPromiseReactions(reactions, reason);
90
+
91
+ // 9. Return unused.
92
+ };
93
+
94
+
95
+ export const __Porffor_promise_noop = () => {};
96
+
97
+ let activePromise: any;
98
+ export const __Porffor_promise_resolve = (value: any): any => {
99
+ // todo: if value is own promise, reject with typeerror
100
+
101
+ if (__ecma262_IsPromise(value)) {
102
+ // todo
103
+ } else {
104
+ __ecma262_FulfillPromise(activePromise, value);
105
+ }
106
+
107
+ return undefined;
108
+ };
109
+
110
+ export const __Porffor_promise_reject = (reason: any): any => {
111
+ if (__ecma262_IsPromise(reason)) {
112
+ // todo
113
+ } else {
114
+ __ecma262_RejectPromise(activePromise, reason);
115
+ }
116
+
117
+ return undefined;
118
+ };
119
+
120
+ export const __Porffor_promise_create = (): any[] => {
121
+ // Promise [ result, state, fulfillReactions, rejectReactions ]
122
+ const obj: any[] = Porffor.allocateBytes(40); // 4 length
123
+
124
+ // result = undefined
125
+ obj[0] = undefined;
126
+
127
+ // enum PromiseState { pending = 0, fulfilled = 1, rejected = 2 }
128
+ // state = .pending
129
+ obj[1] = 0;
130
+
131
+ // fulfillReactions = []
132
+ const fulfillReactions: any[] = Porffor.allocateBytes(256); // max length: 28
133
+ obj[2] = fulfillReactions;
134
+
135
+ // rejectReactions = []
136
+ const rejectReactions: any[] = Porffor.allocateBytes(256); // max length: 28
137
+ obj[3] = rejectReactions;
138
+
139
+ return obj;
140
+ };
141
+
142
+ export const __Porffor_promise_newReaction = (handler: Function, promise: any[], type: i32): any[] => {
143
+ // enum ReactionType { then = 0, finally = 1 }
144
+ const out: any[] = Porffor.allocateBytes(31); // 3 length
145
+ out[0] = handler;
146
+ out[1] = promise;
147
+ out[2] = type;
148
+
149
+ return out;
150
+ };
151
+
152
+ export const __Porffor_promise_runJobs = () => {
153
+ while (true) {
154
+ let x: any = jobQueue.shift();
155
+ if (x == null) break;
156
+
157
+ const reaction: any[] = x[0];
158
+ const handler: Function = reaction[0];
159
+ const outPromise: any[] = reaction[1];
160
+ const type: i32 = reaction[2];
161
+
162
+ const value: any = x[1];
163
+
164
+ // todo: handle thrown errors in handler?
165
+ let outValue: any;
166
+ if (type == 0) { // 0: then reaction
167
+ outValue = handler(value);
168
+ } else { // 1: finally reaction
169
+ handler();
170
+ outValue = value;
171
+ }
172
+
173
+ // todo: should this be resolve or fulfill?
174
+ __ecma262_FulfillPromise(outPromise, outValue);
175
+ }
176
+ };
177
+
178
+
179
+ export const Promise = function (executor: any): Promise {
180
+ if (!new.target) throw new TypeError("Constructor Promise requires 'new'");
181
+ if (Porffor.rawType(executor) != Porffor.TYPES.function) throw new TypeError('Promise executor is not a function');
182
+
183
+ const obj: any[] = __Porffor_promise_create();
184
+
185
+ activePromise = obj;
186
+ executor(__Porffor_promise_resolve, __Porffor_promise_reject);
187
+
188
+ const pro: Promise = obj;
189
+ return pro;
190
+ };
191
+
192
+
193
+ // 27.2.5.4 Promise.prototype.then (onFulfilled, onRejected)
194
+ // https://tc39.es/ecma262/#sec-promise.prototype.then
195
+ export const __Promise_prototype_then = (_this: any, onFulfilled: any, onRejected: any) => {
196
+ // 1. Let promise be the this value.
197
+ // 2. If IsPromise(promise) is false, throw a TypeError exception.
198
+ if (!__ecma262_IsPromise(_this)) throw new TypeError('Promise.prototype.then called on non-Promise');
199
+
200
+ // 27.2.5.4.1 PerformPromiseThen (promise, onFulfilled, onRejected [, resultCapability])
201
+ // https://tc39.es/ecma262/#sec-performpromisethen
202
+
203
+ if (Porffor.rawType(onFulfilled) != Porffor.TYPES.function) onFulfilled = __Porffor_promise_noop;
204
+ if (Porffor.rawType(onRejected) != Porffor.TYPES.function) onRejected = __Porffor_promise_noop;
205
+
206
+ const promise: any[] = _this;
207
+ const state: i32 = promise[1];
208
+
209
+ const outPromise: any[] = __Porffor_promise_create();
210
+
211
+ const fulfillReaction: any[] = __Porffor_promise_newReaction(onFulfilled, outPromise, 0);
212
+ const rejectReaction: any[] = __Porffor_promise_newReaction(onRejected, outPromise, 0);
213
+
214
+ // 9. If promise.[[PromiseState]] is pending, then
215
+ if (state == 0) { // pending
216
+ // a. Append fulfillReaction to promise.[[PromiseFulfillReactions]].
217
+ const fulfillReactions: any[] = promise[2];
218
+ Porffor.fastPush(fulfillReactions, fulfillReaction);
219
+
220
+ // b. Append rejectReaction to promise.[[PromiseRejectReactions]].
221
+ const rejectReactions: any[] = promise[3];
222
+ Porffor.fastPush(rejectReactions, rejectReaction);
223
+ } else if (state == 1) { // fulfilled
224
+ // 10. Else if promise.[[PromiseState]] is fulfilled, then
225
+ // a. Let value be promise.[[PromiseResult]].
226
+ const value: any = promise[0];
227
+
228
+ // b. Let fulfillJob be NewPromiseReactionJob(fulfillReaction, value).
229
+ // c. Perform HostEnqueuePromiseJob(fulfillJob.[[Job]], fulfillJob.[[Realm]]).
230
+ __ecma262_HostEnqueuePromiseJob(__ecma262_NewPromiseReactionJob(fulfillReaction, value));
231
+ } else { // rejected
232
+ // 11. Else,
233
+ // a. Assert: The value of promise.[[PromiseState]] is rejected.
234
+ // todo
235
+
236
+ // b. Let reason be promise.[[PromiseResult]].
237
+ const reason: any = promise[0];
238
+
239
+ // c. If promise.[[PromiseIsHandled]] is false, perform HostPromiseRejectionTracker(promise, "handle").
240
+ // unimplemented
241
+
242
+ // d. Let rejectJob be NewPromiseReactionJob(rejectReaction, reason).
243
+ // e. Perform HostEnqueuePromiseJob(rejectJob.[[Job]], rejectJob.[[Realm]]).
244
+ __ecma262_HostEnqueuePromiseJob(__ecma262_NewPromiseReactionJob(rejectReaction, reason));
245
+ }
246
+
247
+ const pro: Promise = outPromise;
248
+ return pro;
249
+ };
250
+
251
+ // 27.2.5.1 Promise.prototype.catch (onRejected)
252
+ // https://tc39.es/ecma262/#sec-promise.prototype.catch
253
+ export const __Promise_prototype_catch = (_this: any, onRejected: any): Promise => {
254
+ // 1. Let promise be the this value.
255
+ // 2. Return ? Invoke(promise, "then", « undefined, onRejected »).
256
+ return __Promise_prototype_then(_this, undefined, onRejected);
257
+ };
258
+
259
+
260
+ export const __Promise_prototype_finally = (_this: any, onFinally: any): Promise => {
261
+ // custom impl based on then but also not (sorry)
262
+ if (!__ecma262_IsPromise(_this)) throw new TypeError('Promise.prototype.then called on non-Promise');
263
+
264
+ if (Porffor.rawType(onFinally) != Porffor.TYPES.function) onFinally = __Porffor_promise_noop;
265
+
266
+ const promise: any[] = _this;
267
+ const state: i32 = promise[1];
268
+
269
+ const outPromise: any[] = __Porffor_promise_create();
270
+
271
+ const finallyReaction: any[] = __Porffor_promise_newReaction(onFinally, outPromise, 1);
272
+
273
+ if (state == 0) { // pending
274
+ const fulfillReactions: any[] = promise[2];
275
+ Porffor.fastPush(fulfillReactions, finallyReaction);
276
+
277
+ const rejectReactions: any[] = promise[3];
278
+ Porffor.fastPush(rejectReactions, finallyReaction);
279
+ } else { // fulfilled or rejected
280
+ const value: any = promise[0];
281
+ __ecma262_HostEnqueuePromiseJob(__ecma262_NewPromiseReactionJob(finallyReaction, value));
282
+ }
283
+
284
+ const pro: Promise = outPromise;
285
+ return pro;
286
+ };
287
+
288
+ export const __Promise_prototype_toString = (_this: any) => {
289
+ const str: bytestring = '[object Promise]';
290
+ return str;
291
+ };
292
+
293
+ export const __Promise_prototype_toLocaleString = (_this: any) => __Promise_prototype_toString(_this);
@@ -1877,6 +1877,122 @@ export const BuiltinFuncs = function() {
1877
1877
  returns: [124,127], typedReturns: 1,
1878
1878
  locals: [], localNames: ["_this","_this#type"],
1879
1879
  };
1880
+ this.__ecma262_NewPromiseReactionJob = {
1881
+ 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]],
1882
+ params: [124,127,124,127], typedParams: 1,
1883
+ returns: [124,127], typedReturns: 1,
1884
+ locals: [124,124,127,124,124,127], localNames: ["reaction","reaction#type","argument","argument#type","job","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#swap"],
1885
+ };
1886
+ this.__ecma262_HostEnqueuePromiseJob = {
1887
+ wasm: (scope, {glbl,builtin}) => [...glbl(35, 'jobQueue', 124),[65,208,0],[32,0],[65,208,0],[16, ...builtin('__Porffor_fastPush')],[26],[26],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1888
+ params: [124,127], typedParams: 1,
1889
+ returns: [124,127], typedReturns: 1,
1890
+ locals: [127], localNames: ["job","job#type","#last_type"],
1891
+ globalInits: {jobQueue: (scope, {allocPage,glbl,loc}) => [...number(allocPage(scope, 'array: promise.ts/jobQueue', 'f64') * pageSize, 124),...glbl(36, 'jobQueue', 124),...glbl(35, 'jobQueue', 124),[252,3],[33,loc('#makearray_pointer_tmp', 127)],[32,loc('#makearray_pointer_tmp', 127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[68,0,0,0,0,0,0,0,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[26]]},
1892
+ };
1893
+ this.__ecma262_TriggerPromiseReactions = {
1894
+ wasm: (scope, {builtin}) => [[32,0],[252,3],[33,4],[65,0],[33,6],[32,4],[40,1,0],[34,5],[4,64],[3,64],[32,4],[43,0,4],[32,4],[45,0,12],[33,8],[33,7],[2,64],[32,7],[32,8],[32,2],[32,3],[16, ...builtin('__ecma262_NewPromiseReactionJob')],[34,9],[16, ...builtin('__ecma262_HostEnqueuePromiseJob')],[33,9],[26],[32,4],[65,9],[106],[33,4],[32,6],[65,1],[106],[34,6],[32,5],[71],[13,1],[11],[11],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1895
+ params: [124,127,124,127], typedParams: 1,
1896
+ returns: [124,127], typedReturns: 1,
1897
+ locals: [127,127,127,124,127,127,127], localNames: ["reactions","reactions#type","argument","argument#type","forof_base_pointer","forof_length","forof_counter","reaction","reaction#type","#last_type","#forof_allocd"],
1898
+ };
1899
+ this.__ecma262_IsPromise = {
1900
+ wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,66,64],[97],[184],[65,2],[15]],
1901
+ params: [124,127], typedParams: 1,
1902
+ returns: [124,127], typedReturns: 1,
1903
+ locals: [], localNames: ["x","x#type"],
1904
+ };
1905
+ this.__ecma262_FulfillPromise = {
1906
+ wasm: (scope, {builtin}) => [[32,0],[33,5],[68,0,0,0,0,0,0,0,64],[34,6],[252,3],[65,9],[108],[32,5],[252,3],[106],[34,7],[43,0,4],[32,7],[45,0,12],[26],[33,4],[32,0],[33,5],[68,0,0,0,0,0,0,0,0],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[32,2],[34,11],[57,0,4],[32,12],[32,3],[58,0,12],[32,0],[33,5],[68,0,0,0,0,0,0,0,64],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[68,0,0,0,0,0,0,0,0],[34,11],[57,0,4],[32,12],[65,128,1],[58,0,12],[32,0],[33,5],[68,0,0,0,0,0,0,8,64],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[68,0,0,0,0,0,0,0,0],[34,11],[57,0,4],[32,12],[65,128,1],[58,0,12],[32,0],[33,5],[68,0,0,0,0,0,0,240,63],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[68,0,0,0,0,0,0,240,63],[34,11],[57,0,4],[32,12],[65,1],[58,0,12],[32,4],[65,208,0],[32,2],[32,3],[16, ...builtin('__ecma262_TriggerPromiseReactions')],[33,8],[26],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1907
+ params: [124,127,124,127], typedParams: 1,
1908
+ returns: [124,127], typedReturns: 1,
1909
+ locals: [124,124,124,127,127,127,127,124,127,124], localNames: ["promise","promise#type","value","value#type","reactions","#member_obj","#member_prop","#loadArray_offset","#last_type","#member_allocd","#swap","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_prop_assign"],
1910
+ };
1911
+ this.__ecma262_RejectPromise = {
1912
+ wasm: (scope, {builtin}) => [[32,0],[33,5],[68,0,0,0,0,0,0,8,64],[34,6],[252,3],[65,9],[108],[32,5],[252,3],[106],[34,7],[43,0,4],[32,7],[45,0,12],[26],[33,4],[32,0],[33,5],[68,0,0,0,0,0,0,0,0],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[32,2],[34,11],[57,0,4],[32,12],[32,3],[58,0,12],[32,0],[33,5],[68,0,0,0,0,0,0,0,64],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[68,0,0,0,0,0,0,0,0],[34,11],[57,0,4],[32,12],[65,128,1],[58,0,12],[32,0],[33,5],[68,0,0,0,0,0,0,8,64],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[68,0,0,0,0,0,0,0,0],[34,11],[57,0,4],[32,12],[65,128,1],[58,0,12],[32,0],[33,5],[68,0,0,0,0,0,0,240,63],[33,13],[32,5],[252,3],[32,13],[252,3],[65,9],[108],[106],[34,12],[68,0,0,0,0,0,0,0,64],[34,11],[57,0,4],[32,12],[65,1],[58,0,12],[32,4],[65,208,0],[32,2],[32,3],[16, ...builtin('__ecma262_TriggerPromiseReactions')],[33,8],[26],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1913
+ params: [124,127,124,127], typedParams: 1,
1914
+ returns: [124,127], typedReturns: 1,
1915
+ locals: [124,124,124,127,127,127,127,124,127,124], localNames: ["promise","promise#type","reason","reason#type","reactions","#member_obj","#member_prop","#loadArray_offset","#last_type","#member_allocd","#swap","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_prop_assign"],
1916
+ };
1917
+ this.__Porffor_promise_noop = {
1918
+ wasm: (scope, {}) => [[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1919
+ params: [], typedParams: 1,
1920
+ returns: [124,127], typedReturns: 1,
1921
+ locals: [], localNames: [],
1922
+ };
1923
+ this.__Porffor_promise_resolve = {
1924
+ wasm: (scope, {glbl,builtin}) => [[32,0],[32,1],[16, ...builtin('__ecma262_IsPromise')],[33,2],[33,3],[32,2],[33,4],[2,127],[32,4],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,3],[252,3],[40,1,0],[12,1],[11],[32,4],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,3],[252,3],[40,1,0],[12,1],[11],[32,3],[252,3],[11,"TYPESWITCH_end"],[4,64],[5],...glbl(35, 'activePromise', 124),...glbl(35, 'activePromise#type', 127),[32,0],[32,1],[16, ...builtin('__ecma262_FulfillPromise')],[33,2],[26],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1925
+ params: [124,127], typedParams: 1,
1926
+ returns: [124,127], typedReturns: 1,
1927
+ locals: [127,124,127], localNames: ["value","value#type","#last_type","#logicinner_tmp","#typeswitch_tmp"],
1928
+ globalInits: {jobQueue: (scope, {allocPage,glbl,loc}) => [...number(allocPage(scope, 'array: promise.ts/jobQueue', 'f64') * pageSize, 124),...glbl(36, 'jobQueue', 124),...glbl(35, 'jobQueue', 124),[252,3],[33,loc('#makearray_pointer_tmp', 127)],[32,loc('#makearray_pointer_tmp', 127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[68,0,0,0,0,0,0,0,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[26]]},
1929
+ };
1930
+ this.__Porffor_promise_reject = {
1931
+ wasm: (scope, {glbl,builtin}) => [[32,0],[32,1],[16, ...builtin('__ecma262_IsPromise')],[33,2],[33,3],[32,2],[33,4],[2,127],[32,4],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,3],[252,3],[40,1,0],[12,1],[11],[32,4],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,3],[252,3],[40,1,0],[12,1],[11],[32,3],[252,3],[11,"TYPESWITCH_end"],[4,64],[5],...glbl(35, 'activePromise', 124),...glbl(35, 'activePromise#type', 127),[32,0],[32,1],[16, ...builtin('__ecma262_RejectPromise')],[33,2],[26],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1932
+ params: [124,127], typedParams: 1,
1933
+ returns: [124,127], typedReturns: 1,
1934
+ locals: [127,124,127], localNames: ["reason","reason#type","#last_type","#logicinner_tmp","#typeswitch_tmp"],
1935
+ globalInits: {jobQueue: (scope, {allocPage,glbl,loc}) => [...number(allocPage(scope, 'array: promise.ts/jobQueue', 'f64') * pageSize, 124),...glbl(36, 'jobQueue', 124),...glbl(35, 'jobQueue', 124),[252,3],[33,loc('#makearray_pointer_tmp', 127)],[32,loc('#makearray_pointer_tmp', 127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[68,0,0,0,0,0,0,0,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[26]]},
1936
+ };
1937
+ this.__Porffor_promise_create = {
1938
+ wasm: (scope, {builtin}) => [[65,40],[16, ...builtin('__Porffor_allocateBytes')],[183],[34,0],[33,3],[68,0,0,0,0,0,0,0,0],[33,4],[32,3],[252,3],[32,4],[252,3],[65,9],[108],[106],[34,2],[68,0,0,0,0,0,0,0,0],[34,1],[57,0,4],[32,2],[65,128,1],[58,0,12],[32,0],[33,3],[68,0,0,0,0,0,0,240,63],[33,4],[32,3],[252,3],[32,4],[252,3],[65,9],[108],[106],[34,2],[68,0,0,0,0,0,0,0,0],[34,1],[57,0,4],[32,2],[65,1],[58,0,12],[65,128,2],[16, ...builtin('__Porffor_allocateBytes')],[183],[33,6],[32,0],[33,3],[68,0,0,0,0,0,0,0,64],[33,4],[32,3],[252,3],[32,4],[252,3],[65,9],[108],[106],[34,2],[32,6],[34,1],[57,0,4],[32,2],[65,208,0],[58,0,12],[65,128,2],[16, ...builtin('__Porffor_allocateBytes')],[183],[33,7],[32,0],[33,3],[68,0,0,0,0,0,0,8,64],[33,4],[32,3],[252,3],[32,4],[252,3],[65,9],[108],[106],[34,2],[32,7],[34,1],[57,0,4],[32,2],[65,208,0],[58,0,12],[32,0],[65,208,0],[15]],
1939
+ params: [], typedParams: 1,
1940
+ returns: [124,127], typedReturns: 1,
1941
+ locals: [124,124,127,124,124,127,124,124], localNames: ["obj","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#swap","fulfillReactions","rejectReactions"],
1942
+ };
1943
+ this.__Porffor_promise_newReaction = {
1944
+ wasm: (scope, {builtin}) => [[65,31],[16, ...builtin('__Porffor_allocateBytes')],[183],[34,6],[33,9],[68,0,0,0,0,0,0,0,0],[33,10],[32,9],[252,3],[32,10],[252,3],[65,9],[108],[106],[34,8],[32,0],[34,7],[57,0,4],[32,8],[65,6],[58,0,12],[32,6],[33,9],[68,0,0,0,0,0,0,240,63],[33,10],[32,9],[252,3],[32,10],[252,3],[65,9],[108],[106],[34,8],[32,2],[34,7],[57,0,4],[32,8],[65,208,0],[58,0,12],[32,6],[33,9],[68,0,0,0,0,0,0,0,64],[33,10],[32,9],[252,3],[32,10],[252,3],[65,9],[108],[106],[34,8],[32,4],[34,7],[57,0,4],[32,8],[65,1],[58,0,12],[32,6],[65,208,0],[15]],
1945
+ params: [124,127,124,127,124,127], typedParams: 1,
1946
+ returns: [124,127], typedReturns: 1,
1947
+ locals: [124,124,127,124,124,127], localNames: ["handler","handler#type","promise","promise#type","type","type#type","out","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_obj","#member_prop_assign","#swap"],
1948
+ };
1949
+ this.__Porffor_promise_runJobs = {
1950
+ wasm: (scope, {glbl,builtin,internalThrow}) => [[3,64],[65,1],[4,64],...glbl(35, 'jobQueue', 124),[252,3],[34,3],[40,1,0],[33,2],[2,124],[32,2],[69],[4,64],[68,0,0,0,0,0,0,0,0],[12,1],[11],[32,3],[32,2],[65,1],[107],[34,2],[54,1,0],[32,3],[43,0,4],[32,3],[45,0,12],[65,4],[32,3],[106],[65,13],[32,3],[106],[32,2],[65,9],[108],[252,10,0,0],[33,4],[11],[33,0],[32,4],[33,1],[32,0],[33,5],[32,1],[33,6],[2,127],[32,6],[65,0],[70],[4,64,"TYPESWITCH|empty"],[65,1],[12,1],[11],[32,6],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,5],[68,0,0,0,0,0,0,0,0],[97],[12,1],[11],[32,6],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],[65,1],[12,1],[11],[65,0],[11,"TYPESWITCH_end"],[4,64],[12,1],[11],[32,0],[33,8],[68,0,0,0,0,0,0,0,0],[33,9],[32,1],[33,6],[2,124],[32,6],[65,6],[70],[4,64,"TYPESWITCH|Function"],[32,8],[252,3],[32,1],[32,9],[65,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,12],[252,3],[32,12],[16, ...builtin('__Porffor_object_get')],[33,4],[12,1],[11],[32,6],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,8],[252,3],[32,1],[32,9],[65,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,12],[252,3],[32,12],[16, ...builtin('__Porffor_object_get')],[33,4],[12,1],[11],[32,6],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[16, ...builtin('__Porffor_allocate')],[34,11],[65,1],[54,0,0],[32,11],[32,9],[252,3],[65,2],[108],[32,8],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,4],[12,1],[11],[32,6],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[32,9],[252,3],[65,9],[108],[32,8],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[33,4],[12,1],[11],[32,6],[65,216,0],[70],[4,64,"TYPESWITCH|Uint8Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[106],[45,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,217,0],[70],[4,64,"TYPESWITCH|Int8Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[106],[44,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,218,0],[70],[4,64,"TYPESWITCH|Uint8ClampedArray"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[106],[45,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,219,0],[70],[4,64,"TYPESWITCH|Uint16Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,220,0],[70],[4,64,"TYPESWITCH|Int16Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,221,0],[70],[4,64,"TYPESWITCH|Uint32Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,222,0],[70],[4,64,"TYPESWITCH|Int32Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,223,0],[70],[4,64,"TYPESWITCH|Float32Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,4],[12,1],[11],[32,6],[65,224,0],[70],[4,64,"TYPESWITCH|Float64Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,4],[12,1],[11],[32,6],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],...internalThrow(scope, 'TypeError', `Cannot read property of undefined`),[68,0,0,0,0,0,0,0,0],[12,1],[11],[32,6],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[16, ...builtin('__Porffor_allocate')],[34,11],[65,1],[54,0,0],[32,11],[32,9],[252,3],[32,8],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,4],[12,1],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,4],[11,"TYPESWITCH_end"],[34,7],[33,8],[68,0,0,0,0,0,0,0,0],[34,9],[252,3],[65,9],[108],[32,8],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[26],[33,13],[32,7],[33,8],[68,0,0,0,0,0,0,240,63],[34,9],[252,3],[65,9],[108],[32,8],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[26],[33,14],[32,7],[33,8],[68,0,0,0,0,0,0,0,64],[34,9],[252,3],[65,9],[108],[32,8],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[26],[33,15],[32,0],[33,8],[68,0,0,0,0,0,0,240,63],[33,9],[32,1],[33,6],[2,124],[32,6],[65,6],[70],[4,64,"TYPESWITCH|Function"],[32,8],[252,3],[32,1],[32,9],[65,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,12],[252,3],[32,12],[16, ...builtin('__Porffor_object_get')],[33,4],[12,1],[11],[32,6],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,8],[252,3],[32,1],[32,9],[65,1],[16, ...builtin('__ecma262_ToPropertyKey')],[33,12],[252,3],[32,12],[16, ...builtin('__Porffor_object_get')],[33,4],[12,1],[11],[32,6],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[16, ...builtin('__Porffor_allocate')],[34,11],[65,1],[54,0,0],[32,11],[32,9],[252,3],[65,2],[108],[32,8],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,4],[12,1],[11],[32,6],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[32,9],[252,3],[65,9],[108],[32,8],[252,3],[106],[34,10],[43,0,4],[32,10],[45,0,12],[33,4],[12,1],[11],[32,6],[65,216,0],[70],[4,64,"TYPESWITCH|Uint8Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[106],[45,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,217,0],[70],[4,64,"TYPESWITCH|Int8Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[106],[44,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,218,0],[70],[4,64,"TYPESWITCH|Uint8ClampedArray"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[106],[45,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,219,0],[70],[4,64,"TYPESWITCH|Uint16Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,220,0],[70],[4,64,"TYPESWITCH|Int16Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,221,0],[70],[4,64,"TYPESWITCH|Uint32Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,222,0],[70],[4,64,"TYPESWITCH|Int32Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,223,0],[70],[4,64,"TYPESWITCH|Float32Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,4],[12,1],[11],[32,6],[65,224,0],[70],[4,64,"TYPESWITCH|Float64Array"],[32,8],[252,3],[40,0,4],[32,9],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,4],[12,1],[11],[32,6],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],...internalThrow(scope, 'TypeError', `Cannot read property of undefined`),[68,0,0,0,0,0,0,0,0],[12,1],[11],[32,6],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[16, ...builtin('__Porffor_allocate')],[34,11],[65,1],[54,0,0],[32,11],[32,9],[252,3],[32,8],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,4],[12,1],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,4],[11,"TYPESWITCH_end"],[33,16],[32,4],[33,17],[32,15],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,13],[33,28],[32,16],[32,17],[33,20],[33,21],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,22],[33,23],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,24],[33,25],[32,28],[252,3],[34,26],[65,128,1],[108],[65,2],[106],[45,0,128,128,4,"read func lut"],[34,27],[65,2],[113],[69],[65,0],[113],[4,64],...internalThrow(scope, 'TypeError', `handler is not a constructor`),[11],[2,124],[2,64],[2,64],[2,64],[2,64],[32,26],[65,128,1],[108],[47,0,128,128,4,"read func lut"],[14,4,0,1,2,3,0],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,26],[17,2,0,"no_type_return"],[5],[32,26],[17,0,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,26],[17,2,0],[33,4],[5],[32,26],[17,0,0],[33,4],[11],[11],[12,3],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,26],[17,3,0,"no_type_return"],[5],[32,21],[32,20],[32,26],[17,1,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,26],[17,3,0],[33,4],[5],[32,21],[32,20],[32,26],[17,1,0],[33,4],[11],[11],[12,2],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,26],[17,4,0,"no_type_return"],[5],[32,21],[32,20],[32,23],[32,22],[32,26],[17,2,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,26],[17,4,0],[33,4],[5],[32,21],[32,20],[32,23],[32,22],[32,26],[17,2,0],[33,4],[11],[11],[12,1],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,5,0,"no_type_return"],[5],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,3,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,5,0],[33,4],[5],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,3,0],[33,4],[11],[11],[11],[34,18],[32,4],[33,19],[26],[5],[32,13],[33,28],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,20],[33,21],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,22],[33,23],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,24],[33,25],[32,28],[252,3],[34,26],[65,128,1],[108],[65,2],[106],[45,0,128,128,4,"read func lut"],[34,27],[65,2],[113],[69],[65,0],[113],[4,64],...internalThrow(scope, 'TypeError', `handler is not a constructor`),[11],[2,124],[2,64],[2,64],[2,64],[2,64],[32,26],[65,128,1],[108],[47,0,128,128,4,"read func lut"],[14,4,0,1,2,3,0],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,26],[17,2,0,"no_type_return"],[5],[32,26],[17,0,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,26],[17,2,0],[33,4],[5],[32,26],[17,0,0],[33,4],[11],[11],[12,3],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,26],[17,3,0,"no_type_return"],[5],[32,21],[32,20],[32,26],[17,1,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,26],[17,3,0],[33,4],[5],[32,21],[32,20],[32,26],[17,1,0],[33,4],[11],[11],[12,2],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,26],[17,4,0,"no_type_return"],[5],[32,21],[32,20],[32,23],[32,22],[32,26],[17,2,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,26],[17,4,0],[33,4],[5],[32,21],[32,20],[32,23],[32,22],[32,26],[17,2,0],[33,4],[11],[11],[12,1],[11],[32,27],[65,1],[113],[4,124],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,5,0,"no_type_return"],[5],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,3,0,"no_type_return"],[11],[5],[32,27],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,5,0],[33,4],[5],[32,21],[32,20],[32,23],[32,22],[32,25],[32,24],[32,26],[17,3,0],[33,4],[11],[11],[11],[26],[32,16],[34,18],[32,17],[33,19],[26],[11],[32,14],[65,208,0],[32,18],[32,19],[16, ...builtin('__ecma262_FulfillPromise')],[33,4],[26],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
1951
+ params: [], typedParams: 1,
1952
+ returns: [124,127], typedReturns: 1,
1953
+ locals: [124,127,127,127,127,124,127,124,124,124,127,127,127,124,124,124,124,127,124,127,127,124,127,124,127,124,127,127,124], localNames: ["x","x#type","__proto_length_cache","__proto_pointer_cache","#last_type","#logicinner_tmp","#typeswitch_tmp","reaction","#member_obj","#member_prop","#loadArray_offset","#member_allocd","#swap","handler","outPromise","type","value","value#type","outValue","outValue#type","#indirect_arg0_type","#indirect_arg0_val","#indirect_arg1_type","#indirect_arg1_val","#indirect_arg2_type","#indirect_arg2_val","#indirect_func","#indirect_flags","#indirect_callee"],
1954
+ globalInits: {jobQueue: (scope, {allocPage,glbl,loc}) => [...number(allocPage(scope, 'array: promise.ts/jobQueue', 'f64') * pageSize, 124),...glbl(36, 'jobQueue', 124),...glbl(35, 'jobQueue', 124),[252,3],[33,loc('#makearray_pointer_tmp', 127)],[32,loc('#makearray_pointer_tmp', 127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[68,0,0,0,0,0,0,0,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[26]]},
1955
+ table: 1,
1956
+ };
1957
+ this.Promise = {
1958
+ wasm: (scope, {glbl,builtin,internalThrow}) => [[32,0],[33,6],[32,1],[33,7],[2,124],[32,7],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,6],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,7],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,6],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,6],[68,0,0,0,0,0,0,0,0],[97],[184],[11,"TYPESWITCH_end"],[252,3],[4,64],...internalThrow(scope, 'TypeError', `Constructor Promise requires 'new'`),[11],[32,4],[32,5],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,24,64],[98],[4,64],...internalThrow(scope, 'TypeError', `Promise executor is not a function`),[11],[16, ...builtin('__Porffor_promise_create')],[26],[34,8],...glbl(36, 'activePromise', 124),...glbl(35, 'activePromise', 124),[65,208,0],...glbl(36, 'activePromise#type', 127),[26],[32,4],[33,18],[32,5],[33,7],[2,124],[32,7],[65,6],[70],[4,64,"TYPESWITCH|Function"],[68,...builtin('__Porffor_promise_resolve', true, true)],[65,6],[33,10],[33,11],[68,...builtin('__Porffor_promise_reject', true, true)],[65,6],[33,12],[33,13],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,14],[33,15],[32,18],[252,3],[34,16],[65,128,1],[108],[65,2],[106],[45,0,128,128,4,"read func lut"],[34,17],[65,2],[113],[69],[65,0],[113],[4,64],...internalThrow(scope, 'TypeError', `executor is not a constructor`),[11],[2,124],[2,64],[2,64],[2,64],[2,64],[32,16],[65,128,1],[108],[47,0,128,128,4,"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],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,16],[17,2,0,"no_type_return"],[5],[32,16],[17,0,0,"no_type_return"],[11],[5],[32,17],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,16],[17,2,0],[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],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,11],[32,10],[32,16],[17,3,0,"no_type_return"],[5],[32,11],[32,10],[32,16],[17,1,0,"no_type_return"],[11],[5],[32,17],[65,2],[113],[4,124],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,11],[32,10],[32,16],[17,3,0],[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],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,11],[32,10],[32,13],[32,12],[32,16],[17,4,0,"no_type_return"],[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],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,11],[32,10],[32,13],[32,12],[32,16],[17,4,0],[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],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,5,0,"no_type_return"],[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],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('#get_globalThis')],[184],[65,7],[32,11],[32,10],[32,13],[32,12],[32,15],[32,14],[32,16],[17,5,0],[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', `executor is not a function`),[68,0,0,0,0,0,0,0,0],[11,"TYPESWITCH_end"],[26],[32,8],[34,19],[65,36],[15]],
1959
+ params: [124,127,124,127,124,127], typedParams: 1,
1960
+ returns: [124,127], typedReturns: 1,
1961
+ locals: [124,127,124,127,127,124,127,124,127,124,127,127,124,124], localNames: ["#newtarget","#newtarget#type","#this","#this#type","executor","executor#type","#logicinner_tmp","#typeswitch_tmp","obj","#last_type","#indirect_arg0_type","#indirect_arg0_val","#indirect_arg1_type","#indirect_arg1_val","#indirect_arg2_type","#indirect_arg2_val","#indirect_func","#indirect_flags","#indirect_callee","pro"],
1962
+ globalInits: {jobQueue: (scope, {allocPage,glbl,loc}) => [...number(allocPage(scope, 'array: promise.ts/jobQueue', 'f64') * pageSize, 124),...glbl(36, 'jobQueue', 124),...glbl(35, 'jobQueue', 124),[252,3],[33,loc('#makearray_pointer_tmp', 127)],[32,loc('#makearray_pointer_tmp', 127)],[65,0],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[68,0,0,0,0,0,0,0,0],[252,3],[54,1,0],[32,loc('#makearray_pointer_tmp', 127)],[26]]},
1963
+ table: 1, constr: 1,
1964
+ };
1965
+ this.__Promise_prototype_then = {
1966
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__ecma262_IsPromise')],[33,6],[33,7],[32,6],[33,8],[2,124],[32,8],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,7],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,8],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,7],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,7],[68,0,0,0,0,0,0,0,0],[97],[184],[11,"TYPESWITCH_end"],[252,3],[4,64],...internalThrow(scope, 'TypeError', `Promise.prototype.then called on non-Promise`),[11],[32,2],[32,3],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,24,64],[98],[4,64],[68,...builtin('__Porffor_promise_noop', true, true)],[34,2],[65,6],[33,3],[26],[11],[32,4],[32,5],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,24,64],[98],[4,64],[68,...builtin('__Porffor_promise_noop', true, true)],[34,4],[65,6],[33,5],[26],[11],[32,0],[34,9],[33,11],[68,0,0,0,0,0,0,240,63],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[26],[33,10],[16, ...builtin('__Porffor_promise_create')],[26],[33,16],[32,2],[32,3],[32,16],[65,208,0],[68,0,0,0,0,0,0,0,0],[65,1],[16, ...builtin('__Porffor_promise_newReaction')],[26],[33,17],[32,4],[32,5],[32,16],[65,208,0],[68,0,0,0,0,0,0,0,0],[65,1],[16, ...builtin('__Porffor_promise_newReaction')],[26],[33,18],[32,10],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,9],[33,11],[68,0,0,0,0,0,0,0,64],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[26],[34,19],[65,208,0],[32,17],[65,208,0],[16, ...builtin('__Porffor_fastPush')],[33,6],[26],[32,9],[33,11],[68,0,0,0,0,0,0,8,64],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[26],[34,20],[65,208,0],[32,18],[65,208,0],[16, ...builtin('__Porffor_fastPush')],[33,6],[26],[5],[32,10],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,9],[33,11],[68,0,0,0,0,0,0,0,0],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[33,22],[33,21],[32,17],[65,208,0],[32,21],[32,22],[16, ...builtin('__ecma262_NewPromiseReactionJob')],[34,6],[16, ...builtin('__ecma262_HostEnqueuePromiseJob')],[33,6],[26],[5],[32,9],[33,11],[68,0,0,0,0,0,0,0,0],[34,12],[252,3],[65,9],[108],[32,11],[252,3],[106],[34,13],[43,0,4],[32,13],[45,0,12],[33,24],[33,23],[32,18],[65,208,0],[32,23],[32,24],[16, ...builtin('__ecma262_NewPromiseReactionJob')],[34,6],[16, ...builtin('__ecma262_HostEnqueuePromiseJob')],[33,6],[26],[11],[11],[32,16],[34,25],[65,36],[15]],
1967
+ params: [124,127,124,127,124,127], typedParams: 1,
1968
+ returns: [124,127], typedReturns: 1,
1969
+ locals: [127,124,127,124,124,124,124,127,127,127,124,124,124,124,124,124,127,124,127,124], localNames: ["_this","_this#type","onFulfilled","onFulfilled#type","onRejected","onRejected#type","#last_type","#logicinner_tmp","#typeswitch_tmp","promise","state","#member_obj","#member_prop","#loadArray_offset","#member_allocd","#swap","outPromise","fulfillReaction","rejectReaction","fulfillReactions","rejectReactions","value","value#type","reason","reason#type","pro"],
1970
+ };
1971
+ this.__Promise_prototype_catch = {
1972
+ wasm: (scope, {builtin}) => [[32,0],[32,1],[68,0,0,0,0,0,0,0,0],[65,128,1],[32,2],[32,3],[16, ...builtin('__Promise_prototype_then')],[34,4],[15]],
1973
+ params: [124,127,124,127], typedParams: 1,
1974
+ returns: [124,127], typedReturns: 1,
1975
+ locals: [127], localNames: ["_this","_this#type","onRejected","onRejected#type","#last_type"],
1976
+ };
1977
+ this.__Promise_prototype_finally = {
1978
+ wasm: (scope, {builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__ecma262_IsPromise')],[33,4],[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', `Promise.prototype.then called on non-Promise`),[11],[32,2],[32,3],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,24,64],[98],[4,64],[68,...builtin('__Porffor_promise_noop', true, true)],[34,2],[65,6],[33,3],[26],[11],[32,0],[34,7],[33,9],[68,0,0,0,0,0,0,240,63],[34,10],[252,3],[65,9],[108],[32,9],[252,3],[106],[34,11],[43,0,4],[32,11],[45,0,12],[26],[33,8],[16, ...builtin('__Porffor_promise_create')],[26],[33,14],[32,2],[32,3],[32,14],[65,208,0],[68,0,0,0,0,0,0,240,63],[65,1],[16, ...builtin('__Porffor_promise_newReaction')],[26],[33,15],[32,8],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,7],[33,9],[68,0,0,0,0,0,0,0,64],[34,10],[252,3],[65,9],[108],[32,9],[252,3],[106],[34,11],[43,0,4],[32,11],[45,0,12],[26],[34,16],[65,208,0],[32,15],[65,208,0],[16, ...builtin('__Porffor_fastPush')],[33,4],[26],[32,7],[33,9],[68,0,0,0,0,0,0,8,64],[34,10],[252,3],[65,9],[108],[32,9],[252,3],[106],[34,11],[43,0,4],[32,11],[45,0,12],[26],[34,17],[65,208,0],[32,15],[65,208,0],[16, ...builtin('__Porffor_fastPush')],[33,4],[26],[5],[32,7],[33,9],[68,0,0,0,0,0,0,0,0],[34,10],[252,3],[65,9],[108],[32,9],[252,3],[106],[34,11],[43,0,4],[32,11],[45,0,12],[33,19],[33,18],[32,15],[65,208,0],[32,18],[32,19],[16, ...builtin('__ecma262_NewPromiseReactionJob')],[34,4],[16, ...builtin('__ecma262_HostEnqueuePromiseJob')],[33,4],[26],[11],[32,14],[34,20],[65,36],[15]],
1979
+ params: [124,127,124,127], typedParams: 1,
1980
+ returns: [124,127], typedReturns: 1,
1981
+ locals: [127,124,127,124,124,124,124,127,127,127,124,124,124,124,124,127,124], localNames: ["_this","_this#type","onFinally","onFinally#type","#last_type","#logicinner_tmp","#typeswitch_tmp","promise","state","#member_obj","#member_prop","#loadArray_offset","#member_allocd","#swap","outPromise","finallyReaction","fulfillReactions","rejectReactions","value","value#type","pro"],
1982
+ };
1983
+ this.__Promise_prototype_toString = {
1984
+ wasm: (scope, {allocPage}) => [...number(allocPage(scope, 'bytestring: __Promise_prototype_toString/str', 'i8') * pageSize, 124),[34,2],[65,195,1],[15]],
1985
+ params: [124,127], typedParams: 1,
1986
+ returns: [124,127], typedReturns: 1,
1987
+ locals: [124], localNames: ["_this","_this#type","str"],
1988
+ data: [[0,[16,0,0,0,91,111,98,106,101,99,116,32,80,114,111,109,105,115,101,93]]],
1989
+ };
1990
+ this.__Promise_prototype_toLocaleString = {
1991
+ wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__Promise_prototype_toString')],[34,2],[15]],
1992
+ params: [124,127], typedParams: 1,
1993
+ returns: [124,127], typedReturns: 1,
1994
+ locals: [127], localNames: ["_this","_this#type","#last_type"],
1995
+ };
1880
1996
  this.__Reflect_get = {
1881
1997
  wasm: (scope, {builtin,internalThrow}) => [[32,0],[252,2],[32,1],[16, ...builtin('__Porffor_object_isObject')],[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', `Target is a non-object`),[11],[32,0],[33,7],[32,2],[33,8],[32,1],[33,6],[2,124],[32,6],[65,6],[70],[4,64,"TYPESWITCH|Function"],[32,7],[252,3],[32,1],[32,8],[32,3],[16, ...builtin('__ecma262_ToPropertyKey')],[33,11],[252,3],[32,11],[16, ...builtin('__Porffor_object_get')],[33,4],[12,1],[11],[32,6],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,7],[252,3],[32,1],[32,8],[32,3],[16, ...builtin('__ecma262_ToPropertyKey')],[33,11],[252,3],[32,11],[16, ...builtin('__Porffor_object_get')],[33,4],[12,1],[11],[32,6],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[16, ...builtin('__Porffor_allocate')],[34,10],[65,1],[54,0,0],[32,10],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,10],[184],[65,195,0],[33,4],[12,1],[11],[32,6],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,9],[43,0,4],[32,9],[45,0,12],[33,4],[12,1],[11],[32,6],[65,216,0],[70],[4,64,"TYPESWITCH|Uint8Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,217,0],[70],[4,64,"TYPESWITCH|Int8Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,218,0],[70],[4,64,"TYPESWITCH|Uint8ClampedArray"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,219,0],[70],[4,64,"TYPESWITCH|Uint16Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,220,0],[70],[4,64,"TYPESWITCH|Int16Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,221,0],[70],[4,64,"TYPESWITCH|Uint32Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,4],[12,1],[11],[32,6],[65,222,0],[70],[4,64,"TYPESWITCH|Int32Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,4],[12,1],[11],[32,6],[65,223,0],[70],[4,64,"TYPESWITCH|Float32Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,4],[12,1],[11],[32,6],[65,224,0],[70],[4,64,"TYPESWITCH|Float64Array"],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,4],[12,1],[11],[32,6],[65,128,1],[70],[4,64,"TYPESWITCH|undefined"],...internalThrow(scope, 'TypeError', `Cannot read property of undefined`),[68,0,0,0,0,0,0,0,0],[12,1],[11],[32,6],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[16, ...builtin('__Porffor_allocate')],[34,10],[65,1],[54,0,0],[32,10],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,10],[184],[65,195,1],[33,4],[12,1],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,4],[11,"TYPESWITCH_end"],[32,4],[15]],
1882
1998
  params: [124,127,124,127], typedParams: 1,
@@ -4492,7 +4608,7 @@ export const BuiltinFuncs = function() {
4492
4608
  locals: [124,127], localNames: ["value","value#type","integer","#last_type"],
4493
4609
  };
4494
4610
  this.__ecma262_ToString = {
4495
- wasm: (scope, {allocPage,builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[34,2],[68,0,0,0,0,0,192,80,64],[97],[32,2],[68,0,0,0,0,0,96,104,64],[97],[114],[4,64],[32,0],[32,1],[15],[11],[32,2],[68,0,0,0,0,0,0,20,64],[97],[4,64],...internalThrow(scope, 'TypeError', `Cannot convert a Symbol value to a string`),[11],[16, ...builtin('__Porffor_allocate')],[183],[33,3],[32,2],[68,0,0,0,0,0,0,96,64],[97],[32,2],[68,0,0,0,0,0,0,0,0],[97],[114],[4,64],...number(allocPage(scope, 'bytestring: __ecma262_ToString/out', 'i8') * pageSize, 124),[34,3],[65,195,1],[15],[11],[32,2],[68,0,0,0,0,0,0,28,64],[97],[32,0],[68,0,0,0,0,0,0,0,0],[97],[113],[4,64],[32,3],[252,3],[34,4],[65,4],[54,1,0],[32,4],[65,238,0],[58,0,4],[32,4],[65,245,0],[58,0,5],[32,4],[65,236,0],[58,0,6],[32,4],[65,236,0],[58,0,7],[32,4],[184],[34,3],[65,195,1],[15],[11],[32,2],[68,0,0,0,0,0,0,0,64],[97],[4,64],[32,0],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,3],[252,3],[34,4],[65,4],[54,1,0],[32,4],[65,244,0],[58,0,4],[32,4],[65,242,0],[58,0,5],[32,4],[65,245,0],[58,0,6],[32,4],[65,229,0],[58,0,7],[32,4],[184],[34,3],[65,195,1],[15],[11],[32,3],[252,3],[34,4],[65,5],[54,1,0],[32,4],[65,230,0],[58,0,4],[32,4],[65,225,0],[58,0,5],[32,4],[65,236,0],[58,0,6],[32,4],[65,243,0],[58,0,7],[32,4],[65,229,0],[58,0,8],[32,4],[184],[34,3],[65,195,1],[15],[11],[32,0],[33,5],[32,1],[34,6],[33,8],[2,124],[32,8],[65,1],[70],[4,64,"TYPESWITCH|Number"],[32,5],[32,6],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('__Number_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,2],[70],[4,64,"TYPESWITCH|Boolean"],[32,5],[32,6],[16, ...builtin('__Boolean_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,5],[70],[4,64,"TYPESWITCH|Symbol"],[32,5],[32,6],[16, ...builtin('__Symbol_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,6],[70],[4,64,"TYPESWITCH|Function"],[32,5],[32,6],[16, ...builtin('__Function_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,5],[32,6],[16, ...builtin('__Object_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,18],[70],[4,64,"TYPESWITCH|Date"],[32,5],[32,6],[16, ...builtin('__Date_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,19],[70],[4,64,"TYPESWITCH|Set"],[32,5],[32,6],[16, ...builtin('__Set_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,20],[70],[4,64,"TYPESWITCH|Map"],[32,5],[32,6],[16, ...builtin('__Map_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,33],[70],[4,64,"TYPESWITCH|WeakRef"],[32,5],[32,6],[16, ...builtin('__WeakRef_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,34],[70],[4,64,"TYPESWITCH|WeakSet"],[32,5],[32,6],[16, ...builtin('__WeakSet_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,35],[70],[4,64,"TYPESWITCH|WeakMap"],[32,5],[32,6],[16, ...builtin('__WeakMap_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,5],[252,2],[32,6],[16, ...builtin('__String_prototype_toString')],[33,7],[183],[12,1],[11],[32,8],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[32,5],[32,6],[16, ...builtin('__Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,216,0],[70],[4,64,"TYPESWITCH|Uint8Array"],[32,5],[32,6],[16, ...builtin('__Uint8Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,217,0],[70],[4,64,"TYPESWITCH|Int8Array"],[32,5],[32,6],[16, ...builtin('__Int8Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,218,0],[70],[4,64,"TYPESWITCH|Uint8ClampedArray"],[32,5],[32,6],[16, ...builtin('__Uint8ClampedArray_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,219,0],[70],[4,64,"TYPESWITCH|Uint16Array"],[32,5],[32,6],[16, ...builtin('__Uint16Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,220,0],[70],[4,64,"TYPESWITCH|Int16Array"],[32,5],[32,6],[16, ...builtin('__Int16Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,221,0],[70],[4,64,"TYPESWITCH|Uint32Array"],[32,5],[32,6],[16, ...builtin('__Uint32Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,222,0],[70],[4,64,"TYPESWITCH|Int32Array"],[32,5],[32,6],[16, ...builtin('__Int32Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,223,0],[70],[4,64,"TYPESWITCH|Float32Array"],[32,5],[32,6],[16, ...builtin('__Float32Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,224,0],[70],[4,64,"TYPESWITCH|Float64Array"],[32,5],[32,6],[16, ...builtin('__Float64Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,5],[252,2],[32,6],[16, ...builtin('__ByteString_prototype_toString')],[33,7],[183],[12,1],[11],...internalThrow(scope, 'TypeError', `'toString' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[32,7],[15]],
4611
+ wasm: (scope, {allocPage,builtin,internalThrow}) => [[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[34,2],[68,0,0,0,0,0,192,80,64],[97],[32,2],[68,0,0,0,0,0,96,104,64],[97],[114],[4,64],[32,0],[32,1],[15],[11],[32,2],[68,0,0,0,0,0,0,20,64],[97],[4,64],...internalThrow(scope, 'TypeError', `Cannot convert a Symbol value to a string`),[11],[16, ...builtin('__Porffor_allocate')],[183],[33,3],[32,2],[68,0,0,0,0,0,0,96,64],[97],[32,2],[68,0,0,0,0,0,0,0,0],[97],[114],[4,64],...number(allocPage(scope, 'bytestring: __ecma262_ToString/out', 'i8') * pageSize, 124),[34,3],[65,195,1],[15],[11],[32,2],[68,0,0,0,0,0,0,28,64],[97],[32,0],[68,0,0,0,0,0,0,0,0],[97],[113],[4,64],[32,3],[252,3],[34,4],[65,4],[54,1,0],[32,4],[65,238,0],[58,0,4],[32,4],[65,245,0],[58,0,5],[32,4],[65,236,0],[58,0,6],[32,4],[65,236,0],[58,0,7],[32,4],[184],[34,3],[65,195,1],[15],[11],[32,2],[68,0,0,0,0,0,0,0,64],[97],[4,64],[32,0],[68,0,0,0,0,0,0,240,63],[97],[4,64],[32,3],[252,3],[34,4],[65,4],[54,1,0],[32,4],[65,244,0],[58,0,4],[32,4],[65,242,0],[58,0,5],[32,4],[65,245,0],[58,0,6],[32,4],[65,229,0],[58,0,7],[32,4],[184],[34,3],[65,195,1],[15],[11],[32,3],[252,3],[34,4],[65,5],[54,1,0],[32,4],[65,230,0],[58,0,4],[32,4],[65,225,0],[58,0,5],[32,4],[65,236,0],[58,0,6],[32,4],[65,243,0],[58,0,7],[32,4],[65,229,0],[58,0,8],[32,4],[184],[34,3],[65,195,1],[15],[11],[32,0],[33,5],[32,1],[34,6],[33,8],[2,124],[32,8],[65,1],[70],[4,64,"TYPESWITCH|Number"],[32,5],[32,6],[68,0,0,0,0,0,0,0,0],[65,128,1],[16, ...builtin('__Number_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,2],[70],[4,64,"TYPESWITCH|Boolean"],[32,5],[32,6],[16, ...builtin('__Boolean_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,5],[70],[4,64,"TYPESWITCH|Symbol"],[32,5],[32,6],[16, ...builtin('__Symbol_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,6],[70],[4,64,"TYPESWITCH|Function"],[32,5],[32,6],[16, ...builtin('__Function_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,7],[70],[4,64,"TYPESWITCH|Object"],[32,5],[32,6],[16, ...builtin('__Object_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,18],[70],[4,64,"TYPESWITCH|Date"],[32,5],[32,6],[16, ...builtin('__Date_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,19],[70],[4,64,"TYPESWITCH|Set"],[32,5],[32,6],[16, ...builtin('__Set_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,20],[70],[4,64,"TYPESWITCH|Map"],[32,5],[32,6],[16, ...builtin('__Map_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,33],[70],[4,64,"TYPESWITCH|WeakRef"],[32,5],[32,6],[16, ...builtin('__WeakRef_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,34],[70],[4,64,"TYPESWITCH|WeakSet"],[32,5],[32,6],[16, ...builtin('__WeakSet_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,35],[70],[4,64,"TYPESWITCH|WeakMap"],[32,5],[32,6],[16, ...builtin('__WeakMap_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,36],[70],[4,64,"TYPESWITCH|Promise"],[32,5],[32,6],[16, ...builtin('__Promise_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,5],[252,2],[32,6],[16, ...builtin('__String_prototype_toString')],[33,7],[183],[12,1],[11],[32,8],[65,208,0],[70],[4,64,"TYPESWITCH|Array"],[32,5],[32,6],[16, ...builtin('__Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,216,0],[70],[4,64,"TYPESWITCH|Uint8Array"],[32,5],[32,6],[16, ...builtin('__Uint8Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,217,0],[70],[4,64,"TYPESWITCH|Int8Array"],[32,5],[32,6],[16, ...builtin('__Int8Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,218,0],[70],[4,64,"TYPESWITCH|Uint8ClampedArray"],[32,5],[32,6],[16, ...builtin('__Uint8ClampedArray_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,219,0],[70],[4,64,"TYPESWITCH|Uint16Array"],[32,5],[32,6],[16, ...builtin('__Uint16Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,220,0],[70],[4,64,"TYPESWITCH|Int16Array"],[32,5],[32,6],[16, ...builtin('__Int16Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,221,0],[70],[4,64,"TYPESWITCH|Uint32Array"],[32,5],[32,6],[16, ...builtin('__Uint32Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,222,0],[70],[4,64,"TYPESWITCH|Int32Array"],[32,5],[32,6],[16, ...builtin('__Int32Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,223,0],[70],[4,64,"TYPESWITCH|Float32Array"],[32,5],[32,6],[16, ...builtin('__Float32Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,224,0],[70],[4,64,"TYPESWITCH|Float64Array"],[32,5],[32,6],[16, ...builtin('__Float64Array_prototype_toString')],[33,7],[12,1],[11],[32,8],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,5],[252,2],[32,6],[16, ...builtin('__ByteString_prototype_toString')],[33,7],[183],[12,1],[11],...internalThrow(scope, 'TypeError', `'toString' proto func tried to be called on a type without an impl`),[11,"TYPESWITCH_end"],[32,7],[15]],
4496
4612
  params: [124,127], typedParams: 1,
4497
4613
  returns: [124,127], typedReturns: 1,
4498
4614
  locals: [124,124,127,124,127,127,127], localNames: ["argument","argument#type","type","out","#makearray_pointer_tmp","#proto_target","#proto_target#type","#last_type","#typeswitch_tmp"],
@@ -333,7 +333,10 @@ const generateIdent = (scope, decl) => {
333
333
  if (Object.hasOwn(globals, name)) return [ [ Opcodes.global_get, globals[name].idx ] ];
334
334
 
335
335
  if (Object.hasOwn(importedFuncs, name)) return number(importedFuncs[name] - importedFuncs.length);
336
- if (Object.hasOwn(funcIndex, name)) return number(funcIndex[name] - importedFuncs.length);
336
+ if (Object.hasOwn(funcIndex, name)) {
337
+ if (globalThis.precompile) return [ [ Opcodes.const, 'funcref', name ] ];
338
+ return number(funcIndex[name] - importedFuncs.length);
339
+ }
337
340
  }
338
341
 
339
342
  if (local?.idx === undefined && rawName.startsWith('__')) {
@@ -1195,7 +1198,7 @@ const asmFuncToAsm = (scope, func) => {
1195
1198
  return func(scope, {
1196
1199
  TYPES, TYPE_NAMES, typeSwitch, makeArray, makeString, allocPage, internalThrow,
1197
1200
  getNodeType, generate, generateIdent,
1198
- builtin: n => {
1201
+ builtin: (n, float = false, offset = false) => {
1199
1202
  let idx = funcIndex[n] ?? importedFuncs[n];
1200
1203
  if (idx == null && builtinFuncs[n]) {
1201
1204
  includeBuiltin(null, n);
@@ -1203,7 +1206,9 @@ const asmFuncToAsm = (scope, func) => {
1203
1206
  }
1204
1207
 
1205
1208
  if (idx == null) throw new Error(`builtin('${n}') failed to find a func (inside ${scope.name})`);
1206
- return unsignedLEB128(idx);
1209
+ if (offset) idx -= importedFuncs.length;
1210
+
1211
+ return float ? ieee754_binary64(idx) : unsignedLEB128(idx);
1207
1212
  },
1208
1213
  glbl: (opcode, name, type) => {
1209
1214
  const globalName = '#porf#' + name; // avoid potential name clashing with user js
@@ -2357,6 +2362,23 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
2357
2362
  ...internalThrow(scope, 'TypeError', `${unhackName(name)} is not a constructor`),
2358
2363
  [ Opcodes.end ],
2359
2364
 
2365
+ // [ Opcodes.local_get, funcLocal ],
2366
+ // Opcodes.i32_from_u,
2367
+ // [ Opcodes.call, 0 ],
2368
+
2369
+ // ...number(32),
2370
+ // [ Opcodes.call, 1 ],
2371
+
2372
+ // [ Opcodes.local_get, funcLocal ],
2373
+ // ...number(128, Valtype.i32),
2374
+ // [ Opcodes.i32_mul ],
2375
+ // [ Opcodes.i32_load16_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut') * pageSize), 'read func lut' ],
2376
+ // Opcodes.i32_from_u,
2377
+ // [ Opcodes.call, 0 ],
2378
+
2379
+ // ...number(10),
2380
+ // [ Opcodes.call, 1 ],
2381
+
2360
2382
  ...brTable([
2361
2383
  // get argc of func we are calling
2362
2384
  [ Opcodes.local_get, funcLocal ],
@@ -5233,11 +5255,53 @@ const generateFunc = (scope, decl) => {
5233
5255
 
5234
5256
  const wasm = func.wasm = prelude.concat(generate(func, body));
5235
5257
 
5236
- if (name === 'main') func.gotLastType = true;
5258
+ if (name === 'main') {
5259
+ func.gotLastType = true;
5260
+
5261
+ func.export = true;
5262
+ func.returns = [ valtypeBinary, Valtype.i32 ];
5263
+
5264
+ const lastInst = func.wasm[func.wasm.length - 1] ?? [ Opcodes.end ];
5265
+ if (lastInst[0] === Opcodes.drop) {
5266
+ func.wasm.splice(func.wasm.length - 1, 1);
5267
+
5268
+ const finalStatement = decl.body.body[decl.body.body.length - 1];
5269
+ func.wasm.push(...getNodeType(func, finalStatement));
5270
+ }
5271
+
5272
+ if (lastInst[0] === Opcodes.end || lastInst[0] === Opcodes.local_set || lastInst[0] === Opcodes.global_set) {
5273
+ if (lastInst[0] === Opcodes.local_set && lastInst[1] === func.locals['#last_type'].idx) {
5274
+ func.wasm.splice(main.wasm.length - 1, 1);
5275
+ } else {
5276
+ func.returns = [];
5277
+ }
5278
+ }
5237
5279
 
5238
- // add end return if not found
5239
- if (name !== 'main' && wasm[wasm.length - 1]?.[0] !== Opcodes.return && countLeftover(wasm) === 0) {
5240
- wasm.push(...generateReturn(func, {}));
5280
+ if (lastInst[0] === Opcodes.call) {
5281
+ const callee = funcs.find(x => x.index === lastInst[1]);
5282
+ if (callee) func.returns = callee.returns.slice();
5283
+ else func.returns = [];
5284
+ }
5285
+
5286
+ // inject promise job runner func at the end of main if used
5287
+ if (Object.hasOwn(funcIndex, 'Promise')) {
5288
+ wasm.push(
5289
+ ...generateCall(func, {
5290
+ callee: {
5291
+ type: 'Identifier',
5292
+ name: '__Porffor_promise_runJobs'
5293
+ },
5294
+ arguments: []
5295
+ }).slice(0, -1), // remove set last type
5296
+ [ Opcodes.drop ],
5297
+ [ Opcodes.drop ]
5298
+ );
5299
+ }
5300
+ } else {
5301
+ // add end return if not found
5302
+ if (wasm[wasm.length - 1]?.[0] !== Opcodes.return && countLeftover(wasm) === 0) {
5303
+ wasm.push(...generateReturn(func, {}));
5304
+ }
5241
5305
  }
5242
5306
 
5243
5307
  if (func.constr) {
@@ -5488,31 +5552,6 @@ export default program => {
5488
5552
 
5489
5553
  const main = generateFunc(scope, program);
5490
5554
 
5491
- main.export = true;
5492
- main.returns = [ valtypeBinary, Valtype.i32 ];
5493
-
5494
- const lastInst = main.wasm[main.wasm.length - 1] ?? [ Opcodes.end ];
5495
- if (lastInst[0] === Opcodes.drop) {
5496
- main.wasm.splice(main.wasm.length - 1, 1);
5497
-
5498
- const finalStatement = program.body.body[program.body.body.length - 1];
5499
- main.wasm.push(...getNodeType(main, finalStatement));
5500
- }
5501
-
5502
- if (lastInst[0] === Opcodes.end || lastInst[0] === Opcodes.local_set || lastInst[0] === Opcodes.global_set) {
5503
- if (lastInst[0] === Opcodes.local_set && lastInst[1] === main.locals['#last_type'].idx) {
5504
- main.wasm.splice(main.wasm.length - 1, 1);
5505
- } else {
5506
- main.returns = [];
5507
- }
5508
- }
5509
-
5510
- if (lastInst[0] === Opcodes.call) {
5511
- const func = funcs.find(x => x.index === lastInst[1]);
5512
- if (func) main.returns = func.returns.slice();
5513
- else main.returns = [];
5514
- }
5515
-
5516
5555
  delete globals['#ind'];
5517
5556
 
5518
5557
  // if blank main func and other exports, remove it
package/compiler/opt.js CHANGED
@@ -347,7 +347,7 @@ export default (funcs, globals, pages, tags, exceptions) => {
347
347
  continue;
348
348
  }
349
349
 
350
- if (lastInst[0] === Opcodes.i32_const && (inst[0] === Opcodes.i32_from[0] || inst[0] === Opcodes.i32_from_u[0])) {
350
+ if (lastInst[0] === Opcodes.i32_const && (inst[0] === Opcodes.i32_from[0] || inst[0] === Opcodes.i32_from_u[0]) && (typeof lastInst[1] !== 'string')) {
351
351
  // change i32 const and immediate convert to const (opposite way of previous)
352
352
  // i32.const 0
353
353
  // f64.convert_i32_s || f64.convert_i32_u
@@ -191,7 +191,7 @@ const precompile = async () => {
191
191
  }
192
192
 
193
193
  const total = performance.now() - t;
194
- console.log(`\r${' '.repeat(100)}\r\u001b[90m${`[${total.toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92mcompiled ${fileCount} files (${funcs.length} funcs)\u001b[0m \u001b[90m(${['parse', 'codegen', 'opt'].map(x => `${x}: ${((timing[x] / total) * 100).toFixed(2)}%`).join(', ')})\u001b[0m`);
194
+ console.log(`\r${' '.repeat(100)}\r\u001b[90m${`[${total.toFixed(2)}ms]`.padEnd(12, ' ')}\u001b[0m\u001b[92mcompiled ${fileCount} files (${funcs.length} funcs)\u001b[0m \u001b[90m(${['parse', 'codegen', 'opt'].map(x => `${x}: ${((timing[x] / total) * 100).toFixed(0)}%`).join(', ')})\u001b[0m`);
195
195
 
196
196
  return `// autogenerated by compiler/precompile.js
197
197
  import { number } from './embedding.js';
@@ -204,6 +204,7 @@ ${funcs.map(x => {
204
204
  .replace(/\["global",(.*?),"(.*?)",(.*?)\]/g, (_, opcode, name, valtype) => `...glbl(${opcode}, '${name}', ${valtype})`)
205
205
  .replace(/\"local","(.*?)",(.*?)\]/g, (_, name, valtype) => `loc('${name}', ${valtype})]`)
206
206
  .replace(/\[16,"(.*?)"]/g, (_, name) => `[16, ...builtin('${name}')]`)
207
+ .replace(/\[68,"funcref","(.*?)"]/g, (_, name, offset) => `[68,...builtin('${name}', true, true)]`)
207
208
  .replace(/\["throw","(.*?)","(.*?)"\]/g, (_, constructor, message) => `...internalThrow(scope, '${constructor}', \`${message}\`)`)
208
209
  .replace(/\["get object","(.*?)"\]/g, (_, objName) => `...generateIdent(scope, { name: '${objName}' })`);
209
210
 
package/compiler/types.js CHANGED
@@ -72,6 +72,8 @@ registerInternalType('WeakRef');
72
72
  registerInternalType('WeakSet');
73
73
  registerInternalType('WeakMap');
74
74
 
75
+ registerInternalType('Promise');
76
+
75
77
  if (Prefs.largestTypes) {
76
78
  const typeKeys = Object.keys(TYPES);
77
79
  const typeVals = Object.values(TYPES);
package/compiler/wrap.js CHANGED
@@ -35,7 +35,7 @@ export const writeByteStr = (memory, ptr, str) => {
35
35
  }
36
36
  };
37
37
 
38
- const porfToJSValue = ({ memory, funcs, pages }, value, type) => {
38
+ const porfToJSValue = ({ memory, funcs, pages }, value, type, override = undefined) => {
39
39
  switch (type) {
40
40
  case TYPES.empty:
41
41
  case TYPES.undefined:
@@ -138,7 +138,8 @@ ${flags & 0b0001 ? ` get func idx: ${get}
138
138
  }
139
139
 
140
140
  case TYPES.array: {
141
- const length = read(Uint32Array, memory, value, 1)[0];
141
+ let length = read(Uint32Array, memory, value, 1)[0];
142
+ if (override) length = override;
142
143
 
143
144
  const out = [];
144
145
  for (let i = 0; i < length; i++) {
@@ -258,6 +259,30 @@ ${flags & 0b0001 ? ` get func idx: ${get}
258
259
  return out;
259
260
  }
260
261
 
262
+ case TYPES.promise: {
263
+ const [ result, _state, fulfillReactions, rejectReactions ] = porfToJSValue({ memory, funcs, pages }, value, TYPES.array, 4);
264
+
265
+ const state = ({
266
+ 0: 'pending',
267
+ 1: 'fulfilled',
268
+ 2: 'rejected'
269
+ })[_state];
270
+ const stateColor = ({
271
+ 0: '\x1B[93m',
272
+ 1: '\x1B[32m',
273
+ 2: '\x1B[31m'
274
+ })[_state];
275
+
276
+ const out = { state, result };
277
+ Object.defineProperty(out, Symbol.for('nodejs.util.inspect.custom'), {
278
+ value(depth, opts, inspect) {
279
+ return `${opts.colors ? '\x1B[36m' : ''}Promise${opts.colors ? '\x1B[0m' : ''} (state: ${opts.colors ? stateColor : ''}<${state}>${opts.colors ? '\x1B[0m' : ''}, result: ${inspect(result, opts)})`;
280
+ }
281
+ });
282
+
283
+ return out;
284
+ }
285
+
261
286
  default: return value;
262
287
  }
263
288
  };
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.25.3+8f4d9af84",
4
+ "version": "0.25.5+b293a1a33",
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.25.3+8f4d9af84';
3
+ globalThis.version = '0.25.5+b293a1a33';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {