porffor 0.25.3 → 0.25.4
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/promise.ts +247 -0
- package/compiler/builtins_precompiled.js +99 -1
- package/compiler/codegen.js +71 -32
- package/compiler/opt.js +1 -1
- package/compiler/precompile.js +2 -1
- package/compiler/types.js +2 -0
- package/compiler/wrap.js +27 -2
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -0,0 +1,247 @@
|
|
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
|
+
printStatic('todo res');
|
103
|
+
// todo
|
104
|
+
} else {
|
105
|
+
__ecma262_FulfillPromise(activePromise, value);
|
106
|
+
}
|
107
|
+
|
108
|
+
return undefined;
|
109
|
+
};
|
110
|
+
|
111
|
+
export const __Porffor_promise_reject = (reason: any): any => {
|
112
|
+
if (__ecma262_IsPromise(reason)) {
|
113
|
+
printStatic('todo rej');
|
114
|
+
// todo
|
115
|
+
} else {
|
116
|
+
__ecma262_RejectPromise(activePromise, reason);
|
117
|
+
}
|
118
|
+
|
119
|
+
return undefined;
|
120
|
+
};
|
121
|
+
|
122
|
+
export const __Porffor_promise_create = (): any[] => {
|
123
|
+
// Promise [ result, state, fulfillReactions, rejectReactions ]
|
124
|
+
const obj: any[] = Porffor.allocateBytes(40); // 4 length
|
125
|
+
|
126
|
+
// result = undefined
|
127
|
+
obj[0] = undefined;
|
128
|
+
|
129
|
+
// enum PromiseState { pending = 0, fulfilled = 1, rejected = 2 }
|
130
|
+
// state = .pending
|
131
|
+
obj[1] = 0;
|
132
|
+
|
133
|
+
// fulfillReactions = []
|
134
|
+
const fulfillReactions: any[] = Porffor.allocateBytes(256); // max length: 28
|
135
|
+
obj[2] = fulfillReactions;
|
136
|
+
|
137
|
+
// rejectReactions = []
|
138
|
+
const rejectReactions: any[] = Porffor.allocateBytes(256); // max length: 28
|
139
|
+
obj[3] = rejectReactions;
|
140
|
+
|
141
|
+
return obj;
|
142
|
+
};
|
143
|
+
|
144
|
+
export const __Porffor_promise_runJobs = () => {
|
145
|
+
while (true) {
|
146
|
+
let x: any = jobQueue.shift();
|
147
|
+
if (x == null) break;
|
148
|
+
|
149
|
+
const reaction: any[] = x[0];
|
150
|
+
const handler: Function = reaction[0];
|
151
|
+
const outPromise: any[] = reaction[1];
|
152
|
+
|
153
|
+
const value: any = x[1];
|
154
|
+
|
155
|
+
// todo: handle thrown errors in handler?
|
156
|
+
const outValue: any = handler(value);
|
157
|
+
|
158
|
+
// todo: should this be resolve or fulfill?
|
159
|
+
__ecma262_FulfillPromise(outPromise, outValue);
|
160
|
+
}
|
161
|
+
};
|
162
|
+
|
163
|
+
|
164
|
+
export const Promise = function (executor: any): Promise {
|
165
|
+
if (!new.target) throw new TypeError("Constructor Promise requires 'new'");
|
166
|
+
if (Porffor.rawType(executor) != Porffor.TYPES.function) throw new TypeError('Promise executor is not a function');
|
167
|
+
|
168
|
+
const obj: any[] = __Porffor_promise_create();
|
169
|
+
|
170
|
+
activePromise = obj;
|
171
|
+
executor(__Porffor_promise_resolve, __Porffor_promise_reject);
|
172
|
+
|
173
|
+
const pro: Promise = obj;
|
174
|
+
return pro;
|
175
|
+
};
|
176
|
+
|
177
|
+
|
178
|
+
export const __Promise_prototype_then = (_this: any, onFulfilled: any, onRejected: any) => {
|
179
|
+
// 27.2.5.4 Promise.prototype.then (onFulfilled, onRejected)
|
180
|
+
// https://tc39.es/ecma262/#sec-promise.prototype.then
|
181
|
+
|
182
|
+
// 1. Let promise be the this value.
|
183
|
+
// 2. If IsPromise(promise) is false, throw a TypeError exception.
|
184
|
+
if (!__ecma262_IsPromise(_this)) throw new TypeError('Promise.prototype.then called on non-Promise');
|
185
|
+
|
186
|
+
// 27.2.5.4.1 PerformPromiseThen (promise, onFulfilled, onRejected [, resultCapability])
|
187
|
+
// https://tc39.es/ecma262/#sec-performpromisethen
|
188
|
+
|
189
|
+
if (Porffor.rawType(onFulfilled) != Porffor.TYPES.function) onFulfilled = __Porffor_promise_noop;
|
190
|
+
if (Porffor.rawType(onRejected) != Porffor.TYPES.function) onRejected = __Porffor_promise_noop;
|
191
|
+
|
192
|
+
const promise: any[] = _this;
|
193
|
+
const state: i32 = promise[1];
|
194
|
+
|
195
|
+
const outPromise: any[] = __Porffor_promise_create();
|
196
|
+
|
197
|
+
const fulfillReaction: any[] = Porffor.allocateBytes(22); // 2 length
|
198
|
+
fulfillReaction[0] = onFulfilled;
|
199
|
+
fulfillReaction[1] = outPromise;
|
200
|
+
|
201
|
+
const rejectReaction: any[] = Porffor.allocateBytes(22); // 2 length
|
202
|
+
rejectReaction[0] = onRejected;
|
203
|
+
rejectReaction[1] = outPromise;
|
204
|
+
|
205
|
+
// 9. If promise.[[PromiseState]] is pending, then
|
206
|
+
if (state == 0) { // pending
|
207
|
+
// a. Append fulfillReaction to promise.[[PromiseFulfillReactions]].
|
208
|
+
const fulfillReactions: any[] = promise[2];
|
209
|
+
Porffor.fastPush(fulfillReactions, fulfillReaction);
|
210
|
+
|
211
|
+
// b. Append rejectReaction to promise.[[PromiseRejectReactions]].
|
212
|
+
const rejectReactions: any[] = promise[3];
|
213
|
+
Porffor.fastPush(rejectReactions, rejectReaction);
|
214
|
+
} else if (state == 1) { // fulfilled
|
215
|
+
// 10. Else if promise.[[PromiseState]] is fulfilled, then
|
216
|
+
// a. Let value be promise.[[PromiseResult]].
|
217
|
+
const value: any = promise[0];
|
218
|
+
|
219
|
+
// b. Let fulfillJob be NewPromiseReactionJob(fulfillReaction, value).
|
220
|
+
// c. Perform HostEnqueuePromiseJob(fulfillJob.[[Job]], fulfillJob.[[Realm]]).
|
221
|
+
__ecma262_HostEnqueuePromiseJob(__ecma262_NewPromiseReactionJob(fulfillReaction, value));
|
222
|
+
} else { // rejected
|
223
|
+
// 11. Else,
|
224
|
+
// a. Assert: The value of promise.[[PromiseState]] is rejected.
|
225
|
+
// todo
|
226
|
+
|
227
|
+
// b. Let reason be promise.[[PromiseResult]].
|
228
|
+
const reason: any = promise[0];
|
229
|
+
|
230
|
+
// c. If promise.[[PromiseIsHandled]] is false, perform HostPromiseRejectionTracker(promise, "handle").
|
231
|
+
// unimplemented
|
232
|
+
|
233
|
+
// d. Let rejectJob be NewPromiseReactionJob(rejectReaction, reason).
|
234
|
+
// e. Perform HostEnqueuePromiseJob(rejectJob.[[Job]], rejectJob.[[Realm]]).
|
235
|
+
__ecma262_HostEnqueuePromiseJob(__ecma262_NewPromiseReactionJob(rejectReaction, reason));
|
236
|
+
}
|
237
|
+
|
238
|
+
const pro: Promise = outPromise;
|
239
|
+
return pro;
|
240
|
+
};
|
241
|
+
|
242
|
+
export const __Promise_prototype_toString = (_this: any) => {
|
243
|
+
const str: bytestring = '[object Promise]';
|
244
|
+
return str;
|
245
|
+
};
|
246
|
+
|
247
|
+
export const __Promise_prototype_toLocaleString = (_this: any) => __Promise_prototype_toString(_this);
|
@@ -1877,6 +1877,104 @@ 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],[68,0,0,0,0,0,0,93,64],[16,1],[68,0,0,0,0,0,192,91,64],[16,1],[68,0,0,0,0,0,0,89,64],[16,1],[68,0,0,0,0,0,192,91,64],[16,1],[68,0,0,0,0,0,0,64,64],[16,1],[68,0,0,0,0,0,128,92,64],[16,1],[68,0,0,0,0,0,64,89,64],[16,1],[68,0,0,0,0,0,192,92,64],[16,1],[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],[68,0,0,0,0,0,0,93,64],[16,1],[68,0,0,0,0,0,192,91,64],[16,1],[68,0,0,0,0,0,0,89,64],[16,1],[68,0,0,0,0,0,192,91,64],[16,1],[68,0,0,0,0,0,0,64,64],[16,1],[68,0,0,0,0,0,128,92,64],[16,1],[68,0,0,0,0,0,64,89,64],[16,1],[68,0,0,0,0,0,128,90,64],[16,1],[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_runJobs = {
|
1944
|
+
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,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,15],[32,4],[33,16],[32,13],[33,27],[32,15],[32,16],[33,19],[33,20],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,21],[33,22],[68,0,0,0,0,0,0,0,0],[65,128,1],[33,23],[33,24],[32,27],[252,3],[34,25],[65,128,1],[108],[65,2],[106],[45,0,128,128,4,"read func lut"],[34,26],[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,25],[65,128,1],[108],[47,0,128,128,4,"read func lut"],[14,4,0,1,2,3,0],[11],[32,26],[65,1],[113],[4,124],[32,26],[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,25],[17,2,0,"no_type_return"],[5],[32,25],[17,0,0,"no_type_return"],[11],[5],[32,26],[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,25],[17,2,0],[33,4],[5],[32,25],[17,0,0],[33,4],[11],[11],[12,3],[11],[32,26],[65,1],[113],[4,124],[32,26],[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,20],[32,19],[32,25],[17,3,0,"no_type_return"],[5],[32,20],[32,19],[32,25],[17,1,0,"no_type_return"],[11],[5],[32,26],[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,20],[32,19],[32,25],[17,3,0],[33,4],[5],[32,20],[32,19],[32,25],[17,1,0],[33,4],[11],[11],[12,2],[11],[32,26],[65,1],[113],[4,124],[32,26],[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,20],[32,19],[32,22],[32,21],[32,25],[17,4,0,"no_type_return"],[5],[32,20],[32,19],[32,22],[32,21],[32,25],[17,2,0,"no_type_return"],[11],[5],[32,26],[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,20],[32,19],[32,22],[32,21],[32,25],[17,4,0],[33,4],[5],[32,20],[32,19],[32,22],[32,21],[32,25],[17,2,0],[33,4],[11],[11],[12,1],[11],[32,26],[65,1],[113],[4,124],[32,26],[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,20],[32,19],[32,22],[32,21],[32,24],[32,23],[32,25],[17,5,0,"no_type_return"],[5],[32,20],[32,19],[32,22],[32,21],[32,24],[32,23],[32,25],[17,3,0,"no_type_return"],[11],[5],[32,26],[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,20],[32,19],[32,22],[32,21],[32,24],[32,23],[32,25],[17,5,0],[33,4],[5],[32,20],[32,19],[32,22],[32,21],[32,24],[32,23],[32,25],[17,3,0],[33,4],[11],[11],[11],[33,17],[32,4],[33,18],[32,14],[65,208,0],[32,17],[32,18],[16, ...builtin('__ecma262_FulfillPromise')],[33,4],[26],[12,1],[11],[11],[68,0,0,0,0,0,0,0,0],[65,128,1],[15]],
|
1945
|
+
params: [], typedParams: 1,
|
1946
|
+
returns: [124,127], typedReturns: 1,
|
1947
|
+
locals: [124,127,127,127,127,124,127,124,124,124,127,127,127,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","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"],
|
1948
|
+
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]]},
|
1949
|
+
table: 1,
|
1950
|
+
};
|
1951
|
+
this.Promise = {
|
1952
|
+
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]],
|
1953
|
+
params: [124,127,124,127,124,127], typedParams: 1,
|
1954
|
+
returns: [124,127], typedReturns: 1,
|
1955
|
+
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"],
|
1956
|
+
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]]},
|
1957
|
+
table: 1, constr: 1,
|
1958
|
+
};
|
1959
|
+
this.__Promise_prototype_then = {
|
1960
|
+
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],[65,22],[16, ...builtin('__Porffor_allocateBytes')],[183],[34,17],[33,11],[68,0,0,0,0,0,0,0,0],[33,20],[32,11],[252,3],[32,20],[252,3],[65,9],[108],[106],[34,19],[32,2],[34,18],[57,0,4],[32,19],[32,3],[58,0,12],[32,17],[33,11],[68,0,0,0,0,0,0,240,63],[33,20],[32,11],[252,3],[32,20],[252,3],[65,9],[108],[106],[34,19],[32,16],[34,18],[57,0,4],[32,19],[65,208,0],[58,0,12],[65,22],[16, ...builtin('__Porffor_allocateBytes')],[183],[34,21],[33,11],[68,0,0,0,0,0,0,0,0],[33,20],[32,11],[252,3],[32,20],[252,3],[65,9],[108],[106],[34,19],[32,4],[34,18],[57,0,4],[32,19],[32,5],[58,0,12],[32,21],[33,11],[68,0,0,0,0,0,0,240,63],[33,20],[32,11],[252,3],[32,20],[252,3],[65,9],[108],[106],[34,19],[32,16],[34,18],[57,0,4],[32,19],[65,208,0],[58,0,12],[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,22],[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,23],[65,208,0],[32,21],[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,25],[33,24],[32,17],[65,208,0],[32,24],[32,25],[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,27],[33,26],[32,21],[65,208,0],[32,26],[32,27],[16, ...builtin('__ecma262_NewPromiseReactionJob')],[34,6],[16, ...builtin('__ecma262_HostEnqueuePromiseJob')],[33,6],[26],[11],[11],[32,16],[34,28],[65,36],[15]],
|
1961
|
+
params: [124,127,124,127,124,127], typedParams: 1,
|
1962
|
+
returns: [124,127], typedReturns: 1,
|
1963
|
+
locals: [127,124,127,124,124,124,124,127,127,127,124,124,124,127,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","#member_setter_val_tmp","#member_setter_ptr_tmp","#member_prop_assign","rejectReaction","fulfillReactions","rejectReactions","value","value#type","reason","reason#type","pro"],
|
1964
|
+
};
|
1965
|
+
this.__Promise_prototype_toString = {
|
1966
|
+
wasm: (scope, {allocPage}) => [...number(allocPage(scope, 'bytestring: __Promise_prototype_toString/str', 'i8') * pageSize, 124),[34,2],[65,195,1],[15]],
|
1967
|
+
params: [124,127], typedParams: 1,
|
1968
|
+
returns: [124,127], typedReturns: 1,
|
1969
|
+
locals: [124], localNames: ["_this","_this#type","str"],
|
1970
|
+
data: [[0,[16,0,0,0,91,111,98,106,101,99,116,32,80,114,111,109,105,115,101,93]]],
|
1971
|
+
};
|
1972
|
+
this.__Promise_prototype_toLocaleString = {
|
1973
|
+
wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__Promise_prototype_toString')],[34,2],[15]],
|
1974
|
+
params: [124,127], typedParams: 1,
|
1975
|
+
returns: [124,127], typedReturns: 1,
|
1976
|
+
locals: [127], localNames: ["_this","_this#type","#last_type"],
|
1977
|
+
};
|
1880
1978
|
this.__Reflect_get = {
|
1881
1979
|
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
1980
|
params: [124,127,124,127], typedParams: 1,
|
@@ -4492,7 +4590,7 @@ export const BuiltinFuncs = function() {
|
|
4492
4590
|
locals: [124,127], localNames: ["value","value#type","integer","#last_type"],
|
4493
4591
|
};
|
4494
4592
|
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]],
|
4593
|
+
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
4594
|
params: [124,127], typedParams: 1,
|
4497
4595
|
returns: [124,127], typedReturns: 1,
|
4498
4596
|
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"],
|
package/compiler/codegen.js
CHANGED
@@ -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))
|
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
|
-
|
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')
|
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
|
-
|
5239
|
-
|
5240
|
-
|
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
|
package/compiler/precompile.js
CHANGED
@@ -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(
|
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
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
|
-
|
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