porffor 0.60.27 → 0.60.29
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/json.ts +125 -67
- package/compiler/builtins.js +172 -0
- package/compiler/builtins_precompiled.js +26 -5
- package/compiler/codegen.js +4 -191
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/runtime/index.js +1 -1
|
@@ -1,169 +1,222 @@
|
|
|
1
1
|
import type {} from './porffor.d.ts';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const __Porffor_bytestring_bufferStr = (buffer: i32, str: bytestring): i32 => {
|
|
4
|
+
const len: i32 = str.length;
|
|
5
|
+
let strPtr: i32 = Porffor.wasm`local.get ${str}`;
|
|
6
|
+
let ptr: i32 = Porffor.wasm`local.get ${buffer}`;
|
|
7
|
+
let endPtr: i32 = ptr + len;
|
|
8
|
+
|
|
9
|
+
while (ptr + 4 <= endPtr) {
|
|
10
|
+
Porffor.wasm.i32.store(ptr, Porffor.wasm.i32.load(strPtr, 0, 4), 0, 4);
|
|
11
|
+
ptr += 4;
|
|
12
|
+
strPtr += 4;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
while (ptr < endPtr) {
|
|
16
|
+
Porffor.wasm.i32.store8(ptr++, Porffor.wasm.i32.load8_u(strPtr++, 0, 4), 0, 4);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return ptr;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const __Porffor_bytestring_bufferChar = (buffer: i32, char: i32): i32 => {
|
|
23
|
+
Porffor.wasm.i32.store8(buffer, char, 0, 4);
|
|
24
|
+
return buffer + 1;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const __Porffor_bytestring_buffer2Char = (buffer: i32, char1: i32, char2: i32): i32 => {
|
|
28
|
+
Porffor.wasm.i32.store8(buffer, char1, 0, 4);
|
|
29
|
+
Porffor.wasm.i32.store8(buffer + 1, char2, 0, 4);
|
|
30
|
+
return buffer + 2;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const __Porffor_json_canSerialize = (value: any): boolean => {
|
|
34
|
+
if (Porffor.fastOr(
|
|
35
|
+
value === null,
|
|
36
|
+
value === true,
|
|
37
|
+
value === false,
|
|
38
|
+
(Porffor.type(value) | 0b10000000) == Porffor.TYPES.bytestring,
|
|
39
|
+
Porffor.type(value) == Porffor.TYPES.stringobject,
|
|
40
|
+
Porffor.type(value) == Porffor.TYPES.number,
|
|
41
|
+
Porffor.type(value) == Porffor.TYPES.numberobject,
|
|
42
|
+
Porffor.type(value) == Porffor.TYPES.array,
|
|
43
|
+
Porffor.type(value) > Porffor.TYPES.function
|
|
44
|
+
)) return true;
|
|
45
|
+
|
|
46
|
+
if (Porffor.type(value) == Porffor.TYPES.bigint) {
|
|
47
|
+
throw new TypeError('Cannot serialize BigInts');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return false;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const __Porffor_json_serialize = (_buffer: i32, value: any, depth: i32, space: bytestring|undefined): i32 => {
|
|
4
54
|
// somewhat modelled after 25.5.2.2 SerializeJSONProperty: https://tc39.es/ecma262/#sec-serializejsonproperty
|
|
5
|
-
|
|
6
|
-
if (value ===
|
|
7
|
-
if (value ===
|
|
55
|
+
let buffer: i32 = Porffor.wasm`local.get ${_buffer}`;
|
|
56
|
+
if (value === null) return __Porffor_bytestring_bufferStr(buffer, 'null');
|
|
57
|
+
if (value === true) return __Porffor_bytestring_bufferStr(buffer, 'true');
|
|
58
|
+
if (value === false) return __Porffor_bytestring_bufferStr(buffer, 'false');
|
|
8
59
|
|
|
9
60
|
if (Porffor.fastOr(
|
|
10
61
|
(Porffor.type(value) | 0b10000000) == Porffor.TYPES.bytestring,
|
|
11
62
|
Porffor.type(value) == Porffor.TYPES.stringobject
|
|
12
63
|
)) { // string
|
|
13
|
-
|
|
14
|
-
Porffor.bytestring.appendChar(out, 34); // start "
|
|
64
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 34); // start "
|
|
15
65
|
|
|
16
66
|
const len: i32 = value.length;
|
|
17
67
|
for (let i: i32 = 0; i < len; i++) {
|
|
18
68
|
const c: i32 = value.charCodeAt(i);
|
|
19
69
|
if (c < 0x20) {
|
|
20
70
|
if (c == 0x08) {
|
|
21
|
-
|
|
71
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 98); // \b
|
|
22
72
|
continue;
|
|
23
73
|
}
|
|
24
74
|
|
|
25
75
|
if (c == 0x09) {
|
|
26
|
-
|
|
76
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 116); // \t
|
|
27
77
|
continue;
|
|
28
78
|
}
|
|
29
79
|
|
|
30
80
|
if (c == 0x0a) {
|
|
31
|
-
|
|
81
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 110); // \n
|
|
32
82
|
continue;
|
|
33
83
|
}
|
|
34
84
|
|
|
35
85
|
if (c == 0x0c) {
|
|
36
|
-
|
|
86
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 102); // \f
|
|
37
87
|
continue;
|
|
38
88
|
}
|
|
39
89
|
|
|
40
90
|
if (c == 0x0d) {
|
|
41
|
-
|
|
91
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 114); // \r
|
|
42
92
|
continue;
|
|
43
93
|
}
|
|
44
94
|
|
|
45
95
|
// \u00FF
|
|
46
|
-
|
|
47
|
-
|
|
96
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 117); // \u
|
|
97
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 48, 48); // 00
|
|
48
98
|
|
|
49
99
|
const h1: i32 = (c & 0xf0) / 0x10;
|
|
50
100
|
const h2: i32 = c & 0x0f;
|
|
51
|
-
|
|
52
|
-
Porffor.bytestring.appendChar(out, h2 < 10 ? h2 + 48 : h2 + 55); // 0-9 or A-F
|
|
101
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, h1 < 10 ? h1 + 48 : h1 + 55, h2 < 10 ? h2 + 48 : h2 + 55); // 0-9 or A-F
|
|
53
102
|
continue;
|
|
54
103
|
}
|
|
55
104
|
|
|
56
105
|
if (c == 0x22) { // "
|
|
57
|
-
|
|
106
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 34); // \"
|
|
58
107
|
continue;
|
|
59
108
|
}
|
|
60
109
|
|
|
61
110
|
if (c == 0x5c) { // \
|
|
62
|
-
|
|
111
|
+
buffer = __Porffor_bytestring_buffer2Char(buffer, 92, 92); // \\
|
|
63
112
|
continue;
|
|
64
113
|
}
|
|
65
114
|
|
|
66
115
|
// todo: support non-bytestrings
|
|
67
|
-
|
|
116
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, c);
|
|
68
117
|
}
|
|
69
118
|
|
|
70
|
-
|
|
71
|
-
return out;
|
|
119
|
+
return __Porffor_bytestring_bufferChar(buffer, 34); // final "
|
|
72
120
|
}
|
|
73
121
|
|
|
74
122
|
if (Porffor.fastOr(
|
|
75
123
|
Porffor.type(value) == Porffor.TYPES.number,
|
|
76
124
|
Porffor.type(value) == Porffor.TYPES.numberobject
|
|
77
125
|
)) { // number
|
|
78
|
-
if (Number.isFinite(value))
|
|
79
|
-
|
|
126
|
+
if (Number.isFinite(value)) {
|
|
127
|
+
return __Porffor_bytestring_bufferStr(buffer, __Number_prototype_toString(value, 10));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return __Porffor_bytestring_bufferStr(buffer, 'null');
|
|
80
131
|
}
|
|
81
132
|
|
|
82
133
|
if (Porffor.type(value) == Porffor.TYPES.array) {
|
|
83
|
-
|
|
84
|
-
Porffor.bytestring.appendChar(out, 91); // [
|
|
134
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 91); // [
|
|
85
135
|
|
|
86
136
|
const hasSpace: boolean = space !== undefined;
|
|
87
137
|
depth += 1;
|
|
88
138
|
|
|
89
139
|
for (const x of (value as any[])) {
|
|
90
140
|
if (hasSpace) {
|
|
91
|
-
|
|
92
|
-
for (let i: i32 = 0; i < depth; i++)
|
|
141
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 10); // \n
|
|
142
|
+
for (let i: i32 = 0; i < depth; i++) buffer = __Porffor_bytestring_bufferStr(buffer, space as bytestring);
|
|
93
143
|
}
|
|
94
144
|
|
|
95
|
-
|
|
145
|
+
if (__Porffor_json_canSerialize(x)) {
|
|
146
|
+
buffer = __Porffor_json_serialize(buffer, x, depth, space);
|
|
147
|
+
} else {
|
|
148
|
+
// non-serializable value, write null
|
|
149
|
+
buffer = __Porffor_bytestring_bufferStr(buffer, 'null');
|
|
150
|
+
}
|
|
96
151
|
|
|
97
|
-
|
|
152
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 44); // ,
|
|
98
153
|
}
|
|
99
154
|
|
|
100
155
|
depth -= 1;
|
|
101
156
|
|
|
102
|
-
// swap trailing , with ] (or append if empty)
|
|
103
|
-
if (
|
|
157
|
+
// swap trailing , with ] (or \n or append if empty)
|
|
158
|
+
if ((buffer - _buffer) > 1) {
|
|
104
159
|
if (hasSpace) {
|
|
105
|
-
Porffor.
|
|
106
|
-
for (let i: i32 = 0; i < depth; i++)
|
|
107
|
-
|
|
108
|
-
} else {
|
|
109
|
-
Porffor.wasm.i32.store8(Porffor.wasm`local.get ${out}` + out.length, 93, 0, 3); // ]
|
|
160
|
+
Porffor.wasm.i32.store8(buffer, 10, 0, 3); // \n
|
|
161
|
+
for (let i: i32 = 0; i < depth; i++) buffer = __Porffor_bytestring_bufferStr(buffer, space as bytestring);
|
|
162
|
+
return __Porffor_bytestring_bufferChar(buffer, 93); // ]
|
|
110
163
|
}
|
|
111
|
-
|
|
112
|
-
Porffor.
|
|
164
|
+
|
|
165
|
+
Porffor.wasm.i32.store8(buffer, 93, 0, 3); // ]
|
|
166
|
+
return buffer;
|
|
113
167
|
}
|
|
114
168
|
|
|
115
|
-
return
|
|
169
|
+
return __Porffor_bytestring_bufferChar(buffer, 93); // ]
|
|
116
170
|
}
|
|
117
171
|
|
|
118
172
|
if (Porffor.type(value) > 0x06) {
|
|
119
173
|
// non-function object
|
|
120
|
-
|
|
121
|
-
Porffor.bytestring.appendChar(out, 123); // {
|
|
174
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 123); // {
|
|
122
175
|
|
|
123
176
|
const hasSpace: boolean = space !== undefined;
|
|
124
177
|
depth += 1;
|
|
125
178
|
|
|
126
|
-
for (const key in (value as object)) {
|
|
179
|
+
for (const key: bytestring in (value as object)) {
|
|
127
180
|
// skip symbol keys
|
|
128
181
|
if (Porffor.type(key) == Porffor.TYPES.symbol) continue;
|
|
129
182
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
183
|
+
const val: any = (value as object)[key];
|
|
184
|
+
if (!__Porffor_json_canSerialize(val)) {
|
|
185
|
+
// skip non-serializable value
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
133
188
|
|
|
134
189
|
if (hasSpace) {
|
|
135
|
-
|
|
136
|
-
for (let i: i32 = 0; i < depth; i++)
|
|
190
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 10); // \n
|
|
191
|
+
for (let i: i32 = 0; i < depth; i++) buffer = __Porffor_bytestring_bufferStr(buffer, space as bytestring);
|
|
137
192
|
}
|
|
138
193
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
Porffor.bytestring.appendChar(out, 58); // :
|
|
144
|
-
if (hasSpace) Porffor.bytestring.appendChar(out, 32); // space
|
|
194
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 34); // "
|
|
195
|
+
buffer = __Porffor_bytestring_bufferStr(buffer, key);
|
|
196
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 34); // "
|
|
145
197
|
|
|
146
|
-
|
|
198
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 58); // :
|
|
199
|
+
if (hasSpace) buffer = __Porffor_bytestring_bufferChar(buffer, 32); // space
|
|
147
200
|
|
|
148
|
-
|
|
201
|
+
buffer = __Porffor_json_serialize(buffer, val, depth, space);
|
|
202
|
+
buffer = __Porffor_bytestring_bufferChar(buffer, 44); // ,
|
|
149
203
|
}
|
|
150
204
|
|
|
151
205
|
depth -= 1;
|
|
152
206
|
|
|
153
|
-
// swap trailing , with } (or append if empty)
|
|
154
|
-
if (
|
|
207
|
+
// swap trailing , with } (or \n or append if empty)
|
|
208
|
+
if ((buffer - _buffer) > 1) {
|
|
155
209
|
if (hasSpace) {
|
|
156
|
-
Porffor.
|
|
157
|
-
for (let i: i32 = 0; i < depth; i++)
|
|
158
|
-
|
|
159
|
-
} else {
|
|
160
|
-
Porffor.wasm.i32.store8(Porffor.wasm`local.get ${out}` + out.length, 125, 0, 3); // }
|
|
210
|
+
Porffor.wasm.i32.store8(buffer, 10, 0, 3); // \n
|
|
211
|
+
for (let i: i32 = 0; i < depth; i++) buffer = __Porffor_bytestring_bufferStr(buffer, space as bytestring);
|
|
212
|
+
return __Porffor_bytestring_bufferChar(buffer, 125); // }
|
|
161
213
|
}
|
|
162
|
-
|
|
163
|
-
Porffor.
|
|
214
|
+
|
|
215
|
+
Porffor.wasm.i32.store8(buffer, 125, 0, 3); // }
|
|
216
|
+
return buffer;
|
|
164
217
|
}
|
|
165
218
|
|
|
166
|
-
return
|
|
219
|
+
return __Porffor_bytestring_bufferChar(buffer, 125); // }
|
|
167
220
|
}
|
|
168
221
|
|
|
169
222
|
if (Porffor.type(value) == 0x04) {
|
|
@@ -171,7 +224,7 @@ export const __Porffor_json_serialize = (value: any, depth: i32, space: bytestri
|
|
|
171
224
|
throw new TypeError('Cannot serialize BigInts');
|
|
172
225
|
}
|
|
173
226
|
|
|
174
|
-
return
|
|
227
|
+
return -1;
|
|
175
228
|
};
|
|
176
229
|
|
|
177
230
|
export const __JSON_stringify = (value: any, replacer: any, space: any) => {
|
|
@@ -187,7 +240,7 @@ export const __JSON_stringify = (value: any, replacer: any, space: any) => {
|
|
|
187
240
|
if (space < 1) {
|
|
188
241
|
space = undefined;
|
|
189
242
|
} else {
|
|
190
|
-
const spaceStr: bytestring = Porffor.
|
|
243
|
+
const spaceStr: bytestring = Porffor.allocateBytes(4 + space);
|
|
191
244
|
for (let i: i32 = 0; i < space; i++) Porffor.bytestring.appendChar(spaceStr, 32);
|
|
192
245
|
|
|
193
246
|
space = spaceStr;
|
|
@@ -209,7 +262,12 @@ export const __JSON_stringify = (value: any, replacer: any, space: any) => {
|
|
|
209
262
|
}
|
|
210
263
|
}
|
|
211
264
|
|
|
212
|
-
|
|
265
|
+
const buffer: bytestring = Porffor.allocate();
|
|
266
|
+
const out = __Porffor_json_serialize(buffer, value, 0, space);
|
|
267
|
+
if (out == -1) return undefined;
|
|
268
|
+
|
|
269
|
+
buffer.length = out - (buffer as i32);
|
|
270
|
+
return buffer;
|
|
213
271
|
};
|
|
214
272
|
|
|
215
273
|
|
package/compiler/builtins.js
CHANGED
|
@@ -1411,6 +1411,178 @@ export const BuiltinFuncs = () => {
|
|
|
1411
1411
|
]
|
|
1412
1412
|
};
|
|
1413
1413
|
|
|
1414
|
+
_.__Porffor_memorySize = {
|
|
1415
|
+
params: [],
|
|
1416
|
+
returns: [ Valtype.i32 ],
|
|
1417
|
+
returnType: TYPES.number,
|
|
1418
|
+
wasm: () => [
|
|
1419
|
+
[ Opcodes.memory_size, 0 ],
|
|
1420
|
+
number(PageSize, Valtype.i32),
|
|
1421
|
+
[ Opcodes.i32_mul ]
|
|
1422
|
+
]
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
// allow non-comptime redefinition later in precompiled
|
|
1426
|
+
const comptime = (name, returnType, comptime) => {
|
|
1427
|
+
let v = {
|
|
1428
|
+
returnType,
|
|
1429
|
+
comptime,
|
|
1430
|
+
params: [],
|
|
1431
|
+
locals: [],
|
|
1432
|
+
returns: []
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
Object.defineProperty(_, name, {
|
|
1436
|
+
get() {
|
|
1437
|
+
return v;
|
|
1438
|
+
},
|
|
1439
|
+
set(x) {
|
|
1440
|
+
// v = { ...x, comptime, returnType };
|
|
1441
|
+
x.comptime = comptime;
|
|
1442
|
+
x.returnType = returnType;
|
|
1443
|
+
v = x;
|
|
1444
|
+
}
|
|
1445
|
+
});
|
|
1446
|
+
};
|
|
1447
|
+
|
|
1448
|
+
comptime('__Array_of', TYPES.array, (scope, decl, { generate }) => generate(scope, {
|
|
1449
|
+
type: 'ArrayExpression',
|
|
1450
|
+
elements: decl.arguments
|
|
1451
|
+
}));
|
|
1452
|
+
|
|
1453
|
+
comptime('__Porffor_fastOr', TYPES.boolean, (scope, decl, { generate }) => {
|
|
1454
|
+
const out = [];
|
|
1455
|
+
|
|
1456
|
+
for (let i = 0; i < decl.arguments.length; i++) {
|
|
1457
|
+
out.push(
|
|
1458
|
+
...generate(scope, decl.arguments[i]),
|
|
1459
|
+
Opcodes.i32_to_u,
|
|
1460
|
+
...(i > 0 ? [ [ Opcodes.i32_or ] ] : [])
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
out.push(Opcodes.i32_from_u);
|
|
1465
|
+
return out;
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
comptime('__Porffor_fastAnd', TYPES.boolean, (scope, decl, { generate }) => {
|
|
1469
|
+
const out = [];
|
|
1470
|
+
|
|
1471
|
+
for (let i = 0; i < decl.arguments.length; i++) {
|
|
1472
|
+
out.push(
|
|
1473
|
+
...generate(scope, decl.arguments[i]),
|
|
1474
|
+
Opcodes.i32_to_u,
|
|
1475
|
+
...(i > 0 ? [ [ Opcodes.i32_and ] ] : [])
|
|
1476
|
+
);
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
out.push(Opcodes.i32_from_u);
|
|
1480
|
+
return out;
|
|
1481
|
+
});
|
|
1482
|
+
|
|
1483
|
+
comptime('__Math_max', TYPES.number, (scope, decl, { generate }) => {
|
|
1484
|
+
const out = [
|
|
1485
|
+
number(-Infinity)
|
|
1486
|
+
];
|
|
1487
|
+
|
|
1488
|
+
for (let i = 0; i < decl.arguments.length; i++) {
|
|
1489
|
+
out.push(
|
|
1490
|
+
...generate(scope, decl.arguments[i]),
|
|
1491
|
+
[ Opcodes.f64_max ]
|
|
1492
|
+
);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
return out;
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
comptime('__Math_min', TYPES.number, (scope, decl, { generate }) => {
|
|
1499
|
+
const out = [
|
|
1500
|
+
number(Infinity)
|
|
1501
|
+
];
|
|
1502
|
+
|
|
1503
|
+
for (let i = 0; i < decl.arguments.length; i++) {
|
|
1504
|
+
out.push(
|
|
1505
|
+
...generate(scope, decl.arguments[i]),
|
|
1506
|
+
[ Opcodes.f64_min ]
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1510
|
+
return out;
|
|
1511
|
+
});
|
|
1512
|
+
|
|
1513
|
+
comptime('__Porffor_printStatic', TYPES.undefined, (scope, decl, { printStaticStr }) => {
|
|
1514
|
+
const str = decl.arguments[0].value;
|
|
1515
|
+
const out = printStaticStr(scope, str);
|
|
1516
|
+
out.push(number(UNDEFINED));
|
|
1517
|
+
return out;
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1520
|
+
comptime('__Porffor_type', TYPES.number, (scope, decl, { getNodeType }) => [
|
|
1521
|
+
...getNodeType(scope, decl.arguments[0]),
|
|
1522
|
+
Opcodes.i32_from_u
|
|
1523
|
+
]);
|
|
1524
|
+
|
|
1525
|
+
comptime('__Porffor_compileType', TYPES.bytestring, (scope, decl, { makeString, knownType }) =>
|
|
1526
|
+
makeString(scope, TYPE_NAMES[knownType(scope, getNodeType(scope, decl.arguments[0]))] ?? 'unknown')
|
|
1527
|
+
);
|
|
1528
|
+
|
|
1529
|
+
// Porffor.call(func, argArray, this, newTarget)
|
|
1530
|
+
comptime('__Porffor_call', undefined, (scope, decl, { generate, getNodeType }) => generate(scope, {
|
|
1531
|
+
type: 'CallExpression',
|
|
1532
|
+
callee: decl.arguments[0],
|
|
1533
|
+
arguments: [ {
|
|
1534
|
+
type: 'SpreadElement',
|
|
1535
|
+
argument: decl.arguments[1],
|
|
1536
|
+
} ],
|
|
1537
|
+
_thisWasm: decl.arguments[2].value === null ? null : [
|
|
1538
|
+
...generate(scope, decl.arguments[2]),
|
|
1539
|
+
...getNodeType(scope, decl.arguments[2])
|
|
1540
|
+
],
|
|
1541
|
+
_newTargetWasm: decl.arguments[3].value === null ? null : [
|
|
1542
|
+
...generate(scope, decl.arguments[3]),
|
|
1543
|
+
...getNodeType(scope, decl.arguments[3])
|
|
1544
|
+
],
|
|
1545
|
+
_new: decl.arguments[3].value !== null,
|
|
1546
|
+
_forceCreateThis: true
|
|
1547
|
+
}));
|
|
1548
|
+
|
|
1549
|
+
// compile-time aware console.log to optimize fast paths
|
|
1550
|
+
// todo: this breaks console.group, etc - disable this if those are used but edge case for now
|
|
1551
|
+
comptime('__console_log', TYPES.undefined, (scope, decl, { generate, getNodeType, knownTypeWithGuess, printStaticStr }) => {
|
|
1552
|
+
const slow = () => {
|
|
1553
|
+
decl._noComptime = true;
|
|
1554
|
+
return generate(scope, decl);
|
|
1555
|
+
};
|
|
1556
|
+
const fast = name => {
|
|
1557
|
+
return [
|
|
1558
|
+
...(!name ? [ number(UNDEFINED) ] : generate(scope, {
|
|
1559
|
+
...decl,
|
|
1560
|
+
callee: {
|
|
1561
|
+
type: 'Identifier',
|
|
1562
|
+
name
|
|
1563
|
+
}
|
|
1564
|
+
})),
|
|
1565
|
+
...printStaticStr(scope, '\n')
|
|
1566
|
+
];
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
if (decl.arguments.length === 0) return fast();
|
|
1570
|
+
if (decl.arguments.length !== 1) return slow();
|
|
1571
|
+
|
|
1572
|
+
generate(scope, decl.arguments[0]); // generate first to get accurate type
|
|
1573
|
+
const type = knownTypeWithGuess(scope, getNodeType(scope, decl.arguments[0]));
|
|
1574
|
+
|
|
1575
|
+
// if we know the type skip the entire print logic, use type's func directly
|
|
1576
|
+
if (type === TYPES.string || type === TYPES.bytestring) {
|
|
1577
|
+
return fast('__Porffor_printString');
|
|
1578
|
+
} else if (type === TYPES.number) {
|
|
1579
|
+
return fast('print');
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
// one arg, skip most of console to avoid rest arg etc
|
|
1583
|
+
return fast('__Porffor_consolePrint');
|
|
1584
|
+
});
|
|
1585
|
+
|
|
1414
1586
|
PrecompiledBuiltins.BuiltinFuncs(_);
|
|
1415
1587
|
return _;
|
|
1416
1588
|
};
|
|
@@ -1967,16 +1967,37 @@ params:[124,127,124,127],typedParams:1,returns:[124,127],jsLength:1,
|
|
|
1967
1967
|
locals:[124,127],localNames:["vals","vals#type","value","value#type","#async_out_promise","#last_type"],
|
|
1968
1968
|
usesTag:1
|
|
1969
1969
|
}
|
|
1970
|
+
x.__Porffor_bytestring_bufferStr={
|
|
1971
|
+
wasm:()=>eval("[[32,2],[252,3],[40,1,0],[184],[33,4],[32,2],[33,5],[32,0],[34,6],[32,4],[160],[33,7],[3,64],[32,6],[68,4],[160],[32,7],[101],[4,64],[32,6],[252,2],[32,5],[252,2],[40,0,4],[54,0,4],[32,6],[68,4],[160],[33,6],[32,5],[68,4],[160],[33,5],[12,1],[11],[11],[3,64],[32,6],[32,7],[99],[4,64],[32,6],[32,6],[68,1],[160],[33,6],[252,2],[32,5],[32,5],[68,1],[160],[33,5],[252,2],[45,0,4],[58,0,4],[12,1],[11],[11],[32,6],[15]]"),
|
|
1972
|
+
params:[124,127,124,127],typedParams:1,returns:[124],returnType:1,jsLength:2,
|
|
1973
|
+
locals:[124,124,124,124],localNames:["buffer","buffer#type","str","str#type","len","strPtr","ptr","endPtr"]
|
|
1974
|
+
}
|
|
1975
|
+
x.__Porffor_bytestring_bufferChar={
|
|
1976
|
+
wasm:()=>eval("[[32,0],[252,2],[32,2],[252,2],[58,0,4],[32,0],[68,1],[160],[15]]"),
|
|
1977
|
+
params:[124,127,124,127],typedParams:1,returns:[124],returnType:1,jsLength:2,
|
|
1978
|
+
locals:[],localNames:["buffer","buffer#type","char","char#type"]
|
|
1979
|
+
}
|
|
1980
|
+
x.__Porffor_bytestring_buffer2Char={
|
|
1981
|
+
wasm:()=>eval("[[32,0],[252,2],[32,2],[252,2],[58,0,4],[32,0],[68,1],[160],[252,2],[32,4],[252,2],[58,0,4],[32,0],[68,2],[160],[15]]"),
|
|
1982
|
+
params:[124,127,124,127,124,127],typedParams:1,returns:[124],returnType:1,jsLength:3,
|
|
1983
|
+
locals:[],localNames:["buffer","buffer#type","char1","char1#type","char2","char2#type"]
|
|
1984
|
+
}
|
|
1985
|
+
x.__Porffor_json_canSerialize={
|
|
1986
|
+
wasm:(_,{internalThrow})=>eval("[[32,0],[68,0],[97],[32,1],[65,128],[114],[65,7],[65,128],[114],[70],[113],[32,0],[68,1],[97],[32,1],[65,128],[114],[65,2],[65,128],[114],[70],[113],[114],[32,0],[68,0],[97],[32,1],[65,128],[114],[65,2],[65,128],[114],[70],[113],[114],[32,1],[65,128],[114],[183],[68,195],[97],[114],[32,1],[184],[68,33],[97],[114],[32,1],[184],[68,1],[97],[114],[32,1],[184],[68,32],[97],[114],[32,1],[184],[68,72],[97],[114],[32,1],[184],[68,6],[100],[114],[4,64],[68,1],[15],[26],[11],[32,1],[184],[68,4],[97],[4,64],...internalThrow(_,'TypeError',`Cannot serialize BigInts`),[26],[11],[68,0],[15]]"),
|
|
1987
|
+
params:[124,127],typedParams:1,returns:[124],returnType:2,jsLength:1,
|
|
1988
|
+
locals:[],localNames:["value","value#type"],
|
|
1989
|
+
usesTag:1
|
|
1990
|
+
}
|
|
1970
1991
|
x.__Porffor_json_serialize={
|
|
1971
|
-
wasm:(_,{t,makeString,builtin,internalThrow})=>eval("[[32,0],[68,0],[97],[32,1],[65,128],[114],[65,7],[65,128],[114],[70],[113],[4,64],...makeString(_,\"null\",1),[65,195],[15],[26],[11],[32,0],[68,1],[97],[32,1],[65,128],[114],[65,2],[65,128],[114],[70],[113],[4,64],...makeString(_,\"true\",1),[65,195],[15],[26],[11],[32,0],[68,0],[97],[32,1],[65,128],[114],[65,2],[65,128],[114],[70],[113],[4,64],...makeString(_,\"false\",1),[65,195],[15],[26],[11],[32,1],[65,128],[114],[183],[68,195],[97],[32,1],[184],[68,33],[97],[114],[4,64],[16,builtin('__Porffor_allocate')],[183],[34,6],[65,195],[68,34],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,0],[252,3],[40,1,0],[184],[33,7],[68,0],[33,8],[3,64],[32,8],[32,7],[99],[4,64],[2,64],[32,0],[33,10],[32,1],[33,11],[32,1],[33,12],[2,124],...t([33],()=>[[32,12],[65,33],[70],[4,64],[32,10],[32,11],[32,8],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,13],[12,1],[11]]),...t([67],()=>[[32,12],[65,67],[70],[4,64],[32,10],[32,11],[32,8],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,13],[12,1],[11]]),[32,12],[65,195],[70],[4,64],[32,10],[32,11],[32,8],[65,1],[16,builtin('__ByteString_prototype_charCodeAt')],[33,13],[12,1],[11],...internalThrow(_,'TypeError',`'charCodeAt' proto func tried to be called on a type without an impl`),[68,0],[11],[34,9],[68,32],[99],[4,64],[32,9],[68,8],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,98],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,2],[26],[11],[32,9],[68,9],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,116],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,2],[26],[11],[32,9],[68,10],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,110],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,2],[26],[11],[32,9],[68,12],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,102],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,2],[26],[11],[32,9],[68,13],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,114],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,2],[26],[11],[32,6],[65,195],[68,92],[65,1],[68,117],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[32,6],[65,195],[68,48],[65,1],[68,48],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[32,9],[252,2],[65,240],[113],[183],[68,16],[163],[33,14],[32,9],[252,2],[65,15],[113],[183],[33,15],[32,6],[65,195],[32,14],[68,10],[99],[4,124],[32,14],[68,48],[160],[65,1],[33,13],[5],[32,14],[68,55],[160],[65,1],[33,13],[11],[32,13],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,6],[65,195],[32,15],[68,10],[99],[4,124],[32,15],[68,48],[160],[65,1],[33,13],[5],[32,15],[68,55],[160],[65,1],[33,13],[11],[32,13],[16,builtin('__Porffor_bytestring_appendChar')],[26],[12,1],[26],[11],[32,9],[68,34],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,34],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,1],[26],[11],[32,9],[68,92],[97],[4,64],[32,6],[65,195],[68,92],[65,1],[68,92],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[26],[12,1],[26],[11],[32,6],[65,195],[32,9],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[11],[32,8],[68,1],[160],[33,8],[12,1],[11],[11],[32,6],[65,195],[68,34],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,6],[65,195],[15],[26],[11],[32,1],[184],[68,1],[97],[32,1],[184],[68,32],[97],[114],[4,64],[32,0],[16,builtin('__Number_isFinite')],[252,3],[4,64],[32,0],[32,1],[68,0],[65,195],[16,builtin('__Porffor_concatStrings')],[34,13],[15],[26],[11],...makeString(_,\"null\",1),[65,195],[15],[26],[11],[32,1],[184],[68,72],[97],[4,64],[16,builtin('__Porffor_allocate')],[183],[34,6],[65,195],[68,91],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,4],[68,0],[98],[32,5],[65,128],[114],[65,0],[65,128],[114],[71],[114],[184],[33,16],[32,2],[68,1],[160],[33,2],[32,0],[252,3],[33,17],[65,72],[33,20],[65,0],[33,19],[32,20],[65,72],[70],[32,20],[65,11],[70],[114],[32,20],[65,12],[70],[114],[32,20],[65,67],[70],[114],[32,20],[65,195],[70],[114],[32,20],[65,34],[70],[114],[32,20],[65,80],[78],[32,20],[65,90],[76],[113],[114],[69],[4,64],...internalThrow(_,'TypeError',`Tried for..of on non-iterable type`),[11],[32,17],[40,1,0],[33,18],[3,64],[2,64],[32,20],[33,12],[2,124],[32,12],[65,72],[70],[32,12],[65,11],[70],[114],[4,64],[32,18],[69],[13,2],[32,17],[43,0,4],[32,17],[45,0,12],[32,17],[65,9],[106],[33,17],[32,18],[65,1],[107],[33,18],[33,13],[12,1],[11],...t([67],()=>[[32,12],[65,67],[70],[4,64],[32,18],[69],[13,2],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,23],[65,1],[54,0,0],[32,23],[32,17],[47,1,4],[59,1,4],[32,17],[65,2],[106],[33,17],[32,18],[65,1],[107],[33,18],[32,23],[184],[65,67],[33,13],[12,1],[11]]),[32,12],[65,195],[70],[4,64],[32,18],[69],[13,2],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,23],[65,1],[54,0,0],[32,23],[32,17],[45,0,4],[58,0,4],[32,17],[65,1],[106],[33,17],[32,18],[65,1],[107],[33,18],[32,23],[184],[65,195],[33,13],[12,1],[11],...t([81,80],()=>[[32,12],[65,81],[70],[32,12],[65,80],[70],[114],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[106],[45,0,4],[184],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([82],()=>[[32,12],[65,82],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[106],[44,0,4],[183],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([83],()=>[[32,12],[65,83],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,2],[108],[106],[47,0,4],[184],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([84],()=>[[32,12],[65,84],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,2],[108],[106],[47,0,4],[184],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([85],()=>[[32,12],[65,85],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,4],[108],[106],[40,0,4],[184],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([86],()=>[[32,12],[65,86],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,4],[108],[106],[40,0,4],[183],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([89],()=>[[32,12],[65,89],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,4],[108],[106],[42,0,4],[187],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([90],()=>[[32,12],[65,90],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,8],[108],[106],[43,0,4],[32,19],[65,1],[106],[33,19],[65,1],[33,13],[12,1],[11]]),...t([88],()=>[[32,12],[65,88],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,8],[108],[106],[41,0,4],[16,builtin('__Porffor_bigint_fromS64')],[32,19],[65,1],[106],[33,19],[65,4],[33,13],[12,1],[11]]),...t([87],()=>[[32,12],[65,87],[70],[4,64],[32,19],[32,18],[70],[13,2],[32,17],[40,0,4],[32,19],[65,8],[108],[106],[41,0,4],[16,builtin('__Porffor_bigint_fromU64')],[32,19],[65,1],[106],[33,19],[65,4],[33,13],[12,1],[11]]),...t([34],()=>[[32,12],[65,34],[70],[4,64],[12,2],[12,1],[11]]),...t([12],()=>[[32,12],[65,12],[70],[4,64],[32,19],[32,18],[40,1,0],[70],[13,2],[65,128],[16,builtin('__Porffor_allocateBytes')],[34,23],[65,2],[54,0,0],[32,23],[32,23],[32,23],[32,23],[32,18],[32,19],[65,9],[108],[106],[34,24],[43,0,4],[57,0,4],[32,24],[45,0,12],[58,0,12],[32,17],[40,1,4],[32,19],[65,9],[108],[106],[34,24],[43,0,4],[57,0,13],[32,24],[45,0,12],[58,0,21],[32,19],[65,1],[106],[33,19],[32,23],[184],[65,72],[33,13],[12,1],[11]]),[0],[11],[33,21],[32,13],[33,22],[32,16],[252,3],[4,64],[32,6],[65,195],[68,10],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[68,0],[33,8],[3,64],[32,8],[32,2],[99],[4,64],[32,6],[65,195],[32,4],[65,195],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,8],[68,1],[160],[33,8],[12,1],[11],[11],[11],[32,6],[65,195],[32,21],[32,22],[32,2],[65,1],[32,4],[32,5],[16,builtin('__Porffor_json_serialize')],[33,13],[34,25],[33,26],[32,13],[33,12],[2,127],[32,12],[65,0],[70],[4,64],[65,1],[12,1],[11],[32,12],[65,7],[70],[4,64],[32,26],[68,0],[97],[12,1],[11],[65,0],[11],[4,124],...makeString(_,\"null\",1),[65,195],[33,13],[5],[32,25],[32,13],[33,13],[11],[32,13],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,6],[65,195],[68,44],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[12,1],[11],[11],[32,2],[68,1],[161],[33,2],[32,6],[252,3],[40,1,0],[184],[68,1],[100],[4,64],[32,16],[252,3],[4,64],[32,6],[65,195],[68,10],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[68,0],[33,8],[3,64],[32,8],[32,2],[99],[4,64],[32,6],[65,195],[32,4],[65,195],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,8],[68,1],[160],[33,8],[12,1],[11],[11],[32,6],[65,195],[68,93],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[5],[32,6],[32,6],[252,3],[40,1,0],[184],[160],[252,2],[65,93],[58,0,3],[11],[5],[32,6],[65,195],[68,93],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[11],[32,6],[65,195],[15],[26],[11],[32,1],[184],[68,6],[100],[4,64],[16,builtin('__Porffor_allocate')],[183],[34,6],[65,195],[68,123],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,4],[68,0],[98],[32,5],[65,128],[114],[65,0],[65,128],[114],[71],[114],[184],[33,16],[32,2],[68,1],[160],[33,2],[32,0],[252,3],[33,27],[65,0],[33,29],[32,27],[47,0,0],[34,28],[4,64],[3,64],[32,27],[40,0,12],[34,30],[65,31],[118],[4,127],[32,30],[65,1073741823],[113],[33,30],[65,67],[65,5],[32,30],[65,1073741824],[113],[27],[5],[65,195],[11],[33,31],[32,30],[184],[33,32],[32,31],[33,33],[2,64],[32,27],[45,0,24],[65,4],[113],[4,64],[32,33],[184],[68,5],[97],[4,64],[12,1],[26],[11],[32,32],[33,37],[32,0],[34,36],[252,2],[65,7],[32,37],[32,33],[16,builtin('__ecma262_ToPropertyKey')],[33,38],[252,2],[32,38],[16,builtin('__Porffor_object_get')],[34,13],[32,2],[65,1],[32,4],[32,5],[16,builtin('__Porffor_json_serialize')],[34,13],[33,35],[34,34],[33,26],[32,35],[33,12],[2,127],[32,12],[65,0],[70],[4,64],[65,1],[12,1],[11],[32,12],[65,7],[70],[4,64],[32,26],[68,0],[97],[12,1],[11],[65,0],[11],[4,64],[12,1],[26],[11],[32,16],[252,3],[4,64],[32,6],[65,195],[68,10],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[68,0],[33,8],[3,64],[32,8],[32,2],[99],[4,64],[32,6],[65,195],[32,4],[65,195],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,8],[68,1],[160],[33,8],[12,1],[11],[11],[11],[32,6],[65,195],[68,34],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,6],[65,195],[32,32],[32,33],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,6],[65,195],[68,34],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,6],[65,195],[68,58],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,16],[252,3],[4,64],[32,6],[65,195],[68,32],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[11],[32,6],[65,195],[32,34],[32,35],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,6],[65,195],[68,44],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[11],[32,27],[65,18],[106],[33,27],[32,29],[65,1],[106],[34,29],[32,28],[71],[13,1],[11],[11],[11],[32,2],[68,1],[161],[33,2],[32,6],[252,3],[40,1,0],[184],[68,1],[100],[4,64],[32,16],[252,3],[4,64],[32,6],[65,195],[68,10],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[68,0],[33,8],[3,64],[32,8],[32,2],[99],[4,64],[32,6],[65,195],[32,4],[65,195],[16,builtin('__Porffor_bytestring_appendStr')],[26],[32,8],[68,1],[160],[33,8],[12,1],[11],[11],[32,6],[65,195],[68,125],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[5],[32,6],[32,6],[252,3],[40,1,0],[184],[160],[252,2],[65,125],[58,0,3],[11],[5],[32,6],[65,195],[68,125],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[11],[32,6],[65,195],[15],[26],[11],[32,1],[184],[68,4],[97],[4,64],...internalThrow(_,'TypeError',`Cannot serialize BigInts`),[26],[11],[68,0],[65,0],[15]]"),
|
|
1972
|
-
params:[124,127,124,127,124,127],typedParams:1,returns:[124
|
|
1973
|
-
locals:[124,124,124,124,124,127,127,127,124,124,124,127,127,127,127,124,127,127,127,
|
|
1992
|
+
wasm:(_,{t,makeString,builtin,internalThrow})=>eval("[[32,0],[33,8],[32,2],[68,0],[97],[32,3],[65,128],[114],[65,7],[65,128],[114],[70],[113],[4,64],[32,8],[65,1],...makeString(_,\"null\",1),[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[15],[26],[11],[32,2],[68,1],[97],[32,3],[65,128],[114],[65,2],[65,128],[114],[70],[113],[4,64],[32,8],[65,1],...makeString(_,\"true\",1),[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[15],[26],[11],[32,2],[68,0],[97],[32,3],[65,128],[114],[65,2],[65,128],[114],[70],[113],[4,64],[32,8],[65,1],...makeString(_,\"false\",1),[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[15],[26],[11],[32,3],[65,128],[114],[183],[68,195],[97],[32,3],[184],[68,33],[97],[114],[4,64],[32,8],[65,1],[68,34],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[32,2],[252,3],[40,1,0],[184],[33,9],[68,0],[33,10],[3,64],[32,10],[32,9],[99],[4,64],[2,64],[32,2],[33,12],[32,3],[33,13],[32,3],[33,14],[2,124],...t([33],()=>[[32,14],[65,33],[70],[4,64],[32,12],[32,13],[32,10],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,15],[12,1],[11]]),...t([67],()=>[[32,14],[65,67],[70],[4,64],[32,12],[32,13],[32,10],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,15],[12,1],[11]]),[32,14],[65,195],[70],[4,64],[32,12],[32,13],[32,10],[65,1],[16,builtin('__ByteString_prototype_charCodeAt')],[33,15],[12,1],[11],...internalThrow(_,'TypeError',`'charCodeAt' proto func tried to be called on a type without an impl`),[68,0],[11],[34,11],[68,32],[99],[4,64],[32,11],[68,8],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,98],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,2],[26],[11],[32,11],[68,9],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,116],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,2],[26],[11],[32,11],[68,10],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,110],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,2],[26],[11],[32,11],[68,12],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,102],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,2],[26],[11],[32,11],[68,13],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,114],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,2],[26],[11],[32,8],[65,1],[68,92],[65,1],[68,117],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[34,8],[65,1],[68,48],[65,1],[68,48],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[32,11],[252,2],[65,240],[113],[183],[68,16],[163],[33,16],[32,11],[252,2],[65,15],[113],[183],[33,17],[32,8],[65,1],[32,16],[68,10],[99],[4,124],[32,16],[68,48],[160],[65,1],[33,15],[5],[32,16],[68,55],[160],[65,1],[33,15],[11],[32,15],[32,17],[68,10],[99],[4,124],[32,17],[68,48],[160],[65,1],[33,15],[5],[32,17],[68,55],[160],[65,1],[33,15],[11],[32,15],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,1],[26],[11],[32,11],[68,34],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,34],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,1],[26],[11],[32,11],[68,92],[97],[4,64],[32,8],[65,1],[68,92],[65,1],[68,92],[65,1],[16,builtin('__Porffor_bytestring_buffer2Char')],[33,8],[12,1],[26],[11],[32,8],[65,1],[32,11],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[11],[32,10],[68,1],[160],[33,10],[12,1],[11],[11],[32,8],[65,1],[68,34],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[15],[26],[11],[32,3],[184],[68,1],[97],[32,3],[184],[68,32],[97],[114],[4,64],[32,2],[16,builtin('__Number_isFinite')],[252,3],[4,64],[32,8],[65,1],[32,2],[32,3],[68,10],[65,1],[16,builtin('__Number_prototype_toString')],[34,15],[16,builtin('__Porffor_bytestring_bufferStr')],[15],[26],[11],[32,8],[65,1],...makeString(_,\"null\",1),[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[15],[26],[11],[32,3],[184],[68,72],[97],[4,64],[32,8],[65,1],[68,91],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[32,6],[68,0],[98],[32,7],[65,128],[114],[65,0],[65,128],[114],[71],[114],[184],[33,18],[32,4],[68,1],[160],[33,4],[32,2],[252,3],[33,19],[65,72],[33,22],[65,0],[33,21],[32,22],[65,72],[70],[32,22],[65,11],[70],[114],[32,22],[65,12],[70],[114],[32,22],[65,67],[70],[114],[32,22],[65,195],[70],[114],[32,22],[65,34],[70],[114],[32,22],[65,80],[78],[32,22],[65,90],[76],[113],[114],[69],[4,64],...internalThrow(_,'TypeError',`Tried for..of on non-iterable type`),[11],[32,19],[40,1,0],[33,20],[3,64],[2,64],[32,22],[33,14],[2,124],[32,14],[65,72],[70],[32,14],[65,11],[70],[114],[4,64],[32,20],[69],[13,2],[32,19],[43,0,4],[32,19],[45,0,12],[32,19],[65,9],[106],[33,19],[32,20],[65,1],[107],[33,20],[33,15],[12,1],[11],...t([67],()=>[[32,14],[65,67],[70],[4,64],[32,20],[69],[13,2],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,25],[65,1],[54,0,0],[32,25],[32,19],[47,1,4],[59,1,4],[32,19],[65,2],[106],[33,19],[32,20],[65,1],[107],[33,20],[32,25],[184],[65,67],[33,15],[12,1],[11]]),[32,14],[65,195],[70],[4,64],[32,20],[69],[13,2],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,25],[65,1],[54,0,0],[32,25],[32,19],[45,0,4],[58,0,4],[32,19],[65,1],[106],[33,19],[32,20],[65,1],[107],[33,20],[32,25],[184],[65,195],[33,15],[12,1],[11],...t([81,80],()=>[[32,14],[65,81],[70],[32,14],[65,80],[70],[114],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[106],[45,0,4],[184],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([82],()=>[[32,14],[65,82],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[106],[44,0,4],[183],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([83],()=>[[32,14],[65,83],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,2],[108],[106],[47,0,4],[184],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([84],()=>[[32,14],[65,84],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,2],[108],[106],[47,0,4],[184],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([85],()=>[[32,14],[65,85],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,4],[108],[106],[40,0,4],[184],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([86],()=>[[32,14],[65,86],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,4],[108],[106],[40,0,4],[183],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([89],()=>[[32,14],[65,89],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,4],[108],[106],[42,0,4],[187],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([90],()=>[[32,14],[65,90],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,8],[108],[106],[43,0,4],[32,21],[65,1],[106],[33,21],[65,1],[33,15],[12,1],[11]]),...t([88],()=>[[32,14],[65,88],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,8],[108],[106],[41,0,4],[16,builtin('__Porffor_bigint_fromS64')],[32,21],[65,1],[106],[33,21],[65,4],[33,15],[12,1],[11]]),...t([87],()=>[[32,14],[65,87],[70],[4,64],[32,21],[32,20],[70],[13,2],[32,19],[40,0,4],[32,21],[65,8],[108],[106],[41,0,4],[16,builtin('__Porffor_bigint_fromU64')],[32,21],[65,1],[106],[33,21],[65,4],[33,15],[12,1],[11]]),...t([34],()=>[[32,14],[65,34],[70],[4,64],[12,2],[12,1],[11]]),...t([12],()=>[[32,14],[65,12],[70],[4,64],[32,21],[32,20],[40,1,0],[70],[13,2],[65,128],[16,builtin('__Porffor_allocateBytes')],[34,25],[65,2],[54,0,0],[32,25],[32,25],[32,25],[32,25],[32,20],[32,21],[65,9],[108],[106],[34,26],[43,0,4],[57,0,4],[32,26],[45,0,12],[58,0,12],[32,19],[40,1,4],[32,21],[65,9],[108],[106],[34,26],[43,0,4],[57,0,13],[32,26],[45,0,12],[58,0,21],[32,21],[65,1],[106],[33,21],[32,25],[184],[65,72],[33,15],[12,1],[11]]),[0],[11],[33,23],[32,15],[33,24],[32,18],[252,3],[4,64],[32,8],[65,1],[68,10],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[68,0],[33,10],[3,64],[32,10],[32,4],[99],[4,64],[32,8],[65,1],[32,6],[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[33,8],[32,10],[68,1],[160],[33,10],[12,1],[11],[11],[11],[32,23],[32,24],[16,builtin('__Porffor_json_canSerialize')],[252,3],[4,64],[32,8],[65,1],[32,23],[32,24],[32,4],[65,1],[32,6],[32,7],[16,builtin('__Porffor_json_serialize')],[33,8],[5],[32,8],[65,1],...makeString(_,\"null\",1),[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[33,8],[11],[32,8],[65,1],[68,44],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[12,1],[11],[11],[32,4],[68,1],[161],[33,4],[32,8],[32,0],[161],[68,1],[100],[4,64],[32,18],[252,3],[4,64],[32,8],[252,2],[65,10],[58,0,3],[68,0],[33,10],[3,64],[32,10],[32,4],[99],[4,64],[32,8],[65,1],[32,6],[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[33,8],[32,10],[68,1],[160],[33,10],[12,1],[11],[11],[32,8],[65,1],[68,93],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[15],[26],[11],[32,8],[252,2],[65,93],[58,0,3],[32,8],[15],[26],[11],[32,8],[65,1],[68,93],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[15],[26],[11],[32,3],[184],[68,6],[100],[4,64],[32,8],[65,1],[68,123],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[32,6],[68,0],[98],[32,7],[65,128],[114],[65,0],[65,128],[114],[71],[114],[184],[33,18],[32,4],[68,1],[160],[33,4],[32,2],[252,3],[33,27],[65,0],[33,29],[32,27],[47,0,0],[34,28],[4,64],[3,64],[32,27],[40,0,12],[34,30],[65,31],[118],[4,127],[32,30],[65,1073741823],[113],[33,30],[65,67],[65,5],[32,30],[65,1073741824],[113],[27],[5],[65,195],[11],[33,31],[32,30],[184],[33,32],[2,64],[32,27],[45,0,24],[65,4],[113],[4,64],[68,195],[68,5],[97],[4,64],[12,1],[26],[11],[32,32],[33,36],[32,2],[34,35],[252,2],[65,7],[32,36],[65,195],[16,builtin('__ecma262_ToPropertyKey')],[33,37],[252,2],[32,37],[16,builtin('__Porffor_object_get')],[34,15],[33,34],[34,33],[32,34],[16,builtin('__Porffor_json_canSerialize')],[68,0],[97],[4,64],[12,1],[26],[11],[32,18],[252,3],[4,64],[32,8],[65,1],[68,10],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[68,0],[33,10],[3,64],[32,10],[32,4],[99],[4,64],[32,8],[65,1],[32,6],[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[33,8],[32,10],[68,1],[160],[33,10],[12,1],[11],[11],[11],[32,8],[65,1],[68,34],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[34,8],[65,1],[32,32],[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[34,8],[65,1],[68,34],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[34,8],[65,1],[68,58],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[32,18],[252,3],[4,64],[32,8],[65,1],[68,32],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[11],[32,8],[65,1],[32,33],[32,34],[32,4],[65,1],[32,6],[32,7],[16,builtin('__Porffor_json_serialize')],[34,8],[65,1],[68,44],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[33,8],[11],[32,27],[65,18],[106],[33,27],[32,29],[65,1],[106],[34,29],[32,28],[71],[13,1],[11],[11],[11],[32,4],[68,1],[161],[33,4],[32,8],[32,0],[161],[68,1],[100],[4,64],[32,18],[252,3],[4,64],[32,8],[252,2],[65,10],[58,0,3],[68,0],[33,10],[3,64],[32,10],[32,4],[99],[4,64],[32,8],[65,1],[32,6],[65,195],[16,builtin('__Porffor_bytestring_bufferStr')],[33,8],[32,10],[68,1],[160],[33,10],[12,1],[11],[11],[32,8],[65,1],[68,125],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[15],[26],[11],[32,8],[252,2],[65,125],[58,0,3],[32,8],[15],[26],[11],[32,8],[65,1],[68,125],[65,1],[16,builtin('__Porffor_bytestring_bufferChar')],[15],[26],[11],[32,3],[184],[68,4],[97],[4,64],...internalThrow(_,'TypeError',`Cannot serialize BigInts`),[26],[11],[68,-1],[15]]"),
|
|
1993
|
+
params:[124,127,124,127,124,127,124,127],typedParams:1,returns:[124],returnType:1,jsLength:4,
|
|
1994
|
+
locals:[124,124,124,124,124,127,127,127,124,124,124,127,127,127,127,124,127,127,127,127,127,127,127,127,124,124,127,124,124,127],localNames:["_buffer","_buffer#type","value","value#type","depth","depth#type","space","space#type","buffer","len","i","c","#proto_target","#proto_target#type","#typeswitch_tmp1","#last_type","h1","h2","hasSpace","#forof_base_pointer0","#forof_length0","#forof_counter0","#forof_itertype0","x","x#type","#forof_allocd","#forof_mapptr","#forin_base_pointer0","#forin_length0","#forin_counter0","#forin_tmp0","#forin_tmp0#type","key","val","val#type","#member_obj_172","#member_prop_172","#swap"],
|
|
1974
1995
|
usesTag:1
|
|
1975
1996
|
}
|
|
1976
1997
|
x.__JSON_stringify={
|
|
1977
|
-
wasm:(_,{t,builtin,internalThrow})=>eval("[[32,4],[68,0],[98],[32,5],[65,128],[114],[65,0],[65,128],[114],[71],[114],[4,64],[32,5],[184],[68,1],[97],[32,5],[184],[68,32],[97],[114],[4,64],[68,\"Infinity\"],[32,4],[16,builtin('__Math_trunc')],[164],[68,10],[164],[33,4],[65,1],[33,5],[32,4],[68,1],[99],[4,64],[68,0],[33,4],[65,0],[33,5],[5],[16,builtin('
|
|
1998
|
+
wasm:(_,{t,builtin,internalThrow})=>eval("[[32,4],[68,0],[98],[32,5],[65,128],[114],[65,0],[65,128],[114],[71],[114],[4,64],[32,5],[184],[68,1],[97],[32,5],[184],[68,32],[97],[114],[4,64],[68,\"Infinity\"],[32,4],[16,builtin('__Math_trunc')],[164],[68,10],[164],[33,4],[65,1],[33,5],[32,4],[68,1],[99],[4,64],[68,0],[33,4],[65,0],[33,5],[5],[68,4],[32,4],[160],[252,2],[16,builtin('__Porffor_allocateBytes')],[183],[33,6],[68,0],[33,7],[3,64],[32,7],[32,4],[99],[4,64],[32,6],[65,195],[68,32],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[26],[32,7],[68,1],[160],[33,7],[12,1],[11],[11],[32,6],[33,4],[65,195],[33,5],[11],[5],[32,5],[65,128],[114],[183],[68,195],[97],[32,5],[184],[68,33],[97],[114],[4,64],[32,4],[252,3],[40,1,0],[184],[34,8],[68,0],[97],[4,64],[68,0],[33,4],[65,0],[33,5],[5],[32,8],[68,10],[100],[4,64],[32,4],[33,9],[32,5],[33,10],[32,5],[33,11],[2,124],...t([13],()=>[[32,11],[65,13],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__ArrayBuffer_prototype_slice')],[33,12],[12,1],[11]]),...t([14],()=>[[32,11],[65,14],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__SharedArrayBuffer_prototype_slice')],[33,12],[12,1],[11]]),...t([33],()=>[[32,11],[65,33],[70],[4,64],[32,9],[252,2],[32,10],[65,0],[65,1],[65,10],[65,1],[16,builtin('__String_prototype_slice')],[33,12],[183],[12,1],[11]]),...t([67],()=>[[32,11],[65,67],[70],[4,64],[32,9],[252,2],[32,10],[65,0],[65,1],[65,10],[65,1],[16,builtin('__String_prototype_slice')],[33,12],[183],[12,1],[11]]),...t([72],()=>[[32,11],[65,72],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Array_prototype_slice')],[33,12],[12,1],[11]]),...t([80],()=>[[32,11],[65,80],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Uint8ClampedArray_prototype_slice')],[33,12],[12,1],[11]]),...t([81],()=>[[32,11],[65,81],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Uint8Array_prototype_slice')],[33,12],[12,1],[11]]),...t([82],()=>[[32,11],[65,82],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Int8Array_prototype_slice')],[33,12],[12,1],[11]]),...t([83],()=>[[32,11],[65,83],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Uint16Array_prototype_slice')],[33,12],[12,1],[11]]),...t([84],()=>[[32,11],[65,84],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Int16Array_prototype_slice')],[33,12],[12,1],[11]]),...t([85],()=>[[32,11],[65,85],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Uint32Array_prototype_slice')],[33,12],[12,1],[11]]),...t([86],()=>[[32,11],[65,86],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Int32Array_prototype_slice')],[33,12],[12,1],[11]]),...t([87],()=>[[32,11],[65,87],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__BigUint64Array_prototype_slice')],[33,12],[12,1],[11]]),...t([88],()=>[[32,11],[65,88],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__BigInt64Array_prototype_slice')],[33,12],[12,1],[11]]),...t([89],()=>[[32,11],[65,89],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Float32Array_prototype_slice')],[33,12],[12,1],[11]]),...t([90],()=>[[32,11],[65,90],[70],[4,64],[32,9],[32,10],[68,0],[65,1],[68,10],[65,1],[16,builtin('__Float64Array_prototype_slice')],[33,12],[12,1],[11]]),[32,11],[65,195],[70],[4,64],[32,9],[252,2],[32,10],[65,0],[65,1],[65,10],[65,1],[16,builtin('__ByteString_prototype_slice')],[33,12],[183],[12,1],[11],...internalThrow(_,'TypeError',`'slice' proto func tried to be called on a type without an impl`),[68,0],[11],[33,4],[32,12],[33,5],[11],[11],[5],[68,0],[33,4],[65,0],[33,5],[11],[11],[11],[16,builtin('__Porffor_allocate')],[183],[34,13],[65,195],[32,0],[32,1],[68,0],[65,1],[32,4],[32,5],[16,builtin('__Porffor_json_serialize')],[33,14],[65,1],[33,15],[32,14],[68,-1],[97],[4,64],[68,0],[65,0],[15],[26],[11],[32,13],[252,3],[32,14],[32,13],[161],[252,3],[54,1,0],[32,13],[65,195],[15]]"),
|
|
1978
1999
|
params:[124,127,124,127,124,127],typedParams:1,returns:[124,127],jsLength:3,
|
|
1979
|
-
locals:[124,124,124,124,127,127,127],localNames:["value","value#type","replacer","replacer#type","space","space#type","spaceStr","i","len","#proto_target","#proto_target#type","#typeswitch_tmp1","#last_type"],
|
|
2000
|
+
locals:[124,124,124,124,127,127,127,124,124,127],localNames:["value","value#type","replacer","replacer#type","space","space#type","spaceStr","i","len","#proto_target","#proto_target#type","#typeswitch_tmp1","#last_type","buffer","out","out#type"],
|
|
1980
2001
|
usesTag:1
|
|
1981
2002
|
}
|
|
1982
2003
|
x.__JSON_parse={
|
package/compiler/codegen.js
CHANGED
|
@@ -79,7 +79,7 @@ const isFuncType = type =>
|
|
|
79
79
|
type === 'FunctionDeclaration' || type === 'FunctionExpression' || type === 'ArrowFunctionExpression' ||
|
|
80
80
|
type === 'ClassDeclaration' || type === 'ClassExpression';
|
|
81
81
|
const hasFuncWithName = name =>
|
|
82
|
-
name in funcIndex || name in builtinFuncs || name in importedFuncs
|
|
82
|
+
name in funcIndex || name in builtinFuncs || name in importedFuncs;
|
|
83
83
|
|
|
84
84
|
const astCache = new WeakMap();
|
|
85
85
|
const cacheAst = (decl, wasm) => {
|
|
@@ -614,9 +614,6 @@ const lookup = (scope, name, failEarly = false) => {
|
|
|
614
614
|
|
|
615
615
|
if (name in builtinFuncs) {
|
|
616
616
|
if (!(name in funcIndex)) includeBuiltin(scope, name);
|
|
617
|
-
} else if (name in internalConstrs) {
|
|
618
|
-
// todo: return an actual something
|
|
619
|
-
return [ number(1) ];
|
|
620
617
|
}
|
|
621
618
|
|
|
622
619
|
if (local?.idx === undefined) {
|
|
@@ -1528,8 +1525,8 @@ const asmFunc = (name, func) => {
|
|
|
1528
1525
|
func = { ...func };
|
|
1529
1526
|
let { wasm, params = [], locals: localTypes = [], localNames = [], table, usesTag, returnTypes, returnType } = func;
|
|
1530
1527
|
if (wasm == null) { // called with no built-in
|
|
1531
|
-
log.warning('codegen', `${name} has no built-in!`);
|
|
1532
|
-
wasm = [];
|
|
1528
|
+
if (!func.comptime) log.warning('codegen', `${name} has no built-in!`);
|
|
1529
|
+
wasm = () => [];
|
|
1533
1530
|
}
|
|
1534
1531
|
|
|
1535
1532
|
const existing = builtinFuncByName(name);
|
|
@@ -1782,7 +1779,6 @@ const getNodeType = (scope, node) => {
|
|
|
1782
1779
|
}
|
|
1783
1780
|
|
|
1784
1781
|
if (name in builtinFuncs && builtinFuncs[name].returnType != null) return builtinFuncs[name].returnType;
|
|
1785
|
-
if (name in internalConstrs && internalConstrs[name].type != null) return internalConstrs[name].type;
|
|
1786
1782
|
|
|
1787
1783
|
if (name.startsWith('__Porffor_wasm_')) {
|
|
1788
1784
|
// todo: return undefined for non-returning ops
|
|
@@ -2449,9 +2445,6 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
|
2449
2445
|
let idx;
|
|
2450
2446
|
if (decl._funcIdx) {
|
|
2451
2447
|
idx = decl._funcIdx;
|
|
2452
|
-
} else if (name in internalConstrs && !decl._noInternalConstr) {
|
|
2453
|
-
if (decl._new && internalConstrs[name].notConstr) return internalThrow(scope, 'TypeError', `${unhackName(name)} is not a constructor`, true);
|
|
2454
|
-
return internalConstrs[name].generate(scope, decl, _global, _name);
|
|
2455
2448
|
} else if (name in funcIndex) {
|
|
2456
2449
|
idx = funcIndex[name];
|
|
2457
2450
|
} else if (scope.name === name) {
|
|
@@ -2462,6 +2455,7 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
|
2462
2455
|
scope.usesImports = true;
|
|
2463
2456
|
} else if (name in builtinFuncs) {
|
|
2464
2457
|
if (decl._new && !builtinFuncs[name].constr) return internalThrow(scope, 'TypeError', `${unhackName(name)} is not a constructor`, true);
|
|
2458
|
+
if (builtinFuncs[name].comptime && !decl._noComptime) return builtinFuncs[name].comptime(scope, decl, { generate, getNodeType, knownTypeWithGuess, makeString, printStaticStr });
|
|
2465
2459
|
|
|
2466
2460
|
includeBuiltin(scope, name);
|
|
2467
2461
|
idx = funcIndex[name];
|
|
@@ -7166,187 +7160,6 @@ const generateBlock = (scope, decl) => {
|
|
|
7166
7160
|
return out;
|
|
7167
7161
|
};
|
|
7168
7162
|
|
|
7169
|
-
const internalConstrs = {
|
|
7170
|
-
__proto__: null,
|
|
7171
|
-
__Array_of: {
|
|
7172
|
-
// this is not a constructor but best fits internal structure here
|
|
7173
|
-
generate: (scope, decl, global, name) => {
|
|
7174
|
-
// Array.of(i0, i1, ...)
|
|
7175
|
-
return generateArray(scope, {
|
|
7176
|
-
elements: decl.arguments
|
|
7177
|
-
}, global, name);
|
|
7178
|
-
},
|
|
7179
|
-
type: TYPES.array,
|
|
7180
|
-
notConstr: true
|
|
7181
|
-
},
|
|
7182
|
-
|
|
7183
|
-
__Porffor_fastOr: {
|
|
7184
|
-
generate: (scope, decl) => {
|
|
7185
|
-
const out = [];
|
|
7186
|
-
|
|
7187
|
-
for (let i = 0; i < decl.arguments.length; i++) {
|
|
7188
|
-
out.push(
|
|
7189
|
-
...generate(scope, decl.arguments[i]),
|
|
7190
|
-
Opcodes.i32_to_u,
|
|
7191
|
-
...(i > 0 ? [ [ Opcodes.i32_or ] ] : [])
|
|
7192
|
-
);
|
|
7193
|
-
}
|
|
7194
|
-
|
|
7195
|
-
out.push(Opcodes.i32_from_u);
|
|
7196
|
-
|
|
7197
|
-
return out;
|
|
7198
|
-
},
|
|
7199
|
-
type: TYPES.boolean,
|
|
7200
|
-
notConstr: true
|
|
7201
|
-
},
|
|
7202
|
-
|
|
7203
|
-
__Porffor_fastAnd: {
|
|
7204
|
-
generate: (scope, decl) => {
|
|
7205
|
-
const out = [];
|
|
7206
|
-
|
|
7207
|
-
for (let i = 0; i < decl.arguments.length; i++) {
|
|
7208
|
-
out.push(
|
|
7209
|
-
...generate(scope, decl.arguments[i]),
|
|
7210
|
-
Opcodes.i32_to_u,
|
|
7211
|
-
...(i > 0 ? [ [ Opcodes.i32_and ] ] : [])
|
|
7212
|
-
);
|
|
7213
|
-
}
|
|
7214
|
-
|
|
7215
|
-
out.push(Opcodes.i32_from_u);
|
|
7216
|
-
|
|
7217
|
-
return out;
|
|
7218
|
-
},
|
|
7219
|
-
type: TYPES.boolean,
|
|
7220
|
-
notConstr: true
|
|
7221
|
-
},
|
|
7222
|
-
|
|
7223
|
-
__Math_max: {
|
|
7224
|
-
generate: (scope, decl) => {
|
|
7225
|
-
const out = [
|
|
7226
|
-
number(-Infinity)
|
|
7227
|
-
];
|
|
7228
|
-
|
|
7229
|
-
for (let i = 0; i < decl.arguments.length; i++) {
|
|
7230
|
-
out.push(
|
|
7231
|
-
...generate(scope, decl.arguments[i]),
|
|
7232
|
-
[ Opcodes.f64_max ]
|
|
7233
|
-
);
|
|
7234
|
-
}
|
|
7235
|
-
|
|
7236
|
-
return out;
|
|
7237
|
-
},
|
|
7238
|
-
type: TYPES.number,
|
|
7239
|
-
notConstr: true
|
|
7240
|
-
},
|
|
7241
|
-
|
|
7242
|
-
__Math_min: {
|
|
7243
|
-
generate: (scope, decl) => {
|
|
7244
|
-
const out = [
|
|
7245
|
-
number(Infinity)
|
|
7246
|
-
];
|
|
7247
|
-
|
|
7248
|
-
for (let i = 0; i < decl.arguments.length; i++) {
|
|
7249
|
-
out.push(
|
|
7250
|
-
...generate(scope, decl.arguments[i]),
|
|
7251
|
-
[ Opcodes.f64_min ]
|
|
7252
|
-
);
|
|
7253
|
-
}
|
|
7254
|
-
|
|
7255
|
-
return out;
|
|
7256
|
-
},
|
|
7257
|
-
type: TYPES.number,
|
|
7258
|
-
notConstr: true
|
|
7259
|
-
},
|
|
7260
|
-
|
|
7261
|
-
__Porffor_printStatic: {
|
|
7262
|
-
generate: (scope, decl) => {
|
|
7263
|
-
const str = decl.arguments[0].value;
|
|
7264
|
-
const out = printStaticStr(scope, str);
|
|
7265
|
-
out.push(number(UNDEFINED));
|
|
7266
|
-
return out;
|
|
7267
|
-
},
|
|
7268
|
-
type: TYPES.undefined,
|
|
7269
|
-
notConstr: true
|
|
7270
|
-
},
|
|
7271
|
-
|
|
7272
|
-
__Porffor_type: {
|
|
7273
|
-
generate: (scope, decl) => [
|
|
7274
|
-
...getNodeType(scope, decl.arguments[0]),
|
|
7275
|
-
Opcodes.i32_from_u
|
|
7276
|
-
],
|
|
7277
|
-
type: TYPES.number,
|
|
7278
|
-
notConstr: true
|
|
7279
|
-
},
|
|
7280
|
-
|
|
7281
|
-
__Porffor_compileType: {
|
|
7282
|
-
generate: (scope, decl) => makeString(scope, TYPE_NAMES[knownType(scope, getNodeType(scope, decl.arguments[0]))] ?? 'unknown'),
|
|
7283
|
-
type: TYPES.bytestring,
|
|
7284
|
-
notConstr: true
|
|
7285
|
-
},
|
|
7286
|
-
|
|
7287
|
-
__Porffor_call: {
|
|
7288
|
-
// Porffor.call(func, argArray, this, newTarget)
|
|
7289
|
-
generate: (scope, decl) => generate(scope, {
|
|
7290
|
-
type: 'CallExpression',
|
|
7291
|
-
callee: decl.arguments[0],
|
|
7292
|
-
arguments: [ {
|
|
7293
|
-
type: 'SpreadElement',
|
|
7294
|
-
argument: decl.arguments[1],
|
|
7295
|
-
} ],
|
|
7296
|
-
_thisWasm: decl.arguments[2].value === null ? null : [
|
|
7297
|
-
...generate(scope, decl.arguments[2]),
|
|
7298
|
-
...getNodeType(scope, decl.arguments[2])
|
|
7299
|
-
],
|
|
7300
|
-
_newTargetWasm: decl.arguments[3].value === null ? null : [
|
|
7301
|
-
...generate(scope, decl.arguments[3]),
|
|
7302
|
-
...getNodeType(scope, decl.arguments[3])
|
|
7303
|
-
],
|
|
7304
|
-
_new: decl.arguments[3].value !== null,
|
|
7305
|
-
_forceCreateThis: true
|
|
7306
|
-
}),
|
|
7307
|
-
notConstr: true
|
|
7308
|
-
},
|
|
7309
|
-
|
|
7310
|
-
__console_log: {
|
|
7311
|
-
// compile-time aware console.log to optimize fast paths
|
|
7312
|
-
// todo: this breaks console.group, etc - disable this if those are used but edge case for now
|
|
7313
|
-
generate: (scope, decl) => {
|
|
7314
|
-
const slow = () => {
|
|
7315
|
-
decl._noInternalConstr = true;
|
|
7316
|
-
return generate(scope, decl);
|
|
7317
|
-
};
|
|
7318
|
-
const fast = name => {
|
|
7319
|
-
return [
|
|
7320
|
-
...generate(scope, {
|
|
7321
|
-
...decl,
|
|
7322
|
-
callee: {
|
|
7323
|
-
type: 'Identifier',
|
|
7324
|
-
name
|
|
7325
|
-
}
|
|
7326
|
-
}),
|
|
7327
|
-
...printStaticStr(scope, '\n')
|
|
7328
|
-
];
|
|
7329
|
-
};
|
|
7330
|
-
if (decl.arguments.length !== 1) return slow();
|
|
7331
|
-
|
|
7332
|
-
generate(scope, decl.arguments[0]); // generate first to get accurate type
|
|
7333
|
-
const type = knownTypeWithGuess(scope, getNodeType(scope, decl.arguments[0]));
|
|
7334
|
-
|
|
7335
|
-
// if we know the type skip the entire print logic, use type's func directly
|
|
7336
|
-
if (type === TYPES.string || type === TYPES.bytestring) {
|
|
7337
|
-
return fast('__Porffor_printString');
|
|
7338
|
-
} else if (type === TYPES.number) {
|
|
7339
|
-
return fast('print');
|
|
7340
|
-
}
|
|
7341
|
-
|
|
7342
|
-
// one arg, skip most of console to avoid rest arg etc
|
|
7343
|
-
return fast('__Porffor_consolePrint');
|
|
7344
|
-
},
|
|
7345
|
-
type: TYPES.undefined,
|
|
7346
|
-
notConstr: true
|
|
7347
|
-
}
|
|
7348
|
-
};
|
|
7349
|
-
|
|
7350
7163
|
let globals, tags, exceptions, funcs, indirectFuncs, funcIndex, currentFuncIndex, depth, pages, data, typeswitchDepth, usedTypes, coctc, globalInfer, builtinFuncs, builtinVars, lastValtype;
|
|
7351
7164
|
export default program => {
|
|
7352
7165
|
globals = Object.create(null);
|
package/jsr.json
CHANGED
package/package.json
CHANGED