UNPKG

oxc-parser

Version:

Oxc Parser Node API

1,986 lines (1,659 loc) 333 kB
// Auto-generated code, DO NOT EDIT DIRECTLY! // To edit this generated file you have to edit `tasks/ast_tools/src/generators/raw_transfer_lazy.rs`. 'use strict'; const { TOKEN, constructorError } = require('../../raw-transfer/lazy-common.js'), NodeArray = require('../../raw-transfer/node-array.js'); module.exports = { construct, TOKEN }; function construct(ast) { // (2 * 1024 * 1024 * 1024 - 16) >> 2 const metadataPos32 = 536870908; return new RawTransferData(ast.buffer.uint32[metadataPos32], ast); } const textDecoder = new TextDecoder('utf-8', { ignoreBOM: true }), decodeStr = textDecoder.decode.bind(textDecoder), { fromCodePoint } = String, inspectSymbol = Symbol.for('nodejs.util.inspect.custom'); class Program { type = 'Program'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $body: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get sourceType() { const internal = this.#internal; return new SourceType(internal.pos + 124, internal.ast); } get hashbang() { const internal = this.#internal; return constructOptionHashbang(internal.pos + 48, internal.ast); } get body() { const internal = this.#internal, cached = internal.$body; if (cached !== void 0) return cached; return internal.$body = constructVecStatement(internal.pos + 96, internal.ast); } toJSON() { return { type: 'Program', start: this.start, end: this.end, sourceType: this.sourceType, hashbang: this.hashbang, body: this.body, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugProgram.prototype); } } const DebugProgram = class Program {}; function constructExpression(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxBooleanLiteral(pos + 8, ast); case 1: return constructBoxNullLiteral(pos + 8, ast); case 2: return constructBoxNumericLiteral(pos + 8, ast); case 3: return constructBoxBigIntLiteral(pos + 8, ast); case 4: return constructBoxRegExpLiteral(pos + 8, ast); case 5: return constructBoxStringLiteral(pos + 8, ast); case 6: return constructBoxTemplateLiteral(pos + 8, ast); case 7: return constructBoxIdentifierReference(pos + 8, ast); case 8: return constructBoxMetaProperty(pos + 8, ast); case 9: return constructBoxSuper(pos + 8, ast); case 10: return constructBoxArrayExpression(pos + 8, ast); case 11: return constructBoxArrowFunctionExpression(pos + 8, ast); case 12: return constructBoxAssignmentExpression(pos + 8, ast); case 13: return constructBoxAwaitExpression(pos + 8, ast); case 14: return constructBoxBinaryExpression(pos + 8, ast); case 15: return constructBoxCallExpression(pos + 8, ast); case 16: return constructBoxChainExpression(pos + 8, ast); case 17: return constructBoxClass(pos + 8, ast); case 18: return constructBoxConditionalExpression(pos + 8, ast); case 19: return constructBoxFunction(pos + 8, ast); case 20: return constructBoxImportExpression(pos + 8, ast); case 21: return constructBoxLogicalExpression(pos + 8, ast); case 22: return constructBoxNewExpression(pos + 8, ast); case 23: return constructBoxObjectExpression(pos + 8, ast); case 24: return constructBoxParenthesizedExpression(pos + 8, ast); case 25: return constructBoxSequenceExpression(pos + 8, ast); case 26: return constructBoxTaggedTemplateExpression(pos + 8, ast); case 27: return constructBoxThisExpression(pos + 8, ast); case 28: return constructBoxUnaryExpression(pos + 8, ast); case 29: return constructBoxUpdateExpression(pos + 8, ast); case 30: return constructBoxYieldExpression(pos + 8, ast); case 31: return constructBoxPrivateInExpression(pos + 8, ast); case 32: return constructBoxJSXElement(pos + 8, ast); case 33: return constructBoxJSXFragment(pos + 8, ast); case 34: return constructBoxTSAsExpression(pos + 8, ast); case 35: return constructBoxTSSatisfiesExpression(pos + 8, ast); case 36: return constructBoxTSTypeAssertion(pos + 8, ast); case 37: return constructBoxTSNonNullExpression(pos + 8, ast); case 38: return constructBoxTSInstantiationExpression(pos + 8, ast); case 39: return constructBoxV8IntrinsicExpression(pos + 8, ast); case 48: return constructBoxComputedMemberExpression(pos + 8, ast); case 49: return constructBoxStaticMemberExpression(pos + 8, ast); case 50: return constructBoxPrivateFieldExpression(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for Expression`); } } class IdentifierName { type = 'IdentifierName'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $name: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get name() { const internal = this.#internal, cached = internal.$name; if (cached !== void 0) return cached; return internal.$name = constructStr(internal.pos + 8, internal.ast); } toJSON() { return { type: 'IdentifierName', start: this.start, end: this.end, name: this.name, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugIdentifierName.prototype); } } const DebugIdentifierName = class IdentifierName {}; class IdentifierReference { type = 'IdentifierReference'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $name: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get name() { const internal = this.#internal, cached = internal.$name; if (cached !== void 0) return cached; return internal.$name = constructStr(internal.pos + 8, internal.ast); } toJSON() { return { type: 'IdentifierReference', start: this.start, end: this.end, name: this.name, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugIdentifierReference.prototype); } } const DebugIdentifierReference = class IdentifierReference {}; class BindingIdentifier { type = 'BindingIdentifier'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $name: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get name() { const internal = this.#internal, cached = internal.$name; if (cached !== void 0) return cached; return internal.$name = constructStr(internal.pos + 8, internal.ast); } toJSON() { return { type: 'BindingIdentifier', start: this.start, end: this.end, name: this.name, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugBindingIdentifier.prototype); } } const DebugBindingIdentifier = class BindingIdentifier {}; class LabelIdentifier { type = 'LabelIdentifier'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $name: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get name() { const internal = this.#internal, cached = internal.$name; if (cached !== void 0) return cached; return internal.$name = constructStr(internal.pos + 8, internal.ast); } toJSON() { return { type: 'LabelIdentifier', start: this.start, end: this.end, name: this.name, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugLabelIdentifier.prototype); } } const DebugLabelIdentifier = class LabelIdentifier {}; class ThisExpression { type = 'ThisExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } toJSON() { return { type: 'ThisExpression', start: this.start, end: this.end, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugThisExpression.prototype); } } const DebugThisExpression = class ThisExpression {}; class ArrayExpression { type = 'ArrayExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $elements: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get elements() { const internal = this.#internal, cached = internal.$elements; if (cached !== void 0) return cached; return internal.$elements = constructVecArrayExpressionElement(internal.pos + 8, internal.ast); } toJSON() { return { type: 'ArrayExpression', start: this.start, end: this.end, elements: this.elements, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugArrayExpression.prototype); } } const DebugArrayExpression = class ArrayExpression {}; function constructArrayExpressionElement(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxBooleanLiteral(pos + 8, ast); case 1: return constructBoxNullLiteral(pos + 8, ast); case 2: return constructBoxNumericLiteral(pos + 8, ast); case 3: return constructBoxBigIntLiteral(pos + 8, ast); case 4: return constructBoxRegExpLiteral(pos + 8, ast); case 5: return constructBoxStringLiteral(pos + 8, ast); case 6: return constructBoxTemplateLiteral(pos + 8, ast); case 7: return constructBoxIdentifierReference(pos + 8, ast); case 8: return constructBoxMetaProperty(pos + 8, ast); case 9: return constructBoxSuper(pos + 8, ast); case 10: return constructBoxArrayExpression(pos + 8, ast); case 11: return constructBoxArrowFunctionExpression(pos + 8, ast); case 12: return constructBoxAssignmentExpression(pos + 8, ast); case 13: return constructBoxAwaitExpression(pos + 8, ast); case 14: return constructBoxBinaryExpression(pos + 8, ast); case 15: return constructBoxCallExpression(pos + 8, ast); case 16: return constructBoxChainExpression(pos + 8, ast); case 17: return constructBoxClass(pos + 8, ast); case 18: return constructBoxConditionalExpression(pos + 8, ast); case 19: return constructBoxFunction(pos + 8, ast); case 20: return constructBoxImportExpression(pos + 8, ast); case 21: return constructBoxLogicalExpression(pos + 8, ast); case 22: return constructBoxNewExpression(pos + 8, ast); case 23: return constructBoxObjectExpression(pos + 8, ast); case 24: return constructBoxParenthesizedExpression(pos + 8, ast); case 25: return constructBoxSequenceExpression(pos + 8, ast); case 26: return constructBoxTaggedTemplateExpression(pos + 8, ast); case 27: return constructBoxThisExpression(pos + 8, ast); case 28: return constructBoxUnaryExpression(pos + 8, ast); case 29: return constructBoxUpdateExpression(pos + 8, ast); case 30: return constructBoxYieldExpression(pos + 8, ast); case 31: return constructBoxPrivateInExpression(pos + 8, ast); case 32: return constructBoxJSXElement(pos + 8, ast); case 33: return constructBoxJSXFragment(pos + 8, ast); case 34: return constructBoxTSAsExpression(pos + 8, ast); case 35: return constructBoxTSSatisfiesExpression(pos + 8, ast); case 36: return constructBoxTSTypeAssertion(pos + 8, ast); case 37: return constructBoxTSNonNullExpression(pos + 8, ast); case 38: return constructBoxTSInstantiationExpression(pos + 8, ast); case 39: return constructBoxV8IntrinsicExpression(pos + 8, ast); case 48: return constructBoxComputedMemberExpression(pos + 8, ast); case 49: return constructBoxStaticMemberExpression(pos + 8, ast); case 50: return constructBoxPrivateFieldExpression(pos + 8, ast); case 64: return constructBoxSpreadElement(pos + 8, ast); case 65: return new Elision(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for ArrayExpressionElement`); } } class Elision { type = 'Elision'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } toJSON() { return { type: 'Elision', start: this.start, end: this.end, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugElision.prototype); } } const DebugElision = class Elision {}; class ObjectExpression { type = 'ObjectExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $properties: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get properties() { const internal = this.#internal, cached = internal.$properties; if (cached !== void 0) return cached; return internal.$properties = constructVecObjectPropertyKind(internal.pos + 8, internal.ast); } toJSON() { return { type: 'ObjectExpression', start: this.start, end: this.end, properties: this.properties, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugObjectExpression.prototype); } } const DebugObjectExpression = class ObjectExpression {}; function constructObjectPropertyKind(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxObjectProperty(pos + 8, ast); case 1: return constructBoxSpreadElement(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for ObjectPropertyKind`); } } class ObjectProperty { type = 'ObjectProperty'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get kind() { const internal = this.#internal; return constructPropertyKind(internal.pos + 40, internal.ast); } get key() { const internal = this.#internal; return constructPropertyKey(internal.pos + 8, internal.ast); } get value() { const internal = this.#internal; return constructExpression(internal.pos + 24, internal.ast); } get method() { const internal = this.#internal; return constructBool(internal.pos + 41, internal.ast); } get shorthand() { const internal = this.#internal; return constructBool(internal.pos + 42, internal.ast); } get computed() { const internal = this.#internal; return constructBool(internal.pos + 43, internal.ast); } toJSON() { return { type: 'ObjectProperty', start: this.start, end: this.end, kind: this.kind, key: this.key, value: this.value, method: this.method, shorthand: this.shorthand, computed: this.computed, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugObjectProperty.prototype); } } const DebugObjectProperty = class ObjectProperty {}; function constructPropertyKey(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxBooleanLiteral(pos + 8, ast); case 1: return constructBoxNullLiteral(pos + 8, ast); case 2: return constructBoxNumericLiteral(pos + 8, ast); case 3: return constructBoxBigIntLiteral(pos + 8, ast); case 4: return constructBoxRegExpLiteral(pos + 8, ast); case 5: return constructBoxStringLiteral(pos + 8, ast); case 6: return constructBoxTemplateLiteral(pos + 8, ast); case 7: return constructBoxIdentifierReference(pos + 8, ast); case 8: return constructBoxMetaProperty(pos + 8, ast); case 9: return constructBoxSuper(pos + 8, ast); case 10: return constructBoxArrayExpression(pos + 8, ast); case 11: return constructBoxArrowFunctionExpression(pos + 8, ast); case 12: return constructBoxAssignmentExpression(pos + 8, ast); case 13: return constructBoxAwaitExpression(pos + 8, ast); case 14: return constructBoxBinaryExpression(pos + 8, ast); case 15: return constructBoxCallExpression(pos + 8, ast); case 16: return constructBoxChainExpression(pos + 8, ast); case 17: return constructBoxClass(pos + 8, ast); case 18: return constructBoxConditionalExpression(pos + 8, ast); case 19: return constructBoxFunction(pos + 8, ast); case 20: return constructBoxImportExpression(pos + 8, ast); case 21: return constructBoxLogicalExpression(pos + 8, ast); case 22: return constructBoxNewExpression(pos + 8, ast); case 23: return constructBoxObjectExpression(pos + 8, ast); case 24: return constructBoxParenthesizedExpression(pos + 8, ast); case 25: return constructBoxSequenceExpression(pos + 8, ast); case 26: return constructBoxTaggedTemplateExpression(pos + 8, ast); case 27: return constructBoxThisExpression(pos + 8, ast); case 28: return constructBoxUnaryExpression(pos + 8, ast); case 29: return constructBoxUpdateExpression(pos + 8, ast); case 30: return constructBoxYieldExpression(pos + 8, ast); case 31: return constructBoxPrivateInExpression(pos + 8, ast); case 32: return constructBoxJSXElement(pos + 8, ast); case 33: return constructBoxJSXFragment(pos + 8, ast); case 34: return constructBoxTSAsExpression(pos + 8, ast); case 35: return constructBoxTSSatisfiesExpression(pos + 8, ast); case 36: return constructBoxTSTypeAssertion(pos + 8, ast); case 37: return constructBoxTSNonNullExpression(pos + 8, ast); case 38: return constructBoxTSInstantiationExpression(pos + 8, ast); case 39: return constructBoxV8IntrinsicExpression(pos + 8, ast); case 48: return constructBoxComputedMemberExpression(pos + 8, ast); case 49: return constructBoxStaticMemberExpression(pos + 8, ast); case 50: return constructBoxPrivateFieldExpression(pos + 8, ast); case 64: return constructBoxIdentifierName(pos + 8, ast); case 65: return constructBoxPrivateIdentifier(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for PropertyKey`); } } function constructPropertyKind(pos, ast) { switch (ast.buffer[pos]) { case 0: return 'init'; case 1: return 'get'; case 2: return 'set'; default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for PropertyKind`); } } class TemplateLiteral { type = 'TemplateLiteral'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $quasis: void 0, $expressions: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get quasis() { const internal = this.#internal, cached = internal.$quasis; if (cached !== void 0) return cached; return internal.$quasis = constructVecTemplateElement(internal.pos + 8, internal.ast); } get expressions() { const internal = this.#internal, cached = internal.$expressions; if (cached !== void 0) return cached; return internal.$expressions = constructVecExpression(internal.pos + 32, internal.ast); } toJSON() { return { type: 'TemplateLiteral', start: this.start, end: this.end, quasis: this.quasis, expressions: this.expressions, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugTemplateLiteral.prototype); } } const DebugTemplateLiteral = class TemplateLiteral {}; class TaggedTemplateExpression { type = 'TaggedTemplateExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get tag() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get typeArguments() { const internal = this.#internal; return constructOptionBoxTSTypeParameterInstantiation(internal.pos + 24, internal.ast); } get quasi() { const internal = this.#internal; return new TemplateLiteral(internal.pos + 32, internal.ast); } toJSON() { return { type: 'TaggedTemplateExpression', start: this.start, end: this.end, tag: this.tag, typeArguments: this.typeArguments, quasi: this.quasi, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugTaggedTemplateExpression.prototype); } } const DebugTaggedTemplateExpression = class TaggedTemplateExpression {}; class TemplateElement { type = 'TemplateElement'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get value() { const internal = this.#internal; return new TemplateElementValue(internal.pos + 8, internal.ast); } get tail() { const internal = this.#internal; return constructBool(internal.pos + 40, internal.ast); } toJSON() { return { type: 'TemplateElement', start: this.start, end: this.end, value: this.value, tail: this.tail, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugTemplateElement.prototype); } } const DebugTemplateElement = class TemplateElement {}; class TemplateElementValue { #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $raw: void 0, $cooked: void 0 }; nodes.set(pos, this); } get raw() { const internal = this.#internal, cached = internal.$raw; if (cached !== void 0) return cached; return internal.$raw = constructStr(internal.pos, internal.ast); } get cooked() { const internal = this.#internal, cached = internal.$cooked; if (cached !== void 0) return cached; return internal.$cooked = constructOptionStr(internal.pos + 16, internal.ast); } toJSON() { return { raw: this.raw, cooked: this.cooked, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugTemplateElementValue.prototype); } } const DebugTemplateElementValue = class TemplateElementValue {}; function constructMemberExpression(pos, ast) { switch (ast.buffer[pos]) { case 48: return constructBoxComputedMemberExpression(pos + 8, ast); case 49: return constructBoxStaticMemberExpression(pos + 8, ast); case 50: return constructBoxPrivateFieldExpression(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for MemberExpression`); } } class ComputedMemberExpression { type = 'ComputedMemberExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get object() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get property() { const internal = this.#internal; return constructExpression(internal.pos + 24, internal.ast); } get optional() { const internal = this.#internal; return constructBool(internal.pos + 40, internal.ast); } toJSON() { return { type: 'ComputedMemberExpression', start: this.start, end: this.end, object: this.object, property: this.property, optional: this.optional, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugComputedMemberExpression.prototype); } } const DebugComputedMemberExpression = class ComputedMemberExpression {}; class StaticMemberExpression { type = 'StaticMemberExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get object() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get property() { const internal = this.#internal; return new IdentifierName(internal.pos + 24, internal.ast); } get optional() { const internal = this.#internal; return constructBool(internal.pos + 48, internal.ast); } toJSON() { return { type: 'StaticMemberExpression', start: this.start, end: this.end, object: this.object, property: this.property, optional: this.optional, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugStaticMemberExpression.prototype); } } const DebugStaticMemberExpression = class StaticMemberExpression {}; class PrivateFieldExpression { type = 'PrivateFieldExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get object() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get property() { const internal = this.#internal; return new PrivateIdentifier(internal.pos + 24, internal.ast); } get optional() { const internal = this.#internal; return constructBool(internal.pos + 48, internal.ast); } toJSON() { return { type: 'PrivateFieldExpression', start: this.start, end: this.end, object: this.object, property: this.property, optional: this.optional, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugPrivateFieldExpression.prototype); } } const DebugPrivateFieldExpression = class PrivateFieldExpression {}; class CallExpression { type = 'CallExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $arguments: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get callee() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get typeArguments() { const internal = this.#internal; return constructOptionBoxTSTypeParameterInstantiation(internal.pos + 24, internal.ast); } get arguments() { const internal = this.#internal, cached = internal.$arguments; if (cached !== void 0) return cached; return internal.$arguments = constructVecArgument(internal.pos + 32, internal.ast); } get optional() { const internal = this.#internal; return constructBool(internal.pos + 56, internal.ast); } toJSON() { return { type: 'CallExpression', start: this.start, end: this.end, callee: this.callee, typeArguments: this.typeArguments, arguments: this.arguments, optional: this.optional, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugCallExpression.prototype); } } const DebugCallExpression = class CallExpression {}; class NewExpression { type = 'NewExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast, $arguments: void 0 }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get callee() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get typeArguments() { const internal = this.#internal; return constructOptionBoxTSTypeParameterInstantiation(internal.pos + 24, internal.ast); } get arguments() { const internal = this.#internal, cached = internal.$arguments; if (cached !== void 0) return cached; return internal.$arguments = constructVecArgument(internal.pos + 32, internal.ast); } toJSON() { return { type: 'NewExpression', start: this.start, end: this.end, callee: this.callee, typeArguments: this.typeArguments, arguments: this.arguments, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugNewExpression.prototype); } } const DebugNewExpression = class NewExpression {}; class MetaProperty { type = 'MetaProperty'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get meta() { const internal = this.#internal; return new IdentifierName(internal.pos + 8, internal.ast); } get property() { const internal = this.#internal; return new IdentifierName(internal.pos + 32, internal.ast); } toJSON() { return { type: 'MetaProperty', start: this.start, end: this.end, meta: this.meta, property: this.property, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugMetaProperty.prototype); } } const DebugMetaProperty = class MetaProperty {}; class SpreadElement { type = 'SpreadElement'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get argument() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } toJSON() { return { type: 'SpreadElement', start: this.start, end: this.end, argument: this.argument, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugSpreadElement.prototype); } } const DebugSpreadElement = class SpreadElement {}; function constructArgument(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxBooleanLiteral(pos + 8, ast); case 1: return constructBoxNullLiteral(pos + 8, ast); case 2: return constructBoxNumericLiteral(pos + 8, ast); case 3: return constructBoxBigIntLiteral(pos + 8, ast); case 4: return constructBoxRegExpLiteral(pos + 8, ast); case 5: return constructBoxStringLiteral(pos + 8, ast); case 6: return constructBoxTemplateLiteral(pos + 8, ast); case 7: return constructBoxIdentifierReference(pos + 8, ast); case 8: return constructBoxMetaProperty(pos + 8, ast); case 9: return constructBoxSuper(pos + 8, ast); case 10: return constructBoxArrayExpression(pos + 8, ast); case 11: return constructBoxArrowFunctionExpression(pos + 8, ast); case 12: return constructBoxAssignmentExpression(pos + 8, ast); case 13: return constructBoxAwaitExpression(pos + 8, ast); case 14: return constructBoxBinaryExpression(pos + 8, ast); case 15: return constructBoxCallExpression(pos + 8, ast); case 16: return constructBoxChainExpression(pos + 8, ast); case 17: return constructBoxClass(pos + 8, ast); case 18: return constructBoxConditionalExpression(pos + 8, ast); case 19: return constructBoxFunction(pos + 8, ast); case 20: return constructBoxImportExpression(pos + 8, ast); case 21: return constructBoxLogicalExpression(pos + 8, ast); case 22: return constructBoxNewExpression(pos + 8, ast); case 23: return constructBoxObjectExpression(pos + 8, ast); case 24: return constructBoxParenthesizedExpression(pos + 8, ast); case 25: return constructBoxSequenceExpression(pos + 8, ast); case 26: return constructBoxTaggedTemplateExpression(pos + 8, ast); case 27: return constructBoxThisExpression(pos + 8, ast); case 28: return constructBoxUnaryExpression(pos + 8, ast); case 29: return constructBoxUpdateExpression(pos + 8, ast); case 30: return constructBoxYieldExpression(pos + 8, ast); case 31: return constructBoxPrivateInExpression(pos + 8, ast); case 32: return constructBoxJSXElement(pos + 8, ast); case 33: return constructBoxJSXFragment(pos + 8, ast); case 34: return constructBoxTSAsExpression(pos + 8, ast); case 35: return constructBoxTSSatisfiesExpression(pos + 8, ast); case 36: return constructBoxTSTypeAssertion(pos + 8, ast); case 37: return constructBoxTSNonNullExpression(pos + 8, ast); case 38: return constructBoxTSInstantiationExpression(pos + 8, ast); case 39: return constructBoxV8IntrinsicExpression(pos + 8, ast); case 48: return constructBoxComputedMemberExpression(pos + 8, ast); case 49: return constructBoxStaticMemberExpression(pos + 8, ast); case 50: return constructBoxPrivateFieldExpression(pos + 8, ast); case 64: return constructBoxSpreadElement(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for Argument`); } } class UpdateExpression { type = 'UpdateExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get operator() { const internal = this.#internal; return constructUpdateOperator(internal.pos + 24, internal.ast); } get prefix() { const internal = this.#internal; return constructBool(internal.pos + 25, internal.ast); } get argument() { const internal = this.#internal; return constructSimpleAssignmentTarget(internal.pos + 8, internal.ast); } toJSON() { return { type: 'UpdateExpression', start: this.start, end: this.end, operator: this.operator, prefix: this.prefix, argument: this.argument, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugUpdateExpression.prototype); } } const DebugUpdateExpression = class UpdateExpression {}; class UnaryExpression { type = 'UnaryExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get operator() { const internal = this.#internal; return constructUnaryOperator(internal.pos + 24, internal.ast); } get argument() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } toJSON() { return { type: 'UnaryExpression', start: this.start, end: this.end, operator: this.operator, argument: this.argument, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugUnaryExpression.prototype); } } const DebugUnaryExpression = class UnaryExpression {}; class BinaryExpression { type = 'BinaryExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get left() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get operator() { const internal = this.#internal; return constructBinaryOperator(internal.pos + 40, internal.ast); } get right() { const internal = this.#internal; return constructExpression(internal.pos + 24, internal.ast); } toJSON() { return { type: 'BinaryExpression', start: this.start, end: this.end, left: this.left, operator: this.operator, right: this.right, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugBinaryExpression.prototype); } } const DebugBinaryExpression = class BinaryExpression {}; class PrivateInExpression { type = 'PrivateInExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get left() { const internal = this.#internal; return new PrivateIdentifier(internal.pos + 8, internal.ast); } get right() { const internal = this.#internal; return constructExpression(internal.pos + 32, internal.ast); } toJSON() { return { type: 'PrivateInExpression', start: this.start, end: this.end, left: this.left, right: this.right, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugPrivateInExpression.prototype); } } const DebugPrivateInExpression = class PrivateInExpression {}; class LogicalExpression { type = 'LogicalExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get left() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get operator() { const internal = this.#internal; return constructLogicalOperator(internal.pos + 40, internal.ast); } get right() { const internal = this.#internal; return constructExpression(internal.pos + 24, internal.ast); } toJSON() { return { type: 'LogicalExpression', start: this.start, end: this.end, left: this.left, operator: this.operator, right: this.right, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugLogicalExpression.prototype); } } const DebugLogicalExpression = class LogicalExpression {}; class ConditionalExpression { type = 'ConditionalExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get test() { const internal = this.#internal; return constructExpression(internal.pos + 8, internal.ast); } get consequent() { const internal = this.#internal; return constructExpression(internal.pos + 24, internal.ast); } get alternate() { const internal = this.#internal; return constructExpression(internal.pos + 40, internal.ast); } toJSON() { return { type: 'ConditionalExpression', start: this.start, end: this.end, test: this.test, consequent: this.consequent, alternate: this.alternate, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugConditionalExpression.prototype); } } const DebugConditionalExpression = class ConditionalExpression {}; class AssignmentExpression { type = 'AssignmentExpression'; #internal; constructor(pos, ast) { if (ast?.token !== TOKEN) constructorError(); const { nodes } = ast; const cached = nodes.get(pos); if (cached !== void 0) return cached; this.#internal = { pos, ast }; nodes.set(pos, this); } get start() { const internal = this.#internal; return constructU32(internal.pos, internal.ast); } get end() { const internal = this.#internal; return constructU32(internal.pos + 4, internal.ast); } get operator() { const internal = this.#internal; return constructAssignmentOperator(internal.pos + 40, internal.ast); } get left() { const internal = this.#internal; return constructAssignmentTarget(internal.pos + 8, internal.ast); } get right() { const internal = this.#internal; return constructExpression(internal.pos + 24, internal.ast); } toJSON() { return { type: 'AssignmentExpression', start: this.start, end: this.end, operator: this.operator, left: this.left, right: this.right, }; } [inspectSymbol]() { return Object.setPrototypeOf(this.toJSON(), DebugAssignmentExpression.prototype); } } const DebugAssignmentExpression = class AssignmentExpression {}; function constructAssignmentTarget(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxIdentifierReference(pos + 8, ast); case 1: return constructBoxTSAsExpression(pos + 8, ast); case 2: return constructBoxTSSatisfiesExpression(pos + 8, ast); case 3: return constructBoxTSNonNullExpression(pos + 8, ast); case 4: return constructBoxTSTypeAssertion(pos + 8, ast); case 8: return constructBoxArrayAssignmentTarget(pos + 8, ast); case 9: return constructBoxObjectAssignmentTarget(pos + 8, ast); case 48: return constructBoxComputedMemberExpression(pos + 8, ast); case 49: return constructBoxStaticMemberExpression(pos + 8, ast); case 50: return constructBoxPrivateFieldExpression(pos + 8, ast); default: throw new Error(`Unexpected discriminant ${ast.buffer[pos]} for AssignmentTarget`); } } function constructSimpleAssignmentTarget(pos, ast) { switch (ast.buffer[pos]) { case 0: return constructBoxIdentifierReference(pos + 8, ast); case 1: return constructBoxTSAsExpression(pos + 8, ast); case 2: return constructBoxTSSatisfiesExpression(pos + 8, ast); case 3: return constructBoxTSNonNullExpression(pos + 8, ast); case 4: return constructBoxTSTypeAssertion(pos + 8, ast); case 48: return co