yuku-analyzer 0.5.36 → 0.5.37

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.
Files changed (5) hide show
  1. package/README.md +0 -15
  2. package/decode.js +340 -442
  3. package/index.d.ts +0 -32
  4. package/module.js +0 -56
  5. package/package.json +12 -12
package/README.md CHANGED
@@ -89,21 +89,6 @@ module.walk({
89
89
 
90
90
  The walk mutates in place: `ctx.replace(node)`, `ctx.remove()`, `ctx.insertBefore(node)`, `ctx.insertAfter(node)`, plus `ctx.skip()` and `ctx.stop()`. Transform the AST during the walk and print it with [`yuku-codegen`](https://www.npmjs.com/package/yuku-codegen).
91
91
 
92
- ## Scanning without building the AST
93
-
94
- `module.scan` visits the parsed node records directly in the binary buffer. Nothing is materialized unless you ask for it, and symbols and references resolve in index space:
95
-
96
- ```js
97
- const writes = [];
98
- module.scan({
99
- Identifier(cursor) {
100
- if (cursor.reference?.isWrite) writes.push(cursor.reference.name);
101
- },
102
- });
103
- ```
104
-
105
- This answers questions like "every write to an imported binding across 10,000 files" without constructing a single AST object. For semantic queries like this, scanning runs about 4x faster than the equivalent walk, since it never builds the AST. Scan to find, walk to change.
106
-
107
92
  ## Closure analysis
108
93
 
109
94
  `capturesOf` reports the free variables of any function: every outer binding it closes over, with the capturing reference sites and whether the function writes to the binding. Shadowing and aliasing are handled by the resolved reference table, not by name matching:
package/decode.js CHANGED
@@ -231,7 +231,7 @@ const SymbolFlags = Object.freeze({
231
231
  ValueSpace: 127,
232
232
  TypeSpace: 952,
233
233
  });
234
- const SCAN_CHILDREN = [
234
+ const CHILD_SLOTS = [
235
235
  [2, 2],
236
236
  [0, 2],
237
237
  [0, 2, 0, 3, 0, 4, 0, 5],
@@ -239,6 +239,7 @@ const SCAN_CHILDREN = [
239
239
  [2, 2],
240
240
  [2, 2],
241
241
  [2, 2, 0, 3],
242
+ [0, 2],
242
243
  [0, 2, 0, 3],
243
244
  [0, 2, 0, 3],
244
245
  [0, 2, 0, 3, 0, 4],
@@ -403,184 +404,179 @@ const SCAN_CHILDREN = [
403
404
  [],
404
405
  [0, 2],
405
406
  ];
406
- const TAG_TYPES = [
407
- "SequenceExpression",
408
- "ParenthesizedExpression",
409
- "ArrowFunctionExpression",
410
- 0,
411
- "BlockStatement",
412
- "BlockStatement",
413
- null,
414
- "BinaryExpression",
415
- "LogicalExpression",
416
- "ConditionalExpression",
417
- "UnaryExpression",
418
- "UpdateExpression",
419
- "AssignmentExpression",
420
- "ArrayExpression",
421
- "ObjectExpression",
422
- "SpreadElement",
423
- "Property",
424
- "MemberExpression",
425
- "CallExpression",
426
- "ChainExpression",
427
- "TaggedTemplateExpression",
428
- "NewExpression",
429
- "AwaitExpression",
430
- "YieldExpression",
431
- "MetaProperty",
432
- "Decorator",
433
- 0,
434
- "ClassBody",
435
- 0,
436
- 0,
437
- "StaticBlock",
438
- "Super",
439
- "Literal",
440
- "Literal",
441
- "Literal",
442
- "Literal",
443
- "Literal",
444
- "ThisExpression",
445
- "Literal",
446
- "TemplateLiteral",
447
- "TemplateElement",
448
- "Identifier",
449
- "PrivateIdentifier",
450
- "Identifier",
451
- "Identifier",
452
- "Identifier",
453
- "ExpressionStatement",
454
- "IfStatement",
455
- "SwitchStatement",
456
- "SwitchCase",
457
- "ForStatement",
458
- "ForInStatement",
459
- "ForOfStatement",
460
- "WhileStatement",
461
- "DoWhileStatement",
462
- "BreakStatement",
463
- "ContinueStatement",
464
- "LabeledStatement",
465
- "WithStatement",
466
- "ReturnStatement",
467
- "ThrowStatement",
468
- "TryStatement",
469
- "CatchClause",
470
- "DebuggerStatement",
471
- "EmptyStatement",
472
- "VariableDeclaration",
473
- "VariableDeclarator",
474
- "ExpressionStatement",
475
- "AssignmentPattern",
476
- "RestElement",
477
- "ArrayPattern",
478
- "ObjectPattern",
479
- "Property",
480
- "Program",
481
- "ImportExpression",
482
- "ImportDeclaration",
483
- "ImportSpecifier",
484
- "ImportDefaultSpecifier",
485
- "ImportNamespaceSpecifier",
486
- "ImportAttribute",
487
- "ExportNamedDeclaration",
488
- "ExportDefaultDeclaration",
489
- "ExportAllDeclaration",
490
- "ExportSpecifier",
491
- "TSTypeAnnotation",
492
- "TSAnyKeyword",
493
- "TSUnknownKeyword",
494
- "TSNeverKeyword",
495
- "TSVoidKeyword",
496
- "TSNullKeyword",
497
- "TSUndefinedKeyword",
498
- "TSStringKeyword",
499
- "TSNumberKeyword",
500
- "TSBigIntKeyword",
501
- "TSBooleanKeyword",
502
- "TSSymbolKeyword",
503
- "TSObjectKeyword",
504
- "TSIntrinsicKeyword",
505
- "TSThisType",
506
- "TSTypeReference",
507
- "TSQualifiedName",
508
- "TSTypeQuery",
509
- "TSImportType",
510
- "TSTypeParameter",
511
- "TSTypeParameterDeclaration",
512
- "TSTypeParameterInstantiation",
513
- "TSLiteralType",
514
- "TSTemplateLiteralType",
515
- "TSArrayType",
516
- "TSIndexedAccessType",
517
- "TSTupleType",
518
- "TSNamedTupleMember",
519
- "TSOptionalType",
520
- "TSRestType",
521
- "TSJSDocNullableType",
522
- "TSJSDocNonNullableType",
523
- "TSJSDocUnknownType",
524
- "TSUnionType",
525
- "TSIntersectionType",
526
- "TSConditionalType",
527
- "TSInferType",
528
- "TSTypeOperator",
529
- "TSParenthesizedType",
530
- "TSFunctionType",
531
- "TSConstructorType",
532
- "TSTypePredicate",
533
- "TSTypeLiteral",
534
- "TSMappedType",
535
- "TSPropertySignature",
536
- "TSMethodSignature",
537
- "TSCallSignatureDeclaration",
538
- "TSConstructSignatureDeclaration",
539
- "TSIndexSignature",
540
- "TSTypeAliasDeclaration",
541
- "TSInterfaceDeclaration",
542
- "TSInterfaceBody",
543
- "TSInterfaceHeritage",
544
- "TSClassImplements",
545
- "TSEnumDeclaration",
546
- "TSEnumBody",
547
- "TSEnumMember",
548
- "TSModuleDeclaration",
549
- "TSModuleBlock",
550
- "TSModuleDeclaration",
551
- "TSParameterProperty",
552
- "Identifier",
553
- "TSAsExpression",
554
- "TSSatisfiesExpression",
555
- "TSTypeAssertion",
556
- "TSNonNullExpression",
557
- "TSInstantiationExpression",
558
- "TSExportAssignment",
559
- "TSNamespaceExportDeclaration",
560
- "TSImportEqualsDeclaration",
561
- "TSExternalModuleReference",
562
- "JSXElement",
563
- "JSXOpeningElement",
564
- "JSXClosingElement",
565
- "JSXFragment",
566
- "JSXOpeningFragment",
567
- "JSXClosingFragment",
568
- "JSXIdentifier",
569
- "JSXNamespacedName",
570
- "JSXMemberExpression",
571
- "JSXAttribute",
572
- "JSXSpreadAttribute",
573
- "JSXExpressionContainer",
574
- "JSXEmptyExpression",
575
- "JSXText",
576
- "JSXSpreadChild",
407
+ const IS_NODE = [
408
+ true,
409
+ true,
410
+ true,
411
+ true,
412
+ true,
413
+ true,
414
+ false,
415
+ false,
416
+ true,
417
+ true,
418
+ true,
419
+ true,
420
+ true,
421
+ true,
422
+ true,
423
+ true,
424
+ true,
425
+ true,
426
+ true,
427
+ true,
428
+ true,
429
+ true,
430
+ true,
431
+ true,
432
+ true,
433
+ true,
434
+ true,
435
+ true,
436
+ true,
437
+ true,
438
+ true,
439
+ true,
440
+ true,
441
+ true,
442
+ true,
443
+ true,
444
+ true,
445
+ true,
446
+ true,
447
+ true,
448
+ true,
449
+ true,
450
+ true,
451
+ true,
452
+ true,
453
+ true,
454
+ true,
455
+ true,
456
+ true,
457
+ true,
458
+ true,
459
+ true,
460
+ true,
461
+ true,
462
+ true,
463
+ true,
464
+ true,
465
+ true,
466
+ true,
467
+ true,
468
+ true,
469
+ true,
470
+ true,
471
+ true,
472
+ true,
473
+ true,
474
+ true,
475
+ true,
476
+ true,
477
+ true,
478
+ true,
479
+ true,
480
+ true,
481
+ true,
482
+ true,
483
+ true,
484
+ true,
485
+ true,
486
+ true,
487
+ true,
488
+ true,
489
+ true,
490
+ true,
491
+ true,
492
+ true,
493
+ true,
494
+ true,
495
+ true,
496
+ true,
497
+ true,
498
+ true,
499
+ true,
500
+ true,
501
+ true,
502
+ true,
503
+ true,
504
+ true,
505
+ true,
506
+ true,
507
+ true,
508
+ true,
509
+ true,
510
+ true,
511
+ true,
512
+ true,
513
+ true,
514
+ true,
515
+ true,
516
+ true,
517
+ true,
518
+ true,
519
+ true,
520
+ true,
521
+ true,
522
+ true,
523
+ true,
524
+ true,
525
+ true,
526
+ true,
527
+ true,
528
+ true,
529
+ true,
530
+ true,
531
+ true,
532
+ true,
533
+ true,
534
+ true,
535
+ true,
536
+ true,
537
+ true,
538
+ true,
539
+ true,
540
+ true,
541
+ true,
542
+ true,
543
+ true,
544
+ true,
545
+ true,
546
+ true,
547
+ true,
548
+ true,
549
+ true,
550
+ true,
551
+ true,
552
+ true,
553
+ true,
554
+ true,
555
+ true,
556
+ true,
557
+ true,
558
+ true,
559
+ true,
560
+ true,
561
+ true,
562
+ true,
563
+ true,
564
+ true,
565
+ true,
566
+ true,
567
+ true,
568
+ true,
569
+ true,
570
+ true,
571
+ true,
572
+ true,
573
+ true,
574
+ true,
575
+ true,
576
+ true,
577
+ true,
578
+ true,
577
579
  ];
578
- const TAG_CHOICES = new Map([
579
- [3, ["FunctionDeclaration", "FunctionExpression", "TSDeclareFunction", "TSEmptyBodyFunctionExpression"]],
580
- [26, ["ClassDeclaration", "ClassExpression"]],
581
- [28, ["MethodDefinition", "TSAbstractMethodDefinition"]],
582
- [29, ["PropertyDefinition", "AccessorProperty", "TSAbstractPropertyDefinition", "TSAbstractAccessorProperty"]],
583
- ]);
584
580
  function buildPosMap(src, byteLen, startByte) {
585
581
  const m = new Uint32Array(byteLen - startByte + 1);
586
582
  const len = src.length;
@@ -774,30 +770,31 @@ function decode(buffer, source) {
774
770
  case 4: return { type: "BlockStatement", start, end, body: nodeArr(f1, f0) };
775
771
  case 5: return { type: "BlockStatement", start, end, body: nodeArr(f1, f0) };
776
772
  case 6: return { params: fnParams(i) };
777
- case 7: return { type: "BinaryExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: BINARY_OPS[flags & 31] };
778
- case 8: return { type: "LogicalExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: LOGICAL_OPS[flags & 3] };
779
- case 9: return { type: "ConditionalExpression", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
780
- case 10: return {
773
+ case 7: return node(f1);
774
+ case 8: return { type: "BinaryExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: BINARY_OPS[flags & 31] };
775
+ case 9: return { type: "LogicalExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: LOGICAL_OPS[flags & 3] };
776
+ case 10: return { type: "ConditionalExpression", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
777
+ case 11: return {
781
778
  type: "UnaryExpression", start, end,
782
779
  operator: UNARY_OPS[flags & 7], prefix: true,
783
780
  argument: f1 !== NULL ? node(f1) : null,
784
781
  };
785
- case 11: return { type: "UpdateExpression", start, end, argument: f1 !== NULL ? node(f1) : null, operator: UPDATE_OPS[flags & 1], prefix: !!(flags & 2) };
786
- case 12: return { type: "AssignmentExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: ASSIGNMENT_OPS[flags & 15] };
787
- case 13: return { type: "ArrayExpression", start, end, elements: nodeArrHoles(f1, f0) };
788
- case 14: return { type: "ObjectExpression", start, end, properties: nodeArr(f1, f0) };
789
- case 15: return { type: "SpreadElement", start, end, argument: f1 !== NULL ? node(f1) : null };
790
- case 16: { const r = { type: "Property", start, end, key: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null, kind: PROPERTY_KINDS[flags & 3], method: !!(flags & 4), shorthand: !!(flags & 8), computed: !!(flags & 16) }; if (_isTs) { r.optional = false; } return r; }
791
- case 17: return { type: "MemberExpression", start, end, object: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1), optional: !!(flags & 2) };
792
- case 18: { const r = { type: "CallExpression", start, end, callee: f1 !== NULL ? node(f1) : null, arguments: nodeArr(f2, f0), optional: !!(flags & 1) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
793
- case 19: return { type: "ChainExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
794
- case 20: { const r = { type: "TaggedTemplateExpression", start, end, tag: f1 !== NULL ? node(f1) : null, quasi: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
795
- case 21: { const r = { type: "NewExpression", start, end, callee: f1 !== NULL ? node(f1) : null, arguments: nodeArr(f2, f0) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
796
- case 22: return { type: "AwaitExpression", start, end, argument: f1 !== NULL ? node(f1) : null };
797
- case 23: return { type: "YieldExpression", start, end, argument: f1 !== NULL ? node(f1) : null, delegate: !!(flags & 1) };
798
- case 24: return { type: "MetaProperty", start, end, meta: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
799
- case 25: return { type: "Decorator", start, end, expression: f1 !== NULL ? node(f1) : null };
800
- case 26: {
782
+ case 12: return { type: "UpdateExpression", start, end, argument: f1 !== NULL ? node(f1) : null, operator: UPDATE_OPS[flags & 1], prefix: !!(flags & 2) };
783
+ case 13: return { type: "AssignmentExpression", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, operator: ASSIGNMENT_OPS[flags & 15] };
784
+ case 14: return { type: "ArrayExpression", start, end, elements: nodeArrHoles(f1, f0) };
785
+ case 15: return { type: "ObjectExpression", start, end, properties: nodeArr(f1, f0) };
786
+ case 16: return { type: "SpreadElement", start, end, argument: f1 !== NULL ? node(f1) : null };
787
+ case 17: { const r = { type: "Property", start, end, key: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null, kind: PROPERTY_KINDS[flags & 3], method: !!(flags & 4), shorthand: !!(flags & 8), computed: !!(flags & 16) }; if (_isTs) { r.optional = false; } return r; }
788
+ case 18: return { type: "MemberExpression", start, end, object: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1), optional: !!(flags & 2) };
789
+ case 19: { const r = { type: "CallExpression", start, end, callee: f1 !== NULL ? node(f1) : null, arguments: nodeArr(f2, f0), optional: !!(flags & 1) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
790
+ case 20: return { type: "ChainExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
791
+ case 21: { const r = { type: "TaggedTemplateExpression", start, end, tag: f1 !== NULL ? node(f1) : null, quasi: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
792
+ case 22: { const r = { type: "NewExpression", start, end, callee: f1 !== NULL ? node(f1) : null, arguments: nodeArr(f2, f0) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
793
+ case 23: return { type: "AwaitExpression", start, end, argument: f1 !== NULL ? node(f1) : null };
794
+ case 24: return { type: "YieldExpression", start, end, argument: f1 !== NULL ? node(f1) : null, delegate: !!(flags & 1) };
795
+ case 25: return { type: "MetaProperty", start, end, meta: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
796
+ case 26: return { type: "Decorator", start, end, expression: f1 !== NULL ? node(f1) : null };
797
+ case 27: {
801
798
  const r = {
802
799
  type: CLASS_TYPES[flags & 1], start, end,
803
800
  decorators: nodeArr(f1, f0),
@@ -814,8 +811,8 @@ function decode(buffer, source) {
814
811
  }
815
812
  return r;
816
813
  }
817
- case 27: return { type: "ClassBody", start, end, body: nodeArr(f1, f0) };
818
- case 28: {
814
+ case 28: return { type: "ClassBody", start, end, body: nodeArr(f1, f0) };
815
+ case 29: {
819
816
  const r = {
820
817
  type: "MethodDefinition", start, end,
821
818
  decorators: nodeArr(f1, f0),
@@ -832,7 +829,7 @@ function decode(buffer, source) {
832
829
  }
833
830
  return r;
834
831
  }
835
- case 29: {
832
+ case 30: {
836
833
  const _acc = !!(flags & 4);
837
834
  const r = {
838
835
  type: _acc ? "AccessorProperty" : "PropertyDefinition",
@@ -858,13 +855,13 @@ function decode(buffer, source) {
858
855
  }
859
856
  return r;
860
857
  }
861
- case 30: return { type: "StaticBlock", start, end, body: nodeArr(f1, f0) };
862
- case 31: return { type: "Super", start, end };
863
- case 32: return {
858
+ case 31: return { type: "StaticBlock", start, end, body: nodeArr(f1, f0) };
859
+ case 32: return { type: "Super", start, end };
860
+ case 33: return {
864
861
  type: "Literal", start, end,
865
862
  value: str(f1, f2), raw: _src.slice(start, end),
866
863
  };
867
- case 33: {
864
+ case 34: {
868
865
  const r = _src.slice(start, end);
869
866
  const s = r.indexOf("_") === -1 ? r : r.replace(/_/g, "");
870
867
  const v = (flags & 3) === 2 && s[1] !== "o" && s[1] !== "O"
@@ -876,7 +873,7 @@ function decode(buffer, source) {
876
873
  raw: r,
877
874
  };
878
875
  }
879
- case 34: {
876
+ case 35: {
880
877
  const r = _src.slice(start, end);
881
878
  const d = str(f1, f2).replace(/_/g, "");
882
879
  const v = BigInt(d);
@@ -885,16 +882,16 @@ function decode(buffer, source) {
885
882
  value: v, raw: r, bigint: v.toString(),
886
883
  };
887
884
  }
888
- case 35: {
885
+ case 36: {
889
886
  const v = !!(flags & 1);
890
887
  return {
891
888
  type: "Literal", start, end,
892
889
  value: v, raw: v ? "true" : "false",
893
890
  };
894
891
  }
895
- case 36: return { type: "Literal", start, end, value: null, raw: "null" };
896
- case 37: return { type: "ThisExpression", start, end };
897
- case 38: {
892
+ case 37: return { type: "Literal", start, end, value: null, raw: "null" };
893
+ case 38: return { type: "ThisExpression", start, end };
894
+ case 39: {
898
895
  const p = str(f1, f2), fl = str(f3, f4);
899
896
  let v = null;
900
897
  try { v = new RegExp(p, fl); } catch {}
@@ -904,8 +901,8 @@ function decode(buffer, source) {
904
901
  regex: { pattern: p, flags: fl.split("").sort().join("") },
905
902
  };
906
903
  }
907
- case 39: return { type: "TemplateLiteral", start, end, quasis: nodeArr(f1, f0), expressions: nodeArr(f2, f3) };
908
- case 40: {
904
+ case 40: return { type: "TemplateLiteral", start, end, quasis: nodeArr(f1, f0), expressions: nodeArr(f2, f3) };
905
+ case 41: {
909
906
  const raw = _src.slice(start, end).replace(/\r\n?/g, "\n");
910
907
  const tl = !!(flags & 1);
911
908
  const s = _isTs ? start - 1 : start;
@@ -919,39 +916,39 @@ function decode(buffer, source) {
919
916
  tail: tl,
920
917
  };
921
918
  }
922
- case 41: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
923
- case 42: return { type: "PrivateIdentifier", start, end, name: str(f1, f2) };
924
- case 43: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
925
- case 44: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
919
+ case 42: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
920
+ case 43: return { type: "PrivateIdentifier", start, end, name: str(f1, f2) };
921
+ case 44: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
926
922
  case 45: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
927
- case 46: { const r = { type: "ExpressionStatement", start, end, expression: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.directive = null; } return r; }
928
- case 47: return { type: "IfStatement", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
929
- case 48: return { type: "SwitchStatement", start, end, discriminant: f1 !== NULL ? node(f1) : null, cases: nodeArr(f2, f0) };
930
- case 49: return { type: "SwitchCase", start, end, test: f1 !== NULL ? node(f1) : null, consequent: nodeArr(f2, f0) };
931
- case 50: return { type: "ForStatement", start, end, init: f1 !== NULL ? node(f1) : null, test: f2 !== NULL ? node(f2) : null, update: f3 !== NULL ? node(f3) : null, body: f4 !== NULL ? node(f4) : null };
932
- case 51: return { type: "ForInStatement", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, body: f3 !== NULL ? node(f3) : null };
933
- case 52: return { type: "ForOfStatement", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, body: f3 !== NULL ? node(f3) : null, await: !!(flags & 1) };
934
- case 53: return { type: "WhileStatement", start, end, test: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
935
- case 54: return { type: "DoWhileStatement", start, end, body: f1 !== NULL ? node(f1) : null, test: f2 !== NULL ? node(f2) : null };
936
- case 55: return { type: "BreakStatement", start, end, label: f1 !== NULL ? node(f1) : null };
937
- case 56: return { type: "ContinueStatement", start, end, label: f1 !== NULL ? node(f1) : null };
938
- case 57: return { type: "LabeledStatement", start, end, label: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
939
- case 58: return { type: "WithStatement", start, end, object: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
940
- case 59: return { type: "ReturnStatement", start, end, argument: f1 !== NULL ? node(f1) : null };
941
- case 60: return { type: "ThrowStatement", start, end, argument: f1 !== NULL ? node(f1) : null };
942
- case 61: return { type: "TryStatement", start, end, block: f1 !== NULL ? node(f1) : null, handler: f2 !== NULL ? node(f2) : null, finalizer: f3 !== NULL ? node(f3) : null };
943
- case 62: return { type: "CatchClause", start, end, param: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
944
- case 63: return { type: "DebuggerStatement", start, end };
945
- case 64: return { type: "EmptyStatement", start, end };
946
- case 65: { const r = { type: "VariableDeclaration", start, end, kind: VAR_KINDS[flags & 7], declarations: nodeArr(f1, f0) }; if (_isTs) { r.declare = !!(flags & 8); } return r; }
947
- case 66: { const r = { type: "VariableDeclarator", start, end, id: f1 !== NULL ? node(f1) : null, init: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.definite = !!(flags & 1); } return r; }
948
- case 67: return {
923
+ case 46: { const r = { type: "Identifier", start, end, name: str(f1, f2) }; if (_isTs) { r.decorators = []; r.optional = false; r.typeAnnotation = null; } return r; }
924
+ case 47: { const r = { type: "ExpressionStatement", start, end, expression: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.directive = null; } return r; }
925
+ case 48: return { type: "IfStatement", start, end, test: f1 !== NULL ? node(f1) : null, consequent: f2 !== NULL ? node(f2) : null, alternate: f3 !== NULL ? node(f3) : null };
926
+ case 49: return { type: "SwitchStatement", start, end, discriminant: f1 !== NULL ? node(f1) : null, cases: nodeArr(f2, f0) };
927
+ case 50: return { type: "SwitchCase", start, end, test: f1 !== NULL ? node(f1) : null, consequent: nodeArr(f2, f0) };
928
+ case 51: return { type: "ForStatement", start, end, init: f1 !== NULL ? node(f1) : null, test: f2 !== NULL ? node(f2) : null, update: f3 !== NULL ? node(f3) : null, body: f4 !== NULL ? node(f4) : null };
929
+ case 52: return { type: "ForInStatement", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, body: f3 !== NULL ? node(f3) : null };
930
+ case 53: return { type: "ForOfStatement", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null, body: f3 !== NULL ? node(f3) : null, await: !!(flags & 1) };
931
+ case 54: return { type: "WhileStatement", start, end, test: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
932
+ case 55: return { type: "DoWhileStatement", start, end, body: f1 !== NULL ? node(f1) : null, test: f2 !== NULL ? node(f2) : null };
933
+ case 56: return { type: "BreakStatement", start, end, label: f1 !== NULL ? node(f1) : null };
934
+ case 57: return { type: "ContinueStatement", start, end, label: f1 !== NULL ? node(f1) : null };
935
+ case 58: return { type: "LabeledStatement", start, end, label: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
936
+ case 59: return { type: "WithStatement", start, end, object: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
937
+ case 60: return { type: "ReturnStatement", start, end, argument: f1 !== NULL ? node(f1) : null };
938
+ case 61: return { type: "ThrowStatement", start, end, argument: f1 !== NULL ? node(f1) : null };
939
+ case 62: return { type: "TryStatement", start, end, block: f1 !== NULL ? node(f1) : null, handler: f2 !== NULL ? node(f2) : null, finalizer: f3 !== NULL ? node(f3) : null };
940
+ case 63: return { type: "CatchClause", start, end, param: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null };
941
+ case 64: return { type: "DebuggerStatement", start, end };
942
+ case 65: return { type: "EmptyStatement", start, end };
943
+ case 66: { const r = { type: "VariableDeclaration", start, end, kind: VAR_KINDS[flags & 7], declarations: nodeArr(f1, f0) }; if (_isTs) { r.declare = !!(flags & 8); } return r; }
944
+ case 67: { const r = { type: "VariableDeclarator", start, end, id: f1 !== NULL ? node(f1) : null, init: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.definite = !!(flags & 1); } return r; }
945
+ case 68: return {
949
946
  type: "ExpressionStatement", start, end,
950
947
  expression: node(f1), directive: str(f2, f3),
951
948
  };
952
- case 68: { const r = { type: "AssignmentPattern", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
953
- case 69: { const r = { type: "RestElement", start, end, argument: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.decorators = nodeArr(f2, f0); r.typeAnnotation = f3 !== NULL ? node(f3) : null; r.optional = !!(flags & 1); r.value = null; } return r; }
954
- case 70: {
949
+ case 69: { const r = { type: "AssignmentPattern", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.decorators = nodeArr(f3, f0); r.typeAnnotation = f4 !== NULL ? node(f4) : null; r.optional = !!(flags & 1); } return r; }
950
+ case 70: { const r = { type: "RestElement", start, end, argument: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.decorators = nodeArr(f2, f0); r.typeAnnotation = f3 !== NULL ? node(f3) : null; r.optional = !!(flags & 1); r.value = null; } return r; }
951
+ case 71: {
955
952
  const el = nodeArrHoles(f1, f0);
956
953
  if (f2 !== NULL) el.push(node(f2));
957
954
  const r = { type: "ArrayPattern", start, end, elements: el };
@@ -962,7 +959,7 @@ function decode(buffer, source) {
962
959
  }
963
960
  return r;
964
961
  }
965
- case 71: {
962
+ case 72: {
966
963
  const pr = nodeArr(f1, f0);
967
964
  if (f2 !== NULL) pr.push(node(f2));
968
965
  const r = { type: "ObjectPattern", start, end, properties: pr };
@@ -973,7 +970,7 @@ function decode(buffer, source) {
973
970
  }
974
971
  return r;
975
972
  }
976
- case 72: {
973
+ case 73: {
977
974
  const r = {
978
975
  type: "Property", start, end,
979
976
  kind: "init",
@@ -982,7 +979,7 @@ function decode(buffer, source) {
982
979
  shorthand: !!(flags & 1),
983
980
  computed: !!(flags & 2),
984
981
  }; if (_isTs) { r.optional = false; } return r; }
985
- case 73: return {
982
+ case 74: return {
986
983
  type: "Program", start, end,
987
984
  sourceType: (flags & 1) ? "module" : "script",
988
985
  hashbang: (flags & 2) ? {
@@ -992,71 +989,71 @@ function decode(buffer, source) {
992
989
  } : null,
993
990
  body: nodeArr(f1, f0),
994
991
  };
995
- case 74: return { type: "ImportExpression", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null };
996
- case 75: { const r = { type: "ImportDeclaration", start, end, specifiers: nodeArr(f1, f0), source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f4), phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[(flags >> 2) & 1]; } return r; }
997
- case 76: { const r = { type: "ImportSpecifier", start, end, imported: f1 !== NULL ? node(f1) : null, local: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
998
- case 77: return { type: "ImportDefaultSpecifier", start, end, local: f1 !== NULL ? node(f1) : null };
999
- case 78: return { type: "ImportNamespaceSpecifier", start, end, local: f1 !== NULL ? node(f1) : null };
1000
- case 79: return { type: "ImportAttribute", start, end, key: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null };
1001
- case 80: { const r = { type: "ExportNamedDeclaration", start, end, declaration: f1 !== NULL ? node(f1) : null, specifiers: nodeArr(f2, f0), source: f3 !== NULL ? node(f3) : null, attributes: nodeArr(f4, f5) }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
1002
- case 81: { const r = { type: "ExportDefaultDeclaration", start, end, declaration: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.exportKind = "value"; } return r; }
1003
- case 82: { const r = { type: "ExportAllDeclaration", start, end, exported: f1 !== NULL ? node(f1) : null, source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f0) }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
1004
- case 83: { const r = { type: "ExportSpecifier", start, end, local: f1 !== NULL ? node(f1) : null, exported: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
1005
- case 84: return { type: "TSTypeAnnotation", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1006
- case 85: return { type: "TSAnyKeyword", start, end };
1007
- case 86: return { type: "TSUnknownKeyword", start, end };
1008
- case 87: return { type: "TSNeverKeyword", start, end };
1009
- case 88: return { type: "TSVoidKeyword", start, end };
1010
- case 89: return { type: "TSNullKeyword", start, end };
1011
- case 90: return { type: "TSUndefinedKeyword", start, end };
1012
- case 91: return { type: "TSStringKeyword", start, end };
1013
- case 92: return { type: "TSNumberKeyword", start, end };
1014
- case 93: return { type: "TSBigIntKeyword", start, end };
1015
- case 94: return { type: "TSBooleanKeyword", start, end };
1016
- case 95: return { type: "TSSymbolKeyword", start, end };
1017
- case 96: return { type: "TSObjectKeyword", start, end };
1018
- case 97: return { type: "TSIntrinsicKeyword", start, end };
1019
- case 98: return { type: "TSThisType", start, end };
1020
- case 99: return { type: "TSTypeReference", start, end, typeName: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1021
- case 100: return { type: "TSQualifiedName", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null };
1022
- case 101: return { type: "TSTypeQuery", start, end, exprName: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1023
- case 102: return { type: "TSImportType", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, qualifier: f3 !== NULL ? node(f3) : null, typeArguments: f4 !== NULL ? node(f4) : null };
1024
- case 103: return { type: "TSTypeParameter", start, end, name: f1 !== NULL ? node(f1) : null, constraint: f2 !== NULL ? node(f2) : null, default: f3 !== NULL ? node(f3) : null, in: !!(flags & 1), out: !!(flags & 2), const: !!(flags & 4) };
1025
- case 104: return { type: "TSTypeParameterDeclaration", start, end, params: nodeArr(f1, f0) };
1026
- case 105: return { type: "TSTypeParameterInstantiation", start, end, params: nodeArr(f1, f0) };
1027
- case 106: return { type: "TSLiteralType", start, end, literal: f1 !== NULL ? node(f1) : null };
1028
- case 107: return { type: "TSTemplateLiteralType", start, end, quasis: nodeArr(f1, f0), types: nodeArr(f2, f3) };
1029
- case 108: return { type: "TSArrayType", start, end, elementType: f1 !== NULL ? node(f1) : null };
1030
- case 109: return { type: "TSIndexedAccessType", start, end, objectType: f1 !== NULL ? node(f1) : null, indexType: f2 !== NULL ? node(f2) : null };
1031
- case 110: return { type: "TSTupleType", start, end, elementTypes: nodeArr(f1, f0) };
1032
- case 111: return { type: "TSNamedTupleMember", start, end, label: f1 !== NULL ? node(f1) : null, elementType: f2 !== NULL ? node(f2) : null, optional: !!(flags & 1) };
1033
- case 112: return { type: "TSOptionalType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1034
- case 113: return { type: "TSRestType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1035
- case 114: return { type: "TSJSDocNullableType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, postfix: !!(flags & 1) };
1036
- case 115: return { type: "TSJSDocNonNullableType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, postfix: !!(flags & 1) };
1037
- case 116: return { type: "TSJSDocUnknownType", start, end };
1038
- case 117: return { type: "TSUnionType", start, end, types: nodeArr(f1, f0) };
1039
- case 118: return { type: "TSIntersectionType", start, end, types: nodeArr(f1, f0) };
1040
- case 119: return { type: "TSConditionalType", start, end, checkType: f1 !== NULL ? node(f1) : null, extendsType: f2 !== NULL ? node(f2) : null, trueType: f3 !== NULL ? node(f3) : null, falseType: f4 !== NULL ? node(f4) : null };
1041
- case 120: return { type: "TSInferType", start, end, typeParameter: f1 !== NULL ? node(f1) : null };
1042
- case 121: return { type: "TSTypeOperator", start, end, operator: TS_TYPE_OPERATORS[flags & 3], typeAnnotation: f1 !== NULL ? node(f1) : null };
1043
- case 122: return { type: "TSParenthesizedType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1044
- case 123: return {
992
+ case 75: return { type: "ImportExpression", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null };
993
+ case 76: { const r = { type: "ImportDeclaration", start, end, specifiers: nodeArr(f1, f0), source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f4), phase: (flags & 1) ? ["source", "defer"][(flags >> 1) & 1] : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[(flags >> 2) & 1]; } return r; }
994
+ case 77: { const r = { type: "ImportSpecifier", start, end, imported: f1 !== NULL ? node(f1) : null, local: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.importKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
995
+ case 78: return { type: "ImportDefaultSpecifier", start, end, local: f1 !== NULL ? node(f1) : null };
996
+ case 79: return { type: "ImportNamespaceSpecifier", start, end, local: f1 !== NULL ? node(f1) : null };
997
+ case 80: return { type: "ImportAttribute", start, end, key: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null };
998
+ case 81: { const r = { type: "ExportNamedDeclaration", start, end, declaration: f1 !== NULL ? node(f1) : null, specifiers: nodeArr(f2, f0), source: f3 !== NULL ? node(f3) : null, attributes: nodeArr(f4, f5) }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
999
+ case 82: { const r = { type: "ExportDefaultDeclaration", start, end, declaration: f1 !== NULL ? node(f1) : null }; if (_isTs) { r.exportKind = "value"; } return r; }
1000
+ case 83: { const r = { type: "ExportAllDeclaration", start, end, exported: f1 !== NULL ? node(f1) : null, source: f2 !== NULL ? node(f2) : null, attributes: nodeArr(f3, f0) }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
1001
+ case 84: { const r = { type: "ExportSpecifier", start, end, local: f1 !== NULL ? node(f1) : null, exported: f2 !== NULL ? node(f2) : null }; if (_isTs) { r.exportKind = IMPORT_EXPORT_KINDS[flags & 1]; } return r; }
1002
+ case 85: return { type: "TSTypeAnnotation", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1003
+ case 86: return { type: "TSAnyKeyword", start, end };
1004
+ case 87: return { type: "TSUnknownKeyword", start, end };
1005
+ case 88: return { type: "TSNeverKeyword", start, end };
1006
+ case 89: return { type: "TSVoidKeyword", start, end };
1007
+ case 90: return { type: "TSNullKeyword", start, end };
1008
+ case 91: return { type: "TSUndefinedKeyword", start, end };
1009
+ case 92: return { type: "TSStringKeyword", start, end };
1010
+ case 93: return { type: "TSNumberKeyword", start, end };
1011
+ case 94: return { type: "TSBigIntKeyword", start, end };
1012
+ case 95: return { type: "TSBooleanKeyword", start, end };
1013
+ case 96: return { type: "TSSymbolKeyword", start, end };
1014
+ case 97: return { type: "TSObjectKeyword", start, end };
1015
+ case 98: return { type: "TSIntrinsicKeyword", start, end };
1016
+ case 99: return { type: "TSThisType", start, end };
1017
+ case 100: return { type: "TSTypeReference", start, end, typeName: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1018
+ case 101: return { type: "TSQualifiedName", start, end, left: f1 !== NULL ? node(f1) : null, right: f2 !== NULL ? node(f2) : null };
1019
+ case 102: return { type: "TSTypeQuery", start, end, exprName: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1020
+ case 103: return { type: "TSImportType", start, end, source: f1 !== NULL ? node(f1) : null, options: f2 !== NULL ? node(f2) : null, qualifier: f3 !== NULL ? node(f3) : null, typeArguments: f4 !== NULL ? node(f4) : null };
1021
+ case 104: return { type: "TSTypeParameter", start, end, name: f1 !== NULL ? node(f1) : null, constraint: f2 !== NULL ? node(f2) : null, default: f3 !== NULL ? node(f3) : null, in: !!(flags & 1), out: !!(flags & 2), const: !!(flags & 4) };
1022
+ case 105: return { type: "TSTypeParameterDeclaration", start, end, params: nodeArr(f1, f0) };
1023
+ case 106: return { type: "TSTypeParameterInstantiation", start, end, params: nodeArr(f1, f0) };
1024
+ case 107: return { type: "TSLiteralType", start, end, literal: f1 !== NULL ? node(f1) : null };
1025
+ case 108: return { type: "TSTemplateLiteralType", start, end, quasis: nodeArr(f1, f0), types: nodeArr(f2, f3) };
1026
+ case 109: return { type: "TSArrayType", start, end, elementType: f1 !== NULL ? node(f1) : null };
1027
+ case 110: return { type: "TSIndexedAccessType", start, end, objectType: f1 !== NULL ? node(f1) : null, indexType: f2 !== NULL ? node(f2) : null };
1028
+ case 111: return { type: "TSTupleType", start, end, elementTypes: nodeArr(f1, f0) };
1029
+ case 112: return { type: "TSNamedTupleMember", start, end, label: f1 !== NULL ? node(f1) : null, elementType: f2 !== NULL ? node(f2) : null, optional: !!(flags & 1) };
1030
+ case 113: return { type: "TSOptionalType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1031
+ case 114: return { type: "TSRestType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1032
+ case 115: return { type: "TSJSDocNullableType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, postfix: !!(flags & 1) };
1033
+ case 116: return { type: "TSJSDocNonNullableType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, postfix: !!(flags & 1) };
1034
+ case 117: return { type: "TSJSDocUnknownType", start, end };
1035
+ case 118: return { type: "TSUnionType", start, end, types: nodeArr(f1, f0) };
1036
+ case 119: return { type: "TSIntersectionType", start, end, types: nodeArr(f1, f0) };
1037
+ case 120: return { type: "TSConditionalType", start, end, checkType: f1 !== NULL ? node(f1) : null, extendsType: f2 !== NULL ? node(f2) : null, trueType: f3 !== NULL ? node(f3) : null, falseType: f4 !== NULL ? node(f4) : null };
1038
+ case 121: return { type: "TSInferType", start, end, typeParameter: f1 !== NULL ? node(f1) : null };
1039
+ case 122: return { type: "TSTypeOperator", start, end, operator: TS_TYPE_OPERATORS[flags & 3], typeAnnotation: f1 !== NULL ? node(f1) : null };
1040
+ case 123: return { type: "TSParenthesizedType", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null };
1041
+ case 124: return {
1045
1042
  type: "TSFunctionType", start, end,
1046
1043
  typeParameters: f1 !== NULL ? node(f1) : null,
1047
1044
  params: f2 !== NULL ? fnParams(f2) : [],
1048
1045
  returnType: f3 !== NULL ? node(f3) : null,
1049
1046
  };
1050
- case 124: return {
1047
+ case 125: return {
1051
1048
  type: "TSConstructorType", start, end,
1052
1049
  abstract: !!(flags & 1),
1053
1050
  typeParameters: f1 !== NULL ? node(f1) : null,
1054
1051
  params: f2 !== NULL ? fnParams(f2) : [],
1055
1052
  returnType: f3 !== NULL ? node(f3) : null,
1056
1053
  };
1057
- case 125: return { type: "TSTypePredicate", start, end, parameterName: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null, asserts: !!(flags & 1) };
1058
- case 126: return { type: "TSTypeLiteral", start, end, members: nodeArr(f1, f0) };
1059
- case 127: return {
1054
+ case 126: return { type: "TSTypePredicate", start, end, parameterName: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null, asserts: !!(flags & 1) };
1055
+ case 127: return { type: "TSTypeLiteral", start, end, members: nodeArr(f1, f0) };
1056
+ case 128: return {
1060
1057
  type: "TSMappedType", start, end,
1061
1058
  key: node(f1),
1062
1059
  constraint: node(f2),
@@ -1065,8 +1062,8 @@ function decode(buffer, source) {
1065
1062
  optional: TS_MAPPED_OPTIONAL[(flags >> 0) & 3],
1066
1063
  readonly: TS_MAPPED_READONLY[(flags >> 2) & 3],
1067
1064
  };
1068
- case 128: { const r = { type: "TSPropertySignature", start, end, key: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1), optional: !!(flags & 2), readonly: !!(flags & 4) }; if (_isTs) { r.accessibility = null; r.static = false; } return r; }
1069
- case 129: return {
1065
+ case 129: { const r = { type: "TSPropertySignature", start, end, key: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1), optional: !!(flags & 2), readonly: !!(flags & 4) }; if (_isTs) { r.accessibility = null; r.static = false; } return r; }
1066
+ case 130: return {
1070
1067
  type: "TSMethodSignature", start, end,
1071
1068
  key: node(f1),
1072
1069
  computed: !!(flags & 4),
@@ -1077,28 +1074,28 @@ function decode(buffer, source) {
1077
1074
  returnType: f4 !== NULL ? node(f4) : null,
1078
1075
  accessibility: null, readonly: false, static: false,
1079
1076
  };
1080
- case 130: return {
1077
+ case 131: return {
1081
1078
  type: "TSCallSignatureDeclaration", start, end,
1082
1079
  typeParameters: f1 !== NULL ? node(f1) : null,
1083
1080
  params: f2 !== NULL ? fnParams(f2) : [],
1084
1081
  returnType: f3 !== NULL ? node(f3) : null,
1085
1082
  };
1086
- case 131: return {
1083
+ case 132: return {
1087
1084
  type: "TSConstructSignatureDeclaration", start, end,
1088
1085
  typeParameters: f1 !== NULL ? node(f1) : null,
1089
1086
  params: f2 !== NULL ? fnParams(f2) : [],
1090
1087
  returnType: f3 !== NULL ? node(f3) : null,
1091
1088
  };
1092
- case 132: { const r = { type: "TSIndexSignature", start, end, parameters: nodeArr(f1, f0), typeAnnotation: f2 !== NULL ? node(f2) : null, readonly: !!(flags & 1) }; if (_isTs) { r.static = !!(flags & 2); r.accessibility = null; } return r; }
1093
- case 133: return { type: "TSTypeAliasDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, typeAnnotation: f3 !== NULL ? node(f3) : null, declare: !!(flags & 1) };
1094
- case 134: return { type: "TSInterfaceDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, extends: nodeArr(f3, f0), body: f4 !== NULL ? node(f4) : null, declare: !!(flags & 1) };
1095
- case 135: return { type: "TSInterfaceBody", start, end, body: nodeArr(f1, f0) };
1096
- case 136: return { type: "TSInterfaceHeritage", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1097
- case 137: return { type: "TSClassImplements", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1098
- case 138: return { type: "TSEnumDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null, const: !!(flags & 1), declare: !!(flags & 2) };
1099
- case 139: return { type: "TSEnumBody", start, end, members: nodeArr(f1, f0) };
1100
- case 140: return { type: "TSEnumMember", start, end, id: f1 !== NULL ? node(f1) : null, initializer: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1) };
1101
- case 141: {
1089
+ case 133: { const r = { type: "TSIndexSignature", start, end, parameters: nodeArr(f1, f0), typeAnnotation: f2 !== NULL ? node(f2) : null, readonly: !!(flags & 1) }; if (_isTs) { r.static = !!(flags & 2); r.accessibility = null; } return r; }
1090
+ case 134: return { type: "TSTypeAliasDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, typeAnnotation: f3 !== NULL ? node(f3) : null, declare: !!(flags & 1) };
1091
+ case 135: return { type: "TSInterfaceDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, typeParameters: f2 !== NULL ? node(f2) : null, extends: nodeArr(f3, f0), body: f4 !== NULL ? node(f4) : null, declare: !!(flags & 1) };
1092
+ case 136: return { type: "TSInterfaceBody", start, end, body: nodeArr(f1, f0) };
1093
+ case 137: return { type: "TSInterfaceHeritage", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1094
+ case 138: return { type: "TSClassImplements", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1095
+ case 139: return { type: "TSEnumDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, body: f2 !== NULL ? node(f2) : null, const: !!(flags & 1), declare: !!(flags & 2) };
1096
+ case 140: return { type: "TSEnumBody", start, end, members: nodeArr(f1, f0) };
1097
+ case 141: return { type: "TSEnumMember", start, end, id: f1 !== NULL ? node(f1) : null, initializer: f2 !== NULL ? node(f2) : null, computed: !!(flags & 1) };
1098
+ case 142: {
1102
1099
  const r = {
1103
1100
  type: "TSModuleDeclaration", start, end,
1104
1101
  id: node(f1),
@@ -1109,48 +1106,48 @@ function decode(buffer, source) {
1109
1106
  if (f2 !== NULL) r.body = node(f2);
1110
1107
  return r;
1111
1108
  }
1112
- case 142: return { type: "TSModuleBlock", start, end, body: nodeArr(f1, f0) };
1113
- case 143: return {
1109
+ case 143: return { type: "TSModuleBlock", start, end, body: nodeArr(f1, f0) };
1110
+ case 144: return {
1114
1111
  type: "TSModuleDeclaration", start, end,
1115
1112
  id: node(f1), body: node(f2),
1116
1113
  kind: "global",
1117
1114
  declare: !!(flags & 1),
1118
1115
  global: true,
1119
1116
  };
1120
- case 144: { const r = { type: "TSParameterProperty", start, end, decorators: nodeArr(f1, f0), parameter: f2 !== NULL ? node(f2) : null, override: !!(flags & 1), readonly: !!(flags & 2), accessibility: ACCESSIBILITY[(flags >> 2) & 3] }; if (_isTs) { r.static = false; } return r; }
1121
- case 145: return {
1117
+ case 145: { const r = { type: "TSParameterProperty", start, end, decorators: nodeArr(f1, f0), parameter: f2 !== NULL ? node(f2) : null, override: !!(flags & 1), readonly: !!(flags & 2), accessibility: ACCESSIBILITY[(flags >> 2) & 3] }; if (_isTs) { r.static = false; } return r; }
1118
+ case 146: return {
1122
1119
  type: "Identifier", start, end,
1123
1120
  decorators: [],
1124
1121
  name: "this", optional: false,
1125
1122
  typeAnnotation: f1 !== NULL ? node(f1) : null,
1126
1123
  };
1127
- case 146: return { type: "TSAsExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
1128
- case 147: return { type: "TSSatisfiesExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
1129
- case 148: return { type: "TSTypeAssertion", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, expression: f2 !== NULL ? node(f2) : null };
1130
- case 149: return { type: "TSNonNullExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
1131
- case 150: return { type: "TSInstantiationExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1132
- case 151: return { type: "TSExportAssignment", start, end, expression: f1 !== NULL ? node(f1) : null };
1133
- case 152: return { type: "TSNamespaceExportDeclaration", start, end, id: f1 !== NULL ? node(f1) : null };
1134
- case 153: return { type: "TSImportEqualsDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, moduleReference: f2 !== NULL ? node(f2) : null, importKind: IMPORT_EXPORT_KINDS[flags & 1] };
1135
- case 154: return { type: "TSExternalModuleReference", start, end, expression: f1 !== NULL ? node(f1) : null };
1136
- case 155: return { type: "JSXElement", start, end, openingElement: f1 !== NULL ? node(f1) : null, children: nodeArr(f2, f0), closingElement: f3 !== NULL ? node(f3) : null };
1137
- case 156: { const r = { type: "JSXOpeningElement", start, end, name: f1 !== NULL ? node(f1) : null, attributes: nodeArr(f2, f0), selfClosing: !!(flags & 1) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
1138
- case 157: return { type: "JSXClosingElement", start, end, name: f1 !== NULL ? node(f1) : null };
1139
- case 158: return { type: "JSXFragment", start, end, openingFragment: f1 !== NULL ? node(f1) : null, children: nodeArr(f2, f0), closingFragment: f3 !== NULL ? node(f3) : null };
1140
- case 159: return { type: "JSXOpeningFragment", start, end };
1141
- case 160: return { type: "JSXClosingFragment", start, end };
1142
- case 161: return { type: "JSXIdentifier", start, end, name: str(f1, f2) };
1143
- case 162: return { type: "JSXNamespacedName", start, end, namespace: f1 !== NULL ? node(f1) : null, name: f2 !== NULL ? node(f2) : null };
1144
- case 163: return { type: "JSXMemberExpression", start, end, object: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
1145
- case 164: return { type: "JSXAttribute", start, end, name: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null };
1146
- case 165: return { type: "JSXSpreadAttribute", start, end, argument: f1 !== NULL ? node(f1) : null };
1147
- case 166: return { type: "JSXExpressionContainer", start, end, expression: f1 !== NULL ? node(f1) : null };
1148
- case 167: return { type: "JSXEmptyExpression", start, end };
1149
- case 168: {
1124
+ case 147: return { type: "TSAsExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
1125
+ case 148: return { type: "TSSatisfiesExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeAnnotation: f2 !== NULL ? node(f2) : null };
1126
+ case 149: return { type: "TSTypeAssertion", start, end, typeAnnotation: f1 !== NULL ? node(f1) : null, expression: f2 !== NULL ? node(f2) : null };
1127
+ case 150: return { type: "TSNonNullExpression", start, end, expression: f1 !== NULL ? node(f1) : null };
1128
+ case 151: return { type: "TSInstantiationExpression", start, end, expression: f1 !== NULL ? node(f1) : null, typeArguments: f2 !== NULL ? node(f2) : null };
1129
+ case 152: return { type: "TSExportAssignment", start, end, expression: f1 !== NULL ? node(f1) : null };
1130
+ case 153: return { type: "TSNamespaceExportDeclaration", start, end, id: f1 !== NULL ? node(f1) : null };
1131
+ case 154: return { type: "TSImportEqualsDeclaration", start, end, id: f1 !== NULL ? node(f1) : null, moduleReference: f2 !== NULL ? node(f2) : null, importKind: IMPORT_EXPORT_KINDS[flags & 1] };
1132
+ case 155: return { type: "TSExternalModuleReference", start, end, expression: f1 !== NULL ? node(f1) : null };
1133
+ case 156: return { type: "JSXElement", start, end, openingElement: f1 !== NULL ? node(f1) : null, children: nodeArr(f2, f0), closingElement: f3 !== NULL ? node(f3) : null };
1134
+ case 157: { const r = { type: "JSXOpeningElement", start, end, name: f1 !== NULL ? node(f1) : null, attributes: nodeArr(f2, f0), selfClosing: !!(flags & 1) }; if (_isTs) { r.typeArguments = f3 !== NULL ? node(f3) : null; } return r; }
1135
+ case 158: return { type: "JSXClosingElement", start, end, name: f1 !== NULL ? node(f1) : null };
1136
+ case 159: return { type: "JSXFragment", start, end, openingFragment: f1 !== NULL ? node(f1) : null, children: nodeArr(f2, f0), closingFragment: f3 !== NULL ? node(f3) : null };
1137
+ case 160: return { type: "JSXOpeningFragment", start, end };
1138
+ case 161: return { type: "JSXClosingFragment", start, end };
1139
+ case 162: return { type: "JSXIdentifier", start, end, name: str(f1, f2) };
1140
+ case 163: return { type: "JSXNamespacedName", start, end, namespace: f1 !== NULL ? node(f1) : null, name: f2 !== NULL ? node(f2) : null };
1141
+ case 164: return { type: "JSXMemberExpression", start, end, object: f1 !== NULL ? node(f1) : null, property: f2 !== NULL ? node(f2) : null };
1142
+ case 165: return { type: "JSXAttribute", start, end, name: f1 !== NULL ? node(f1) : null, value: f2 !== NULL ? node(f2) : null };
1143
+ case 166: return { type: "JSXSpreadAttribute", start, end, argument: f1 !== NULL ? node(f1) : null };
1144
+ case 167: return { type: "JSXExpressionContainer", start, end, expression: f1 !== NULL ? node(f1) : null };
1145
+ case 168: return { type: "JSXEmptyExpression", start, end };
1146
+ case 169: {
1150
1147
  const t = str(f1, f2);
1151
1148
  return { type: "JSXText", start, end, value: t, raw: t };
1152
1149
  }
1153
- case 169: return { type: "JSXSpreadChild", start, end, expression: f1 !== NULL ? node(f1) : null };
1150
+ case 170: return { type: "JSXSpreadChild", start, end, expression: f1 !== NULL ? node(f1) : null };
1154
1151
  }
1155
1152
  }
1156
1153
  const _inner = _attached ? nodeWithComments : _decode;
@@ -1161,7 +1158,7 @@ function decode(buffer, source) {
1161
1158
  if (m !== undefined) return m;
1162
1159
  const r = _inner(i);
1163
1160
  _nodes[i] = r;
1164
- if (r !== null && typeof r === "object") _nodeIndexes.set(r, i);
1161
+ if (r !== null && typeof r === "object" && !_nodeIndexes.has(r)) _nodeIndexes.set(r, i);
1165
1162
  return r;
1166
1163
  }
1167
1164
  const _nodesU32 = _nodesOff >> 2;
@@ -1233,104 +1230,6 @@ function decode(buffer, source) {
1233
1230
  }
1234
1231
  return out;
1235
1232
  }
1236
- function _scanType(tag, flags) {
1237
- switch (tag) {
1238
- case 3: return FUNCTION_TYPES[flags & 3];
1239
- case 26: return CLASS_TYPES[flags & 1];
1240
- case 28:
1241
- return _isTs && (flags & 64)
1242
- ? "TSAbstractMethodDefinition"
1243
- : "MethodDefinition";
1244
- default: {
1245
- const acc = (flags & 4) !== 0;
1246
- if (_isTs && (flags & 256)) {
1247
- return acc ? "TSAbstractAccessorProperty" : "TSAbstractPropertyDefinition";
1248
- }
1249
- return acc ? "AccessorProperty" : "PropertyDefinition";
1250
- }
1251
- }
1252
- }
1253
- function scan(visitors) {
1254
- const handlers = new Map();
1255
- let every = null;
1256
- for (const k of Object.keys(visitors)) {
1257
- const v = visitors[k];
1258
- if (typeof v !== "function") continue;
1259
- if (k === "enter") every = v;
1260
- else handlers.set(k, v);
1261
- }
1262
- const wanted = new Array(TAG_TYPES.length).fill(null);
1263
- for (let t = 0; t < TAG_TYPES.length; t++) {
1264
- const tt = TAG_TYPES[t];
1265
- if (tt === null) continue;
1266
- if (tt === 0) {
1267
- for (const c of TAG_CHOICES.get(t)) {
1268
- if (handlers.has(c)) { wanted[t] = 0; break; }
1269
- }
1270
- } else {
1271
- const h = handlers.get(tt);
1272
- if (h !== undefined) wanted[t] = h;
1273
- }
1274
- }
1275
- let stopFlag = false, skipFlag = false;
1276
- let curIndex = 0, curO = 0, curTag = 0;
1277
- const cursor = {
1278
- get index() { return curIndex; },
1279
- get type() {
1280
- const t = TAG_TYPES[curTag];
1281
- return t !== 0 ? t : _scanType(curTag, _u8[curO + 2] | (_u8[curO + 3] << 8));
1282
- },
1283
- get start() { return startOf(curIndex); },
1284
- get end() { return endOf(curIndex); },
1285
- node() { return node(curIndex); },
1286
- skip() { skipFlag = true; },
1287
- stop() { stopFlag = true; },
1288
- };
1289
- (function visit(i) {
1290
- const o = _nodesOff + i * 48;
1291
- const tag = _u8[o];
1292
- let h = wanted[tag];
1293
- if (h !== null || every !== null) {
1294
- curIndex = i; curO = o; curTag = tag;
1295
- if (h === 0) {
1296
- h = handlers.get(_scanType(tag, _u8[o + 2] | (_u8[o + 3] << 8))) ?? null;
1297
- }
1298
- if (every !== null && TAG_TYPES[tag] !== null) {
1299
- every(cursor);
1300
- if (stopFlag) return;
1301
- }
1302
- if (h !== null) {
1303
- h(cursor);
1304
- if (stopFlag) return;
1305
- }
1306
- if (skipFlag) { skipFlag = false; return; }
1307
- }
1308
- const ops = SCAN_CHILDREN[tag];
1309
- const b = o >> 2;
1310
- for (let p = 0; p < ops.length; p += 2) {
1311
- const slot = ops[p + 1];
1312
- if (ops[p] === 0) {
1313
- const c = _u32[b + slot];
1314
- if (c !== NULL) {
1315
- visit(c);
1316
- if (stopFlag) return;
1317
- }
1318
- } else {
1319
- const s = _u32[b + slot];
1320
- const len = ops[p] === 1
1321
- ? _u32[b + slot + 1]
1322
- : _u8[o + 4] | (_u8[o + 5] << 8);
1323
- for (let j = 0; j < len; j++) {
1324
- const c = _u32[_extraBase + s + j];
1325
- if (c !== NULL) {
1326
- visit(c);
1327
- if (stopFlag) return;
1328
- }
1329
- }
1330
- }
1331
- }
1332
- })(progIdx);
1333
- }
1334
1233
  let _parentArr;
1335
1234
  function _parents() {
1336
1235
  if (_parentArr !== undefined) return _parentArr;
@@ -1338,8 +1237,8 @@ function decode(buffer, source) {
1338
1237
  (function visit(i, parent) {
1339
1238
  const o = _nodesOff + i * 48;
1340
1239
  const tag = _u8[o];
1341
- if (TAG_TYPES[tag] !== null) { p[i] = parent; parent = i; }
1342
- const ops = SCAN_CHILDREN[tag];
1240
+ if (IS_NODE[tag]) { p[i] = parent; parent = i; }
1241
+ const ops = CHILD_SLOTS[tag];
1343
1242
  const b = o >> 2;
1344
1243
  for (let q = 0; q < ops.length; q += 2) {
1345
1244
  const slot = ops[q + 1];
@@ -1485,7 +1384,6 @@ function decode(buffer, source) {
1485
1384
  }
1486
1385
  return { line: lo, column: offset - ls[lo - 1] };
1487
1386
  },
1488
- scan,
1489
1387
  nodeOf: node,
1490
1388
  indexOf: (n) => _nodeIndexes.get(n),
1491
1389
  parentIndex: (i) => _parents()[i],
package/index.d.ts CHANGED
@@ -12,7 +12,6 @@ import type {
12
12
  NodeOfType,
13
13
  NodeType,
14
14
  Program,
15
- ScanCursor as BaseScanCursor,
16
15
  SourceLang,
17
16
  SourceLocation,
18
17
  SourceType,
@@ -271,27 +270,6 @@ type Visitors = {
271
270
  leave?: WalkHandler;
272
271
  };
273
272
 
274
- /**
275
- * The semantic scan cursor: the toolchain's {@link BaseScanCursor} plus
276
- * symbol and reference lookups. Both are index-keyed, so a scan can
277
- * resolve semantics without materializing any AST nodes.
278
- */
279
- interface ScanCursor<T extends Node = Node> extends BaseScanCursor<T> {
280
- /** The module being scanned. */
281
- readonly module: Module;
282
- /** Shorthand for `module.symbolOf(node)`, without materializing. */
283
- readonly symbol: Symbol | null;
284
- /** Shorthand for `module.referenceOf(node)`, without materializing. */
285
- readonly reference: Reference | null;
286
- }
287
-
288
- /** Scan handlers keyed by node `type`, plus the universal `enter`. */
289
- type ScanVisitors = {
290
- [K in NodeType]?: (cursor: ScanCursor<NodeOfType<K>>) => void;
291
- } & {
292
- enter?: (cursor: ScanCursor) => void;
293
- };
294
-
295
273
  /** A free variable of a function, as reported by {@link Module.capturesOf}. */
296
274
  interface Capture {
297
275
  /** The outer binding being closed over. */
@@ -452,14 +430,6 @@ interface Module {
452
430
  */
453
431
  walk(visitors: Visitors, root?: Node): void;
454
432
 
455
- /**
456
- * Readonly buffer scan with semantic context: visits the parsed node
457
- * records directly without materializing AST objects, and resolves
458
- * symbols and references in index space. Many times faster than
459
- * {@link walk} for sparse queries; call {@link ScanCursor.node} to
460
- * materialize a matched node (identity-shared with the walked AST).
461
- */
462
- scan(visitors: ScanVisitors): void;
463
433
  /** Collects every node of the given type(s), in source order. */
464
434
  findAll<K extends NodeType>(type: K): NodeOfType<K>[];
465
435
  findAll<K extends NodeType>(types: readonly K[]): NodeOfType<K>[];
@@ -572,8 +542,6 @@ export {
572
542
  type NodeOfType,
573
543
  type NodeType,
574
544
  type Reference,
575
- type ScanCursor,
576
- type ScanVisitors,
577
545
  type Scope,
578
546
  type ScopeKind,
579
547
  type Symbol,
package/module.js CHANGED
@@ -213,46 +213,6 @@ class Export {
213
213
  }
214
214
  }
215
215
 
216
- // The semantic scan cursor, the generated buffer cursor plus symbol and
217
- // reference lookups, which are index-keyed and so need no AST nodes.
218
- class ScanCursor {
219
- _raw = null;
220
- #module;
221
- constructor(module) {
222
- this.#module = module;
223
- }
224
- get module() {
225
- return this.#module;
226
- }
227
- get index() {
228
- return this._raw.index;
229
- }
230
- get type() {
231
- return this._raw.type;
232
- }
233
- get start() {
234
- return this._raw.start;
235
- }
236
- get end() {
237
- return this._raw.end;
238
- }
239
- get symbol() {
240
- return this.#module._symbolByIndex(this._raw.index);
241
- }
242
- get reference() {
243
- return this.#module._referenceByIndex(this._raw.index);
244
- }
245
- node() {
246
- return this._raw.node();
247
- }
248
- skip() {
249
- this._raw.skip();
250
- }
251
- stop() {
252
- this._raw.stop();
253
- }
254
- }
255
-
256
216
  export class Module {
257
217
  #r;
258
218
  #sem;
@@ -440,22 +400,6 @@ export class Module {
440
400
  walkModule(this, visitor, root);
441
401
  }
442
402
 
443
- // readonly buffer scan with a semantic cursor, resolving symbols and
444
- // references in index space, materializing no AST nodes.
445
- scan(visitors) {
446
- const cursor = new ScanCursor(this);
447
- const wrapped = {};
448
- for (const key of Object.keys(visitors)) {
449
- const fn = visitors[key];
450
- if (typeof fn !== "function") continue;
451
- wrapped[key] = (raw) => {
452
- cursor._raw = raw;
453
- fn(cursor);
454
- };
455
- }
456
- this.#r.scan(wrapped);
457
- }
458
-
459
403
  findAll(types) {
460
404
  const single = typeof types === "string" ? types : null;
461
405
  const set = single === null ? new Set(types) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yuku-analyzer",
3
- "version": "0.5.36",
3
+ "version": "0.5.37",
4
4
  "description": "High-performance JavaScript/TypeScript semantic analyzer: per-file scopes, symbols, references, and cross-file module linking",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -21,17 +21,17 @@
21
21
  "decode.js"
22
22
  ],
23
23
  "optionalDependencies": {
24
- "@yuku-analyzer/binding-linux-x64-gnu": "0.5.36",
25
- "@yuku-analyzer/binding-linux-arm64-gnu": "0.5.36",
26
- "@yuku-analyzer/binding-linux-arm-gnu": "0.5.36",
27
- "@yuku-analyzer/binding-linux-x64-musl": "0.5.36",
28
- "@yuku-analyzer/binding-linux-arm64-musl": "0.5.36",
29
- "@yuku-analyzer/binding-linux-arm-musl": "0.5.36",
30
- "@yuku-analyzer/binding-darwin-x64": "0.5.36",
31
- "@yuku-analyzer/binding-darwin-arm64": "0.5.36",
32
- "@yuku-analyzer/binding-win32-x64": "0.5.36",
33
- "@yuku-analyzer/binding-win32-arm64": "0.5.36",
34
- "@yuku-analyzer/binding-freebsd-x64": "0.5.36"
24
+ "@yuku-analyzer/binding-linux-x64-gnu": "0.5.37",
25
+ "@yuku-analyzer/binding-linux-arm64-gnu": "0.5.37",
26
+ "@yuku-analyzer/binding-linux-arm-gnu": "0.5.37",
27
+ "@yuku-analyzer/binding-linux-x64-musl": "0.5.37",
28
+ "@yuku-analyzer/binding-linux-arm64-musl": "0.5.37",
29
+ "@yuku-analyzer/binding-linux-arm-musl": "0.5.37",
30
+ "@yuku-analyzer/binding-darwin-x64": "0.5.37",
31
+ "@yuku-analyzer/binding-darwin-arm64": "0.5.37",
32
+ "@yuku-analyzer/binding-win32-x64": "0.5.37",
33
+ "@yuku-analyzer/binding-win32-arm64": "0.5.37",
34
+ "@yuku-analyzer/binding-freebsd-x64": "0.5.37"
35
35
  },
36
36
  "keywords": [
37
37
  "analyzer",