yuku-codegen 0.5.14 → 0.5.16
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/README.md +23 -24
- package/encode.js +294 -46
- package/index.d.ts +10 -5
- package/index.js +21 -8
- package/package.json +13 -13
package/encode.js
CHANGED
|
@@ -10,13 +10,11 @@ const NODE_FIELD0_OFFSET = 4;
|
|
|
10
10
|
const NODE_HEADER_U32S = 2;
|
|
11
11
|
const NODE_SPAN_START_U32 = 10;
|
|
12
12
|
const NODE_SPAN_END_U32 = 11;
|
|
13
|
-
const COMMENT_SIZE =
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const COMMENT_VALUE_START_OFFSET = 12;
|
|
19
|
-
const COMMENT_VALUE_END_OFFSET = 16;
|
|
13
|
+
const COMMENT_SIZE = 12;
|
|
14
|
+
const COMMENT_FLAGS_OFFSET = 0;
|
|
15
|
+
const COMMENT_VALUE_START_OFFSET = 4;
|
|
16
|
+
const COMMENT_VALUE_END_OFFSET = 8;
|
|
17
|
+
const FLAG_ATTACH_COMMENTS = 2;
|
|
20
18
|
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};
|
|
21
19
|
const LOGICAL_OPS_INV = {"&&": 0, "||": 1, "??": 2};
|
|
22
20
|
const UNARY_OPS_INV = {"-": 0, "+": 1, "!": 2, "~": 3, "typeof": 4, "void": 5, "delete": 6};
|
|
@@ -30,10 +28,16 @@ const TS_TYPE_OPERATORS_INV = {"keyof": 0, "unique": 1, "readonly": 2};
|
|
|
30
28
|
const TS_METHOD_SIGNATURE_KINDS_INV = {"method": 0, "get": 1, "set": 2};
|
|
31
29
|
const TS_MODULE_KINDS_INV = {"namespace": 0, "module": 1};
|
|
32
30
|
const IMPORT_PHASE_INV = {"source": 0, "defer": 1};
|
|
33
|
-
const ACCESSIBILITY_INV = (v) =>
|
|
31
|
+
const ACCESSIBILITY_INV = (v) =>
|
|
32
|
+
v == null ? 0
|
|
33
|
+
: v === "public" ? 1
|
|
34
|
+
: v === "private" ? 2
|
|
35
|
+
: 3;
|
|
34
36
|
const TS_MAPPED_OPTIONAL_INV = (v) => v === true ? 1 : v === "+" ? 2 : v === "-" ? 3 : 0;
|
|
35
37
|
const TS_MAPPED_READONLY_INV = (v) => v === true ? 1 : v === "+" ? 2 : v === "-" ? 3 : 0;
|
|
36
|
-
function encode(
|
|
38
|
+
function encode(result) {
|
|
39
|
+
const root = result.program;
|
|
40
|
+
const lineStarts = result.lineStarts;
|
|
37
41
|
let nodeCap = 512;
|
|
38
42
|
let nodeAB = new ArrayBuffer(nodeCap * NODE_SIZE);
|
|
39
43
|
let nU8 = new Uint8Array(nodeAB);
|
|
@@ -103,7 +107,10 @@ function encode(estree, comments, lineStarts) {
|
|
|
103
107
|
if (!arr || arr.length === 0) return { start: 0, len: 0 };
|
|
104
108
|
const len = arr.length;
|
|
105
109
|
const ids = new Array(len);
|
|
106
|
-
for (let i = 0; i < len; i++) {
|
|
110
|
+
for (let i = 0; i < len; i++) {
|
|
111
|
+
const e = arr[i];
|
|
112
|
+
ids[i] = e == null ? NULL : encEach(e);
|
|
113
|
+
}
|
|
107
114
|
const start = extraCount;
|
|
108
115
|
for (let i = 0; i < len; i++) pushExtra(ids[i]);
|
|
109
116
|
return { start, len };
|
|
@@ -126,6 +133,12 @@ function encode(estree, comments, lineStarts) {
|
|
|
126
133
|
}
|
|
127
134
|
function asStart(n) { return (n && typeof n.start === "number") ? n.start : 0; }
|
|
128
135
|
function asEnd(n) { return (n && typeof n.end === "number") ? n.end : 0; }
|
|
136
|
+
// called by every enc_* to register the node's `.comments` array
|
|
137
|
+
function recordComments(n, idx) {
|
|
138
|
+
if (idx !== NULL && n && Array.isArray(n.comments) && n.comments.length > 0) {
|
|
139
|
+
commentsByIdx.set(idx, n.comments);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
129
142
|
function encBindingTarget(n) {
|
|
130
143
|
if (n == null) return NULL;
|
|
131
144
|
if (n.type === "Identifier") return enc_binding_identifier(n);
|
|
@@ -147,6 +160,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
147
160
|
f0At(idx, c_expressions.len);
|
|
148
161
|
slotAt(idx, 0, c_expressions.start);
|
|
149
162
|
spanAt(idx, asStart(n), asEnd(n));
|
|
163
|
+
recordComments(n, idx);
|
|
150
164
|
return idx;
|
|
151
165
|
}
|
|
152
166
|
function enc_parenthesized_expression(n) {
|
|
@@ -155,6 +169,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
155
169
|
tagAt(idx, 1);
|
|
156
170
|
slotAt(idx, 0, c_expression);
|
|
157
171
|
spanAt(idx, asStart(n), asEnd(n));
|
|
172
|
+
recordComments(n, idx);
|
|
158
173
|
return idx;
|
|
159
174
|
}
|
|
160
175
|
function enc_arrow_function_expression(n) {
|
|
@@ -170,6 +185,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
170
185
|
slotAt(idx, 3, rt_);
|
|
171
186
|
flagsAt(idx, (n.expression ? 1 : 0) | (n.async ? 2 : 0));
|
|
172
187
|
spanAt(idx, asStart(n), asEnd(n));
|
|
188
|
+
recordComments(n, idx);
|
|
173
189
|
return idx;
|
|
174
190
|
}
|
|
175
191
|
function enc_function(n, kind) {
|
|
@@ -185,8 +201,13 @@ function encode(estree, comments, lineStarts) {
|
|
|
185
201
|
slotAt(idx, 2, body);
|
|
186
202
|
slotAt(idx, 3, tp);
|
|
187
203
|
slotAt(idx, 4, rt_);
|
|
188
|
-
flagsAt(idx,
|
|
204
|
+
flagsAt(idx,
|
|
205
|
+
((kind & 3) << 0)
|
|
206
|
+
| (n.generator ? 4 : 0)
|
|
207
|
+
| (n.async ? 8 : 0)
|
|
208
|
+
| (n.declare ? 16 : 0));
|
|
189
209
|
spanAt(idx, asStart(n), asEnd(n));
|
|
210
|
+
recordComments(n, idx);
|
|
190
211
|
return idx;
|
|
191
212
|
}
|
|
192
213
|
function enc_block_statement(n) {
|
|
@@ -196,6 +217,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
196
217
|
f0At(idx, c_body.len);
|
|
197
218
|
slotAt(idx, 0, c_body.start);
|
|
198
219
|
spanAt(idx, asStart(n), asEnd(n));
|
|
220
|
+
recordComments(n, idx);
|
|
199
221
|
return idx;
|
|
200
222
|
}
|
|
201
223
|
function encFormalParameters(params) {
|
|
@@ -211,7 +233,8 @@ function encode(estree, comments, lineStarts) {
|
|
|
211
233
|
const p = params[i];
|
|
212
234
|
if (p && p.type === "RestElement") rest = enc_binding_rest_element(p);
|
|
213
235
|
else if (p && p.type === "TSParameterProperty") items.push(encNode(p));
|
|
214
|
-
else if (p && p.type === "Identifier" && p.name === "this")
|
|
236
|
+
else if (p && p.type === "Identifier" && p.name === "this")
|
|
237
|
+
items.push(enc_ts_this_parameter(p));
|
|
215
238
|
else items.push(enc_formal_parameter(p));
|
|
216
239
|
}
|
|
217
240
|
const ids = items;
|
|
@@ -231,6 +254,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
231
254
|
tagAt(idx, 7);
|
|
232
255
|
slotAt(idx, 0, pat);
|
|
233
256
|
spanAt(idx, asStart(p), asEnd(p));
|
|
257
|
+
recordComments(p, idx);
|
|
234
258
|
return idx;
|
|
235
259
|
}
|
|
236
260
|
function enc_binary_expression(n) {
|
|
@@ -242,6 +266,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
242
266
|
slotAt(idx, 1, c_right);
|
|
243
267
|
flagsAt(idx, 0 | (BINARY_OPS_INV[n.operator] | 0));
|
|
244
268
|
spanAt(idx, asStart(n), asEnd(n));
|
|
269
|
+
recordComments(n, idx);
|
|
245
270
|
return idx;
|
|
246
271
|
}
|
|
247
272
|
function enc_logical_expression(n) {
|
|
@@ -253,6 +278,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
253
278
|
slotAt(idx, 1, c_right);
|
|
254
279
|
flagsAt(idx, 0 | (LOGICAL_OPS_INV[n.operator] | 0));
|
|
255
280
|
spanAt(idx, asStart(n), asEnd(n));
|
|
281
|
+
recordComments(n, idx);
|
|
256
282
|
return idx;
|
|
257
283
|
}
|
|
258
284
|
function enc_conditional_expression(n) {
|
|
@@ -265,6 +291,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
265
291
|
slotAt(idx, 1, c_consequent);
|
|
266
292
|
slotAt(idx, 2, c_alternate);
|
|
267
293
|
spanAt(idx, asStart(n), asEnd(n));
|
|
294
|
+
recordComments(n, idx);
|
|
268
295
|
return idx;
|
|
269
296
|
}
|
|
270
297
|
function enc_unary_expression(n) {
|
|
@@ -274,6 +301,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
274
301
|
slotAt(idx, 0, a);
|
|
275
302
|
flagsAt(idx, UNARY_OPS_INV[n.operator] | 0);
|
|
276
303
|
spanAt(idx, asStart(n), asEnd(n));
|
|
304
|
+
recordComments(n, idx);
|
|
277
305
|
return idx;
|
|
278
306
|
}
|
|
279
307
|
function enc_update_expression(n) {
|
|
@@ -283,6 +311,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
283
311
|
slotAt(idx, 0, c_argument);
|
|
284
312
|
flagsAt(idx, 0 | (UPDATE_OPS_INV[n.operator] | 0) | (n.prefix ? 2 : 0));
|
|
285
313
|
spanAt(idx, asStart(n), asEnd(n));
|
|
314
|
+
recordComments(n, idx);
|
|
286
315
|
return idx;
|
|
287
316
|
}
|
|
288
317
|
function enc_assignment_expression(n) {
|
|
@@ -294,6 +323,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
294
323
|
slotAt(idx, 1, c_right);
|
|
295
324
|
flagsAt(idx, 0 | (ASSIGNMENT_OPS_INV[n.operator] | 0));
|
|
296
325
|
spanAt(idx, asStart(n), asEnd(n));
|
|
326
|
+
recordComments(n, idx);
|
|
297
327
|
return idx;
|
|
298
328
|
}
|
|
299
329
|
function enc_array_expression(n) {
|
|
@@ -303,6 +333,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
303
333
|
f0At(idx, c_elements.len);
|
|
304
334
|
slotAt(idx, 0, c_elements.start);
|
|
305
335
|
spanAt(idx, asStart(n), asEnd(n));
|
|
336
|
+
recordComments(n, idx);
|
|
306
337
|
return idx;
|
|
307
338
|
}
|
|
308
339
|
function enc_object_expression(n) {
|
|
@@ -312,6 +343,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
312
343
|
f0At(idx, c_properties.len);
|
|
313
344
|
slotAt(idx, 0, c_properties.start);
|
|
314
345
|
spanAt(idx, asStart(n), asEnd(n));
|
|
346
|
+
recordComments(n, idx);
|
|
315
347
|
return idx;
|
|
316
348
|
}
|
|
317
349
|
function enc_spread_element(n) {
|
|
@@ -320,26 +352,37 @@ function encode(estree, comments, lineStarts) {
|
|
|
320
352
|
tagAt(idx, 16);
|
|
321
353
|
slotAt(idx, 0, c_argument);
|
|
322
354
|
spanAt(idx, asStart(n), asEnd(n));
|
|
355
|
+
recordComments(n, idx);
|
|
323
356
|
return idx;
|
|
324
357
|
}
|
|
325
358
|
function enc_object_property(n) {
|
|
326
|
-
const k = n.key == null
|
|
359
|
+
const k = n.key == null
|
|
360
|
+
? NULL
|
|
361
|
+
: (n.computed ? encNode(n.key) : encPropertyKey(n.key));
|
|
327
362
|
const v = n.value == null ? NULL : encNode(n.value);
|
|
328
363
|
const idx = alloc();
|
|
329
364
|
tagAt(idx, 17);
|
|
330
365
|
slotAt(idx, 0, k); slotAt(idx, 1, v);
|
|
331
|
-
flagsAt(idx,
|
|
366
|
+
flagsAt(idx,
|
|
367
|
+
((PROPERTY_KINDS_INV[n.kind] | 0) << 0)
|
|
368
|
+
| (n.method ? 4 : 0)
|
|
369
|
+
| (n.shorthand ? 8 : 0)
|
|
370
|
+
| (n.computed ? 16 : 0));
|
|
332
371
|
spanAt(idx, asStart(n), asEnd(n));
|
|
372
|
+
recordComments(n, idx);
|
|
333
373
|
return idx;
|
|
334
374
|
}
|
|
335
375
|
function enc_member_expression(n) {
|
|
336
376
|
const o = n.object == null ? NULL : encNode(n.object);
|
|
337
|
-
const p = n.property == null
|
|
377
|
+
const p = n.property == null
|
|
378
|
+
? NULL
|
|
379
|
+
: (n.computed ? encNode(n.property) : encPropertyKey(n.property));
|
|
338
380
|
const idx = alloc();
|
|
339
381
|
tagAt(idx, 18);
|
|
340
382
|
slotAt(idx, 0, o); slotAt(idx, 1, p);
|
|
341
383
|
flagsAt(idx, (n.computed ? 1 : 0) | (n.optional ? 2 : 0));
|
|
342
384
|
spanAt(idx, asStart(n), asEnd(n));
|
|
385
|
+
recordComments(n, idx);
|
|
343
386
|
return idx;
|
|
344
387
|
}
|
|
345
388
|
function enc_call_expression(n) {
|
|
@@ -354,6 +397,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
354
397
|
slotAt(idx, 2, c_type_arguments);
|
|
355
398
|
flagsAt(idx, 0 | (n.optional ? 1 : 0));
|
|
356
399
|
spanAt(idx, asStart(n), asEnd(n));
|
|
400
|
+
recordComments(n, idx);
|
|
357
401
|
return idx;
|
|
358
402
|
}
|
|
359
403
|
function enc_chain_expression(n) {
|
|
@@ -362,6 +406,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
362
406
|
tagAt(idx, 20);
|
|
363
407
|
slotAt(idx, 0, c_expression);
|
|
364
408
|
spanAt(idx, asStart(n), asEnd(n));
|
|
409
|
+
recordComments(n, idx);
|
|
365
410
|
return idx;
|
|
366
411
|
}
|
|
367
412
|
function enc_tagged_template_expression(n) {
|
|
@@ -374,6 +419,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
374
419
|
slotAt(idx, 1, c_quasi);
|
|
375
420
|
slotAt(idx, 2, c_type_arguments);
|
|
376
421
|
spanAt(idx, asStart(n), asEnd(n));
|
|
422
|
+
recordComments(n, idx);
|
|
377
423
|
return idx;
|
|
378
424
|
}
|
|
379
425
|
function enc_new_expression(n) {
|
|
@@ -387,6 +433,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
387
433
|
slotAt(idx, 1, c_arguments.start);
|
|
388
434
|
slotAt(idx, 2, c_type_arguments);
|
|
389
435
|
spanAt(idx, asStart(n), asEnd(n));
|
|
436
|
+
recordComments(n, idx);
|
|
390
437
|
return idx;
|
|
391
438
|
}
|
|
392
439
|
function enc_await_expression(n) {
|
|
@@ -395,6 +442,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
395
442
|
tagAt(idx, 23);
|
|
396
443
|
slotAt(idx, 0, c_argument);
|
|
397
444
|
spanAt(idx, asStart(n), asEnd(n));
|
|
445
|
+
recordComments(n, idx);
|
|
398
446
|
return idx;
|
|
399
447
|
}
|
|
400
448
|
function enc_yield_expression(n) {
|
|
@@ -404,6 +452,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
404
452
|
slotAt(idx, 0, c_argument);
|
|
405
453
|
flagsAt(idx, 0 | (n.delegate ? 1 : 0));
|
|
406
454
|
spanAt(idx, asStart(n), asEnd(n));
|
|
455
|
+
recordComments(n, idx);
|
|
407
456
|
return idx;
|
|
408
457
|
}
|
|
409
458
|
function enc_meta_property(n) {
|
|
@@ -414,6 +463,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
414
463
|
slotAt(idx, 0, c_meta);
|
|
415
464
|
slotAt(idx, 1, c_property);
|
|
416
465
|
spanAt(idx, asStart(n), asEnd(n));
|
|
466
|
+
recordComments(n, idx);
|
|
417
467
|
return idx;
|
|
418
468
|
}
|
|
419
469
|
function enc_decorator(n) {
|
|
@@ -422,6 +472,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
422
472
|
tagAt(idx, 26);
|
|
423
473
|
slotAt(idx, 0, c_expression);
|
|
424
474
|
spanAt(idx, asStart(n), asEnd(n));
|
|
475
|
+
recordComments(n, idx);
|
|
425
476
|
return idx;
|
|
426
477
|
}
|
|
427
478
|
function enc_class(n, kind) {
|
|
@@ -445,6 +496,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
445
496
|
slotAt(idx, 7, imps.len);
|
|
446
497
|
flagsAt(idx, ((kind & 1) << 0) | (n.abstract ? 2 : 0) | (n.declare ? 4 : 0));
|
|
447
498
|
spanAt(idx, asStart(n), asEnd(n));
|
|
499
|
+
recordComments(n, idx);
|
|
448
500
|
return idx;
|
|
449
501
|
}
|
|
450
502
|
function enc_class_body(n) {
|
|
@@ -454,6 +506,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
454
506
|
f0At(idx, c_body.len);
|
|
455
507
|
slotAt(idx, 0, c_body.start);
|
|
456
508
|
spanAt(idx, asStart(n), asEnd(n));
|
|
509
|
+
recordComments(n, idx);
|
|
457
510
|
return idx;
|
|
458
511
|
}
|
|
459
512
|
function enc_method_definition(n, abstract) {
|
|
@@ -475,6 +528,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
475
528
|
(abstract ? 64 : 0) |
|
|
476
529
|
(ACCESSIBILITY_INV(n.accessibility) << 7));
|
|
477
530
|
spanAt(idx, asStart(n), asEnd(n));
|
|
531
|
+
recordComments(n, idx);
|
|
478
532
|
return idx;
|
|
479
533
|
}
|
|
480
534
|
function enc_property_definition(n, accessor, abstract) {
|
|
@@ -501,6 +555,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
501
555
|
(abstract ? 256 : 0) |
|
|
502
556
|
(ACCESSIBILITY_INV(n.accessibility) << 9));
|
|
503
557
|
spanAt(idx, asStart(n), asEnd(n));
|
|
558
|
+
recordComments(n, idx);
|
|
504
559
|
return idx;
|
|
505
560
|
}
|
|
506
561
|
function enc_static_block(n) {
|
|
@@ -510,12 +565,14 @@ function encode(estree, comments, lineStarts) {
|
|
|
510
565
|
f0At(idx, c_body.len);
|
|
511
566
|
slotAt(idx, 0, c_body.start);
|
|
512
567
|
spanAt(idx, asStart(n), asEnd(n));
|
|
568
|
+
recordComments(n, idx);
|
|
513
569
|
return idx;
|
|
514
570
|
}
|
|
515
571
|
function enc_super(n) {
|
|
516
572
|
const idx = alloc();
|
|
517
573
|
tagAt(idx, 32);
|
|
518
574
|
spanAt(idx, asStart(n), asEnd(n));
|
|
575
|
+
recordComments(n, idx);
|
|
519
576
|
return idx;
|
|
520
577
|
}
|
|
521
578
|
function enc_string_literal(n) {
|
|
@@ -524,6 +581,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
524
581
|
tagAt(idx, 33);
|
|
525
582
|
slotAt(idx, 0, s.start); slotAt(idx, 1, s.end);
|
|
526
583
|
spanAt(idx, asStart(n), asEnd(n));
|
|
584
|
+
recordComments(n, idx);
|
|
527
585
|
return idx;
|
|
528
586
|
}
|
|
529
587
|
function enc_numeric_literal(n) {
|
|
@@ -541,6 +599,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
541
599
|
flagsAt(idx, kind);
|
|
542
600
|
slotAt(idx, 0, r.start); slotAt(idx, 1, r.end);
|
|
543
601
|
spanAt(idx, asStart(n), asEnd(n));
|
|
602
|
+
recordComments(n, idx);
|
|
544
603
|
return idx;
|
|
545
604
|
}
|
|
546
605
|
function enc_bigint_literal(n) {
|
|
@@ -550,6 +609,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
550
609
|
tagAt(idx, 35);
|
|
551
610
|
slotAt(idx, 0, r.start); slotAt(idx, 1, r.end);
|
|
552
611
|
spanAt(idx, asStart(n), asEnd(n));
|
|
612
|
+
recordComments(n, idx);
|
|
553
613
|
return idx;
|
|
554
614
|
}
|
|
555
615
|
function enc_boolean_literal(n) {
|
|
@@ -557,18 +617,21 @@ function encode(estree, comments, lineStarts) {
|
|
|
557
617
|
tagAt(idx, 36);
|
|
558
618
|
flagsAt(idx, n.value ? 1 : 0);
|
|
559
619
|
spanAt(idx, asStart(n), asEnd(n));
|
|
620
|
+
recordComments(n, idx);
|
|
560
621
|
return idx;
|
|
561
622
|
}
|
|
562
623
|
function enc_null_literal(n) {
|
|
563
624
|
const idx = alloc();
|
|
564
625
|
tagAt(idx, 37);
|
|
565
626
|
spanAt(idx, asStart(n), asEnd(n));
|
|
627
|
+
recordComments(n, idx);
|
|
566
628
|
return idx;
|
|
567
629
|
}
|
|
568
630
|
function enc_this_expression(n) {
|
|
569
631
|
const idx = alloc();
|
|
570
632
|
tagAt(idx, 38);
|
|
571
633
|
spanAt(idx, asStart(n), asEnd(n));
|
|
634
|
+
recordComments(n, idx);
|
|
572
635
|
return idx;
|
|
573
636
|
}
|
|
574
637
|
function enc_regexp_literal(n) {
|
|
@@ -579,6 +642,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
579
642
|
slotAt(idx, 0, p.start); slotAt(idx, 1, p.end);
|
|
580
643
|
slotAt(idx, 2, fl.start); slotAt(idx, 3, fl.end);
|
|
581
644
|
spanAt(idx, asStart(n), asEnd(n));
|
|
645
|
+
recordComments(n, idx);
|
|
582
646
|
return idx;
|
|
583
647
|
}
|
|
584
648
|
function enc_template_literal(n) {
|
|
@@ -591,6 +655,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
591
655
|
slotAt(idx, 1, c_expressions.start);
|
|
592
656
|
slotAt(idx, 2, c_expressions.len);
|
|
593
657
|
spanAt(idx, asStart(n), asEnd(n));
|
|
658
|
+
recordComments(n, idx);
|
|
594
659
|
return idx;
|
|
595
660
|
}
|
|
596
661
|
function enc_template_element(n) {
|
|
@@ -602,6 +667,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
602
667
|
flagsAt(idx, (n.tail ? 1 : 0) | (undef ? 2 : 0));
|
|
603
668
|
slotAt(idx, 0, c.start); slotAt(idx, 1, c.end);
|
|
604
669
|
spanAt(idx, asStart(n), asEnd(n));
|
|
670
|
+
recordComments(n, idx);
|
|
605
671
|
return idx;
|
|
606
672
|
}
|
|
607
673
|
function enc_identifier_reference(n) {
|
|
@@ -611,6 +677,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
611
677
|
slotAt(idx, 0, c_name.start);
|
|
612
678
|
slotAt(idx, 1, c_name.end);
|
|
613
679
|
spanAt(idx, asStart(n), asEnd(n));
|
|
680
|
+
recordComments(n, idx);
|
|
614
681
|
return idx;
|
|
615
682
|
}
|
|
616
683
|
function enc_private_identifier(n) {
|
|
@@ -620,6 +687,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
620
687
|
slotAt(idx, 0, c_name.start);
|
|
621
688
|
slotAt(idx, 1, c_name.end);
|
|
622
689
|
spanAt(idx, asStart(n), asEnd(n));
|
|
690
|
+
recordComments(n, idx);
|
|
623
691
|
return idx;
|
|
624
692
|
}
|
|
625
693
|
function enc_binding_identifier(n) {
|
|
@@ -635,6 +703,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
635
703
|
slotAt(idx, 3, c_type_annotation);
|
|
636
704
|
flagsAt(idx, 0 | (n.optional ? 1 : 0));
|
|
637
705
|
spanAt(idx, asStart(n), asEnd(n));
|
|
706
|
+
recordComments(n, idx);
|
|
638
707
|
return idx;
|
|
639
708
|
}
|
|
640
709
|
function enc_identifier_name(n) {
|
|
@@ -644,6 +713,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
644
713
|
slotAt(idx, 0, c_name.start);
|
|
645
714
|
slotAt(idx, 1, c_name.end);
|
|
646
715
|
spanAt(idx, asStart(n), asEnd(n));
|
|
716
|
+
recordComments(n, idx);
|
|
647
717
|
return idx;
|
|
648
718
|
}
|
|
649
719
|
function enc_label_identifier(n) {
|
|
@@ -653,6 +723,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
653
723
|
slotAt(idx, 0, c_name.start);
|
|
654
724
|
slotAt(idx, 1, c_name.end);
|
|
655
725
|
spanAt(idx, asStart(n), asEnd(n));
|
|
726
|
+
recordComments(n, idx);
|
|
656
727
|
return idx;
|
|
657
728
|
}
|
|
658
729
|
function enc_expression_statement(n) {
|
|
@@ -661,6 +732,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
661
732
|
tagAt(idx, 47);
|
|
662
733
|
slotAt(idx, 0, c_expression);
|
|
663
734
|
spanAt(idx, asStart(n), asEnd(n));
|
|
735
|
+
recordComments(n, idx);
|
|
664
736
|
return idx;
|
|
665
737
|
}
|
|
666
738
|
function enc_if_statement(n) {
|
|
@@ -673,6 +745,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
673
745
|
slotAt(idx, 1, c_consequent);
|
|
674
746
|
slotAt(idx, 2, c_alternate);
|
|
675
747
|
spanAt(idx, asStart(n), asEnd(n));
|
|
748
|
+
recordComments(n, idx);
|
|
676
749
|
return idx;
|
|
677
750
|
}
|
|
678
751
|
function enc_switch_statement(n) {
|
|
@@ -684,6 +757,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
684
757
|
f0At(idx, c_cases.len);
|
|
685
758
|
slotAt(idx, 1, c_cases.start);
|
|
686
759
|
spanAt(idx, asStart(n), asEnd(n));
|
|
760
|
+
recordComments(n, idx);
|
|
687
761
|
return idx;
|
|
688
762
|
}
|
|
689
763
|
function enc_switch_case(n) {
|
|
@@ -695,6 +769,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
695
769
|
f0At(idx, c_consequent.len);
|
|
696
770
|
slotAt(idx, 1, c_consequent.start);
|
|
697
771
|
spanAt(idx, asStart(n), asEnd(n));
|
|
772
|
+
recordComments(n, idx);
|
|
698
773
|
return idx;
|
|
699
774
|
}
|
|
700
775
|
function enc_for_statement(n) {
|
|
@@ -709,6 +784,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
709
784
|
slotAt(idx, 2, c_update);
|
|
710
785
|
slotAt(idx, 3, c_body);
|
|
711
786
|
spanAt(idx, asStart(n), asEnd(n));
|
|
787
|
+
recordComments(n, idx);
|
|
712
788
|
return idx;
|
|
713
789
|
}
|
|
714
790
|
function enc_for_in_statement(n) {
|
|
@@ -721,6 +797,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
721
797
|
slotAt(idx, 1, c_right);
|
|
722
798
|
slotAt(idx, 2, c_body);
|
|
723
799
|
spanAt(idx, asStart(n), asEnd(n));
|
|
800
|
+
recordComments(n, idx);
|
|
724
801
|
return idx;
|
|
725
802
|
}
|
|
726
803
|
function enc_for_of_statement(n) {
|
|
@@ -734,6 +811,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
734
811
|
slotAt(idx, 2, c_body);
|
|
735
812
|
flagsAt(idx, 0 | (n.await ? 1 : 0));
|
|
736
813
|
spanAt(idx, asStart(n), asEnd(n));
|
|
814
|
+
recordComments(n, idx);
|
|
737
815
|
return idx;
|
|
738
816
|
}
|
|
739
817
|
function enc_while_statement(n) {
|
|
@@ -744,6 +822,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
744
822
|
slotAt(idx, 0, c_test);
|
|
745
823
|
slotAt(idx, 1, c_body);
|
|
746
824
|
spanAt(idx, asStart(n), asEnd(n));
|
|
825
|
+
recordComments(n, idx);
|
|
747
826
|
return idx;
|
|
748
827
|
}
|
|
749
828
|
function enc_do_while_statement(n) {
|
|
@@ -754,6 +833,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
754
833
|
slotAt(idx, 0, c_body);
|
|
755
834
|
slotAt(idx, 1, c_test);
|
|
756
835
|
spanAt(idx, asStart(n), asEnd(n));
|
|
836
|
+
recordComments(n, idx);
|
|
757
837
|
return idx;
|
|
758
838
|
}
|
|
759
839
|
function enc_break_statement(n) {
|
|
@@ -762,6 +842,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
762
842
|
tagAt(idx, 56);
|
|
763
843
|
slotAt(idx, 0, c_label);
|
|
764
844
|
spanAt(idx, asStart(n), asEnd(n));
|
|
845
|
+
recordComments(n, idx);
|
|
765
846
|
return idx;
|
|
766
847
|
}
|
|
767
848
|
function enc_continue_statement(n) {
|
|
@@ -770,6 +851,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
770
851
|
tagAt(idx, 57);
|
|
771
852
|
slotAt(idx, 0, c_label);
|
|
772
853
|
spanAt(idx, asStart(n), asEnd(n));
|
|
854
|
+
recordComments(n, idx);
|
|
773
855
|
return idx;
|
|
774
856
|
}
|
|
775
857
|
function enc_labeled_statement(n) {
|
|
@@ -780,6 +862,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
780
862
|
slotAt(idx, 0, c_label);
|
|
781
863
|
slotAt(idx, 1, c_body);
|
|
782
864
|
spanAt(idx, asStart(n), asEnd(n));
|
|
865
|
+
recordComments(n, idx);
|
|
783
866
|
return idx;
|
|
784
867
|
}
|
|
785
868
|
function enc_with_statement(n) {
|
|
@@ -790,6 +873,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
790
873
|
slotAt(idx, 0, c_object);
|
|
791
874
|
slotAt(idx, 1, c_body);
|
|
792
875
|
spanAt(idx, asStart(n), asEnd(n));
|
|
876
|
+
recordComments(n, idx);
|
|
793
877
|
return idx;
|
|
794
878
|
}
|
|
795
879
|
function enc_return_statement(n) {
|
|
@@ -798,6 +882,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
798
882
|
tagAt(idx, 60);
|
|
799
883
|
slotAt(idx, 0, c_argument);
|
|
800
884
|
spanAt(idx, asStart(n), asEnd(n));
|
|
885
|
+
recordComments(n, idx);
|
|
801
886
|
return idx;
|
|
802
887
|
}
|
|
803
888
|
function enc_throw_statement(n) {
|
|
@@ -806,6 +891,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
806
891
|
tagAt(idx, 61);
|
|
807
892
|
slotAt(idx, 0, c_argument);
|
|
808
893
|
spanAt(idx, asStart(n), asEnd(n));
|
|
894
|
+
recordComments(n, idx);
|
|
809
895
|
return idx;
|
|
810
896
|
}
|
|
811
897
|
function enc_try_statement(n) {
|
|
@@ -818,6 +904,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
818
904
|
slotAt(idx, 1, c_handler);
|
|
819
905
|
slotAt(idx, 2, c_finalizer);
|
|
820
906
|
spanAt(idx, asStart(n), asEnd(n));
|
|
907
|
+
recordComments(n, idx);
|
|
821
908
|
return idx;
|
|
822
909
|
}
|
|
823
910
|
function enc_catch_clause(n) {
|
|
@@ -828,18 +915,21 @@ function encode(estree, comments, lineStarts) {
|
|
|
828
915
|
slotAt(idx, 0, c_param);
|
|
829
916
|
slotAt(idx, 1, c_body);
|
|
830
917
|
spanAt(idx, asStart(n), asEnd(n));
|
|
918
|
+
recordComments(n, idx);
|
|
831
919
|
return idx;
|
|
832
920
|
}
|
|
833
921
|
function enc_debugger_statement(n) {
|
|
834
922
|
const idx = alloc();
|
|
835
923
|
tagAt(idx, 64);
|
|
836
924
|
spanAt(idx, asStart(n), asEnd(n));
|
|
925
|
+
recordComments(n, idx);
|
|
837
926
|
return idx;
|
|
838
927
|
}
|
|
839
928
|
function enc_empty_statement(n) {
|
|
840
929
|
const idx = alloc();
|
|
841
930
|
tagAt(idx, 65);
|
|
842
931
|
spanAt(idx, asStart(n), asEnd(n));
|
|
932
|
+
recordComments(n, idx);
|
|
843
933
|
return idx;
|
|
844
934
|
}
|
|
845
935
|
function enc_variable_declaration(n) {
|
|
@@ -850,6 +940,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
850
940
|
slotAt(idx, 0, c_declarators.start);
|
|
851
941
|
flagsAt(idx, 0 | (VAR_KINDS_INV[n.kind] | 0) | (n.declare ? 8 : 0));
|
|
852
942
|
spanAt(idx, asStart(n), asEnd(n));
|
|
943
|
+
recordComments(n, idx);
|
|
853
944
|
return idx;
|
|
854
945
|
}
|
|
855
946
|
function enc_variable_declarator(n) {
|
|
@@ -861,6 +952,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
861
952
|
slotAt(idx, 1, c_init);
|
|
862
953
|
flagsAt(idx, 0 | (n.definite ? 1 : 0));
|
|
863
954
|
spanAt(idx, asStart(n), asEnd(n));
|
|
955
|
+
recordComments(n, idx);
|
|
864
956
|
return idx;
|
|
865
957
|
}
|
|
866
958
|
function enc_directive(n) {
|
|
@@ -871,6 +963,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
871
963
|
slotAt(idx, 0, e);
|
|
872
964
|
slotAt(idx, 1, dv.start); slotAt(idx, 2, dv.end);
|
|
873
965
|
spanAt(idx, asStart(n), asEnd(n));
|
|
966
|
+
recordComments(n, idx);
|
|
874
967
|
return idx;
|
|
875
968
|
}
|
|
876
969
|
function enc_assignment_pattern(n) {
|
|
@@ -887,6 +980,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
887
980
|
slotAt(idx, 3, c_type_annotation);
|
|
888
981
|
flagsAt(idx, 0 | (n.optional ? 1 : 0));
|
|
889
982
|
spanAt(idx, asStart(n), asEnd(n));
|
|
983
|
+
recordComments(n, idx);
|
|
890
984
|
return idx;
|
|
891
985
|
}
|
|
892
986
|
function enc_binding_rest_element(n) {
|
|
@@ -901,6 +995,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
901
995
|
slotAt(idx, 2, c_type_annotation);
|
|
902
996
|
flagsAt(idx, 0 | (n.optional ? 1 : 0));
|
|
903
997
|
spanAt(idx, asStart(n), asEnd(n));
|
|
998
|
+
recordComments(n, idx);
|
|
904
999
|
return idx;
|
|
905
1000
|
}
|
|
906
1001
|
function enc_array_pattern(n) {
|
|
@@ -925,6 +1020,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
925
1020
|
slotAt(idx, 4, ta);
|
|
926
1021
|
flagsAt(idx, n.optional ? 1 : 0);
|
|
927
1022
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1023
|
+
recordComments(n, idx);
|
|
928
1024
|
return idx;
|
|
929
1025
|
}
|
|
930
1026
|
function enc_object_pattern(n) {
|
|
@@ -948,10 +1044,13 @@ function encode(estree, comments, lineStarts) {
|
|
|
948
1044
|
slotAt(idx, 4, ta);
|
|
949
1045
|
flagsAt(idx, n.optional ? 1 : 0);
|
|
950
1046
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1047
|
+
recordComments(n, idx);
|
|
951
1048
|
return idx;
|
|
952
1049
|
}
|
|
953
1050
|
function enc_binding_property(p) {
|
|
954
|
-
const k = p.key == null
|
|
1051
|
+
const k = p.key == null
|
|
1052
|
+
? NULL
|
|
1053
|
+
: (p.computed ? encNode(p.key) : encPropertyKey(p.key));
|
|
955
1054
|
const v = p.value == null ? NULL : encBindingTarget(p.value);
|
|
956
1055
|
const idx = alloc();
|
|
957
1056
|
tagAt(idx, 73);
|
|
@@ -962,7 +1061,9 @@ function encode(estree, comments, lineStarts) {
|
|
|
962
1061
|
}
|
|
963
1062
|
function enc_program(n) {
|
|
964
1063
|
const body = encArr(n.body, encNode);
|
|
965
|
-
const hb = n.hashbang && typeof n.hashbang.value === "string"
|
|
1064
|
+
const hb = n.hashbang && typeof n.hashbang.value === "string"
|
|
1065
|
+
? encStr(n.hashbang.value)
|
|
1066
|
+
: null;
|
|
966
1067
|
const idx = alloc();
|
|
967
1068
|
tagAt(idx, 74);
|
|
968
1069
|
f0At(idx, body.len);
|
|
@@ -970,6 +1071,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
970
1071
|
if (hb) { slotAt(idx, 1, hb.start); slotAt(idx, 2, hb.end); }
|
|
971
1072
|
flagsAt(idx, (n.sourceType === "script" ? 0 : 1) | (hb ? 2 : 0));
|
|
972
1073
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1074
|
+
recordComments(n, idx);
|
|
973
1075
|
return idx;
|
|
974
1076
|
}
|
|
975
1077
|
function enc_import_expression(n) {
|
|
@@ -981,6 +1083,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
981
1083
|
slotAt(idx, 1, c_options);
|
|
982
1084
|
flagsAt(idx, 0 | (n.phase != null ? 1 | ((IMPORT_PHASE_INV[n.phase] | 0) << 1) : 0));
|
|
983
1085
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1086
|
+
recordComments(n, idx);
|
|
984
1087
|
return idx;
|
|
985
1088
|
}
|
|
986
1089
|
function enc_import_declaration(n) {
|
|
@@ -996,6 +1099,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
996
1099
|
slotAt(idx, 3, c_attributes.len);
|
|
997
1100
|
flagsAt(idx, 0 | (n.phase != null ? 1 | ((IMPORT_PHASE_INV[n.phase] | 0) << 1) : 0) | ((IMPORT_EXPORT_KINDS_INV[n.importKind] | 0) << 2));
|
|
998
1101
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1102
|
+
recordComments(n, idx);
|
|
999
1103
|
return idx;
|
|
1000
1104
|
}
|
|
1001
1105
|
function enc_import_specifier(n) {
|
|
@@ -1007,6 +1111,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1007
1111
|
slotAt(idx, 1, c_local);
|
|
1008
1112
|
flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.importKind] | 0));
|
|
1009
1113
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1114
|
+
recordComments(n, idx);
|
|
1010
1115
|
return idx;
|
|
1011
1116
|
}
|
|
1012
1117
|
function enc_import_default_specifier(n) {
|
|
@@ -1015,6 +1120,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1015
1120
|
tagAt(idx, 78);
|
|
1016
1121
|
slotAt(idx, 0, c_local);
|
|
1017
1122
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1123
|
+
recordComments(n, idx);
|
|
1018
1124
|
return idx;
|
|
1019
1125
|
}
|
|
1020
1126
|
function enc_import_namespace_specifier(n) {
|
|
@@ -1023,6 +1129,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1023
1129
|
tagAt(idx, 79);
|
|
1024
1130
|
slotAt(idx, 0, c_local);
|
|
1025
1131
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1132
|
+
recordComments(n, idx);
|
|
1026
1133
|
return idx;
|
|
1027
1134
|
}
|
|
1028
1135
|
function enc_import_attribute(n) {
|
|
@@ -1033,6 +1140,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1033
1140
|
slotAt(idx, 0, c_key);
|
|
1034
1141
|
slotAt(idx, 1, c_value);
|
|
1035
1142
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1143
|
+
recordComments(n, idx);
|
|
1036
1144
|
return idx;
|
|
1037
1145
|
}
|
|
1038
1146
|
function enc_export_named_declaration(n) {
|
|
@@ -1050,6 +1158,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1050
1158
|
slotAt(idx, 4, c_attributes.len);
|
|
1051
1159
|
flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.exportKind] | 0));
|
|
1052
1160
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1161
|
+
recordComments(n, idx);
|
|
1053
1162
|
return idx;
|
|
1054
1163
|
}
|
|
1055
1164
|
function enc_export_default_declaration(n) {
|
|
@@ -1058,6 +1167,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1058
1167
|
tagAt(idx, 82);
|
|
1059
1168
|
slotAt(idx, 0, c_declaration);
|
|
1060
1169
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1170
|
+
recordComments(n, idx);
|
|
1061
1171
|
return idx;
|
|
1062
1172
|
}
|
|
1063
1173
|
function enc_export_all_declaration(n) {
|
|
@@ -1072,6 +1182,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1072
1182
|
slotAt(idx, 2, c_attributes.start);
|
|
1073
1183
|
flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.exportKind] | 0));
|
|
1074
1184
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1185
|
+
recordComments(n, idx);
|
|
1075
1186
|
return idx;
|
|
1076
1187
|
}
|
|
1077
1188
|
function enc_export_specifier(n) {
|
|
@@ -1083,6 +1194,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1083
1194
|
slotAt(idx, 1, c_exported);
|
|
1084
1195
|
flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.exportKind] | 0));
|
|
1085
1196
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1197
|
+
recordComments(n, idx);
|
|
1086
1198
|
return idx;
|
|
1087
1199
|
}
|
|
1088
1200
|
function enc_ts_type_annotation(n) {
|
|
@@ -1091,90 +1203,105 @@ function encode(estree, comments, lineStarts) {
|
|
|
1091
1203
|
tagAt(idx, 85);
|
|
1092
1204
|
slotAt(idx, 0, c_type_annotation);
|
|
1093
1205
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1206
|
+
recordComments(n, idx);
|
|
1094
1207
|
return idx;
|
|
1095
1208
|
}
|
|
1096
1209
|
function enc_ts_any_keyword(n) {
|
|
1097
1210
|
const idx = alloc();
|
|
1098
1211
|
tagAt(idx, 86);
|
|
1099
1212
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1213
|
+
recordComments(n, idx);
|
|
1100
1214
|
return idx;
|
|
1101
1215
|
}
|
|
1102
1216
|
function enc_ts_unknown_keyword(n) {
|
|
1103
1217
|
const idx = alloc();
|
|
1104
1218
|
tagAt(idx, 87);
|
|
1105
1219
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1220
|
+
recordComments(n, idx);
|
|
1106
1221
|
return idx;
|
|
1107
1222
|
}
|
|
1108
1223
|
function enc_ts_never_keyword(n) {
|
|
1109
1224
|
const idx = alloc();
|
|
1110
1225
|
tagAt(idx, 88);
|
|
1111
1226
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1227
|
+
recordComments(n, idx);
|
|
1112
1228
|
return idx;
|
|
1113
1229
|
}
|
|
1114
1230
|
function enc_ts_void_keyword(n) {
|
|
1115
1231
|
const idx = alloc();
|
|
1116
1232
|
tagAt(idx, 89);
|
|
1117
1233
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1234
|
+
recordComments(n, idx);
|
|
1118
1235
|
return idx;
|
|
1119
1236
|
}
|
|
1120
1237
|
function enc_ts_null_keyword(n) {
|
|
1121
1238
|
const idx = alloc();
|
|
1122
1239
|
tagAt(idx, 90);
|
|
1123
1240
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1241
|
+
recordComments(n, idx);
|
|
1124
1242
|
return idx;
|
|
1125
1243
|
}
|
|
1126
1244
|
function enc_ts_undefined_keyword(n) {
|
|
1127
1245
|
const idx = alloc();
|
|
1128
1246
|
tagAt(idx, 91);
|
|
1129
1247
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1248
|
+
recordComments(n, idx);
|
|
1130
1249
|
return idx;
|
|
1131
1250
|
}
|
|
1132
1251
|
function enc_ts_string_keyword(n) {
|
|
1133
1252
|
const idx = alloc();
|
|
1134
1253
|
tagAt(idx, 92);
|
|
1135
1254
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1255
|
+
recordComments(n, idx);
|
|
1136
1256
|
return idx;
|
|
1137
1257
|
}
|
|
1138
1258
|
function enc_ts_number_keyword(n) {
|
|
1139
1259
|
const idx = alloc();
|
|
1140
1260
|
tagAt(idx, 93);
|
|
1141
1261
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1262
|
+
recordComments(n, idx);
|
|
1142
1263
|
return idx;
|
|
1143
1264
|
}
|
|
1144
1265
|
function enc_ts_bigint_keyword(n) {
|
|
1145
1266
|
const idx = alloc();
|
|
1146
1267
|
tagAt(idx, 94);
|
|
1147
1268
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1269
|
+
recordComments(n, idx);
|
|
1148
1270
|
return idx;
|
|
1149
1271
|
}
|
|
1150
1272
|
function enc_ts_boolean_keyword(n) {
|
|
1151
1273
|
const idx = alloc();
|
|
1152
1274
|
tagAt(idx, 95);
|
|
1153
1275
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1276
|
+
recordComments(n, idx);
|
|
1154
1277
|
return idx;
|
|
1155
1278
|
}
|
|
1156
1279
|
function enc_ts_symbol_keyword(n) {
|
|
1157
1280
|
const idx = alloc();
|
|
1158
1281
|
tagAt(idx, 96);
|
|
1159
1282
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1283
|
+
recordComments(n, idx);
|
|
1160
1284
|
return idx;
|
|
1161
1285
|
}
|
|
1162
1286
|
function enc_ts_object_keyword(n) {
|
|
1163
1287
|
const idx = alloc();
|
|
1164
1288
|
tagAt(idx, 97);
|
|
1165
1289
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1290
|
+
recordComments(n, idx);
|
|
1166
1291
|
return idx;
|
|
1167
1292
|
}
|
|
1168
1293
|
function enc_ts_intrinsic_keyword(n) {
|
|
1169
1294
|
const idx = alloc();
|
|
1170
1295
|
tagAt(idx, 98);
|
|
1171
1296
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1297
|
+
recordComments(n, idx);
|
|
1172
1298
|
return idx;
|
|
1173
1299
|
}
|
|
1174
1300
|
function enc_ts_this_type(n) {
|
|
1175
1301
|
const idx = alloc();
|
|
1176
1302
|
tagAt(idx, 99);
|
|
1177
1303
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1304
|
+
recordComments(n, idx);
|
|
1178
1305
|
return idx;
|
|
1179
1306
|
}
|
|
1180
1307
|
function enc_ts_type_reference(n) {
|
|
@@ -1185,6 +1312,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1185
1312
|
slotAt(idx, 0, c_type_name);
|
|
1186
1313
|
slotAt(idx, 1, c_type_arguments);
|
|
1187
1314
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1315
|
+
recordComments(n, idx);
|
|
1188
1316
|
return idx;
|
|
1189
1317
|
}
|
|
1190
1318
|
function enc_ts_qualified_name(n) {
|
|
@@ -1195,6 +1323,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1195
1323
|
slotAt(idx, 0, c_left);
|
|
1196
1324
|
slotAt(idx, 1, c_right);
|
|
1197
1325
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1326
|
+
recordComments(n, idx);
|
|
1198
1327
|
return idx;
|
|
1199
1328
|
}
|
|
1200
1329
|
function enc_ts_type_query(n) {
|
|
@@ -1205,6 +1334,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1205
1334
|
slotAt(idx, 0, c_expr_name);
|
|
1206
1335
|
slotAt(idx, 1, c_type_arguments);
|
|
1207
1336
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1337
|
+
recordComments(n, idx);
|
|
1208
1338
|
return idx;
|
|
1209
1339
|
}
|
|
1210
1340
|
function enc_ts_import_type(n) {
|
|
@@ -1219,6 +1349,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1219
1349
|
slotAt(idx, 2, c_qualifier);
|
|
1220
1350
|
slotAt(idx, 3, c_type_arguments);
|
|
1221
1351
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1352
|
+
recordComments(n, idx);
|
|
1222
1353
|
return idx;
|
|
1223
1354
|
}
|
|
1224
1355
|
function enc_ts_type_parameter(n) {
|
|
@@ -1232,6 +1363,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1232
1363
|
slotAt(idx, 2, c_default);
|
|
1233
1364
|
flagsAt(idx, 0 | (n.in ? 1 : 0) | (n.out ? 2 : 0) | (n.const ? 4 : 0));
|
|
1234
1365
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1366
|
+
recordComments(n, idx);
|
|
1235
1367
|
return idx;
|
|
1236
1368
|
}
|
|
1237
1369
|
function enc_ts_type_parameter_declaration(n) {
|
|
@@ -1241,6 +1373,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1241
1373
|
f0At(idx, c_params.len);
|
|
1242
1374
|
slotAt(idx, 0, c_params.start);
|
|
1243
1375
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1376
|
+
recordComments(n, idx);
|
|
1244
1377
|
return idx;
|
|
1245
1378
|
}
|
|
1246
1379
|
function enc_ts_type_parameter_instantiation(n) {
|
|
@@ -1250,6 +1383,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1250
1383
|
f0At(idx, c_params.len);
|
|
1251
1384
|
slotAt(idx, 0, c_params.start);
|
|
1252
1385
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1386
|
+
recordComments(n, idx);
|
|
1253
1387
|
return idx;
|
|
1254
1388
|
}
|
|
1255
1389
|
function enc_ts_literal_type(n) {
|
|
@@ -1258,6 +1392,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1258
1392
|
tagAt(idx, 107);
|
|
1259
1393
|
slotAt(idx, 0, c_literal);
|
|
1260
1394
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1395
|
+
recordComments(n, idx);
|
|
1261
1396
|
return idx;
|
|
1262
1397
|
}
|
|
1263
1398
|
function enc_ts_template_literal_type(n) {
|
|
@@ -1270,6 +1405,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1270
1405
|
slotAt(idx, 1, c_types.start);
|
|
1271
1406
|
slotAt(idx, 2, c_types.len);
|
|
1272
1407
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1408
|
+
recordComments(n, idx);
|
|
1273
1409
|
return idx;
|
|
1274
1410
|
}
|
|
1275
1411
|
function enc_ts_array_type(n) {
|
|
@@ -1278,6 +1414,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1278
1414
|
tagAt(idx, 109);
|
|
1279
1415
|
slotAt(idx, 0, c_element_type);
|
|
1280
1416
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1417
|
+
recordComments(n, idx);
|
|
1281
1418
|
return idx;
|
|
1282
1419
|
}
|
|
1283
1420
|
function enc_ts_indexed_access_type(n) {
|
|
@@ -1288,6 +1425,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1288
1425
|
slotAt(idx, 0, c_object_type);
|
|
1289
1426
|
slotAt(idx, 1, c_index_type);
|
|
1290
1427
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1428
|
+
recordComments(n, idx);
|
|
1291
1429
|
return idx;
|
|
1292
1430
|
}
|
|
1293
1431
|
function enc_ts_tuple_type(n) {
|
|
@@ -1297,6 +1435,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1297
1435
|
f0At(idx, c_element_types.len);
|
|
1298
1436
|
slotAt(idx, 0, c_element_types.start);
|
|
1299
1437
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1438
|
+
recordComments(n, idx);
|
|
1300
1439
|
return idx;
|
|
1301
1440
|
}
|
|
1302
1441
|
function enc_ts_named_tuple_member(n) {
|
|
@@ -1308,6 +1447,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1308
1447
|
slotAt(idx, 1, c_element_type);
|
|
1309
1448
|
flagsAt(idx, 0 | (n.optional ? 1 : 0));
|
|
1310
1449
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1450
|
+
recordComments(n, idx);
|
|
1311
1451
|
return idx;
|
|
1312
1452
|
}
|
|
1313
1453
|
function enc_ts_optional_type(n) {
|
|
@@ -1316,6 +1456,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1316
1456
|
tagAt(idx, 113);
|
|
1317
1457
|
slotAt(idx, 0, c_type_annotation);
|
|
1318
1458
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1459
|
+
recordComments(n, idx);
|
|
1319
1460
|
return idx;
|
|
1320
1461
|
}
|
|
1321
1462
|
function enc_ts_rest_type(n) {
|
|
@@ -1324,6 +1465,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1324
1465
|
tagAt(idx, 114);
|
|
1325
1466
|
slotAt(idx, 0, c_type_annotation);
|
|
1326
1467
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1468
|
+
recordComments(n, idx);
|
|
1327
1469
|
return idx;
|
|
1328
1470
|
}
|
|
1329
1471
|
function enc_ts_jsdoc_nullable_type(n) {
|
|
@@ -1333,6 +1475,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1333
1475
|
slotAt(idx, 0, c_type_annotation);
|
|
1334
1476
|
flagsAt(idx, 0 | (n.postfix ? 1 : 0));
|
|
1335
1477
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1478
|
+
recordComments(n, idx);
|
|
1336
1479
|
return idx;
|
|
1337
1480
|
}
|
|
1338
1481
|
function enc_ts_jsdoc_non_nullable_type(n) {
|
|
@@ -1342,12 +1485,14 @@ function encode(estree, comments, lineStarts) {
|
|
|
1342
1485
|
slotAt(idx, 0, c_type_annotation);
|
|
1343
1486
|
flagsAt(idx, 0 | (n.postfix ? 1 : 0));
|
|
1344
1487
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1488
|
+
recordComments(n, idx);
|
|
1345
1489
|
return idx;
|
|
1346
1490
|
}
|
|
1347
1491
|
function enc_ts_jsdoc_unknown_type(n) {
|
|
1348
1492
|
const idx = alloc();
|
|
1349
1493
|
tagAt(idx, 117);
|
|
1350
1494
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1495
|
+
recordComments(n, idx);
|
|
1351
1496
|
return idx;
|
|
1352
1497
|
}
|
|
1353
1498
|
function enc_ts_union_type(n) {
|
|
@@ -1357,6 +1502,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1357
1502
|
f0At(idx, c_types.len);
|
|
1358
1503
|
slotAt(idx, 0, c_types.start);
|
|
1359
1504
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1505
|
+
recordComments(n, idx);
|
|
1360
1506
|
return idx;
|
|
1361
1507
|
}
|
|
1362
1508
|
function enc_ts_intersection_type(n) {
|
|
@@ -1366,6 +1512,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1366
1512
|
f0At(idx, c_types.len);
|
|
1367
1513
|
slotAt(idx, 0, c_types.start);
|
|
1368
1514
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1515
|
+
recordComments(n, idx);
|
|
1369
1516
|
return idx;
|
|
1370
1517
|
}
|
|
1371
1518
|
function enc_ts_conditional_type(n) {
|
|
@@ -1380,6 +1527,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1380
1527
|
slotAt(idx, 2, c_true_type);
|
|
1381
1528
|
slotAt(idx, 3, c_false_type);
|
|
1382
1529
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1530
|
+
recordComments(n, idx);
|
|
1383
1531
|
return idx;
|
|
1384
1532
|
}
|
|
1385
1533
|
function enc_ts_infer_type(n) {
|
|
@@ -1388,6 +1536,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1388
1536
|
tagAt(idx, 121);
|
|
1389
1537
|
slotAt(idx, 0, c_type_parameter);
|
|
1390
1538
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1539
|
+
recordComments(n, idx);
|
|
1391
1540
|
return idx;
|
|
1392
1541
|
}
|
|
1393
1542
|
function enc_ts_type_operator(n) {
|
|
@@ -1397,6 +1546,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1397
1546
|
slotAt(idx, 0, c_type_annotation);
|
|
1398
1547
|
flagsAt(idx, 0 | (TS_TYPE_OPERATORS_INV[n.operator] | 0));
|
|
1399
1548
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1549
|
+
recordComments(n, idx);
|
|
1400
1550
|
return idx;
|
|
1401
1551
|
}
|
|
1402
1552
|
function enc_ts_parenthesized_type(n) {
|
|
@@ -1405,6 +1555,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1405
1555
|
tagAt(idx, 123);
|
|
1406
1556
|
slotAt(idx, 0, c_type_annotation);
|
|
1407
1557
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1558
|
+
recordComments(n, idx);
|
|
1408
1559
|
return idx;
|
|
1409
1560
|
}
|
|
1410
1561
|
function enc_ts_function_type(n) {
|
|
@@ -1415,6 +1566,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1415
1566
|
tagAt(idx, 124);
|
|
1416
1567
|
slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
|
|
1417
1568
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1569
|
+
recordComments(n, idx);
|
|
1418
1570
|
return idx;
|
|
1419
1571
|
}
|
|
1420
1572
|
function enc_ts_constructor_type(n) {
|
|
@@ -1426,6 +1578,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1426
1578
|
slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
|
|
1427
1579
|
flagsAt(idx, n.abstract ? 1 : 0);
|
|
1428
1580
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1581
|
+
recordComments(n, idx);
|
|
1429
1582
|
return idx;
|
|
1430
1583
|
}
|
|
1431
1584
|
function enc_ts_type_predicate(n) {
|
|
@@ -1437,6 +1590,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1437
1590
|
slotAt(idx, 1, c_type_annotation);
|
|
1438
1591
|
flagsAt(idx, 0 | (n.asserts ? 1 : 0));
|
|
1439
1592
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1593
|
+
recordComments(n, idx);
|
|
1440
1594
|
return idx;
|
|
1441
1595
|
}
|
|
1442
1596
|
function enc_ts_type_literal(n) {
|
|
@@ -1446,6 +1600,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1446
1600
|
f0At(idx, c_members.len);
|
|
1447
1601
|
slotAt(idx, 0, c_members.start);
|
|
1448
1602
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1603
|
+
recordComments(n, idx);
|
|
1449
1604
|
return idx;
|
|
1450
1605
|
}
|
|
1451
1606
|
function enc_ts_mapped_type(n) {
|
|
@@ -1456,8 +1611,11 @@ function encode(estree, comments, lineStarts) {
|
|
|
1456
1611
|
const idx = alloc();
|
|
1457
1612
|
tagAt(idx, 128);
|
|
1458
1613
|
slotAt(idx, 0, k); slotAt(idx, 1, c); slotAt(idx, 2, nt); slotAt(idx, 3, ta);
|
|
1459
|
-
flagsAt(idx,
|
|
1614
|
+
flagsAt(idx,
|
|
1615
|
+
(TS_MAPPED_OPTIONAL_INV(n.optional) << 0)
|
|
1616
|
+
| (TS_MAPPED_READONLY_INV(n.readonly) << 2));
|
|
1460
1617
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1618
|
+
recordComments(n, idx);
|
|
1461
1619
|
return idx;
|
|
1462
1620
|
}
|
|
1463
1621
|
function enc_ts_property_signature(n) {
|
|
@@ -1466,8 +1624,12 @@ function encode(estree, comments, lineStarts) {
|
|
|
1466
1624
|
const idx = alloc();
|
|
1467
1625
|
tagAt(idx, 129);
|
|
1468
1626
|
slotAt(idx, 0, k); slotAt(idx, 1, ta);
|
|
1469
|
-
flagsAt(idx,
|
|
1627
|
+
flagsAt(idx,
|
|
1628
|
+
(n.computed ? 1 : 0)
|
|
1629
|
+
| (n.optional ? 2 : 0)
|
|
1630
|
+
| (n.readonly ? 4 : 0));
|
|
1470
1631
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1632
|
+
recordComments(n, idx);
|
|
1471
1633
|
return idx;
|
|
1472
1634
|
}
|
|
1473
1635
|
function enc_ts_method_signature(n) {
|
|
@@ -1477,9 +1639,16 @@ function encode(estree, comments, lineStarts) {
|
|
|
1477
1639
|
const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
|
|
1478
1640
|
const idx = alloc();
|
|
1479
1641
|
tagAt(idx, 130);
|
|
1480
|
-
slotAt(idx, 0, k);
|
|
1481
|
-
|
|
1642
|
+
slotAt(idx, 0, k);
|
|
1643
|
+
slotAt(idx, 1, tp);
|
|
1644
|
+
slotAt(idx, 2, params);
|
|
1645
|
+
slotAt(idx, 3, rt_);
|
|
1646
|
+
flagsAt(idx,
|
|
1647
|
+
(n.computed ? 4 : 0)
|
|
1648
|
+
| (n.optional ? 8 : 0)
|
|
1649
|
+
| ((TS_METHOD_SIGNATURE_KINDS_INV[n.kind] | 0) << 0));
|
|
1482
1650
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1651
|
+
recordComments(n, idx);
|
|
1483
1652
|
return idx;
|
|
1484
1653
|
}
|
|
1485
1654
|
function enc_ts_call_signature_declaration(n) {
|
|
@@ -1490,6 +1659,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1490
1659
|
tagAt(idx, 131);
|
|
1491
1660
|
slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
|
|
1492
1661
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1662
|
+
recordComments(n, idx);
|
|
1493
1663
|
return idx;
|
|
1494
1664
|
}
|
|
1495
1665
|
function enc_ts_construct_signature_declaration(n) {
|
|
@@ -1500,6 +1670,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1500
1670
|
tagAt(idx, 132);
|
|
1501
1671
|
slotAt(idx, 0, tp); slotAt(idx, 1, params); slotAt(idx, 2, rt_);
|
|
1502
1672
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1673
|
+
recordComments(n, idx);
|
|
1503
1674
|
return idx;
|
|
1504
1675
|
}
|
|
1505
1676
|
function enc_ts_index_signature(n) {
|
|
@@ -1512,6 +1683,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1512
1683
|
slotAt(idx, 1, ta);
|
|
1513
1684
|
flagsAt(idx, (n.readonly ? 1 : 0) | (n.static ? 2 : 0));
|
|
1514
1685
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1686
|
+
recordComments(n, idx);
|
|
1515
1687
|
return idx;
|
|
1516
1688
|
}
|
|
1517
1689
|
function enc_ts_type_alias_declaration(n) {
|
|
@@ -1525,6 +1697,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1525
1697
|
slotAt(idx, 2, c_type_annotation);
|
|
1526
1698
|
flagsAt(idx, 0 | (n.declare ? 1 : 0));
|
|
1527
1699
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1700
|
+
recordComments(n, idx);
|
|
1528
1701
|
return idx;
|
|
1529
1702
|
}
|
|
1530
1703
|
function enc_ts_interface_declaration(n) {
|
|
@@ -1541,6 +1714,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1541
1714
|
slotAt(idx, 3, c_body);
|
|
1542
1715
|
flagsAt(idx, 0 | (n.declare ? 1 : 0));
|
|
1543
1716
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1717
|
+
recordComments(n, idx);
|
|
1544
1718
|
return idx;
|
|
1545
1719
|
}
|
|
1546
1720
|
function enc_ts_interface_body(n) {
|
|
@@ -1550,6 +1724,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1550
1724
|
f0At(idx, c_body.len);
|
|
1551
1725
|
slotAt(idx, 0, c_body.start);
|
|
1552
1726
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1727
|
+
recordComments(n, idx);
|
|
1553
1728
|
return idx;
|
|
1554
1729
|
}
|
|
1555
1730
|
function enc_ts_interface_heritage(n) {
|
|
@@ -1560,6 +1735,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1560
1735
|
slotAt(idx, 0, c_expression);
|
|
1561
1736
|
slotAt(idx, 1, c_type_arguments);
|
|
1562
1737
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1738
|
+
recordComments(n, idx);
|
|
1563
1739
|
return idx;
|
|
1564
1740
|
}
|
|
1565
1741
|
function enc_ts_class_implements(n) {
|
|
@@ -1570,6 +1746,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1570
1746
|
slotAt(idx, 0, c_expression);
|
|
1571
1747
|
slotAt(idx, 1, c_type_arguments);
|
|
1572
1748
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1749
|
+
recordComments(n, idx);
|
|
1573
1750
|
return idx;
|
|
1574
1751
|
}
|
|
1575
1752
|
function enc_ts_enum_declaration(n) {
|
|
@@ -1581,6 +1758,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1581
1758
|
slotAt(idx, 1, c_body);
|
|
1582
1759
|
flagsAt(idx, 0 | (n.const ? 1 : 0) | (n.declare ? 2 : 0));
|
|
1583
1760
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1761
|
+
recordComments(n, idx);
|
|
1584
1762
|
return idx;
|
|
1585
1763
|
}
|
|
1586
1764
|
function enc_ts_enum_body(n) {
|
|
@@ -1590,6 +1768,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1590
1768
|
f0At(idx, c_members.len);
|
|
1591
1769
|
slotAt(idx, 0, c_members.start);
|
|
1592
1770
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1771
|
+
recordComments(n, idx);
|
|
1593
1772
|
return idx;
|
|
1594
1773
|
}
|
|
1595
1774
|
function enc_ts_enum_member(n) {
|
|
@@ -1600,6 +1779,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1600
1779
|
slotAt(idx, 0, id); slotAt(idx, 1, init);
|
|
1601
1780
|
flagsAt(idx, n.computed ? 1 : 0);
|
|
1602
1781
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1782
|
+
recordComments(n, idx);
|
|
1603
1783
|
return idx;
|
|
1604
1784
|
}
|
|
1605
1785
|
function enc_ts_module_declaration(n) {
|
|
@@ -1611,6 +1791,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1611
1791
|
slotAt(idx, 1, body);
|
|
1612
1792
|
flagsAt(idx, ((TS_MODULE_KINDS_INV[n.kind] | 0) << 0) | (n.declare ? 2 : 0));
|
|
1613
1793
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1794
|
+
recordComments(n, idx);
|
|
1614
1795
|
return idx;
|
|
1615
1796
|
}
|
|
1616
1797
|
function enc_ts_module_block(n) {
|
|
@@ -1620,6 +1801,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1620
1801
|
f0At(idx, c_body.len);
|
|
1621
1802
|
slotAt(idx, 0, c_body.start);
|
|
1622
1803
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1804
|
+
recordComments(n, idx);
|
|
1623
1805
|
return idx;
|
|
1624
1806
|
}
|
|
1625
1807
|
function enc_ts_global_declaration(n) {
|
|
@@ -1631,6 +1813,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1631
1813
|
slotAt(idx, 1, body);
|
|
1632
1814
|
flagsAt(idx, n.declare ? 1 : 0);
|
|
1633
1815
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1816
|
+
recordComments(n, idx);
|
|
1634
1817
|
return idx;
|
|
1635
1818
|
}
|
|
1636
1819
|
function enc_ts_parameter_property(n) {
|
|
@@ -1643,6 +1826,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1643
1826
|
slotAt(idx, 1, c_parameter);
|
|
1644
1827
|
flagsAt(idx, 0 | (n.override ? 1 : 0) | (n.readonly ? 2 : 0) | (ACCESSIBILITY_INV(n.accessibility) << 2));
|
|
1645
1828
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1829
|
+
recordComments(n, idx);
|
|
1646
1830
|
return idx;
|
|
1647
1831
|
}
|
|
1648
1832
|
function enc_ts_this_parameter(n) {
|
|
@@ -1651,6 +1835,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1651
1835
|
tagAt(idx, 146);
|
|
1652
1836
|
slotAt(idx, 0, ta);
|
|
1653
1837
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1838
|
+
recordComments(n, idx);
|
|
1654
1839
|
return idx;
|
|
1655
1840
|
}
|
|
1656
1841
|
function enc_ts_as_expression(n) {
|
|
@@ -1661,6 +1846,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1661
1846
|
slotAt(idx, 0, c_expression);
|
|
1662
1847
|
slotAt(idx, 1, c_type_annotation);
|
|
1663
1848
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1849
|
+
recordComments(n, idx);
|
|
1664
1850
|
return idx;
|
|
1665
1851
|
}
|
|
1666
1852
|
function enc_ts_satisfies_expression(n) {
|
|
@@ -1671,6 +1857,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1671
1857
|
slotAt(idx, 0, c_expression);
|
|
1672
1858
|
slotAt(idx, 1, c_type_annotation);
|
|
1673
1859
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1860
|
+
recordComments(n, idx);
|
|
1674
1861
|
return idx;
|
|
1675
1862
|
}
|
|
1676
1863
|
function enc_ts_type_assertion(n) {
|
|
@@ -1681,6 +1868,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1681
1868
|
slotAt(idx, 0, c_type_annotation);
|
|
1682
1869
|
slotAt(idx, 1, c_expression);
|
|
1683
1870
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1871
|
+
recordComments(n, idx);
|
|
1684
1872
|
return idx;
|
|
1685
1873
|
}
|
|
1686
1874
|
function enc_ts_non_null_expression(n) {
|
|
@@ -1689,6 +1877,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1689
1877
|
tagAt(idx, 150);
|
|
1690
1878
|
slotAt(idx, 0, c_expression);
|
|
1691
1879
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1880
|
+
recordComments(n, idx);
|
|
1692
1881
|
return idx;
|
|
1693
1882
|
}
|
|
1694
1883
|
function enc_ts_instantiation_expression(n) {
|
|
@@ -1699,6 +1888,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1699
1888
|
slotAt(idx, 0, c_expression);
|
|
1700
1889
|
slotAt(idx, 1, c_type_arguments);
|
|
1701
1890
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1891
|
+
recordComments(n, idx);
|
|
1702
1892
|
return idx;
|
|
1703
1893
|
}
|
|
1704
1894
|
function enc_ts_export_assignment(n) {
|
|
@@ -1707,6 +1897,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1707
1897
|
tagAt(idx, 152);
|
|
1708
1898
|
slotAt(idx, 0, c_expression);
|
|
1709
1899
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1900
|
+
recordComments(n, idx);
|
|
1710
1901
|
return idx;
|
|
1711
1902
|
}
|
|
1712
1903
|
function enc_ts_namespace_export_declaration(n) {
|
|
@@ -1715,6 +1906,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1715
1906
|
tagAt(idx, 153);
|
|
1716
1907
|
slotAt(idx, 0, c_id);
|
|
1717
1908
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1909
|
+
recordComments(n, idx);
|
|
1718
1910
|
return idx;
|
|
1719
1911
|
}
|
|
1720
1912
|
function enc_ts_import_equals_declaration(n) {
|
|
@@ -1726,6 +1918,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1726
1918
|
slotAt(idx, 1, c_module_reference);
|
|
1727
1919
|
flagsAt(idx, 0 | (IMPORT_EXPORT_KINDS_INV[n.importKind] | 0));
|
|
1728
1920
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1921
|
+
recordComments(n, idx);
|
|
1729
1922
|
return idx;
|
|
1730
1923
|
}
|
|
1731
1924
|
function enc_ts_external_module_reference(n) {
|
|
@@ -1734,6 +1927,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1734
1927
|
tagAt(idx, 155);
|
|
1735
1928
|
slotAt(idx, 0, c_expression);
|
|
1736
1929
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1930
|
+
recordComments(n, idx);
|
|
1737
1931
|
return idx;
|
|
1738
1932
|
}
|
|
1739
1933
|
function enc_jsx_element(n) {
|
|
@@ -1747,6 +1941,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1747
1941
|
slotAt(idx, 1, c_children.start);
|
|
1748
1942
|
slotAt(idx, 2, c_closing_element);
|
|
1749
1943
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1944
|
+
recordComments(n, idx);
|
|
1750
1945
|
return idx;
|
|
1751
1946
|
}
|
|
1752
1947
|
function enc_jsx_opening_element(n) {
|
|
@@ -1761,6 +1956,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1761
1956
|
slotAt(idx, 2, c_type_arguments);
|
|
1762
1957
|
flagsAt(idx, 0 | (n.selfClosing ? 1 : 0));
|
|
1763
1958
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1959
|
+
recordComments(n, idx);
|
|
1764
1960
|
return idx;
|
|
1765
1961
|
}
|
|
1766
1962
|
function enc_jsx_closing_element(n) {
|
|
@@ -1769,6 +1965,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1769
1965
|
tagAt(idx, 158);
|
|
1770
1966
|
slotAt(idx, 0, c_name);
|
|
1771
1967
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1968
|
+
recordComments(n, idx);
|
|
1772
1969
|
return idx;
|
|
1773
1970
|
}
|
|
1774
1971
|
function enc_jsx_fragment(n) {
|
|
@@ -1782,18 +1979,21 @@ function encode(estree, comments, lineStarts) {
|
|
|
1782
1979
|
slotAt(idx, 1, c_children.start);
|
|
1783
1980
|
slotAt(idx, 2, c_closing_fragment);
|
|
1784
1981
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1982
|
+
recordComments(n, idx);
|
|
1785
1983
|
return idx;
|
|
1786
1984
|
}
|
|
1787
1985
|
function enc_jsx_opening_fragment(n) {
|
|
1788
1986
|
const idx = alloc();
|
|
1789
1987
|
tagAt(idx, 160);
|
|
1790
1988
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1989
|
+
recordComments(n, idx);
|
|
1791
1990
|
return idx;
|
|
1792
1991
|
}
|
|
1793
1992
|
function enc_jsx_closing_fragment(n) {
|
|
1794
1993
|
const idx = alloc();
|
|
1795
1994
|
tagAt(idx, 161);
|
|
1796
1995
|
spanAt(idx, asStart(n), asEnd(n));
|
|
1996
|
+
recordComments(n, idx);
|
|
1797
1997
|
return idx;
|
|
1798
1998
|
}
|
|
1799
1999
|
function enc_jsx_identifier(n) {
|
|
@@ -1803,6 +2003,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1803
2003
|
slotAt(idx, 0, c_name.start);
|
|
1804
2004
|
slotAt(idx, 1, c_name.end);
|
|
1805
2005
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2006
|
+
recordComments(n, idx);
|
|
1806
2007
|
return idx;
|
|
1807
2008
|
}
|
|
1808
2009
|
function enc_jsx_namespaced_name(n) {
|
|
@@ -1813,6 +2014,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1813
2014
|
slotAt(idx, 0, c_namespace);
|
|
1814
2015
|
slotAt(idx, 1, c_name);
|
|
1815
2016
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2017
|
+
recordComments(n, idx);
|
|
1816
2018
|
return idx;
|
|
1817
2019
|
}
|
|
1818
2020
|
function enc_jsx_member_expression(n) {
|
|
@@ -1823,6 +2025,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1823
2025
|
slotAt(idx, 0, c_object);
|
|
1824
2026
|
slotAt(idx, 1, c_property);
|
|
1825
2027
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2028
|
+
recordComments(n, idx);
|
|
1826
2029
|
return idx;
|
|
1827
2030
|
}
|
|
1828
2031
|
function enc_jsx_attribute(n) {
|
|
@@ -1833,6 +2036,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1833
2036
|
slotAt(idx, 0, c_name);
|
|
1834
2037
|
slotAt(idx, 1, c_value);
|
|
1835
2038
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2039
|
+
recordComments(n, idx);
|
|
1836
2040
|
return idx;
|
|
1837
2041
|
}
|
|
1838
2042
|
function enc_jsx_spread_attribute(n) {
|
|
@@ -1841,6 +2045,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1841
2045
|
tagAt(idx, 166);
|
|
1842
2046
|
slotAt(idx, 0, c_argument);
|
|
1843
2047
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2048
|
+
recordComments(n, idx);
|
|
1844
2049
|
return idx;
|
|
1845
2050
|
}
|
|
1846
2051
|
function enc_jsx_expression_container(n) {
|
|
@@ -1849,12 +2054,14 @@ function encode(estree, comments, lineStarts) {
|
|
|
1849
2054
|
tagAt(idx, 167);
|
|
1850
2055
|
slotAt(idx, 0, c_expression);
|
|
1851
2056
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2057
|
+
recordComments(n, idx);
|
|
1852
2058
|
return idx;
|
|
1853
2059
|
}
|
|
1854
2060
|
function enc_jsx_empty_expression(n) {
|
|
1855
2061
|
const idx = alloc();
|
|
1856
2062
|
tagAt(idx, 168);
|
|
1857
2063
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2064
|
+
recordComments(n, idx);
|
|
1858
2065
|
return idx;
|
|
1859
2066
|
}
|
|
1860
2067
|
function enc_jsx_text(n) {
|
|
@@ -1863,6 +2070,7 @@ function encode(estree, comments, lineStarts) {
|
|
|
1863
2070
|
tagAt(idx, 169);
|
|
1864
2071
|
slotAt(idx, 0, v.start); slotAt(idx, 1, v.end);
|
|
1865
2072
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2073
|
+
recordComments(n, idx);
|
|
1866
2074
|
return idx;
|
|
1867
2075
|
}
|
|
1868
2076
|
function enc_jsx_spread_child(n) {
|
|
@@ -1871,18 +2079,30 @@ function encode(estree, comments, lineStarts) {
|
|
|
1871
2079
|
tagAt(idx, 170);
|
|
1872
2080
|
slotAt(idx, 0, c_expression);
|
|
1873
2081
|
spanAt(idx, asStart(n), asEnd(n));
|
|
2082
|
+
recordComments(n, idx);
|
|
1874
2083
|
return idx;
|
|
1875
2084
|
}
|
|
2085
|
+
// encoded node index -> its `.comments` array
|
|
2086
|
+
const commentsByIdx = new Map();
|
|
1876
2087
|
function encNode(n) {
|
|
1877
2088
|
if (n == null) return NULL;
|
|
1878
2089
|
switch (n.type) {
|
|
1879
|
-
case "Identifier":
|
|
2090
|
+
case "Identifier": {
|
|
2091
|
+
switch (n.kind) {
|
|
2092
|
+
case "binding": return enc_binding_identifier(n);
|
|
2093
|
+
case "name": return enc_identifier_name(n);
|
|
2094
|
+
case "label": return enc_label_identifier(n);
|
|
2095
|
+
default: return enc_identifier_reference(n);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
1880
2098
|
case "PrivateIdentifier": return enc_private_identifier(n);
|
|
1881
2099
|
case "Literal": {
|
|
1882
2100
|
if (n.regex) return enc_regexp_literal(n);
|
|
1883
2101
|
if (typeof n.bigint === "string") return enc_bigint_literal(n);
|
|
1884
2102
|
const v = n.value;
|
|
1885
|
-
if (v === null) return typeof n.raw === "string" && n.raw !== "null"
|
|
2103
|
+
if (v === null) return typeof n.raw === "string" && n.raw !== "null"
|
|
2104
|
+
? enc_numeric_literal(n)
|
|
2105
|
+
: enc_null_literal(n);
|
|
1886
2106
|
if (typeof v === "boolean") return enc_boolean_literal(n);
|
|
1887
2107
|
if (typeof v === "string") return enc_string_literal(n);
|
|
1888
2108
|
if (typeof v === "number") return enc_numeric_literal(n);
|
|
@@ -1901,8 +2121,12 @@ function encode(estree, comments, lineStarts) {
|
|
|
1901
2121
|
case "AccessorProperty": return enc_property_definition(n, true, false);
|
|
1902
2122
|
case "TSAbstractAccessorProperty": return enc_property_definition(n, true, true);
|
|
1903
2123
|
case "RestElement": return enc_binding_rest_element(n);
|
|
1904
|
-
case "TSModuleDeclaration": return n.global
|
|
1905
|
-
|
|
2124
|
+
case "TSModuleDeclaration": return n.global
|
|
2125
|
+
? enc_ts_global_declaration(n)
|
|
2126
|
+
: enc_ts_module_declaration(n);
|
|
2127
|
+
case "ExpressionStatement": return n.directive != null
|
|
2128
|
+
? enc_directive(n)
|
|
2129
|
+
: enc_expression_statement(n);
|
|
1906
2130
|
case "SequenceExpression": return enc_sequence_expression(n);
|
|
1907
2131
|
case "ParenthesizedExpression": return enc_parenthesized_expression(n);
|
|
1908
2132
|
case "ArrowFunctionExpression": return enc_arrow_function_expression(n);
|
|
@@ -2052,27 +2276,44 @@ function encode(estree, comments, lineStarts) {
|
|
|
2052
2276
|
default: throw new Error("yuku-codegen: unsupported ESTree node type: " + n.type);
|
|
2053
2277
|
}
|
|
2054
2278
|
}
|
|
2055
|
-
const progIdx = encNode(
|
|
2056
|
-
|
|
2057
|
-
|
|
2279
|
+
const progIdx = encNode(root);
|
|
2280
|
+
const POSITION_INV = { "before": 0, "after": 1, "inside": 2 };
|
|
2281
|
+
// counting-sort comments by host into a prefix-sum offsets table,
|
|
2282
|
+
// then write each comment at its slot in `commentBytes`.
|
|
2283
|
+
const attachComments = commentsByIdx.size > 0;
|
|
2284
|
+
let commentCount = 0;
|
|
2285
|
+
let offsetsBytes = null;
|
|
2058
2286
|
let commentBytes = null;
|
|
2059
|
-
if (
|
|
2287
|
+
if (attachComments) {
|
|
2288
|
+
for (const arr of commentsByIdx.values()) commentCount += arr.length;
|
|
2289
|
+
const offsets = new Uint32Array(nodeCount + 1);
|
|
2290
|
+
for (const [idx, arr] of commentsByIdx) offsets[idx] = arr.length;
|
|
2291
|
+
let sum = 0;
|
|
2292
|
+
for (let i = 0; i < nodeCount; i++) {
|
|
2293
|
+
const c = offsets[i];
|
|
2294
|
+
offsets[i] = sum;
|
|
2295
|
+
sum += c;
|
|
2296
|
+
}
|
|
2297
|
+
offsets[nodeCount] = sum;
|
|
2298
|
+
offsetsBytes = offsets.buffer;
|
|
2060
2299
|
commentBytes = new ArrayBuffer(commentCount * COMMENT_SIZE);
|
|
2061
2300
|
const cU8 = new Uint8Array(commentBytes);
|
|
2062
2301
|
const cDV = new DataView(commentBytes);
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2302
|
+
const cursor = new Uint32Array(nodeCount);
|
|
2303
|
+
for (const [idx, arr] of commentsByIdx) {
|
|
2304
|
+
for (let j = 0; j < arr.length; j++) {
|
|
2305
|
+
const c = arr[j];
|
|
2306
|
+
const slot = offsets[idx] + cursor[idx]; cursor[idx]++;
|
|
2307
|
+
let f = 0;
|
|
2308
|
+
if (c.type === "Block") f |= 1;
|
|
2309
|
+
f |= ((POSITION_INV[c.position] ?? 0) & 3) << 1;
|
|
2310
|
+
if (c.sameLine) f |= 8;
|
|
2311
|
+
const v = encStr(typeof c.value === "string" ? c.value : "");
|
|
2312
|
+
const o = slot * COMMENT_SIZE;
|
|
2313
|
+
cU8[o + COMMENT_FLAGS_OFFSET] = f;
|
|
2314
|
+
cDV.setUint32(o + COMMENT_VALUE_START_OFFSET, v.start, true);
|
|
2315
|
+
cDV.setUint32(o + COMMENT_VALUE_END_OFFSET, v.end, true);
|
|
2316
|
+
}
|
|
2076
2317
|
}
|
|
2077
2318
|
}
|
|
2078
2319
|
const lineStartsCount = Array.isArray(lineStarts) ? lineStarts.length : 0;
|
|
@@ -2080,13 +2321,18 @@ function encode(estree, comments, lineStarts) {
|
|
|
2080
2321
|
if (lineStartsCount > 0) {
|
|
2081
2322
|
lineStartsBytes = new ArrayBuffer(lineStartsCount * 4);
|
|
2082
2323
|
const lsDV = new DataView(lineStartsBytes);
|
|
2083
|
-
for (let i = 0; i < lineStartsCount; i++)
|
|
2324
|
+
for (let i = 0; i < lineStartsCount; i++) {
|
|
2325
|
+
lsDV.setUint32(i * 4, lineStarts[i] >>> 0, true);
|
|
2326
|
+
}
|
|
2084
2327
|
}
|
|
2085
2328
|
const totalNodeBytes = nodeCount * NODE_SIZE;
|
|
2086
2329
|
const totalExtraBytes = extraCount * 4;
|
|
2330
|
+
const totalOffsetsBytes = attachComments ? (nodeCount + 1) * 4 : 0;
|
|
2087
2331
|
const totalCommentBytes = commentCount * COMMENT_SIZE;
|
|
2088
2332
|
const totalLineStartsBytes = lineStartsCount * 4;
|
|
2089
|
-
const finalSize =
|
|
2333
|
+
const finalSize =
|
|
2334
|
+
HEADER_SIZE + totalNodeBytes + totalExtraBytes + poolLen +
|
|
2335
|
+
totalOffsetsBytes + totalCommentBytes + totalLineStartsBytes;
|
|
2090
2336
|
const out = new ArrayBuffer(finalSize);
|
|
2091
2337
|
const outU8 = new Uint8Array(out);
|
|
2092
2338
|
const outU32 = new Uint32Array(out, 0, (finalSize >>> 2));
|
|
@@ -2098,16 +2344,18 @@ function encode(estree, comments, lineStarts) {
|
|
|
2098
2344
|
outU32[5] = lineStartsCount;
|
|
2099
2345
|
outU32[6] = 0;
|
|
2100
2346
|
outU32[7] = progIdx;
|
|
2101
|
-
outU32[8] = 0;
|
|
2347
|
+
outU32[8] = attachComments ? FLAG_ATTACH_COMMENTS : 0;
|
|
2102
2348
|
outU32[9] = 0;
|
|
2103
2349
|
const nodesOff = HEADER_SIZE;
|
|
2104
2350
|
const extrasOff = nodesOff + totalNodeBytes;
|
|
2105
2351
|
const poolOff = extrasOff + totalExtraBytes;
|
|
2106
|
-
const
|
|
2352
|
+
const offsetsOff = poolOff + poolLen;
|
|
2353
|
+
const commentsOff = offsetsOff + totalOffsetsBytes;
|
|
2107
2354
|
const lineStartsOff = commentsOff + totalCommentBytes;
|
|
2108
2355
|
outU8.set(new Uint8Array(nodeAB, 0, totalNodeBytes), nodesOff);
|
|
2109
2356
|
outU8.set(new Uint8Array(extras.buffer, 0, totalExtraBytes), extrasOff);
|
|
2110
2357
|
outU8.set(pool.subarray(0, poolLen), poolOff);
|
|
2358
|
+
if (offsetsBytes !== null) outU8.set(new Uint8Array(offsetsBytes), offsetsOff);
|
|
2111
2359
|
if (commentBytes !== null) outU8.set(new Uint8Array(commentBytes), commentsOff);
|
|
2112
2360
|
if (lineStartsBytes !== null) outU8.set(new Uint8Array(lineStartsBytes), lineStartsOff);
|
|
2113
2361
|
return out;
|