rollup 4.64.9 → 5.0.0-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +3 -304
- package/dist/ast-types.d.ts +896 -0
- package/dist/bin/rollup +21 -22
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +1817 -1952
- package/dist/es/shared/parseAst.js +3567 -235
- package/dist/es/shared/watch.js +1765 -9600
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +3 -3
- package/dist/native.js +3 -1
- package/dist/parseAst.d.ts +13 -1
- package/dist/parseAst.js +8 -2
- package/dist/rollup.android-arm-eabi.node +0 -0
- package/dist/rollup.android-arm64.node +0 -0
- package/dist/rollup.d.ts +157 -105
- package/dist/rollup.darwin-arm64.node +0 -0
- package/dist/rollup.darwin-x64.node +0 -0
- package/dist/rollup.freebsd-arm64.node +0 -0
- package/dist/rollup.freebsd-x64.node +0 -0
- package/dist/rollup.js +2 -3
- package/dist/rollup.linux-arm-gnueabihf.node +0 -0
- package/dist/rollup.linux-arm-musleabihf.node +0 -0
- package/dist/rollup.linux-arm64-gnu.node +0 -0
- package/dist/rollup.linux-arm64-musl.node +0 -0
- package/dist/rollup.linux-loong64-gnu.node +0 -0
- package/dist/rollup.linux-loong64-musl.node +0 -0
- package/dist/rollup.linux-ppc64-gnu.node +0 -0
- package/dist/rollup.linux-ppc64-musl.node +0 -0
- package/dist/rollup.linux-riscv64-gnu.node +0 -0
- package/dist/rollup.linux-riscv64-musl.node +0 -0
- package/dist/rollup.linux-s390x-gnu.node +0 -0
- package/dist/rollup.linux-x64-gnu.node +0 -0
- package/dist/rollup.linux-x64-musl.node +0 -0
- package/dist/rollup.openbsd-x64.node +0 -0
- package/dist/rollup.openharmony-arm64.node +0 -0
- package/dist/rollup.win32-arm64-msvc.node +0 -0
- package/dist/rollup.win32-ia32-msvc.node +0 -0
- package/dist/rollup.win32-x64-gnu.node +0 -0
- package/dist/rollup.win32-x64-msvc.node +0 -0
- package/dist/shared/index.js +1775 -9597
- package/dist/shared/loadConfigFile.js +9 -9
- package/dist/shared/node-entry.js +2 -4
- package/dist/shared/parseAst.js +3595 -253
- package/dist/shared/rollup.js +1670 -1783
- package/dist/shared/watch-cli.js +10 -9
- package/dist/shared/watch.js +7 -11
- package/package.json +61 -62
- package/dist/shared/fsevents-importer.js +0 -37
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js
|
|
4
|
-
|
|
3
|
+
Rollup.js v5.0.0-1
|
|
4
|
+
Sun, 18 Oct 2026 06:06:25 GMT - commit ed75a6895d5bc62fdbff91b9d48e22e6e281e3bc
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import { parse, parseAsync } from '../../native.js';
|
|
10
|
+
import { parseAndWalk as parseAndWalk$1, parse, parseAsync } from '../../native.js';
|
|
11
11
|
import { resolve, dirname, basename, extname } from 'node:path';
|
|
12
12
|
|
|
13
13
|
// Replaces node:path in the browser build. Keep the behavior consistent with
|
|
@@ -61,30 +61,6 @@ const EMPTY_SET = Object.freeze(new (class extends Set {
|
|
|
61
61
|
}
|
|
62
62
|
})());
|
|
63
63
|
|
|
64
|
-
// This file is generated by scripts/generate-node-types.js.
|
|
65
|
-
// Do not edit this file directly.
|
|
66
|
-
const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
67
|
-
const AwaitExpression = 'AwaitExpression';
|
|
68
|
-
const BlockStatement = 'BlockStatement';
|
|
69
|
-
const CallExpression = 'CallExpression';
|
|
70
|
-
const CatchClause = 'CatchClause';
|
|
71
|
-
const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
|
|
72
|
-
const ExpressionStatement = 'ExpressionStatement';
|
|
73
|
-
const FunctionExpression = 'FunctionExpression';
|
|
74
|
-
const Identifier = 'Identifier';
|
|
75
|
-
const Literal = 'Literal';
|
|
76
|
-
const MemberExpression = 'MemberExpression';
|
|
77
|
-
const ObjectExpression = 'ObjectExpression';
|
|
78
|
-
const PanicError = 'PanicError';
|
|
79
|
-
const ParseError = 'ParseError';
|
|
80
|
-
const Program = 'Program';
|
|
81
|
-
const Property = 'Property';
|
|
82
|
-
const RestElement = 'RestElement';
|
|
83
|
-
const ReturnStatement = 'ReturnStatement';
|
|
84
|
-
const StaticBlock = 'StaticBlock';
|
|
85
|
-
const TemplateLiteral = 'TemplateLiteral';
|
|
86
|
-
const VariableDeclarator = 'VariableDeclarator';
|
|
87
|
-
|
|
88
64
|
/** @typedef {import('./types').Location} Location */
|
|
89
65
|
|
|
90
66
|
/**
|
|
@@ -311,6 +287,7 @@ const URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = 'configuration-options/#output-exter
|
|
|
311
287
|
const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
|
|
312
288
|
const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
|
|
313
289
|
const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals';
|
|
290
|
+
const URL_OUTPUT_IMPORTATTRIBUTESKEY = 'configuration-options/#output-importattributeskey';
|
|
314
291
|
const URL_OUTPUT_INLINEDYNAMICIMPORTS = 'configuration-options/#output-inlinedynamicimports';
|
|
315
292
|
const URL_OUTPUT_INTEROP = 'configuration-options/#output-interop';
|
|
316
293
|
const URL_OUTPUT_MANUALCHUNKS = 'configuration-options/#output-manualchunks';
|
|
@@ -326,6 +303,7 @@ const URL_WATCH = 'configuration-options/#watch';
|
|
|
326
303
|
// es-module-syntax
|
|
327
304
|
const URL_SOURCE_PHASE_IMPORTS = 'es-module-syntax/#source-phase-import';
|
|
328
305
|
const URL_GENERATEBUNDLE = 'plugin-development/#generatebundle';
|
|
306
|
+
const URL_THIS_RESOLVE = 'plugin-development/#this-resolve';
|
|
329
307
|
const URL_LOAD = 'plugin-development/#load';
|
|
330
308
|
const URL_TRANSFORM = 'plugin-development/#transform';
|
|
331
309
|
|
|
@@ -382,7 +360,7 @@ function augmentLogMessage(log) {
|
|
|
382
360
|
}
|
|
383
361
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
384
362
|
// error code below
|
|
385
|
-
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_CHUNK = 'CIRCULAR_CHUNK', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CONST_REASSIGN = 'CONST_REASSIGN', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_ARGUMENT_NAME = 'DUPLICATE_ARGUMENT_NAME', DUPLICATE_EXPORT = 'DUPLICATE_EXPORT', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NAME_OUTSIDE_OUTPUT_DIRECTORY = 'FILE_NAME_OUTSIDE_OUTPUT_DIRECTORY', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT',
|
|
363
|
+
const ADDON_ERROR = 'ADDON_ERROR', ALREADY_CLOSED = 'ALREADY_CLOSED', AMBIGUOUS_EXTERNAL_NAMESPACES = 'AMBIGUOUS_EXTERNAL_NAMESPACES', AMBIGUOUS_GLOBAL_NAME = 'AMBIGUOUS_GLOBAL_NAME', ANONYMOUS_PLUGIN_CACHE = 'ANONYMOUS_PLUGIN_CACHE', ASSET_NOT_FINALISED = 'ASSET_NOT_FINALISED', ASSET_NOT_FOUND = 'ASSET_NOT_FOUND', ASSET_SOURCE_ALREADY_SET = 'ASSET_SOURCE_ALREADY_SET', ASSET_SOURCE_MISSING = 'ASSET_SOURCE_MISSING', BAD_LOADER = 'BAD_LOADER', CANNOT_CALL_NAMESPACE = 'CANNOT_CALL_NAMESPACE', CANNOT_EMIT_FROM_OPTIONS_HOOK = 'CANNOT_EMIT_FROM_OPTIONS_HOOK', CANNOT_SERIALIZE_AST = 'CANNOT_SERIALIZE_AST', CHUNK_NOT_GENERATED = 'CHUNK_NOT_GENERATED', CHUNK_INVALID = 'CHUNK_INVALID', CIRCULAR_CHUNK = 'CIRCULAR_CHUNK', CIRCULAR_DEPENDENCY = 'CIRCULAR_DEPENDENCY', CIRCULAR_REEXPORT = 'CIRCULAR_REEXPORT', CONST_REASSIGN = 'CONST_REASSIGN', CYCLIC_CROSS_CHUNK_REEXPORT = 'CYCLIC_CROSS_CHUNK_REEXPORT', DEPRECATED_FEATURE = 'DEPRECATED_FEATURE', DUPLICATE_ARGUMENT_NAME = 'DUPLICATE_ARGUMENT_NAME', DUPLICATE_EXPORT = 'DUPLICATE_EXPORT', DUPLICATE_PLUGIN_NAME = 'DUPLICATE_PLUGIN_NAME', EMPTY_BUNDLE = 'EMPTY_BUNDLE', EMPTY_MANUAL_CHUNK = 'EMPTY_MANUAL_CHUNK', EVAL = 'EVAL', EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS = 'EXTERNAL_MODULES_CANNOT_BE_INCLUDED_IN_MANUAL_CHUNKS', EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES = 'EXTERNAL_MODULES_CANNOT_BE_TRANSFORMED_TO_MODULES', EXTERNAL_SYNTHETIC_EXPORTS = 'EXTERNAL_SYNTHETIC_EXPORTS', FILE_NAME_CONFLICT = 'FILE_NAME_CONFLICT', FILE_NAME_OUTSIDE_OUTPUT_DIRECTORY = 'FILE_NAME_OUTSIDE_OUTPUT_DIRECTORY', FILE_NOT_FOUND = 'FILE_NOT_FOUND', FIRST_SIDE_EFFECT = 'FIRST_SIDE_EFFECT', ILLEGAL_IDENTIFIER_AS_NAME = 'ILLEGAL_IDENTIFIER_AS_NAME', ILLEGAL_REASSIGNMENT = 'ILLEGAL_REASSIGNMENT', INVALID_ANNOTATION = 'INVALID_ANNOTATION', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', INVALID_CHUNK = 'INVALID_CHUNK', INVALID_EXPORT_OPTION = 'INVALID_EXPORT_OPTION', INVALID_EXTERNAL_ID = 'INVALID_EXTERNAL_ID', INVALID_IMPORT_ATTRIBUTE = 'INVALID_IMPORT_ATTRIBUTE', INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', INVALID_OPTION = 'INVALID_OPTION', INVALID_PLUGIN_HOOK = 'INVALID_PLUGIN_HOOK', INVALID_ROLLUP_PHASE = 'INVALID_ROLLUP_PHASE', INVALID_SETASSETSOURCE = 'INVALID_SETASSETSOURCE', INVALID_TLA_FORMAT = 'INVALID_TLA_FORMAT', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_GLOBAL_NAME = 'MISSING_GLOBAL_NAME', MISSING_IMPLICIT_DEPENDANT = 'MISSING_IMPLICIT_DEPENDANT', MISSING_JSX_EXPORT = 'MISSING_JSX_EXPORT', MISSING_NAME_OPTION_FOR_IIFE_EXPORT = 'MISSING_NAME_OPTION_FOR_IIFE_EXPORT', MISSING_NODE_BUILTINS = 'MISSING_NODE_BUILTINS', MISSING_OPTION = 'MISSING_OPTION', MIXED_EXPORTS = 'MIXED_EXPORTS', MODULE_LEVEL_DIRECTIVE = 'MODULE_LEVEL_DIRECTIVE', NAMESPACE_CONFLICT = 'NAMESPACE_CONFLICT', NON_EXTERNAL_SOURCE_PHASE_IMPORT = 'NON_EXTERNAL_SOURCE_PHASE_IMPORT', NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE = 'NO_TRANSFORM_MAP_OR_AST_WITHOUT_CODE', OPTIMIZE_CHUNK_STATUS = 'OPTIMIZE_CHUNK_STATUS', PARSE_ERROR = 'PARSE_ERROR', PLUGIN_ERROR = 'PLUGIN_ERROR', REDECLARATION_ERROR = 'REDECLARATION_ERROR', RESERVED_NAMESPACE = 'RESERVED_NAMESPACE', SHIMMED_EXPORT = 'SHIMMED_EXPORT', SOURCE_PHASE_FORMAT_UNSUPPORTED = 'SOURCE_PHASE_FORMAT_UNSUPPORTED', SOURCEMAP_BROKEN = 'SOURCEMAP_BROKEN', SOURCEMAP_ERROR = 'SOURCEMAP_ERROR', SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT = 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', THIS_IS_UNDEFINED = 'THIS_IS_UNDEFINED', UNEXPECTED_NAMED_IMPORT = 'UNEXPECTED_NAMED_IMPORT', UNKNOWN_OPTION = 'UNKNOWN_OPTION', UNRESOLVED_ENTRY = 'UNRESOLVED_ENTRY', UNRESOLVED_IMPORT = 'UNRESOLVED_IMPORT', UNUSED_EXTERNAL_IMPORT = 'UNUSED_EXTERNAL_IMPORT', VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
386
364
|
function logAddonNotGenerated(message, hook, plugin) {
|
|
387
365
|
return {
|
|
388
366
|
code: ADDON_ERROR,
|
|
@@ -405,6 +383,14 @@ function logAmbiguousExternalNamespaces(binding, reexportingModule, usedModule,
|
|
|
405
383
|
reexporter: reexportingModule
|
|
406
384
|
};
|
|
407
385
|
}
|
|
386
|
+
function logAmbiguousGlobalName(rawId, globalName) {
|
|
387
|
+
return {
|
|
388
|
+
code: AMBIGUOUS_GLOBAL_NAME,
|
|
389
|
+
id: rawId,
|
|
390
|
+
message: `The object form of "output.globals" maps several import attribute variants of the external module "${rawId}" to the same global name "${globalName}". Use the function form of "output.globals" to give each variant its own global name.`,
|
|
391
|
+
url: getRollupUrl(URL_OUTPUT_GLOBALS)
|
|
392
|
+
};
|
|
393
|
+
}
|
|
408
394
|
function logAnonymousPluginCache() {
|
|
409
395
|
return {
|
|
410
396
|
code: ANONYMOUS_PLUGIN_CACHE,
|
|
@@ -453,6 +439,19 @@ function logCannotEmitFromOptionsHook() {
|
|
|
453
439
|
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
454
440
|
};
|
|
455
441
|
}
|
|
442
|
+
function logUnknownNodeType(type, parentType, field) {
|
|
443
|
+
const location = parentType ? `in ${parentType}.${field}` : 'at the root';
|
|
444
|
+
return {
|
|
445
|
+
code: CANNOT_SERIALIZE_AST,
|
|
446
|
+
message: `Could not serialize AST: Found unknown node type "${type}" ${location}.`
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function logExpectedNodeList(parentType, field, value) {
|
|
450
|
+
return {
|
|
451
|
+
code: CANNOT_SERIALIZE_AST,
|
|
452
|
+
message: `Could not serialize AST: Expected ${parentType}.${field} to be an array, but it was ${JSON.stringify(value)}.`
|
|
453
|
+
};
|
|
454
|
+
}
|
|
456
455
|
function logChunkNotGeneratedForFileName(name) {
|
|
457
456
|
return {
|
|
458
457
|
code: CHUNK_NOT_GENERATED,
|
|
@@ -474,13 +473,17 @@ function logCircularDependency(cyclePath) {
|
|
|
474
473
|
message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}`
|
|
475
474
|
};
|
|
476
475
|
}
|
|
477
|
-
function logCircularChunk(cyclePath,
|
|
476
|
+
function logCircularChunk(cyclePath, manualChunkNames, nonManualChunkName, onlyExplicitManualChunks) {
|
|
478
477
|
return {
|
|
479
478
|
code: CIRCULAR_CHUNK,
|
|
480
479
|
ids: cyclePath,
|
|
481
|
-
message:
|
|
482
|
-
? `
|
|
483
|
-
: `
|
|
480
|
+
message: manualChunkNames.length === 0
|
|
481
|
+
? `Circular chunk: ${cyclePath.join(' -> ')}.`
|
|
482
|
+
: `Circular chunk: ${cyclePath.join(' -> ')}. ${nonManualChunkName === undefined
|
|
483
|
+
? `Please adjust the manual chunk logic for these chunks.`
|
|
484
|
+
: onlyExplicitManualChunks
|
|
485
|
+
? `Please consider disabling the "output.onlyExplicitManualChunks" option, as enabling it causes modules located between the modules included in the manual chunk "${manualChunkNames[0]}" to be extracted into the separate chunk "${nonManualChunkName}".`
|
|
486
|
+
: `Please adjust the manual chunks or the module structure.`}`
|
|
484
487
|
};
|
|
485
488
|
}
|
|
486
489
|
function logCircularReexport(exportName, exporter) {
|
|
@@ -504,7 +507,7 @@ function logDeprecation(deprecation, urlSnippet, plugin) {
|
|
|
504
507
|
code: DEPRECATED_FEATURE,
|
|
505
508
|
message: deprecation,
|
|
506
509
|
url: getRollupUrl(urlSnippet),
|
|
507
|
-
...({})
|
|
510
|
+
...(plugin ? { plugin } : {})
|
|
508
511
|
};
|
|
509
512
|
}
|
|
510
513
|
function logConstVariableReassignError() {
|
|
@@ -535,6 +538,14 @@ function logEmptyChunk(chunkName) {
|
|
|
535
538
|
names: [chunkName]
|
|
536
539
|
};
|
|
537
540
|
}
|
|
541
|
+
function logEmptyManualChunk(alias) {
|
|
542
|
+
return {
|
|
543
|
+
code: EMPTY_MANUAL_CHUNK,
|
|
544
|
+
message: `Manual chunk "${alias}" was not generated as none of its modules are included in the bundle.`,
|
|
545
|
+
names: [alias],
|
|
546
|
+
url: getRollupUrl(URL_OUTPUT_MANUALCHUNKS)
|
|
547
|
+
};
|
|
548
|
+
}
|
|
538
549
|
function logEval(id) {
|
|
539
550
|
return {
|
|
540
551
|
code: EVAL,
|
|
@@ -587,18 +598,6 @@ function logIllegalImportReassignment(name, importingId) {
|
|
|
587
598
|
message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
|
|
588
599
|
};
|
|
589
600
|
}
|
|
590
|
-
function logInconsistentImportAttributes(existingAttributes, newAttributes, source, importer) {
|
|
591
|
-
return {
|
|
592
|
-
code: INCONSISTENT_IMPORT_ATTRIBUTES,
|
|
593
|
-
message: `Module "${relativeId(importer)}" tried to import "${relativeId(source)}" with ${formatAttributes(newAttributes)} attributes, but it was already imported elsewhere with ${formatAttributes(existingAttributes)} attributes. Please ensure that import attributes for the same module are always consistent.`
|
|
594
|
-
};
|
|
595
|
-
}
|
|
596
|
-
const formatAttributes = (attributes) => {
|
|
597
|
-
const entries = Object.entries(attributes);
|
|
598
|
-
if (entries.length === 0)
|
|
599
|
-
return 'no';
|
|
600
|
-
return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
|
|
601
|
-
};
|
|
602
601
|
function logInvalidAnnotation(comment, id, type) {
|
|
603
602
|
return {
|
|
604
603
|
code: INVALID_ANNOTATION,
|
|
@@ -1039,11 +1038,11 @@ function logFailedValidation(message) {
|
|
|
1039
1038
|
};
|
|
1040
1039
|
}
|
|
1041
1040
|
function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
|
|
1042
|
-
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
|
|
1041
|
+
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations, plugin);
|
|
1043
1042
|
}
|
|
1044
1043
|
function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
|
|
1045
1044
|
if (activeDeprecation || strictDeprecations) {
|
|
1046
|
-
const warning = logDeprecation(deprecation, urlSnippet);
|
|
1045
|
+
const warning = logDeprecation(deprecation, urlSnippet, plugin);
|
|
1047
1046
|
if (strictDeprecations) {
|
|
1048
1047
|
return error(warning);
|
|
1049
1048
|
}
|
|
@@ -1051,7 +1050,33 @@ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation,
|
|
|
1051
1050
|
}
|
|
1052
1051
|
}
|
|
1053
1052
|
|
|
1054
|
-
// This file is generated by scripts/generate-
|
|
1053
|
+
// This file is generated by scripts/generate-node-types.ts.
|
|
1054
|
+
// Do not edit this file directly.
|
|
1055
|
+
const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
1056
|
+
const AwaitExpression = 'AwaitExpression';
|
|
1057
|
+
const BlockStatement = 'BlockStatement';
|
|
1058
|
+
const CallExpression = 'CallExpression';
|
|
1059
|
+
const CatchClause = 'CatchClause';
|
|
1060
|
+
const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
|
|
1061
|
+
const ExpressionStatement = 'ExpressionStatement';
|
|
1062
|
+
const FunctionDeclaration = 'FunctionDeclaration';
|
|
1063
|
+
const FunctionExpression = 'FunctionExpression';
|
|
1064
|
+
const Identifier = 'Identifier';
|
|
1065
|
+
const IfStatement$1 = 'IfStatement';
|
|
1066
|
+
const Literal = 'Literal';
|
|
1067
|
+
const MemberExpression = 'MemberExpression';
|
|
1068
|
+
const ObjectExpression = 'ObjectExpression';
|
|
1069
|
+
const PanicError = 'PanicError';
|
|
1070
|
+
const ParseError = 'ParseError';
|
|
1071
|
+
const Program = 'Program';
|
|
1072
|
+
const Property = 'Property';
|
|
1073
|
+
const RestElement = 'RestElement';
|
|
1074
|
+
const ReturnStatement = 'ReturnStatement';
|
|
1075
|
+
const StaticBlock = 'StaticBlock';
|
|
1076
|
+
const TemplateLiteral = 'TemplateLiteral';
|
|
1077
|
+
const VariableDeclarator = 'VariableDeclarator';
|
|
1078
|
+
|
|
1079
|
+
// This file is generated by scripts/generate-string-constants.ts.
|
|
1055
1080
|
// Do not edit this file directly.
|
|
1056
1081
|
const FIXED_STRINGS = [
|
|
1057
1082
|
'var',
|
|
@@ -1082,8 +1107,6 @@ const FIXED_STRINGS = [
|
|
|
1082
1107
|
'<<',
|
|
1083
1108
|
'>>',
|
|
1084
1109
|
'>>>',
|
|
1085
|
-
'+',
|
|
1086
|
-
'-',
|
|
1087
1110
|
'*',
|
|
1088
1111
|
'/',
|
|
1089
1112
|
'%',
|
|
@@ -1121,8 +1144,6 @@ const FIXED_STRINGS = [
|
|
|
1121
1144
|
'defer'
|
|
1122
1145
|
];
|
|
1123
1146
|
|
|
1124
|
-
const ANNOTATION_KEY = '_rollupAnnotations';
|
|
1125
|
-
const INVALID_ANNOTATION_KEY = '_rollupRemoved';
|
|
1126
1147
|
const convertAnnotations = (position, buffer) => {
|
|
1127
1148
|
if (position === 0)
|
|
1128
1149
|
return EMPTY_ARRAY;
|
|
@@ -1140,10 +1161,10 @@ const convertAnnotation = (position, buffer) => {
|
|
|
1140
1161
|
return { end, start, type };
|
|
1141
1162
|
};
|
|
1142
1163
|
|
|
1143
|
-
// This file is generated by scripts/generate-buffer-to-ast.
|
|
1164
|
+
// This file is generated by scripts/generate-buffer-to-lazy-ast.ts.
|
|
1144
1165
|
// Do not edit this file directly.
|
|
1145
|
-
|
|
1146
|
-
const node = convertNode(
|
|
1166
|
+
const deserializeLazyAstBuffer = (buffer, position) => {
|
|
1167
|
+
const node = convertNode$1(position, buffer);
|
|
1147
1168
|
switch (node.type) {
|
|
1148
1169
|
case PanicError: {
|
|
1149
1170
|
return error(getRollupError(logParseError(node.message)));
|
|
@@ -1155,511 +1176,2500 @@ function convertProgram(buffer) {
|
|
|
1155
1176
|
return node;
|
|
1156
1177
|
}
|
|
1157
1178
|
}
|
|
1158
|
-
}
|
|
1179
|
+
};
|
|
1159
1180
|
/* eslint-disable sort-keys */
|
|
1160
|
-
const nodeConverters = [
|
|
1181
|
+
const nodeConverters$1 = [
|
|
1161
1182
|
function panicError(position, buffer) {
|
|
1162
|
-
|
|
1183
|
+
const node = {
|
|
1163
1184
|
type: 'PanicError',
|
|
1164
1185
|
start: buffer[position],
|
|
1165
1186
|
end: buffer[position + 1],
|
|
1166
|
-
message
|
|
1187
|
+
get message() {
|
|
1188
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1189
|
+
Object.defineProperty(node, 'message', { value: result });
|
|
1190
|
+
return result;
|
|
1191
|
+
}
|
|
1167
1192
|
};
|
|
1193
|
+
return node;
|
|
1168
1194
|
},
|
|
1169
1195
|
function parseError(position, buffer) {
|
|
1170
|
-
|
|
1196
|
+
const node = {
|
|
1171
1197
|
type: 'ParseError',
|
|
1172
1198
|
start: buffer[position],
|
|
1173
1199
|
end: buffer[position + 1],
|
|
1174
|
-
message
|
|
1200
|
+
get message() {
|
|
1201
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1202
|
+
Object.defineProperty(node, 'message', { value: result });
|
|
1203
|
+
return result;
|
|
1204
|
+
}
|
|
1175
1205
|
};
|
|
1206
|
+
return node;
|
|
1176
1207
|
},
|
|
1177
1208
|
function arrayExpression(position, buffer) {
|
|
1178
|
-
|
|
1209
|
+
const node = {
|
|
1179
1210
|
type: 'ArrayExpression',
|
|
1180
1211
|
start: buffer[position],
|
|
1181
1212
|
end: buffer[position + 1],
|
|
1182
|
-
elements
|
|
1213
|
+
get elements() {
|
|
1214
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1215
|
+
Object.defineProperty(node, 'elements', { value: result });
|
|
1216
|
+
return result;
|
|
1217
|
+
}
|
|
1183
1218
|
};
|
|
1219
|
+
return node;
|
|
1184
1220
|
},
|
|
1185
1221
|
function arrayPattern(position, buffer) {
|
|
1186
|
-
|
|
1222
|
+
const node = {
|
|
1187
1223
|
type: 'ArrayPattern',
|
|
1188
1224
|
start: buffer[position],
|
|
1189
1225
|
end: buffer[position + 1],
|
|
1190
|
-
elements
|
|
1226
|
+
get elements() {
|
|
1227
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1228
|
+
Object.defineProperty(node, 'elements', { value: result });
|
|
1229
|
+
return result;
|
|
1230
|
+
}
|
|
1191
1231
|
};
|
|
1232
|
+
return node;
|
|
1192
1233
|
},
|
|
1193
1234
|
function arrowFunctionExpression(position, buffer) {
|
|
1194
1235
|
const flags = buffer[position + 2];
|
|
1195
1236
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1196
|
-
|
|
1237
|
+
const node = {
|
|
1197
1238
|
type: 'ArrowFunctionExpression',
|
|
1198
1239
|
start: buffer[position],
|
|
1199
1240
|
end: buffer[position + 1],
|
|
1200
1241
|
async: (flags & 1) === 1,
|
|
1201
1242
|
expression: (flags & 2) === 2,
|
|
1202
1243
|
generator: (flags & 4) === 4,
|
|
1203
|
-
...(annotations.length > 0 ? {
|
|
1204
|
-
params
|
|
1205
|
-
|
|
1244
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1245
|
+
get params() {
|
|
1246
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1247
|
+
Object.defineProperty(node, 'params', { value: result });
|
|
1248
|
+
return result;
|
|
1249
|
+
},
|
|
1250
|
+
get body() {
|
|
1251
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1252
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1253
|
+
return result;
|
|
1254
|
+
},
|
|
1206
1255
|
id: null
|
|
1207
1256
|
};
|
|
1257
|
+
return node;
|
|
1208
1258
|
},
|
|
1209
1259
|
function assignmentExpression(position, buffer) {
|
|
1210
|
-
|
|
1260
|
+
const node = {
|
|
1211
1261
|
type: 'AssignmentExpression',
|
|
1212
1262
|
start: buffer[position],
|
|
1213
1263
|
end: buffer[position + 1],
|
|
1214
|
-
operator
|
|
1215
|
-
|
|
1216
|
-
|
|
1264
|
+
get operator() {
|
|
1265
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
1266
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
1267
|
+
return result;
|
|
1268
|
+
},
|
|
1269
|
+
get left() {
|
|
1270
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1271
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1272
|
+
return result;
|
|
1273
|
+
},
|
|
1274
|
+
get right() {
|
|
1275
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1276
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1277
|
+
return result;
|
|
1278
|
+
}
|
|
1217
1279
|
};
|
|
1280
|
+
return node;
|
|
1218
1281
|
},
|
|
1219
1282
|
function assignmentPattern(position, buffer) {
|
|
1220
|
-
|
|
1283
|
+
const node = {
|
|
1221
1284
|
type: 'AssignmentPattern',
|
|
1222
1285
|
start: buffer[position],
|
|
1223
1286
|
end: buffer[position + 1],
|
|
1224
|
-
left
|
|
1225
|
-
|
|
1287
|
+
get left() {
|
|
1288
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1289
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1290
|
+
return result;
|
|
1291
|
+
},
|
|
1292
|
+
get right() {
|
|
1293
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1294
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1295
|
+
return result;
|
|
1296
|
+
}
|
|
1226
1297
|
};
|
|
1298
|
+
return node;
|
|
1227
1299
|
},
|
|
1228
1300
|
function awaitExpression(position, buffer) {
|
|
1229
|
-
|
|
1301
|
+
const node = {
|
|
1230
1302
|
type: 'AwaitExpression',
|
|
1231
1303
|
start: buffer[position],
|
|
1232
1304
|
end: buffer[position + 1],
|
|
1233
|
-
argument
|
|
1305
|
+
get argument() {
|
|
1306
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1307
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
1308
|
+
return result;
|
|
1309
|
+
}
|
|
1234
1310
|
};
|
|
1311
|
+
return node;
|
|
1235
1312
|
},
|
|
1236
1313
|
function binaryExpression(position, buffer) {
|
|
1237
|
-
|
|
1314
|
+
const node = {
|
|
1238
1315
|
type: 'BinaryExpression',
|
|
1239
1316
|
start: buffer[position],
|
|
1240
1317
|
end: buffer[position + 1],
|
|
1241
|
-
operator
|
|
1242
|
-
|
|
1243
|
-
|
|
1318
|
+
get operator() {
|
|
1319
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
1320
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
1321
|
+
return result;
|
|
1322
|
+
},
|
|
1323
|
+
get left() {
|
|
1324
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1325
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1326
|
+
return result;
|
|
1327
|
+
},
|
|
1328
|
+
get right() {
|
|
1329
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1330
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1331
|
+
return result;
|
|
1332
|
+
}
|
|
1244
1333
|
};
|
|
1334
|
+
return node;
|
|
1245
1335
|
},
|
|
1246
1336
|
function blockStatement(position, buffer) {
|
|
1247
|
-
|
|
1337
|
+
const node = {
|
|
1248
1338
|
type: 'BlockStatement',
|
|
1249
1339
|
start: buffer[position],
|
|
1250
1340
|
end: buffer[position + 1],
|
|
1251
|
-
body
|
|
1341
|
+
get body() {
|
|
1342
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1343
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1344
|
+
return result;
|
|
1345
|
+
}
|
|
1252
1346
|
};
|
|
1347
|
+
return node;
|
|
1253
1348
|
},
|
|
1254
1349
|
function breakStatement(position, buffer) {
|
|
1255
1350
|
const labelPosition = buffer[position + 2];
|
|
1256
|
-
|
|
1351
|
+
const node = {
|
|
1257
1352
|
type: 'BreakStatement',
|
|
1258
1353
|
start: buffer[position],
|
|
1259
1354
|
end: buffer[position + 1],
|
|
1260
|
-
label
|
|
1355
|
+
get label() {
|
|
1356
|
+
const result = labelPosition === 0 ? null : convertNode$1(labelPosition, buffer);
|
|
1357
|
+
Object.defineProperty(node, 'label', { value: result });
|
|
1358
|
+
return result;
|
|
1359
|
+
}
|
|
1261
1360
|
};
|
|
1361
|
+
return node;
|
|
1262
1362
|
},
|
|
1263
1363
|
function callExpression(position, buffer) {
|
|
1264
1364
|
const flags = buffer[position + 2];
|
|
1265
1365
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1266
|
-
|
|
1366
|
+
const node = {
|
|
1267
1367
|
type: 'CallExpression',
|
|
1268
1368
|
start: buffer[position],
|
|
1269
1369
|
end: buffer[position + 1],
|
|
1270
1370
|
optional: (flags & 1) === 1,
|
|
1271
|
-
...(annotations.length > 0 ? {
|
|
1272
|
-
callee
|
|
1273
|
-
|
|
1371
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1372
|
+
get callee() {
|
|
1373
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1374
|
+
Object.defineProperty(node, 'callee', { value: result });
|
|
1375
|
+
return result;
|
|
1376
|
+
},
|
|
1377
|
+
get arguments() {
|
|
1378
|
+
const result = convertNodeList$1(buffer[position + 5], buffer);
|
|
1379
|
+
Object.defineProperty(node, 'arguments', { value: result });
|
|
1380
|
+
return result;
|
|
1381
|
+
}
|
|
1274
1382
|
};
|
|
1383
|
+
return node;
|
|
1275
1384
|
},
|
|
1276
1385
|
function catchClause(position, buffer) {
|
|
1277
1386
|
const parameterPosition = buffer[position + 2];
|
|
1278
|
-
|
|
1387
|
+
const node = {
|
|
1279
1388
|
type: 'CatchClause',
|
|
1280
1389
|
start: buffer[position],
|
|
1281
1390
|
end: buffer[position + 1],
|
|
1282
|
-
param
|
|
1283
|
-
|
|
1391
|
+
get param() {
|
|
1392
|
+
const result = parameterPosition === 0 ? null : convertNode$1(parameterPosition, buffer);
|
|
1393
|
+
Object.defineProperty(node, 'param', { value: result });
|
|
1394
|
+
return result;
|
|
1395
|
+
},
|
|
1396
|
+
get body() {
|
|
1397
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1398
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1399
|
+
return result;
|
|
1400
|
+
}
|
|
1284
1401
|
};
|
|
1402
|
+
return node;
|
|
1285
1403
|
},
|
|
1286
1404
|
function chainExpression(position, buffer) {
|
|
1287
|
-
|
|
1405
|
+
const node = {
|
|
1288
1406
|
type: 'ChainExpression',
|
|
1289
1407
|
start: buffer[position],
|
|
1290
1408
|
end: buffer[position + 1],
|
|
1291
|
-
expression
|
|
1409
|
+
get expression() {
|
|
1410
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1411
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1412
|
+
return result;
|
|
1413
|
+
}
|
|
1292
1414
|
};
|
|
1415
|
+
return node;
|
|
1293
1416
|
},
|
|
1294
1417
|
function classBody(position, buffer) {
|
|
1295
|
-
|
|
1418
|
+
const node = {
|
|
1296
1419
|
type: 'ClassBody',
|
|
1297
1420
|
start: buffer[position],
|
|
1298
1421
|
end: buffer[position + 1],
|
|
1299
|
-
body
|
|
1422
|
+
get body() {
|
|
1423
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1424
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1425
|
+
return result;
|
|
1426
|
+
}
|
|
1300
1427
|
};
|
|
1428
|
+
return node;
|
|
1301
1429
|
},
|
|
1302
1430
|
function classDeclaration(position, buffer) {
|
|
1303
1431
|
const idPosition = buffer[position + 3];
|
|
1304
1432
|
const superClassPosition = buffer[position + 4];
|
|
1305
|
-
|
|
1433
|
+
const node = {
|
|
1306
1434
|
type: 'ClassDeclaration',
|
|
1307
1435
|
start: buffer[position],
|
|
1308
1436
|
end: buffer[position + 1],
|
|
1309
|
-
decorators
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1437
|
+
get decorators() {
|
|
1438
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1439
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
1440
|
+
return result;
|
|
1441
|
+
},
|
|
1442
|
+
get id() {
|
|
1443
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
1444
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
1445
|
+
return result;
|
|
1446
|
+
},
|
|
1447
|
+
get superClass() {
|
|
1448
|
+
const result = superClassPosition === 0 ? null : convertNode$1(superClassPosition, buffer);
|
|
1449
|
+
Object.defineProperty(node, 'superClass', { value: result });
|
|
1450
|
+
return result;
|
|
1451
|
+
},
|
|
1452
|
+
get body() {
|
|
1453
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1454
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1455
|
+
return result;
|
|
1456
|
+
}
|
|
1313
1457
|
};
|
|
1458
|
+
return node;
|
|
1314
1459
|
},
|
|
1315
1460
|
function classExpression(position, buffer) {
|
|
1316
1461
|
const idPosition = buffer[position + 3];
|
|
1317
1462
|
const superClassPosition = buffer[position + 4];
|
|
1318
|
-
|
|
1463
|
+
const node = {
|
|
1319
1464
|
type: 'ClassExpression',
|
|
1320
1465
|
start: buffer[position],
|
|
1321
1466
|
end: buffer[position + 1],
|
|
1322
|
-
decorators
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1467
|
+
get decorators() {
|
|
1468
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1469
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
1470
|
+
return result;
|
|
1471
|
+
},
|
|
1472
|
+
get id() {
|
|
1473
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
1474
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
1475
|
+
return result;
|
|
1476
|
+
},
|
|
1477
|
+
get superClass() {
|
|
1478
|
+
const result = superClassPosition === 0 ? null : convertNode$1(superClassPosition, buffer);
|
|
1479
|
+
Object.defineProperty(node, 'superClass', { value: result });
|
|
1480
|
+
return result;
|
|
1481
|
+
},
|
|
1482
|
+
get body() {
|
|
1483
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1484
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1485
|
+
return result;
|
|
1486
|
+
}
|
|
1326
1487
|
};
|
|
1488
|
+
return node;
|
|
1327
1489
|
},
|
|
1328
1490
|
function conditionalExpression(position, buffer) {
|
|
1329
|
-
|
|
1491
|
+
const node = {
|
|
1330
1492
|
type: 'ConditionalExpression',
|
|
1331
1493
|
start: buffer[position],
|
|
1332
1494
|
end: buffer[position + 1],
|
|
1333
|
-
test
|
|
1334
|
-
|
|
1335
|
-
|
|
1495
|
+
get test() {
|
|
1496
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1497
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1498
|
+
return result;
|
|
1499
|
+
},
|
|
1500
|
+
get consequent() {
|
|
1501
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1502
|
+
Object.defineProperty(node, 'consequent', { value: result });
|
|
1503
|
+
return result;
|
|
1504
|
+
},
|
|
1505
|
+
get alternate() {
|
|
1506
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1507
|
+
Object.defineProperty(node, 'alternate', { value: result });
|
|
1508
|
+
return result;
|
|
1509
|
+
}
|
|
1336
1510
|
};
|
|
1511
|
+
return node;
|
|
1337
1512
|
},
|
|
1338
1513
|
function continueStatement(position, buffer) {
|
|
1339
1514
|
const labelPosition = buffer[position + 2];
|
|
1340
|
-
|
|
1515
|
+
const node = {
|
|
1341
1516
|
type: 'ContinueStatement',
|
|
1342
1517
|
start: buffer[position],
|
|
1343
1518
|
end: buffer[position + 1],
|
|
1344
|
-
label
|
|
1519
|
+
get label() {
|
|
1520
|
+
const result = labelPosition === 0 ? null : convertNode$1(labelPosition, buffer);
|
|
1521
|
+
Object.defineProperty(node, 'label', { value: result });
|
|
1522
|
+
return result;
|
|
1523
|
+
}
|
|
1345
1524
|
};
|
|
1525
|
+
return node;
|
|
1346
1526
|
},
|
|
1347
1527
|
function debuggerStatement(position, buffer) {
|
|
1348
|
-
|
|
1528
|
+
const node = {
|
|
1349
1529
|
type: 'DebuggerStatement',
|
|
1350
1530
|
start: buffer[position],
|
|
1351
1531
|
end: buffer[position + 1]
|
|
1352
1532
|
};
|
|
1533
|
+
return node;
|
|
1353
1534
|
},
|
|
1354
1535
|
function decorator(position, buffer) {
|
|
1355
|
-
|
|
1536
|
+
const node = {
|
|
1356
1537
|
type: 'Decorator',
|
|
1357
1538
|
start: buffer[position],
|
|
1358
1539
|
end: buffer[position + 1],
|
|
1359
|
-
expression
|
|
1540
|
+
get expression() {
|
|
1541
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1542
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1543
|
+
return result;
|
|
1544
|
+
}
|
|
1360
1545
|
};
|
|
1546
|
+
return node;
|
|
1361
1547
|
},
|
|
1362
1548
|
function directive(position, buffer) {
|
|
1363
|
-
|
|
1549
|
+
const node = {
|
|
1364
1550
|
type: 'ExpressionStatement',
|
|
1365
1551
|
start: buffer[position],
|
|
1366
1552
|
end: buffer[position + 1],
|
|
1367
|
-
directive
|
|
1368
|
-
|
|
1553
|
+
get directive() {
|
|
1554
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1555
|
+
Object.defineProperty(node, 'directive', { value: result });
|
|
1556
|
+
return result;
|
|
1557
|
+
},
|
|
1558
|
+
get expression() {
|
|
1559
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1560
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1561
|
+
return result;
|
|
1562
|
+
}
|
|
1369
1563
|
};
|
|
1564
|
+
return node;
|
|
1370
1565
|
},
|
|
1371
1566
|
function doWhileStatement(position, buffer) {
|
|
1372
|
-
|
|
1567
|
+
const node = {
|
|
1373
1568
|
type: 'DoWhileStatement',
|
|
1374
1569
|
start: buffer[position],
|
|
1375
1570
|
end: buffer[position + 1],
|
|
1376
|
-
body
|
|
1377
|
-
|
|
1571
|
+
get body() {
|
|
1572
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1573
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1574
|
+
return result;
|
|
1575
|
+
},
|
|
1576
|
+
get test() {
|
|
1577
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1578
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1579
|
+
return result;
|
|
1580
|
+
}
|
|
1378
1581
|
};
|
|
1582
|
+
return node;
|
|
1379
1583
|
},
|
|
1380
1584
|
function emptyStatement(position, buffer) {
|
|
1381
|
-
|
|
1585
|
+
const node = {
|
|
1382
1586
|
type: 'EmptyStatement',
|
|
1383
1587
|
start: buffer[position],
|
|
1384
1588
|
end: buffer[position + 1]
|
|
1385
1589
|
};
|
|
1590
|
+
return node;
|
|
1386
1591
|
},
|
|
1387
1592
|
function exportAllDeclaration(position, buffer) {
|
|
1388
1593
|
const exportedPosition = buffer[position + 2];
|
|
1389
|
-
|
|
1594
|
+
const node = {
|
|
1390
1595
|
type: 'ExportAllDeclaration',
|
|
1391
1596
|
start: buffer[position],
|
|
1392
1597
|
end: buffer[position + 1],
|
|
1393
|
-
exported
|
|
1394
|
-
|
|
1395
|
-
|
|
1598
|
+
get exported() {
|
|
1599
|
+
const result = exportedPosition === 0 ? null : convertNode$1(exportedPosition, buffer);
|
|
1600
|
+
Object.defineProperty(node, 'exported', { value: result });
|
|
1601
|
+
return result;
|
|
1602
|
+
},
|
|
1603
|
+
get source() {
|
|
1604
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1605
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
1606
|
+
return result;
|
|
1607
|
+
},
|
|
1608
|
+
get attributes() {
|
|
1609
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1610
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
1611
|
+
return result;
|
|
1612
|
+
}
|
|
1396
1613
|
};
|
|
1614
|
+
return node;
|
|
1397
1615
|
},
|
|
1398
1616
|
function exportDefaultDeclaration(position, buffer) {
|
|
1399
|
-
|
|
1617
|
+
const node = {
|
|
1400
1618
|
type: 'ExportDefaultDeclaration',
|
|
1401
1619
|
start: buffer[position],
|
|
1402
1620
|
end: buffer[position + 1],
|
|
1403
|
-
declaration
|
|
1621
|
+
get declaration() {
|
|
1622
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1623
|
+
Object.defineProperty(node, 'declaration', { value: result });
|
|
1624
|
+
return result;
|
|
1625
|
+
}
|
|
1404
1626
|
};
|
|
1627
|
+
return node;
|
|
1405
1628
|
},
|
|
1406
1629
|
function exportNamedDeclaration(position, buffer) {
|
|
1407
1630
|
const sourcePosition = buffer[position + 3];
|
|
1408
1631
|
const declarationPosition = buffer[position + 5];
|
|
1409
|
-
|
|
1632
|
+
const node = {
|
|
1410
1633
|
type: 'ExportNamedDeclaration',
|
|
1411
1634
|
start: buffer[position],
|
|
1412
1635
|
end: buffer[position + 1],
|
|
1413
|
-
specifiers
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1636
|
+
get specifiers() {
|
|
1637
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1638
|
+
Object.defineProperty(node, 'specifiers', { value: result });
|
|
1639
|
+
return result;
|
|
1640
|
+
},
|
|
1641
|
+
get source() {
|
|
1642
|
+
const result = sourcePosition === 0 ? null : convertNode$1(sourcePosition, buffer);
|
|
1643
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
1644
|
+
return result;
|
|
1645
|
+
},
|
|
1646
|
+
get attributes() {
|
|
1647
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1648
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
1649
|
+
return result;
|
|
1650
|
+
},
|
|
1651
|
+
get declaration() {
|
|
1652
|
+
const result = declarationPosition === 0 ? null : convertNode$1(declarationPosition, buffer);
|
|
1653
|
+
Object.defineProperty(node, 'declaration', { value: result });
|
|
1654
|
+
return result;
|
|
1655
|
+
}
|
|
1417
1656
|
};
|
|
1657
|
+
return node;
|
|
1418
1658
|
},
|
|
1419
1659
|
function exportSpecifier(position, buffer) {
|
|
1420
|
-
const local = convertNode(buffer[position + 2], buffer);
|
|
1660
|
+
const local = convertNode$1(buffer[position + 2], buffer);
|
|
1421
1661
|
const exportedPosition = buffer[position + 3];
|
|
1422
|
-
|
|
1662
|
+
const node = {
|
|
1423
1663
|
type: 'ExportSpecifier',
|
|
1424
1664
|
start: buffer[position],
|
|
1425
1665
|
end: buffer[position + 1],
|
|
1426
1666
|
local,
|
|
1427
|
-
exported
|
|
1667
|
+
get exported() {
|
|
1668
|
+
const result = exportedPosition === 0 ? { ...local } : convertNode$1(exportedPosition, buffer);
|
|
1669
|
+
Object.defineProperty(node, 'exported', { value: result });
|
|
1670
|
+
return result;
|
|
1671
|
+
}
|
|
1428
1672
|
};
|
|
1673
|
+
return node;
|
|
1429
1674
|
},
|
|
1430
1675
|
function expressionStatement(position, buffer) {
|
|
1431
|
-
|
|
1676
|
+
const node = {
|
|
1432
1677
|
type: 'ExpressionStatement',
|
|
1433
1678
|
start: buffer[position],
|
|
1434
1679
|
end: buffer[position + 1],
|
|
1435
|
-
expression
|
|
1680
|
+
get expression() {
|
|
1681
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1682
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1683
|
+
return result;
|
|
1684
|
+
}
|
|
1436
1685
|
};
|
|
1686
|
+
return node;
|
|
1437
1687
|
},
|
|
1438
1688
|
function forInStatement(position, buffer) {
|
|
1439
|
-
|
|
1689
|
+
const node = {
|
|
1440
1690
|
type: 'ForInStatement',
|
|
1441
1691
|
start: buffer[position],
|
|
1442
1692
|
end: buffer[position + 1],
|
|
1443
|
-
left
|
|
1444
|
-
|
|
1445
|
-
|
|
1693
|
+
get left() {
|
|
1694
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1695
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1696
|
+
return result;
|
|
1697
|
+
},
|
|
1698
|
+
get right() {
|
|
1699
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1700
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1701
|
+
return result;
|
|
1702
|
+
},
|
|
1703
|
+
get body() {
|
|
1704
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1705
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1706
|
+
return result;
|
|
1707
|
+
}
|
|
1446
1708
|
};
|
|
1709
|
+
return node;
|
|
1447
1710
|
},
|
|
1448
1711
|
function forOfStatement(position, buffer) {
|
|
1449
1712
|
const flags = buffer[position + 2];
|
|
1450
|
-
|
|
1713
|
+
const node = {
|
|
1451
1714
|
type: 'ForOfStatement',
|
|
1452
1715
|
start: buffer[position],
|
|
1453
1716
|
end: buffer[position + 1],
|
|
1454
1717
|
await: (flags & 1) === 1,
|
|
1455
|
-
left
|
|
1456
|
-
|
|
1457
|
-
|
|
1718
|
+
get left() {
|
|
1719
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1720
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1721
|
+
return result;
|
|
1722
|
+
},
|
|
1723
|
+
get right() {
|
|
1724
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1725
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1726
|
+
return result;
|
|
1727
|
+
},
|
|
1728
|
+
get body() {
|
|
1729
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1730
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1731
|
+
return result;
|
|
1732
|
+
}
|
|
1458
1733
|
};
|
|
1734
|
+
return node;
|
|
1459
1735
|
},
|
|
1460
1736
|
function forStatement(position, buffer) {
|
|
1461
1737
|
const initPosition = buffer[position + 2];
|
|
1462
1738
|
const testPosition = buffer[position + 3];
|
|
1463
1739
|
const updatePosition = buffer[position + 4];
|
|
1464
|
-
|
|
1740
|
+
const node = {
|
|
1465
1741
|
type: 'ForStatement',
|
|
1466
1742
|
start: buffer[position],
|
|
1467
1743
|
end: buffer[position + 1],
|
|
1468
|
-
init
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1744
|
+
get init() {
|
|
1745
|
+
const result = initPosition === 0 ? null : convertNode$1(initPosition, buffer);
|
|
1746
|
+
Object.defineProperty(node, 'init', { value: result });
|
|
1747
|
+
return result;
|
|
1748
|
+
},
|
|
1749
|
+
get test() {
|
|
1750
|
+
const result = testPosition === 0 ? null : convertNode$1(testPosition, buffer);
|
|
1751
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1752
|
+
return result;
|
|
1753
|
+
},
|
|
1754
|
+
get update() {
|
|
1755
|
+
const result = updatePosition === 0 ? null : convertNode$1(updatePosition, buffer);
|
|
1756
|
+
Object.defineProperty(node, 'update', { value: result });
|
|
1757
|
+
return result;
|
|
1758
|
+
},
|
|
1759
|
+
get body() {
|
|
1760
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1761
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1762
|
+
return result;
|
|
1763
|
+
}
|
|
1472
1764
|
};
|
|
1765
|
+
return node;
|
|
1473
1766
|
},
|
|
1474
1767
|
function functionDeclaration(position, buffer) {
|
|
1475
1768
|
const flags = buffer[position + 2];
|
|
1476
1769
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1477
1770
|
const idPosition = buffer[position + 4];
|
|
1478
|
-
|
|
1771
|
+
const node = {
|
|
1479
1772
|
type: 'FunctionDeclaration',
|
|
1480
1773
|
start: buffer[position],
|
|
1481
1774
|
end: buffer[position + 1],
|
|
1482
1775
|
async: (flags & 1) === 1,
|
|
1483
1776
|
generator: (flags & 2) === 2,
|
|
1484
|
-
...(annotations.length > 0 ? {
|
|
1485
|
-
id
|
|
1486
|
-
|
|
1487
|
-
|
|
1777
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1778
|
+
get id() {
|
|
1779
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
1780
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
1781
|
+
return result;
|
|
1782
|
+
},
|
|
1783
|
+
get params() {
|
|
1784
|
+
const result = convertNodeList$1(buffer[position + 5], buffer);
|
|
1785
|
+
Object.defineProperty(node, 'params', { value: result });
|
|
1786
|
+
return result;
|
|
1787
|
+
},
|
|
1788
|
+
get body() {
|
|
1789
|
+
const result = convertNode$1(buffer[position + 6], buffer);
|
|
1790
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1791
|
+
return result;
|
|
1792
|
+
},
|
|
1488
1793
|
expression: false
|
|
1489
1794
|
};
|
|
1795
|
+
return node;
|
|
1490
1796
|
},
|
|
1491
1797
|
function functionExpression(position, buffer) {
|
|
1492
1798
|
const flags = buffer[position + 2];
|
|
1493
1799
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1494
1800
|
const idPosition = buffer[position + 4];
|
|
1495
|
-
|
|
1801
|
+
const node = {
|
|
1496
1802
|
type: 'FunctionExpression',
|
|
1497
1803
|
start: buffer[position],
|
|
1498
1804
|
end: buffer[position + 1],
|
|
1499
1805
|
async: (flags & 1) === 1,
|
|
1500
1806
|
generator: (flags & 2) === 2,
|
|
1501
|
-
...(annotations.length > 0 ? {
|
|
1502
|
-
id
|
|
1503
|
-
|
|
1504
|
-
|
|
1807
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1808
|
+
get id() {
|
|
1809
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
1810
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
1811
|
+
return result;
|
|
1812
|
+
},
|
|
1813
|
+
get params() {
|
|
1814
|
+
const result = convertNodeList$1(buffer[position + 5], buffer);
|
|
1815
|
+
Object.defineProperty(node, 'params', { value: result });
|
|
1816
|
+
return result;
|
|
1817
|
+
},
|
|
1818
|
+
get body() {
|
|
1819
|
+
const result = convertNode$1(buffer[position + 6], buffer);
|
|
1820
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1821
|
+
return result;
|
|
1822
|
+
},
|
|
1505
1823
|
expression: false
|
|
1506
1824
|
};
|
|
1825
|
+
return node;
|
|
1507
1826
|
},
|
|
1508
1827
|
function identifier(position, buffer) {
|
|
1509
|
-
|
|
1828
|
+
const node = {
|
|
1510
1829
|
type: 'Identifier',
|
|
1511
1830
|
start: buffer[position],
|
|
1512
1831
|
end: buffer[position + 1],
|
|
1513
|
-
name
|
|
1832
|
+
get name() {
|
|
1833
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1834
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
1835
|
+
return result;
|
|
1836
|
+
}
|
|
1514
1837
|
};
|
|
1838
|
+
return node;
|
|
1515
1839
|
},
|
|
1516
1840
|
function ifStatement(position, buffer) {
|
|
1517
1841
|
const alternatePosition = buffer[position + 4];
|
|
1518
|
-
|
|
1842
|
+
const node = {
|
|
1519
1843
|
type: 'IfStatement',
|
|
1520
1844
|
start: buffer[position],
|
|
1521
1845
|
end: buffer[position + 1],
|
|
1522
|
-
test
|
|
1523
|
-
|
|
1524
|
-
|
|
1846
|
+
get test() {
|
|
1847
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1848
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1849
|
+
return result;
|
|
1850
|
+
},
|
|
1851
|
+
get consequent() {
|
|
1852
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1853
|
+
Object.defineProperty(node, 'consequent', { value: result });
|
|
1854
|
+
return result;
|
|
1855
|
+
},
|
|
1856
|
+
get alternate() {
|
|
1857
|
+
const result = alternatePosition === 0 ? null : convertNode$1(alternatePosition, buffer);
|
|
1858
|
+
Object.defineProperty(node, 'alternate', { value: result });
|
|
1859
|
+
return result;
|
|
1860
|
+
}
|
|
1525
1861
|
};
|
|
1862
|
+
return node;
|
|
1526
1863
|
},
|
|
1527
1864
|
function importAttribute(position, buffer) {
|
|
1528
|
-
|
|
1865
|
+
const node = {
|
|
1529
1866
|
type: 'ImportAttribute',
|
|
1530
1867
|
start: buffer[position],
|
|
1531
1868
|
end: buffer[position + 1],
|
|
1532
|
-
key
|
|
1533
|
-
|
|
1869
|
+
get key() {
|
|
1870
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1871
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
1872
|
+
return result;
|
|
1873
|
+
},
|
|
1874
|
+
get value() {
|
|
1875
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1876
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
1877
|
+
return result;
|
|
1878
|
+
}
|
|
1534
1879
|
};
|
|
1880
|
+
return node;
|
|
1535
1881
|
},
|
|
1536
1882
|
function importDeclaration(position, buffer) {
|
|
1537
|
-
const
|
|
1538
|
-
|
|
1883
|
+
const phasePosition = buffer[position + 5];
|
|
1884
|
+
const node = {
|
|
1539
1885
|
type: 'ImportDeclaration',
|
|
1540
1886
|
start: buffer[position],
|
|
1541
1887
|
end: buffer[position + 1],
|
|
1542
|
-
specifiers
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1888
|
+
get specifiers() {
|
|
1889
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1890
|
+
Object.defineProperty(node, 'specifiers', { value: result });
|
|
1891
|
+
return result;
|
|
1892
|
+
},
|
|
1893
|
+
get source() {
|
|
1894
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1895
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
1896
|
+
return result;
|
|
1897
|
+
},
|
|
1898
|
+
get attributes() {
|
|
1899
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1900
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
1901
|
+
return result;
|
|
1902
|
+
},
|
|
1903
|
+
get phase() {
|
|
1904
|
+
const result = phasePosition === 0
|
|
1905
|
+
? undefined
|
|
1906
|
+
: FIXED_STRINGS[buffer[position + 5]];
|
|
1907
|
+
Object.defineProperty(node, 'phase', { value: result });
|
|
1908
|
+
return result;
|
|
1909
|
+
}
|
|
1546
1910
|
};
|
|
1911
|
+
return node;
|
|
1547
1912
|
},
|
|
1548
1913
|
function importDefaultSpecifier(position, buffer) {
|
|
1549
|
-
|
|
1914
|
+
const node = {
|
|
1550
1915
|
type: 'ImportDefaultSpecifier',
|
|
1551
1916
|
start: buffer[position],
|
|
1552
1917
|
end: buffer[position + 1],
|
|
1553
|
-
local
|
|
1918
|
+
get local() {
|
|
1919
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1920
|
+
Object.defineProperty(node, 'local', { value: result });
|
|
1921
|
+
return result;
|
|
1922
|
+
}
|
|
1554
1923
|
};
|
|
1924
|
+
return node;
|
|
1555
1925
|
},
|
|
1556
1926
|
function importExpression(position, buffer) {
|
|
1557
1927
|
const optionsPosition = buffer[position + 3];
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1928
|
+
const phasePosition = buffer[position + 4];
|
|
1929
|
+
const node = {
|
|
1560
1930
|
type: 'ImportExpression',
|
|
1561
1931
|
start: buffer[position],
|
|
1562
1932
|
end: buffer[position + 1],
|
|
1563
|
-
source
|
|
1564
|
-
|
|
1565
|
-
|
|
1933
|
+
get source() {
|
|
1934
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1935
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
1936
|
+
return result;
|
|
1937
|
+
},
|
|
1938
|
+
get options() {
|
|
1939
|
+
const result = optionsPosition === 0 ? null : convertNode$1(optionsPosition, buffer);
|
|
1940
|
+
Object.defineProperty(node, 'options', { value: result });
|
|
1941
|
+
return result;
|
|
1942
|
+
},
|
|
1943
|
+
get phase() {
|
|
1944
|
+
const result = phasePosition === 0
|
|
1945
|
+
? undefined
|
|
1946
|
+
: FIXED_STRINGS[buffer[position + 4]];
|
|
1947
|
+
Object.defineProperty(node, 'phase', { value: result });
|
|
1948
|
+
return result;
|
|
1949
|
+
}
|
|
1566
1950
|
};
|
|
1951
|
+
return node;
|
|
1567
1952
|
},
|
|
1568
1953
|
function importNamespaceSpecifier(position, buffer) {
|
|
1569
|
-
|
|
1954
|
+
const node = {
|
|
1570
1955
|
type: 'ImportNamespaceSpecifier',
|
|
1571
1956
|
start: buffer[position],
|
|
1572
1957
|
end: buffer[position + 1],
|
|
1573
|
-
local
|
|
1958
|
+
get local() {
|
|
1959
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1960
|
+
Object.defineProperty(node, 'local', { value: result });
|
|
1961
|
+
return result;
|
|
1962
|
+
}
|
|
1574
1963
|
};
|
|
1964
|
+
return node;
|
|
1575
1965
|
},
|
|
1576
1966
|
function importSpecifier(position, buffer) {
|
|
1577
1967
|
const importedPosition = buffer[position + 2];
|
|
1578
|
-
const local = convertNode(buffer[position + 3], buffer);
|
|
1579
|
-
|
|
1968
|
+
const local = convertNode$1(buffer[position + 3], buffer);
|
|
1969
|
+
const node = {
|
|
1580
1970
|
type: 'ImportSpecifier',
|
|
1581
1971
|
start: buffer[position],
|
|
1582
1972
|
end: buffer[position + 1],
|
|
1583
|
-
imported
|
|
1973
|
+
get imported() {
|
|
1974
|
+
const result = importedPosition === 0 ? { ...local } : convertNode$1(importedPosition, buffer);
|
|
1975
|
+
Object.defineProperty(node, 'imported', { value: result });
|
|
1976
|
+
return result;
|
|
1977
|
+
},
|
|
1584
1978
|
local
|
|
1585
1979
|
};
|
|
1980
|
+
return node;
|
|
1586
1981
|
},
|
|
1587
1982
|
function jsxAttribute(position, buffer) {
|
|
1588
1983
|
const valuePosition = buffer[position + 3];
|
|
1589
|
-
|
|
1984
|
+
const node = {
|
|
1590
1985
|
type: 'JSXAttribute',
|
|
1591
1986
|
start: buffer[position],
|
|
1592
1987
|
end: buffer[position + 1],
|
|
1593
|
-
name
|
|
1594
|
-
|
|
1988
|
+
get name() {
|
|
1989
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1990
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
1991
|
+
return result;
|
|
1992
|
+
},
|
|
1993
|
+
get value() {
|
|
1994
|
+
const result = valuePosition === 0 ? null : convertNode$1(valuePosition, buffer);
|
|
1995
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
1996
|
+
return result;
|
|
1997
|
+
}
|
|
1595
1998
|
};
|
|
1999
|
+
return node;
|
|
1596
2000
|
},
|
|
1597
2001
|
function jsxClosingElement(position, buffer) {
|
|
1598
|
-
|
|
2002
|
+
const node = {
|
|
1599
2003
|
type: 'JSXClosingElement',
|
|
1600
2004
|
start: buffer[position],
|
|
1601
2005
|
end: buffer[position + 1],
|
|
1602
|
-
name
|
|
2006
|
+
get name() {
|
|
2007
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2008
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2009
|
+
return result;
|
|
2010
|
+
}
|
|
1603
2011
|
};
|
|
2012
|
+
return node;
|
|
1604
2013
|
},
|
|
1605
2014
|
function jsxClosingFragment(position, buffer) {
|
|
1606
|
-
|
|
2015
|
+
const node = {
|
|
1607
2016
|
type: 'JSXClosingFragment',
|
|
1608
2017
|
start: buffer[position],
|
|
1609
2018
|
end: buffer[position + 1]
|
|
1610
2019
|
};
|
|
2020
|
+
return node;
|
|
1611
2021
|
},
|
|
1612
2022
|
function jsxElement(position, buffer) {
|
|
1613
2023
|
const closingElementPosition = buffer[position + 4];
|
|
1614
|
-
|
|
2024
|
+
const node = {
|
|
1615
2025
|
type: 'JSXElement',
|
|
1616
2026
|
start: buffer[position],
|
|
1617
2027
|
end: buffer[position + 1],
|
|
1618
|
-
openingElement
|
|
1619
|
-
|
|
1620
|
-
|
|
2028
|
+
get openingElement() {
|
|
2029
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2030
|
+
Object.defineProperty(node, 'openingElement', { value: result });
|
|
2031
|
+
return result;
|
|
2032
|
+
},
|
|
2033
|
+
get children() {
|
|
2034
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2035
|
+
Object.defineProperty(node, 'children', { value: result });
|
|
2036
|
+
return result;
|
|
2037
|
+
},
|
|
2038
|
+
get closingElement() {
|
|
2039
|
+
const result = closingElementPosition === 0 ? null : convertNode$1(closingElementPosition, buffer);
|
|
2040
|
+
Object.defineProperty(node, 'closingElement', { value: result });
|
|
2041
|
+
return result;
|
|
2042
|
+
}
|
|
1621
2043
|
};
|
|
2044
|
+
return node;
|
|
1622
2045
|
},
|
|
1623
2046
|
function jsxEmptyExpression(position, buffer) {
|
|
1624
|
-
|
|
2047
|
+
const node = {
|
|
1625
2048
|
type: 'JSXEmptyExpression',
|
|
1626
2049
|
start: buffer[position],
|
|
1627
2050
|
end: buffer[position + 1]
|
|
1628
2051
|
};
|
|
2052
|
+
return node;
|
|
1629
2053
|
},
|
|
1630
2054
|
function jsxExpressionContainer(position, buffer) {
|
|
1631
|
-
|
|
2055
|
+
const node = {
|
|
1632
2056
|
type: 'JSXExpressionContainer',
|
|
1633
2057
|
start: buffer[position],
|
|
1634
2058
|
end: buffer[position + 1],
|
|
1635
|
-
expression
|
|
2059
|
+
get expression() {
|
|
2060
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2061
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
2062
|
+
return result;
|
|
2063
|
+
}
|
|
1636
2064
|
};
|
|
2065
|
+
return node;
|
|
1637
2066
|
},
|
|
1638
2067
|
function jsxFragment(position, buffer) {
|
|
1639
|
-
|
|
2068
|
+
const node = {
|
|
1640
2069
|
type: 'JSXFragment',
|
|
1641
2070
|
start: buffer[position],
|
|
1642
2071
|
end: buffer[position + 1],
|
|
1643
|
-
openingFragment
|
|
1644
|
-
|
|
1645
|
-
|
|
2072
|
+
get openingFragment() {
|
|
2073
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2074
|
+
Object.defineProperty(node, 'openingFragment', { value: result });
|
|
2075
|
+
return result;
|
|
2076
|
+
},
|
|
2077
|
+
get children() {
|
|
2078
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2079
|
+
Object.defineProperty(node, 'children', { value: result });
|
|
2080
|
+
return result;
|
|
2081
|
+
},
|
|
2082
|
+
get closingFragment() {
|
|
2083
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2084
|
+
Object.defineProperty(node, 'closingFragment', { value: result });
|
|
2085
|
+
return result;
|
|
2086
|
+
}
|
|
1646
2087
|
};
|
|
2088
|
+
return node;
|
|
1647
2089
|
},
|
|
1648
2090
|
function jsxIdentifier(position, buffer) {
|
|
1649
|
-
|
|
2091
|
+
const node = {
|
|
1650
2092
|
type: 'JSXIdentifier',
|
|
1651
2093
|
start: buffer[position],
|
|
1652
2094
|
end: buffer[position + 1],
|
|
1653
|
-
name
|
|
2095
|
+
get name() {
|
|
2096
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2097
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2098
|
+
return result;
|
|
2099
|
+
}
|
|
1654
2100
|
};
|
|
2101
|
+
return node;
|
|
1655
2102
|
},
|
|
1656
2103
|
function jsxMemberExpression(position, buffer) {
|
|
1657
|
-
|
|
2104
|
+
const node = {
|
|
1658
2105
|
type: 'JSXMemberExpression',
|
|
1659
2106
|
start: buffer[position],
|
|
1660
2107
|
end: buffer[position + 1],
|
|
1661
|
-
object
|
|
1662
|
-
|
|
2108
|
+
get object() {
|
|
2109
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2110
|
+
Object.defineProperty(node, 'object', { value: result });
|
|
2111
|
+
return result;
|
|
2112
|
+
},
|
|
2113
|
+
get property() {
|
|
2114
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2115
|
+
Object.defineProperty(node, 'property', { value: result });
|
|
2116
|
+
return result;
|
|
2117
|
+
}
|
|
2118
|
+
};
|
|
2119
|
+
return node;
|
|
2120
|
+
},
|
|
2121
|
+
function jsxNamespacedName(position, buffer) {
|
|
2122
|
+
const node = {
|
|
2123
|
+
type: 'JSXNamespacedName',
|
|
2124
|
+
start: buffer[position],
|
|
2125
|
+
end: buffer[position + 1],
|
|
2126
|
+
get namespace() {
|
|
2127
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2128
|
+
Object.defineProperty(node, 'namespace', { value: result });
|
|
2129
|
+
return result;
|
|
2130
|
+
},
|
|
2131
|
+
get name() {
|
|
2132
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2133
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2134
|
+
return result;
|
|
2135
|
+
}
|
|
2136
|
+
};
|
|
2137
|
+
return node;
|
|
2138
|
+
},
|
|
2139
|
+
function jsxOpeningElement(position, buffer) {
|
|
2140
|
+
const flags = buffer[position + 2];
|
|
2141
|
+
const node = {
|
|
2142
|
+
type: 'JSXOpeningElement',
|
|
2143
|
+
start: buffer[position],
|
|
2144
|
+
end: buffer[position + 1],
|
|
2145
|
+
selfClosing: (flags & 1) === 1,
|
|
2146
|
+
get name() {
|
|
2147
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2148
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2149
|
+
return result;
|
|
2150
|
+
},
|
|
2151
|
+
get attributes() {
|
|
2152
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
2153
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
2154
|
+
return result;
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
return node;
|
|
2158
|
+
},
|
|
2159
|
+
function jsxOpeningFragment(position, buffer) {
|
|
2160
|
+
const node = {
|
|
2161
|
+
type: 'JSXOpeningFragment',
|
|
2162
|
+
start: buffer[position],
|
|
2163
|
+
end: buffer[position + 1],
|
|
2164
|
+
attributes: [],
|
|
2165
|
+
selfClosing: false
|
|
2166
|
+
};
|
|
2167
|
+
return node;
|
|
2168
|
+
},
|
|
2169
|
+
function jsxSpreadAttribute(position, buffer) {
|
|
2170
|
+
const node = {
|
|
2171
|
+
type: 'JSXSpreadAttribute',
|
|
2172
|
+
start: buffer[position],
|
|
2173
|
+
end: buffer[position + 1],
|
|
2174
|
+
get argument() {
|
|
2175
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2176
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2177
|
+
return result;
|
|
2178
|
+
}
|
|
2179
|
+
};
|
|
2180
|
+
return node;
|
|
2181
|
+
},
|
|
2182
|
+
function jsxSpreadChild(position, buffer) {
|
|
2183
|
+
const node = {
|
|
2184
|
+
type: 'JSXSpreadChild',
|
|
2185
|
+
start: buffer[position],
|
|
2186
|
+
end: buffer[position + 1],
|
|
2187
|
+
get expression() {
|
|
2188
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2189
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
2190
|
+
return result;
|
|
2191
|
+
}
|
|
2192
|
+
};
|
|
2193
|
+
return node;
|
|
2194
|
+
},
|
|
2195
|
+
function jsxText(position, buffer) {
|
|
2196
|
+
const node = {
|
|
2197
|
+
type: 'JSXText',
|
|
2198
|
+
start: buffer[position],
|
|
2199
|
+
end: buffer[position + 1],
|
|
2200
|
+
get value() {
|
|
2201
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2202
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2203
|
+
return result;
|
|
2204
|
+
},
|
|
2205
|
+
get raw() {
|
|
2206
|
+
const result = buffer.convertString(buffer[position + 3]);
|
|
2207
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2208
|
+
return result;
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2211
|
+
return node;
|
|
2212
|
+
},
|
|
2213
|
+
function labeledStatement(position, buffer) {
|
|
2214
|
+
const node = {
|
|
2215
|
+
type: 'LabeledStatement',
|
|
2216
|
+
start: buffer[position],
|
|
2217
|
+
end: buffer[position + 1],
|
|
2218
|
+
get label() {
|
|
2219
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2220
|
+
Object.defineProperty(node, 'label', { value: result });
|
|
2221
|
+
return result;
|
|
2222
|
+
},
|
|
2223
|
+
get body() {
|
|
2224
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2225
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2226
|
+
return result;
|
|
2227
|
+
}
|
|
2228
|
+
};
|
|
2229
|
+
return node;
|
|
2230
|
+
},
|
|
2231
|
+
function literalBigInt(position, buffer) {
|
|
2232
|
+
const bigint = buffer.convertString(buffer[position + 2]);
|
|
2233
|
+
const node = {
|
|
2234
|
+
type: 'Literal',
|
|
2235
|
+
start: buffer[position],
|
|
2236
|
+
end: buffer[position + 1],
|
|
2237
|
+
bigint,
|
|
2238
|
+
get raw() {
|
|
2239
|
+
const result = buffer.convertString(buffer[position + 3]);
|
|
2240
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2241
|
+
return result;
|
|
2242
|
+
},
|
|
2243
|
+
value: BigInt(bigint)
|
|
2244
|
+
};
|
|
2245
|
+
return node;
|
|
2246
|
+
},
|
|
2247
|
+
function literalBoolean(position, buffer) {
|
|
2248
|
+
const flags = buffer[position + 2];
|
|
2249
|
+
const value = (flags & 1) === 1;
|
|
2250
|
+
const node = {
|
|
2251
|
+
type: 'Literal',
|
|
2252
|
+
start: buffer[position],
|
|
2253
|
+
end: buffer[position + 1],
|
|
2254
|
+
value,
|
|
2255
|
+
raw: value ? 'true' : 'false'
|
|
2256
|
+
};
|
|
2257
|
+
return node;
|
|
2258
|
+
},
|
|
2259
|
+
function literalNull(position, buffer) {
|
|
2260
|
+
const node = {
|
|
2261
|
+
type: 'Literal',
|
|
2262
|
+
start: buffer[position],
|
|
2263
|
+
end: buffer[position + 1],
|
|
2264
|
+
raw: 'null',
|
|
2265
|
+
value: null
|
|
2266
|
+
};
|
|
2267
|
+
return node;
|
|
2268
|
+
},
|
|
2269
|
+
function literalNumber(position, buffer) {
|
|
2270
|
+
const rawPosition = buffer[position + 2];
|
|
2271
|
+
const node = {
|
|
2272
|
+
type: 'Literal',
|
|
2273
|
+
start: buffer[position],
|
|
2274
|
+
end: buffer[position + 1],
|
|
2275
|
+
get raw() {
|
|
2276
|
+
const result = rawPosition === 0 ? undefined : buffer.convertString(rawPosition);
|
|
2277
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2278
|
+
return result;
|
|
2279
|
+
},
|
|
2280
|
+
get value() {
|
|
2281
|
+
const result = buffer.convertFloat64(position + 3);
|
|
2282
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2283
|
+
return result;
|
|
2284
|
+
}
|
|
2285
|
+
};
|
|
2286
|
+
return node;
|
|
2287
|
+
},
|
|
2288
|
+
function literalRegExp(position, buffer) {
|
|
2289
|
+
const flags = buffer.convertString(buffer[position + 2]);
|
|
2290
|
+
const pattern = buffer.convertString(buffer[position + 3]);
|
|
2291
|
+
const node = {
|
|
2292
|
+
type: 'Literal',
|
|
2293
|
+
start: buffer[position],
|
|
2294
|
+
end: buffer[position + 1],
|
|
2295
|
+
raw: `/${pattern}/${flags}`,
|
|
2296
|
+
regex: { flags, pattern },
|
|
2297
|
+
value: new RegExp(pattern, flags)
|
|
2298
|
+
};
|
|
2299
|
+
return node;
|
|
2300
|
+
},
|
|
2301
|
+
function literalString(position, buffer) {
|
|
2302
|
+
const rawPosition = buffer[position + 3];
|
|
2303
|
+
const node = {
|
|
2304
|
+
type: 'Literal',
|
|
2305
|
+
start: buffer[position],
|
|
2306
|
+
end: buffer[position + 1],
|
|
2307
|
+
get value() {
|
|
2308
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2309
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2310
|
+
return result;
|
|
2311
|
+
},
|
|
2312
|
+
get raw() {
|
|
2313
|
+
const result = rawPosition === 0 ? undefined : buffer.convertString(rawPosition);
|
|
2314
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2315
|
+
return result;
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
return node;
|
|
2319
|
+
},
|
|
2320
|
+
function logicalExpression(position, buffer) {
|
|
2321
|
+
const node = {
|
|
2322
|
+
type: 'LogicalExpression',
|
|
2323
|
+
start: buffer[position],
|
|
2324
|
+
end: buffer[position + 1],
|
|
2325
|
+
get operator() {
|
|
2326
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
2327
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
2328
|
+
return result;
|
|
2329
|
+
},
|
|
2330
|
+
get left() {
|
|
2331
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2332
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
2333
|
+
return result;
|
|
2334
|
+
},
|
|
2335
|
+
get right() {
|
|
2336
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2337
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
2338
|
+
return result;
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2341
|
+
return node;
|
|
2342
|
+
},
|
|
2343
|
+
function memberExpression(position, buffer) {
|
|
2344
|
+
const flags = buffer[position + 2];
|
|
2345
|
+
const node = {
|
|
2346
|
+
type: 'MemberExpression',
|
|
2347
|
+
start: buffer[position],
|
|
2348
|
+
end: buffer[position + 1],
|
|
2349
|
+
computed: (flags & 1) === 1,
|
|
2350
|
+
optional: (flags & 2) === 2,
|
|
2351
|
+
get object() {
|
|
2352
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2353
|
+
Object.defineProperty(node, 'object', { value: result });
|
|
2354
|
+
return result;
|
|
2355
|
+
},
|
|
2356
|
+
get property() {
|
|
2357
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2358
|
+
Object.defineProperty(node, 'property', { value: result });
|
|
2359
|
+
return result;
|
|
2360
|
+
}
|
|
2361
|
+
};
|
|
2362
|
+
return node;
|
|
2363
|
+
},
|
|
2364
|
+
function metaProperty(position, buffer) {
|
|
2365
|
+
const node = {
|
|
2366
|
+
type: 'MetaProperty',
|
|
2367
|
+
start: buffer[position],
|
|
2368
|
+
end: buffer[position + 1],
|
|
2369
|
+
get meta() {
|
|
2370
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2371
|
+
Object.defineProperty(node, 'meta', { value: result });
|
|
2372
|
+
return result;
|
|
2373
|
+
},
|
|
2374
|
+
get property() {
|
|
2375
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2376
|
+
Object.defineProperty(node, 'property', { value: result });
|
|
2377
|
+
return result;
|
|
2378
|
+
}
|
|
2379
|
+
};
|
|
2380
|
+
return node;
|
|
2381
|
+
},
|
|
2382
|
+
function methodDefinition(position, buffer) {
|
|
2383
|
+
const flags = buffer[position + 2];
|
|
2384
|
+
const node = {
|
|
2385
|
+
type: 'MethodDefinition',
|
|
2386
|
+
start: buffer[position],
|
|
2387
|
+
end: buffer[position + 1],
|
|
2388
|
+
static: (flags & 1) === 1,
|
|
2389
|
+
computed: (flags & 2) === 2,
|
|
2390
|
+
get decorators() {
|
|
2391
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2392
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
2393
|
+
return result;
|
|
2394
|
+
},
|
|
2395
|
+
get key() {
|
|
2396
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2397
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2398
|
+
return result;
|
|
2399
|
+
},
|
|
2400
|
+
get value() {
|
|
2401
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
2402
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2403
|
+
return result;
|
|
2404
|
+
},
|
|
2405
|
+
get kind() {
|
|
2406
|
+
const result = FIXED_STRINGS[buffer[position + 6]];
|
|
2407
|
+
Object.defineProperty(node, 'kind', { value: result });
|
|
2408
|
+
return result;
|
|
2409
|
+
}
|
|
2410
|
+
};
|
|
2411
|
+
return node;
|
|
2412
|
+
},
|
|
2413
|
+
function newExpression(position, buffer) {
|
|
2414
|
+
const annotations = convertAnnotations(buffer[position + 2], buffer);
|
|
2415
|
+
const node = {
|
|
2416
|
+
type: 'NewExpression',
|
|
2417
|
+
start: buffer[position],
|
|
2418
|
+
end: buffer[position + 1],
|
|
2419
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
2420
|
+
get callee() {
|
|
2421
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2422
|
+
Object.defineProperty(node, 'callee', { value: result });
|
|
2423
|
+
return result;
|
|
2424
|
+
},
|
|
2425
|
+
get arguments() {
|
|
2426
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
2427
|
+
Object.defineProperty(node, 'arguments', { value: result });
|
|
2428
|
+
return result;
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
return node;
|
|
2432
|
+
},
|
|
2433
|
+
function objectExpression(position, buffer) {
|
|
2434
|
+
const node = {
|
|
2435
|
+
type: 'ObjectExpression',
|
|
2436
|
+
start: buffer[position],
|
|
2437
|
+
end: buffer[position + 1],
|
|
2438
|
+
get properties() {
|
|
2439
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2440
|
+
Object.defineProperty(node, 'properties', { value: result });
|
|
2441
|
+
return result;
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2444
|
+
return node;
|
|
2445
|
+
},
|
|
2446
|
+
function objectPattern(position, buffer) {
|
|
2447
|
+
const node = {
|
|
2448
|
+
type: 'ObjectPattern',
|
|
2449
|
+
start: buffer[position],
|
|
2450
|
+
end: buffer[position + 1],
|
|
2451
|
+
get properties() {
|
|
2452
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2453
|
+
Object.defineProperty(node, 'properties', { value: result });
|
|
2454
|
+
return result;
|
|
2455
|
+
}
|
|
2456
|
+
};
|
|
2457
|
+
return node;
|
|
2458
|
+
},
|
|
2459
|
+
function privateIdentifier(position, buffer) {
|
|
2460
|
+
const node = {
|
|
2461
|
+
type: 'PrivateIdentifier',
|
|
2462
|
+
start: buffer[position],
|
|
2463
|
+
end: buffer[position + 1],
|
|
2464
|
+
get name() {
|
|
2465
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2466
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2467
|
+
return result;
|
|
2468
|
+
}
|
|
2469
|
+
};
|
|
2470
|
+
return node;
|
|
2471
|
+
},
|
|
2472
|
+
function program(position, buffer) {
|
|
2473
|
+
const invalidAnnotations = convertAnnotations(buffer[position + 3], buffer);
|
|
2474
|
+
const node = {
|
|
2475
|
+
type: 'Program',
|
|
2476
|
+
start: buffer[position],
|
|
2477
|
+
end: buffer[position + 1],
|
|
2478
|
+
get body() {
|
|
2479
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2480
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2481
|
+
return result;
|
|
2482
|
+
},
|
|
2483
|
+
...(invalidAnnotations.length > 0 ? { invalidAnnotations } : {}),
|
|
2484
|
+
sourceType: 'module'
|
|
2485
|
+
};
|
|
2486
|
+
return node;
|
|
2487
|
+
},
|
|
2488
|
+
function property(position, buffer) {
|
|
2489
|
+
const flags = buffer[position + 2];
|
|
2490
|
+
const keyPosition = buffer[position + 3];
|
|
2491
|
+
const value = convertNode$1(buffer[position + 4], buffer);
|
|
2492
|
+
const node = {
|
|
2493
|
+
type: 'Property',
|
|
2494
|
+
start: buffer[position],
|
|
2495
|
+
end: buffer[position + 1],
|
|
2496
|
+
method: (flags & 1) === 1,
|
|
2497
|
+
shorthand: (flags & 2) === 2,
|
|
2498
|
+
computed: (flags & 4) === 4,
|
|
2499
|
+
get key() {
|
|
2500
|
+
const result = keyPosition === 0 ? { ...value } : convertNode$1(keyPosition, buffer);
|
|
2501
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2502
|
+
return result;
|
|
2503
|
+
},
|
|
2504
|
+
value,
|
|
2505
|
+
get kind() {
|
|
2506
|
+
const result = FIXED_STRINGS[buffer[position + 5]];
|
|
2507
|
+
Object.defineProperty(node, 'kind', { value: result });
|
|
2508
|
+
return result;
|
|
2509
|
+
}
|
|
2510
|
+
};
|
|
2511
|
+
return node;
|
|
2512
|
+
},
|
|
2513
|
+
function propertyDefinition(position, buffer) {
|
|
2514
|
+
const flags = buffer[position + 2];
|
|
2515
|
+
const valuePosition = buffer[position + 5];
|
|
2516
|
+
const node = {
|
|
2517
|
+
type: 'PropertyDefinition',
|
|
2518
|
+
start: buffer[position],
|
|
2519
|
+
end: buffer[position + 1],
|
|
2520
|
+
static: (flags & 1) === 1,
|
|
2521
|
+
computed: (flags & 2) === 2,
|
|
2522
|
+
get decorators() {
|
|
2523
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2524
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
2525
|
+
return result;
|
|
2526
|
+
},
|
|
2527
|
+
get key() {
|
|
2528
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2529
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2530
|
+
return result;
|
|
2531
|
+
},
|
|
2532
|
+
get value() {
|
|
2533
|
+
const result = valuePosition === 0 ? null : convertNode$1(valuePosition, buffer);
|
|
2534
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2535
|
+
return result;
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
return node;
|
|
2539
|
+
},
|
|
2540
|
+
function restElement(position, buffer) {
|
|
2541
|
+
const node = {
|
|
2542
|
+
type: 'RestElement',
|
|
2543
|
+
start: buffer[position],
|
|
2544
|
+
end: buffer[position + 1],
|
|
2545
|
+
get argument() {
|
|
2546
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2547
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2548
|
+
return result;
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
return node;
|
|
2552
|
+
},
|
|
2553
|
+
function returnStatement(position, buffer) {
|
|
2554
|
+
const argumentPosition = buffer[position + 2];
|
|
2555
|
+
const node = {
|
|
2556
|
+
type: 'ReturnStatement',
|
|
2557
|
+
start: buffer[position],
|
|
2558
|
+
end: buffer[position + 1],
|
|
2559
|
+
get argument() {
|
|
2560
|
+
const result = argumentPosition === 0 ? null : convertNode$1(argumentPosition, buffer);
|
|
2561
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2562
|
+
return result;
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2565
|
+
return node;
|
|
2566
|
+
},
|
|
2567
|
+
function sequenceExpression(position, buffer) {
|
|
2568
|
+
const node = {
|
|
2569
|
+
type: 'SequenceExpression',
|
|
2570
|
+
start: buffer[position],
|
|
2571
|
+
end: buffer[position + 1],
|
|
2572
|
+
get expressions() {
|
|
2573
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2574
|
+
Object.defineProperty(node, 'expressions', { value: result });
|
|
2575
|
+
return result;
|
|
2576
|
+
}
|
|
2577
|
+
};
|
|
2578
|
+
return node;
|
|
2579
|
+
},
|
|
2580
|
+
function spreadElement(position, buffer) {
|
|
2581
|
+
const node = {
|
|
2582
|
+
type: 'SpreadElement',
|
|
2583
|
+
start: buffer[position],
|
|
2584
|
+
end: buffer[position + 1],
|
|
2585
|
+
get argument() {
|
|
2586
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2587
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2588
|
+
return result;
|
|
2589
|
+
}
|
|
2590
|
+
};
|
|
2591
|
+
return node;
|
|
2592
|
+
},
|
|
2593
|
+
function staticBlock(position, buffer) {
|
|
2594
|
+
const node = {
|
|
2595
|
+
type: 'StaticBlock',
|
|
2596
|
+
start: buffer[position],
|
|
2597
|
+
end: buffer[position + 1],
|
|
2598
|
+
get body() {
|
|
2599
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2600
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2601
|
+
return result;
|
|
2602
|
+
}
|
|
2603
|
+
};
|
|
2604
|
+
return node;
|
|
2605
|
+
},
|
|
2606
|
+
function superElement(position, buffer) {
|
|
2607
|
+
const node = {
|
|
2608
|
+
type: 'Super',
|
|
2609
|
+
start: buffer[position],
|
|
2610
|
+
end: buffer[position + 1]
|
|
2611
|
+
};
|
|
2612
|
+
return node;
|
|
2613
|
+
},
|
|
2614
|
+
function switchCase(position, buffer) {
|
|
2615
|
+
const testPosition = buffer[position + 2];
|
|
2616
|
+
const node = {
|
|
2617
|
+
type: 'SwitchCase',
|
|
2618
|
+
start: buffer[position],
|
|
2619
|
+
end: buffer[position + 1],
|
|
2620
|
+
get test() {
|
|
2621
|
+
const result = testPosition === 0 ? null : convertNode$1(testPosition, buffer);
|
|
2622
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
2623
|
+
return result;
|
|
2624
|
+
},
|
|
2625
|
+
get consequent() {
|
|
2626
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2627
|
+
Object.defineProperty(node, 'consequent', { value: result });
|
|
2628
|
+
return result;
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
return node;
|
|
2632
|
+
},
|
|
2633
|
+
function switchStatement(position, buffer) {
|
|
2634
|
+
const node = {
|
|
2635
|
+
type: 'SwitchStatement',
|
|
2636
|
+
start: buffer[position],
|
|
2637
|
+
end: buffer[position + 1],
|
|
2638
|
+
get discriminant() {
|
|
2639
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2640
|
+
Object.defineProperty(node, 'discriminant', { value: result });
|
|
2641
|
+
return result;
|
|
2642
|
+
},
|
|
2643
|
+
get cases() {
|
|
2644
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2645
|
+
Object.defineProperty(node, 'cases', { value: result });
|
|
2646
|
+
return result;
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
return node;
|
|
2650
|
+
},
|
|
2651
|
+
function taggedTemplateExpression(position, buffer) {
|
|
2652
|
+
const node = {
|
|
2653
|
+
type: 'TaggedTemplateExpression',
|
|
2654
|
+
start: buffer[position],
|
|
2655
|
+
end: buffer[position + 1],
|
|
2656
|
+
get tag() {
|
|
2657
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2658
|
+
Object.defineProperty(node, 'tag', { value: result });
|
|
2659
|
+
return result;
|
|
2660
|
+
},
|
|
2661
|
+
get quasi() {
|
|
2662
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2663
|
+
Object.defineProperty(node, 'quasi', { value: result });
|
|
2664
|
+
return result;
|
|
2665
|
+
}
|
|
2666
|
+
};
|
|
2667
|
+
return node;
|
|
2668
|
+
},
|
|
2669
|
+
function templateElement(position, buffer) {
|
|
2670
|
+
const flags = buffer[position + 2];
|
|
2671
|
+
const cookedPosition = buffer[position + 3];
|
|
2672
|
+
const cooked = cookedPosition === 0 ? undefined : buffer.convertString(cookedPosition);
|
|
2673
|
+
const raw = buffer.convertString(buffer[position + 4]);
|
|
2674
|
+
const node = {
|
|
2675
|
+
type: 'TemplateElement',
|
|
2676
|
+
start: buffer[position],
|
|
2677
|
+
end: buffer[position + 1],
|
|
2678
|
+
tail: (flags & 1) === 1,
|
|
2679
|
+
value: { cooked, raw }
|
|
2680
|
+
};
|
|
2681
|
+
return node;
|
|
2682
|
+
},
|
|
2683
|
+
function templateLiteral(position, buffer) {
|
|
2684
|
+
const node = {
|
|
2685
|
+
type: 'TemplateLiteral',
|
|
2686
|
+
start: buffer[position],
|
|
2687
|
+
end: buffer[position + 1],
|
|
2688
|
+
get quasis() {
|
|
2689
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2690
|
+
Object.defineProperty(node, 'quasis', { value: result });
|
|
2691
|
+
return result;
|
|
2692
|
+
},
|
|
2693
|
+
get expressions() {
|
|
2694
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2695
|
+
Object.defineProperty(node, 'expressions', { value: result });
|
|
2696
|
+
return result;
|
|
2697
|
+
}
|
|
2698
|
+
};
|
|
2699
|
+
return node;
|
|
2700
|
+
},
|
|
2701
|
+
function thisExpression(position, buffer) {
|
|
2702
|
+
const node = {
|
|
2703
|
+
type: 'ThisExpression',
|
|
2704
|
+
start: buffer[position],
|
|
2705
|
+
end: buffer[position + 1]
|
|
2706
|
+
};
|
|
2707
|
+
return node;
|
|
2708
|
+
},
|
|
2709
|
+
function throwStatement(position, buffer) {
|
|
2710
|
+
const node = {
|
|
2711
|
+
type: 'ThrowStatement',
|
|
2712
|
+
start: buffer[position],
|
|
2713
|
+
end: buffer[position + 1],
|
|
2714
|
+
get argument() {
|
|
2715
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2716
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2717
|
+
return result;
|
|
2718
|
+
}
|
|
2719
|
+
};
|
|
2720
|
+
return node;
|
|
2721
|
+
},
|
|
2722
|
+
function tryStatement(position, buffer) {
|
|
2723
|
+
const handlerPosition = buffer[position + 3];
|
|
2724
|
+
const finalizerPosition = buffer[position + 4];
|
|
2725
|
+
const node = {
|
|
2726
|
+
type: 'TryStatement',
|
|
2727
|
+
start: buffer[position],
|
|
2728
|
+
end: buffer[position + 1],
|
|
2729
|
+
get block() {
|
|
2730
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2731
|
+
Object.defineProperty(node, 'block', { value: result });
|
|
2732
|
+
return result;
|
|
2733
|
+
},
|
|
2734
|
+
get handler() {
|
|
2735
|
+
const result = handlerPosition === 0 ? null : convertNode$1(handlerPosition, buffer);
|
|
2736
|
+
Object.defineProperty(node, 'handler', { value: result });
|
|
2737
|
+
return result;
|
|
2738
|
+
},
|
|
2739
|
+
get finalizer() {
|
|
2740
|
+
const result = finalizerPosition === 0 ? null : convertNode$1(finalizerPosition, buffer);
|
|
2741
|
+
Object.defineProperty(node, 'finalizer', { value: result });
|
|
2742
|
+
return result;
|
|
2743
|
+
}
|
|
2744
|
+
};
|
|
2745
|
+
return node;
|
|
2746
|
+
},
|
|
2747
|
+
function unaryExpression(position, buffer) {
|
|
2748
|
+
const node = {
|
|
2749
|
+
type: 'UnaryExpression',
|
|
2750
|
+
start: buffer[position],
|
|
2751
|
+
end: buffer[position + 1],
|
|
2752
|
+
get operator() {
|
|
2753
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
2754
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
2755
|
+
return result;
|
|
2756
|
+
},
|
|
2757
|
+
get argument() {
|
|
2758
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2759
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2760
|
+
return result;
|
|
2761
|
+
},
|
|
2762
|
+
prefix: true
|
|
2763
|
+
};
|
|
2764
|
+
return node;
|
|
2765
|
+
},
|
|
2766
|
+
function updateExpression(position, buffer) {
|
|
2767
|
+
const flags = buffer[position + 2];
|
|
2768
|
+
const node = {
|
|
2769
|
+
type: 'UpdateExpression',
|
|
2770
|
+
start: buffer[position],
|
|
2771
|
+
end: buffer[position + 1],
|
|
2772
|
+
prefix: (flags & 1) === 1,
|
|
2773
|
+
get operator() {
|
|
2774
|
+
const result = FIXED_STRINGS[buffer[position + 3]];
|
|
2775
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
2776
|
+
return result;
|
|
2777
|
+
},
|
|
2778
|
+
get argument() {
|
|
2779
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2780
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2781
|
+
return result;
|
|
2782
|
+
}
|
|
2783
|
+
};
|
|
2784
|
+
return node;
|
|
2785
|
+
},
|
|
2786
|
+
function variableDeclaration(position, buffer) {
|
|
2787
|
+
const node = {
|
|
2788
|
+
type: 'VariableDeclaration',
|
|
2789
|
+
start: buffer[position],
|
|
2790
|
+
end: buffer[position + 1],
|
|
2791
|
+
get kind() {
|
|
2792
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
2793
|
+
Object.defineProperty(node, 'kind', { value: result });
|
|
2794
|
+
return result;
|
|
2795
|
+
},
|
|
2796
|
+
get declarations() {
|
|
2797
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2798
|
+
Object.defineProperty(node, 'declarations', { value: result });
|
|
2799
|
+
return result;
|
|
2800
|
+
}
|
|
2801
|
+
};
|
|
2802
|
+
return node;
|
|
2803
|
+
},
|
|
2804
|
+
function variableDeclarator(position, buffer) {
|
|
2805
|
+
const initPosition = buffer[position + 3];
|
|
2806
|
+
const node = {
|
|
2807
|
+
type: 'VariableDeclarator',
|
|
2808
|
+
start: buffer[position],
|
|
2809
|
+
end: buffer[position + 1],
|
|
2810
|
+
get id() {
|
|
2811
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2812
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
2813
|
+
return result;
|
|
2814
|
+
},
|
|
2815
|
+
get init() {
|
|
2816
|
+
const result = initPosition === 0 ? null : convertNode$1(initPosition, buffer);
|
|
2817
|
+
Object.defineProperty(node, 'init', { value: result });
|
|
2818
|
+
return result;
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
return node;
|
|
2822
|
+
},
|
|
2823
|
+
function whileStatement(position, buffer) {
|
|
2824
|
+
const node = {
|
|
2825
|
+
type: 'WhileStatement',
|
|
2826
|
+
start: buffer[position],
|
|
2827
|
+
end: buffer[position + 1],
|
|
2828
|
+
get test() {
|
|
2829
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2830
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
2831
|
+
return result;
|
|
2832
|
+
},
|
|
2833
|
+
get body() {
|
|
2834
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2835
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2836
|
+
return result;
|
|
2837
|
+
}
|
|
2838
|
+
};
|
|
2839
|
+
return node;
|
|
2840
|
+
},
|
|
2841
|
+
function yieldExpression(position, buffer) {
|
|
2842
|
+
const flags = buffer[position + 2];
|
|
2843
|
+
const argumentPosition = buffer[position + 3];
|
|
2844
|
+
const node = {
|
|
2845
|
+
type: 'YieldExpression',
|
|
2846
|
+
start: buffer[position],
|
|
2847
|
+
end: buffer[position + 1],
|
|
2848
|
+
delegate: (flags & 1) === 1,
|
|
2849
|
+
get argument() {
|
|
2850
|
+
const result = argumentPosition === 0 ? null : convertNode$1(argumentPosition, buffer);
|
|
2851
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2852
|
+
return result;
|
|
2853
|
+
}
|
|
2854
|
+
};
|
|
2855
|
+
return node;
|
|
2856
|
+
}
|
|
2857
|
+
];
|
|
2858
|
+
function convertNode$1(position, buffer) {
|
|
2859
|
+
const nodeType = buffer[position];
|
|
2860
|
+
const converter = nodeConverters$1[nodeType];
|
|
2861
|
+
/* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
|
|
2862
|
+
if (!converter) {
|
|
2863
|
+
console.trace();
|
|
2864
|
+
throw new Error(`Unknown node type: ${nodeType}`);
|
|
2865
|
+
}
|
|
2866
|
+
return converter(position + 1, buffer);
|
|
2867
|
+
}
|
|
2868
|
+
function convertNodeList$1(position, buffer) {
|
|
2869
|
+
if (position === 0)
|
|
2870
|
+
return EMPTY_ARRAY;
|
|
2871
|
+
const length = buffer[position++];
|
|
2872
|
+
const list = new Array(length);
|
|
2873
|
+
for (let index = 0; index < length; index++) {
|
|
2874
|
+
const nodePosition = buffer[position++];
|
|
2875
|
+
list[index] = nodePosition ? convertNode$1(nodePosition, buffer) : null;
|
|
2876
|
+
}
|
|
2877
|
+
return list;
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
// Buffers hold 32-bit words in host byte order. For words that represent
|
|
2881
|
+
// strings, the four string bytes are packed LSB-first into the word, which on
|
|
2882
|
+
// little-endian hosts leaves the raw encoded string bytes in memory while
|
|
2883
|
+
// big-endian hosts need the byte order of each word reversed.
|
|
2884
|
+
const isBigEndianHost = new Uint8Array(new Uint32Array([1]).buffer)[0] === 0;
|
|
2885
|
+
const scratchFloat64 = new DataView(new ArrayBuffer(8));
|
|
2886
|
+
let scratchStringBytes = new Uint8Array(0);
|
|
2887
|
+
const writeFloat64 = function (value, wordPosition) {
|
|
2888
|
+
scratchFloat64.setFloat64(0, value, true);
|
|
2889
|
+
this[wordPosition] = scratchFloat64.getUint32(0, true);
|
|
2890
|
+
this[wordPosition + 1] = scratchFloat64.getUint32(4, true);
|
|
2891
|
+
};
|
|
2892
|
+
function writeStringWordsBigEndian(buffer, byteBuffer, bytePosition, byteLength) {
|
|
2893
|
+
const firstWordPosition = bytePosition >> 2;
|
|
2894
|
+
const wordCount = (byteLength + 3) >> 2;
|
|
2895
|
+
for (let index = 0; index < wordCount; index++) {
|
|
2896
|
+
const offset = bytePosition + (index << 2);
|
|
2897
|
+
buffer[firstWordPosition + index] =
|
|
2898
|
+
byteBuffer[offset] |
|
|
2899
|
+
(byteBuffer[offset + 1] << 8) |
|
|
2900
|
+
(byteBuffer[offset + 2] << 16) |
|
|
2901
|
+
(byteBuffer[offset + 3] << 24);
|
|
2902
|
+
}
|
|
2903
|
+
}
|
|
2904
|
+
const expandPackedString = (array, position, length) => {
|
|
2905
|
+
const paddedByteLength = ((length + 3) >> 2) << 2;
|
|
2906
|
+
if (scratchStringBytes.length < paddedByteLength) {
|
|
2907
|
+
scratchStringBytes = new Uint8Array(paddedByteLength);
|
|
2908
|
+
}
|
|
2909
|
+
const firstStringWord = position + 1;
|
|
2910
|
+
for (let index = 0; index < paddedByteLength >> 2; index++) {
|
|
2911
|
+
const word = array[firstStringWord + index];
|
|
2912
|
+
scratchStringBytes[index << 2] = word & 0xff;
|
|
2913
|
+
scratchStringBytes[(index << 2) + 1] = (word >>> 8) & 0xff;
|
|
2914
|
+
scratchStringBytes[(index << 2) + 2] = (word >>> 16) & 0xff;
|
|
2915
|
+
scratchStringBytes[(index << 2) + 3] = (word >>> 24) & 0xff;
|
|
2916
|
+
}
|
|
2917
|
+
return scratchStringBytes.subarray(0, length);
|
|
2918
|
+
};
|
|
2919
|
+
const decodePackedString = (array, position, length) => {
|
|
2920
|
+
const bytes = expandPackedString(array, position, length);
|
|
2921
|
+
return typeof Buffer !== 'undefined'
|
|
2922
|
+
? Buffer.from(bytes.buffer, bytes.byteOffset, bytes.length).toString('utf8')
|
|
2923
|
+
: new TextDecoder().decode(bytes);
|
|
2924
|
+
};
|
|
2925
|
+
function getAstBuffer(byteBuffer) {
|
|
2926
|
+
// Create an aligned copy for misaligned views, e.g. buffers restored by
|
|
2927
|
+
// v8.deserialize, as the Uint32Array below requires a 4-byte aligned offset
|
|
2928
|
+
const alignedByteBuffer = byteBuffer.byteOffset & 3 ? new Uint8Array(byteBuffer) : byteBuffer;
|
|
2929
|
+
const array = new Uint32Array(alignedByteBuffer.buffer, alignedByteBuffer.byteOffset, alignedByteBuffer.byteLength >> 2);
|
|
2930
|
+
let convertString;
|
|
2931
|
+
if (isBigEndianHost) {
|
|
2932
|
+
convertString = position => decodePackedString(array, position, array[position]);
|
|
2933
|
+
}
|
|
2934
|
+
else if (typeof Buffer !== 'undefined' && byteBuffer instanceof Buffer) {
|
|
2935
|
+
convertString = position => {
|
|
2936
|
+
const length = array[position];
|
|
2937
|
+
const bytePosition = (position + 1) << 2;
|
|
2938
|
+
return byteBuffer.toString('utf8', bytePosition, bytePosition + length);
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
else {
|
|
2942
|
+
const textDecoder = new TextDecoder();
|
|
2943
|
+
convertString = position => {
|
|
2944
|
+
const length = array[position];
|
|
2945
|
+
const bytePosition = (position + 1) << 2;
|
|
2946
|
+
return textDecoder.decode(byteBuffer.subarray(bytePosition, bytePosition + length));
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
return Object.assign(array, {
|
|
2950
|
+
convertFloat64(position) {
|
|
2951
|
+
scratchFloat64.setUint32(0, this[position], true);
|
|
2952
|
+
scratchFloat64.setUint32(4, this[position + 1], true);
|
|
2953
|
+
return scratchFloat64.getFloat64(0, true);
|
|
2954
|
+
},
|
|
2955
|
+
convertString
|
|
2956
|
+
});
|
|
2957
|
+
}
|
|
2958
|
+
function createAstBufferUint8(uInt32Size) {
|
|
2959
|
+
const buffer = new Uint32Array(uInt32Size);
|
|
2960
|
+
const encoder = new TextEncoder();
|
|
2961
|
+
const byteBuffer = new Uint8Array(buffer.buffer);
|
|
2962
|
+
return Object.assign(buffer, {
|
|
2963
|
+
addStringToBuffer(text, referencePosition) {
|
|
2964
|
+
const insertPosition = buffer.position;
|
|
2965
|
+
buffer[referencePosition] = insertPosition;
|
|
2966
|
+
const encoded = encoder.encode(text);
|
|
2967
|
+
const encodedByteLength = encoded.length;
|
|
2968
|
+
// Round up to the next 4-byte boundary, add 1 for the length
|
|
2969
|
+
const reservedSize = 1 + ((encodedByteLength + 3) >> 2);
|
|
2970
|
+
const extendedBuffer = buffer.reserve(reservedSize);
|
|
2971
|
+
extendedBuffer[insertPosition] = encodedByteLength;
|
|
2972
|
+
const stringBytePosition = (insertPosition + 1) << 2;
|
|
2973
|
+
extendedBuffer.byteBuffer.set(encoded, stringBytePosition);
|
|
2974
|
+
if (isBigEndianHost) {
|
|
2975
|
+
writeStringWordsBigEndian(extendedBuffer, extendedBuffer.byteBuffer, stringBytePosition, encodedByteLength);
|
|
2976
|
+
}
|
|
2977
|
+
return extendedBuffer;
|
|
2978
|
+
},
|
|
2979
|
+
byteBuffer,
|
|
2980
|
+
position: 0,
|
|
2981
|
+
reserve(size) {
|
|
2982
|
+
const newPosition = buffer.position + size;
|
|
2983
|
+
if (newPosition <= buffer.length) {
|
|
2984
|
+
buffer.position = newPosition;
|
|
2985
|
+
return buffer;
|
|
2986
|
+
}
|
|
2987
|
+
const newBuffer = createAstBufferUint8(newPosition * 2);
|
|
2988
|
+
newBuffer.set(buffer);
|
|
2989
|
+
newBuffer.position = newPosition;
|
|
2990
|
+
return newBuffer;
|
|
2991
|
+
},
|
|
2992
|
+
toOutput() {
|
|
2993
|
+
const byteSize = buffer.position << 2;
|
|
2994
|
+
return byteBuffer.slice(0, byteSize);
|
|
2995
|
+
},
|
|
2996
|
+
writeFloat64
|
|
2997
|
+
});
|
|
2998
|
+
}
|
|
2999
|
+
function createAstBufferNode(uInt32Size) {
|
|
3000
|
+
const buffer = new Uint32Array(uInt32Size);
|
|
3001
|
+
const byteBuffer = Buffer.from(buffer.buffer);
|
|
3002
|
+
return Object.assign(buffer, {
|
|
3003
|
+
addStringToBuffer(text, referencePosition) {
|
|
3004
|
+
let extendedBuffer = buffer;
|
|
3005
|
+
const requiredSize = buffer.position + 1 + ((text.length * 3 + 3) >> 2);
|
|
3006
|
+
if (requiredSize > buffer.length) {
|
|
3007
|
+
// Reserve more space if needed
|
|
3008
|
+
extendedBuffer = createAstBufferNode(requiredSize * 2);
|
|
3009
|
+
byteBuffer.copy(extendedBuffer.byteBuffer, 0, 0, buffer.position << 2);
|
|
3010
|
+
extendedBuffer.position = buffer.position;
|
|
3011
|
+
}
|
|
3012
|
+
const insertPosition = extendedBuffer.position;
|
|
3013
|
+
extendedBuffer[referencePosition] = insertPosition;
|
|
3014
|
+
const stringBytePosition = (insertPosition + 1) << 2;
|
|
3015
|
+
const encodedLength = extendedBuffer.byteBuffer.write(text, stringBytePosition);
|
|
3016
|
+
extendedBuffer[insertPosition] = encodedLength;
|
|
3017
|
+
if (isBigEndianHost) {
|
|
3018
|
+
writeStringWordsBigEndian(extendedBuffer, extendedBuffer.byteBuffer, stringBytePosition, encodedLength);
|
|
3019
|
+
}
|
|
3020
|
+
// Round up to the next 4-byte boundary
|
|
3021
|
+
extendedBuffer.position = (stringBytePosition + encodedLength + 3) >> 2;
|
|
3022
|
+
return extendedBuffer;
|
|
3023
|
+
},
|
|
3024
|
+
byteBuffer,
|
|
3025
|
+
position: 0,
|
|
3026
|
+
reserve(size) {
|
|
3027
|
+
const newPosition = buffer.position + size;
|
|
3028
|
+
if (newPosition <= buffer.length) {
|
|
3029
|
+
buffer.position = newPosition;
|
|
3030
|
+
return buffer;
|
|
3031
|
+
}
|
|
3032
|
+
const newBuffer = createAstBufferNode(newPosition * 2);
|
|
3033
|
+
byteBuffer.copy(newBuffer.byteBuffer, 0, 0, buffer.position << 2);
|
|
3034
|
+
newBuffer.position = newPosition;
|
|
3035
|
+
return newBuffer;
|
|
3036
|
+
},
|
|
3037
|
+
toOutput() {
|
|
3038
|
+
const byteSize = buffer.position << 2;
|
|
3039
|
+
// The "slow" version will allocate exactly the needed size and is preferable
|
|
3040
|
+
// for long-term memory usage.
|
|
3041
|
+
const truncatedBuffer = Buffer.allocUnsafeSlow(byteSize);
|
|
3042
|
+
byteBuffer.copy(truncatedBuffer, 0, 0, byteSize);
|
|
3043
|
+
return truncatedBuffer;
|
|
3044
|
+
},
|
|
3045
|
+
writeFloat64
|
|
3046
|
+
});
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
// This file is generated by scripts/generate-node-type-strings.ts.
|
|
3050
|
+
// Do not edit this file directly.
|
|
3051
|
+
const nodeTypeStrings = [
|
|
3052
|
+
'PanicError',
|
|
3053
|
+
'ParseError',
|
|
3054
|
+
'ArrayExpression',
|
|
3055
|
+
'ArrayPattern',
|
|
3056
|
+
'ArrowFunctionExpression',
|
|
3057
|
+
'AssignmentExpression',
|
|
3058
|
+
'AssignmentPattern',
|
|
3059
|
+
'AwaitExpression',
|
|
3060
|
+
'BinaryExpression',
|
|
3061
|
+
'BlockStatement',
|
|
3062
|
+
'BreakStatement',
|
|
3063
|
+
'CallExpression',
|
|
3064
|
+
'CatchClause',
|
|
3065
|
+
'ChainExpression',
|
|
3066
|
+
'ClassBody',
|
|
3067
|
+
'ClassDeclaration',
|
|
3068
|
+
'ClassExpression',
|
|
3069
|
+
'ConditionalExpression',
|
|
3070
|
+
'ContinueStatement',
|
|
3071
|
+
'DebuggerStatement',
|
|
3072
|
+
'Decorator',
|
|
3073
|
+
'ExpressionStatement',
|
|
3074
|
+
'DoWhileStatement',
|
|
3075
|
+
'EmptyStatement',
|
|
3076
|
+
'ExportAllDeclaration',
|
|
3077
|
+
'ExportDefaultDeclaration',
|
|
3078
|
+
'ExportNamedDeclaration',
|
|
3079
|
+
'ExportSpecifier',
|
|
3080
|
+
'ExpressionStatement',
|
|
3081
|
+
'ForInStatement',
|
|
3082
|
+
'ForOfStatement',
|
|
3083
|
+
'ForStatement',
|
|
3084
|
+
'FunctionDeclaration',
|
|
3085
|
+
'FunctionExpression',
|
|
3086
|
+
'Identifier',
|
|
3087
|
+
'IfStatement',
|
|
3088
|
+
'ImportAttribute',
|
|
3089
|
+
'ImportDeclaration',
|
|
3090
|
+
'ImportDefaultSpecifier',
|
|
3091
|
+
'ImportExpression',
|
|
3092
|
+
'ImportNamespaceSpecifier',
|
|
3093
|
+
'ImportSpecifier',
|
|
3094
|
+
'JSXAttribute',
|
|
3095
|
+
'JSXClosingElement',
|
|
3096
|
+
'JSXClosingFragment',
|
|
3097
|
+
'JSXElement',
|
|
3098
|
+
'JSXEmptyExpression',
|
|
3099
|
+
'JSXExpressionContainer',
|
|
3100
|
+
'JSXFragment',
|
|
3101
|
+
'JSXIdentifier',
|
|
3102
|
+
'JSXMemberExpression',
|
|
3103
|
+
'JSXNamespacedName',
|
|
3104
|
+
'JSXOpeningElement',
|
|
3105
|
+
'JSXOpeningFragment',
|
|
3106
|
+
'JSXSpreadAttribute',
|
|
3107
|
+
'JSXSpreadChild',
|
|
3108
|
+
'JSXText',
|
|
3109
|
+
'LabeledStatement',
|
|
3110
|
+
'Literal',
|
|
3111
|
+
'Literal',
|
|
3112
|
+
'Literal',
|
|
3113
|
+
'Literal',
|
|
3114
|
+
'Literal',
|
|
3115
|
+
'Literal',
|
|
3116
|
+
'LogicalExpression',
|
|
3117
|
+
'MemberExpression',
|
|
3118
|
+
'MetaProperty',
|
|
3119
|
+
'MethodDefinition',
|
|
3120
|
+
'NewExpression',
|
|
3121
|
+
'ObjectExpression',
|
|
3122
|
+
'ObjectPattern',
|
|
3123
|
+
'PrivateIdentifier',
|
|
3124
|
+
'Program',
|
|
3125
|
+
'Property',
|
|
3126
|
+
'PropertyDefinition',
|
|
3127
|
+
'RestElement',
|
|
3128
|
+
'ReturnStatement',
|
|
3129
|
+
'SequenceExpression',
|
|
3130
|
+
'SpreadElement',
|
|
3131
|
+
'StaticBlock',
|
|
3132
|
+
'Super',
|
|
3133
|
+
'SwitchCase',
|
|
3134
|
+
'SwitchStatement',
|
|
3135
|
+
'TaggedTemplateExpression',
|
|
3136
|
+
'TemplateElement',
|
|
3137
|
+
'TemplateLiteral',
|
|
3138
|
+
'ThisExpression',
|
|
3139
|
+
'ThrowStatement',
|
|
3140
|
+
'TryStatement',
|
|
3141
|
+
'UnaryExpression',
|
|
3142
|
+
'UpdateExpression',
|
|
3143
|
+
'VariableDeclaration',
|
|
3144
|
+
'VariableDeclarator',
|
|
3145
|
+
'WhileStatement',
|
|
3146
|
+
'YieldExpression'
|
|
3147
|
+
];
|
|
3148
|
+
|
|
3149
|
+
// This file is generated by scripts/generate-buffer-to-ast.ts.
|
|
3150
|
+
// Do not edit this file directly.
|
|
3151
|
+
const deserializeAstBuffer = (buffer, position) => {
|
|
3152
|
+
const node = convertNode(position, buffer);
|
|
3153
|
+
switch (node.type) {
|
|
3154
|
+
case PanicError: {
|
|
3155
|
+
return error(getRollupError(logParseError(node.message)));
|
|
3156
|
+
}
|
|
3157
|
+
case ParseError: {
|
|
3158
|
+
return error(getRollupError(logParseError(node.message, node.start)));
|
|
3159
|
+
}
|
|
3160
|
+
default: {
|
|
3161
|
+
return node;
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
/* eslint-disable sort-keys */
|
|
3166
|
+
const nodeConverters = [
|
|
3167
|
+
function panicError(position, buffer) {
|
|
3168
|
+
return {
|
|
3169
|
+
type: 'PanicError',
|
|
3170
|
+
start: buffer[position],
|
|
3171
|
+
end: buffer[position + 1],
|
|
3172
|
+
message: buffer.convertString(buffer[position + 2])
|
|
3173
|
+
};
|
|
3174
|
+
},
|
|
3175
|
+
function parseError(position, buffer) {
|
|
3176
|
+
return {
|
|
3177
|
+
type: 'ParseError',
|
|
3178
|
+
start: buffer[position],
|
|
3179
|
+
end: buffer[position + 1],
|
|
3180
|
+
message: buffer.convertString(buffer[position + 2])
|
|
3181
|
+
};
|
|
3182
|
+
},
|
|
3183
|
+
function arrayExpression(position, buffer) {
|
|
3184
|
+
return {
|
|
3185
|
+
type: 'ArrayExpression',
|
|
3186
|
+
start: buffer[position],
|
|
3187
|
+
end: buffer[position + 1],
|
|
3188
|
+
elements: convertNodeList(buffer[position + 2], buffer)
|
|
3189
|
+
};
|
|
3190
|
+
},
|
|
3191
|
+
function arrayPattern(position, buffer) {
|
|
3192
|
+
return {
|
|
3193
|
+
type: 'ArrayPattern',
|
|
3194
|
+
start: buffer[position],
|
|
3195
|
+
end: buffer[position + 1],
|
|
3196
|
+
elements: convertNodeList(buffer[position + 2], buffer)
|
|
3197
|
+
};
|
|
3198
|
+
},
|
|
3199
|
+
function arrowFunctionExpression(position, buffer) {
|
|
3200
|
+
const flags = buffer[position + 2];
|
|
3201
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3202
|
+
return {
|
|
3203
|
+
type: 'ArrowFunctionExpression',
|
|
3204
|
+
start: buffer[position],
|
|
3205
|
+
end: buffer[position + 1],
|
|
3206
|
+
async: (flags & 1) === 1,
|
|
3207
|
+
expression: (flags & 2) === 2,
|
|
3208
|
+
generator: (flags & 4) === 4,
|
|
3209
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3210
|
+
params: convertNodeList(buffer[position + 4], buffer),
|
|
3211
|
+
body: convertNode(buffer[position + 5], buffer),
|
|
3212
|
+
id: null
|
|
3213
|
+
};
|
|
3214
|
+
},
|
|
3215
|
+
function assignmentExpression(position, buffer) {
|
|
3216
|
+
return {
|
|
3217
|
+
type: 'AssignmentExpression',
|
|
3218
|
+
start: buffer[position],
|
|
3219
|
+
end: buffer[position + 1],
|
|
3220
|
+
operator: FIXED_STRINGS[buffer[position + 2]],
|
|
3221
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3222
|
+
right: convertNode(buffer[position + 4], buffer)
|
|
3223
|
+
};
|
|
3224
|
+
},
|
|
3225
|
+
function assignmentPattern(position, buffer) {
|
|
3226
|
+
return {
|
|
3227
|
+
type: 'AssignmentPattern',
|
|
3228
|
+
start: buffer[position],
|
|
3229
|
+
end: buffer[position + 1],
|
|
3230
|
+
left: convertNode(buffer[position + 2], buffer),
|
|
3231
|
+
right: convertNode(buffer[position + 3], buffer)
|
|
3232
|
+
};
|
|
3233
|
+
},
|
|
3234
|
+
function awaitExpression(position, buffer) {
|
|
3235
|
+
return {
|
|
3236
|
+
type: 'AwaitExpression',
|
|
3237
|
+
start: buffer[position],
|
|
3238
|
+
end: buffer[position + 1],
|
|
3239
|
+
argument: convertNode(buffer[position + 2], buffer)
|
|
3240
|
+
};
|
|
3241
|
+
},
|
|
3242
|
+
function binaryExpression(position, buffer) {
|
|
3243
|
+
return {
|
|
3244
|
+
type: 'BinaryExpression',
|
|
3245
|
+
start: buffer[position],
|
|
3246
|
+
end: buffer[position + 1],
|
|
3247
|
+
operator: FIXED_STRINGS[buffer[position + 2]],
|
|
3248
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3249
|
+
right: convertNode(buffer[position + 4], buffer)
|
|
3250
|
+
};
|
|
3251
|
+
},
|
|
3252
|
+
function blockStatement(position, buffer) {
|
|
3253
|
+
return {
|
|
3254
|
+
type: 'BlockStatement',
|
|
3255
|
+
start: buffer[position],
|
|
3256
|
+
end: buffer[position + 1],
|
|
3257
|
+
body: convertNodeList(buffer[position + 2], buffer)
|
|
3258
|
+
};
|
|
3259
|
+
},
|
|
3260
|
+
function breakStatement(position, buffer) {
|
|
3261
|
+
const labelPosition = buffer[position + 2];
|
|
3262
|
+
return {
|
|
3263
|
+
type: 'BreakStatement',
|
|
3264
|
+
start: buffer[position],
|
|
3265
|
+
end: buffer[position + 1],
|
|
3266
|
+
label: labelPosition === 0 ? null : convertNode(labelPosition, buffer)
|
|
3267
|
+
};
|
|
3268
|
+
},
|
|
3269
|
+
function callExpression(position, buffer) {
|
|
3270
|
+
const flags = buffer[position + 2];
|
|
3271
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3272
|
+
return {
|
|
3273
|
+
type: 'CallExpression',
|
|
3274
|
+
start: buffer[position],
|
|
3275
|
+
end: buffer[position + 1],
|
|
3276
|
+
optional: (flags & 1) === 1,
|
|
3277
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3278
|
+
callee: convertNode(buffer[position + 4], buffer),
|
|
3279
|
+
arguments: convertNodeList(buffer[position + 5], buffer)
|
|
3280
|
+
};
|
|
3281
|
+
},
|
|
3282
|
+
function catchClause(position, buffer) {
|
|
3283
|
+
const parameterPosition = buffer[position + 2];
|
|
3284
|
+
return {
|
|
3285
|
+
type: 'CatchClause',
|
|
3286
|
+
start: buffer[position],
|
|
3287
|
+
end: buffer[position + 1],
|
|
3288
|
+
param: parameterPosition === 0 ? null : convertNode(parameterPosition, buffer),
|
|
3289
|
+
body: convertNode(buffer[position + 3], buffer)
|
|
3290
|
+
};
|
|
3291
|
+
},
|
|
3292
|
+
function chainExpression(position, buffer) {
|
|
3293
|
+
return {
|
|
3294
|
+
type: 'ChainExpression',
|
|
3295
|
+
start: buffer[position],
|
|
3296
|
+
end: buffer[position + 1],
|
|
3297
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3298
|
+
};
|
|
3299
|
+
},
|
|
3300
|
+
function classBody(position, buffer) {
|
|
3301
|
+
return {
|
|
3302
|
+
type: 'ClassBody',
|
|
3303
|
+
start: buffer[position],
|
|
3304
|
+
end: buffer[position + 1],
|
|
3305
|
+
body: convertNodeList(buffer[position + 2], buffer)
|
|
3306
|
+
};
|
|
3307
|
+
},
|
|
3308
|
+
function classDeclaration(position, buffer) {
|
|
3309
|
+
const idPosition = buffer[position + 3];
|
|
3310
|
+
const superClassPosition = buffer[position + 4];
|
|
3311
|
+
return {
|
|
3312
|
+
type: 'ClassDeclaration',
|
|
3313
|
+
start: buffer[position],
|
|
3314
|
+
end: buffer[position + 1],
|
|
3315
|
+
decorators: convertNodeList(buffer[position + 2], buffer),
|
|
3316
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3317
|
+
superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer),
|
|
3318
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3319
|
+
};
|
|
3320
|
+
},
|
|
3321
|
+
function classExpression(position, buffer) {
|
|
3322
|
+
const idPosition = buffer[position + 3];
|
|
3323
|
+
const superClassPosition = buffer[position + 4];
|
|
3324
|
+
return {
|
|
3325
|
+
type: 'ClassExpression',
|
|
3326
|
+
start: buffer[position],
|
|
3327
|
+
end: buffer[position + 1],
|
|
3328
|
+
decorators: convertNodeList(buffer[position + 2], buffer),
|
|
3329
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3330
|
+
superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer),
|
|
3331
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3332
|
+
};
|
|
3333
|
+
},
|
|
3334
|
+
function conditionalExpression(position, buffer) {
|
|
3335
|
+
return {
|
|
3336
|
+
type: 'ConditionalExpression',
|
|
3337
|
+
start: buffer[position],
|
|
3338
|
+
end: buffer[position + 1],
|
|
3339
|
+
test: convertNode(buffer[position + 2], buffer),
|
|
3340
|
+
consequent: convertNode(buffer[position + 3], buffer),
|
|
3341
|
+
alternate: convertNode(buffer[position + 4], buffer)
|
|
3342
|
+
};
|
|
3343
|
+
},
|
|
3344
|
+
function continueStatement(position, buffer) {
|
|
3345
|
+
const labelPosition = buffer[position + 2];
|
|
3346
|
+
return {
|
|
3347
|
+
type: 'ContinueStatement',
|
|
3348
|
+
start: buffer[position],
|
|
3349
|
+
end: buffer[position + 1],
|
|
3350
|
+
label: labelPosition === 0 ? null : convertNode(labelPosition, buffer)
|
|
3351
|
+
};
|
|
3352
|
+
},
|
|
3353
|
+
function debuggerStatement(position, buffer) {
|
|
3354
|
+
return {
|
|
3355
|
+
type: 'DebuggerStatement',
|
|
3356
|
+
start: buffer[position],
|
|
3357
|
+
end: buffer[position + 1]
|
|
3358
|
+
};
|
|
3359
|
+
},
|
|
3360
|
+
function decorator(position, buffer) {
|
|
3361
|
+
return {
|
|
3362
|
+
type: 'Decorator',
|
|
3363
|
+
start: buffer[position],
|
|
3364
|
+
end: buffer[position + 1],
|
|
3365
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3366
|
+
};
|
|
3367
|
+
},
|
|
3368
|
+
function directive(position, buffer) {
|
|
3369
|
+
return {
|
|
3370
|
+
type: 'ExpressionStatement',
|
|
3371
|
+
start: buffer[position],
|
|
3372
|
+
end: buffer[position + 1],
|
|
3373
|
+
directive: buffer.convertString(buffer[position + 2]),
|
|
3374
|
+
expression: convertNode(buffer[position + 3], buffer)
|
|
3375
|
+
};
|
|
3376
|
+
},
|
|
3377
|
+
function doWhileStatement(position, buffer) {
|
|
3378
|
+
return {
|
|
3379
|
+
type: 'DoWhileStatement',
|
|
3380
|
+
start: buffer[position],
|
|
3381
|
+
end: buffer[position + 1],
|
|
3382
|
+
body: convertNode(buffer[position + 2], buffer),
|
|
3383
|
+
test: convertNode(buffer[position + 3], buffer)
|
|
3384
|
+
};
|
|
3385
|
+
},
|
|
3386
|
+
function emptyStatement(position, buffer) {
|
|
3387
|
+
return {
|
|
3388
|
+
type: 'EmptyStatement',
|
|
3389
|
+
start: buffer[position],
|
|
3390
|
+
end: buffer[position + 1]
|
|
3391
|
+
};
|
|
3392
|
+
},
|
|
3393
|
+
function exportAllDeclaration(position, buffer) {
|
|
3394
|
+
const exportedPosition = buffer[position + 2];
|
|
3395
|
+
return {
|
|
3396
|
+
type: 'ExportAllDeclaration',
|
|
3397
|
+
start: buffer[position],
|
|
3398
|
+
end: buffer[position + 1],
|
|
3399
|
+
exported: exportedPosition === 0 ? null : convertNode(exportedPosition, buffer),
|
|
3400
|
+
source: convertNode(buffer[position + 3], buffer),
|
|
3401
|
+
attributes: convertNodeList(buffer[position + 4], buffer)
|
|
3402
|
+
};
|
|
3403
|
+
},
|
|
3404
|
+
function exportDefaultDeclaration(position, buffer) {
|
|
3405
|
+
return {
|
|
3406
|
+
type: 'ExportDefaultDeclaration',
|
|
3407
|
+
start: buffer[position],
|
|
3408
|
+
end: buffer[position + 1],
|
|
3409
|
+
declaration: convertNode(buffer[position + 2], buffer)
|
|
3410
|
+
};
|
|
3411
|
+
},
|
|
3412
|
+
function exportNamedDeclaration(position, buffer) {
|
|
3413
|
+
const sourcePosition = buffer[position + 3];
|
|
3414
|
+
const declarationPosition = buffer[position + 5];
|
|
3415
|
+
return {
|
|
3416
|
+
type: 'ExportNamedDeclaration',
|
|
3417
|
+
start: buffer[position],
|
|
3418
|
+
end: buffer[position + 1],
|
|
3419
|
+
specifiers: convertNodeList(buffer[position + 2], buffer),
|
|
3420
|
+
source: sourcePosition === 0 ? null : convertNode(sourcePosition, buffer),
|
|
3421
|
+
attributes: convertNodeList(buffer[position + 4], buffer),
|
|
3422
|
+
declaration: declarationPosition === 0 ? null : convertNode(declarationPosition, buffer)
|
|
3423
|
+
};
|
|
3424
|
+
},
|
|
3425
|
+
function exportSpecifier(position, buffer) {
|
|
3426
|
+
const local = convertNode(buffer[position + 2], buffer);
|
|
3427
|
+
const exportedPosition = buffer[position + 3];
|
|
3428
|
+
return {
|
|
3429
|
+
type: 'ExportSpecifier',
|
|
3430
|
+
start: buffer[position],
|
|
3431
|
+
end: buffer[position + 1],
|
|
3432
|
+
local,
|
|
3433
|
+
exported: exportedPosition === 0 ? { ...local } : convertNode(exportedPosition, buffer)
|
|
3434
|
+
};
|
|
3435
|
+
},
|
|
3436
|
+
function expressionStatement(position, buffer) {
|
|
3437
|
+
return {
|
|
3438
|
+
type: 'ExpressionStatement',
|
|
3439
|
+
start: buffer[position],
|
|
3440
|
+
end: buffer[position + 1],
|
|
3441
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3442
|
+
};
|
|
3443
|
+
},
|
|
3444
|
+
function forInStatement(position, buffer) {
|
|
3445
|
+
return {
|
|
3446
|
+
type: 'ForInStatement',
|
|
3447
|
+
start: buffer[position],
|
|
3448
|
+
end: buffer[position + 1],
|
|
3449
|
+
left: convertNode(buffer[position + 2], buffer),
|
|
3450
|
+
right: convertNode(buffer[position + 3], buffer),
|
|
3451
|
+
body: convertNode(buffer[position + 4], buffer)
|
|
3452
|
+
};
|
|
3453
|
+
},
|
|
3454
|
+
function forOfStatement(position, buffer) {
|
|
3455
|
+
const flags = buffer[position + 2];
|
|
3456
|
+
return {
|
|
3457
|
+
type: 'ForOfStatement',
|
|
3458
|
+
start: buffer[position],
|
|
3459
|
+
end: buffer[position + 1],
|
|
3460
|
+
await: (flags & 1) === 1,
|
|
3461
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3462
|
+
right: convertNode(buffer[position + 4], buffer),
|
|
3463
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3464
|
+
};
|
|
3465
|
+
},
|
|
3466
|
+
function forStatement(position, buffer) {
|
|
3467
|
+
const initPosition = buffer[position + 2];
|
|
3468
|
+
const testPosition = buffer[position + 3];
|
|
3469
|
+
const updatePosition = buffer[position + 4];
|
|
3470
|
+
return {
|
|
3471
|
+
type: 'ForStatement',
|
|
3472
|
+
start: buffer[position],
|
|
3473
|
+
end: buffer[position + 1],
|
|
3474
|
+
init: initPosition === 0 ? null : convertNode(initPosition, buffer),
|
|
3475
|
+
test: testPosition === 0 ? null : convertNode(testPosition, buffer),
|
|
3476
|
+
update: updatePosition === 0 ? null : convertNode(updatePosition, buffer),
|
|
3477
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3478
|
+
};
|
|
3479
|
+
},
|
|
3480
|
+
function functionDeclaration(position, buffer) {
|
|
3481
|
+
const flags = buffer[position + 2];
|
|
3482
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3483
|
+
const idPosition = buffer[position + 4];
|
|
3484
|
+
return {
|
|
3485
|
+
type: 'FunctionDeclaration',
|
|
3486
|
+
start: buffer[position],
|
|
3487
|
+
end: buffer[position + 1],
|
|
3488
|
+
async: (flags & 1) === 1,
|
|
3489
|
+
generator: (flags & 2) === 2,
|
|
3490
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3491
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3492
|
+
params: convertNodeList(buffer[position + 5], buffer),
|
|
3493
|
+
body: convertNode(buffer[position + 6], buffer),
|
|
3494
|
+
expression: false
|
|
3495
|
+
};
|
|
3496
|
+
},
|
|
3497
|
+
function functionExpression(position, buffer) {
|
|
3498
|
+
const flags = buffer[position + 2];
|
|
3499
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3500
|
+
const idPosition = buffer[position + 4];
|
|
3501
|
+
return {
|
|
3502
|
+
type: 'FunctionExpression',
|
|
3503
|
+
start: buffer[position],
|
|
3504
|
+
end: buffer[position + 1],
|
|
3505
|
+
async: (flags & 1) === 1,
|
|
3506
|
+
generator: (flags & 2) === 2,
|
|
3507
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3508
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3509
|
+
params: convertNodeList(buffer[position + 5], buffer),
|
|
3510
|
+
body: convertNode(buffer[position + 6], buffer),
|
|
3511
|
+
expression: false
|
|
3512
|
+
};
|
|
3513
|
+
},
|
|
3514
|
+
function identifier(position, buffer) {
|
|
3515
|
+
return {
|
|
3516
|
+
type: 'Identifier',
|
|
3517
|
+
start: buffer[position],
|
|
3518
|
+
end: buffer[position + 1],
|
|
3519
|
+
name: buffer.convertString(buffer[position + 2])
|
|
3520
|
+
};
|
|
3521
|
+
},
|
|
3522
|
+
function ifStatement(position, buffer) {
|
|
3523
|
+
const alternatePosition = buffer[position + 4];
|
|
3524
|
+
return {
|
|
3525
|
+
type: 'IfStatement',
|
|
3526
|
+
start: buffer[position],
|
|
3527
|
+
end: buffer[position + 1],
|
|
3528
|
+
test: convertNode(buffer[position + 2], buffer),
|
|
3529
|
+
consequent: convertNode(buffer[position + 3], buffer),
|
|
3530
|
+
alternate: alternatePosition === 0 ? null : convertNode(alternatePosition, buffer)
|
|
3531
|
+
};
|
|
3532
|
+
},
|
|
3533
|
+
function importAttribute(position, buffer) {
|
|
3534
|
+
return {
|
|
3535
|
+
type: 'ImportAttribute',
|
|
3536
|
+
start: buffer[position],
|
|
3537
|
+
end: buffer[position + 1],
|
|
3538
|
+
key: convertNode(buffer[position + 2], buffer),
|
|
3539
|
+
value: convertNode(buffer[position + 3], buffer)
|
|
3540
|
+
};
|
|
3541
|
+
},
|
|
3542
|
+
function importDeclaration(position, buffer) {
|
|
3543
|
+
const phasePosition = buffer[position + 5];
|
|
3544
|
+
return {
|
|
3545
|
+
type: 'ImportDeclaration',
|
|
3546
|
+
start: buffer[position],
|
|
3547
|
+
end: buffer[position + 1],
|
|
3548
|
+
specifiers: convertNodeList(buffer[position + 2], buffer),
|
|
3549
|
+
source: convertNode(buffer[position + 3], buffer),
|
|
3550
|
+
attributes: convertNodeList(buffer[position + 4], buffer),
|
|
3551
|
+
phase: phasePosition === 0
|
|
3552
|
+
? undefined
|
|
3553
|
+
: FIXED_STRINGS[buffer[position + 5]]
|
|
3554
|
+
};
|
|
3555
|
+
},
|
|
3556
|
+
function importDefaultSpecifier(position, buffer) {
|
|
3557
|
+
return {
|
|
3558
|
+
type: 'ImportDefaultSpecifier',
|
|
3559
|
+
start: buffer[position],
|
|
3560
|
+
end: buffer[position + 1],
|
|
3561
|
+
local: convertNode(buffer[position + 2], buffer)
|
|
3562
|
+
};
|
|
3563
|
+
},
|
|
3564
|
+
function importExpression(position, buffer) {
|
|
3565
|
+
const optionsPosition = buffer[position + 3];
|
|
3566
|
+
const phasePosition = buffer[position + 4];
|
|
3567
|
+
return {
|
|
3568
|
+
type: 'ImportExpression',
|
|
3569
|
+
start: buffer[position],
|
|
3570
|
+
end: buffer[position + 1],
|
|
3571
|
+
source: convertNode(buffer[position + 2], buffer),
|
|
3572
|
+
options: optionsPosition === 0 ? null : convertNode(optionsPosition, buffer),
|
|
3573
|
+
phase: phasePosition === 0
|
|
3574
|
+
? undefined
|
|
3575
|
+
: FIXED_STRINGS[buffer[position + 4]]
|
|
3576
|
+
};
|
|
3577
|
+
},
|
|
3578
|
+
function importNamespaceSpecifier(position, buffer) {
|
|
3579
|
+
return {
|
|
3580
|
+
type: 'ImportNamespaceSpecifier',
|
|
3581
|
+
start: buffer[position],
|
|
3582
|
+
end: buffer[position + 1],
|
|
3583
|
+
local: convertNode(buffer[position + 2], buffer)
|
|
3584
|
+
};
|
|
3585
|
+
},
|
|
3586
|
+
function importSpecifier(position, buffer) {
|
|
3587
|
+
const importedPosition = buffer[position + 2];
|
|
3588
|
+
const local = convertNode(buffer[position + 3], buffer);
|
|
3589
|
+
return {
|
|
3590
|
+
type: 'ImportSpecifier',
|
|
3591
|
+
start: buffer[position],
|
|
3592
|
+
end: buffer[position + 1],
|
|
3593
|
+
imported: importedPosition === 0 ? { ...local } : convertNode(importedPosition, buffer),
|
|
3594
|
+
local
|
|
3595
|
+
};
|
|
3596
|
+
},
|
|
3597
|
+
function jsxAttribute(position, buffer) {
|
|
3598
|
+
const valuePosition = buffer[position + 3];
|
|
3599
|
+
return {
|
|
3600
|
+
type: 'JSXAttribute',
|
|
3601
|
+
start: buffer[position],
|
|
3602
|
+
end: buffer[position + 1],
|
|
3603
|
+
name: convertNode(buffer[position + 2], buffer),
|
|
3604
|
+
value: valuePosition === 0 ? null : convertNode(valuePosition, buffer)
|
|
3605
|
+
};
|
|
3606
|
+
},
|
|
3607
|
+
function jsxClosingElement(position, buffer) {
|
|
3608
|
+
return {
|
|
3609
|
+
type: 'JSXClosingElement',
|
|
3610
|
+
start: buffer[position],
|
|
3611
|
+
end: buffer[position + 1],
|
|
3612
|
+
name: convertNode(buffer[position + 2], buffer)
|
|
3613
|
+
};
|
|
3614
|
+
},
|
|
3615
|
+
function jsxClosingFragment(position, buffer) {
|
|
3616
|
+
return {
|
|
3617
|
+
type: 'JSXClosingFragment',
|
|
3618
|
+
start: buffer[position],
|
|
3619
|
+
end: buffer[position + 1]
|
|
3620
|
+
};
|
|
3621
|
+
},
|
|
3622
|
+
function jsxElement(position, buffer) {
|
|
3623
|
+
const closingElementPosition = buffer[position + 4];
|
|
3624
|
+
return {
|
|
3625
|
+
type: 'JSXElement',
|
|
3626
|
+
start: buffer[position],
|
|
3627
|
+
end: buffer[position + 1],
|
|
3628
|
+
openingElement: convertNode(buffer[position + 2], buffer),
|
|
3629
|
+
children: convertNodeList(buffer[position + 3], buffer),
|
|
3630
|
+
closingElement: closingElementPosition === 0 ? null : convertNode(closingElementPosition, buffer)
|
|
3631
|
+
};
|
|
3632
|
+
},
|
|
3633
|
+
function jsxEmptyExpression(position, buffer) {
|
|
3634
|
+
return {
|
|
3635
|
+
type: 'JSXEmptyExpression',
|
|
3636
|
+
start: buffer[position],
|
|
3637
|
+
end: buffer[position + 1]
|
|
3638
|
+
};
|
|
3639
|
+
},
|
|
3640
|
+
function jsxExpressionContainer(position, buffer) {
|
|
3641
|
+
return {
|
|
3642
|
+
type: 'JSXExpressionContainer',
|
|
3643
|
+
start: buffer[position],
|
|
3644
|
+
end: buffer[position + 1],
|
|
3645
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3646
|
+
};
|
|
3647
|
+
},
|
|
3648
|
+
function jsxFragment(position, buffer) {
|
|
3649
|
+
return {
|
|
3650
|
+
type: 'JSXFragment',
|
|
3651
|
+
start: buffer[position],
|
|
3652
|
+
end: buffer[position + 1],
|
|
3653
|
+
openingFragment: convertNode(buffer[position + 2], buffer),
|
|
3654
|
+
children: convertNodeList(buffer[position + 3], buffer),
|
|
3655
|
+
closingFragment: convertNode(buffer[position + 4], buffer)
|
|
3656
|
+
};
|
|
3657
|
+
},
|
|
3658
|
+
function jsxIdentifier(position, buffer) {
|
|
3659
|
+
return {
|
|
3660
|
+
type: 'JSXIdentifier',
|
|
3661
|
+
start: buffer[position],
|
|
3662
|
+
end: buffer[position + 1],
|
|
3663
|
+
name: buffer.convertString(buffer[position + 2])
|
|
3664
|
+
};
|
|
3665
|
+
},
|
|
3666
|
+
function jsxMemberExpression(position, buffer) {
|
|
3667
|
+
return {
|
|
3668
|
+
type: 'JSXMemberExpression',
|
|
3669
|
+
start: buffer[position],
|
|
3670
|
+
end: buffer[position + 1],
|
|
3671
|
+
object: convertNode(buffer[position + 2], buffer),
|
|
3672
|
+
property: convertNode(buffer[position + 3], buffer)
|
|
1663
3673
|
};
|
|
1664
3674
|
},
|
|
1665
3675
|
function jsxNamespacedName(position, buffer) {
|
|
@@ -1763,7 +3773,7 @@ const nodeConverters = [
|
|
|
1763
3773
|
start: buffer[position],
|
|
1764
3774
|
end: buffer[position + 1],
|
|
1765
3775
|
raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition),
|
|
1766
|
-
value:
|
|
3776
|
+
value: buffer.convertFloat64(position + 3)
|
|
1767
3777
|
};
|
|
1768
3778
|
},
|
|
1769
3779
|
function literalRegExp(position, buffer) {
|
|
@@ -1839,7 +3849,7 @@ const nodeConverters = [
|
|
|
1839
3849
|
type: 'NewExpression',
|
|
1840
3850
|
start: buffer[position],
|
|
1841
3851
|
end: buffer[position + 1],
|
|
1842
|
-
...(annotations.length > 0 ? {
|
|
3852
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1843
3853
|
callee: convertNode(buffer[position + 3], buffer),
|
|
1844
3854
|
arguments: convertNodeList(buffer[position + 4], buffer)
|
|
1845
3855
|
};
|
|
@@ -1875,7 +3885,7 @@ const nodeConverters = [
|
|
|
1875
3885
|
start: buffer[position],
|
|
1876
3886
|
end: buffer[position + 1],
|
|
1877
3887
|
body: convertNodeList(buffer[position + 2], buffer),
|
|
1878
|
-
...(invalidAnnotations.length > 0 ? {
|
|
3888
|
+
...(invalidAnnotations.length > 0 ? { invalidAnnotations } : {}),
|
|
1879
3889
|
sourceType: 'module'
|
|
1880
3890
|
};
|
|
1881
3891
|
},
|
|
@@ -1988,7 +3998,7 @@ const nodeConverters = [
|
|
|
1988
3998
|
function templateElement(position, buffer) {
|
|
1989
3999
|
const flags = buffer[position + 2];
|
|
1990
4000
|
const cookedPosition = buffer[position + 3];
|
|
1991
|
-
const cooked = cookedPosition === 0 ?
|
|
4001
|
+
const cooked = cookedPosition === 0 ? undefined : buffer.convertString(cookedPosition);
|
|
1992
4002
|
const raw = buffer.convertString(buffer[position + 4]);
|
|
1993
4003
|
return {
|
|
1994
4004
|
type: 'TemplateElement',
|
|
@@ -2117,28 +4127,1350 @@ function convertNodeList(position, buffer) {
|
|
|
2117
4127
|
return list;
|
|
2118
4128
|
}
|
|
2119
4129
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
4130
|
+
// This file is generated by scripts/generate-string-constants.ts.
|
|
4131
|
+
// Do not edit this file directly.
|
|
4132
|
+
const FIXED_STRING_INDICES = {
|
|
4133
|
+
'!': 10,
|
|
4134
|
+
'!=': 18,
|
|
4135
|
+
'!==': 20,
|
|
4136
|
+
'%': 30,
|
|
4137
|
+
'%=': 45,
|
|
4138
|
+
'&': 33,
|
|
4139
|
+
'&&': 35,
|
|
4140
|
+
'&&=': 53,
|
|
4141
|
+
'&=': 51,
|
|
4142
|
+
'*': 28,
|
|
4143
|
+
'**': 38,
|
|
4144
|
+
'**=': 52,
|
|
4145
|
+
'*=': 43,
|
|
4146
|
+
'+': 9,
|
|
4147
|
+
'++': 15,
|
|
4148
|
+
'+=': 41,
|
|
4149
|
+
'-': 8,
|
|
4150
|
+
'--': 16,
|
|
4151
|
+
'-=': 42,
|
|
4152
|
+
'/': 29,
|
|
4153
|
+
'/=': 44,
|
|
4154
|
+
'<': 21,
|
|
4155
|
+
'<<': 25,
|
|
4156
|
+
'<<=': 46,
|
|
4157
|
+
'<=': 22,
|
|
4158
|
+
'=': 40,
|
|
4159
|
+
'==': 17,
|
|
4160
|
+
'===': 19,
|
|
4161
|
+
'>': 23,
|
|
4162
|
+
'>=': 24,
|
|
4163
|
+
'>>': 26,
|
|
4164
|
+
'>>=': 47,
|
|
4165
|
+
'>>>': 27,
|
|
4166
|
+
'>>>=': 48,
|
|
4167
|
+
'??': 39,
|
|
4168
|
+
'??=': 55,
|
|
4169
|
+
'^': 32,
|
|
4170
|
+
'^=': 50,
|
|
4171
|
+
'await using': 60,
|
|
4172
|
+
const: 2,
|
|
4173
|
+
constructor: 6,
|
|
4174
|
+
defer: 62,
|
|
4175
|
+
delete: 14,
|
|
4176
|
+
get: 4,
|
|
4177
|
+
in: 36,
|
|
4178
|
+
init: 3,
|
|
4179
|
+
instanceof: 37,
|
|
4180
|
+
let: 1,
|
|
4181
|
+
method: 7,
|
|
4182
|
+
noSideEffects: 57,
|
|
4183
|
+
pure: 56,
|
|
4184
|
+
set: 5,
|
|
4185
|
+
source: 61,
|
|
4186
|
+
sourcemap: 58,
|
|
4187
|
+
typeof: 12,
|
|
4188
|
+
using: 59,
|
|
4189
|
+
var: 0,
|
|
4190
|
+
void: 13,
|
|
4191
|
+
'|': 31,
|
|
4192
|
+
'|=': 49,
|
|
4193
|
+
'||': 34,
|
|
4194
|
+
'||=': 54,
|
|
4195
|
+
'~': 11
|
|
4196
|
+
};
|
|
4197
|
+
|
|
4198
|
+
// This file is generated by scripts/generate-ast-to-buffer.ts.
|
|
4199
|
+
// Do not edit this file directly.
|
|
4200
|
+
const INITIAL_BUFFER_SIZE = 2 ** 16; // 64KB
|
|
4201
|
+
const serializeAst = node => {
|
|
4202
|
+
const initialBuffer = (typeof Buffer === 'undefined' ? createAstBufferUint8 : createAstBufferNode)(INITIAL_BUFFER_SIZE);
|
|
4203
|
+
const buffer = (nodeSerializers[node.type] || error(logUnknownNodeType(node.type, null, '')))(node, initialBuffer);
|
|
4204
|
+
return buffer.toOutput();
|
|
4205
|
+
};
|
|
4206
|
+
const serializeExpressionStatementNode = (node, buffer) => {
|
|
4207
|
+
return 'directive' in node
|
|
4208
|
+
? serializeDirective(node, buffer)
|
|
4209
|
+
: serializeExpressionStatement(node, buffer);
|
|
4210
|
+
};
|
|
4211
|
+
const serializeLiteralNode = (node, buffer) => {
|
|
4212
|
+
switch (typeof node.value) {
|
|
4213
|
+
case 'object':
|
|
4214
|
+
if (node.value === null) {
|
|
4215
|
+
return serializeLiteralNull(node, buffer);
|
|
4216
|
+
}
|
|
4217
|
+
return serializeLiteralRegExp(node, buffer);
|
|
4218
|
+
case 'boolean':
|
|
4219
|
+
return serializeLiteralBoolean(node, buffer);
|
|
4220
|
+
case 'number':
|
|
4221
|
+
return serializeLiteralNumber(node, buffer);
|
|
4222
|
+
case 'string':
|
|
4223
|
+
return serializeLiteralString(node, buffer);
|
|
4224
|
+
case 'bigint':
|
|
4225
|
+
return serializeLiteralBigInt(node, buffer);
|
|
4226
|
+
default: {
|
|
4227
|
+
/* istanbul ignore next */
|
|
4228
|
+
throw new Error(`Unexpected node value type for Literal: ${typeof node.value}`);
|
|
4229
|
+
}
|
|
2129
4230
|
}
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
4231
|
+
};
|
|
4232
|
+
const nodeSerializers = {
|
|
4233
|
+
ArrayExpression: (node, buffer) => {
|
|
4234
|
+
const nodePosition = buffer.position;
|
|
4235
|
+
buffer = buffer.reserve(4);
|
|
4236
|
+
buffer[nodePosition] = 2;
|
|
4237
|
+
buffer[nodePosition + 1] = node.start;
|
|
4238
|
+
buffer[nodePosition + 2] = node.end;
|
|
4239
|
+
buffer = serializeNodeList('elements', node, buffer, nodePosition + 3);
|
|
4240
|
+
return buffer;
|
|
4241
|
+
},
|
|
4242
|
+
ArrayPattern: (node, buffer) => {
|
|
4243
|
+
const nodePosition = buffer.position;
|
|
4244
|
+
buffer = buffer.reserve(4);
|
|
4245
|
+
buffer[nodePosition] = 3;
|
|
4246
|
+
buffer[nodePosition + 1] = node.start;
|
|
4247
|
+
buffer[nodePosition + 2] = node.end;
|
|
4248
|
+
buffer = serializeNodeList('elements', node, buffer, nodePosition + 3);
|
|
4249
|
+
return buffer;
|
|
4250
|
+
},
|
|
4251
|
+
ArrowFunctionExpression: (node, buffer) => {
|
|
4252
|
+
const nodePosition = buffer.position;
|
|
4253
|
+
buffer = buffer.reserve(8);
|
|
4254
|
+
buffer[nodePosition] = 4;
|
|
4255
|
+
buffer[nodePosition + 1] = node.start;
|
|
4256
|
+
buffer[nodePosition + 2] = node.end;
|
|
4257
|
+
buffer[nodePosition + 3] =
|
|
4258
|
+
(node.async << 0) | (node.expression << 1) | (node.generator << 2);
|
|
4259
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4260
|
+
buffer = serializeNodeList('params', node, buffer, nodePosition + 5);
|
|
4261
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4262
|
+
return buffer;
|
|
4263
|
+
},
|
|
4264
|
+
AssignmentExpression: (node, buffer) => {
|
|
4265
|
+
const nodePosition = buffer.position;
|
|
4266
|
+
buffer = buffer.reserve(6);
|
|
4267
|
+
buffer[nodePosition] = 5;
|
|
4268
|
+
buffer[nodePosition + 1] = node.start;
|
|
4269
|
+
buffer[nodePosition + 2] = node.end;
|
|
4270
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
4271
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4272
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4273
|
+
return buffer;
|
|
4274
|
+
},
|
|
4275
|
+
AssignmentPattern: (node, buffer) => {
|
|
4276
|
+
const nodePosition = buffer.position;
|
|
4277
|
+
buffer = buffer.reserve(5);
|
|
4278
|
+
buffer[nodePosition] = 6;
|
|
4279
|
+
buffer[nodePosition + 1] = node.start;
|
|
4280
|
+
buffer[nodePosition + 2] = node.end;
|
|
4281
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 3);
|
|
4282
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 4);
|
|
4283
|
+
return buffer;
|
|
4284
|
+
},
|
|
4285
|
+
AwaitExpression: (node, buffer) => {
|
|
4286
|
+
const nodePosition = buffer.position;
|
|
4287
|
+
buffer = buffer.reserve(4);
|
|
4288
|
+
buffer[nodePosition] = 7;
|
|
4289
|
+
buffer[nodePosition + 1] = node.start;
|
|
4290
|
+
buffer[nodePosition + 2] = node.end;
|
|
4291
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4292
|
+
return buffer;
|
|
4293
|
+
},
|
|
4294
|
+
BinaryExpression: (node, buffer) => {
|
|
4295
|
+
const nodePosition = buffer.position;
|
|
4296
|
+
buffer = buffer.reserve(6);
|
|
4297
|
+
buffer[nodePosition] = 8;
|
|
4298
|
+
buffer[nodePosition + 1] = node.start;
|
|
4299
|
+
buffer[nodePosition + 2] = node.end;
|
|
4300
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
4301
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4302
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4303
|
+
return buffer;
|
|
4304
|
+
},
|
|
4305
|
+
BlockStatement: (node, buffer) => {
|
|
4306
|
+
const nodePosition = buffer.position;
|
|
4307
|
+
buffer = buffer.reserve(5);
|
|
4308
|
+
buffer[nodePosition] = 9;
|
|
4309
|
+
buffer[nodePosition + 1] = node.start;
|
|
4310
|
+
buffer[nodePosition + 2] = node.end;
|
|
4311
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
4312
|
+
return buffer;
|
|
4313
|
+
},
|
|
4314
|
+
BreakStatement: (node, buffer) => {
|
|
4315
|
+
const nodePosition = buffer.position;
|
|
4316
|
+
buffer = buffer.reserve(4);
|
|
4317
|
+
buffer[nodePosition] = 10;
|
|
4318
|
+
buffer[nodePosition + 1] = node.start;
|
|
4319
|
+
buffer[nodePosition + 2] = node.end;
|
|
4320
|
+
if (node.label != null)
|
|
4321
|
+
buffer = serializeNode('label', node, buffer, nodePosition + 3);
|
|
4322
|
+
return buffer;
|
|
4323
|
+
},
|
|
4324
|
+
CallExpression: (node, buffer) => {
|
|
4325
|
+
const nodePosition = buffer.position;
|
|
4326
|
+
buffer = buffer.reserve(7);
|
|
4327
|
+
buffer[nodePosition] = 11;
|
|
4328
|
+
buffer[nodePosition + 1] = node.start;
|
|
4329
|
+
buffer[nodePosition + 2] = node.end;
|
|
4330
|
+
buffer[nodePosition + 3] = node.optional << 0;
|
|
4331
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4332
|
+
buffer = serializeNode('callee', node, buffer, nodePosition + 5);
|
|
4333
|
+
buffer = serializeNodeList('arguments', node, buffer, nodePosition + 6);
|
|
4334
|
+
return buffer;
|
|
4335
|
+
},
|
|
4336
|
+
CatchClause: (node, buffer) => {
|
|
4337
|
+
const nodePosition = buffer.position;
|
|
4338
|
+
buffer = buffer.reserve(6);
|
|
4339
|
+
buffer[nodePosition] = 12;
|
|
4340
|
+
buffer[nodePosition + 1] = node.start;
|
|
4341
|
+
buffer[nodePosition + 2] = node.end;
|
|
4342
|
+
if (node.param != null)
|
|
4343
|
+
buffer = serializeNode('param', node, buffer, nodePosition + 3);
|
|
4344
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 4);
|
|
4345
|
+
return buffer;
|
|
4346
|
+
},
|
|
4347
|
+
ChainExpression: (node, buffer) => {
|
|
4348
|
+
const nodePosition = buffer.position;
|
|
4349
|
+
buffer = buffer.reserve(4);
|
|
4350
|
+
buffer[nodePosition] = 13;
|
|
4351
|
+
buffer[nodePosition + 1] = node.start;
|
|
4352
|
+
buffer[nodePosition + 2] = node.end;
|
|
4353
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4354
|
+
return buffer;
|
|
4355
|
+
},
|
|
4356
|
+
ClassBody: (node, buffer) => {
|
|
4357
|
+
const nodePosition = buffer.position;
|
|
4358
|
+
buffer = buffer.reserve(4);
|
|
4359
|
+
buffer[nodePosition] = 14;
|
|
4360
|
+
buffer[nodePosition + 1] = node.start;
|
|
4361
|
+
buffer[nodePosition + 2] = node.end;
|
|
4362
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
4363
|
+
return buffer;
|
|
4364
|
+
},
|
|
4365
|
+
ClassDeclaration: (node, buffer) => {
|
|
4366
|
+
const nodePosition = buffer.position;
|
|
4367
|
+
buffer = buffer.reserve(8);
|
|
4368
|
+
buffer[nodePosition] = 15;
|
|
4369
|
+
buffer[nodePosition + 1] = node.start;
|
|
4370
|
+
buffer[nodePosition + 2] = node.end;
|
|
4371
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 3);
|
|
4372
|
+
if (node.id != null)
|
|
4373
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 4);
|
|
4374
|
+
if (node.superClass != null)
|
|
4375
|
+
buffer = serializeNode('superClass', node, buffer, nodePosition + 5);
|
|
4376
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4377
|
+
return buffer;
|
|
4378
|
+
},
|
|
4379
|
+
ClassExpression: (node, buffer) => {
|
|
4380
|
+
const nodePosition = buffer.position;
|
|
4381
|
+
buffer = buffer.reserve(8);
|
|
4382
|
+
buffer[nodePosition] = 16;
|
|
4383
|
+
buffer[nodePosition + 1] = node.start;
|
|
4384
|
+
buffer[nodePosition + 2] = node.end;
|
|
4385
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 3);
|
|
4386
|
+
if (node.id != null)
|
|
4387
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 4);
|
|
4388
|
+
if (node.superClass != null)
|
|
4389
|
+
buffer = serializeNode('superClass', node, buffer, nodePosition + 5);
|
|
4390
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4391
|
+
return buffer;
|
|
4392
|
+
},
|
|
4393
|
+
ConditionalExpression: (node, buffer) => {
|
|
4394
|
+
const nodePosition = buffer.position;
|
|
4395
|
+
buffer = buffer.reserve(6);
|
|
4396
|
+
buffer[nodePosition] = 17;
|
|
4397
|
+
buffer[nodePosition + 1] = node.start;
|
|
4398
|
+
buffer[nodePosition + 2] = node.end;
|
|
4399
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
4400
|
+
buffer = serializeNode('consequent', node, buffer, nodePosition + 4);
|
|
4401
|
+
buffer = serializeNode('alternate', node, buffer, nodePosition + 5);
|
|
4402
|
+
return buffer;
|
|
4403
|
+
},
|
|
4404
|
+
ContinueStatement: (node, buffer) => {
|
|
4405
|
+
const nodePosition = buffer.position;
|
|
4406
|
+
buffer = buffer.reserve(4);
|
|
4407
|
+
buffer[nodePosition] = 18;
|
|
4408
|
+
buffer[nodePosition + 1] = node.start;
|
|
4409
|
+
buffer[nodePosition + 2] = node.end;
|
|
4410
|
+
if (node.label != null)
|
|
4411
|
+
buffer = serializeNode('label', node, buffer, nodePosition + 3);
|
|
4412
|
+
return buffer;
|
|
4413
|
+
},
|
|
4414
|
+
DebuggerStatement: (node, buffer) => {
|
|
4415
|
+
const nodePosition = buffer.position;
|
|
4416
|
+
buffer = buffer.reserve(3);
|
|
4417
|
+
buffer[nodePosition] = 19;
|
|
4418
|
+
buffer[nodePosition + 1] = node.start;
|
|
4419
|
+
buffer[nodePosition + 2] = node.end;
|
|
4420
|
+
return buffer;
|
|
4421
|
+
},
|
|
4422
|
+
Decorator: (node, buffer) => {
|
|
4423
|
+
const nodePosition = buffer.position;
|
|
4424
|
+
buffer = buffer.reserve(4);
|
|
4425
|
+
buffer[nodePosition] = 20;
|
|
4426
|
+
buffer[nodePosition + 1] = node.start;
|
|
4427
|
+
buffer[nodePosition + 2] = node.end;
|
|
4428
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4429
|
+
return buffer;
|
|
4430
|
+
},
|
|
4431
|
+
DoWhileStatement: (node, buffer) => {
|
|
4432
|
+
const nodePosition = buffer.position;
|
|
4433
|
+
buffer = buffer.reserve(5);
|
|
4434
|
+
buffer[nodePosition] = 22;
|
|
4435
|
+
buffer[nodePosition + 1] = node.start;
|
|
4436
|
+
buffer[nodePosition + 2] = node.end;
|
|
4437
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 3);
|
|
4438
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 4);
|
|
4439
|
+
return buffer;
|
|
4440
|
+
},
|
|
4441
|
+
EmptyStatement: (node, buffer) => {
|
|
4442
|
+
const nodePosition = buffer.position;
|
|
4443
|
+
buffer = buffer.reserve(3);
|
|
4444
|
+
buffer[nodePosition] = 23;
|
|
4445
|
+
buffer[nodePosition + 1] = node.start;
|
|
4446
|
+
buffer[nodePosition + 2] = node.end;
|
|
4447
|
+
return buffer;
|
|
4448
|
+
},
|
|
4449
|
+
ExportAllDeclaration: (node, buffer) => {
|
|
4450
|
+
const nodePosition = buffer.position;
|
|
4451
|
+
buffer = buffer.reserve(6);
|
|
4452
|
+
buffer[nodePosition] = 24;
|
|
4453
|
+
buffer[nodePosition + 1] = node.start;
|
|
4454
|
+
buffer[nodePosition + 2] = node.end;
|
|
4455
|
+
if (node.exported != null)
|
|
4456
|
+
buffer = serializeNode('exported', node, buffer, nodePosition + 3);
|
|
4457
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 4);
|
|
4458
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4459
|
+
return buffer;
|
|
4460
|
+
},
|
|
4461
|
+
ExportDefaultDeclaration: (node, buffer) => {
|
|
4462
|
+
const nodePosition = buffer.position;
|
|
4463
|
+
buffer = buffer.reserve(4);
|
|
4464
|
+
buffer[nodePosition] = 25;
|
|
4465
|
+
buffer[nodePosition + 1] = node.start;
|
|
4466
|
+
buffer[nodePosition + 2] = node.end;
|
|
4467
|
+
buffer = serializeNode('declaration', node, buffer, nodePosition + 3);
|
|
4468
|
+
return buffer;
|
|
4469
|
+
},
|
|
4470
|
+
ExportNamedDeclaration: (node, buffer) => {
|
|
4471
|
+
const nodePosition = buffer.position;
|
|
4472
|
+
buffer = buffer.reserve(7);
|
|
4473
|
+
buffer[nodePosition] = 26;
|
|
4474
|
+
buffer[nodePosition + 1] = node.start;
|
|
4475
|
+
buffer[nodePosition + 2] = node.end;
|
|
4476
|
+
buffer = serializeNodeList('specifiers', node, buffer, nodePosition + 3);
|
|
4477
|
+
if (node.source != null)
|
|
4478
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 4);
|
|
4479
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4480
|
+
if (node.declaration != null)
|
|
4481
|
+
buffer = serializeNode('declaration', node, buffer, nodePosition + 6);
|
|
4482
|
+
return buffer;
|
|
4483
|
+
},
|
|
4484
|
+
ExportSpecifier: (node, buffer) => {
|
|
4485
|
+
const nodePosition = buffer.position;
|
|
4486
|
+
buffer = buffer.reserve(5);
|
|
4487
|
+
buffer[nodePosition] = 27;
|
|
4488
|
+
buffer[nodePosition + 1] = node.start;
|
|
4489
|
+
buffer[nodePosition + 2] = node.end;
|
|
4490
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 3);
|
|
4491
|
+
if (node.exported.end != node.local.end)
|
|
4492
|
+
buffer = serializeNode('exported', node, buffer, nodePosition + 4);
|
|
4493
|
+
return buffer;
|
|
4494
|
+
},
|
|
4495
|
+
ExpressionStatement: serializeExpressionStatementNode,
|
|
4496
|
+
ForInStatement: (node, buffer) => {
|
|
4497
|
+
const nodePosition = buffer.position;
|
|
4498
|
+
buffer = buffer.reserve(7);
|
|
4499
|
+
buffer[nodePosition] = 29;
|
|
4500
|
+
buffer[nodePosition + 1] = node.start;
|
|
4501
|
+
buffer[nodePosition + 2] = node.end;
|
|
4502
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 3);
|
|
4503
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 4);
|
|
4504
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 5);
|
|
4505
|
+
return buffer;
|
|
4506
|
+
},
|
|
4507
|
+
ForOfStatement: (node, buffer) => {
|
|
4508
|
+
const nodePosition = buffer.position;
|
|
4509
|
+
buffer = buffer.reserve(8);
|
|
4510
|
+
buffer[nodePosition] = 30;
|
|
4511
|
+
buffer[nodePosition + 1] = node.start;
|
|
4512
|
+
buffer[nodePosition + 2] = node.end;
|
|
4513
|
+
buffer[nodePosition + 3] = node.await << 0;
|
|
4514
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4515
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4516
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4517
|
+
return buffer;
|
|
4518
|
+
},
|
|
4519
|
+
ForStatement: (node, buffer) => {
|
|
4520
|
+
const nodePosition = buffer.position;
|
|
4521
|
+
buffer = buffer.reserve(8);
|
|
4522
|
+
buffer[nodePosition] = 31;
|
|
4523
|
+
buffer[nodePosition + 1] = node.start;
|
|
4524
|
+
buffer[nodePosition + 2] = node.end;
|
|
4525
|
+
if (node.init != null)
|
|
4526
|
+
buffer = serializeNode('init', node, buffer, nodePosition + 3);
|
|
4527
|
+
if (node.test != null)
|
|
4528
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 4);
|
|
4529
|
+
if (node.update != null)
|
|
4530
|
+
buffer = serializeNode('update', node, buffer, nodePosition + 5);
|
|
4531
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4532
|
+
return buffer;
|
|
4533
|
+
},
|
|
4534
|
+
FunctionDeclaration: (node, buffer) => {
|
|
4535
|
+
const nodePosition = buffer.position;
|
|
4536
|
+
buffer = buffer.reserve(9);
|
|
4537
|
+
buffer[nodePosition] = 32;
|
|
4538
|
+
buffer[nodePosition + 1] = node.start;
|
|
4539
|
+
buffer[nodePosition + 2] = node.end;
|
|
4540
|
+
buffer[nodePosition + 3] = (node.async << 0) | (node.generator << 1);
|
|
4541
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4542
|
+
if (node.id != null)
|
|
4543
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 5);
|
|
4544
|
+
buffer = serializeNodeList('params', node, buffer, nodePosition + 6);
|
|
4545
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 7);
|
|
4546
|
+
return buffer;
|
|
4547
|
+
},
|
|
4548
|
+
FunctionExpression: (node, buffer) => {
|
|
4549
|
+
const nodePosition = buffer.position;
|
|
4550
|
+
buffer = buffer.reserve(9);
|
|
4551
|
+
buffer[nodePosition] = 33;
|
|
4552
|
+
buffer[nodePosition + 1] = node.start;
|
|
4553
|
+
buffer[nodePosition + 2] = node.end;
|
|
4554
|
+
buffer[nodePosition + 3] = (node.async << 0) | (node.generator << 1);
|
|
4555
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4556
|
+
if (node.id != null)
|
|
4557
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 5);
|
|
4558
|
+
buffer = serializeNodeList('params', node, buffer, nodePosition + 6);
|
|
4559
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 7);
|
|
4560
|
+
return buffer;
|
|
4561
|
+
},
|
|
4562
|
+
Identifier: (node, buffer) => {
|
|
4563
|
+
const nodePosition = buffer.position;
|
|
4564
|
+
buffer = buffer.reserve(4);
|
|
4565
|
+
buffer[nodePosition] = 34;
|
|
4566
|
+
buffer[nodePosition + 1] = node.start;
|
|
4567
|
+
buffer[nodePosition + 2] = node.end;
|
|
4568
|
+
buffer = buffer.addStringToBuffer(node.name, nodePosition + 3);
|
|
4569
|
+
return buffer;
|
|
4570
|
+
},
|
|
4571
|
+
IfStatement: (node, buffer) => {
|
|
4572
|
+
const nodePosition = buffer.position;
|
|
4573
|
+
buffer = buffer.reserve(6);
|
|
4574
|
+
buffer[nodePosition] = 35;
|
|
4575
|
+
buffer[nodePosition + 1] = node.start;
|
|
4576
|
+
buffer[nodePosition + 2] = node.end;
|
|
4577
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
4578
|
+
buffer = serializeNode('consequent', node, buffer, nodePosition + 4);
|
|
4579
|
+
if (node.alternate != null)
|
|
4580
|
+
buffer = serializeNode('alternate', node, buffer, nodePosition + 5);
|
|
4581
|
+
return buffer;
|
|
4582
|
+
},
|
|
4583
|
+
ImportAttribute: (node, buffer) => {
|
|
4584
|
+
const nodePosition = buffer.position;
|
|
4585
|
+
buffer = buffer.reserve(5);
|
|
4586
|
+
buffer[nodePosition] = 36;
|
|
4587
|
+
buffer[nodePosition + 1] = node.start;
|
|
4588
|
+
buffer[nodePosition + 2] = node.end;
|
|
4589
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 3);
|
|
4590
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 4);
|
|
4591
|
+
return buffer;
|
|
4592
|
+
},
|
|
4593
|
+
ImportDeclaration: (node, buffer) => {
|
|
4594
|
+
const nodePosition = buffer.position;
|
|
4595
|
+
buffer = buffer.reserve(7);
|
|
4596
|
+
buffer[nodePosition] = 37;
|
|
4597
|
+
buffer[nodePosition + 1] = node.start;
|
|
4598
|
+
buffer[nodePosition + 2] = node.end;
|
|
4599
|
+
buffer = serializeNodeList('specifiers', node, buffer, nodePosition + 3);
|
|
4600
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 4);
|
|
4601
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4602
|
+
if (node.phase != null) {
|
|
4603
|
+
buffer[nodePosition + 6] = FIXED_STRING_INDICES[node.phase];
|
|
4604
|
+
}
|
|
4605
|
+
return buffer;
|
|
4606
|
+
},
|
|
4607
|
+
ImportDefaultSpecifier: (node, buffer) => {
|
|
4608
|
+
const nodePosition = buffer.position;
|
|
4609
|
+
buffer = buffer.reserve(4);
|
|
4610
|
+
buffer[nodePosition] = 38;
|
|
4611
|
+
buffer[nodePosition + 1] = node.start;
|
|
4612
|
+
buffer[nodePosition + 2] = node.end;
|
|
4613
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 3);
|
|
4614
|
+
return buffer;
|
|
4615
|
+
},
|
|
4616
|
+
ImportExpression: (node, buffer) => {
|
|
4617
|
+
const nodePosition = buffer.position;
|
|
4618
|
+
buffer = buffer.reserve(6);
|
|
4619
|
+
buffer[nodePosition] = 39;
|
|
4620
|
+
buffer[nodePosition + 1] = node.start;
|
|
4621
|
+
buffer[nodePosition + 2] = node.end;
|
|
4622
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 3);
|
|
4623
|
+
if (node.options != null)
|
|
4624
|
+
buffer = serializeNode('options', node, buffer, nodePosition + 4);
|
|
4625
|
+
if (node.phase != null) {
|
|
4626
|
+
buffer[nodePosition + 5] = FIXED_STRING_INDICES[node.phase];
|
|
4627
|
+
}
|
|
4628
|
+
return buffer;
|
|
4629
|
+
},
|
|
4630
|
+
ImportNamespaceSpecifier: (node, buffer) => {
|
|
4631
|
+
const nodePosition = buffer.position;
|
|
4632
|
+
buffer = buffer.reserve(4);
|
|
4633
|
+
buffer[nodePosition] = 40;
|
|
4634
|
+
buffer[nodePosition + 1] = node.start;
|
|
4635
|
+
buffer[nodePosition + 2] = node.end;
|
|
4636
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 3);
|
|
4637
|
+
return buffer;
|
|
4638
|
+
},
|
|
4639
|
+
ImportSpecifier: (node, buffer) => {
|
|
4640
|
+
const nodePosition = buffer.position;
|
|
4641
|
+
buffer = buffer.reserve(5);
|
|
4642
|
+
buffer[nodePosition] = 41;
|
|
4643
|
+
buffer[nodePosition + 1] = node.start;
|
|
4644
|
+
buffer[nodePosition + 2] = node.end;
|
|
4645
|
+
if (node.imported.end != node.local.end)
|
|
4646
|
+
buffer = serializeNode('imported', node, buffer, nodePosition + 3);
|
|
4647
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 4);
|
|
4648
|
+
return buffer;
|
|
4649
|
+
},
|
|
4650
|
+
JSXAttribute: (node, buffer) => {
|
|
4651
|
+
const nodePosition = buffer.position;
|
|
4652
|
+
buffer = buffer.reserve(5);
|
|
4653
|
+
buffer[nodePosition] = 42;
|
|
4654
|
+
buffer[nodePosition + 1] = node.start;
|
|
4655
|
+
buffer[nodePosition + 2] = node.end;
|
|
4656
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 3);
|
|
4657
|
+
if (node.value != null)
|
|
4658
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 4);
|
|
4659
|
+
return buffer;
|
|
4660
|
+
},
|
|
4661
|
+
JSXClosingElement: (node, buffer) => {
|
|
4662
|
+
const nodePosition = buffer.position;
|
|
4663
|
+
buffer = buffer.reserve(4);
|
|
4664
|
+
buffer[nodePosition] = 43;
|
|
4665
|
+
buffer[nodePosition + 1] = node.start;
|
|
4666
|
+
buffer[nodePosition + 2] = node.end;
|
|
4667
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 3);
|
|
4668
|
+
return buffer;
|
|
4669
|
+
},
|
|
4670
|
+
JSXClosingFragment: (node, buffer) => {
|
|
4671
|
+
const nodePosition = buffer.position;
|
|
4672
|
+
buffer = buffer.reserve(3);
|
|
4673
|
+
buffer[nodePosition] = 44;
|
|
4674
|
+
buffer[nodePosition + 1] = node.start;
|
|
4675
|
+
buffer[nodePosition + 2] = node.end;
|
|
4676
|
+
return buffer;
|
|
4677
|
+
},
|
|
4678
|
+
JSXElement: (node, buffer) => {
|
|
4679
|
+
const nodePosition = buffer.position;
|
|
4680
|
+
buffer = buffer.reserve(6);
|
|
4681
|
+
buffer[nodePosition] = 45;
|
|
4682
|
+
buffer[nodePosition + 1] = node.start;
|
|
4683
|
+
buffer[nodePosition + 2] = node.end;
|
|
4684
|
+
buffer = serializeNode('openingElement', node, buffer, nodePosition + 3);
|
|
4685
|
+
buffer = serializeNodeList('children', node, buffer, nodePosition + 4);
|
|
4686
|
+
if (node.closingElement != null)
|
|
4687
|
+
buffer = serializeNode('closingElement', node, buffer, nodePosition + 5);
|
|
4688
|
+
return buffer;
|
|
4689
|
+
},
|
|
4690
|
+
JSXEmptyExpression: (node, buffer) => {
|
|
4691
|
+
const nodePosition = buffer.position;
|
|
4692
|
+
buffer = buffer.reserve(3);
|
|
4693
|
+
buffer[nodePosition] = 46;
|
|
4694
|
+
buffer[nodePosition + 1] = node.start;
|
|
4695
|
+
buffer[nodePosition + 2] = node.end;
|
|
4696
|
+
return buffer;
|
|
4697
|
+
},
|
|
4698
|
+
JSXExpressionContainer: (node, buffer) => {
|
|
4699
|
+
const nodePosition = buffer.position;
|
|
4700
|
+
buffer = buffer.reserve(4);
|
|
4701
|
+
buffer[nodePosition] = 47;
|
|
4702
|
+
buffer[nodePosition + 1] = node.start;
|
|
4703
|
+
buffer[nodePosition + 2] = node.end;
|
|
4704
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4705
|
+
return buffer;
|
|
4706
|
+
},
|
|
4707
|
+
JSXFragment: (node, buffer) => {
|
|
4708
|
+
const nodePosition = buffer.position;
|
|
4709
|
+
buffer = buffer.reserve(6);
|
|
4710
|
+
buffer[nodePosition] = 48;
|
|
4711
|
+
buffer[nodePosition + 1] = node.start;
|
|
4712
|
+
buffer[nodePosition + 2] = node.end;
|
|
4713
|
+
buffer = serializeNode('openingFragment', node, buffer, nodePosition + 3);
|
|
4714
|
+
buffer = serializeNodeList('children', node, buffer, nodePosition + 4);
|
|
4715
|
+
buffer = serializeNode('closingFragment', node, buffer, nodePosition + 5);
|
|
4716
|
+
return buffer;
|
|
4717
|
+
},
|
|
4718
|
+
JSXIdentifier: (node, buffer) => {
|
|
4719
|
+
const nodePosition = buffer.position;
|
|
4720
|
+
buffer = buffer.reserve(4);
|
|
4721
|
+
buffer[nodePosition] = 49;
|
|
4722
|
+
buffer[nodePosition + 1] = node.start;
|
|
4723
|
+
buffer[nodePosition + 2] = node.end;
|
|
4724
|
+
buffer = buffer.addStringToBuffer(node.name, nodePosition + 3);
|
|
4725
|
+
return buffer;
|
|
4726
|
+
},
|
|
4727
|
+
JSXMemberExpression: (node, buffer) => {
|
|
4728
|
+
const nodePosition = buffer.position;
|
|
4729
|
+
buffer = buffer.reserve(5);
|
|
4730
|
+
buffer[nodePosition] = 50;
|
|
4731
|
+
buffer[nodePosition + 1] = node.start;
|
|
4732
|
+
buffer[nodePosition + 2] = node.end;
|
|
4733
|
+
buffer = serializeNode('object', node, buffer, nodePosition + 3);
|
|
4734
|
+
buffer = serializeNode('property', node, buffer, nodePosition + 4);
|
|
4735
|
+
return buffer;
|
|
4736
|
+
},
|
|
4737
|
+
JSXNamespacedName: (node, buffer) => {
|
|
4738
|
+
const nodePosition = buffer.position;
|
|
4739
|
+
buffer = buffer.reserve(5);
|
|
4740
|
+
buffer[nodePosition] = 51;
|
|
4741
|
+
buffer[nodePosition + 1] = node.start;
|
|
4742
|
+
buffer[nodePosition + 2] = node.end;
|
|
4743
|
+
buffer = serializeNode('namespace', node, buffer, nodePosition + 3);
|
|
4744
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 4);
|
|
4745
|
+
return buffer;
|
|
4746
|
+
},
|
|
4747
|
+
JSXOpeningElement: (node, buffer) => {
|
|
4748
|
+
const nodePosition = buffer.position;
|
|
4749
|
+
buffer = buffer.reserve(6);
|
|
4750
|
+
buffer[nodePosition] = 52;
|
|
4751
|
+
buffer[nodePosition + 1] = node.start;
|
|
4752
|
+
buffer[nodePosition + 2] = node.end;
|
|
4753
|
+
buffer[nodePosition + 3] = node.selfClosing << 0;
|
|
4754
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 4);
|
|
4755
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4756
|
+
return buffer;
|
|
4757
|
+
},
|
|
4758
|
+
JSXOpeningFragment: (node, buffer) => {
|
|
4759
|
+
const nodePosition = buffer.position;
|
|
4760
|
+
buffer = buffer.reserve(3);
|
|
4761
|
+
buffer[nodePosition] = 53;
|
|
4762
|
+
buffer[nodePosition + 1] = node.start;
|
|
4763
|
+
buffer[nodePosition + 2] = node.end;
|
|
4764
|
+
return buffer;
|
|
4765
|
+
},
|
|
4766
|
+
JSXSpreadAttribute: (node, buffer) => {
|
|
4767
|
+
const nodePosition = buffer.position;
|
|
4768
|
+
buffer = buffer.reserve(4);
|
|
4769
|
+
buffer[nodePosition] = 54;
|
|
4770
|
+
buffer[nodePosition + 1] = node.start;
|
|
4771
|
+
buffer[nodePosition + 2] = node.end;
|
|
4772
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4773
|
+
return buffer;
|
|
4774
|
+
},
|
|
4775
|
+
JSXSpreadChild: (node, buffer) => {
|
|
4776
|
+
const nodePosition = buffer.position;
|
|
4777
|
+
buffer = buffer.reserve(4);
|
|
4778
|
+
buffer[nodePosition] = 55;
|
|
4779
|
+
buffer[nodePosition + 1] = node.start;
|
|
4780
|
+
buffer[nodePosition + 2] = node.end;
|
|
4781
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4782
|
+
return buffer;
|
|
4783
|
+
},
|
|
4784
|
+
JSXText: (node, buffer) => {
|
|
4785
|
+
const nodePosition = buffer.position;
|
|
4786
|
+
buffer = buffer.reserve(5);
|
|
4787
|
+
buffer[nodePosition] = 56;
|
|
4788
|
+
buffer[nodePosition + 1] = node.start;
|
|
4789
|
+
buffer[nodePosition + 2] = node.end;
|
|
4790
|
+
buffer = buffer.addStringToBuffer(node.value, nodePosition + 3);
|
|
4791
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 4);
|
|
4792
|
+
return buffer;
|
|
4793
|
+
},
|
|
4794
|
+
LabeledStatement: (node, buffer) => {
|
|
4795
|
+
const nodePosition = buffer.position;
|
|
4796
|
+
buffer = buffer.reserve(5);
|
|
4797
|
+
buffer[nodePosition] = 57;
|
|
4798
|
+
buffer[nodePosition + 1] = node.start;
|
|
4799
|
+
buffer[nodePosition + 2] = node.end;
|
|
4800
|
+
buffer = serializeNode('label', node, buffer, nodePosition + 3);
|
|
4801
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 4);
|
|
4802
|
+
return buffer;
|
|
4803
|
+
},
|
|
4804
|
+
Literal: serializeLiteralNode,
|
|
4805
|
+
LogicalExpression: (node, buffer) => {
|
|
4806
|
+
const nodePosition = buffer.position;
|
|
4807
|
+
buffer = buffer.reserve(6);
|
|
4808
|
+
buffer[nodePosition] = 64;
|
|
4809
|
+
buffer[nodePosition + 1] = node.start;
|
|
4810
|
+
buffer[nodePosition + 2] = node.end;
|
|
4811
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
4812
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4813
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4814
|
+
return buffer;
|
|
4815
|
+
},
|
|
4816
|
+
MemberExpression: (node, buffer) => {
|
|
4817
|
+
const nodePosition = buffer.position;
|
|
4818
|
+
buffer = buffer.reserve(6);
|
|
4819
|
+
buffer[nodePosition] = 65;
|
|
4820
|
+
buffer[nodePosition + 1] = node.start;
|
|
4821
|
+
buffer[nodePosition + 2] = node.end;
|
|
4822
|
+
buffer[nodePosition + 3] = (node.computed << 0) | (node.optional << 1);
|
|
4823
|
+
buffer = serializeNode('object', node, buffer, nodePosition + 4);
|
|
4824
|
+
buffer = serializeNode('property', node, buffer, nodePosition + 5);
|
|
4825
|
+
return buffer;
|
|
4826
|
+
},
|
|
4827
|
+
MetaProperty: (node, buffer) => {
|
|
4828
|
+
const nodePosition = buffer.position;
|
|
4829
|
+
buffer = buffer.reserve(5);
|
|
4830
|
+
buffer[nodePosition] = 66;
|
|
4831
|
+
buffer[nodePosition + 1] = node.start;
|
|
4832
|
+
buffer[nodePosition + 2] = node.end;
|
|
4833
|
+
buffer = serializeNode('meta', node, buffer, nodePosition + 3);
|
|
4834
|
+
buffer = serializeNode('property', node, buffer, nodePosition + 4);
|
|
4835
|
+
return buffer;
|
|
4836
|
+
},
|
|
4837
|
+
MethodDefinition: (node, buffer) => {
|
|
4838
|
+
const nodePosition = buffer.position;
|
|
4839
|
+
buffer = buffer.reserve(8);
|
|
4840
|
+
buffer[nodePosition] = 67;
|
|
4841
|
+
buffer[nodePosition + 1] = node.start;
|
|
4842
|
+
buffer[nodePosition + 2] = node.end;
|
|
4843
|
+
buffer[nodePosition + 3] = (node.static << 0) | (node.computed << 1);
|
|
4844
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 4);
|
|
4845
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 5);
|
|
4846
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 6);
|
|
4847
|
+
buffer[nodePosition + 7] = FIXED_STRING_INDICES[node.kind];
|
|
4848
|
+
return buffer;
|
|
4849
|
+
},
|
|
4850
|
+
NewExpression: (node, buffer) => {
|
|
4851
|
+
const nodePosition = buffer.position;
|
|
4852
|
+
buffer = buffer.reserve(6);
|
|
4853
|
+
buffer[nodePosition] = 68;
|
|
4854
|
+
buffer[nodePosition + 1] = node.start;
|
|
4855
|
+
buffer[nodePosition + 2] = node.end;
|
|
4856
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 3);
|
|
4857
|
+
buffer = serializeNode('callee', node, buffer, nodePosition + 4);
|
|
4858
|
+
buffer = serializeNodeList('arguments', node, buffer, nodePosition + 5);
|
|
4859
|
+
return buffer;
|
|
4860
|
+
},
|
|
4861
|
+
ObjectExpression: (node, buffer) => {
|
|
4862
|
+
const nodePosition = buffer.position;
|
|
4863
|
+
buffer = buffer.reserve(4);
|
|
4864
|
+
buffer[nodePosition] = 69;
|
|
4865
|
+
buffer[nodePosition + 1] = node.start;
|
|
4866
|
+
buffer[nodePosition + 2] = node.end;
|
|
4867
|
+
buffer = serializeNodeList('properties', node, buffer, nodePosition + 3);
|
|
4868
|
+
return buffer;
|
|
4869
|
+
},
|
|
4870
|
+
ObjectPattern: (node, buffer) => {
|
|
4871
|
+
const nodePosition = buffer.position;
|
|
4872
|
+
buffer = buffer.reserve(4);
|
|
4873
|
+
buffer[nodePosition] = 70;
|
|
4874
|
+
buffer[nodePosition + 1] = node.start;
|
|
4875
|
+
buffer[nodePosition + 2] = node.end;
|
|
4876
|
+
buffer = serializeNodeList('properties', node, buffer, nodePosition + 3);
|
|
4877
|
+
return buffer;
|
|
4878
|
+
},
|
|
4879
|
+
PanicError: (node, buffer) => {
|
|
4880
|
+
const nodePosition = buffer.position;
|
|
4881
|
+
buffer = buffer.reserve(4);
|
|
4882
|
+
buffer[nodePosition] = 0;
|
|
4883
|
+
buffer[nodePosition + 1] = node.start;
|
|
4884
|
+
buffer[nodePosition + 2] = node.end;
|
|
4885
|
+
buffer = buffer.addStringToBuffer(node.message, nodePosition + 3);
|
|
4886
|
+
return buffer;
|
|
4887
|
+
},
|
|
4888
|
+
ParseError: (node, buffer) => {
|
|
4889
|
+
const nodePosition = buffer.position;
|
|
4890
|
+
buffer = buffer.reserve(4);
|
|
4891
|
+
buffer[nodePosition] = 1;
|
|
4892
|
+
buffer[nodePosition + 1] = node.start;
|
|
4893
|
+
buffer[nodePosition + 2] = node.end;
|
|
4894
|
+
buffer = buffer.addStringToBuffer(node.message, nodePosition + 3);
|
|
4895
|
+
return buffer;
|
|
4896
|
+
},
|
|
4897
|
+
PrivateIdentifier: (node, buffer) => {
|
|
4898
|
+
const nodePosition = buffer.position;
|
|
4899
|
+
buffer = buffer.reserve(4);
|
|
4900
|
+
buffer[nodePosition] = 71;
|
|
4901
|
+
buffer[nodePosition + 1] = node.start;
|
|
4902
|
+
buffer[nodePosition + 2] = node.end;
|
|
4903
|
+
buffer = buffer.addStringToBuffer(node.name, nodePosition + 3);
|
|
4904
|
+
return buffer;
|
|
4905
|
+
},
|
|
4906
|
+
Program: (node, buffer) => {
|
|
4907
|
+
const nodePosition = buffer.position;
|
|
4908
|
+
buffer = buffer.reserve(6);
|
|
4909
|
+
buffer[nodePosition] = 72;
|
|
4910
|
+
buffer[nodePosition + 1] = node.start;
|
|
4911
|
+
buffer[nodePosition + 2] = node.end;
|
|
4912
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
4913
|
+
buffer = serializeAnnotations(node.invalidAnnotations, buffer, nodePosition + 4);
|
|
4914
|
+
return buffer;
|
|
4915
|
+
},
|
|
4916
|
+
Property: (node, buffer) => {
|
|
4917
|
+
const nodePosition = buffer.position;
|
|
4918
|
+
buffer = buffer.reserve(7);
|
|
4919
|
+
buffer[nodePosition] = 73;
|
|
4920
|
+
buffer[nodePosition + 1] = node.start;
|
|
4921
|
+
buffer[nodePosition + 2] = node.end;
|
|
4922
|
+
buffer[nodePosition + 3] =
|
|
4923
|
+
(node.method << 0) | (node.shorthand << 1) | (node.computed << 2);
|
|
4924
|
+
if (node.key.end != node.value.end)
|
|
4925
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 4);
|
|
4926
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 5);
|
|
4927
|
+
buffer[nodePosition + 6] = FIXED_STRING_INDICES[node.kind];
|
|
4928
|
+
return buffer;
|
|
4929
|
+
},
|
|
4930
|
+
PropertyDefinition: (node, buffer) => {
|
|
4931
|
+
const nodePosition = buffer.position;
|
|
4932
|
+
buffer = buffer.reserve(7);
|
|
4933
|
+
buffer[nodePosition] = 74;
|
|
4934
|
+
buffer[nodePosition + 1] = node.start;
|
|
4935
|
+
buffer[nodePosition + 2] = node.end;
|
|
4936
|
+
buffer[nodePosition + 3] = (node.static << 0) | (node.computed << 1);
|
|
4937
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 4);
|
|
4938
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 5);
|
|
4939
|
+
if (node.value != null)
|
|
4940
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 6);
|
|
4941
|
+
return buffer;
|
|
4942
|
+
},
|
|
4943
|
+
RestElement: (node, buffer) => {
|
|
4944
|
+
const nodePosition = buffer.position;
|
|
4945
|
+
buffer = buffer.reserve(4);
|
|
4946
|
+
buffer[nodePosition] = 75;
|
|
4947
|
+
buffer[nodePosition + 1] = node.start;
|
|
4948
|
+
buffer[nodePosition + 2] = node.end;
|
|
4949
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4950
|
+
return buffer;
|
|
4951
|
+
},
|
|
4952
|
+
ReturnStatement: (node, buffer) => {
|
|
4953
|
+
const nodePosition = buffer.position;
|
|
4954
|
+
buffer = buffer.reserve(4);
|
|
4955
|
+
buffer[nodePosition] = 76;
|
|
4956
|
+
buffer[nodePosition + 1] = node.start;
|
|
4957
|
+
buffer[nodePosition + 2] = node.end;
|
|
4958
|
+
if (node.argument != null)
|
|
4959
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4960
|
+
return buffer;
|
|
4961
|
+
},
|
|
4962
|
+
SequenceExpression: (node, buffer) => {
|
|
4963
|
+
const nodePosition = buffer.position;
|
|
4964
|
+
buffer = buffer.reserve(4);
|
|
4965
|
+
buffer[nodePosition] = 77;
|
|
4966
|
+
buffer[nodePosition + 1] = node.start;
|
|
4967
|
+
buffer[nodePosition + 2] = node.end;
|
|
4968
|
+
buffer = serializeNodeList('expressions', node, buffer, nodePosition + 3);
|
|
4969
|
+
return buffer;
|
|
4970
|
+
},
|
|
4971
|
+
SpreadElement: (node, buffer) => {
|
|
4972
|
+
const nodePosition = buffer.position;
|
|
4973
|
+
buffer = buffer.reserve(4);
|
|
4974
|
+
buffer[nodePosition] = 78;
|
|
4975
|
+
buffer[nodePosition + 1] = node.start;
|
|
4976
|
+
buffer[nodePosition + 2] = node.end;
|
|
4977
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4978
|
+
return buffer;
|
|
4979
|
+
},
|
|
4980
|
+
StaticBlock: (node, buffer) => {
|
|
4981
|
+
const nodePosition = buffer.position;
|
|
4982
|
+
buffer = buffer.reserve(5);
|
|
4983
|
+
buffer[nodePosition] = 79;
|
|
4984
|
+
buffer[nodePosition + 1] = node.start;
|
|
4985
|
+
buffer[nodePosition + 2] = node.end;
|
|
4986
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
4987
|
+
return buffer;
|
|
4988
|
+
},
|
|
4989
|
+
Super: (node, buffer) => {
|
|
4990
|
+
const nodePosition = buffer.position;
|
|
4991
|
+
buffer = buffer.reserve(3);
|
|
4992
|
+
buffer[nodePosition] = 80;
|
|
4993
|
+
buffer[nodePosition + 1] = node.start;
|
|
4994
|
+
buffer[nodePosition + 2] = node.end;
|
|
4995
|
+
return buffer;
|
|
4996
|
+
},
|
|
4997
|
+
SwitchCase: (node, buffer) => {
|
|
4998
|
+
const nodePosition = buffer.position;
|
|
4999
|
+
buffer = buffer.reserve(5);
|
|
5000
|
+
buffer[nodePosition] = 81;
|
|
5001
|
+
buffer[nodePosition + 1] = node.start;
|
|
5002
|
+
buffer[nodePosition + 2] = node.end;
|
|
5003
|
+
if (node.test != null)
|
|
5004
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
5005
|
+
buffer = serializeNodeList('consequent', node, buffer, nodePosition + 4);
|
|
5006
|
+
return buffer;
|
|
5007
|
+
},
|
|
5008
|
+
SwitchStatement: (node, buffer) => {
|
|
5009
|
+
const nodePosition = buffer.position;
|
|
5010
|
+
buffer = buffer.reserve(6);
|
|
5011
|
+
buffer[nodePosition] = 82;
|
|
5012
|
+
buffer[nodePosition + 1] = node.start;
|
|
5013
|
+
buffer[nodePosition + 2] = node.end;
|
|
5014
|
+
buffer = serializeNode('discriminant', node, buffer, nodePosition + 3);
|
|
5015
|
+
buffer = serializeNodeList('cases', node, buffer, nodePosition + 4);
|
|
5016
|
+
return buffer;
|
|
5017
|
+
},
|
|
5018
|
+
TaggedTemplateExpression: (node, buffer) => {
|
|
5019
|
+
const nodePosition = buffer.position;
|
|
5020
|
+
buffer = buffer.reserve(5);
|
|
5021
|
+
buffer[nodePosition] = 83;
|
|
5022
|
+
buffer[nodePosition + 1] = node.start;
|
|
5023
|
+
buffer[nodePosition + 2] = node.end;
|
|
5024
|
+
buffer = serializeNode('tag', node, buffer, nodePosition + 3);
|
|
5025
|
+
buffer = serializeNode('quasi', node, buffer, nodePosition + 4);
|
|
5026
|
+
return buffer;
|
|
5027
|
+
},
|
|
5028
|
+
TemplateElement: (node, buffer) => {
|
|
5029
|
+
const nodePosition = buffer.position;
|
|
5030
|
+
buffer = buffer.reserve(6);
|
|
5031
|
+
buffer[nodePosition] = 84;
|
|
5032
|
+
buffer[nodePosition + 1] = node.start;
|
|
5033
|
+
buffer[nodePosition + 2] = node.end;
|
|
5034
|
+
buffer[nodePosition + 3] = node.tail << 0;
|
|
5035
|
+
if (node.value.cooked != null) {
|
|
5036
|
+
buffer = buffer.addStringToBuffer(node.value.cooked, nodePosition + 4);
|
|
5037
|
+
}
|
|
5038
|
+
buffer = buffer.addStringToBuffer(node.value.raw, nodePosition + 5);
|
|
5039
|
+
return buffer;
|
|
5040
|
+
},
|
|
5041
|
+
TemplateLiteral: (node, buffer) => {
|
|
5042
|
+
const nodePosition = buffer.position;
|
|
5043
|
+
buffer = buffer.reserve(5);
|
|
5044
|
+
buffer[nodePosition] = 85;
|
|
5045
|
+
buffer[nodePosition + 1] = node.start;
|
|
5046
|
+
buffer[nodePosition + 2] = node.end;
|
|
5047
|
+
buffer = serializeNodeList('quasis', node, buffer, nodePosition + 3);
|
|
5048
|
+
buffer = serializeNodeList('expressions', node, buffer, nodePosition + 4);
|
|
5049
|
+
return buffer;
|
|
5050
|
+
},
|
|
5051
|
+
ThisExpression: (node, buffer) => {
|
|
5052
|
+
const nodePosition = buffer.position;
|
|
5053
|
+
buffer = buffer.reserve(3);
|
|
5054
|
+
buffer[nodePosition] = 86;
|
|
5055
|
+
buffer[nodePosition + 1] = node.start;
|
|
5056
|
+
buffer[nodePosition + 2] = node.end;
|
|
5057
|
+
return buffer;
|
|
5058
|
+
},
|
|
5059
|
+
ThrowStatement: (node, buffer) => {
|
|
5060
|
+
const nodePosition = buffer.position;
|
|
5061
|
+
buffer = buffer.reserve(4);
|
|
5062
|
+
buffer[nodePosition] = 87;
|
|
5063
|
+
buffer[nodePosition + 1] = node.start;
|
|
5064
|
+
buffer[nodePosition + 2] = node.end;
|
|
5065
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
5066
|
+
return buffer;
|
|
5067
|
+
},
|
|
5068
|
+
TryStatement: (node, buffer) => {
|
|
5069
|
+
const nodePosition = buffer.position;
|
|
5070
|
+
buffer = buffer.reserve(6);
|
|
5071
|
+
buffer[nodePosition] = 88;
|
|
5072
|
+
buffer[nodePosition + 1] = node.start;
|
|
5073
|
+
buffer[nodePosition + 2] = node.end;
|
|
5074
|
+
buffer = serializeNode('block', node, buffer, nodePosition + 3);
|
|
5075
|
+
if (node.handler != null)
|
|
5076
|
+
buffer = serializeNode('handler', node, buffer, nodePosition + 4);
|
|
5077
|
+
if (node.finalizer != null)
|
|
5078
|
+
buffer = serializeNode('finalizer', node, buffer, nodePosition + 5);
|
|
5079
|
+
return buffer;
|
|
5080
|
+
},
|
|
5081
|
+
UnaryExpression: (node, buffer) => {
|
|
5082
|
+
const nodePosition = buffer.position;
|
|
5083
|
+
buffer = buffer.reserve(5);
|
|
5084
|
+
buffer[nodePosition] = 89;
|
|
5085
|
+
buffer[nodePosition + 1] = node.start;
|
|
5086
|
+
buffer[nodePosition + 2] = node.end;
|
|
5087
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
5088
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 4);
|
|
5089
|
+
return buffer;
|
|
5090
|
+
},
|
|
5091
|
+
UpdateExpression: (node, buffer) => {
|
|
5092
|
+
const nodePosition = buffer.position;
|
|
5093
|
+
buffer = buffer.reserve(6);
|
|
5094
|
+
buffer[nodePosition] = 90;
|
|
5095
|
+
buffer[nodePosition + 1] = node.start;
|
|
5096
|
+
buffer[nodePosition + 2] = node.end;
|
|
5097
|
+
buffer[nodePosition + 3] = node.prefix << 0;
|
|
5098
|
+
buffer[nodePosition + 4] = FIXED_STRING_INDICES[node.operator];
|
|
5099
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 5);
|
|
5100
|
+
return buffer;
|
|
5101
|
+
},
|
|
5102
|
+
VariableDeclaration: (node, buffer) => {
|
|
5103
|
+
const nodePosition = buffer.position;
|
|
5104
|
+
buffer = buffer.reserve(5);
|
|
5105
|
+
buffer[nodePosition] = 91;
|
|
5106
|
+
buffer[nodePosition + 1] = node.start;
|
|
5107
|
+
buffer[nodePosition + 2] = node.end;
|
|
5108
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.kind];
|
|
5109
|
+
buffer = serializeNodeList('declarations', node, buffer, nodePosition + 4);
|
|
5110
|
+
return buffer;
|
|
5111
|
+
},
|
|
5112
|
+
VariableDeclarator: (node, buffer) => {
|
|
5113
|
+
const nodePosition = buffer.position;
|
|
5114
|
+
buffer = buffer.reserve(5);
|
|
5115
|
+
buffer[nodePosition] = 92;
|
|
5116
|
+
buffer[nodePosition + 1] = node.start;
|
|
5117
|
+
buffer[nodePosition + 2] = node.end;
|
|
5118
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 3);
|
|
5119
|
+
if (node.init != null)
|
|
5120
|
+
buffer = serializeNode('init', node, buffer, nodePosition + 4);
|
|
5121
|
+
return buffer;
|
|
5122
|
+
},
|
|
5123
|
+
WhileStatement: (node, buffer) => {
|
|
5124
|
+
const nodePosition = buffer.position;
|
|
5125
|
+
buffer = buffer.reserve(5);
|
|
5126
|
+
buffer[nodePosition] = 93;
|
|
5127
|
+
buffer[nodePosition + 1] = node.start;
|
|
5128
|
+
buffer[nodePosition + 2] = node.end;
|
|
5129
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
5130
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 4);
|
|
5131
|
+
return buffer;
|
|
5132
|
+
},
|
|
5133
|
+
YieldExpression: (node, buffer) => {
|
|
5134
|
+
const nodePosition = buffer.position;
|
|
5135
|
+
buffer = buffer.reserve(5);
|
|
5136
|
+
buffer[nodePosition] = 94;
|
|
5137
|
+
buffer[nodePosition + 1] = node.start;
|
|
5138
|
+
buffer[nodePosition + 2] = node.end;
|
|
5139
|
+
buffer[nodePosition + 3] = node.delegate << 0;
|
|
5140
|
+
if (node.argument != null)
|
|
5141
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 4);
|
|
5142
|
+
return buffer;
|
|
5143
|
+
}
|
|
5144
|
+
};
|
|
5145
|
+
const serializeDirective = (node, buffer) => {
|
|
5146
|
+
const nodePosition = buffer.position;
|
|
5147
|
+
buffer = buffer.reserve(5);
|
|
5148
|
+
buffer[nodePosition] = 21;
|
|
5149
|
+
buffer[nodePosition + 1] = node.start;
|
|
5150
|
+
buffer[nodePosition + 2] = node.end;
|
|
5151
|
+
buffer = buffer.addStringToBuffer(node.directive, nodePosition + 3);
|
|
5152
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 4);
|
|
5153
|
+
return buffer;
|
|
5154
|
+
};
|
|
5155
|
+
const serializeExpressionStatement = (node, buffer) => {
|
|
5156
|
+
const nodePosition = buffer.position;
|
|
5157
|
+
buffer = buffer.reserve(4);
|
|
5158
|
+
buffer[nodePosition] = 28;
|
|
5159
|
+
buffer[nodePosition + 1] = node.start;
|
|
5160
|
+
buffer[nodePosition + 2] = node.end;
|
|
5161
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
5162
|
+
return buffer;
|
|
5163
|
+
};
|
|
5164
|
+
const serializeLiteralBigInt = (node, buffer) => {
|
|
5165
|
+
const nodePosition = buffer.position;
|
|
5166
|
+
buffer = buffer.reserve(5);
|
|
5167
|
+
buffer[nodePosition] = 58;
|
|
5168
|
+
buffer[nodePosition + 1] = node.start;
|
|
5169
|
+
buffer[nodePosition + 2] = node.end;
|
|
5170
|
+
buffer = buffer.addStringToBuffer(node.bigint, nodePosition + 3);
|
|
5171
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 4);
|
|
5172
|
+
return buffer;
|
|
5173
|
+
};
|
|
5174
|
+
const serializeLiteralBoolean = (node, buffer) => {
|
|
5175
|
+
const nodePosition = buffer.position;
|
|
5176
|
+
buffer = buffer.reserve(4);
|
|
5177
|
+
buffer[nodePosition] = 59;
|
|
5178
|
+
buffer[nodePosition + 1] = node.start;
|
|
5179
|
+
buffer[nodePosition + 2] = node.end;
|
|
5180
|
+
buffer[nodePosition + 3] = node.value << 0;
|
|
5181
|
+
return buffer;
|
|
5182
|
+
};
|
|
5183
|
+
const serializeLiteralNull = (node, buffer) => {
|
|
5184
|
+
const nodePosition = buffer.position;
|
|
5185
|
+
buffer = buffer.reserve(3);
|
|
5186
|
+
buffer[nodePosition] = 60;
|
|
5187
|
+
buffer[nodePosition + 1] = node.start;
|
|
5188
|
+
buffer[nodePosition + 2] = node.end;
|
|
5189
|
+
return buffer;
|
|
5190
|
+
};
|
|
5191
|
+
const serializeLiteralNumber = (node, buffer) => {
|
|
5192
|
+
const nodePosition = buffer.position;
|
|
5193
|
+
buffer = buffer.reserve(6);
|
|
5194
|
+
buffer[nodePosition] = 61;
|
|
5195
|
+
buffer[nodePosition + 1] = node.start;
|
|
5196
|
+
buffer[nodePosition + 2] = node.end;
|
|
5197
|
+
if (node.raw != null) {
|
|
5198
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 3);
|
|
5199
|
+
}
|
|
5200
|
+
buffer.writeFloat64(node.value, nodePosition + 4);
|
|
5201
|
+
return buffer;
|
|
5202
|
+
};
|
|
5203
|
+
const serializeLiteralRegExp = (node, buffer) => {
|
|
5204
|
+
const nodePosition = buffer.position;
|
|
5205
|
+
buffer = buffer.reserve(5);
|
|
5206
|
+
buffer[nodePosition] = 62;
|
|
5207
|
+
buffer[nodePosition + 1] = node.start;
|
|
5208
|
+
buffer[nodePosition + 2] = node.end;
|
|
5209
|
+
buffer = buffer.addStringToBuffer(node.regex.flags, nodePosition + 3);
|
|
5210
|
+
buffer = buffer.addStringToBuffer(node.regex.pattern, nodePosition + 4);
|
|
5211
|
+
return buffer;
|
|
5212
|
+
};
|
|
5213
|
+
const serializeLiteralString = (node, buffer) => {
|
|
5214
|
+
const nodePosition = buffer.position;
|
|
5215
|
+
buffer = buffer.reserve(5);
|
|
5216
|
+
buffer[nodePosition] = 63;
|
|
5217
|
+
buffer[nodePosition + 1] = node.start;
|
|
5218
|
+
buffer[nodePosition + 2] = node.end;
|
|
5219
|
+
buffer = buffer.addStringToBuffer(node.value, nodePosition + 3);
|
|
5220
|
+
if (node.raw != null) {
|
|
5221
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 4);
|
|
5222
|
+
}
|
|
5223
|
+
return buffer;
|
|
5224
|
+
};
|
|
5225
|
+
function serializeNode(field, parent, buffer, referencePosition) {
|
|
5226
|
+
buffer[referencePosition] = buffer.position;
|
|
5227
|
+
const node = parent[field];
|
|
5228
|
+
return (nodeSerializers[node.type] || error(logUnknownNodeType(node.type, parent.type, field)))(node, buffer);
|
|
5229
|
+
}
|
|
5230
|
+
function serializeNodeList(field, parent, buffer, referencePosition) {
|
|
5231
|
+
const nodes = parent[field];
|
|
5232
|
+
if (nodes == null) {
|
|
5233
|
+
return buffer;
|
|
5234
|
+
}
|
|
5235
|
+
const { length } = nodes;
|
|
5236
|
+
if (length === 0) {
|
|
5237
|
+
return buffer;
|
|
5238
|
+
}
|
|
5239
|
+
if (length == null) {
|
|
5240
|
+
return error(logExpectedNodeList(parent.type, field, parent[field]));
|
|
5241
|
+
}
|
|
5242
|
+
let insertPosition = buffer.position;
|
|
5243
|
+
buffer = buffer.reserve(length + 1);
|
|
5244
|
+
buffer[referencePosition] = insertPosition;
|
|
5245
|
+
buffer[insertPosition] = length;
|
|
5246
|
+
insertPosition++;
|
|
5247
|
+
for (let index = 0; index < length; index++) {
|
|
5248
|
+
const node = nodes[index];
|
|
5249
|
+
if (node != null) {
|
|
5250
|
+
buffer[insertPosition + index] = buffer.position;
|
|
5251
|
+
buffer = (nodeSerializers[node.type] || error(logUnknownNodeType(node.type, parent.type, field)))(node, buffer);
|
|
5252
|
+
}
|
|
5253
|
+
}
|
|
5254
|
+
return buffer;
|
|
5255
|
+
}
|
|
5256
|
+
function serializeAnnotations(annotations, buffer, referencePosition) {
|
|
5257
|
+
if (!annotations?.length) {
|
|
5258
|
+
return buffer;
|
|
5259
|
+
}
|
|
5260
|
+
const { length } = annotations;
|
|
5261
|
+
let insertPosition = buffer.position;
|
|
5262
|
+
buffer = buffer.reserve(length + 1);
|
|
5263
|
+
buffer[referencePosition] = insertPosition;
|
|
5264
|
+
buffer[insertPosition] = length;
|
|
5265
|
+
insertPosition++;
|
|
5266
|
+
for (let index = 0; index < length; index++) {
|
|
5267
|
+
const annotation = annotations[index];
|
|
5268
|
+
const annotationPosition = buffer.position;
|
|
5269
|
+
buffer = buffer.reserve(3); // 3 for start, end, type
|
|
5270
|
+
buffer[insertPosition + index] = annotationPosition;
|
|
5271
|
+
buffer[annotationPosition] = annotation.start;
|
|
5272
|
+
buffer[annotationPosition + 1] = annotation.end;
|
|
5273
|
+
buffer[annotationPosition + 2] = FIXED_STRING_INDICES[annotation.type];
|
|
5274
|
+
}
|
|
5275
|
+
return buffer;
|
|
5276
|
+
}
|
|
5277
|
+
|
|
5278
|
+
// This file is generated by scripts/generate-node-ids.ts.
|
|
5279
|
+
// Do not edit this file directly.
|
|
5280
|
+
const nodeIds = {
|
|
5281
|
+
ArrayExpression: [2],
|
|
5282
|
+
ArrayPattern: [3],
|
|
5283
|
+
ArrowFunctionExpression: [4],
|
|
5284
|
+
AssignmentExpression: [5],
|
|
5285
|
+
AssignmentPattern: [6],
|
|
5286
|
+
AwaitExpression: [7],
|
|
5287
|
+
BinaryExpression: [8],
|
|
5288
|
+
BlockStatement: [9],
|
|
5289
|
+
BreakStatement: [10],
|
|
5290
|
+
CallExpression: [11],
|
|
5291
|
+
CatchClause: [12],
|
|
5292
|
+
ChainExpression: [13],
|
|
5293
|
+
ClassBody: [14],
|
|
5294
|
+
ClassDeclaration: [15],
|
|
5295
|
+
ClassExpression: [16],
|
|
5296
|
+
ConditionalExpression: [17],
|
|
5297
|
+
ContinueStatement: [18],
|
|
5298
|
+
DebuggerStatement: [19],
|
|
5299
|
+
Decorator: [20],
|
|
5300
|
+
DoWhileStatement: [22],
|
|
5301
|
+
EmptyStatement: [23],
|
|
5302
|
+
ExportAllDeclaration: [24],
|
|
5303
|
+
ExportDefaultDeclaration: [25],
|
|
5304
|
+
ExportNamedDeclaration: [26],
|
|
5305
|
+
ExportSpecifier: [27],
|
|
5306
|
+
ExpressionStatement: [21, 28],
|
|
5307
|
+
ForInStatement: [29],
|
|
5308
|
+
ForOfStatement: [30],
|
|
5309
|
+
ForStatement: [31],
|
|
5310
|
+
FunctionDeclaration: [32],
|
|
5311
|
+
FunctionExpression: [33],
|
|
5312
|
+
Identifier: [34],
|
|
5313
|
+
IfStatement: [35],
|
|
5314
|
+
ImportAttribute: [36],
|
|
5315
|
+
ImportDeclaration: [37],
|
|
5316
|
+
ImportDefaultSpecifier: [38],
|
|
5317
|
+
ImportExpression: [39],
|
|
5318
|
+
ImportNamespaceSpecifier: [40],
|
|
5319
|
+
ImportSpecifier: [41],
|
|
5320
|
+
JSXAttribute: [42],
|
|
5321
|
+
JSXClosingElement: [43],
|
|
5322
|
+
JSXClosingFragment: [44],
|
|
5323
|
+
JSXElement: [45],
|
|
5324
|
+
JSXEmptyExpression: [46],
|
|
5325
|
+
JSXExpressionContainer: [47],
|
|
5326
|
+
JSXFragment: [48],
|
|
5327
|
+
JSXIdentifier: [49],
|
|
5328
|
+
JSXMemberExpression: [50],
|
|
5329
|
+
JSXNamespacedName: [51],
|
|
5330
|
+
JSXOpeningElement: [52],
|
|
5331
|
+
JSXOpeningFragment: [53],
|
|
5332
|
+
JSXSpreadAttribute: [54],
|
|
5333
|
+
JSXSpreadChild: [55],
|
|
5334
|
+
JSXText: [56],
|
|
5335
|
+
LabeledStatement: [57],
|
|
5336
|
+
Literal: [58, 59, 60, 61, 62, 63],
|
|
5337
|
+
LogicalExpression: [64],
|
|
5338
|
+
MemberExpression: [65],
|
|
5339
|
+
MetaProperty: [66],
|
|
5340
|
+
MethodDefinition: [67],
|
|
5341
|
+
NewExpression: [68],
|
|
5342
|
+
ObjectExpression: [69],
|
|
5343
|
+
ObjectPattern: [70],
|
|
5344
|
+
PanicError: [0],
|
|
5345
|
+
ParseError: [1],
|
|
5346
|
+
PrivateIdentifier: [71],
|
|
5347
|
+
Program: [72],
|
|
5348
|
+
Property: [73],
|
|
5349
|
+
PropertyDefinition: [74],
|
|
5350
|
+
RestElement: [75],
|
|
5351
|
+
ReturnStatement: [76],
|
|
5352
|
+
SequenceExpression: [77],
|
|
5353
|
+
SpreadElement: [78],
|
|
5354
|
+
StaticBlock: [79],
|
|
5355
|
+
Super: [80],
|
|
5356
|
+
SwitchCase: [81],
|
|
5357
|
+
SwitchStatement: [82],
|
|
5358
|
+
TaggedTemplateExpression: [83],
|
|
5359
|
+
TemplateElement: [84],
|
|
5360
|
+
TemplateLiteral: [85],
|
|
5361
|
+
ThisExpression: [86],
|
|
5362
|
+
ThrowStatement: [87],
|
|
5363
|
+
TryStatement: [88],
|
|
5364
|
+
UnaryExpression: [89],
|
|
5365
|
+
UpdateExpression: [90],
|
|
5366
|
+
VariableDeclaration: [91],
|
|
5367
|
+
VariableDeclarator: [92],
|
|
5368
|
+
WhileStatement: [93],
|
|
5369
|
+
YieldExpression: [94]
|
|
5370
|
+
};
|
|
5371
|
+
|
|
5372
|
+
// This file is generated by scripts/generate-scope-constants.ts.
|
|
5373
|
+
// Do not edit this file directly.
|
|
5374
|
+
const SCOPE_PARENT_OFFSET = 0;
|
|
5375
|
+
const SCOPE_DECLARATION_COUNT_OFFSET = 1;
|
|
5376
|
+
const SCOPE_DECLARATIONS_OFFSET = 2;
|
|
5377
|
+
|
|
5378
|
+
const IDENTIFIER_NAME_OFFSET = 3;
|
|
5379
|
+
async function parseAndWalk(input, visitors, { allowReturnOutsideFunction = false, collectScopes = false, jsx = false } = {}) {
|
|
5380
|
+
const selectedNodesBuffer = getSelectedNodesBitsetBuffer(visitors);
|
|
5381
|
+
const astBuffer = getAstBuffer(await parseAndWalk$1(input, allowReturnOutsideFunction, jsx, selectedNodesBuffer, collectScopes));
|
|
5382
|
+
walkAstBuffer(astBuffer, visitors, collectScopes);
|
|
5383
|
+
}
|
|
5384
|
+
function getSelectedNodesBitsetBuffer(visitors) {
|
|
5385
|
+
let selectedNodesBitset = 0n;
|
|
5386
|
+
for (const nodeType of Object.keys(visitors)) {
|
|
5387
|
+
const ids = nodeIds[nodeType];
|
|
5388
|
+
if (ids) {
|
|
5389
|
+
for (const id of ids) {
|
|
5390
|
+
selectedNodesBitset |= 1n << BigInt(id);
|
|
5391
|
+
}
|
|
5392
|
+
}
|
|
5393
|
+
else {
|
|
5394
|
+
throw new Error(`Unknown node type "${nodeType}" when calling "parseAndWalk".`);
|
|
5395
|
+
}
|
|
5396
|
+
}
|
|
5397
|
+
const selectedNodesBuffer = new BigUint64Array(2); // 2 × 64 bits = 128 bits
|
|
5398
|
+
selectedNodesBuffer[0] = selectedNodesBitset & ((1n << 64n) - 1n);
|
|
5399
|
+
selectedNodesBuffer[1] = selectedNodesBitset >> 64n;
|
|
5400
|
+
return selectedNodesBuffer;
|
|
5401
|
+
}
|
|
5402
|
+
// TODO Lukas Can we expose parseAndWalk as a separate method? Can we also make
|
|
5403
|
+
// sure to include its tests in the smoke tests to test on a big endian system?
|
|
5404
|
+
function walkAstBuffer(astBuffer, visitors, collectScopes) {
|
|
5405
|
+
const walkingInfoOffset = astBuffer[0];
|
|
5406
|
+
const entrySize = 3;
|
|
5407
|
+
// If it is 0, there are no walking buffer or walked nodes
|
|
5408
|
+
if (walkingInfoOffset === 0) {
|
|
5409
|
+
// This will throw the correct error if there was a parse error
|
|
5410
|
+
return deserializeLazyAstBuffer(astBuffer, 1);
|
|
5411
|
+
}
|
|
5412
|
+
let walkingPosition = walkingInfoOffset;
|
|
5413
|
+
const scopeCache = new Map();
|
|
5414
|
+
const api = {
|
|
5415
|
+
parseChildren() {
|
|
5416
|
+
const endPosition = walkingInfoOffset + astBuffer[walkingPosition + 1] * entrySize;
|
|
5417
|
+
walkingPosition += entrySize;
|
|
5418
|
+
walkUntilPosition(endPosition);
|
|
5419
|
+
// After parseChildren, the walkingPosition must point to the last child,
|
|
5420
|
+
// not beyond. Otherwise, we would skip the next element.
|
|
5421
|
+
walkingPosition -= entrySize;
|
|
5422
|
+
},
|
|
5423
|
+
skipChildren() {
|
|
5424
|
+
// Like parseChildren, the pointer must point to the last child after
|
|
5425
|
+
// skipping, not beyond.
|
|
5426
|
+
walkingPosition = walkingInfoOffset + astBuffer[walkingPosition + 1] * entrySize - entrySize;
|
|
5427
|
+
}
|
|
5428
|
+
};
|
|
5429
|
+
function walkUntilPosition(endPosition) {
|
|
5430
|
+
for (; walkingPosition < endPosition; walkingPosition += entrySize) {
|
|
5431
|
+
const elementIndex = astBuffer[walkingPosition];
|
|
5432
|
+
if (collectScopes) {
|
|
5433
|
+
api.scope = getScope(astBuffer[walkingPosition + 2]);
|
|
5434
|
+
}
|
|
5435
|
+
const nodeTypeString = nodeTypeStrings[astBuffer[elementIndex]];
|
|
5436
|
+
visitors[nodeTypeString](deserializeLazyAstBuffer(astBuffer, elementIndex), api);
|
|
5437
|
+
}
|
|
5438
|
+
}
|
|
5439
|
+
function getScope(scopePosition) {
|
|
5440
|
+
/* istanbul ignore next */
|
|
5441
|
+
if (scopePosition === 0) {
|
|
5442
|
+
throw new Error('Internal Error: Missing scope information in parseAndWalk.');
|
|
5443
|
+
}
|
|
5444
|
+
let scope = scopeCache.get(scopePosition);
|
|
5445
|
+
if (!scope) {
|
|
5446
|
+
scope = {
|
|
5447
|
+
contains(name) {
|
|
5448
|
+
for (let currentScopePosition = scopePosition; currentScopePosition;) {
|
|
5449
|
+
const declarationCount = astBuffer[currentScopePosition + SCOPE_DECLARATION_COUNT_OFFSET];
|
|
5450
|
+
for (let index = 0; index < declarationCount; index++) {
|
|
5451
|
+
const identifierPosition = astBuffer[currentScopePosition + SCOPE_DECLARATIONS_OFFSET + index];
|
|
5452
|
+
if (astBuffer.convertString(astBuffer[identifierPosition + IDENTIFIER_NAME_OFFSET]) ===
|
|
5453
|
+
name) {
|
|
5454
|
+
return true;
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
currentScopePosition = astBuffer[currentScopePosition + SCOPE_PARENT_OFFSET];
|
|
5458
|
+
}
|
|
5459
|
+
return false;
|
|
5460
|
+
}
|
|
5461
|
+
};
|
|
5462
|
+
scopeCache.set(scopePosition, scope);
|
|
5463
|
+
}
|
|
5464
|
+
return scope;
|
|
2137
5465
|
}
|
|
2138
|
-
|
|
5466
|
+
walkUntilPosition(astBuffer.length);
|
|
2139
5467
|
}
|
|
2140
5468
|
|
|
2141
|
-
const
|
|
2142
|
-
const
|
|
5469
|
+
const deserializeAst = (buffer, position = 0) => deserializeAstBuffer(getAstBuffer(buffer), position);
|
|
5470
|
+
const deserializeLazyAst = (buffer, position = 0) => deserializeLazyAstBuffer(getAstBuffer(buffer), position);
|
|
5471
|
+
const parseAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeAst(parse(input, allowReturnOutsideFunction, jsx));
|
|
5472
|
+
const parseAstAsync = async (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeAst(await parseAsync(input, allowReturnOutsideFunction, jsx));
|
|
5473
|
+
const parseLazyAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeLazyAst(parse(input, allowReturnOutsideFunction, jsx));
|
|
5474
|
+
const parseLazyAstAsync = async (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeLazyAst(await parseAsync(input, allowReturnOutsideFunction, jsx));
|
|
2143
5475
|
|
|
2144
|
-
export {
|
|
5476
|
+
export { ArrowFunctionExpression, AwaitExpression, BLANK, BlockStatement, CallExpression, CatchClause, EMPTY_ARRAY, EMPTY_OBJECT, EMPTY_SET, ExportDefaultDeclaration, ExpressionStatement, FIXED_STRINGS, FunctionDeclaration, FunctionExpression, Identifier, IfStatement$1 as IfStatement, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, Literal, MemberExpression, ObjectExpression, Program, Property, RestElement, ReturnStatement, StaticBlock, TemplateLiteral, URL_GENERATEBUNDLE, URL_JSX, URL_LOAD, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_AMD_ID, URL_OUTPUT_DIR, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, URL_OUTPUT_FORMAT, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_IMPORTATTRIBUTESKEY, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_OUTPUT_INTEROP, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_SOURCEMAPFILE, URL_PRESERVEENTRYSIGNATURES, URL_THIS_RESOLVE, URL_TRANSFORM, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, URL_WATCH, VariableDeclarator, addTrailingSlashIfMissed, augmentCodeLocation, augmentLogMessage, convertAnnotations, convertNode$1 as convertNode, deserializeAst, deserializeLazyAst, error, getAliasName, getAstBuffer, getImportPath, getRollupError, isAbsolute, isPathFragment, isRelative, isValidUrl, locate, logAddonNotGenerated, logAlreadyClosed, logAmbiguousExternalNamespaces, logAmbiguousGlobalName, logAnonymousPluginCache, logAssetNotFinalisedForFileName, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logBadLoader, logCannotAssignModuleToChunk, logCannotCallNamespace, logCannotEmitFromOptionsHook, logChunkInvalid, logChunkNotGeneratedForFileName, logCircularChunk, logCircularDependency, logCircularReexport, logConflictingSourcemapSources, logConstVariableReassignError, logCyclicCrossChunkReexport, logDuplicateArgumentNameError, logDuplicateExportError, logDuplicatePluginName, logEmptyChunk, logEmptyManualChunk, logEntryCannotBeExternal, logEval, logExternalModulesCannotBeIncludedInManualChunks, logExternalModulesCannotBeTransformedToModules, logExternalSyntheticExports, logFailedValidation, logFileNameConflict, logFileNameOutsideOutputDirectory, logFileReferenceIdNotFoundForFilename, logFirstSideEffect, logIllegalIdentifierAsName, logIllegalImportReassignment, logImplicitDependantCannotBeExternal, logImplicitDependantIsNotIncluded, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logIncompatibleExportOptionValue, logInputHookInOutputPlugin, logInternalIdCannotBeExternal, logInvalidAddonPluginHook, logInvalidAnnotation, logInvalidExportOptionValue, logInvalidFormatForTopLevelAwait, logInvalidFunctionPluginHook, logInvalidLogPosition, logInvalidOption, logInvalidRollupPhaseForChunkEmission, logInvalidSetAssetSourceCall, logInvalidSourcemapForError, logLevelPriority, logMissingEntryExport, logMissingExport, logMissingFileOrDirOption, logMissingGlobalName, logMissingJsxExport, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logMissingNodeBuiltins, logMixedExport, logModuleLevelDirective, logModuleParseError, logNamespaceConflict, logNoAssetSourceSet, logNoTransformMapOrAstWithoutCode, logNonExternalSourcePhaseImport, logOptimizeChunkStatus, logParseError, logPluginError, logRedeclarationError, logReservedNamespace, logShimmedExport, logSourcePhaseFormatUnsupported, logSourcemapBroken, logSyntheticNamedExportsNeedNamespaceExport, logThisIsUndefined, logUnexpectedNamedImport, logUnexpectedNamespaceReexport, logUnknownOption, logUnresolvedEntry, logUnresolvedImplicitDependant, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logUnusedExternalImports, nodeTypeStrings, normalize, parseAndWalk, parseAst, parseAstAsync, parseLazyAst, parseLazyAstAsync, printQuotedStringList, relative, relativeId, serializeAst, warnDeprecation };
|