@yuku-codegen/wasm 0.5.21

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/encode.js ADDED
@@ -0,0 +1,2367 @@
1
+ // generated by tools/gen_estree_encoder.zig, do not edit
2
+ const NULL = 0xFFFFFFFF;
3
+ const _enc = new TextEncoder();
4
+ const NODE_SIZE = 48;
5
+ const HEADER_SIZE = 44;
6
+ const NODE_FLAGS_OFFSET = 2;
7
+ const NODE_FIELD0_OFFSET = 4;
8
+ const NODE_HEADER_U32S = 2;
9
+ const NODE_SPAN_START_U32 = 10;
10
+ const NODE_SPAN_END_U32 = 11;
11
+ const ATTACHED_COMMENT_SIZE = 12;
12
+ const ATTACHED_COMMENT_FLAGS_OFFSET = 0;
13
+ const ATTACHED_COMMENT_VALUE_START_OFFSET = 4;
14
+ const ATTACHED_COMMENT_VALUE_END_OFFSET = 8;
15
+ const FLAG_ATTACHED_COMMENTS = 2;
16
+ const BINARY_OPS_INV = {"==": 0, "!=": 1, "===": 2, "!==": 3, "<": 4, "<=": 5, ">": 6, ">=": 7, "+": 8, "-": 9, "*": 10, "/": 11, "%": 12, "**": 13, "|": 14, "^": 15, "&": 16, "<<": 17, ">>": 18, ">>>": 19, "in": 20, "instanceof": 21};
17
+ const LOGICAL_OPS_INV = {"&&": 0, "||": 1, "??": 2};
18
+ const UNARY_OPS_INV = {"-": 0, "+": 1, "!": 2, "~": 3, "typeof": 4, "void": 5, "delete": 6};
19
+ const UPDATE_OPS_INV = {"++": 0, "--": 1};
20
+ const ASSIGNMENT_OPS_INV = {"=": 0, "+=": 1, "-=": 2, "*=": 3, "/=": 4, "%=": 5, "**=": 6, "<<=": 7, ">>=": 8, ">>>=": 9, "|=": 10, "^=": 11, "&=": 12, "||=": 13, "&&=": 14, "??=": 15};
21
+ const VAR_KINDS_INV = {"var": 0, "let": 1, "const": 2, "using": 3, "await using": 4};
22
+ const PROPERTY_KINDS_INV = {"init": 0, "get": 1, "set": 2};
23
+ const METHOD_KINDS_INV = {"constructor": 0, "method": 1, "get": 2, "set": 3};
24
+ const IMPORT_EXPORT_KINDS_INV = {"value": 0, "type": 1};
25
+ const TS_TYPE_OPERATORS_INV = {"keyof": 0, "unique": 1, "readonly": 2};
26
+ const TS_METHOD_SIGNATURE_KINDS_INV = {"method": 0, "get": 1, "set": 2};
27
+ const TS_MODULE_KINDS_INV = {"namespace": 0, "module": 1};
28
+ const IMPORT_PHASE_INV = {"source": 0, "defer": 1};
29
+ const ACCESSIBILITY_INV = (v) =>
30
+ v == null ? 0
31
+ : v === "public" ? 1
32
+ : v === "private" ? 2
33
+ : 3;
34
+ const TS_MAPPED_OPTIONAL_INV = (v) => v === true ? 1 : v === "+" ? 2 : v === "-" ? 3 : 0;
35
+ const TS_MAPPED_READONLY_INV = (v) => v === true ? 1 : v === "+" ? 2 : v === "-" ? 3 : 0;
36
+ function encode(program, lineStarts) {
37
+ const root = program;
38
+ const sizeHint = root.end || 0;
39
+ let nodeCap = Math.max(512, (sizeHint / 7) | 0);
40
+ let nodeAB = new ArrayBuffer(nodeCap * NODE_SIZE);
41
+ let nU8 = new Uint8Array(nodeAB);
42
+ let nU32 = new Uint32Array(nodeAB);
43
+ let nodeCount = 0;
44
+ let extraCap = Math.max(512, (sizeHint / 20) | 0);
45
+ let extras = new Uint32Array(extraCap);
46
+ let extraCount = 0;
47
+ let poolCap = Math.max(4096, (sizeHint / 8) | 0);
48
+ let pool = new Uint8Array(poolCap);
49
+ let poolLen = 0;
50
+ const strMap = new Map();
51
+ function alloc() {
52
+ if (nodeCount >= nodeCap) {
53
+ nodeCap *= 2;
54
+ const nb = new ArrayBuffer(nodeCap * NODE_SIZE);
55
+ new Uint8Array(nb).set(nU8);
56
+ nodeAB = nb; nU8 = new Uint8Array(nb); nU32 = new Uint32Array(nb);
57
+ }
58
+ const idx = nodeCount++;
59
+ const b = (idx * NODE_SIZE) >>> 2;
60
+ nU32[b + NODE_HEADER_U32S + 0] = NULL;
61
+ nU32[b + NODE_HEADER_U32S + 1] = NULL;
62
+ nU32[b + NODE_HEADER_U32S + 2] = NULL;
63
+ nU32[b + NODE_HEADER_U32S + 3] = NULL;
64
+ nU32[b + NODE_HEADER_U32S + 4] = NULL;
65
+ nU32[b + NODE_HEADER_U32S + 5] = NULL;
66
+ nU32[b + NODE_HEADER_U32S + 6] = NULL;
67
+ nU32[b + NODE_HEADER_U32S + 7] = NULL;
68
+ return idx;
69
+ }
70
+ function tagAt(idx, tag) { nU8[idx * NODE_SIZE] = tag; }
71
+ function flagsAt(idx, v) {
72
+ const o = idx * NODE_SIZE + NODE_FLAGS_OFFSET;
73
+ nU8[o] = v & 0xFF; nU8[o + 1] = (v >>> 8) & 0xFF;
74
+ }
75
+ function f0At(idx, v) {
76
+ const o = idx * NODE_SIZE + NODE_FIELD0_OFFSET;
77
+ nU8[o] = v & 0xFF; nU8[o + 1] = (v >>> 8) & 0xFF;
78
+ }
79
+ function slotAt(idx, slot, v) {
80
+ nU32[((idx * NODE_SIZE) >>> 2) + NODE_HEADER_U32S + slot] = v >>> 0;
81
+ }
82
+ function spanAt(idx, s, e) {
83
+ const b = (idx * NODE_SIZE) >>> 2;
84
+ nU32[b + NODE_SPAN_START_U32] = (s >>> 0);
85
+ nU32[b + NODE_SPAN_END_U32] = (e >>> 0);
86
+ }
87
+ function pushExtra(idx) {
88
+ if (extraCount >= extraCap) {
89
+ extraCap *= 2;
90
+ const ne = new Uint32Array(extraCap);
91
+ ne.set(extras); extras = ne;
92
+ }
93
+ extras[extraCount++] = idx >>> 0;
94
+ }
95
+ function encArr(arr, encEach) {
96
+ if (!arr || arr.length === 0) return { start: 0, len: 0 };
97
+ const len = arr.length;
98
+ const ids = new Array(len);
99
+ for (let i = 0; i < len; i++) ids[i] = encEach(arr[i]);
100
+ const start = extraCount;
101
+ for (let i = 0; i < len; i++) pushExtra(ids[i]);
102
+ return { start, len };
103
+ }
104
+ function encArrHoles(arr, encEach) {
105
+ if (!arr || arr.length === 0) return { start: 0, len: 0 };
106
+ const len = arr.length;
107
+ const ids = new Array(len);
108
+ for (let i = 0; i < len; i++) {
109
+ const e = arr[i];
110
+ ids[i] = e == null ? NULL : encEach(e);
111
+ }
112
+ const start = extraCount;
113
+ for (let i = 0; i < len; i++) pushExtra(ids[i]);
114
+ return { start, len };
115
+ }
116
+ function encStr(s) {
117
+ if (s == null || s === "") return { start: 0, end: 0 };
118
+ const hit = strMap.get(s);
119
+ if (hit !== undefined) return hit;
120
+ const n = s.length;
121
+ if (poolLen + n * 3 > poolCap) {
122
+ do { poolCap *= 2; } while (poolLen + n * 3 > poolCap);
123
+ const np = new Uint8Array(poolCap);
124
+ np.set(pool); pool = np;
125
+ }
126
+ const start = poolLen;
127
+ let p = start;
128
+ let ascii = true;
129
+ for (let i = 0; i < n; i++) {
130
+ const c = s.charCodeAt(i);
131
+ if (c < 0x80) { pool[p++] = c; } else { ascii = false; break; }
132
+ }
133
+ let r;
134
+ if (ascii) {
135
+ r = { start, end: p };
136
+ poolLen = p;
137
+ } else {
138
+ const bytes = _enc.encode(s);
139
+ pool.set(bytes, start);
140
+ r = { start, end: start + bytes.length };
141
+ poolLen = start + bytes.length;
142
+ }
143
+ strMap.set(s, r);
144
+ return r;
145
+ }
146
+ function asStart(n) { return (n && typeof n.start === "number") ? n.start : 0; }
147
+ function asEnd(n) { return (n && typeof n.end === "number") ? n.end : 0; }
148
+ function recordComments(n, idx) {
149
+ if (idx !== NULL && n && Array.isArray(n.comments) && n.comments.length > 0) {
150
+ commentsByIdx.set(idx, n.comments);
151
+ }
152
+ }
153
+ function encBindingTarget(n) {
154
+ if (n == null) return NULL;
155
+ if (n.type === "Identifier") return enc_binding_identifier(n);
156
+ return encNode(n);
157
+ }
158
+ function encLabel(n) {
159
+ if (n == null) return NULL;
160
+ return enc_label_identifier(n);
161
+ }
162
+ function encName(n) {
163
+ if (n == null) return NULL;
164
+ if (n.type === "Identifier") return enc_identifier_name(n);
165
+ return encNode(n);
166
+ }
167
+ function enc_sequence_expression(n) {
168
+ const c_expressions = encArr(n.expressions, encNode);
169
+ const idx = alloc();
170
+ tagAt(idx, 0);
171
+ f0At(idx, c_expressions.len);
172
+ slotAt(idx, 0, c_expressions.start);
173
+ spanAt(idx, asStart(n), asEnd(n));
174
+ recordComments(n, idx);
175
+ return idx;
176
+ }
177
+ function enc_parenthesized_expression(n) {
178
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
179
+ const idx = alloc();
180
+ tagAt(idx, 1);
181
+ slotAt(idx, 0, c_expression);
182
+ spanAt(idx, asStart(n), asEnd(n));
183
+ recordComments(n, idx);
184
+ return idx;
185
+ }
186
+ function enc_arrow_function_expression(n) {
187
+ const params = encFormalParameters(n.params);
188
+ const body = encNode(n.body);
189
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
190
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
191
+ const idx = alloc();
192
+ tagAt(idx, 2);
193
+ slotAt(idx, 0, params);
194
+ slotAt(idx, 1, body);
195
+ slotAt(idx, 2, tp);
196
+ slotAt(idx, 3, rt_);
197
+ flagsAt(idx, (n.expression ? 1 : 0) | (n.async ? 2 : 0));
198
+ spanAt(idx, asStart(n), asEnd(n));
199
+ recordComments(n, idx);
200
+ return idx;
201
+ }
202
+ function enc_function(n, kind) {
203
+ const id = n.id == null ? NULL : enc_binding_identifier(n.id);
204
+ const params = encFormalParameters(n.params);
205
+ const body = n.body == null ? NULL : encNode(n.body);
206
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
207
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
208
+ const idx = alloc();
209
+ tagAt(idx, 3);
210
+ slotAt(idx, 0, id);
211
+ slotAt(idx, 1, params);
212
+ slotAt(idx, 2, body);
213
+ slotAt(idx, 3, tp);
214
+ slotAt(idx, 4, rt_);
215
+ flagsAt(idx,
216
+ ((kind & 3) << 0)
217
+ | (n.generator ? 4 : 0)
218
+ | (n.async ? 8 : 0)
219
+ | (n.declare ? 16 : 0));
220
+ spanAt(idx, asStart(n), asEnd(n));
221
+ recordComments(n, idx);
222
+ return idx;
223
+ }
224
+ function enc_block_statement(n) {
225
+ const c_body = encArr(n.body, encNode);
226
+ const idx = alloc();
227
+ tagAt(idx, 5);
228
+ f0At(idx, c_body.len);
229
+ slotAt(idx, 0, c_body.start);
230
+ spanAt(idx, asStart(n), asEnd(n));
231
+ recordComments(n, idx);
232
+ return idx;
233
+ }
234
+ function encFormalParameters(params) {
235
+ if (!params) {
236
+ const idx = alloc();
237
+ tagAt(idx, 6);
238
+ spanAt(idx, 0, 0);
239
+ return idx;
240
+ }
241
+ const items = [];
242
+ let rest = NULL;
243
+ for (let i = 0; i < params.length; i++) {
244
+ const p = params[i];
245
+ if (p && p.type === "RestElement") rest = enc_binding_rest_element(p);
246
+ else if (p && p.type === "TSParameterProperty") items.push(encNode(p));
247
+ else if (p && p.type === "Identifier" && p.name === "this")
248
+ items.push(enc_ts_this_parameter(p));
249
+ else items.push(enc_formal_parameter(p));
250
+ }
251
+ const ids = items;
252
+ const start = extraCount;
253
+ for (let i = 0; i < ids.length; i++) pushExtra(ids[i]);
254
+ const idx = alloc();
255
+ tagAt(idx, 6);
256
+ f0At(idx, ids.length);
257
+ slotAt(idx, 0, start);
258
+ slotAt(idx, 1, rest);
259
+ spanAt(idx, 0, 0);
260
+ return idx;
261
+ }
262
+ function enc_formal_parameter(p) {
263
+ const pat = encBindingTarget(p);
264
+ const idx = alloc();
265
+ tagAt(idx, 7);
266
+ slotAt(idx, 0, pat);
267
+ spanAt(idx, asStart(p), asEnd(p));
268
+ recordComments(p, idx);
269
+ return idx;
270
+ }
271
+ function enc_binary_expression(n) {
272
+ const c_left = n.left == null ? NULL : encNode(n.left);
273
+ const c_right = n.right == null ? NULL : encNode(n.right);
274
+ const idx = alloc();
275
+ tagAt(idx, 8);
276
+ slotAt(idx, 0, c_left);
277
+ slotAt(idx, 1, c_right);
278
+ flagsAt(idx, 0 | (BINARY_OPS_INV[n.operator] | 0));
279
+ spanAt(idx, asStart(n), asEnd(n));
280
+ recordComments(n, idx);
281
+ return idx;
282
+ }
283
+ function enc_logical_expression(n) {
284
+ const c_left = n.left == null ? NULL : encNode(n.left);
285
+ const c_right = n.right == null ? NULL : encNode(n.right);
286
+ const idx = alloc();
287
+ tagAt(idx, 9);
288
+ slotAt(idx, 0, c_left);
289
+ slotAt(idx, 1, c_right);
290
+ flagsAt(idx, 0 | (LOGICAL_OPS_INV[n.operator] | 0));
291
+ spanAt(idx, asStart(n), asEnd(n));
292
+ recordComments(n, idx);
293
+ return idx;
294
+ }
295
+ function enc_conditional_expression(n) {
296
+ const c_test = n.test == null ? NULL : encNode(n.test);
297
+ const c_consequent = n.consequent == null ? NULL : encNode(n.consequent);
298
+ const c_alternate = n.alternate == null ? NULL : encNode(n.alternate);
299
+ const idx = alloc();
300
+ tagAt(idx, 10);
301
+ slotAt(idx, 0, c_test);
302
+ slotAt(idx, 1, c_consequent);
303
+ slotAt(idx, 2, c_alternate);
304
+ spanAt(idx, asStart(n), asEnd(n));
305
+ recordComments(n, idx);
306
+ return idx;
307
+ }
308
+ function enc_unary_expression(n) {
309
+ const a = n.argument == null ? NULL : encNode(n.argument);
310
+ const idx = alloc();
311
+ tagAt(idx, 11);
312
+ slotAt(idx, 0, a);
313
+ flagsAt(idx, UNARY_OPS_INV[n.operator] | 0);
314
+ spanAt(idx, asStart(n), asEnd(n));
315
+ recordComments(n, idx);
316
+ return idx;
317
+ }
318
+ function enc_update_expression(n) {
319
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
320
+ const idx = alloc();
321
+ tagAt(idx, 12);
322
+ slotAt(idx, 0, c_argument);
323
+ flagsAt(idx, 0 | (UPDATE_OPS_INV[n.operator] | 0) | (n.prefix ? 2 : 0));
324
+ spanAt(idx, asStart(n), asEnd(n));
325
+ recordComments(n, idx);
326
+ return idx;
327
+ }
328
+ function enc_assignment_expression(n) {
329
+ const c_left = n.left == null ? NULL : encNode(n.left);
330
+ const c_right = n.right == null ? NULL : encNode(n.right);
331
+ const idx = alloc();
332
+ tagAt(idx, 13);
333
+ slotAt(idx, 0, c_left);
334
+ slotAt(idx, 1, c_right);
335
+ flagsAt(idx, 0 | (ASSIGNMENT_OPS_INV[n.operator] | 0));
336
+ spanAt(idx, asStart(n), asEnd(n));
337
+ recordComments(n, idx);
338
+ return idx;
339
+ }
340
+ function enc_array_expression(n) {
341
+ const c_elements = encArrHoles(n.elements, encNode);
342
+ const idx = alloc();
343
+ tagAt(idx, 14);
344
+ f0At(idx, c_elements.len);
345
+ slotAt(idx, 0, c_elements.start);
346
+ spanAt(idx, asStart(n), asEnd(n));
347
+ recordComments(n, idx);
348
+ return idx;
349
+ }
350
+ function enc_object_expression(n) {
351
+ const c_properties = encArr(n.properties, encNode);
352
+ const idx = alloc();
353
+ tagAt(idx, 15);
354
+ f0At(idx, c_properties.len);
355
+ slotAt(idx, 0, c_properties.start);
356
+ spanAt(idx, asStart(n), asEnd(n));
357
+ recordComments(n, idx);
358
+ return idx;
359
+ }
360
+ function enc_spread_element(n) {
361
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
362
+ const idx = alloc();
363
+ tagAt(idx, 16);
364
+ slotAt(idx, 0, c_argument);
365
+ spanAt(idx, asStart(n), asEnd(n));
366
+ recordComments(n, idx);
367
+ return idx;
368
+ }
369
+ function enc_object_property(n) {
370
+ const k = n.key == null
371
+ ? NULL
372
+ : (n.computed ? encNode(n.key) : encName(n.key));
373
+ const v = n.value == null ? NULL : encNode(n.value);
374
+ const idx = alloc();
375
+ tagAt(idx, 17);
376
+ slotAt(idx, 0, k); slotAt(idx, 1, v);
377
+ flagsAt(idx,
378
+ ((PROPERTY_KINDS_INV[n.kind] | 0) << 0)
379
+ | (n.method ? 4 : 0)
380
+ | (n.shorthand ? 8 : 0)
381
+ | (n.computed ? 16 : 0));
382
+ spanAt(idx, asStart(n), asEnd(n));
383
+ recordComments(n, idx);
384
+ return idx;
385
+ }
386
+ function enc_member_expression(n) {
387
+ const o = n.object == null ? NULL : encNode(n.object);
388
+ const p = n.property == null
389
+ ? NULL
390
+ : (n.computed ? encNode(n.property) : encName(n.property));
391
+ const idx = alloc();
392
+ tagAt(idx, 18);
393
+ slotAt(idx, 0, o); slotAt(idx, 1, p);
394
+ flagsAt(idx, (n.computed ? 1 : 0) | (n.optional ? 2 : 0));
395
+ spanAt(idx, asStart(n), asEnd(n));
396
+ recordComments(n, idx);
397
+ return idx;
398
+ }
399
+ function enc_call_expression(n) {
400
+ const c_callee = n.callee == null ? NULL : encNode(n.callee);
401
+ const c_arguments = encArr(n.arguments, encNode);
402
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
403
+ const idx = alloc();
404
+ tagAt(idx, 19);
405
+ slotAt(idx, 0, c_callee);
406
+ f0At(idx, c_arguments.len);
407
+ slotAt(idx, 1, c_arguments.start);
408
+ slotAt(idx, 2, c_type_arguments);
409
+ flagsAt(idx, 0 | (n.optional ? 1 : 0));
410
+ spanAt(idx, asStart(n), asEnd(n));
411
+ recordComments(n, idx);
412
+ return idx;
413
+ }
414
+ function enc_chain_expression(n) {
415
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
416
+ const idx = alloc();
417
+ tagAt(idx, 20);
418
+ slotAt(idx, 0, c_expression);
419
+ spanAt(idx, asStart(n), asEnd(n));
420
+ recordComments(n, idx);
421
+ return idx;
422
+ }
423
+ function enc_tagged_template_expression(n) {
424
+ const c_tag = n.tag == null ? NULL : encNode(n.tag);
425
+ const c_quasi = n.quasi == null ? NULL : encNode(n.quasi);
426
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
427
+ const idx = alloc();
428
+ tagAt(idx, 21);
429
+ slotAt(idx, 0, c_tag);
430
+ slotAt(idx, 1, c_quasi);
431
+ slotAt(idx, 2, c_type_arguments);
432
+ spanAt(idx, asStart(n), asEnd(n));
433
+ recordComments(n, idx);
434
+ return idx;
435
+ }
436
+ function enc_new_expression(n) {
437
+ const c_callee = n.callee == null ? NULL : encNode(n.callee);
438
+ const c_arguments = encArr(n.arguments, encNode);
439
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
440
+ const idx = alloc();
441
+ tagAt(idx, 22);
442
+ slotAt(idx, 0, c_callee);
443
+ f0At(idx, c_arguments.len);
444
+ slotAt(idx, 1, c_arguments.start);
445
+ slotAt(idx, 2, c_type_arguments);
446
+ spanAt(idx, asStart(n), asEnd(n));
447
+ recordComments(n, idx);
448
+ return idx;
449
+ }
450
+ function enc_await_expression(n) {
451
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
452
+ const idx = alloc();
453
+ tagAt(idx, 23);
454
+ slotAt(idx, 0, c_argument);
455
+ spanAt(idx, asStart(n), asEnd(n));
456
+ recordComments(n, idx);
457
+ return idx;
458
+ }
459
+ function enc_yield_expression(n) {
460
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
461
+ const idx = alloc();
462
+ tagAt(idx, 24);
463
+ slotAt(idx, 0, c_argument);
464
+ flagsAt(idx, 0 | (n.delegate ? 1 : 0));
465
+ spanAt(idx, asStart(n), asEnd(n));
466
+ recordComments(n, idx);
467
+ return idx;
468
+ }
469
+ function enc_meta_property(n) {
470
+ const c_meta = n.meta == null ? NULL : encNode(n.meta);
471
+ const c_property = n.property == null ? NULL : encNode(n.property);
472
+ const idx = alloc();
473
+ tagAt(idx, 25);
474
+ slotAt(idx, 0, c_meta);
475
+ slotAt(idx, 1, c_property);
476
+ spanAt(idx, asStart(n), asEnd(n));
477
+ recordComments(n, idx);
478
+ return idx;
479
+ }
480
+ function enc_decorator(n) {
481
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
482
+ const idx = alloc();
483
+ tagAt(idx, 26);
484
+ slotAt(idx, 0, c_expression);
485
+ spanAt(idx, asStart(n), asEnd(n));
486
+ recordComments(n, idx);
487
+ return idx;
488
+ }
489
+ function enc_class(n, kind) {
490
+ const decs = encArr(n.decorators, encNode);
491
+ const id = n.id == null ? NULL : enc_binding_identifier(n.id);
492
+ const sc = n.superClass == null ? NULL : encNode(n.superClass);
493
+ const body = n.body == null ? NULL : encNode(n.body);
494
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
495
+ const sta = n.superTypeArguments == null ? NULL : encNode(n.superTypeArguments);
496
+ const imps = encArr(n.implements, encNode);
497
+ const idx = alloc();
498
+ tagAt(idx, 27);
499
+ f0At(idx, decs.len);
500
+ slotAt(idx, 0, decs.start);
501
+ slotAt(idx, 1, id);
502
+ slotAt(idx, 2, sc);
503
+ slotAt(idx, 3, body);
504
+ slotAt(idx, 4, tp);
505
+ slotAt(idx, 5, sta);
506
+ slotAt(idx, 6, imps.start);
507
+ slotAt(idx, 7, imps.len);
508
+ flagsAt(idx, ((kind & 1) << 0) | (n.abstract ? 2 : 0) | (n.declare ? 4 : 0));
509
+ spanAt(idx, asStart(n), asEnd(n));
510
+ recordComments(n, idx);
511
+ return idx;
512
+ }
513
+ function enc_class_body(n) {
514
+ const c_body = encArr(n.body, encNode);
515
+ const idx = alloc();
516
+ tagAt(idx, 28);
517
+ f0At(idx, c_body.len);
518
+ slotAt(idx, 0, c_body.start);
519
+ spanAt(idx, asStart(n), asEnd(n));
520
+ recordComments(n, idx);
521
+ return idx;
522
+ }
523
+ function enc_method_definition(n, abstract) {
524
+ const decs = encArr(n.decorators, encNode);
525
+ const k = n.computed ? encNode(n.key) : encName(n.key);
526
+ const v = encNode(n.value);
527
+ const idx = alloc();
528
+ tagAt(idx, 29);
529
+ f0At(idx, decs.len);
530
+ slotAt(idx, 0, decs.start);
531
+ slotAt(idx, 1, k);
532
+ slotAt(idx, 2, v);
533
+ flagsAt(idx,
534
+ ((METHOD_KINDS_INV[n.kind] | 0) << 0) |
535
+ (n.computed ? 4 : 0) |
536
+ (n.static ? 8 : 0) |
537
+ (n.override ? 16 : 0) |
538
+ (n.optional ? 32 : 0) |
539
+ (abstract ? 64 : 0) |
540
+ (ACCESSIBILITY_INV(n.accessibility) << 7));
541
+ spanAt(idx, asStart(n), asEnd(n));
542
+ recordComments(n, idx);
543
+ return idx;
544
+ }
545
+ function enc_property_definition(n, accessor, abstract) {
546
+ const decs = encArr(n.decorators, encNode);
547
+ const k = n.computed ? encNode(n.key) : encName(n.key);
548
+ const v = n.value == null ? NULL : encNode(n.value);
549
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
550
+ const idx = alloc();
551
+ tagAt(idx, 30);
552
+ f0At(idx, decs.len);
553
+ slotAt(idx, 0, decs.start);
554
+ slotAt(idx, 1, k);
555
+ slotAt(idx, 2, v);
556
+ slotAt(idx, 3, ta);
557
+ flagsAt(idx,
558
+ (n.computed ? 1 : 0) |
559
+ (n.static ? 2 : 0) |
560
+ (accessor ? 4 : 0) |
561
+ (n.declare ? 8 : 0) |
562
+ (n.override ? 16 : 0) |
563
+ (n.optional ? 32 : 0) |
564
+ (n.definite ? 64 : 0) |
565
+ (n.readonly ? 128 : 0) |
566
+ (abstract ? 256 : 0) |
567
+ (ACCESSIBILITY_INV(n.accessibility) << 9));
568
+ spanAt(idx, asStart(n), asEnd(n));
569
+ recordComments(n, idx);
570
+ return idx;
571
+ }
572
+ function enc_static_block(n) {
573
+ const c_body = encArr(n.body, encNode);
574
+ const idx = alloc();
575
+ tagAt(idx, 31);
576
+ f0At(idx, c_body.len);
577
+ slotAt(idx, 0, c_body.start);
578
+ spanAt(idx, asStart(n), asEnd(n));
579
+ recordComments(n, idx);
580
+ return idx;
581
+ }
582
+ function enc_super(n) {
583
+ const idx = alloc();
584
+ tagAt(idx, 32);
585
+ spanAt(idx, asStart(n), asEnd(n));
586
+ recordComments(n, idx);
587
+ return idx;
588
+ }
589
+ function enc_string_literal(n) {
590
+ const s = encStr(typeof n.value === "string" ? n.value : "");
591
+ const r = encStr(typeof n.raw === "string" ? n.raw : "");
592
+ const idx = alloc();
593
+ tagAt(idx, 33);
594
+ slotAt(idx, 0, s.start); slotAt(idx, 1, s.end);
595
+ slotAt(idx, 2, r.start); slotAt(idx, 3, r.end);
596
+ spanAt(idx, asStart(n), asEnd(n));
597
+ recordComments(n, idx);
598
+ return idx;
599
+ }
600
+ function enc_numeric_literal(n) {
601
+ const raw = typeof n.raw === "string" ? n.raw : String(n.value);
602
+ let kind = 0;
603
+ if (raw.length > 1 && raw.charCodeAt(0) === 48) {
604
+ const c = raw.charCodeAt(1);
605
+ if (c === 120 || c === 88) kind = 1;
606
+ else if (c === 111 || c === 79) kind = 2;
607
+ else if (c === 98 || c === 66) kind = 3;
608
+ }
609
+ const r = encStr(raw);
610
+ const idx = alloc();
611
+ tagAt(idx, 34);
612
+ flagsAt(idx, kind);
613
+ slotAt(idx, 0, r.start); slotAt(idx, 1, r.end);
614
+ spanAt(idx, asStart(n), asEnd(n));
615
+ recordComments(n, idx);
616
+ return idx;
617
+ }
618
+ function enc_bigint_literal(n) {
619
+ const raw = typeof n.bigint === "string" ? n.bigint : String(n.value);
620
+ const r = encStr(raw);
621
+ const idx = alloc();
622
+ tagAt(idx, 35);
623
+ slotAt(idx, 0, r.start); slotAt(idx, 1, r.end);
624
+ spanAt(idx, asStart(n), asEnd(n));
625
+ recordComments(n, idx);
626
+ return idx;
627
+ }
628
+ function enc_boolean_literal(n) {
629
+ const idx = alloc();
630
+ tagAt(idx, 36);
631
+ flagsAt(idx, n.value ? 1 : 0);
632
+ spanAt(idx, asStart(n), asEnd(n));
633
+ recordComments(n, idx);
634
+ return idx;
635
+ }
636
+ function enc_null_literal(n) {
637
+ const idx = alloc();
638
+ tagAt(idx, 37);
639
+ spanAt(idx, asStart(n), asEnd(n));
640
+ recordComments(n, idx);
641
+ return idx;
642
+ }
643
+ function enc_this_expression(n) {
644
+ const idx = alloc();
645
+ tagAt(idx, 38);
646
+ spanAt(idx, asStart(n), asEnd(n));
647
+ recordComments(n, idx);
648
+ return idx;
649
+ }
650
+ function enc_regexp_literal(n) {
651
+ const p = encStr(n.regex && n.regex.pattern || "");
652
+ const fl = encStr(n.regex && n.regex.flags || "");
653
+ const idx = alloc();
654
+ tagAt(idx, 39);
655
+ slotAt(idx, 0, p.start); slotAt(idx, 1, p.end);
656
+ slotAt(idx, 2, fl.start); slotAt(idx, 3, fl.end);
657
+ spanAt(idx, asStart(n), asEnd(n));
658
+ recordComments(n, idx);
659
+ return idx;
660
+ }
661
+ function enc_template_literal(n) {
662
+ const c_quasis = encArr(n.quasis, encNode);
663
+ const c_expressions = encArr(n.expressions, encNode);
664
+ const idx = alloc();
665
+ tagAt(idx, 40);
666
+ f0At(idx, c_quasis.len);
667
+ slotAt(idx, 0, c_quasis.start);
668
+ slotAt(idx, 1, c_expressions.start);
669
+ slotAt(idx, 2, c_expressions.len);
670
+ spanAt(idx, asStart(n), asEnd(n));
671
+ recordComments(n, idx);
672
+ return idx;
673
+ }
674
+ function enc_template_element(n) {
675
+ const v = (n.value || {});
676
+ const undef = v.cooked == null;
677
+ const c = encStr(undef ? "" : v.cooked);
678
+ const idx = alloc();
679
+ tagAt(idx, 41);
680
+ flagsAt(idx, (n.tail ? 1 : 0) | (undef ? 2 : 0));
681
+ slotAt(idx, 0, c.start); slotAt(idx, 1, c.end);
682
+ spanAt(idx, asStart(n), asEnd(n));
683
+ recordComments(n, idx);
684
+ return idx;
685
+ }
686
+ function enc_identifier_reference(n) {
687
+ const c_name = encStr(n.name);
688
+ const idx = alloc();
689
+ tagAt(idx, 42);
690
+ slotAt(idx, 0, c_name.start);
691
+ slotAt(idx, 1, c_name.end);
692
+ spanAt(idx, asStart(n), asEnd(n));
693
+ recordComments(n, idx);
694
+ return idx;
695
+ }
696
+ function enc_private_identifier(n) {
697
+ const c_name = encStr(n.name);
698
+ const idx = alloc();
699
+ tagAt(idx, 43);
700
+ slotAt(idx, 0, c_name.start);
701
+ slotAt(idx, 1, c_name.end);
702
+ spanAt(idx, asStart(n), asEnd(n));
703
+ recordComments(n, idx);
704
+ return idx;
705
+ }
706
+ function enc_binding_identifier(n) {
707
+ const c_name = encStr(n.name);
708
+ const c_decorators = encArr(n.decorators, encNode);
709
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
710
+ const idx = alloc();
711
+ tagAt(idx, 44);
712
+ slotAt(idx, 0, c_name.start);
713
+ slotAt(idx, 1, c_name.end);
714
+ f0At(idx, c_decorators.len);
715
+ slotAt(idx, 2, c_decorators.start);
716
+ slotAt(idx, 3, c_type_annotation);
717
+ flagsAt(idx, 0 | (n.optional ? 1 : 0));
718
+ spanAt(idx, asStart(n), asEnd(n));
719
+ recordComments(n, idx);
720
+ return idx;
721
+ }
722
+ function enc_identifier_name(n) {
723
+ const c_name = encStr(n.name);
724
+ const idx = alloc();
725
+ tagAt(idx, 45);
726
+ slotAt(idx, 0, c_name.start);
727
+ slotAt(idx, 1, c_name.end);
728
+ spanAt(idx, asStart(n), asEnd(n));
729
+ recordComments(n, idx);
730
+ return idx;
731
+ }
732
+ function enc_label_identifier(n) {
733
+ const c_name = encStr(n.name);
734
+ const idx = alloc();
735
+ tagAt(idx, 46);
736
+ slotAt(idx, 0, c_name.start);
737
+ slotAt(idx, 1, c_name.end);
738
+ spanAt(idx, asStart(n), asEnd(n));
739
+ recordComments(n, idx);
740
+ return idx;
741
+ }
742
+ function enc_expression_statement(n) {
743
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
744
+ const idx = alloc();
745
+ tagAt(idx, 47);
746
+ slotAt(idx, 0, c_expression);
747
+ spanAt(idx, asStart(n), asEnd(n));
748
+ recordComments(n, idx);
749
+ return idx;
750
+ }
751
+ function enc_if_statement(n) {
752
+ const c_test = n.test == null ? NULL : encNode(n.test);
753
+ const c_consequent = n.consequent == null ? NULL : encNode(n.consequent);
754
+ const c_alternate = n.alternate == null ? NULL : encNode(n.alternate);
755
+ const idx = alloc();
756
+ tagAt(idx, 48);
757
+ slotAt(idx, 0, c_test);
758
+ slotAt(idx, 1, c_consequent);
759
+ slotAt(idx, 2, c_alternate);
760
+ spanAt(idx, asStart(n), asEnd(n));
761
+ recordComments(n, idx);
762
+ return idx;
763
+ }
764
+ function enc_switch_statement(n) {
765
+ const c_discriminant = n.discriminant == null ? NULL : encNode(n.discriminant);
766
+ const c_cases = encArr(n.cases, encNode);
767
+ const idx = alloc();
768
+ tagAt(idx, 49);
769
+ slotAt(idx, 0, c_discriminant);
770
+ f0At(idx, c_cases.len);
771
+ slotAt(idx, 1, c_cases.start);
772
+ spanAt(idx, asStart(n), asEnd(n));
773
+ recordComments(n, idx);
774
+ return idx;
775
+ }
776
+ function enc_switch_case(n) {
777
+ const c_test = n.test == null ? NULL : encNode(n.test);
778
+ const c_consequent = encArr(n.consequent, encNode);
779
+ const idx = alloc();
780
+ tagAt(idx, 50);
781
+ slotAt(idx, 0, c_test);
782
+ f0At(idx, c_consequent.len);
783
+ slotAt(idx, 1, c_consequent.start);
784
+ spanAt(idx, asStart(n), asEnd(n));
785
+ recordComments(n, idx);
786
+ return idx;
787
+ }
788
+ function enc_for_statement(n) {
789
+ const c_init = n.init == null ? NULL : encNode(n.init);
790
+ const c_test = n.test == null ? NULL : encNode(n.test);
791
+ const c_update = n.update == null ? NULL : encNode(n.update);
792
+ const c_body = n.body == null ? NULL : encNode(n.body);
793
+ const idx = alloc();
794
+ tagAt(idx, 51);
795
+ slotAt(idx, 0, c_init);
796
+ slotAt(idx, 1, c_test);
797
+ slotAt(idx, 2, c_update);
798
+ slotAt(idx, 3, c_body);
799
+ spanAt(idx, asStart(n), asEnd(n));
800
+ recordComments(n, idx);
801
+ return idx;
802
+ }
803
+ function enc_for_in_statement(n) {
804
+ const c_left = n.left == null ? NULL : encNode(n.left);
805
+ const c_right = n.right == null ? NULL : encNode(n.right);
806
+ const c_body = n.body == null ? NULL : encNode(n.body);
807
+ const idx = alloc();
808
+ tagAt(idx, 52);
809
+ slotAt(idx, 0, c_left);
810
+ slotAt(idx, 1, c_right);
811
+ slotAt(idx, 2, c_body);
812
+ spanAt(idx, asStart(n), asEnd(n));
813
+ recordComments(n, idx);
814
+ return idx;
815
+ }
816
+ function enc_for_of_statement(n) {
817
+ const c_left = n.left == null ? NULL : encNode(n.left);
818
+ const c_right = n.right == null ? NULL : encNode(n.right);
819
+ const c_body = n.body == null ? NULL : encNode(n.body);
820
+ const idx = alloc();
821
+ tagAt(idx, 53);
822
+ slotAt(idx, 0, c_left);
823
+ slotAt(idx, 1, c_right);
824
+ slotAt(idx, 2, c_body);
825
+ flagsAt(idx, 0 | (n.await ? 1 : 0));
826
+ spanAt(idx, asStart(n), asEnd(n));
827
+ recordComments(n, idx);
828
+ return idx;
829
+ }
830
+ function enc_while_statement(n) {
831
+ const c_test = n.test == null ? NULL : encNode(n.test);
832
+ const c_body = n.body == null ? NULL : encNode(n.body);
833
+ const idx = alloc();
834
+ tagAt(idx, 54);
835
+ slotAt(idx, 0, c_test);
836
+ slotAt(idx, 1, c_body);
837
+ spanAt(idx, asStart(n), asEnd(n));
838
+ recordComments(n, idx);
839
+ return idx;
840
+ }
841
+ function enc_do_while_statement(n) {
842
+ const c_body = n.body == null ? NULL : encNode(n.body);
843
+ const c_test = n.test == null ? NULL : encNode(n.test);
844
+ const idx = alloc();
845
+ tagAt(idx, 55);
846
+ slotAt(idx, 0, c_body);
847
+ slotAt(idx, 1, c_test);
848
+ spanAt(idx, asStart(n), asEnd(n));
849
+ recordComments(n, idx);
850
+ return idx;
851
+ }
852
+ function enc_break_statement(n) {
853
+ const c_label = n.label == null ? NULL : encLabel(n.label);
854
+ const idx = alloc();
855
+ tagAt(idx, 56);
856
+ slotAt(idx, 0, c_label);
857
+ spanAt(idx, asStart(n), asEnd(n));
858
+ recordComments(n, idx);
859
+ return idx;
860
+ }
861
+ function enc_continue_statement(n) {
862
+ const c_label = n.label == null ? NULL : encLabel(n.label);
863
+ const idx = alloc();
864
+ tagAt(idx, 57);
865
+ slotAt(idx, 0, c_label);
866
+ spanAt(idx, asStart(n), asEnd(n));
867
+ recordComments(n, idx);
868
+ return idx;
869
+ }
870
+ function enc_labeled_statement(n) {
871
+ const c_label = n.label == null ? NULL : encLabel(n.label);
872
+ const c_body = n.body == null ? NULL : encNode(n.body);
873
+ const idx = alloc();
874
+ tagAt(idx, 58);
875
+ slotAt(idx, 0, c_label);
876
+ slotAt(idx, 1, c_body);
877
+ spanAt(idx, asStart(n), asEnd(n));
878
+ recordComments(n, idx);
879
+ return idx;
880
+ }
881
+ function enc_with_statement(n) {
882
+ const c_object = n.object == null ? NULL : encNode(n.object);
883
+ const c_body = n.body == null ? NULL : encNode(n.body);
884
+ const idx = alloc();
885
+ tagAt(idx, 59);
886
+ slotAt(idx, 0, c_object);
887
+ slotAt(idx, 1, c_body);
888
+ spanAt(idx, asStart(n), asEnd(n));
889
+ recordComments(n, idx);
890
+ return idx;
891
+ }
892
+ function enc_return_statement(n) {
893
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
894
+ const idx = alloc();
895
+ tagAt(idx, 60);
896
+ slotAt(idx, 0, c_argument);
897
+ spanAt(idx, asStart(n), asEnd(n));
898
+ recordComments(n, idx);
899
+ return idx;
900
+ }
901
+ function enc_throw_statement(n) {
902
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
903
+ const idx = alloc();
904
+ tagAt(idx, 61);
905
+ slotAt(idx, 0, c_argument);
906
+ spanAt(idx, asStart(n), asEnd(n));
907
+ recordComments(n, idx);
908
+ return idx;
909
+ }
910
+ function enc_try_statement(n) {
911
+ const c_block = n.block == null ? NULL : encNode(n.block);
912
+ const c_handler = n.handler == null ? NULL : encNode(n.handler);
913
+ const c_finalizer = n.finalizer == null ? NULL : encNode(n.finalizer);
914
+ const idx = alloc();
915
+ tagAt(idx, 62);
916
+ slotAt(idx, 0, c_block);
917
+ slotAt(idx, 1, c_handler);
918
+ slotAt(idx, 2, c_finalizer);
919
+ spanAt(idx, asStart(n), asEnd(n));
920
+ recordComments(n, idx);
921
+ return idx;
922
+ }
923
+ function enc_catch_clause(n) {
924
+ const c_param = n.param == null ? NULL : encBindingTarget(n.param);
925
+ const c_body = n.body == null ? NULL : encNode(n.body);
926
+ const idx = alloc();
927
+ tagAt(idx, 63);
928
+ slotAt(idx, 0, c_param);
929
+ slotAt(idx, 1, c_body);
930
+ spanAt(idx, asStart(n), asEnd(n));
931
+ recordComments(n, idx);
932
+ return idx;
933
+ }
934
+ function enc_debugger_statement(n) {
935
+ const idx = alloc();
936
+ tagAt(idx, 64);
937
+ spanAt(idx, asStart(n), asEnd(n));
938
+ recordComments(n, idx);
939
+ return idx;
940
+ }
941
+ function enc_empty_statement(n) {
942
+ const idx = alloc();
943
+ tagAt(idx, 65);
944
+ spanAt(idx, asStart(n), asEnd(n));
945
+ recordComments(n, idx);
946
+ return idx;
947
+ }
948
+ function enc_variable_declaration(n) {
949
+ const c_declarators = encArr(n.declarations, encNode);
950
+ const idx = alloc();
951
+ tagAt(idx, 66);
952
+ f0At(idx, c_declarators.len);
953
+ slotAt(idx, 0, c_declarators.start);
954
+ flagsAt(idx, 0 | (VAR_KINDS_INV[n.kind] | 0) | (n.declare ? 8 : 0));
955
+ spanAt(idx, asStart(n), asEnd(n));
956
+ recordComments(n, idx);
957
+ return idx;
958
+ }
959
+ function enc_variable_declarator(n) {
960
+ const c_id = n.id == null ? NULL : encBindingTarget(n.id);
961
+ const c_init = n.init == null ? NULL : encNode(n.init);
962
+ const idx = alloc();
963
+ tagAt(idx, 67);
964
+ slotAt(idx, 0, c_id);
965
+ slotAt(idx, 1, c_init);
966
+ flagsAt(idx, 0 | (n.definite ? 1 : 0));
967
+ spanAt(idx, asStart(n), asEnd(n));
968
+ recordComments(n, idx);
969
+ return idx;
970
+ }
971
+ function enc_directive(n) {
972
+ const e = encNode(n.expression);
973
+ const dv = encStr(n.directive);
974
+ const idx = alloc();
975
+ tagAt(idx, 68);
976
+ slotAt(idx, 0, e);
977
+ slotAt(idx, 1, dv.start); slotAt(idx, 2, dv.end);
978
+ spanAt(idx, asStart(n), asEnd(n));
979
+ recordComments(n, idx);
980
+ return idx;
981
+ }
982
+ function enc_assignment_pattern(n) {
983
+ const c_left = n.left == null ? NULL : encBindingTarget(n.left);
984
+ const c_right = n.right == null ? NULL : encNode(n.right);
985
+ const c_decorators = encArr(n.decorators, encNode);
986
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
987
+ const idx = alloc();
988
+ tagAt(idx, 69);
989
+ slotAt(idx, 0, c_left);
990
+ slotAt(idx, 1, c_right);
991
+ f0At(idx, c_decorators.len);
992
+ slotAt(idx, 2, c_decorators.start);
993
+ slotAt(idx, 3, c_type_annotation);
994
+ flagsAt(idx, 0 | (n.optional ? 1 : 0));
995
+ spanAt(idx, asStart(n), asEnd(n));
996
+ recordComments(n, idx);
997
+ return idx;
998
+ }
999
+ function enc_binding_rest_element(n) {
1000
+ const c_argument = n.argument == null ? NULL : encBindingTarget(n.argument);
1001
+ const c_decorators = encArr(n.decorators, encNode);
1002
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1003
+ const idx = alloc();
1004
+ tagAt(idx, 70);
1005
+ slotAt(idx, 0, c_argument);
1006
+ f0At(idx, c_decorators.len);
1007
+ slotAt(idx, 1, c_decorators.start);
1008
+ slotAt(idx, 2, c_type_annotation);
1009
+ flagsAt(idx, 0 | (n.optional ? 1 : 0));
1010
+ spanAt(idx, asStart(n), asEnd(n));
1011
+ recordComments(n, idx);
1012
+ return idx;
1013
+ }
1014
+ function enc_array_pattern(n) {
1015
+ const els = n.elements || [];
1016
+ let rest = NULL;
1017
+ const items = [];
1018
+ for (let i = 0; i < els.length; i++) {
1019
+ const e = els[i];
1020
+ if (e == null) items.push(null);
1021
+ else if (e.type === "RestElement") rest = enc_binding_rest_element(e);
1022
+ else items.push(e);
1023
+ }
1024
+ const r = encArrHoles(items, encBindingTarget);
1025
+ const decs = encArr(n.decorators, encNode);
1026
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1027
+ const idx = alloc();
1028
+ tagAt(idx, 71);
1029
+ f0At(idx, r.len);
1030
+ slotAt(idx, 0, r.start);
1031
+ slotAt(idx, 1, rest);
1032
+ slotAt(idx, 2, decs.start); slotAt(idx, 3, decs.len);
1033
+ slotAt(idx, 4, ta);
1034
+ flagsAt(idx, n.optional ? 1 : 0);
1035
+ spanAt(idx, asStart(n), asEnd(n));
1036
+ recordComments(n, idx);
1037
+ return idx;
1038
+ }
1039
+ function enc_object_pattern(n) {
1040
+ const props = n.properties || [];
1041
+ let rest = NULL;
1042
+ const items = [];
1043
+ for (let i = 0; i < props.length; i++) {
1044
+ const p = props[i];
1045
+ if (p && p.type === "RestElement") rest = enc_binding_rest_element(p);
1046
+ else items.push(p);
1047
+ }
1048
+ const r = encArr(items, enc_binding_property);
1049
+ const decs = encArr(n.decorators, encNode);
1050
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1051
+ const idx = alloc();
1052
+ tagAt(idx, 72);
1053
+ f0At(idx, r.len);
1054
+ slotAt(idx, 0, r.start);
1055
+ slotAt(idx, 1, rest);
1056
+ slotAt(idx, 2, decs.start); slotAt(idx, 3, decs.len);
1057
+ slotAt(idx, 4, ta);
1058
+ flagsAt(idx, n.optional ? 1 : 0);
1059
+ spanAt(idx, asStart(n), asEnd(n));
1060
+ recordComments(n, idx);
1061
+ return idx;
1062
+ }
1063
+ function enc_binding_property(p) {
1064
+ const k = p.key == null
1065
+ ? NULL
1066
+ : (p.computed ? encNode(p.key) : encName(p.key));
1067
+ const v = p.value == null ? NULL : encBindingTarget(p.value);
1068
+ const idx = alloc();
1069
+ tagAt(idx, 73);
1070
+ slotAt(idx, 0, k); slotAt(idx, 1, v);
1071
+ flagsAt(idx, (p.shorthand ? 1 : 0) | (p.computed ? 2 : 0));
1072
+ spanAt(idx, asStart(p), asEnd(p));
1073
+ return idx;
1074
+ }
1075
+ function enc_program(n) {
1076
+ const body = encArr(n.body, encNode);
1077
+ const hb = n.hashbang && typeof n.hashbang.value === "string"
1078
+ ? encStr(n.hashbang.value)
1079
+ : null;
1080
+ const idx = alloc();
1081
+ tagAt(idx, 74);
1082
+ f0At(idx, body.len);
1083
+ slotAt(idx, 0, body.start);
1084
+ if (hb) { slotAt(idx, 1, hb.start); slotAt(idx, 2, hb.end); }
1085
+ flagsAt(idx, (n.sourceType === "script" ? 0 : 1) | (hb ? 2 : 0));
1086
+ spanAt(idx, asStart(n), asEnd(n));
1087
+ recordComments(n, idx);
1088
+ return idx;
1089
+ }
1090
+ function enc_import_expression(n) {
1091
+ const c_source = n.source == null ? NULL : encNode(n.source);
1092
+ const c_options = n.options == null ? NULL : encNode(n.options);
1093
+ const idx = alloc();
1094
+ tagAt(idx, 75);
1095
+ slotAt(idx, 0, c_source);
1096
+ slotAt(idx, 1, c_options);
1097
+ flagsAt(idx, 0 | (n.phase != null ? 1 | ((IMPORT_PHASE_INV[n.phase] | 0) << 1) : 0));
1098
+ spanAt(idx, asStart(n), asEnd(n));
1099
+ recordComments(n, idx);
1100
+ return idx;
1101
+ }
1102
+ function enc_import_declaration(n) {
1103
+ const c_specifiers = encArr(n.specifiers, encNode);
1104
+ const c_source = n.source == null ? NULL : encNode(n.source);
1105
+ const c_attributes = encArr(n.attributes, encNode);
1106
+ const idx = alloc();
1107
+ tagAt(idx, 76);
1108
+ f0At(idx, c_specifiers.len);
1109
+ slotAt(idx, 0, c_specifiers.start);
1110
+ slotAt(idx, 1, c_source);
1111
+ slotAt(idx, 2, c_attributes.start);
1112
+ slotAt(idx, 3, c_attributes.len);
1113
+ flagsAt(idx, 0 | (n.phase != null ? 1 | ((IMPORT_PHASE_INV[n.phase] | 0) << 1) : 0) | ((IMPORT_EXPORT_KINDS_INV[n.importKind] | 0) << 2));
1114
+ spanAt(idx, asStart(n), asEnd(n));
1115
+ recordComments(n, idx);
1116
+ return idx;
1117
+ }
1118
+ function enc_import_specifier(n) {
1119
+ const c_imported = n.imported == null ? NULL : encName(n.imported);
1120
+ const c_local = n.local == null ? NULL : encBindingTarget(n.local);
1121
+ const idx = alloc();
1122
+ tagAt(idx, 77);
1123
+ slotAt(idx, 0, c_imported);
1124
+ slotAt(idx, 1, c_local);
1125
+ flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.importKind] | 0));
1126
+ spanAt(idx, asStart(n), asEnd(n));
1127
+ recordComments(n, idx);
1128
+ return idx;
1129
+ }
1130
+ function enc_import_default_specifier(n) {
1131
+ const c_local = n.local == null ? NULL : encBindingTarget(n.local);
1132
+ const idx = alloc();
1133
+ tagAt(idx, 78);
1134
+ slotAt(idx, 0, c_local);
1135
+ spanAt(idx, asStart(n), asEnd(n));
1136
+ recordComments(n, idx);
1137
+ return idx;
1138
+ }
1139
+ function enc_import_namespace_specifier(n) {
1140
+ const c_local = n.local == null ? NULL : encBindingTarget(n.local);
1141
+ const idx = alloc();
1142
+ tagAt(idx, 79);
1143
+ slotAt(idx, 0, c_local);
1144
+ spanAt(idx, asStart(n), asEnd(n));
1145
+ recordComments(n, idx);
1146
+ return idx;
1147
+ }
1148
+ function enc_import_attribute(n) {
1149
+ const c_key = n.key == null ? NULL : encName(n.key);
1150
+ const c_value = n.value == null ? NULL : encNode(n.value);
1151
+ const idx = alloc();
1152
+ tagAt(idx, 80);
1153
+ slotAt(idx, 0, c_key);
1154
+ slotAt(idx, 1, c_value);
1155
+ spanAt(idx, asStart(n), asEnd(n));
1156
+ recordComments(n, idx);
1157
+ return idx;
1158
+ }
1159
+ function enc_export_named_declaration(n) {
1160
+ const c_declaration = n.declaration == null ? NULL : encNode(n.declaration);
1161
+ const c_specifiers = encArr(n.specifiers, encNode);
1162
+ const c_source = n.source == null ? NULL : encNode(n.source);
1163
+ const c_attributes = encArr(n.attributes, encNode);
1164
+ const idx = alloc();
1165
+ tagAt(idx, 81);
1166
+ slotAt(idx, 0, c_declaration);
1167
+ f0At(idx, c_specifiers.len);
1168
+ slotAt(idx, 1, c_specifiers.start);
1169
+ slotAt(idx, 2, c_source);
1170
+ slotAt(idx, 3, c_attributes.start);
1171
+ slotAt(idx, 4, c_attributes.len);
1172
+ flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.exportKind] | 0));
1173
+ spanAt(idx, asStart(n), asEnd(n));
1174
+ recordComments(n, idx);
1175
+ return idx;
1176
+ }
1177
+ function enc_export_default_declaration(n) {
1178
+ const c_declaration = n.declaration == null ? NULL : encNode(n.declaration);
1179
+ const idx = alloc();
1180
+ tagAt(idx, 82);
1181
+ slotAt(idx, 0, c_declaration);
1182
+ spanAt(idx, asStart(n), asEnd(n));
1183
+ recordComments(n, idx);
1184
+ return idx;
1185
+ }
1186
+ function enc_export_all_declaration(n) {
1187
+ const c_exported = n.exported == null ? NULL : encName(n.exported);
1188
+ const c_source = n.source == null ? NULL : encNode(n.source);
1189
+ const c_attributes = encArr(n.attributes, encNode);
1190
+ const idx = alloc();
1191
+ tagAt(idx, 83);
1192
+ slotAt(idx, 0, c_exported);
1193
+ slotAt(idx, 1, c_source);
1194
+ f0At(idx, c_attributes.len);
1195
+ slotAt(idx, 2, c_attributes.start);
1196
+ flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.exportKind] | 0));
1197
+ spanAt(idx, asStart(n), asEnd(n));
1198
+ recordComments(n, idx);
1199
+ return idx;
1200
+ }
1201
+ function enc_export_specifier(n) {
1202
+ const c_local = n.local == null ? NULL : encNode(n.local);
1203
+ const c_exported = n.exported == null ? NULL : encName(n.exported);
1204
+ const idx = alloc();
1205
+ tagAt(idx, 84);
1206
+ slotAt(idx, 0, c_local);
1207
+ slotAt(idx, 1, c_exported);
1208
+ flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.exportKind] | 0));
1209
+ spanAt(idx, asStart(n), asEnd(n));
1210
+ recordComments(n, idx);
1211
+ return idx;
1212
+ }
1213
+ function enc_ts_type_annotation(n) {
1214
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1215
+ const idx = alloc();
1216
+ tagAt(idx, 85);
1217
+ slotAt(idx, 0, c_type_annotation);
1218
+ spanAt(idx, asStart(n), asEnd(n));
1219
+ recordComments(n, idx);
1220
+ return idx;
1221
+ }
1222
+ function enc_ts_any_keyword(n) {
1223
+ const idx = alloc();
1224
+ tagAt(idx, 86);
1225
+ spanAt(idx, asStart(n), asEnd(n));
1226
+ recordComments(n, idx);
1227
+ return idx;
1228
+ }
1229
+ function enc_ts_unknown_keyword(n) {
1230
+ const idx = alloc();
1231
+ tagAt(idx, 87);
1232
+ spanAt(idx, asStart(n), asEnd(n));
1233
+ recordComments(n, idx);
1234
+ return idx;
1235
+ }
1236
+ function enc_ts_never_keyword(n) {
1237
+ const idx = alloc();
1238
+ tagAt(idx, 88);
1239
+ spanAt(idx, asStart(n), asEnd(n));
1240
+ recordComments(n, idx);
1241
+ return idx;
1242
+ }
1243
+ function enc_ts_void_keyword(n) {
1244
+ const idx = alloc();
1245
+ tagAt(idx, 89);
1246
+ spanAt(idx, asStart(n), asEnd(n));
1247
+ recordComments(n, idx);
1248
+ return idx;
1249
+ }
1250
+ function enc_ts_null_keyword(n) {
1251
+ const idx = alloc();
1252
+ tagAt(idx, 90);
1253
+ spanAt(idx, asStart(n), asEnd(n));
1254
+ recordComments(n, idx);
1255
+ return idx;
1256
+ }
1257
+ function enc_ts_undefined_keyword(n) {
1258
+ const idx = alloc();
1259
+ tagAt(idx, 91);
1260
+ spanAt(idx, asStart(n), asEnd(n));
1261
+ recordComments(n, idx);
1262
+ return idx;
1263
+ }
1264
+ function enc_ts_string_keyword(n) {
1265
+ const idx = alloc();
1266
+ tagAt(idx, 92);
1267
+ spanAt(idx, asStart(n), asEnd(n));
1268
+ recordComments(n, idx);
1269
+ return idx;
1270
+ }
1271
+ function enc_ts_number_keyword(n) {
1272
+ const idx = alloc();
1273
+ tagAt(idx, 93);
1274
+ spanAt(idx, asStart(n), asEnd(n));
1275
+ recordComments(n, idx);
1276
+ return idx;
1277
+ }
1278
+ function enc_ts_bigint_keyword(n) {
1279
+ const idx = alloc();
1280
+ tagAt(idx, 94);
1281
+ spanAt(idx, asStart(n), asEnd(n));
1282
+ recordComments(n, idx);
1283
+ return idx;
1284
+ }
1285
+ function enc_ts_boolean_keyword(n) {
1286
+ const idx = alloc();
1287
+ tagAt(idx, 95);
1288
+ spanAt(idx, asStart(n), asEnd(n));
1289
+ recordComments(n, idx);
1290
+ return idx;
1291
+ }
1292
+ function enc_ts_symbol_keyword(n) {
1293
+ const idx = alloc();
1294
+ tagAt(idx, 96);
1295
+ spanAt(idx, asStart(n), asEnd(n));
1296
+ recordComments(n, idx);
1297
+ return idx;
1298
+ }
1299
+ function enc_ts_object_keyword(n) {
1300
+ const idx = alloc();
1301
+ tagAt(idx, 97);
1302
+ spanAt(idx, asStart(n), asEnd(n));
1303
+ recordComments(n, idx);
1304
+ return idx;
1305
+ }
1306
+ function enc_ts_intrinsic_keyword(n) {
1307
+ const idx = alloc();
1308
+ tagAt(idx, 98);
1309
+ spanAt(idx, asStart(n), asEnd(n));
1310
+ recordComments(n, idx);
1311
+ return idx;
1312
+ }
1313
+ function enc_ts_this_type(n) {
1314
+ const idx = alloc();
1315
+ tagAt(idx, 99);
1316
+ spanAt(idx, asStart(n), asEnd(n));
1317
+ recordComments(n, idx);
1318
+ return idx;
1319
+ }
1320
+ function enc_ts_type_reference(n) {
1321
+ const c_type_name = n.typeName == null ? NULL : encNode(n.typeName);
1322
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1323
+ const idx = alloc();
1324
+ tagAt(idx, 100);
1325
+ slotAt(idx, 0, c_type_name);
1326
+ slotAt(idx, 1, c_type_arguments);
1327
+ spanAt(idx, asStart(n), asEnd(n));
1328
+ recordComments(n, idx);
1329
+ return idx;
1330
+ }
1331
+ function enc_ts_qualified_name(n) {
1332
+ const c_left = n.left == null ? NULL : encNode(n.left);
1333
+ const c_right = n.right == null ? NULL : encName(n.right);
1334
+ const idx = alloc();
1335
+ tagAt(idx, 101);
1336
+ slotAt(idx, 0, c_left);
1337
+ slotAt(idx, 1, c_right);
1338
+ spanAt(idx, asStart(n), asEnd(n));
1339
+ recordComments(n, idx);
1340
+ return idx;
1341
+ }
1342
+ function enc_ts_type_query(n) {
1343
+ const c_expr_name = n.exprName == null ? NULL : encNode(n.exprName);
1344
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1345
+ const idx = alloc();
1346
+ tagAt(idx, 102);
1347
+ slotAt(idx, 0, c_expr_name);
1348
+ slotAt(idx, 1, c_type_arguments);
1349
+ spanAt(idx, asStart(n), asEnd(n));
1350
+ recordComments(n, idx);
1351
+ return idx;
1352
+ }
1353
+ function enc_ts_import_type(n) {
1354
+ const c_source = n.source == null ? NULL : encNode(n.source);
1355
+ const c_options = n.options == null ? NULL : encNode(n.options);
1356
+ const c_qualifier = n.qualifier == null ? NULL : encName(n.qualifier);
1357
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1358
+ const idx = alloc();
1359
+ tagAt(idx, 103);
1360
+ slotAt(idx, 0, c_source);
1361
+ slotAt(idx, 1, c_options);
1362
+ slotAt(idx, 2, c_qualifier);
1363
+ slotAt(idx, 3, c_type_arguments);
1364
+ spanAt(idx, asStart(n), asEnd(n));
1365
+ recordComments(n, idx);
1366
+ return idx;
1367
+ }
1368
+ function enc_ts_type_parameter(n) {
1369
+ const c_name = n.name == null ? NULL : encBindingTarget(n.name);
1370
+ const c_constraint = n.constraint == null ? NULL : encNode(n.constraint);
1371
+ const c_default = n.default == null ? NULL : encNode(n.default);
1372
+ const idx = alloc();
1373
+ tagAt(idx, 104);
1374
+ slotAt(idx, 0, c_name);
1375
+ slotAt(idx, 1, c_constraint);
1376
+ slotAt(idx, 2, c_default);
1377
+ flagsAt(idx, 0 | (n.in ? 1 : 0) | (n.out ? 2 : 0) | (n.const ? 4 : 0));
1378
+ spanAt(idx, asStart(n), asEnd(n));
1379
+ recordComments(n, idx);
1380
+ return idx;
1381
+ }
1382
+ function enc_ts_type_parameter_declaration(n) {
1383
+ const c_params = encArr(n.params, encNode);
1384
+ const idx = alloc();
1385
+ tagAt(idx, 105);
1386
+ f0At(idx, c_params.len);
1387
+ slotAt(idx, 0, c_params.start);
1388
+ spanAt(idx, asStart(n), asEnd(n));
1389
+ recordComments(n, idx);
1390
+ return idx;
1391
+ }
1392
+ function enc_ts_type_parameter_instantiation(n) {
1393
+ const c_params = encArr(n.params, encNode);
1394
+ const idx = alloc();
1395
+ tagAt(idx, 106);
1396
+ f0At(idx, c_params.len);
1397
+ slotAt(idx, 0, c_params.start);
1398
+ spanAt(idx, asStart(n), asEnd(n));
1399
+ recordComments(n, idx);
1400
+ return idx;
1401
+ }
1402
+ function enc_ts_literal_type(n) {
1403
+ const c_literal = n.literal == null ? NULL : encNode(n.literal);
1404
+ const idx = alloc();
1405
+ tagAt(idx, 107);
1406
+ slotAt(idx, 0, c_literal);
1407
+ spanAt(idx, asStart(n), asEnd(n));
1408
+ recordComments(n, idx);
1409
+ return idx;
1410
+ }
1411
+ function enc_ts_template_literal_type(n) {
1412
+ const c_quasis = encArr(n.quasis, encNode);
1413
+ const c_types = encArr(n.types, encNode);
1414
+ const idx = alloc();
1415
+ tagAt(idx, 108);
1416
+ f0At(idx, c_quasis.len);
1417
+ slotAt(idx, 0, c_quasis.start);
1418
+ slotAt(idx, 1, c_types.start);
1419
+ slotAt(idx, 2, c_types.len);
1420
+ spanAt(idx, asStart(n), asEnd(n));
1421
+ recordComments(n, idx);
1422
+ return idx;
1423
+ }
1424
+ function enc_ts_array_type(n) {
1425
+ const c_element_type = n.elementType == null ? NULL : encNode(n.elementType);
1426
+ const idx = alloc();
1427
+ tagAt(idx, 109);
1428
+ slotAt(idx, 0, c_element_type);
1429
+ spanAt(idx, asStart(n), asEnd(n));
1430
+ recordComments(n, idx);
1431
+ return idx;
1432
+ }
1433
+ function enc_ts_indexed_access_type(n) {
1434
+ const c_object_type = n.objectType == null ? NULL : encNode(n.objectType);
1435
+ const c_index_type = n.indexType == null ? NULL : encNode(n.indexType);
1436
+ const idx = alloc();
1437
+ tagAt(idx, 110);
1438
+ slotAt(idx, 0, c_object_type);
1439
+ slotAt(idx, 1, c_index_type);
1440
+ spanAt(idx, asStart(n), asEnd(n));
1441
+ recordComments(n, idx);
1442
+ return idx;
1443
+ }
1444
+ function enc_ts_tuple_type(n) {
1445
+ const c_element_types = encArr(n.elementTypes, encNode);
1446
+ const idx = alloc();
1447
+ tagAt(idx, 111);
1448
+ f0At(idx, c_element_types.len);
1449
+ slotAt(idx, 0, c_element_types.start);
1450
+ spanAt(idx, asStart(n), asEnd(n));
1451
+ recordComments(n, idx);
1452
+ return idx;
1453
+ }
1454
+ function enc_ts_named_tuple_member(n) {
1455
+ const c_label = n.label == null ? NULL : encNode(n.label);
1456
+ const c_element_type = n.elementType == null ? NULL : encNode(n.elementType);
1457
+ const idx = alloc();
1458
+ tagAt(idx, 112);
1459
+ slotAt(idx, 0, c_label);
1460
+ slotAt(idx, 1, c_element_type);
1461
+ flagsAt(idx, 0 | (n.optional ? 1 : 0));
1462
+ spanAt(idx, asStart(n), asEnd(n));
1463
+ recordComments(n, idx);
1464
+ return idx;
1465
+ }
1466
+ function enc_ts_optional_type(n) {
1467
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1468
+ const idx = alloc();
1469
+ tagAt(idx, 113);
1470
+ slotAt(idx, 0, c_type_annotation);
1471
+ spanAt(idx, asStart(n), asEnd(n));
1472
+ recordComments(n, idx);
1473
+ return idx;
1474
+ }
1475
+ function enc_ts_rest_type(n) {
1476
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1477
+ const idx = alloc();
1478
+ tagAt(idx, 114);
1479
+ slotAt(idx, 0, c_type_annotation);
1480
+ spanAt(idx, asStart(n), asEnd(n));
1481
+ recordComments(n, idx);
1482
+ return idx;
1483
+ }
1484
+ function enc_ts_jsdoc_nullable_type(n) {
1485
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1486
+ const idx = alloc();
1487
+ tagAt(idx, 115);
1488
+ slotAt(idx, 0, c_type_annotation);
1489
+ flagsAt(idx, 0 | (n.postfix ? 1 : 0));
1490
+ spanAt(idx, asStart(n), asEnd(n));
1491
+ recordComments(n, idx);
1492
+ return idx;
1493
+ }
1494
+ function enc_ts_jsdoc_non_nullable_type(n) {
1495
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1496
+ const idx = alloc();
1497
+ tagAt(idx, 116);
1498
+ slotAt(idx, 0, c_type_annotation);
1499
+ flagsAt(idx, 0 | (n.postfix ? 1 : 0));
1500
+ spanAt(idx, asStart(n), asEnd(n));
1501
+ recordComments(n, idx);
1502
+ return idx;
1503
+ }
1504
+ function enc_ts_jsdoc_unknown_type(n) {
1505
+ const idx = alloc();
1506
+ tagAt(idx, 117);
1507
+ spanAt(idx, asStart(n), asEnd(n));
1508
+ recordComments(n, idx);
1509
+ return idx;
1510
+ }
1511
+ function enc_ts_union_type(n) {
1512
+ const c_types = encArr(n.types, encNode);
1513
+ const idx = alloc();
1514
+ tagAt(idx, 118);
1515
+ f0At(idx, c_types.len);
1516
+ slotAt(idx, 0, c_types.start);
1517
+ spanAt(idx, asStart(n), asEnd(n));
1518
+ recordComments(n, idx);
1519
+ return idx;
1520
+ }
1521
+ function enc_ts_intersection_type(n) {
1522
+ const c_types = encArr(n.types, encNode);
1523
+ const idx = alloc();
1524
+ tagAt(idx, 119);
1525
+ f0At(idx, c_types.len);
1526
+ slotAt(idx, 0, c_types.start);
1527
+ spanAt(idx, asStart(n), asEnd(n));
1528
+ recordComments(n, idx);
1529
+ return idx;
1530
+ }
1531
+ function enc_ts_conditional_type(n) {
1532
+ const c_check_type = n.checkType == null ? NULL : encNode(n.checkType);
1533
+ const c_extends_type = n.extendsType == null ? NULL : encNode(n.extendsType);
1534
+ const c_true_type = n.trueType == null ? NULL : encNode(n.trueType);
1535
+ const c_false_type = n.falseType == null ? NULL : encNode(n.falseType);
1536
+ const idx = alloc();
1537
+ tagAt(idx, 120);
1538
+ slotAt(idx, 0, c_check_type);
1539
+ slotAt(idx, 1, c_extends_type);
1540
+ slotAt(idx, 2, c_true_type);
1541
+ slotAt(idx, 3, c_false_type);
1542
+ spanAt(idx, asStart(n), asEnd(n));
1543
+ recordComments(n, idx);
1544
+ return idx;
1545
+ }
1546
+ function enc_ts_infer_type(n) {
1547
+ const c_type_parameter = n.typeParameter == null ? NULL : encNode(n.typeParameter);
1548
+ const idx = alloc();
1549
+ tagAt(idx, 121);
1550
+ slotAt(idx, 0, c_type_parameter);
1551
+ spanAt(idx, asStart(n), asEnd(n));
1552
+ recordComments(n, idx);
1553
+ return idx;
1554
+ }
1555
+ function enc_ts_type_operator(n) {
1556
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1557
+ const idx = alloc();
1558
+ tagAt(idx, 122);
1559
+ slotAt(idx, 0, c_type_annotation);
1560
+ flagsAt(idx, 0 | (TS_TYPE_OPERATORS_INV[n.operator] | 0));
1561
+ spanAt(idx, asStart(n), asEnd(n));
1562
+ recordComments(n, idx);
1563
+ return idx;
1564
+ }
1565
+ function enc_ts_parenthesized_type(n) {
1566
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1567
+ const idx = alloc();
1568
+ tagAt(idx, 123);
1569
+ slotAt(idx, 0, c_type_annotation);
1570
+ spanAt(idx, asStart(n), asEnd(n));
1571
+ recordComments(n, idx);
1572
+ return idx;
1573
+ }
1574
+ function enc_ts_function_type(n) {
1575
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1576
+ const params = encFormalParameters(n.params);
1577
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
1578
+ const idx = alloc();
1579
+ tagAt(idx, 124);
1580
+ slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
1581
+ spanAt(idx, asStart(n), asEnd(n));
1582
+ recordComments(n, idx);
1583
+ return idx;
1584
+ }
1585
+ function enc_ts_constructor_type(n) {
1586
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1587
+ const params = encFormalParameters(n.params);
1588
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
1589
+ const idx = alloc();
1590
+ tagAt(idx, 125);
1591
+ slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
1592
+ flagsAt(idx, n.abstract ? 1 : 0);
1593
+ spanAt(idx, asStart(n), asEnd(n));
1594
+ recordComments(n, idx);
1595
+ return idx;
1596
+ }
1597
+ function enc_ts_type_predicate(n) {
1598
+ const c_parameter_name = n.parameterName == null ? NULL : encNode(n.parameterName);
1599
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1600
+ const idx = alloc();
1601
+ tagAt(idx, 126);
1602
+ slotAt(idx, 0, c_parameter_name);
1603
+ slotAt(idx, 1, c_type_annotation);
1604
+ flagsAt(idx, 0 | (n.asserts ? 1 : 0));
1605
+ spanAt(idx, asStart(n), asEnd(n));
1606
+ recordComments(n, idx);
1607
+ return idx;
1608
+ }
1609
+ function enc_ts_type_literal(n) {
1610
+ const c_members = encArr(n.members, encNode);
1611
+ const idx = alloc();
1612
+ tagAt(idx, 127);
1613
+ f0At(idx, c_members.len);
1614
+ slotAt(idx, 0, c_members.start);
1615
+ spanAt(idx, asStart(n), asEnd(n));
1616
+ recordComments(n, idx);
1617
+ return idx;
1618
+ }
1619
+ function enc_ts_mapped_type(n) {
1620
+ const k = encNode(n.key);
1621
+ const c = encNode(n.constraint);
1622
+ const nt = n.nameType == null ? NULL : encNode(n.nameType);
1623
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1624
+ const idx = alloc();
1625
+ tagAt(idx, 128);
1626
+ slotAt(idx, 0, k); slotAt(idx, 1, c); slotAt(idx, 2, nt); slotAt(idx, 3, ta);
1627
+ flagsAt(idx,
1628
+ (TS_MAPPED_OPTIONAL_INV(n.optional) << 0)
1629
+ | (TS_MAPPED_READONLY_INV(n.readonly) << 2));
1630
+ spanAt(idx, asStart(n), asEnd(n));
1631
+ recordComments(n, idx);
1632
+ return idx;
1633
+ }
1634
+ function enc_ts_property_signature(n) {
1635
+ const k = n.computed ? encNode(n.key) : encName(n.key);
1636
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1637
+ const idx = alloc();
1638
+ tagAt(idx, 129);
1639
+ slotAt(idx, 0, k); slotAt(idx, 1, ta);
1640
+ flagsAt(idx,
1641
+ (n.computed ? 1 : 0)
1642
+ | (n.optional ? 2 : 0)
1643
+ | (n.readonly ? 4 : 0));
1644
+ spanAt(idx, asStart(n), asEnd(n));
1645
+ recordComments(n, idx);
1646
+ return idx;
1647
+ }
1648
+ function enc_ts_method_signature(n) {
1649
+ const k = n.computed ? encNode(n.key) : encName(n.key);
1650
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1651
+ const params = encFormalParameters(n.params);
1652
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
1653
+ const idx = alloc();
1654
+ tagAt(idx, 130);
1655
+ slotAt(idx, 0, k);
1656
+ slotAt(idx, 1, tp);
1657
+ slotAt(idx, 2, params);
1658
+ slotAt(idx, 3, rt_);
1659
+ flagsAt(idx,
1660
+ (n.computed ? 4 : 0)
1661
+ | (n.optional ? 8 : 0)
1662
+ | ((TS_METHOD_SIGNATURE_KINDS_INV[n.kind] | 0) << 0));
1663
+ spanAt(idx, asStart(n), asEnd(n));
1664
+ recordComments(n, idx);
1665
+ return idx;
1666
+ }
1667
+ function enc_ts_call_signature_declaration(n) {
1668
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1669
+ const params = encFormalParameters(n.params);
1670
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
1671
+ const idx = alloc();
1672
+ tagAt(idx, 131);
1673
+ slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
1674
+ spanAt(idx, asStart(n), asEnd(n));
1675
+ recordComments(n, idx);
1676
+ return idx;
1677
+ }
1678
+ function enc_ts_construct_signature_declaration(n) {
1679
+ const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1680
+ const params = encFormalParameters(n.params);
1681
+ const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
1682
+ const idx = alloc();
1683
+ tagAt(idx, 132);
1684
+ slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
1685
+ spanAt(idx, asStart(n), asEnd(n));
1686
+ recordComments(n, idx);
1687
+ return idx;
1688
+ }
1689
+ function enc_ts_index_signature(n) {
1690
+ const ps = encArr(n.parameters, encBindingTarget);
1691
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1692
+ const idx = alloc();
1693
+ tagAt(idx, 133);
1694
+ f0At(idx, ps.len);
1695
+ slotAt(idx, 0, ps.start);
1696
+ slotAt(idx, 1, ta);
1697
+ flagsAt(idx, (n.readonly ? 1 : 0) | (n.static ? 2 : 0));
1698
+ spanAt(idx, asStart(n), asEnd(n));
1699
+ recordComments(n, idx);
1700
+ return idx;
1701
+ }
1702
+ function enc_ts_type_alias_declaration(n) {
1703
+ const c_id = n.id == null ? NULL : encBindingTarget(n.id);
1704
+ const c_type_parameters = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1705
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1706
+ const idx = alloc();
1707
+ tagAt(idx, 134);
1708
+ slotAt(idx, 0, c_id);
1709
+ slotAt(idx, 1, c_type_parameters);
1710
+ slotAt(idx, 2, c_type_annotation);
1711
+ flagsAt(idx, 0 | (n.declare ? 1 : 0));
1712
+ spanAt(idx, asStart(n), asEnd(n));
1713
+ recordComments(n, idx);
1714
+ return idx;
1715
+ }
1716
+ function enc_ts_interface_declaration(n) {
1717
+ const c_id = n.id == null ? NULL : encBindingTarget(n.id);
1718
+ const c_type_parameters = n.typeParameters == null ? NULL : encNode(n.typeParameters);
1719
+ const c_extends = encArr(n.extends, encNode);
1720
+ const c_body = n.body == null ? NULL : encNode(n.body);
1721
+ const idx = alloc();
1722
+ tagAt(idx, 135);
1723
+ slotAt(idx, 0, c_id);
1724
+ slotAt(idx, 1, c_type_parameters);
1725
+ f0At(idx, c_extends.len);
1726
+ slotAt(idx, 2, c_extends.start);
1727
+ slotAt(idx, 3, c_body);
1728
+ flagsAt(idx, 0 | (n.declare ? 1 : 0));
1729
+ spanAt(idx, asStart(n), asEnd(n));
1730
+ recordComments(n, idx);
1731
+ return idx;
1732
+ }
1733
+ function enc_ts_interface_body(n) {
1734
+ const c_body = encArr(n.body, encNode);
1735
+ const idx = alloc();
1736
+ tagAt(idx, 136);
1737
+ f0At(idx, c_body.len);
1738
+ slotAt(idx, 0, c_body.start);
1739
+ spanAt(idx, asStart(n), asEnd(n));
1740
+ recordComments(n, idx);
1741
+ return idx;
1742
+ }
1743
+ function enc_ts_interface_heritage(n) {
1744
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1745
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1746
+ const idx = alloc();
1747
+ tagAt(idx, 137);
1748
+ slotAt(idx, 0, c_expression);
1749
+ slotAt(idx, 1, c_type_arguments);
1750
+ spanAt(idx, asStart(n), asEnd(n));
1751
+ recordComments(n, idx);
1752
+ return idx;
1753
+ }
1754
+ function enc_ts_class_implements(n) {
1755
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1756
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1757
+ const idx = alloc();
1758
+ tagAt(idx, 138);
1759
+ slotAt(idx, 0, c_expression);
1760
+ slotAt(idx, 1, c_type_arguments);
1761
+ spanAt(idx, asStart(n), asEnd(n));
1762
+ recordComments(n, idx);
1763
+ return idx;
1764
+ }
1765
+ function enc_ts_enum_declaration(n) {
1766
+ const c_id = n.id == null ? NULL : encBindingTarget(n.id);
1767
+ const c_body = n.body == null ? NULL : encNode(n.body);
1768
+ const idx = alloc();
1769
+ tagAt(idx, 139);
1770
+ slotAt(idx, 0, c_id);
1771
+ slotAt(idx, 1, c_body);
1772
+ flagsAt(idx, 0 | (n.const ? 1 : 0) | (n.declare ? 2 : 0));
1773
+ spanAt(idx, asStart(n), asEnd(n));
1774
+ recordComments(n, idx);
1775
+ return idx;
1776
+ }
1777
+ function enc_ts_enum_body(n) {
1778
+ const c_members = encArr(n.members, encNode);
1779
+ const idx = alloc();
1780
+ tagAt(idx, 140);
1781
+ f0At(idx, c_members.len);
1782
+ slotAt(idx, 0, c_members.start);
1783
+ spanAt(idx, asStart(n), asEnd(n));
1784
+ recordComments(n, idx);
1785
+ return idx;
1786
+ }
1787
+ function enc_ts_enum_member(n) {
1788
+ const id = n.computed ? encNode(n.id) : encName(n.id);
1789
+ const init = n.initializer == null ? NULL : encNode(n.initializer);
1790
+ const idx = alloc();
1791
+ tagAt(idx, 141);
1792
+ slotAt(idx, 0, id); slotAt(idx, 1, init);
1793
+ flagsAt(idx, n.computed ? 1 : 0);
1794
+ spanAt(idx, asStart(n), asEnd(n));
1795
+ recordComments(n, idx);
1796
+ return idx;
1797
+ }
1798
+ function enc_ts_module_declaration(n) {
1799
+ const id = encNode(n.id);
1800
+ const body = n.body == null ? NULL : encNode(n.body);
1801
+ const idx = alloc();
1802
+ tagAt(idx, 142);
1803
+ slotAt(idx, 0, id);
1804
+ slotAt(idx, 1, body);
1805
+ flagsAt(idx, ((TS_MODULE_KINDS_INV[n.kind] | 0) << 0) | (n.declare ? 2 : 0));
1806
+ spanAt(idx, asStart(n), asEnd(n));
1807
+ recordComments(n, idx);
1808
+ return idx;
1809
+ }
1810
+ function enc_ts_module_block(n) {
1811
+ const c_body = encArr(n.body, encNode);
1812
+ const idx = alloc();
1813
+ tagAt(idx, 143);
1814
+ f0At(idx, c_body.len);
1815
+ slotAt(idx, 0, c_body.start);
1816
+ spanAt(idx, asStart(n), asEnd(n));
1817
+ recordComments(n, idx);
1818
+ return idx;
1819
+ }
1820
+ function enc_ts_global_declaration(n) {
1821
+ const id = encNode(n.id);
1822
+ const body = encNode(n.body);
1823
+ const idx = alloc();
1824
+ tagAt(idx, 144);
1825
+ slotAt(idx, 0, id);
1826
+ slotAt(idx, 1, body);
1827
+ flagsAt(idx, n.declare ? 1 : 0);
1828
+ spanAt(idx, asStart(n), asEnd(n));
1829
+ recordComments(n, idx);
1830
+ return idx;
1831
+ }
1832
+ function enc_ts_parameter_property(n) {
1833
+ const c_decorators = encArr(n.decorators, encNode);
1834
+ const c_parameter = n.parameter == null ? NULL : encBindingTarget(n.parameter);
1835
+ const idx = alloc();
1836
+ tagAt(idx, 145);
1837
+ f0At(idx, c_decorators.len);
1838
+ slotAt(idx, 0, c_decorators.start);
1839
+ slotAt(idx, 1, c_parameter);
1840
+ flagsAt(idx, 0 | (n.override ? 1 : 0) | (n.readonly ? 2 : 0) | (ACCESSIBILITY_INV(n.accessibility) << 2));
1841
+ spanAt(idx, asStart(n), asEnd(n));
1842
+ recordComments(n, idx);
1843
+ return idx;
1844
+ }
1845
+ function enc_ts_this_parameter(n) {
1846
+ const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1847
+ const idx = alloc();
1848
+ tagAt(idx, 146);
1849
+ slotAt(idx, 0, ta);
1850
+ spanAt(idx, asStart(n), asEnd(n));
1851
+ recordComments(n, idx);
1852
+ return idx;
1853
+ }
1854
+ function enc_ts_as_expression(n) {
1855
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1856
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1857
+ const idx = alloc();
1858
+ tagAt(idx, 147);
1859
+ slotAt(idx, 0, c_expression);
1860
+ slotAt(idx, 1, c_type_annotation);
1861
+ spanAt(idx, asStart(n), asEnd(n));
1862
+ recordComments(n, idx);
1863
+ return idx;
1864
+ }
1865
+ function enc_ts_satisfies_expression(n) {
1866
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1867
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1868
+ const idx = alloc();
1869
+ tagAt(idx, 148);
1870
+ slotAt(idx, 0, c_expression);
1871
+ slotAt(idx, 1, c_type_annotation);
1872
+ spanAt(idx, asStart(n), asEnd(n));
1873
+ recordComments(n, idx);
1874
+ return idx;
1875
+ }
1876
+ function enc_ts_type_assertion(n) {
1877
+ const c_type_annotation = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
1878
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1879
+ const idx = alloc();
1880
+ tagAt(idx, 149);
1881
+ slotAt(idx, 0, c_type_annotation);
1882
+ slotAt(idx, 1, c_expression);
1883
+ spanAt(idx, asStart(n), asEnd(n));
1884
+ recordComments(n, idx);
1885
+ return idx;
1886
+ }
1887
+ function enc_ts_non_null_expression(n) {
1888
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1889
+ const idx = alloc();
1890
+ tagAt(idx, 150);
1891
+ slotAt(idx, 0, c_expression);
1892
+ spanAt(idx, asStart(n), asEnd(n));
1893
+ recordComments(n, idx);
1894
+ return idx;
1895
+ }
1896
+ function enc_ts_instantiation_expression(n) {
1897
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1898
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1899
+ const idx = alloc();
1900
+ tagAt(idx, 151);
1901
+ slotAt(idx, 0, c_expression);
1902
+ slotAt(idx, 1, c_type_arguments);
1903
+ spanAt(idx, asStart(n), asEnd(n));
1904
+ recordComments(n, idx);
1905
+ return idx;
1906
+ }
1907
+ function enc_ts_export_assignment(n) {
1908
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1909
+ const idx = alloc();
1910
+ tagAt(idx, 152);
1911
+ slotAt(idx, 0, c_expression);
1912
+ spanAt(idx, asStart(n), asEnd(n));
1913
+ recordComments(n, idx);
1914
+ return idx;
1915
+ }
1916
+ function enc_ts_namespace_export_declaration(n) {
1917
+ const c_id = n.id == null ? NULL : encNode(n.id);
1918
+ const idx = alloc();
1919
+ tagAt(idx, 153);
1920
+ slotAt(idx, 0, c_id);
1921
+ spanAt(idx, asStart(n), asEnd(n));
1922
+ recordComments(n, idx);
1923
+ return idx;
1924
+ }
1925
+ function enc_ts_import_equals_declaration(n) {
1926
+ const c_id = n.id == null ? NULL : encBindingTarget(n.id);
1927
+ const c_module_reference = n.moduleReference == null ? NULL : encNode(n.moduleReference);
1928
+ const idx = alloc();
1929
+ tagAt(idx, 154);
1930
+ slotAt(idx, 0, c_id);
1931
+ slotAt(idx, 1, c_module_reference);
1932
+ flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.importKind] | 0));
1933
+ spanAt(idx, asStart(n), asEnd(n));
1934
+ recordComments(n, idx);
1935
+ return idx;
1936
+ }
1937
+ function enc_ts_external_module_reference(n) {
1938
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
1939
+ const idx = alloc();
1940
+ tagAt(idx, 155);
1941
+ slotAt(idx, 0, c_expression);
1942
+ spanAt(idx, asStart(n), asEnd(n));
1943
+ recordComments(n, idx);
1944
+ return idx;
1945
+ }
1946
+ function enc_jsx_element(n) {
1947
+ const c_opening_element = n.openingElement == null ? NULL : encNode(n.openingElement);
1948
+ const c_children = encArr(n.children, encNode);
1949
+ const c_closing_element = n.closingElement == null ? NULL : encNode(n.closingElement);
1950
+ const idx = alloc();
1951
+ tagAt(idx, 156);
1952
+ slotAt(idx, 0, c_opening_element);
1953
+ f0At(idx, c_children.len);
1954
+ slotAt(idx, 1, c_children.start);
1955
+ slotAt(idx, 2, c_closing_element);
1956
+ spanAt(idx, asStart(n), asEnd(n));
1957
+ recordComments(n, idx);
1958
+ return idx;
1959
+ }
1960
+ function enc_jsx_opening_element(n) {
1961
+ const c_name = n.name == null ? NULL : encNode(n.name);
1962
+ const c_attributes = encArr(n.attributes, encNode);
1963
+ const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
1964
+ const idx = alloc();
1965
+ tagAt(idx, 157);
1966
+ slotAt(idx, 0, c_name);
1967
+ f0At(idx, c_attributes.len);
1968
+ slotAt(idx, 1, c_attributes.start);
1969
+ slotAt(idx, 2, c_type_arguments);
1970
+ flagsAt(idx, 0 | (n.selfClosing ? 1 : 0));
1971
+ spanAt(idx, asStart(n), asEnd(n));
1972
+ recordComments(n, idx);
1973
+ return idx;
1974
+ }
1975
+ function enc_jsx_closing_element(n) {
1976
+ const c_name = n.name == null ? NULL : encNode(n.name);
1977
+ const idx = alloc();
1978
+ tagAt(idx, 158);
1979
+ slotAt(idx, 0, c_name);
1980
+ spanAt(idx, asStart(n), asEnd(n));
1981
+ recordComments(n, idx);
1982
+ return idx;
1983
+ }
1984
+ function enc_jsx_fragment(n) {
1985
+ const c_opening_fragment = n.openingFragment == null ? NULL : encNode(n.openingFragment);
1986
+ const c_children = encArr(n.children, encNode);
1987
+ const c_closing_fragment = n.closingFragment == null ? NULL : encNode(n.closingFragment);
1988
+ const idx = alloc();
1989
+ tagAt(idx, 159);
1990
+ slotAt(idx, 0, c_opening_fragment);
1991
+ f0At(idx, c_children.len);
1992
+ slotAt(idx, 1, c_children.start);
1993
+ slotAt(idx, 2, c_closing_fragment);
1994
+ spanAt(idx, asStart(n), asEnd(n));
1995
+ recordComments(n, idx);
1996
+ return idx;
1997
+ }
1998
+ function enc_jsx_opening_fragment(n) {
1999
+ const idx = alloc();
2000
+ tagAt(idx, 160);
2001
+ spanAt(idx, asStart(n), asEnd(n));
2002
+ recordComments(n, idx);
2003
+ return idx;
2004
+ }
2005
+ function enc_jsx_closing_fragment(n) {
2006
+ const idx = alloc();
2007
+ tagAt(idx, 161);
2008
+ spanAt(idx, asStart(n), asEnd(n));
2009
+ recordComments(n, idx);
2010
+ return idx;
2011
+ }
2012
+ function enc_jsx_identifier(n) {
2013
+ const c_name = encStr(n.name);
2014
+ const idx = alloc();
2015
+ tagAt(idx, 162);
2016
+ slotAt(idx, 0, c_name.start);
2017
+ slotAt(idx, 1, c_name.end);
2018
+ spanAt(idx, asStart(n), asEnd(n));
2019
+ recordComments(n, idx);
2020
+ return idx;
2021
+ }
2022
+ function enc_jsx_namespaced_name(n) {
2023
+ const c_namespace = n.namespace == null ? NULL : encNode(n.namespace);
2024
+ const c_name = n.name == null ? NULL : encNode(n.name);
2025
+ const idx = alloc();
2026
+ tagAt(idx, 163);
2027
+ slotAt(idx, 0, c_namespace);
2028
+ slotAt(idx, 1, c_name);
2029
+ spanAt(idx, asStart(n), asEnd(n));
2030
+ recordComments(n, idx);
2031
+ return idx;
2032
+ }
2033
+ function enc_jsx_member_expression(n) {
2034
+ const c_object = n.object == null ? NULL : encNode(n.object);
2035
+ const c_property = n.property == null ? NULL : encNode(n.property);
2036
+ const idx = alloc();
2037
+ tagAt(idx, 164);
2038
+ slotAt(idx, 0, c_object);
2039
+ slotAt(idx, 1, c_property);
2040
+ spanAt(idx, asStart(n), asEnd(n));
2041
+ recordComments(n, idx);
2042
+ return idx;
2043
+ }
2044
+ function enc_jsx_attribute(n) {
2045
+ const c_name = n.name == null ? NULL : encNode(n.name);
2046
+ const c_value = n.value == null ? NULL : encNode(n.value);
2047
+ const idx = alloc();
2048
+ tagAt(idx, 165);
2049
+ slotAt(idx, 0, c_name);
2050
+ slotAt(idx, 1, c_value);
2051
+ spanAt(idx, asStart(n), asEnd(n));
2052
+ recordComments(n, idx);
2053
+ return idx;
2054
+ }
2055
+ function enc_jsx_spread_attribute(n) {
2056
+ const c_argument = n.argument == null ? NULL : encNode(n.argument);
2057
+ const idx = alloc();
2058
+ tagAt(idx, 166);
2059
+ slotAt(idx, 0, c_argument);
2060
+ spanAt(idx, asStart(n), asEnd(n));
2061
+ recordComments(n, idx);
2062
+ return idx;
2063
+ }
2064
+ function enc_jsx_expression_container(n) {
2065
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
2066
+ const idx = alloc();
2067
+ tagAt(idx, 167);
2068
+ slotAt(idx, 0, c_expression);
2069
+ spanAt(idx, asStart(n), asEnd(n));
2070
+ recordComments(n, idx);
2071
+ return idx;
2072
+ }
2073
+ function enc_jsx_empty_expression(n) {
2074
+ const idx = alloc();
2075
+ tagAt(idx, 168);
2076
+ spanAt(idx, asStart(n), asEnd(n));
2077
+ recordComments(n, idx);
2078
+ return idx;
2079
+ }
2080
+ function enc_jsx_text(n) {
2081
+ const v = encStr(n.value || "");
2082
+ const idx = alloc();
2083
+ tagAt(idx, 169);
2084
+ slotAt(idx, 0, v.start); slotAt(idx, 1, v.end);
2085
+ spanAt(idx, asStart(n), asEnd(n));
2086
+ recordComments(n, idx);
2087
+ return idx;
2088
+ }
2089
+ function enc_jsx_spread_child(n) {
2090
+ const c_expression = n.expression == null ? NULL : encNode(n.expression);
2091
+ const idx = alloc();
2092
+ tagAt(idx, 170);
2093
+ slotAt(idx, 0, c_expression);
2094
+ spanAt(idx, asStart(n), asEnd(n));
2095
+ recordComments(n, idx);
2096
+ return idx;
2097
+ }
2098
+ const commentsByIdx = new Map();
2099
+ function encNode(n) {
2100
+ if (n == null) return NULL;
2101
+ switch (n.type) {
2102
+ case "Identifier": return enc_identifier_reference(n);
2103
+ case "PrivateIdentifier": return enc_private_identifier(n);
2104
+ case "Literal": {
2105
+ if (n.regex) return enc_regexp_literal(n);
2106
+ if (typeof n.bigint === "string") return enc_bigint_literal(n);
2107
+ const v = n.value;
2108
+ if (v === null) return typeof n.raw === "string" && n.raw !== "null"
2109
+ ? enc_numeric_literal(n)
2110
+ : enc_null_literal(n);
2111
+ if (typeof v === "boolean") return enc_boolean_literal(n);
2112
+ if (typeof v === "string") return enc_string_literal(n);
2113
+ if (typeof v === "number") return enc_numeric_literal(n);
2114
+ throw new Error("yuku-codegen: unrecognised Literal value");
2115
+ }
2116
+ case "FunctionDeclaration": return enc_function(n, 0);
2117
+ case "FunctionExpression": return enc_function(n, 1);
2118
+ case "TSDeclareFunction": return enc_function(n, 2);
2119
+ case "TSEmptyBodyFunctionExpression": return enc_function(n, 3);
2120
+ case "ClassDeclaration": return enc_class(n, 0);
2121
+ case "ClassExpression": return enc_class(n, 1);
2122
+ case "MethodDefinition": return enc_method_definition(n, false);
2123
+ case "TSAbstractMethodDefinition": return enc_method_definition(n, true);
2124
+ case "PropertyDefinition": return enc_property_definition(n, false, false);
2125
+ case "TSAbstractPropertyDefinition": return enc_property_definition(n, false, true);
2126
+ case "AccessorProperty": return enc_property_definition(n, true, false);
2127
+ case "TSAbstractAccessorProperty": return enc_property_definition(n, true, true);
2128
+ case "RestElement": return enc_binding_rest_element(n);
2129
+ case "TSModuleDeclaration": return n.global
2130
+ ? enc_ts_global_declaration(n)
2131
+ : enc_ts_module_declaration(n);
2132
+ case "ExpressionStatement": return n.directive != null
2133
+ ? enc_directive(n)
2134
+ : enc_expression_statement(n);
2135
+ case "SequenceExpression": return enc_sequence_expression(n);
2136
+ case "ParenthesizedExpression": return enc_parenthesized_expression(n);
2137
+ case "ArrowFunctionExpression": return enc_arrow_function_expression(n);
2138
+ case "BlockStatement": return enc_block_statement(n);
2139
+ case "BinaryExpression": return enc_binary_expression(n);
2140
+ case "LogicalExpression": return enc_logical_expression(n);
2141
+ case "ConditionalExpression": return enc_conditional_expression(n);
2142
+ case "UnaryExpression": return enc_unary_expression(n);
2143
+ case "UpdateExpression": return enc_update_expression(n);
2144
+ case "AssignmentExpression": return enc_assignment_expression(n);
2145
+ case "ArrayExpression": return enc_array_expression(n);
2146
+ case "ObjectExpression": return enc_object_expression(n);
2147
+ case "SpreadElement": return enc_spread_element(n);
2148
+ case "Property": return enc_object_property(n);
2149
+ case "MemberExpression": return enc_member_expression(n);
2150
+ case "CallExpression": return enc_call_expression(n);
2151
+ case "ChainExpression": return enc_chain_expression(n);
2152
+ case "TaggedTemplateExpression": return enc_tagged_template_expression(n);
2153
+ case "NewExpression": return enc_new_expression(n);
2154
+ case "AwaitExpression": return enc_await_expression(n);
2155
+ case "YieldExpression": return enc_yield_expression(n);
2156
+ case "MetaProperty": return enc_meta_property(n);
2157
+ case "Decorator": return enc_decorator(n);
2158
+ case "ClassBody": return enc_class_body(n);
2159
+ case "StaticBlock": return enc_static_block(n);
2160
+ case "Super": return enc_super(n);
2161
+ case "ThisExpression": return enc_this_expression(n);
2162
+ case "TemplateLiteral": return enc_template_literal(n);
2163
+ case "TemplateElement": return enc_template_element(n);
2164
+ case "IfStatement": return enc_if_statement(n);
2165
+ case "SwitchStatement": return enc_switch_statement(n);
2166
+ case "SwitchCase": return enc_switch_case(n);
2167
+ case "ForStatement": return enc_for_statement(n);
2168
+ case "ForInStatement": return enc_for_in_statement(n);
2169
+ case "ForOfStatement": return enc_for_of_statement(n);
2170
+ case "WhileStatement": return enc_while_statement(n);
2171
+ case "DoWhileStatement": return enc_do_while_statement(n);
2172
+ case "BreakStatement": return enc_break_statement(n);
2173
+ case "ContinueStatement": return enc_continue_statement(n);
2174
+ case "LabeledStatement": return enc_labeled_statement(n);
2175
+ case "WithStatement": return enc_with_statement(n);
2176
+ case "ReturnStatement": return enc_return_statement(n);
2177
+ case "ThrowStatement": return enc_throw_statement(n);
2178
+ case "TryStatement": return enc_try_statement(n);
2179
+ case "CatchClause": return enc_catch_clause(n);
2180
+ case "DebuggerStatement": return enc_debugger_statement(n);
2181
+ case "EmptyStatement": return enc_empty_statement(n);
2182
+ case "VariableDeclaration": return enc_variable_declaration(n);
2183
+ case "VariableDeclarator": return enc_variable_declarator(n);
2184
+ case "AssignmentPattern": return enc_assignment_pattern(n);
2185
+ case "ArrayPattern": return enc_array_pattern(n);
2186
+ case "ObjectPattern": return enc_object_pattern(n);
2187
+ case "Program": return enc_program(n);
2188
+ case "ImportExpression": return enc_import_expression(n);
2189
+ case "ImportDeclaration": return enc_import_declaration(n);
2190
+ case "ImportSpecifier": return enc_import_specifier(n);
2191
+ case "ImportDefaultSpecifier": return enc_import_default_specifier(n);
2192
+ case "ImportNamespaceSpecifier": return enc_import_namespace_specifier(n);
2193
+ case "ImportAttribute": return enc_import_attribute(n);
2194
+ case "ExportNamedDeclaration": return enc_export_named_declaration(n);
2195
+ case "ExportDefaultDeclaration": return enc_export_default_declaration(n);
2196
+ case "ExportAllDeclaration": return enc_export_all_declaration(n);
2197
+ case "ExportSpecifier": return enc_export_specifier(n);
2198
+ case "TSTypeAnnotation": return enc_ts_type_annotation(n);
2199
+ case "TSAnyKeyword": return enc_ts_any_keyword(n);
2200
+ case "TSUnknownKeyword": return enc_ts_unknown_keyword(n);
2201
+ case "TSNeverKeyword": return enc_ts_never_keyword(n);
2202
+ case "TSVoidKeyword": return enc_ts_void_keyword(n);
2203
+ case "TSNullKeyword": return enc_ts_null_keyword(n);
2204
+ case "TSUndefinedKeyword": return enc_ts_undefined_keyword(n);
2205
+ case "TSStringKeyword": return enc_ts_string_keyword(n);
2206
+ case "TSNumberKeyword": return enc_ts_number_keyword(n);
2207
+ case "TSBigIntKeyword": return enc_ts_bigint_keyword(n);
2208
+ case "TSBooleanKeyword": return enc_ts_boolean_keyword(n);
2209
+ case "TSSymbolKeyword": return enc_ts_symbol_keyword(n);
2210
+ case "TSObjectKeyword": return enc_ts_object_keyword(n);
2211
+ case "TSIntrinsicKeyword": return enc_ts_intrinsic_keyword(n);
2212
+ case "TSThisType": return enc_ts_this_type(n);
2213
+ case "TSTypeReference": return enc_ts_type_reference(n);
2214
+ case "TSQualifiedName": return enc_ts_qualified_name(n);
2215
+ case "TSTypeQuery": return enc_ts_type_query(n);
2216
+ case "TSImportType": return enc_ts_import_type(n);
2217
+ case "TSTypeParameter": return enc_ts_type_parameter(n);
2218
+ case "TSTypeParameterDeclaration": return enc_ts_type_parameter_declaration(n);
2219
+ case "TSTypeParameterInstantiation": return enc_ts_type_parameter_instantiation(n);
2220
+ case "TSLiteralType": return enc_ts_literal_type(n);
2221
+ case "TSTemplateLiteralType": return enc_ts_template_literal_type(n);
2222
+ case "TSArrayType": return enc_ts_array_type(n);
2223
+ case "TSIndexedAccessType": return enc_ts_indexed_access_type(n);
2224
+ case "TSTupleType": return enc_ts_tuple_type(n);
2225
+ case "TSNamedTupleMember": return enc_ts_named_tuple_member(n);
2226
+ case "TSOptionalType": return enc_ts_optional_type(n);
2227
+ case "TSRestType": return enc_ts_rest_type(n);
2228
+ case "TSJSDocNullableType": return enc_ts_jsdoc_nullable_type(n);
2229
+ case "TSJSDocNonNullableType": return enc_ts_jsdoc_non_nullable_type(n);
2230
+ case "TSJSDocUnknownType": return enc_ts_jsdoc_unknown_type(n);
2231
+ case "TSUnionType": return enc_ts_union_type(n);
2232
+ case "TSIntersectionType": return enc_ts_intersection_type(n);
2233
+ case "TSConditionalType": return enc_ts_conditional_type(n);
2234
+ case "TSInferType": return enc_ts_infer_type(n);
2235
+ case "TSTypeOperator": return enc_ts_type_operator(n);
2236
+ case "TSParenthesizedType": return enc_ts_parenthesized_type(n);
2237
+ case "TSFunctionType": return enc_ts_function_type(n);
2238
+ case "TSConstructorType": return enc_ts_constructor_type(n);
2239
+ case "TSTypePredicate": return enc_ts_type_predicate(n);
2240
+ case "TSTypeLiteral": return enc_ts_type_literal(n);
2241
+ case "TSMappedType": return enc_ts_mapped_type(n);
2242
+ case "TSPropertySignature": return enc_ts_property_signature(n);
2243
+ case "TSMethodSignature": return enc_ts_method_signature(n);
2244
+ case "TSCallSignatureDeclaration": return enc_ts_call_signature_declaration(n);
2245
+ case "TSConstructSignatureDeclaration": return enc_ts_construct_signature_declaration(n);
2246
+ case "TSIndexSignature": return enc_ts_index_signature(n);
2247
+ case "TSTypeAliasDeclaration": return enc_ts_type_alias_declaration(n);
2248
+ case "TSInterfaceDeclaration": return enc_ts_interface_declaration(n);
2249
+ case "TSInterfaceBody": return enc_ts_interface_body(n);
2250
+ case "TSInterfaceHeritage": return enc_ts_interface_heritage(n);
2251
+ case "TSClassImplements": return enc_ts_class_implements(n);
2252
+ case "TSEnumDeclaration": return enc_ts_enum_declaration(n);
2253
+ case "TSEnumBody": return enc_ts_enum_body(n);
2254
+ case "TSEnumMember": return enc_ts_enum_member(n);
2255
+ case "TSModuleBlock": return enc_ts_module_block(n);
2256
+ case "TSParameterProperty": return enc_ts_parameter_property(n);
2257
+ case "TSAsExpression": return enc_ts_as_expression(n);
2258
+ case "TSSatisfiesExpression": return enc_ts_satisfies_expression(n);
2259
+ case "TSTypeAssertion": return enc_ts_type_assertion(n);
2260
+ case "TSNonNullExpression": return enc_ts_non_null_expression(n);
2261
+ case "TSInstantiationExpression": return enc_ts_instantiation_expression(n);
2262
+ case "TSExportAssignment": return enc_ts_export_assignment(n);
2263
+ case "TSNamespaceExportDeclaration": return enc_ts_namespace_export_declaration(n);
2264
+ case "TSImportEqualsDeclaration": return enc_ts_import_equals_declaration(n);
2265
+ case "TSExternalModuleReference": return enc_ts_external_module_reference(n);
2266
+ case "JSXElement": return enc_jsx_element(n);
2267
+ case "JSXOpeningElement": return enc_jsx_opening_element(n);
2268
+ case "JSXClosingElement": return enc_jsx_closing_element(n);
2269
+ case "JSXFragment": return enc_jsx_fragment(n);
2270
+ case "JSXOpeningFragment": return enc_jsx_opening_fragment(n);
2271
+ case "JSXClosingFragment": return enc_jsx_closing_fragment(n);
2272
+ case "JSXIdentifier": return enc_jsx_identifier(n);
2273
+ case "JSXNamespacedName": return enc_jsx_namespaced_name(n);
2274
+ case "JSXMemberExpression": return enc_jsx_member_expression(n);
2275
+ case "JSXAttribute": return enc_jsx_attribute(n);
2276
+ case "JSXSpreadAttribute": return enc_jsx_spread_attribute(n);
2277
+ case "JSXExpressionContainer": return enc_jsx_expression_container(n);
2278
+ case "JSXEmptyExpression": return enc_jsx_empty_expression(n);
2279
+ case "JSXText": return enc_jsx_text(n);
2280
+ case "JSXSpreadChild": return enc_jsx_spread_child(n);
2281
+ default: throw new Error("yuku-codegen: unsupported ESTree node type: " + n.type);
2282
+ }
2283
+ }
2284
+ const progIdx = encNode(root);
2285
+ const POSITION_INV = { "before": 0, "after": 1, "inside": 2 };
2286
+ const attached = commentsByIdx.size > 0;
2287
+ let attachedCount = 0;
2288
+ let offsetsBytes = null;
2289
+ let attachedBytes = null;
2290
+ if (attached) {
2291
+ for (const arr of commentsByIdx.values()) attachedCount += arr.length;
2292
+ const offsets = new Uint32Array(nodeCount + 1);
2293
+ for (const [idx, arr] of commentsByIdx) offsets[idx] = arr.length;
2294
+ let sum = 0;
2295
+ for (let i = 0; i < nodeCount; i++) {
2296
+ const c = offsets[i];
2297
+ offsets[i] = sum;
2298
+ sum += c;
2299
+ }
2300
+ offsets[nodeCount] = sum;
2301
+ offsetsBytes = offsets.buffer;
2302
+ attachedBytes = new ArrayBuffer(attachedCount * ATTACHED_COMMENT_SIZE);
2303
+ const cU8 = new Uint8Array(attachedBytes);
2304
+ const cDV = new DataView(attachedBytes);
2305
+ const cursor = new Uint32Array(nodeCount);
2306
+ for (const [idx, arr] of commentsByIdx) {
2307
+ for (let j = 0; j < arr.length; j++) {
2308
+ const c = arr[j];
2309
+ const slot = offsets[idx] + cursor[idx]; cursor[idx]++;
2310
+ let f = 0;
2311
+ if (c.type === "Block") f |= 1;
2312
+ f |= ((POSITION_INV[c.position] ?? 0) & 3) << 1;
2313
+ if (c.sameLine) f |= 8;
2314
+ const v = encStr(typeof c.value === "string" ? c.value : "");
2315
+ const o = slot * ATTACHED_COMMENT_SIZE;
2316
+ cU8[o + ATTACHED_COMMENT_FLAGS_OFFSET] = f;
2317
+ cDV.setUint32(o + ATTACHED_COMMENT_VALUE_START_OFFSET, v.start, true);
2318
+ cDV.setUint32(o + ATTACHED_COMMENT_VALUE_END_OFFSET, v.end, true);
2319
+ }
2320
+ }
2321
+ }
2322
+ const lineStartsCount = Array.isArray(lineStarts) ? lineStarts.length : 0;
2323
+ let lineStartsBytes = null;
2324
+ if (lineStartsCount > 0) {
2325
+ lineStartsBytes = new ArrayBuffer(lineStartsCount * 4);
2326
+ const lsDV = new DataView(lineStartsBytes);
2327
+ for (let i = 0; i < lineStartsCount; i++) {
2328
+ lsDV.setUint32(i * 4, lineStarts[i] >>> 0, true);
2329
+ }
2330
+ }
2331
+ const totalNodeBytes = nodeCount * NODE_SIZE;
2332
+ const totalExtraBytes = extraCount * 4;
2333
+ const totalOffsetsBytes = attached ? (nodeCount + 1) * 4 : 0;
2334
+ const totalAttachedBytes = attachedCount * ATTACHED_COMMENT_SIZE;
2335
+ const totalLineStartsBytes = lineStartsCount * 4;
2336
+ const finalSize =
2337
+ HEADER_SIZE + totalNodeBytes + totalExtraBytes + poolLen +
2338
+ totalOffsetsBytes + totalAttachedBytes + totalLineStartsBytes;
2339
+ const out = new ArrayBuffer(finalSize);
2340
+ const outU8 = new Uint8Array(out);
2341
+ const outU32 = new Uint32Array(out, 0, (finalSize >>> 2));
2342
+ outU32[0] = nodeCount;
2343
+ outU32[1] = extraCount;
2344
+ outU32[2] = poolLen;
2345
+ outU32[3] = 0;
2346
+ outU32[4] = 0;
2347
+ outU32[5] = attachedCount;
2348
+ outU32[6] = lineStartsCount;
2349
+ outU32[7] = 0;
2350
+ outU32[8] = progIdx;
2351
+ outU32[9] = attached ? FLAG_ATTACHED_COMMENTS : 0;
2352
+ outU32[10] = 0;
2353
+ const nodesOff = HEADER_SIZE;
2354
+ const extrasOff = nodesOff + totalNodeBytes;
2355
+ const poolOff = extrasOff + totalExtraBytes;
2356
+ const offsetsOff = poolOff + poolLen;
2357
+ const attachedOff = offsetsOff + totalOffsetsBytes;
2358
+ const lineStartsOff = attachedOff + totalAttachedBytes;
2359
+ outU8.set(new Uint8Array(nodeAB, 0, totalNodeBytes), nodesOff);
2360
+ outU8.set(new Uint8Array(extras.buffer, 0, totalExtraBytes), extrasOff);
2361
+ outU8.set(pool.subarray(0, poolLen), poolOff);
2362
+ if (offsetsBytes !== null) outU8.set(new Uint8Array(offsetsBytes), offsetsOff);
2363
+ if (attachedBytes !== null) outU8.set(new Uint8Array(attachedBytes), attachedOff);
2364
+ if (lineStartsBytes !== null) outU8.set(new Uint8Array(lineStartsBytes), lineStartsOff);
2365
+ return out;
2366
+ }
2367
+ export { encode };