rollup 4.64.0 → 5.0.0-0
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 +1870 -2006
- package/dist/es/shared/parseAst.js +3542 -276
- 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 +3579 -303
- package/dist/shared/rollup.js +1670 -1784
- package/dist/shared/watch-cli.js +10 -9
- package/dist/shared/watch.js +7 -11
- package/package.json +60 -62
- package/dist/shared/fsevents-importer.js +0 -37
package/dist/shared/parseAst.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js
|
|
4
|
-
|
|
3
|
+
Rollup.js v5.0.0-0
|
|
4
|
+
Tue, 06 Oct 2026 08:24:44 GMT - commit d78bf6bee48e411672e05d8977473f76e6758c35
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
12
|
const native_js = require('../native.js');
|
|
13
|
-
const
|
|
13
|
+
const sp = require('node:path');
|
|
14
14
|
|
|
15
15
|
const BLANK = Object.freeze(Object.create(null));
|
|
16
16
|
const EMPTY_OBJECT = Object.freeze({});
|
|
@@ -203,13 +203,13 @@ function relative(from, to) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
function getAliasName(id) {
|
|
206
|
-
const base =
|
|
207
|
-
return base.slice(0, Math.max(0, base.length -
|
|
206
|
+
const base = sp.basename(id);
|
|
207
|
+
return base.slice(0, Math.max(0, base.length - sp.extname(id).length));
|
|
208
208
|
}
|
|
209
209
|
function relativeId(id) {
|
|
210
210
|
if (!isAbsolute(id))
|
|
211
211
|
return id;
|
|
212
|
-
return relative(
|
|
212
|
+
return relative(sp.resolve(), id);
|
|
213
213
|
}
|
|
214
214
|
function isPathFragment(name) {
|
|
215
215
|
// starting with "/", "./", "../", "C:/"
|
|
@@ -221,15 +221,15 @@ function getImportPath(importerId, targetPath, stripJsExtension, ensureFileName)
|
|
|
221
221
|
targetPath = targetPath.slice(3);
|
|
222
222
|
importerId = '_/' + importerId;
|
|
223
223
|
}
|
|
224
|
-
let relativePath = normalize(relative(
|
|
224
|
+
let relativePath = normalize(relative(sp.dirname(importerId), targetPath));
|
|
225
225
|
if (stripJsExtension && relativePath.endsWith('.js')) {
|
|
226
226
|
relativePath = relativePath.slice(0, -3);
|
|
227
227
|
}
|
|
228
228
|
if (ensureFileName) {
|
|
229
229
|
if (relativePath === '')
|
|
230
|
-
return '../' +
|
|
230
|
+
return '../' + sp.basename(targetPath);
|
|
231
231
|
if (UPPER_DIR_REGEX.test(relativePath)) {
|
|
232
|
-
return [...relativePath.split('/'), '..',
|
|
232
|
+
return [...relativePath.split('/'), '..', sp.basename(targetPath)].join('/');
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
return relativePath ? (relativePath.startsWith('..') ? relativePath : './' + relativePath) : '.';
|
|
@@ -271,6 +271,7 @@ const URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = 'configuration-options/#output-exter
|
|
|
271
271
|
const URL_OUTPUT_FORMAT = 'configuration-options/#output-format';
|
|
272
272
|
const URL_OUTPUT_GENERATEDCODE = 'configuration-options/#output-generatedcode';
|
|
273
273
|
const URL_OUTPUT_GLOBALS = 'configuration-options/#output-globals';
|
|
274
|
+
const URL_OUTPUT_IMPORTATTRIBUTESKEY = 'configuration-options/#output-importattributeskey';
|
|
274
275
|
const URL_OUTPUT_INLINEDYNAMICIMPORTS = 'configuration-options/#output-inlinedynamicimports';
|
|
275
276
|
const URL_OUTPUT_INTEROP = 'configuration-options/#output-interop';
|
|
276
277
|
const URL_OUTPUT_MANUALCHUNKS = 'configuration-options/#output-manualchunks';
|
|
@@ -289,6 +290,7 @@ const URL_SOURCE_PHASE_IMPORTS = 'es-module-syntax/#source-phase-import';
|
|
|
289
290
|
const URL_BUNDLE_CONFIG_AS_CJS = 'command-line-interface/#bundleconfigascjs';
|
|
290
291
|
const URL_CONFIGURATION_FILES = 'command-line-interface/#configuration-files';
|
|
291
292
|
const URL_GENERATEBUNDLE = 'plugin-development/#generatebundle';
|
|
293
|
+
const URL_THIS_RESOLVE = 'plugin-development/#this-resolve';
|
|
292
294
|
const URL_LOAD = 'plugin-development/#load';
|
|
293
295
|
const URL_TRANSFORM = 'plugin-development/#transform';
|
|
294
296
|
|
|
@@ -345,7 +347,7 @@ function augmentLogMessage(log) {
|
|
|
345
347
|
}
|
|
346
348
|
// Error codes should be sorted alphabetically while errors should be sorted by
|
|
347
349
|
// error code below
|
|
348
|
-
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_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', 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', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', 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',
|
|
350
|
+
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_IMPORT_OPTIONS = 'DUPLICATE_IMPORT_OPTIONS', 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', FAIL_AFTER_WARNINGS = 'FAIL_AFTER_WARNINGS', 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_CONFIG_MODULE_FORMAT = 'INVALID_CONFIG_MODULE_FORMAT', 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_CONFIG = 'MISSING_CONFIG', MISSING_EXPORT = 'MISSING_EXPORT', MISSING_EXTERNAL_CONFIG = 'MISSING_EXTERNAL_CONFIG', 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', ONLY_INLINE_SOURCEMAPS = 'ONLY_INLINE_SOURCEMAPS', 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';
|
|
349
351
|
function logAddonNotGenerated(message, hook, plugin) {
|
|
350
352
|
return {
|
|
351
353
|
code: ADDON_ERROR,
|
|
@@ -368,6 +370,14 @@ function logAmbiguousExternalNamespaces(binding, reexportingModule, usedModule,
|
|
|
368
370
|
reexporter: reexportingModule
|
|
369
371
|
};
|
|
370
372
|
}
|
|
373
|
+
function logAmbiguousGlobalName(rawId, globalName) {
|
|
374
|
+
return {
|
|
375
|
+
code: AMBIGUOUS_GLOBAL_NAME,
|
|
376
|
+
id: rawId,
|
|
377
|
+
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.`,
|
|
378
|
+
url: getRollupUrl(URL_OUTPUT_GLOBALS)
|
|
379
|
+
};
|
|
380
|
+
}
|
|
371
381
|
function logAnonymousPluginCache() {
|
|
372
382
|
return {
|
|
373
383
|
code: ANONYMOUS_PLUGIN_CACHE,
|
|
@@ -416,6 +426,19 @@ function logCannotEmitFromOptionsHook() {
|
|
|
416
426
|
message: `Cannot emit files or set asset sources in the "outputOptions" hook, use the "renderStart" hook instead.`
|
|
417
427
|
};
|
|
418
428
|
}
|
|
429
|
+
function logUnknownNodeType(type, parentType, field) {
|
|
430
|
+
const location = parentType ? `in ${parentType}.${field}` : 'at the root';
|
|
431
|
+
return {
|
|
432
|
+
code: CANNOT_SERIALIZE_AST,
|
|
433
|
+
message: `Could not serialize AST: Found unknown node type "${type}" ${location}.`
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function logExpectedNodeList(parentType, field, value) {
|
|
437
|
+
return {
|
|
438
|
+
code: CANNOT_SERIALIZE_AST,
|
|
439
|
+
message: `Could not serialize AST: Expected ${parentType}.${field} to be an array, but it was ${JSON.stringify(value)}.`
|
|
440
|
+
};
|
|
441
|
+
}
|
|
419
442
|
function logChunkNotGeneratedForFileName(name) {
|
|
420
443
|
return {
|
|
421
444
|
code: CHUNK_NOT_GENERATED,
|
|
@@ -437,13 +460,17 @@ function logCircularDependency(cyclePath) {
|
|
|
437
460
|
message: `Circular dependency: ${cyclePath.map(relativeId).join(' -> ')}`
|
|
438
461
|
};
|
|
439
462
|
}
|
|
440
|
-
function logCircularChunk(cyclePath,
|
|
463
|
+
function logCircularChunk(cyclePath, manualChunkNames, nonManualChunkName, onlyExplicitManualChunks) {
|
|
441
464
|
return {
|
|
442
465
|
code: CIRCULAR_CHUNK,
|
|
443
466
|
ids: cyclePath,
|
|
444
|
-
message:
|
|
445
|
-
? `
|
|
446
|
-
: `
|
|
467
|
+
message: manualChunkNames.length === 0
|
|
468
|
+
? `Circular chunk: ${cyclePath.join(' -> ')}.`
|
|
469
|
+
: `Circular chunk: ${cyclePath.join(' -> ')}. ${nonManualChunkName === undefined
|
|
470
|
+
? `Please adjust the manual chunk logic for these chunks.`
|
|
471
|
+
: onlyExplicitManualChunks
|
|
472
|
+
? `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}".`
|
|
473
|
+
: `Please adjust the manual chunks or the module structure.`}`
|
|
447
474
|
};
|
|
448
475
|
}
|
|
449
476
|
function logCircularReexport(exportName, exporter) {
|
|
@@ -467,7 +494,7 @@ function logDeprecation(deprecation, urlSnippet, plugin) {
|
|
|
467
494
|
code: DEPRECATED_FEATURE,
|
|
468
495
|
message: deprecation,
|
|
469
496
|
url: getRollupUrl(urlSnippet),
|
|
470
|
-
...({})
|
|
497
|
+
...(plugin ? { plugin } : {})
|
|
471
498
|
};
|
|
472
499
|
}
|
|
473
500
|
function logConstVariableReassignError() {
|
|
@@ -504,6 +531,14 @@ function logEmptyChunk(chunkName) {
|
|
|
504
531
|
names: [chunkName]
|
|
505
532
|
};
|
|
506
533
|
}
|
|
534
|
+
function logEmptyManualChunk(alias) {
|
|
535
|
+
return {
|
|
536
|
+
code: EMPTY_MANUAL_CHUNK,
|
|
537
|
+
message: `Manual chunk "${alias}" was not generated as none of its modules are included in the bundle.`,
|
|
538
|
+
names: [alias],
|
|
539
|
+
url: getRollupUrl(URL_OUTPUT_MANUALCHUNKS)
|
|
540
|
+
};
|
|
541
|
+
}
|
|
507
542
|
function logEval(id) {
|
|
508
543
|
return {
|
|
509
544
|
code: EVAL,
|
|
@@ -562,18 +597,6 @@ function logIllegalImportReassignment(name, importingId) {
|
|
|
562
597
|
message: `Illegal reassignment of import "${name}" in "${relativeId(importingId)}".`
|
|
563
598
|
};
|
|
564
599
|
}
|
|
565
|
-
function logInconsistentImportAttributes(existingAttributes, newAttributes, source, importer) {
|
|
566
|
-
return {
|
|
567
|
-
code: INCONSISTENT_IMPORT_ATTRIBUTES,
|
|
568
|
-
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.`
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
const formatAttributes = (attributes) => {
|
|
572
|
-
const entries = Object.entries(attributes);
|
|
573
|
-
if (entries.length === 0)
|
|
574
|
-
return 'no';
|
|
575
|
-
return entries.map(([key, value]) => `"${key}": "${value}"`).join(', ');
|
|
576
|
-
};
|
|
577
600
|
function logInvalidAnnotation(comment, id, type) {
|
|
578
601
|
return {
|
|
579
602
|
code: INVALID_ANNOTATION,
|
|
@@ -738,7 +761,7 @@ function logMissingExport(binding, importingModule, exporter, missingButExportEx
|
|
|
738
761
|
message: `Exported variable "${binding}" is not defined in "${relativeId(exporter)}", but it is imported by "${relativeId(importingModule)}".`
|
|
739
762
|
};
|
|
740
763
|
}
|
|
741
|
-
const isJson =
|
|
764
|
+
const isJson = sp.extname(exporter) === '.json';
|
|
742
765
|
return {
|
|
743
766
|
...baseLog,
|
|
744
767
|
message: `"${binding}" is not exported by "${relativeId(exporter)}", imported by "${relativeId(importingModule)}".${isJson ? ' (Note that you need @rollup/plugin-json to import JSON files)' : ''}`
|
|
@@ -1060,11 +1083,11 @@ function logFailedValidation(message) {
|
|
|
1060
1083
|
};
|
|
1061
1084
|
}
|
|
1062
1085
|
function warnDeprecation(deprecation, urlSnippet, activeDeprecation, options, plugin) {
|
|
1063
|
-
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations);
|
|
1086
|
+
warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, options.onLog, options.strictDeprecations, plugin);
|
|
1064
1087
|
}
|
|
1065
1088
|
function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation, log, strictDeprecations, plugin) {
|
|
1066
1089
|
if (activeDeprecation || strictDeprecations) {
|
|
1067
|
-
const warning = logDeprecation(deprecation, urlSnippet);
|
|
1090
|
+
const warning = logDeprecation(deprecation, urlSnippet, plugin);
|
|
1068
1091
|
if (strictDeprecations) {
|
|
1069
1092
|
return error(warning);
|
|
1070
1093
|
}
|
|
@@ -1072,7 +1095,201 @@ function warnDeprecationWithOptions(deprecation, urlSnippet, activeDeprecation,
|
|
|
1072
1095
|
}
|
|
1073
1096
|
}
|
|
1074
1097
|
|
|
1075
|
-
// This file is generated by scripts/generate-node-
|
|
1098
|
+
// This file is generated by scripts/generate-node-ids.ts.
|
|
1099
|
+
// Do not edit this file directly.
|
|
1100
|
+
const nodeIds = {
|
|
1101
|
+
ArrayExpression: [2],
|
|
1102
|
+
ArrayPattern: [3],
|
|
1103
|
+
ArrowFunctionExpression: [4],
|
|
1104
|
+
AssignmentExpression: [5],
|
|
1105
|
+
AssignmentPattern: [6],
|
|
1106
|
+
AwaitExpression: [7],
|
|
1107
|
+
BinaryExpression: [8],
|
|
1108
|
+
BlockStatement: [9],
|
|
1109
|
+
BreakStatement: [10],
|
|
1110
|
+
CallExpression: [11],
|
|
1111
|
+
CatchClause: [12],
|
|
1112
|
+
ChainExpression: [13],
|
|
1113
|
+
ClassBody: [14],
|
|
1114
|
+
ClassDeclaration: [15],
|
|
1115
|
+
ClassExpression: [16],
|
|
1116
|
+
ConditionalExpression: [17],
|
|
1117
|
+
ContinueStatement: [18],
|
|
1118
|
+
DebuggerStatement: [19],
|
|
1119
|
+
Decorator: [20],
|
|
1120
|
+
DoWhileStatement: [22],
|
|
1121
|
+
EmptyStatement: [23],
|
|
1122
|
+
ExportAllDeclaration: [24],
|
|
1123
|
+
ExportDefaultDeclaration: [25],
|
|
1124
|
+
ExportNamedDeclaration: [26],
|
|
1125
|
+
ExportSpecifier: [27],
|
|
1126
|
+
ExpressionStatement: [21, 28],
|
|
1127
|
+
ForInStatement: [29],
|
|
1128
|
+
ForOfStatement: [30],
|
|
1129
|
+
ForStatement: [31],
|
|
1130
|
+
FunctionDeclaration: [32],
|
|
1131
|
+
FunctionExpression: [33],
|
|
1132
|
+
Identifier: [34],
|
|
1133
|
+
IfStatement: [35],
|
|
1134
|
+
ImportAttribute: [36],
|
|
1135
|
+
ImportDeclaration: [37],
|
|
1136
|
+
ImportDefaultSpecifier: [38],
|
|
1137
|
+
ImportExpression: [39],
|
|
1138
|
+
ImportNamespaceSpecifier: [40],
|
|
1139
|
+
ImportSpecifier: [41],
|
|
1140
|
+
JSXAttribute: [42],
|
|
1141
|
+
JSXClosingElement: [43],
|
|
1142
|
+
JSXClosingFragment: [44],
|
|
1143
|
+
JSXElement: [45],
|
|
1144
|
+
JSXEmptyExpression: [46],
|
|
1145
|
+
JSXExpressionContainer: [47],
|
|
1146
|
+
JSXFragment: [48],
|
|
1147
|
+
JSXIdentifier: [49],
|
|
1148
|
+
JSXMemberExpression: [50],
|
|
1149
|
+
JSXNamespacedName: [51],
|
|
1150
|
+
JSXOpeningElement: [52],
|
|
1151
|
+
JSXOpeningFragment: [53],
|
|
1152
|
+
JSXSpreadAttribute: [54],
|
|
1153
|
+
JSXSpreadChild: [55],
|
|
1154
|
+
JSXText: [56],
|
|
1155
|
+
LabeledStatement: [57],
|
|
1156
|
+
Literal: [58, 59, 60, 61, 62, 63],
|
|
1157
|
+
LogicalExpression: [64],
|
|
1158
|
+
MemberExpression: [65],
|
|
1159
|
+
MetaProperty: [66],
|
|
1160
|
+
MethodDefinition: [67],
|
|
1161
|
+
NewExpression: [68],
|
|
1162
|
+
ObjectExpression: [69],
|
|
1163
|
+
ObjectPattern: [70],
|
|
1164
|
+
PanicError: [0],
|
|
1165
|
+
ParseError: [1],
|
|
1166
|
+
PrivateIdentifier: [71],
|
|
1167
|
+
Program: [72],
|
|
1168
|
+
Property: [73],
|
|
1169
|
+
PropertyDefinition: [74],
|
|
1170
|
+
RestElement: [75],
|
|
1171
|
+
ReturnStatement: [76],
|
|
1172
|
+
SequenceExpression: [77],
|
|
1173
|
+
SpreadElement: [78],
|
|
1174
|
+
StaticBlock: [79],
|
|
1175
|
+
Super: [80],
|
|
1176
|
+
SwitchCase: [81],
|
|
1177
|
+
SwitchStatement: [82],
|
|
1178
|
+
TaggedTemplateExpression: [83],
|
|
1179
|
+
TemplateElement: [84],
|
|
1180
|
+
TemplateLiteral: [85],
|
|
1181
|
+
ThisExpression: [86],
|
|
1182
|
+
ThrowStatement: [87],
|
|
1183
|
+
TryStatement: [88],
|
|
1184
|
+
UnaryExpression: [89],
|
|
1185
|
+
UpdateExpression: [90],
|
|
1186
|
+
VariableDeclaration: [91],
|
|
1187
|
+
VariableDeclarator: [92],
|
|
1188
|
+
WhileStatement: [93],
|
|
1189
|
+
YieldExpression: [94]
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// This file is generated by scripts/generate-node-type-strings.ts.
|
|
1193
|
+
// Do not edit this file directly.
|
|
1194
|
+
const nodeTypeStrings = [
|
|
1195
|
+
'PanicError',
|
|
1196
|
+
'ParseError',
|
|
1197
|
+
'ArrayExpression',
|
|
1198
|
+
'ArrayPattern',
|
|
1199
|
+
'ArrowFunctionExpression',
|
|
1200
|
+
'AssignmentExpression',
|
|
1201
|
+
'AssignmentPattern',
|
|
1202
|
+
'AwaitExpression',
|
|
1203
|
+
'BinaryExpression',
|
|
1204
|
+
'BlockStatement',
|
|
1205
|
+
'BreakStatement',
|
|
1206
|
+
'CallExpression',
|
|
1207
|
+
'CatchClause',
|
|
1208
|
+
'ChainExpression',
|
|
1209
|
+
'ClassBody',
|
|
1210
|
+
'ClassDeclaration',
|
|
1211
|
+
'ClassExpression',
|
|
1212
|
+
'ConditionalExpression',
|
|
1213
|
+
'ContinueStatement',
|
|
1214
|
+
'DebuggerStatement',
|
|
1215
|
+
'Decorator',
|
|
1216
|
+
'ExpressionStatement',
|
|
1217
|
+
'DoWhileStatement',
|
|
1218
|
+
'EmptyStatement',
|
|
1219
|
+
'ExportAllDeclaration',
|
|
1220
|
+
'ExportDefaultDeclaration',
|
|
1221
|
+
'ExportNamedDeclaration',
|
|
1222
|
+
'ExportSpecifier',
|
|
1223
|
+
'ExpressionStatement',
|
|
1224
|
+
'ForInStatement',
|
|
1225
|
+
'ForOfStatement',
|
|
1226
|
+
'ForStatement',
|
|
1227
|
+
'FunctionDeclaration',
|
|
1228
|
+
'FunctionExpression',
|
|
1229
|
+
'Identifier',
|
|
1230
|
+
'IfStatement',
|
|
1231
|
+
'ImportAttribute',
|
|
1232
|
+
'ImportDeclaration',
|
|
1233
|
+
'ImportDefaultSpecifier',
|
|
1234
|
+
'ImportExpression',
|
|
1235
|
+
'ImportNamespaceSpecifier',
|
|
1236
|
+
'ImportSpecifier',
|
|
1237
|
+
'JSXAttribute',
|
|
1238
|
+
'JSXClosingElement',
|
|
1239
|
+
'JSXClosingFragment',
|
|
1240
|
+
'JSXElement',
|
|
1241
|
+
'JSXEmptyExpression',
|
|
1242
|
+
'JSXExpressionContainer',
|
|
1243
|
+
'JSXFragment',
|
|
1244
|
+
'JSXIdentifier',
|
|
1245
|
+
'JSXMemberExpression',
|
|
1246
|
+
'JSXNamespacedName',
|
|
1247
|
+
'JSXOpeningElement',
|
|
1248
|
+
'JSXOpeningFragment',
|
|
1249
|
+
'JSXSpreadAttribute',
|
|
1250
|
+
'JSXSpreadChild',
|
|
1251
|
+
'JSXText',
|
|
1252
|
+
'LabeledStatement',
|
|
1253
|
+
'Literal',
|
|
1254
|
+
'Literal',
|
|
1255
|
+
'Literal',
|
|
1256
|
+
'Literal',
|
|
1257
|
+
'Literal',
|
|
1258
|
+
'Literal',
|
|
1259
|
+
'LogicalExpression',
|
|
1260
|
+
'MemberExpression',
|
|
1261
|
+
'MetaProperty',
|
|
1262
|
+
'MethodDefinition',
|
|
1263
|
+
'NewExpression',
|
|
1264
|
+
'ObjectExpression',
|
|
1265
|
+
'ObjectPattern',
|
|
1266
|
+
'PrivateIdentifier',
|
|
1267
|
+
'Program',
|
|
1268
|
+
'Property',
|
|
1269
|
+
'PropertyDefinition',
|
|
1270
|
+
'RestElement',
|
|
1271
|
+
'ReturnStatement',
|
|
1272
|
+
'SequenceExpression',
|
|
1273
|
+
'SpreadElement',
|
|
1274
|
+
'StaticBlock',
|
|
1275
|
+
'Super',
|
|
1276
|
+
'SwitchCase',
|
|
1277
|
+
'SwitchStatement',
|
|
1278
|
+
'TaggedTemplateExpression',
|
|
1279
|
+
'TemplateElement',
|
|
1280
|
+
'TemplateLiteral',
|
|
1281
|
+
'ThisExpression',
|
|
1282
|
+
'ThrowStatement',
|
|
1283
|
+
'TryStatement',
|
|
1284
|
+
'UnaryExpression',
|
|
1285
|
+
'UpdateExpression',
|
|
1286
|
+
'VariableDeclaration',
|
|
1287
|
+
'VariableDeclarator',
|
|
1288
|
+
'WhileStatement',
|
|
1289
|
+
'YieldExpression'
|
|
1290
|
+
];
|
|
1291
|
+
|
|
1292
|
+
// This file is generated by scripts/generate-node-types.ts.
|
|
1076
1293
|
// Do not edit this file directly.
|
|
1077
1294
|
const ArrowFunctionExpression = 'ArrowFunctionExpression';
|
|
1078
1295
|
const AwaitExpression = 'AwaitExpression';
|
|
@@ -1081,8 +1298,10 @@ const CallExpression = 'CallExpression';
|
|
|
1081
1298
|
const CatchClause = 'CatchClause';
|
|
1082
1299
|
const ExportDefaultDeclaration = 'ExportDefaultDeclaration';
|
|
1083
1300
|
const ExpressionStatement = 'ExpressionStatement';
|
|
1301
|
+
const FunctionDeclaration = 'FunctionDeclaration';
|
|
1084
1302
|
const FunctionExpression = 'FunctionExpression';
|
|
1085
1303
|
const Identifier = 'Identifier';
|
|
1304
|
+
const IfStatement$1 = 'IfStatement';
|
|
1086
1305
|
const Literal = 'Literal';
|
|
1087
1306
|
const MemberExpression = 'MemberExpression';
|
|
1088
1307
|
const ObjectExpression = 'ObjectExpression';
|
|
@@ -1096,7 +1315,7 @@ const StaticBlock = 'StaticBlock';
|
|
|
1096
1315
|
const TemplateLiteral = 'TemplateLiteral';
|
|
1097
1316
|
const VariableDeclarator = 'VariableDeclarator';
|
|
1098
1317
|
|
|
1099
|
-
// This file is generated by scripts/generate-string-constants.
|
|
1318
|
+
// This file is generated by scripts/generate-string-constants.ts.
|
|
1100
1319
|
// Do not edit this file directly.
|
|
1101
1320
|
const FIXED_STRINGS = [
|
|
1102
1321
|
'var',
|
|
@@ -1127,8 +1346,6 @@ const FIXED_STRINGS = [
|
|
|
1127
1346
|
'<<',
|
|
1128
1347
|
'>>',
|
|
1129
1348
|
'>>>',
|
|
1130
|
-
'+',
|
|
1131
|
-
'-',
|
|
1132
1349
|
'*',
|
|
1133
1350
|
'/',
|
|
1134
1351
|
'%',
|
|
@@ -1166,8 +1383,6 @@ const FIXED_STRINGS = [
|
|
|
1166
1383
|
'defer'
|
|
1167
1384
|
];
|
|
1168
1385
|
|
|
1169
|
-
const ANNOTATION_KEY = '_rollupAnnotations';
|
|
1170
|
-
const INVALID_ANNOTATION_KEY = '_rollupRemoved';
|
|
1171
1386
|
const convertAnnotations = (position, buffer) => {
|
|
1172
1387
|
if (position === 0)
|
|
1173
1388
|
return EMPTY_ARRAY;
|
|
@@ -1185,10 +1400,10 @@ const convertAnnotation = (position, buffer) => {
|
|
|
1185
1400
|
return { end, start, type };
|
|
1186
1401
|
};
|
|
1187
1402
|
|
|
1188
|
-
// This file is generated by scripts/generate-buffer-to-ast.
|
|
1403
|
+
// This file is generated by scripts/generate-buffer-to-lazy-ast.ts.
|
|
1189
1404
|
// Do not edit this file directly.
|
|
1190
|
-
|
|
1191
|
-
const node = convertNode(
|
|
1405
|
+
const deserializeLazyAstBuffer = (buffer, position) => {
|
|
1406
|
+
const node = convertNode$1(position, buffer);
|
|
1192
1407
|
switch (node.type) {
|
|
1193
1408
|
case PanicError: {
|
|
1194
1409
|
return error(getRollupError(logParseError(node.message)));
|
|
@@ -1200,621 +1415,1119 @@ function convertProgram(buffer) {
|
|
|
1200
1415
|
return node;
|
|
1201
1416
|
}
|
|
1202
1417
|
}
|
|
1203
|
-
}
|
|
1418
|
+
};
|
|
1204
1419
|
/* eslint-disable sort-keys */
|
|
1205
|
-
const nodeConverters = [
|
|
1420
|
+
const nodeConverters$1 = [
|
|
1206
1421
|
function panicError(position, buffer) {
|
|
1207
|
-
|
|
1422
|
+
const node = {
|
|
1208
1423
|
type: 'PanicError',
|
|
1209
1424
|
start: buffer[position],
|
|
1210
1425
|
end: buffer[position + 1],
|
|
1211
|
-
message
|
|
1426
|
+
get message() {
|
|
1427
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1428
|
+
Object.defineProperty(node, 'message', { value: result });
|
|
1429
|
+
return result;
|
|
1430
|
+
}
|
|
1212
1431
|
};
|
|
1432
|
+
return node;
|
|
1213
1433
|
},
|
|
1214
1434
|
function parseError(position, buffer) {
|
|
1215
|
-
|
|
1435
|
+
const node = {
|
|
1216
1436
|
type: 'ParseError',
|
|
1217
1437
|
start: buffer[position],
|
|
1218
1438
|
end: buffer[position + 1],
|
|
1219
|
-
message
|
|
1439
|
+
get message() {
|
|
1440
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1441
|
+
Object.defineProperty(node, 'message', { value: result });
|
|
1442
|
+
return result;
|
|
1443
|
+
}
|
|
1220
1444
|
};
|
|
1445
|
+
return node;
|
|
1221
1446
|
},
|
|
1222
1447
|
function arrayExpression(position, buffer) {
|
|
1223
|
-
|
|
1448
|
+
const node = {
|
|
1224
1449
|
type: 'ArrayExpression',
|
|
1225
1450
|
start: buffer[position],
|
|
1226
1451
|
end: buffer[position + 1],
|
|
1227
|
-
elements
|
|
1452
|
+
get elements() {
|
|
1453
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1454
|
+
Object.defineProperty(node, 'elements', { value: result });
|
|
1455
|
+
return result;
|
|
1456
|
+
}
|
|
1228
1457
|
};
|
|
1458
|
+
return node;
|
|
1229
1459
|
},
|
|
1230
1460
|
function arrayPattern(position, buffer) {
|
|
1231
|
-
|
|
1461
|
+
const node = {
|
|
1232
1462
|
type: 'ArrayPattern',
|
|
1233
1463
|
start: buffer[position],
|
|
1234
1464
|
end: buffer[position + 1],
|
|
1235
|
-
elements
|
|
1465
|
+
get elements() {
|
|
1466
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1467
|
+
Object.defineProperty(node, 'elements', { value: result });
|
|
1468
|
+
return result;
|
|
1469
|
+
}
|
|
1236
1470
|
};
|
|
1471
|
+
return node;
|
|
1237
1472
|
},
|
|
1238
1473
|
function arrowFunctionExpression(position, buffer) {
|
|
1239
1474
|
const flags = buffer[position + 2];
|
|
1240
1475
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1241
|
-
|
|
1476
|
+
const node = {
|
|
1242
1477
|
type: 'ArrowFunctionExpression',
|
|
1243
1478
|
start: buffer[position],
|
|
1244
1479
|
end: buffer[position + 1],
|
|
1245
1480
|
async: (flags & 1) === 1,
|
|
1246
1481
|
expression: (flags & 2) === 2,
|
|
1247
1482
|
generator: (flags & 4) === 4,
|
|
1248
|
-
...(annotations.length > 0 ? {
|
|
1249
|
-
params
|
|
1250
|
-
|
|
1483
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1484
|
+
get params() {
|
|
1485
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1486
|
+
Object.defineProperty(node, 'params', { value: result });
|
|
1487
|
+
return result;
|
|
1488
|
+
},
|
|
1489
|
+
get body() {
|
|
1490
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1491
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1492
|
+
return result;
|
|
1493
|
+
},
|
|
1251
1494
|
id: null
|
|
1252
1495
|
};
|
|
1496
|
+
return node;
|
|
1253
1497
|
},
|
|
1254
1498
|
function assignmentExpression(position, buffer) {
|
|
1255
|
-
|
|
1499
|
+
const node = {
|
|
1256
1500
|
type: 'AssignmentExpression',
|
|
1257
1501
|
start: buffer[position],
|
|
1258
1502
|
end: buffer[position + 1],
|
|
1259
|
-
operator
|
|
1260
|
-
|
|
1261
|
-
|
|
1503
|
+
get operator() {
|
|
1504
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
1505
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
1506
|
+
return result;
|
|
1507
|
+
},
|
|
1508
|
+
get left() {
|
|
1509
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1510
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1511
|
+
return result;
|
|
1512
|
+
},
|
|
1513
|
+
get right() {
|
|
1514
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1515
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1516
|
+
return result;
|
|
1517
|
+
}
|
|
1262
1518
|
};
|
|
1519
|
+
return node;
|
|
1263
1520
|
},
|
|
1264
1521
|
function assignmentPattern(position, buffer) {
|
|
1265
|
-
|
|
1522
|
+
const node = {
|
|
1266
1523
|
type: 'AssignmentPattern',
|
|
1267
1524
|
start: buffer[position],
|
|
1268
1525
|
end: buffer[position + 1],
|
|
1269
|
-
left
|
|
1270
|
-
|
|
1526
|
+
get left() {
|
|
1527
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1528
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1529
|
+
return result;
|
|
1530
|
+
},
|
|
1531
|
+
get right() {
|
|
1532
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1533
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1534
|
+
return result;
|
|
1535
|
+
}
|
|
1271
1536
|
};
|
|
1537
|
+
return node;
|
|
1272
1538
|
},
|
|
1273
1539
|
function awaitExpression(position, buffer) {
|
|
1274
|
-
|
|
1540
|
+
const node = {
|
|
1275
1541
|
type: 'AwaitExpression',
|
|
1276
1542
|
start: buffer[position],
|
|
1277
1543
|
end: buffer[position + 1],
|
|
1278
|
-
argument
|
|
1544
|
+
get argument() {
|
|
1545
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1546
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
1547
|
+
return result;
|
|
1548
|
+
}
|
|
1279
1549
|
};
|
|
1550
|
+
return node;
|
|
1280
1551
|
},
|
|
1281
1552
|
function binaryExpression(position, buffer) {
|
|
1282
|
-
|
|
1553
|
+
const node = {
|
|
1283
1554
|
type: 'BinaryExpression',
|
|
1284
1555
|
start: buffer[position],
|
|
1285
1556
|
end: buffer[position + 1],
|
|
1286
|
-
operator
|
|
1287
|
-
|
|
1288
|
-
|
|
1557
|
+
get operator() {
|
|
1558
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
1559
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
1560
|
+
return result;
|
|
1561
|
+
},
|
|
1562
|
+
get left() {
|
|
1563
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1564
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1565
|
+
return result;
|
|
1566
|
+
},
|
|
1567
|
+
get right() {
|
|
1568
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1569
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1570
|
+
return result;
|
|
1571
|
+
}
|
|
1289
1572
|
};
|
|
1573
|
+
return node;
|
|
1290
1574
|
},
|
|
1291
1575
|
function blockStatement(position, buffer) {
|
|
1292
|
-
|
|
1576
|
+
const node = {
|
|
1293
1577
|
type: 'BlockStatement',
|
|
1294
1578
|
start: buffer[position],
|
|
1295
1579
|
end: buffer[position + 1],
|
|
1296
|
-
body
|
|
1580
|
+
get body() {
|
|
1581
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1582
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1583
|
+
return result;
|
|
1584
|
+
}
|
|
1297
1585
|
};
|
|
1586
|
+
return node;
|
|
1298
1587
|
},
|
|
1299
1588
|
function breakStatement(position, buffer) {
|
|
1300
1589
|
const labelPosition = buffer[position + 2];
|
|
1301
|
-
|
|
1590
|
+
const node = {
|
|
1302
1591
|
type: 'BreakStatement',
|
|
1303
1592
|
start: buffer[position],
|
|
1304
1593
|
end: buffer[position + 1],
|
|
1305
|
-
label
|
|
1594
|
+
get label() {
|
|
1595
|
+
const result = labelPosition === 0 ? null : convertNode$1(labelPosition, buffer);
|
|
1596
|
+
Object.defineProperty(node, 'label', { value: result });
|
|
1597
|
+
return result;
|
|
1598
|
+
}
|
|
1306
1599
|
};
|
|
1600
|
+
return node;
|
|
1307
1601
|
},
|
|
1308
1602
|
function callExpression(position, buffer) {
|
|
1309
1603
|
const flags = buffer[position + 2];
|
|
1310
1604
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1311
|
-
|
|
1605
|
+
const node = {
|
|
1312
1606
|
type: 'CallExpression',
|
|
1313
1607
|
start: buffer[position],
|
|
1314
1608
|
end: buffer[position + 1],
|
|
1315
1609
|
optional: (flags & 1) === 1,
|
|
1316
|
-
...(annotations.length > 0 ? {
|
|
1317
|
-
callee
|
|
1318
|
-
|
|
1610
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
1611
|
+
get callee() {
|
|
1612
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1613
|
+
Object.defineProperty(node, 'callee', { value: result });
|
|
1614
|
+
return result;
|
|
1615
|
+
},
|
|
1616
|
+
get arguments() {
|
|
1617
|
+
const result = convertNodeList$1(buffer[position + 5], buffer);
|
|
1618
|
+
Object.defineProperty(node, 'arguments', { value: result });
|
|
1619
|
+
return result;
|
|
1620
|
+
}
|
|
1319
1621
|
};
|
|
1622
|
+
return node;
|
|
1320
1623
|
},
|
|
1321
1624
|
function catchClause(position, buffer) {
|
|
1322
1625
|
const parameterPosition = buffer[position + 2];
|
|
1323
|
-
|
|
1626
|
+
const node = {
|
|
1324
1627
|
type: 'CatchClause',
|
|
1325
1628
|
start: buffer[position],
|
|
1326
1629
|
end: buffer[position + 1],
|
|
1327
|
-
param
|
|
1328
|
-
|
|
1630
|
+
get param() {
|
|
1631
|
+
const result = parameterPosition === 0 ? null : convertNode$1(parameterPosition, buffer);
|
|
1632
|
+
Object.defineProperty(node, 'param', { value: result });
|
|
1633
|
+
return result;
|
|
1634
|
+
},
|
|
1635
|
+
get body() {
|
|
1636
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1637
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1638
|
+
return result;
|
|
1639
|
+
}
|
|
1329
1640
|
};
|
|
1641
|
+
return node;
|
|
1330
1642
|
},
|
|
1331
1643
|
function chainExpression(position, buffer) {
|
|
1332
|
-
|
|
1644
|
+
const node = {
|
|
1333
1645
|
type: 'ChainExpression',
|
|
1334
1646
|
start: buffer[position],
|
|
1335
1647
|
end: buffer[position + 1],
|
|
1336
|
-
expression
|
|
1648
|
+
get expression() {
|
|
1649
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1650
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1651
|
+
return result;
|
|
1652
|
+
}
|
|
1337
1653
|
};
|
|
1654
|
+
return node;
|
|
1338
1655
|
},
|
|
1339
1656
|
function classBody(position, buffer) {
|
|
1340
|
-
|
|
1657
|
+
const node = {
|
|
1341
1658
|
type: 'ClassBody',
|
|
1342
1659
|
start: buffer[position],
|
|
1343
1660
|
end: buffer[position + 1],
|
|
1344
|
-
body
|
|
1661
|
+
get body() {
|
|
1662
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1663
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1664
|
+
return result;
|
|
1665
|
+
}
|
|
1345
1666
|
};
|
|
1667
|
+
return node;
|
|
1346
1668
|
},
|
|
1347
1669
|
function classDeclaration(position, buffer) {
|
|
1348
1670
|
const idPosition = buffer[position + 3];
|
|
1349
1671
|
const superClassPosition = buffer[position + 4];
|
|
1350
|
-
|
|
1672
|
+
const node = {
|
|
1351
1673
|
type: 'ClassDeclaration',
|
|
1352
1674
|
start: buffer[position],
|
|
1353
1675
|
end: buffer[position + 1],
|
|
1354
|
-
decorators
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1676
|
+
get decorators() {
|
|
1677
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1678
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
1679
|
+
return result;
|
|
1680
|
+
},
|
|
1681
|
+
get id() {
|
|
1682
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
1683
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
1684
|
+
return result;
|
|
1685
|
+
},
|
|
1686
|
+
get superClass() {
|
|
1687
|
+
const result = superClassPosition === 0 ? null : convertNode$1(superClassPosition, buffer);
|
|
1688
|
+
Object.defineProperty(node, 'superClass', { value: result });
|
|
1689
|
+
return result;
|
|
1690
|
+
},
|
|
1691
|
+
get body() {
|
|
1692
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1693
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1694
|
+
return result;
|
|
1695
|
+
}
|
|
1358
1696
|
};
|
|
1697
|
+
return node;
|
|
1359
1698
|
},
|
|
1360
1699
|
function classExpression(position, buffer) {
|
|
1361
1700
|
const idPosition = buffer[position + 3];
|
|
1362
1701
|
const superClassPosition = buffer[position + 4];
|
|
1363
|
-
|
|
1702
|
+
const node = {
|
|
1364
1703
|
type: 'ClassExpression',
|
|
1365
1704
|
start: buffer[position],
|
|
1366
1705
|
end: buffer[position + 1],
|
|
1367
|
-
decorators
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1706
|
+
get decorators() {
|
|
1707
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1708
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
1709
|
+
return result;
|
|
1710
|
+
},
|
|
1711
|
+
get id() {
|
|
1712
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
1713
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
1714
|
+
return result;
|
|
1715
|
+
},
|
|
1716
|
+
get superClass() {
|
|
1717
|
+
const result = superClassPosition === 0 ? null : convertNode$1(superClassPosition, buffer);
|
|
1718
|
+
Object.defineProperty(node, 'superClass', { value: result });
|
|
1719
|
+
return result;
|
|
1720
|
+
},
|
|
1721
|
+
get body() {
|
|
1722
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1723
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1724
|
+
return result;
|
|
1725
|
+
}
|
|
1371
1726
|
};
|
|
1727
|
+
return node;
|
|
1372
1728
|
},
|
|
1373
1729
|
function conditionalExpression(position, buffer) {
|
|
1374
|
-
|
|
1730
|
+
const node = {
|
|
1375
1731
|
type: 'ConditionalExpression',
|
|
1376
1732
|
start: buffer[position],
|
|
1377
1733
|
end: buffer[position + 1],
|
|
1378
|
-
test
|
|
1379
|
-
|
|
1380
|
-
|
|
1734
|
+
get test() {
|
|
1735
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1736
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1737
|
+
return result;
|
|
1738
|
+
},
|
|
1739
|
+
get consequent() {
|
|
1740
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1741
|
+
Object.defineProperty(node, 'consequent', { value: result });
|
|
1742
|
+
return result;
|
|
1743
|
+
},
|
|
1744
|
+
get alternate() {
|
|
1745
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1746
|
+
Object.defineProperty(node, 'alternate', { value: result });
|
|
1747
|
+
return result;
|
|
1748
|
+
}
|
|
1381
1749
|
};
|
|
1750
|
+
return node;
|
|
1382
1751
|
},
|
|
1383
1752
|
function continueStatement(position, buffer) {
|
|
1384
1753
|
const labelPosition = buffer[position + 2];
|
|
1385
|
-
|
|
1754
|
+
const node = {
|
|
1386
1755
|
type: 'ContinueStatement',
|
|
1387
1756
|
start: buffer[position],
|
|
1388
1757
|
end: buffer[position + 1],
|
|
1389
|
-
label
|
|
1758
|
+
get label() {
|
|
1759
|
+
const result = labelPosition === 0 ? null : convertNode$1(labelPosition, buffer);
|
|
1760
|
+
Object.defineProperty(node, 'label', { value: result });
|
|
1761
|
+
return result;
|
|
1762
|
+
}
|
|
1390
1763
|
};
|
|
1764
|
+
return node;
|
|
1391
1765
|
},
|
|
1392
1766
|
function debuggerStatement(position, buffer) {
|
|
1393
|
-
|
|
1767
|
+
const node = {
|
|
1394
1768
|
type: 'DebuggerStatement',
|
|
1395
1769
|
start: buffer[position],
|
|
1396
1770
|
end: buffer[position + 1]
|
|
1397
1771
|
};
|
|
1772
|
+
return node;
|
|
1398
1773
|
},
|
|
1399
1774
|
function decorator(position, buffer) {
|
|
1400
|
-
|
|
1775
|
+
const node = {
|
|
1401
1776
|
type: 'Decorator',
|
|
1402
1777
|
start: buffer[position],
|
|
1403
1778
|
end: buffer[position + 1],
|
|
1404
|
-
expression
|
|
1779
|
+
get expression() {
|
|
1780
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1781
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1782
|
+
return result;
|
|
1783
|
+
}
|
|
1405
1784
|
};
|
|
1785
|
+
return node;
|
|
1406
1786
|
},
|
|
1407
1787
|
function directive(position, buffer) {
|
|
1408
|
-
|
|
1788
|
+
const node = {
|
|
1409
1789
|
type: 'ExpressionStatement',
|
|
1410
1790
|
start: buffer[position],
|
|
1411
1791
|
end: buffer[position + 1],
|
|
1412
|
-
directive
|
|
1413
|
-
|
|
1792
|
+
get directive() {
|
|
1793
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
1794
|
+
Object.defineProperty(node, 'directive', { value: result });
|
|
1795
|
+
return result;
|
|
1796
|
+
},
|
|
1797
|
+
get expression() {
|
|
1798
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1799
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1800
|
+
return result;
|
|
1801
|
+
}
|
|
1414
1802
|
};
|
|
1803
|
+
return node;
|
|
1415
1804
|
},
|
|
1416
1805
|
function doWhileStatement(position, buffer) {
|
|
1417
|
-
|
|
1806
|
+
const node = {
|
|
1418
1807
|
type: 'DoWhileStatement',
|
|
1419
1808
|
start: buffer[position],
|
|
1420
1809
|
end: buffer[position + 1],
|
|
1421
|
-
body
|
|
1422
|
-
|
|
1810
|
+
get body() {
|
|
1811
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1812
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1813
|
+
return result;
|
|
1814
|
+
},
|
|
1815
|
+
get test() {
|
|
1816
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1817
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1818
|
+
return result;
|
|
1819
|
+
}
|
|
1423
1820
|
};
|
|
1821
|
+
return node;
|
|
1424
1822
|
},
|
|
1425
1823
|
function emptyStatement(position, buffer) {
|
|
1426
|
-
|
|
1824
|
+
const node = {
|
|
1427
1825
|
type: 'EmptyStatement',
|
|
1428
1826
|
start: buffer[position],
|
|
1429
1827
|
end: buffer[position + 1]
|
|
1430
1828
|
};
|
|
1829
|
+
return node;
|
|
1431
1830
|
},
|
|
1432
1831
|
function exportAllDeclaration(position, buffer) {
|
|
1433
1832
|
const exportedPosition = buffer[position + 2];
|
|
1434
|
-
|
|
1833
|
+
const node = {
|
|
1435
1834
|
type: 'ExportAllDeclaration',
|
|
1436
1835
|
start: buffer[position],
|
|
1437
1836
|
end: buffer[position + 1],
|
|
1438
|
-
exported
|
|
1439
|
-
|
|
1440
|
-
|
|
1837
|
+
get exported() {
|
|
1838
|
+
const result = exportedPosition === 0 ? null : convertNode$1(exportedPosition, buffer);
|
|
1839
|
+
Object.defineProperty(node, 'exported', { value: result });
|
|
1840
|
+
return result;
|
|
1841
|
+
},
|
|
1842
|
+
get source() {
|
|
1843
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1844
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
1845
|
+
return result;
|
|
1846
|
+
},
|
|
1847
|
+
get attributes() {
|
|
1848
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1849
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
1850
|
+
return result;
|
|
1851
|
+
}
|
|
1441
1852
|
};
|
|
1853
|
+
return node;
|
|
1442
1854
|
},
|
|
1443
1855
|
function exportDefaultDeclaration(position, buffer) {
|
|
1444
|
-
|
|
1856
|
+
const node = {
|
|
1445
1857
|
type: 'ExportDefaultDeclaration',
|
|
1446
1858
|
start: buffer[position],
|
|
1447
1859
|
end: buffer[position + 1],
|
|
1448
|
-
declaration
|
|
1860
|
+
get declaration() {
|
|
1861
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1862
|
+
Object.defineProperty(node, 'declaration', { value: result });
|
|
1863
|
+
return result;
|
|
1864
|
+
}
|
|
1449
1865
|
};
|
|
1866
|
+
return node;
|
|
1450
1867
|
},
|
|
1451
1868
|
function exportNamedDeclaration(position, buffer) {
|
|
1452
1869
|
const sourcePosition = buffer[position + 3];
|
|
1453
1870
|
const declarationPosition = buffer[position + 5];
|
|
1454
|
-
|
|
1871
|
+
const node = {
|
|
1455
1872
|
type: 'ExportNamedDeclaration',
|
|
1456
1873
|
start: buffer[position],
|
|
1457
1874
|
end: buffer[position + 1],
|
|
1458
|
-
specifiers
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1875
|
+
get specifiers() {
|
|
1876
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
1877
|
+
Object.defineProperty(node, 'specifiers', { value: result });
|
|
1878
|
+
return result;
|
|
1879
|
+
},
|
|
1880
|
+
get source() {
|
|
1881
|
+
const result = sourcePosition === 0 ? null : convertNode$1(sourcePosition, buffer);
|
|
1882
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
1883
|
+
return result;
|
|
1884
|
+
},
|
|
1885
|
+
get attributes() {
|
|
1886
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
1887
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
1888
|
+
return result;
|
|
1889
|
+
},
|
|
1890
|
+
get declaration() {
|
|
1891
|
+
const result = declarationPosition === 0 ? null : convertNode$1(declarationPosition, buffer);
|
|
1892
|
+
Object.defineProperty(node, 'declaration', { value: result });
|
|
1893
|
+
return result;
|
|
1894
|
+
}
|
|
1462
1895
|
};
|
|
1896
|
+
return node;
|
|
1463
1897
|
},
|
|
1464
1898
|
function exportSpecifier(position, buffer) {
|
|
1465
|
-
const local = convertNode(buffer[position + 2], buffer);
|
|
1899
|
+
const local = convertNode$1(buffer[position + 2], buffer);
|
|
1466
1900
|
const exportedPosition = buffer[position + 3];
|
|
1467
|
-
|
|
1901
|
+
const node = {
|
|
1468
1902
|
type: 'ExportSpecifier',
|
|
1469
1903
|
start: buffer[position],
|
|
1470
1904
|
end: buffer[position + 1],
|
|
1471
1905
|
local,
|
|
1472
|
-
exported
|
|
1906
|
+
get exported() {
|
|
1907
|
+
const result = exportedPosition === 0 ? { ...local } : convertNode$1(exportedPosition, buffer);
|
|
1908
|
+
Object.defineProperty(node, 'exported', { value: result });
|
|
1909
|
+
return result;
|
|
1910
|
+
}
|
|
1473
1911
|
};
|
|
1912
|
+
return node;
|
|
1474
1913
|
},
|
|
1475
1914
|
function expressionStatement(position, buffer) {
|
|
1476
|
-
|
|
1915
|
+
const node = {
|
|
1477
1916
|
type: 'ExpressionStatement',
|
|
1478
1917
|
start: buffer[position],
|
|
1479
1918
|
end: buffer[position + 1],
|
|
1480
|
-
expression
|
|
1919
|
+
get expression() {
|
|
1920
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1921
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
1922
|
+
return result;
|
|
1923
|
+
}
|
|
1481
1924
|
};
|
|
1925
|
+
return node;
|
|
1482
1926
|
},
|
|
1483
1927
|
function forInStatement(position, buffer) {
|
|
1484
|
-
|
|
1928
|
+
const node = {
|
|
1485
1929
|
type: 'ForInStatement',
|
|
1486
1930
|
start: buffer[position],
|
|
1487
1931
|
end: buffer[position + 1],
|
|
1488
|
-
left
|
|
1489
|
-
|
|
1490
|
-
|
|
1932
|
+
get left() {
|
|
1933
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
1934
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1935
|
+
return result;
|
|
1936
|
+
},
|
|
1937
|
+
get right() {
|
|
1938
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1939
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1940
|
+
return result;
|
|
1941
|
+
},
|
|
1942
|
+
get body() {
|
|
1943
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1944
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1945
|
+
return result;
|
|
1946
|
+
}
|
|
1491
1947
|
};
|
|
1948
|
+
return node;
|
|
1492
1949
|
},
|
|
1493
1950
|
function forOfStatement(position, buffer) {
|
|
1494
1951
|
const flags = buffer[position + 2];
|
|
1495
|
-
|
|
1952
|
+
const node = {
|
|
1496
1953
|
type: 'ForOfStatement',
|
|
1497
1954
|
start: buffer[position],
|
|
1498
1955
|
end: buffer[position + 1],
|
|
1499
1956
|
await: (flags & 1) === 1,
|
|
1500
|
-
left
|
|
1501
|
-
|
|
1502
|
-
|
|
1957
|
+
get left() {
|
|
1958
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
1959
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
1960
|
+
return result;
|
|
1961
|
+
},
|
|
1962
|
+
get right() {
|
|
1963
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
1964
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
1965
|
+
return result;
|
|
1966
|
+
},
|
|
1967
|
+
get body() {
|
|
1968
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
1969
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
1970
|
+
return result;
|
|
1971
|
+
}
|
|
1503
1972
|
};
|
|
1973
|
+
return node;
|
|
1504
1974
|
},
|
|
1505
1975
|
function forStatement(position, buffer) {
|
|
1506
1976
|
const initPosition = buffer[position + 2];
|
|
1507
1977
|
const testPosition = buffer[position + 3];
|
|
1508
1978
|
const updatePosition = buffer[position + 4];
|
|
1509
|
-
|
|
1979
|
+
const node = {
|
|
1510
1980
|
type: 'ForStatement',
|
|
1511
1981
|
start: buffer[position],
|
|
1512
1982
|
end: buffer[position + 1],
|
|
1513
|
-
init
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1983
|
+
get init() {
|
|
1984
|
+
const result = initPosition === 0 ? null : convertNode$1(initPosition, buffer);
|
|
1985
|
+
Object.defineProperty(node, 'init', { value: result });
|
|
1986
|
+
return result;
|
|
1987
|
+
},
|
|
1988
|
+
get test() {
|
|
1989
|
+
const result = testPosition === 0 ? null : convertNode$1(testPosition, buffer);
|
|
1990
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
1991
|
+
return result;
|
|
1992
|
+
},
|
|
1993
|
+
get update() {
|
|
1994
|
+
const result = updatePosition === 0 ? null : convertNode$1(updatePosition, buffer);
|
|
1995
|
+
Object.defineProperty(node, 'update', { value: result });
|
|
1996
|
+
return result;
|
|
1997
|
+
},
|
|
1998
|
+
get body() {
|
|
1999
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
2000
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2001
|
+
return result;
|
|
2002
|
+
}
|
|
1517
2003
|
};
|
|
2004
|
+
return node;
|
|
1518
2005
|
},
|
|
1519
2006
|
function functionDeclaration(position, buffer) {
|
|
1520
2007
|
const flags = buffer[position + 2];
|
|
1521
2008
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1522
2009
|
const idPosition = buffer[position + 4];
|
|
1523
|
-
|
|
2010
|
+
const node = {
|
|
1524
2011
|
type: 'FunctionDeclaration',
|
|
1525
2012
|
start: buffer[position],
|
|
1526
2013
|
end: buffer[position + 1],
|
|
1527
2014
|
async: (flags & 1) === 1,
|
|
1528
2015
|
generator: (flags & 2) === 2,
|
|
1529
|
-
...(annotations.length > 0 ? {
|
|
1530
|
-
id
|
|
1531
|
-
|
|
1532
|
-
|
|
2016
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
2017
|
+
get id() {
|
|
2018
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
2019
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
2020
|
+
return result;
|
|
2021
|
+
},
|
|
2022
|
+
get params() {
|
|
2023
|
+
const result = convertNodeList$1(buffer[position + 5], buffer);
|
|
2024
|
+
Object.defineProperty(node, 'params', { value: result });
|
|
2025
|
+
return result;
|
|
2026
|
+
},
|
|
2027
|
+
get body() {
|
|
2028
|
+
const result = convertNode$1(buffer[position + 6], buffer);
|
|
2029
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2030
|
+
return result;
|
|
2031
|
+
},
|
|
1533
2032
|
expression: false
|
|
1534
2033
|
};
|
|
2034
|
+
return node;
|
|
1535
2035
|
},
|
|
1536
2036
|
function functionExpression(position, buffer) {
|
|
1537
2037
|
const flags = buffer[position + 2];
|
|
1538
2038
|
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1539
2039
|
const idPosition = buffer[position + 4];
|
|
1540
|
-
|
|
2040
|
+
const node = {
|
|
1541
2041
|
type: 'FunctionExpression',
|
|
1542
2042
|
start: buffer[position],
|
|
1543
2043
|
end: buffer[position + 1],
|
|
1544
2044
|
async: (flags & 1) === 1,
|
|
1545
2045
|
generator: (flags & 2) === 2,
|
|
1546
|
-
...(annotations.length > 0 ? {
|
|
1547
|
-
id
|
|
1548
|
-
|
|
1549
|
-
|
|
2046
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
2047
|
+
get id() {
|
|
2048
|
+
const result = idPosition === 0 ? null : convertNode$1(idPosition, buffer);
|
|
2049
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
2050
|
+
return result;
|
|
2051
|
+
},
|
|
2052
|
+
get params() {
|
|
2053
|
+
const result = convertNodeList$1(buffer[position + 5], buffer);
|
|
2054
|
+
Object.defineProperty(node, 'params', { value: result });
|
|
2055
|
+
return result;
|
|
2056
|
+
},
|
|
2057
|
+
get body() {
|
|
2058
|
+
const result = convertNode$1(buffer[position + 6], buffer);
|
|
2059
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2060
|
+
return result;
|
|
2061
|
+
},
|
|
1550
2062
|
expression: false
|
|
1551
2063
|
};
|
|
2064
|
+
return node;
|
|
1552
2065
|
},
|
|
1553
2066
|
function identifier(position, buffer) {
|
|
1554
|
-
|
|
2067
|
+
const node = {
|
|
1555
2068
|
type: 'Identifier',
|
|
1556
2069
|
start: buffer[position],
|
|
1557
2070
|
end: buffer[position + 1],
|
|
1558
|
-
name
|
|
2071
|
+
get name() {
|
|
2072
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2073
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2074
|
+
return result;
|
|
2075
|
+
}
|
|
1559
2076
|
};
|
|
2077
|
+
return node;
|
|
1560
2078
|
},
|
|
1561
2079
|
function ifStatement(position, buffer) {
|
|
1562
2080
|
const alternatePosition = buffer[position + 4];
|
|
1563
|
-
|
|
2081
|
+
const node = {
|
|
1564
2082
|
type: 'IfStatement',
|
|
1565
2083
|
start: buffer[position],
|
|
1566
2084
|
end: buffer[position + 1],
|
|
1567
|
-
test
|
|
1568
|
-
|
|
1569
|
-
|
|
2085
|
+
get test() {
|
|
2086
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2087
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
2088
|
+
return result;
|
|
2089
|
+
},
|
|
2090
|
+
get consequent() {
|
|
2091
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2092
|
+
Object.defineProperty(node, 'consequent', { value: result });
|
|
2093
|
+
return result;
|
|
2094
|
+
},
|
|
2095
|
+
get alternate() {
|
|
2096
|
+
const result = alternatePosition === 0 ? null : convertNode$1(alternatePosition, buffer);
|
|
2097
|
+
Object.defineProperty(node, 'alternate', { value: result });
|
|
2098
|
+
return result;
|
|
2099
|
+
}
|
|
1570
2100
|
};
|
|
2101
|
+
return node;
|
|
1571
2102
|
},
|
|
1572
2103
|
function importAttribute(position, buffer) {
|
|
1573
|
-
|
|
2104
|
+
const node = {
|
|
1574
2105
|
type: 'ImportAttribute',
|
|
1575
2106
|
start: buffer[position],
|
|
1576
2107
|
end: buffer[position + 1],
|
|
1577
|
-
key
|
|
1578
|
-
|
|
2108
|
+
get key() {
|
|
2109
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2110
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2111
|
+
return result;
|
|
2112
|
+
},
|
|
2113
|
+
get value() {
|
|
2114
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2115
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2116
|
+
return result;
|
|
2117
|
+
}
|
|
1579
2118
|
};
|
|
2119
|
+
return node;
|
|
1580
2120
|
},
|
|
1581
2121
|
function importDeclaration(position, buffer) {
|
|
1582
|
-
const
|
|
1583
|
-
|
|
2122
|
+
const phasePosition = buffer[position + 5];
|
|
2123
|
+
const node = {
|
|
1584
2124
|
type: 'ImportDeclaration',
|
|
1585
2125
|
start: buffer[position],
|
|
1586
2126
|
end: buffer[position + 1],
|
|
1587
|
-
specifiers
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
2127
|
+
get specifiers() {
|
|
2128
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2129
|
+
Object.defineProperty(node, 'specifiers', { value: result });
|
|
2130
|
+
return result;
|
|
2131
|
+
},
|
|
2132
|
+
get source() {
|
|
2133
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2134
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
2135
|
+
return result;
|
|
2136
|
+
},
|
|
2137
|
+
get attributes() {
|
|
2138
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
2139
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
2140
|
+
return result;
|
|
2141
|
+
},
|
|
2142
|
+
get phase() {
|
|
2143
|
+
const result = phasePosition === 0
|
|
2144
|
+
? undefined
|
|
2145
|
+
: FIXED_STRINGS[buffer[position + 5]];
|
|
2146
|
+
Object.defineProperty(node, 'phase', { value: result });
|
|
2147
|
+
return result;
|
|
2148
|
+
}
|
|
1591
2149
|
};
|
|
2150
|
+
return node;
|
|
1592
2151
|
},
|
|
1593
2152
|
function importDefaultSpecifier(position, buffer) {
|
|
1594
|
-
|
|
2153
|
+
const node = {
|
|
1595
2154
|
type: 'ImportDefaultSpecifier',
|
|
1596
2155
|
start: buffer[position],
|
|
1597
2156
|
end: buffer[position + 1],
|
|
1598
|
-
local
|
|
2157
|
+
get local() {
|
|
2158
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2159
|
+
Object.defineProperty(node, 'local', { value: result });
|
|
2160
|
+
return result;
|
|
2161
|
+
}
|
|
1599
2162
|
};
|
|
2163
|
+
return node;
|
|
1600
2164
|
},
|
|
1601
2165
|
function importExpression(position, buffer) {
|
|
1602
2166
|
const optionsPosition = buffer[position + 3];
|
|
1603
|
-
const
|
|
1604
|
-
|
|
2167
|
+
const phasePosition = buffer[position + 4];
|
|
2168
|
+
const node = {
|
|
1605
2169
|
type: 'ImportExpression',
|
|
1606
2170
|
start: buffer[position],
|
|
1607
2171
|
end: buffer[position + 1],
|
|
1608
|
-
source
|
|
1609
|
-
|
|
1610
|
-
|
|
2172
|
+
get source() {
|
|
2173
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2174
|
+
Object.defineProperty(node, 'source', { value: result });
|
|
2175
|
+
return result;
|
|
2176
|
+
},
|
|
2177
|
+
get options() {
|
|
2178
|
+
const result = optionsPosition === 0 ? null : convertNode$1(optionsPosition, buffer);
|
|
2179
|
+
Object.defineProperty(node, 'options', { value: result });
|
|
2180
|
+
return result;
|
|
2181
|
+
},
|
|
2182
|
+
get phase() {
|
|
2183
|
+
const result = phasePosition === 0
|
|
2184
|
+
? undefined
|
|
2185
|
+
: FIXED_STRINGS[buffer[position + 4]];
|
|
2186
|
+
Object.defineProperty(node, 'phase', { value: result });
|
|
2187
|
+
return result;
|
|
2188
|
+
}
|
|
1611
2189
|
};
|
|
2190
|
+
return node;
|
|
1612
2191
|
},
|
|
1613
2192
|
function importNamespaceSpecifier(position, buffer) {
|
|
1614
|
-
|
|
2193
|
+
const node = {
|
|
1615
2194
|
type: 'ImportNamespaceSpecifier',
|
|
1616
2195
|
start: buffer[position],
|
|
1617
2196
|
end: buffer[position + 1],
|
|
1618
|
-
local
|
|
2197
|
+
get local() {
|
|
2198
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2199
|
+
Object.defineProperty(node, 'local', { value: result });
|
|
2200
|
+
return result;
|
|
2201
|
+
}
|
|
1619
2202
|
};
|
|
2203
|
+
return node;
|
|
1620
2204
|
},
|
|
1621
2205
|
function importSpecifier(position, buffer) {
|
|
1622
2206
|
const importedPosition = buffer[position + 2];
|
|
1623
|
-
const local = convertNode(buffer[position + 3], buffer);
|
|
1624
|
-
|
|
2207
|
+
const local = convertNode$1(buffer[position + 3], buffer);
|
|
2208
|
+
const node = {
|
|
1625
2209
|
type: 'ImportSpecifier',
|
|
1626
2210
|
start: buffer[position],
|
|
1627
2211
|
end: buffer[position + 1],
|
|
1628
|
-
imported
|
|
2212
|
+
get imported() {
|
|
2213
|
+
const result = importedPosition === 0 ? { ...local } : convertNode$1(importedPosition, buffer);
|
|
2214
|
+
Object.defineProperty(node, 'imported', { value: result });
|
|
2215
|
+
return result;
|
|
2216
|
+
},
|
|
1629
2217
|
local
|
|
1630
2218
|
};
|
|
2219
|
+
return node;
|
|
1631
2220
|
},
|
|
1632
2221
|
function jsxAttribute(position, buffer) {
|
|
1633
2222
|
const valuePosition = buffer[position + 3];
|
|
1634
|
-
|
|
2223
|
+
const node = {
|
|
1635
2224
|
type: 'JSXAttribute',
|
|
1636
2225
|
start: buffer[position],
|
|
1637
2226
|
end: buffer[position + 1],
|
|
1638
|
-
name
|
|
1639
|
-
|
|
2227
|
+
get name() {
|
|
2228
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2229
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2230
|
+
return result;
|
|
2231
|
+
},
|
|
2232
|
+
get value() {
|
|
2233
|
+
const result = valuePosition === 0 ? null : convertNode$1(valuePosition, buffer);
|
|
2234
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2235
|
+
return result;
|
|
2236
|
+
}
|
|
1640
2237
|
};
|
|
2238
|
+
return node;
|
|
1641
2239
|
},
|
|
1642
2240
|
function jsxClosingElement(position, buffer) {
|
|
1643
|
-
|
|
2241
|
+
const node = {
|
|
1644
2242
|
type: 'JSXClosingElement',
|
|
1645
2243
|
start: buffer[position],
|
|
1646
2244
|
end: buffer[position + 1],
|
|
1647
|
-
name
|
|
2245
|
+
get name() {
|
|
2246
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2247
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2248
|
+
return result;
|
|
2249
|
+
}
|
|
1648
2250
|
};
|
|
2251
|
+
return node;
|
|
1649
2252
|
},
|
|
1650
2253
|
function jsxClosingFragment(position, buffer) {
|
|
1651
|
-
|
|
2254
|
+
const node = {
|
|
1652
2255
|
type: 'JSXClosingFragment',
|
|
1653
2256
|
start: buffer[position],
|
|
1654
2257
|
end: buffer[position + 1]
|
|
1655
2258
|
};
|
|
2259
|
+
return node;
|
|
1656
2260
|
},
|
|
1657
2261
|
function jsxElement(position, buffer) {
|
|
1658
2262
|
const closingElementPosition = buffer[position + 4];
|
|
1659
|
-
|
|
2263
|
+
const node = {
|
|
1660
2264
|
type: 'JSXElement',
|
|
1661
2265
|
start: buffer[position],
|
|
1662
2266
|
end: buffer[position + 1],
|
|
1663
|
-
openingElement
|
|
1664
|
-
|
|
1665
|
-
|
|
2267
|
+
get openingElement() {
|
|
2268
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2269
|
+
Object.defineProperty(node, 'openingElement', { value: result });
|
|
2270
|
+
return result;
|
|
2271
|
+
},
|
|
2272
|
+
get children() {
|
|
2273
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2274
|
+
Object.defineProperty(node, 'children', { value: result });
|
|
2275
|
+
return result;
|
|
2276
|
+
},
|
|
2277
|
+
get closingElement() {
|
|
2278
|
+
const result = closingElementPosition === 0 ? null : convertNode$1(closingElementPosition, buffer);
|
|
2279
|
+
Object.defineProperty(node, 'closingElement', { value: result });
|
|
2280
|
+
return result;
|
|
2281
|
+
}
|
|
1666
2282
|
};
|
|
2283
|
+
return node;
|
|
1667
2284
|
},
|
|
1668
2285
|
function jsxEmptyExpression(position, buffer) {
|
|
1669
|
-
|
|
2286
|
+
const node = {
|
|
1670
2287
|
type: 'JSXEmptyExpression',
|
|
1671
2288
|
start: buffer[position],
|
|
1672
2289
|
end: buffer[position + 1]
|
|
1673
2290
|
};
|
|
2291
|
+
return node;
|
|
1674
2292
|
},
|
|
1675
2293
|
function jsxExpressionContainer(position, buffer) {
|
|
1676
|
-
|
|
2294
|
+
const node = {
|
|
1677
2295
|
type: 'JSXExpressionContainer',
|
|
1678
2296
|
start: buffer[position],
|
|
1679
2297
|
end: buffer[position + 1],
|
|
1680
|
-
expression
|
|
2298
|
+
get expression() {
|
|
2299
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2300
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
2301
|
+
return result;
|
|
2302
|
+
}
|
|
1681
2303
|
};
|
|
2304
|
+
return node;
|
|
1682
2305
|
},
|
|
1683
2306
|
function jsxFragment(position, buffer) {
|
|
1684
|
-
|
|
2307
|
+
const node = {
|
|
1685
2308
|
type: 'JSXFragment',
|
|
1686
2309
|
start: buffer[position],
|
|
1687
2310
|
end: buffer[position + 1],
|
|
1688
|
-
openingFragment
|
|
1689
|
-
|
|
1690
|
-
|
|
2311
|
+
get openingFragment() {
|
|
2312
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2313
|
+
Object.defineProperty(node, 'openingFragment', { value: result });
|
|
2314
|
+
return result;
|
|
2315
|
+
},
|
|
2316
|
+
get children() {
|
|
2317
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2318
|
+
Object.defineProperty(node, 'children', { value: result });
|
|
2319
|
+
return result;
|
|
2320
|
+
},
|
|
2321
|
+
get closingFragment() {
|
|
2322
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2323
|
+
Object.defineProperty(node, 'closingFragment', { value: result });
|
|
2324
|
+
return result;
|
|
2325
|
+
}
|
|
1691
2326
|
};
|
|
2327
|
+
return node;
|
|
1692
2328
|
},
|
|
1693
2329
|
function jsxIdentifier(position, buffer) {
|
|
1694
|
-
|
|
2330
|
+
const node = {
|
|
1695
2331
|
type: 'JSXIdentifier',
|
|
1696
2332
|
start: buffer[position],
|
|
1697
2333
|
end: buffer[position + 1],
|
|
1698
|
-
name
|
|
2334
|
+
get name() {
|
|
2335
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2336
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2337
|
+
return result;
|
|
2338
|
+
}
|
|
1699
2339
|
};
|
|
2340
|
+
return node;
|
|
1700
2341
|
},
|
|
1701
2342
|
function jsxMemberExpression(position, buffer) {
|
|
1702
|
-
|
|
2343
|
+
const node = {
|
|
1703
2344
|
type: 'JSXMemberExpression',
|
|
1704
2345
|
start: buffer[position],
|
|
1705
2346
|
end: buffer[position + 1],
|
|
1706
|
-
object
|
|
1707
|
-
|
|
2347
|
+
get object() {
|
|
2348
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2349
|
+
Object.defineProperty(node, 'object', { value: result });
|
|
2350
|
+
return result;
|
|
2351
|
+
},
|
|
2352
|
+
get property() {
|
|
2353
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2354
|
+
Object.defineProperty(node, 'property', { value: result });
|
|
2355
|
+
return result;
|
|
2356
|
+
}
|
|
1708
2357
|
};
|
|
2358
|
+
return node;
|
|
1709
2359
|
},
|
|
1710
2360
|
function jsxNamespacedName(position, buffer) {
|
|
1711
|
-
|
|
2361
|
+
const node = {
|
|
1712
2362
|
type: 'JSXNamespacedName',
|
|
1713
2363
|
start: buffer[position],
|
|
1714
2364
|
end: buffer[position + 1],
|
|
1715
|
-
namespace
|
|
1716
|
-
|
|
2365
|
+
get namespace() {
|
|
2366
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2367
|
+
Object.defineProperty(node, 'namespace', { value: result });
|
|
2368
|
+
return result;
|
|
2369
|
+
},
|
|
2370
|
+
get name() {
|
|
2371
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2372
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2373
|
+
return result;
|
|
2374
|
+
}
|
|
1717
2375
|
};
|
|
2376
|
+
return node;
|
|
1718
2377
|
},
|
|
1719
2378
|
function jsxOpeningElement(position, buffer) {
|
|
1720
2379
|
const flags = buffer[position + 2];
|
|
1721
|
-
|
|
2380
|
+
const node = {
|
|
1722
2381
|
type: 'JSXOpeningElement',
|
|
1723
2382
|
start: buffer[position],
|
|
1724
2383
|
end: buffer[position + 1],
|
|
1725
2384
|
selfClosing: (flags & 1) === 1,
|
|
1726
|
-
name
|
|
1727
|
-
|
|
2385
|
+
get name() {
|
|
2386
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2387
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2388
|
+
return result;
|
|
2389
|
+
},
|
|
2390
|
+
get attributes() {
|
|
2391
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
2392
|
+
Object.defineProperty(node, 'attributes', { value: result });
|
|
2393
|
+
return result;
|
|
2394
|
+
}
|
|
1728
2395
|
};
|
|
2396
|
+
return node;
|
|
1729
2397
|
},
|
|
1730
2398
|
function jsxOpeningFragment(position, buffer) {
|
|
1731
|
-
|
|
2399
|
+
const node = {
|
|
1732
2400
|
type: 'JSXOpeningFragment',
|
|
1733
2401
|
start: buffer[position],
|
|
1734
2402
|
end: buffer[position + 1],
|
|
1735
2403
|
attributes: [],
|
|
1736
2404
|
selfClosing: false
|
|
1737
2405
|
};
|
|
2406
|
+
return node;
|
|
1738
2407
|
},
|
|
1739
2408
|
function jsxSpreadAttribute(position, buffer) {
|
|
1740
|
-
|
|
2409
|
+
const node = {
|
|
1741
2410
|
type: 'JSXSpreadAttribute',
|
|
1742
2411
|
start: buffer[position],
|
|
1743
2412
|
end: buffer[position + 1],
|
|
1744
|
-
argument
|
|
2413
|
+
get argument() {
|
|
2414
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2415
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2416
|
+
return result;
|
|
2417
|
+
}
|
|
1745
2418
|
};
|
|
2419
|
+
return node;
|
|
1746
2420
|
},
|
|
1747
2421
|
function jsxSpreadChild(position, buffer) {
|
|
1748
|
-
|
|
2422
|
+
const node = {
|
|
1749
2423
|
type: 'JSXSpreadChild',
|
|
1750
2424
|
start: buffer[position],
|
|
1751
2425
|
end: buffer[position + 1],
|
|
1752
|
-
expression
|
|
2426
|
+
get expression() {
|
|
2427
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2428
|
+
Object.defineProperty(node, 'expression', { value: result });
|
|
2429
|
+
return result;
|
|
2430
|
+
}
|
|
1753
2431
|
};
|
|
2432
|
+
return node;
|
|
1754
2433
|
},
|
|
1755
2434
|
function jsxText(position, buffer) {
|
|
1756
|
-
|
|
2435
|
+
const node = {
|
|
1757
2436
|
type: 'JSXText',
|
|
1758
2437
|
start: buffer[position],
|
|
1759
2438
|
end: buffer[position + 1],
|
|
1760
|
-
value
|
|
1761
|
-
|
|
2439
|
+
get value() {
|
|
2440
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2441
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2442
|
+
return result;
|
|
2443
|
+
},
|
|
2444
|
+
get raw() {
|
|
2445
|
+
const result = buffer.convertString(buffer[position + 3]);
|
|
2446
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2447
|
+
return result;
|
|
2448
|
+
}
|
|
1762
2449
|
};
|
|
2450
|
+
return node;
|
|
1763
2451
|
},
|
|
1764
2452
|
function labeledStatement(position, buffer) {
|
|
1765
|
-
|
|
2453
|
+
const node = {
|
|
1766
2454
|
type: 'LabeledStatement',
|
|
1767
2455
|
start: buffer[position],
|
|
1768
2456
|
end: buffer[position + 1],
|
|
1769
|
-
label
|
|
1770
|
-
|
|
2457
|
+
get label() {
|
|
2458
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2459
|
+
Object.defineProperty(node, 'label', { value: result });
|
|
2460
|
+
return result;
|
|
2461
|
+
},
|
|
2462
|
+
get body() {
|
|
2463
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2464
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2465
|
+
return result;
|
|
2466
|
+
}
|
|
1771
2467
|
};
|
|
2468
|
+
return node;
|
|
1772
2469
|
},
|
|
1773
2470
|
function literalBigInt(position, buffer) {
|
|
1774
2471
|
const bigint = buffer.convertString(buffer[position + 2]);
|
|
1775
|
-
|
|
2472
|
+
const node = {
|
|
1776
2473
|
type: 'Literal',
|
|
1777
2474
|
start: buffer[position],
|
|
1778
2475
|
end: buffer[position + 1],
|
|
1779
2476
|
bigint,
|
|
1780
|
-
raw
|
|
2477
|
+
get raw() {
|
|
2478
|
+
const result = buffer.convertString(buffer[position + 3]);
|
|
2479
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2480
|
+
return result;
|
|
2481
|
+
},
|
|
1781
2482
|
value: BigInt(bigint)
|
|
1782
2483
|
};
|
|
2484
|
+
return node;
|
|
1783
2485
|
},
|
|
1784
2486
|
function literalBoolean(position, buffer) {
|
|
1785
2487
|
const flags = buffer[position + 2];
|
|
1786
2488
|
const value = (flags & 1) === 1;
|
|
1787
|
-
|
|
2489
|
+
const node = {
|
|
1788
2490
|
type: 'Literal',
|
|
1789
2491
|
start: buffer[position],
|
|
1790
2492
|
end: buffer[position + 1],
|
|
1791
2493
|
value,
|
|
1792
2494
|
raw: value ? 'true' : 'false'
|
|
1793
2495
|
};
|
|
2496
|
+
return node;
|
|
1794
2497
|
},
|
|
1795
2498
|
function literalNull(position, buffer) {
|
|
1796
|
-
|
|
2499
|
+
const node = {
|
|
1797
2500
|
type: 'Literal',
|
|
1798
2501
|
start: buffer[position],
|
|
1799
2502
|
end: buffer[position + 1],
|
|
1800
2503
|
raw: 'null',
|
|
1801
2504
|
value: null
|
|
1802
2505
|
};
|
|
2506
|
+
return node;
|
|
1803
2507
|
},
|
|
1804
2508
|
function literalNumber(position, buffer) {
|
|
1805
2509
|
const rawPosition = buffer[position + 2];
|
|
1806
|
-
|
|
2510
|
+
const node = {
|
|
1807
2511
|
type: 'Literal',
|
|
1808
2512
|
start: buffer[position],
|
|
1809
2513
|
end: buffer[position + 1],
|
|
1810
|
-
raw
|
|
1811
|
-
|
|
2514
|
+
get raw() {
|
|
2515
|
+
const result = rawPosition === 0 ? undefined : buffer.convertString(rawPosition);
|
|
2516
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2517
|
+
return result;
|
|
2518
|
+
},
|
|
2519
|
+
get value() {
|
|
2520
|
+
const result = new DataView(buffer.buffer).getFloat64((position + 3) << 2, true);
|
|
2521
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2522
|
+
return result;
|
|
2523
|
+
}
|
|
1812
2524
|
};
|
|
2525
|
+
return node;
|
|
1813
2526
|
},
|
|
1814
2527
|
function literalRegExp(position, buffer) {
|
|
1815
2528
|
const flags = buffer.convertString(buffer[position + 2]);
|
|
1816
2529
|
const pattern = buffer.convertString(buffer[position + 3]);
|
|
1817
|
-
|
|
2530
|
+
const node = {
|
|
1818
2531
|
type: 'Literal',
|
|
1819
2532
|
start: buffer[position],
|
|
1820
2533
|
end: buffer[position + 1],
|
|
@@ -1822,218 +2535,1640 @@ const nodeConverters = [
|
|
|
1822
2535
|
regex: { flags, pattern },
|
|
1823
2536
|
value: new RegExp(pattern, flags)
|
|
1824
2537
|
};
|
|
2538
|
+
return node;
|
|
1825
2539
|
},
|
|
1826
2540
|
function literalString(position, buffer) {
|
|
1827
2541
|
const rawPosition = buffer[position + 3];
|
|
1828
|
-
|
|
2542
|
+
const node = {
|
|
1829
2543
|
type: 'Literal',
|
|
1830
2544
|
start: buffer[position],
|
|
1831
2545
|
end: buffer[position + 1],
|
|
1832
|
-
value
|
|
1833
|
-
|
|
2546
|
+
get value() {
|
|
2547
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2548
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2549
|
+
return result;
|
|
2550
|
+
},
|
|
2551
|
+
get raw() {
|
|
2552
|
+
const result = rawPosition === 0 ? undefined : buffer.convertString(rawPosition);
|
|
2553
|
+
Object.defineProperty(node, 'raw', { value: result });
|
|
2554
|
+
return result;
|
|
2555
|
+
}
|
|
1834
2556
|
};
|
|
2557
|
+
return node;
|
|
1835
2558
|
},
|
|
1836
2559
|
function logicalExpression(position, buffer) {
|
|
1837
|
-
|
|
2560
|
+
const node = {
|
|
1838
2561
|
type: 'LogicalExpression',
|
|
1839
2562
|
start: buffer[position],
|
|
1840
2563
|
end: buffer[position + 1],
|
|
1841
|
-
operator
|
|
1842
|
-
|
|
1843
|
-
|
|
2564
|
+
get operator() {
|
|
2565
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
2566
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
2567
|
+
return result;
|
|
2568
|
+
},
|
|
2569
|
+
get left() {
|
|
2570
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2571
|
+
Object.defineProperty(node, 'left', { value: result });
|
|
2572
|
+
return result;
|
|
2573
|
+
},
|
|
2574
|
+
get right() {
|
|
2575
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2576
|
+
Object.defineProperty(node, 'right', { value: result });
|
|
2577
|
+
return result;
|
|
2578
|
+
}
|
|
1844
2579
|
};
|
|
2580
|
+
return node;
|
|
1845
2581
|
},
|
|
1846
2582
|
function memberExpression(position, buffer) {
|
|
1847
2583
|
const flags = buffer[position + 2];
|
|
1848
|
-
|
|
2584
|
+
const node = {
|
|
1849
2585
|
type: 'MemberExpression',
|
|
1850
2586
|
start: buffer[position],
|
|
1851
2587
|
end: buffer[position + 1],
|
|
1852
2588
|
computed: (flags & 1) === 1,
|
|
1853
2589
|
optional: (flags & 2) === 2,
|
|
1854
|
-
object
|
|
1855
|
-
|
|
2590
|
+
get object() {
|
|
2591
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2592
|
+
Object.defineProperty(node, 'object', { value: result });
|
|
2593
|
+
return result;
|
|
2594
|
+
},
|
|
2595
|
+
get property() {
|
|
2596
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2597
|
+
Object.defineProperty(node, 'property', { value: result });
|
|
2598
|
+
return result;
|
|
2599
|
+
}
|
|
1856
2600
|
};
|
|
2601
|
+
return node;
|
|
1857
2602
|
},
|
|
1858
2603
|
function metaProperty(position, buffer) {
|
|
1859
|
-
|
|
2604
|
+
const node = {
|
|
1860
2605
|
type: 'MetaProperty',
|
|
1861
2606
|
start: buffer[position],
|
|
1862
2607
|
end: buffer[position + 1],
|
|
1863
|
-
meta
|
|
1864
|
-
|
|
2608
|
+
get meta() {
|
|
2609
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2610
|
+
Object.defineProperty(node, 'meta', { value: result });
|
|
2611
|
+
return result;
|
|
2612
|
+
},
|
|
2613
|
+
get property() {
|
|
2614
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2615
|
+
Object.defineProperty(node, 'property', { value: result });
|
|
2616
|
+
return result;
|
|
2617
|
+
}
|
|
1865
2618
|
};
|
|
2619
|
+
return node;
|
|
1866
2620
|
},
|
|
1867
2621
|
function methodDefinition(position, buffer) {
|
|
1868
2622
|
const flags = buffer[position + 2];
|
|
1869
|
-
|
|
2623
|
+
const node = {
|
|
1870
2624
|
type: 'MethodDefinition',
|
|
1871
2625
|
start: buffer[position],
|
|
1872
2626
|
end: buffer[position + 1],
|
|
1873
2627
|
static: (flags & 1) === 1,
|
|
1874
2628
|
computed: (flags & 2) === 2,
|
|
1875
|
-
decorators
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
2629
|
+
get decorators() {
|
|
2630
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2631
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
2632
|
+
return result;
|
|
2633
|
+
},
|
|
2634
|
+
get key() {
|
|
2635
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2636
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2637
|
+
return result;
|
|
2638
|
+
},
|
|
2639
|
+
get value() {
|
|
2640
|
+
const result = convertNode$1(buffer[position + 5], buffer);
|
|
2641
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2642
|
+
return result;
|
|
2643
|
+
},
|
|
2644
|
+
get kind() {
|
|
2645
|
+
const result = FIXED_STRINGS[buffer[position + 6]];
|
|
2646
|
+
Object.defineProperty(node, 'kind', { value: result });
|
|
2647
|
+
return result;
|
|
2648
|
+
}
|
|
1879
2649
|
};
|
|
2650
|
+
return node;
|
|
1880
2651
|
},
|
|
1881
2652
|
function newExpression(position, buffer) {
|
|
1882
2653
|
const annotations = convertAnnotations(buffer[position + 2], buffer);
|
|
1883
|
-
|
|
2654
|
+
const node = {
|
|
1884
2655
|
type: 'NewExpression',
|
|
1885
2656
|
start: buffer[position],
|
|
1886
2657
|
end: buffer[position + 1],
|
|
1887
|
-
...(annotations.length > 0 ? {
|
|
1888
|
-
callee
|
|
1889
|
-
|
|
2658
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
2659
|
+
get callee() {
|
|
2660
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2661
|
+
Object.defineProperty(node, 'callee', { value: result });
|
|
2662
|
+
return result;
|
|
2663
|
+
},
|
|
2664
|
+
get arguments() {
|
|
2665
|
+
const result = convertNodeList$1(buffer[position + 4], buffer);
|
|
2666
|
+
Object.defineProperty(node, 'arguments', { value: result });
|
|
2667
|
+
return result;
|
|
2668
|
+
}
|
|
1890
2669
|
};
|
|
2670
|
+
return node;
|
|
1891
2671
|
},
|
|
1892
2672
|
function objectExpression(position, buffer) {
|
|
1893
|
-
|
|
2673
|
+
const node = {
|
|
1894
2674
|
type: 'ObjectExpression',
|
|
1895
2675
|
start: buffer[position],
|
|
1896
2676
|
end: buffer[position + 1],
|
|
1897
|
-
properties
|
|
2677
|
+
get properties() {
|
|
2678
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2679
|
+
Object.defineProperty(node, 'properties', { value: result });
|
|
2680
|
+
return result;
|
|
2681
|
+
}
|
|
1898
2682
|
};
|
|
2683
|
+
return node;
|
|
1899
2684
|
},
|
|
1900
2685
|
function objectPattern(position, buffer) {
|
|
1901
|
-
|
|
2686
|
+
const node = {
|
|
1902
2687
|
type: 'ObjectPattern',
|
|
1903
2688
|
start: buffer[position],
|
|
1904
2689
|
end: buffer[position + 1],
|
|
1905
|
-
properties
|
|
2690
|
+
get properties() {
|
|
2691
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2692
|
+
Object.defineProperty(node, 'properties', { value: result });
|
|
2693
|
+
return result;
|
|
2694
|
+
}
|
|
1906
2695
|
};
|
|
2696
|
+
return node;
|
|
1907
2697
|
},
|
|
1908
2698
|
function privateIdentifier(position, buffer) {
|
|
1909
|
-
|
|
2699
|
+
const node = {
|
|
1910
2700
|
type: 'PrivateIdentifier',
|
|
1911
2701
|
start: buffer[position],
|
|
1912
2702
|
end: buffer[position + 1],
|
|
1913
|
-
name
|
|
2703
|
+
get name() {
|
|
2704
|
+
const result = buffer.convertString(buffer[position + 2]);
|
|
2705
|
+
Object.defineProperty(node, 'name', { value: result });
|
|
2706
|
+
return result;
|
|
2707
|
+
}
|
|
1914
2708
|
};
|
|
2709
|
+
return node;
|
|
1915
2710
|
},
|
|
1916
2711
|
function program(position, buffer) {
|
|
1917
2712
|
const invalidAnnotations = convertAnnotations(buffer[position + 3], buffer);
|
|
1918
|
-
|
|
2713
|
+
const node = {
|
|
1919
2714
|
type: 'Program',
|
|
1920
2715
|
start: buffer[position],
|
|
1921
2716
|
end: buffer[position + 1],
|
|
1922
|
-
body
|
|
1923
|
-
|
|
2717
|
+
get body() {
|
|
2718
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2719
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2720
|
+
return result;
|
|
2721
|
+
},
|
|
2722
|
+
...(invalidAnnotations.length > 0 ? { invalidAnnotations } : {}),
|
|
1924
2723
|
sourceType: 'module'
|
|
1925
2724
|
};
|
|
2725
|
+
return node;
|
|
1926
2726
|
},
|
|
1927
2727
|
function property(position, buffer) {
|
|
1928
2728
|
const flags = buffer[position + 2];
|
|
1929
2729
|
const keyPosition = buffer[position + 3];
|
|
1930
|
-
const value = convertNode(buffer[position + 4], buffer);
|
|
1931
|
-
|
|
2730
|
+
const value = convertNode$1(buffer[position + 4], buffer);
|
|
2731
|
+
const node = {
|
|
1932
2732
|
type: 'Property',
|
|
1933
2733
|
start: buffer[position],
|
|
1934
2734
|
end: buffer[position + 1],
|
|
1935
2735
|
method: (flags & 1) === 1,
|
|
1936
2736
|
shorthand: (flags & 2) === 2,
|
|
1937
2737
|
computed: (flags & 4) === 4,
|
|
1938
|
-
key
|
|
2738
|
+
get key() {
|
|
2739
|
+
const result = keyPosition === 0 ? { ...value } : convertNode$1(keyPosition, buffer);
|
|
2740
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2741
|
+
return result;
|
|
2742
|
+
},
|
|
1939
2743
|
value,
|
|
1940
|
-
kind
|
|
2744
|
+
get kind() {
|
|
2745
|
+
const result = FIXED_STRINGS[buffer[position + 5]];
|
|
2746
|
+
Object.defineProperty(node, 'kind', { value: result });
|
|
2747
|
+
return result;
|
|
2748
|
+
}
|
|
1941
2749
|
};
|
|
2750
|
+
return node;
|
|
1942
2751
|
},
|
|
1943
2752
|
function propertyDefinition(position, buffer) {
|
|
1944
2753
|
const flags = buffer[position + 2];
|
|
1945
2754
|
const valuePosition = buffer[position + 5];
|
|
1946
|
-
|
|
2755
|
+
const node = {
|
|
1947
2756
|
type: 'PropertyDefinition',
|
|
1948
2757
|
start: buffer[position],
|
|
1949
2758
|
end: buffer[position + 1],
|
|
1950
2759
|
static: (flags & 1) === 1,
|
|
1951
2760
|
computed: (flags & 2) === 2,
|
|
1952
|
-
decorators
|
|
1953
|
-
|
|
1954
|
-
|
|
2761
|
+
get decorators() {
|
|
2762
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2763
|
+
Object.defineProperty(node, 'decorators', { value: result });
|
|
2764
|
+
return result;
|
|
2765
|
+
},
|
|
2766
|
+
get key() {
|
|
2767
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
2768
|
+
Object.defineProperty(node, 'key', { value: result });
|
|
2769
|
+
return result;
|
|
2770
|
+
},
|
|
2771
|
+
get value() {
|
|
2772
|
+
const result = valuePosition === 0 ? null : convertNode$1(valuePosition, buffer);
|
|
2773
|
+
Object.defineProperty(node, 'value', { value: result });
|
|
2774
|
+
return result;
|
|
2775
|
+
}
|
|
1955
2776
|
};
|
|
2777
|
+
return node;
|
|
1956
2778
|
},
|
|
1957
2779
|
function restElement(position, buffer) {
|
|
1958
|
-
|
|
2780
|
+
const node = {
|
|
1959
2781
|
type: 'RestElement',
|
|
1960
2782
|
start: buffer[position],
|
|
1961
2783
|
end: buffer[position + 1],
|
|
1962
|
-
argument
|
|
2784
|
+
get argument() {
|
|
2785
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2786
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2787
|
+
return result;
|
|
2788
|
+
}
|
|
1963
2789
|
};
|
|
2790
|
+
return node;
|
|
1964
2791
|
},
|
|
1965
2792
|
function returnStatement(position, buffer) {
|
|
1966
2793
|
const argumentPosition = buffer[position + 2];
|
|
1967
|
-
|
|
2794
|
+
const node = {
|
|
1968
2795
|
type: 'ReturnStatement',
|
|
1969
2796
|
start: buffer[position],
|
|
1970
2797
|
end: buffer[position + 1],
|
|
1971
|
-
argument
|
|
2798
|
+
get argument() {
|
|
2799
|
+
const result = argumentPosition === 0 ? null : convertNode$1(argumentPosition, buffer);
|
|
2800
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2801
|
+
return result;
|
|
2802
|
+
}
|
|
1972
2803
|
};
|
|
2804
|
+
return node;
|
|
1973
2805
|
},
|
|
1974
2806
|
function sequenceExpression(position, buffer) {
|
|
1975
|
-
|
|
2807
|
+
const node = {
|
|
1976
2808
|
type: 'SequenceExpression',
|
|
1977
2809
|
start: buffer[position],
|
|
1978
2810
|
end: buffer[position + 1],
|
|
1979
|
-
expressions
|
|
2811
|
+
get expressions() {
|
|
2812
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2813
|
+
Object.defineProperty(node, 'expressions', { value: result });
|
|
2814
|
+
return result;
|
|
2815
|
+
}
|
|
1980
2816
|
};
|
|
2817
|
+
return node;
|
|
1981
2818
|
},
|
|
1982
2819
|
function spreadElement(position, buffer) {
|
|
1983
|
-
|
|
2820
|
+
const node = {
|
|
1984
2821
|
type: 'SpreadElement',
|
|
1985
2822
|
start: buffer[position],
|
|
1986
2823
|
end: buffer[position + 1],
|
|
1987
|
-
argument
|
|
2824
|
+
get argument() {
|
|
2825
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2826
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2827
|
+
return result;
|
|
2828
|
+
}
|
|
1988
2829
|
};
|
|
2830
|
+
return node;
|
|
1989
2831
|
},
|
|
1990
2832
|
function staticBlock(position, buffer) {
|
|
1991
|
-
|
|
2833
|
+
const node = {
|
|
1992
2834
|
type: 'StaticBlock',
|
|
1993
2835
|
start: buffer[position],
|
|
1994
2836
|
end: buffer[position + 1],
|
|
1995
|
-
body
|
|
2837
|
+
get body() {
|
|
2838
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2839
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
2840
|
+
return result;
|
|
2841
|
+
}
|
|
1996
2842
|
};
|
|
2843
|
+
return node;
|
|
1997
2844
|
},
|
|
1998
2845
|
function superElement(position, buffer) {
|
|
1999
|
-
|
|
2846
|
+
const node = {
|
|
2000
2847
|
type: 'Super',
|
|
2001
2848
|
start: buffer[position],
|
|
2002
2849
|
end: buffer[position + 1]
|
|
2003
2850
|
};
|
|
2851
|
+
return node;
|
|
2004
2852
|
},
|
|
2005
2853
|
function switchCase(position, buffer) {
|
|
2006
2854
|
const testPosition = buffer[position + 2];
|
|
2007
|
-
|
|
2855
|
+
const node = {
|
|
2008
2856
|
type: 'SwitchCase',
|
|
2009
2857
|
start: buffer[position],
|
|
2010
2858
|
end: buffer[position + 1],
|
|
2011
|
-
test
|
|
2012
|
-
|
|
2859
|
+
get test() {
|
|
2860
|
+
const result = testPosition === 0 ? null : convertNode$1(testPosition, buffer);
|
|
2861
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
2862
|
+
return result;
|
|
2863
|
+
},
|
|
2864
|
+
get consequent() {
|
|
2865
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2866
|
+
Object.defineProperty(node, 'consequent', { value: result });
|
|
2867
|
+
return result;
|
|
2868
|
+
}
|
|
2013
2869
|
};
|
|
2870
|
+
return node;
|
|
2014
2871
|
},
|
|
2015
2872
|
function switchStatement(position, buffer) {
|
|
2016
|
-
|
|
2873
|
+
const node = {
|
|
2017
2874
|
type: 'SwitchStatement',
|
|
2018
2875
|
start: buffer[position],
|
|
2019
2876
|
end: buffer[position + 1],
|
|
2020
|
-
discriminant
|
|
2021
|
-
|
|
2877
|
+
get discriminant() {
|
|
2878
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2879
|
+
Object.defineProperty(node, 'discriminant', { value: result });
|
|
2880
|
+
return result;
|
|
2881
|
+
},
|
|
2882
|
+
get cases() {
|
|
2883
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2884
|
+
Object.defineProperty(node, 'cases', { value: result });
|
|
2885
|
+
return result;
|
|
2886
|
+
}
|
|
2022
2887
|
};
|
|
2888
|
+
return node;
|
|
2023
2889
|
},
|
|
2024
2890
|
function taggedTemplateExpression(position, buffer) {
|
|
2025
|
-
|
|
2891
|
+
const node = {
|
|
2026
2892
|
type: 'TaggedTemplateExpression',
|
|
2027
2893
|
start: buffer[position],
|
|
2028
2894
|
end: buffer[position + 1],
|
|
2029
|
-
tag
|
|
2030
|
-
|
|
2895
|
+
get tag() {
|
|
2896
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2897
|
+
Object.defineProperty(node, 'tag', { value: result });
|
|
2898
|
+
return result;
|
|
2899
|
+
},
|
|
2900
|
+
get quasi() {
|
|
2901
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2902
|
+
Object.defineProperty(node, 'quasi', { value: result });
|
|
2903
|
+
return result;
|
|
2904
|
+
}
|
|
2031
2905
|
};
|
|
2906
|
+
return node;
|
|
2032
2907
|
},
|
|
2033
2908
|
function templateElement(position, buffer) {
|
|
2034
2909
|
const flags = buffer[position + 2];
|
|
2035
2910
|
const cookedPosition = buffer[position + 3];
|
|
2036
|
-
const cooked = cookedPosition === 0 ?
|
|
2911
|
+
const cooked = cookedPosition === 0 ? undefined : buffer.convertString(cookedPosition);
|
|
2912
|
+
const raw = buffer.convertString(buffer[position + 4]);
|
|
2913
|
+
const node = {
|
|
2914
|
+
type: 'TemplateElement',
|
|
2915
|
+
start: buffer[position],
|
|
2916
|
+
end: buffer[position + 1],
|
|
2917
|
+
tail: (flags & 1) === 1,
|
|
2918
|
+
value: { cooked, raw }
|
|
2919
|
+
};
|
|
2920
|
+
return node;
|
|
2921
|
+
},
|
|
2922
|
+
function templateLiteral(position, buffer) {
|
|
2923
|
+
const node = {
|
|
2924
|
+
type: 'TemplateLiteral',
|
|
2925
|
+
start: buffer[position],
|
|
2926
|
+
end: buffer[position + 1],
|
|
2927
|
+
get quasis() {
|
|
2928
|
+
const result = convertNodeList$1(buffer[position + 2], buffer);
|
|
2929
|
+
Object.defineProperty(node, 'quasis', { value: result });
|
|
2930
|
+
return result;
|
|
2931
|
+
},
|
|
2932
|
+
get expressions() {
|
|
2933
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
2934
|
+
Object.defineProperty(node, 'expressions', { value: result });
|
|
2935
|
+
return result;
|
|
2936
|
+
}
|
|
2937
|
+
};
|
|
2938
|
+
return node;
|
|
2939
|
+
},
|
|
2940
|
+
function thisExpression(position, buffer) {
|
|
2941
|
+
const node = {
|
|
2942
|
+
type: 'ThisExpression',
|
|
2943
|
+
start: buffer[position],
|
|
2944
|
+
end: buffer[position + 1]
|
|
2945
|
+
};
|
|
2946
|
+
return node;
|
|
2947
|
+
},
|
|
2948
|
+
function throwStatement(position, buffer) {
|
|
2949
|
+
const node = {
|
|
2950
|
+
type: 'ThrowStatement',
|
|
2951
|
+
start: buffer[position],
|
|
2952
|
+
end: buffer[position + 1],
|
|
2953
|
+
get argument() {
|
|
2954
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2955
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2956
|
+
return result;
|
|
2957
|
+
}
|
|
2958
|
+
};
|
|
2959
|
+
return node;
|
|
2960
|
+
},
|
|
2961
|
+
function tryStatement(position, buffer) {
|
|
2962
|
+
const handlerPosition = buffer[position + 3];
|
|
2963
|
+
const finalizerPosition = buffer[position + 4];
|
|
2964
|
+
const node = {
|
|
2965
|
+
type: 'TryStatement',
|
|
2966
|
+
start: buffer[position],
|
|
2967
|
+
end: buffer[position + 1],
|
|
2968
|
+
get block() {
|
|
2969
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
2970
|
+
Object.defineProperty(node, 'block', { value: result });
|
|
2971
|
+
return result;
|
|
2972
|
+
},
|
|
2973
|
+
get handler() {
|
|
2974
|
+
const result = handlerPosition === 0 ? null : convertNode$1(handlerPosition, buffer);
|
|
2975
|
+
Object.defineProperty(node, 'handler', { value: result });
|
|
2976
|
+
return result;
|
|
2977
|
+
},
|
|
2978
|
+
get finalizer() {
|
|
2979
|
+
const result = finalizerPosition === 0 ? null : convertNode$1(finalizerPosition, buffer);
|
|
2980
|
+
Object.defineProperty(node, 'finalizer', { value: result });
|
|
2981
|
+
return result;
|
|
2982
|
+
}
|
|
2983
|
+
};
|
|
2984
|
+
return node;
|
|
2985
|
+
},
|
|
2986
|
+
function unaryExpression(position, buffer) {
|
|
2987
|
+
const node = {
|
|
2988
|
+
type: 'UnaryExpression',
|
|
2989
|
+
start: buffer[position],
|
|
2990
|
+
end: buffer[position + 1],
|
|
2991
|
+
get operator() {
|
|
2992
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
2993
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
2994
|
+
return result;
|
|
2995
|
+
},
|
|
2996
|
+
get argument() {
|
|
2997
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
2998
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
2999
|
+
return result;
|
|
3000
|
+
},
|
|
3001
|
+
prefix: true
|
|
3002
|
+
};
|
|
3003
|
+
return node;
|
|
3004
|
+
},
|
|
3005
|
+
function updateExpression(position, buffer) {
|
|
3006
|
+
const flags = buffer[position + 2];
|
|
3007
|
+
const node = {
|
|
3008
|
+
type: 'UpdateExpression',
|
|
3009
|
+
start: buffer[position],
|
|
3010
|
+
end: buffer[position + 1],
|
|
3011
|
+
prefix: (flags & 1) === 1,
|
|
3012
|
+
get operator() {
|
|
3013
|
+
const result = FIXED_STRINGS[buffer[position + 3]];
|
|
3014
|
+
Object.defineProperty(node, 'operator', { value: result });
|
|
3015
|
+
return result;
|
|
3016
|
+
},
|
|
3017
|
+
get argument() {
|
|
3018
|
+
const result = convertNode$1(buffer[position + 4], buffer);
|
|
3019
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
3020
|
+
return result;
|
|
3021
|
+
}
|
|
3022
|
+
};
|
|
3023
|
+
return node;
|
|
3024
|
+
},
|
|
3025
|
+
function variableDeclaration(position, buffer) {
|
|
3026
|
+
const node = {
|
|
3027
|
+
type: 'VariableDeclaration',
|
|
3028
|
+
start: buffer[position],
|
|
3029
|
+
end: buffer[position + 1],
|
|
3030
|
+
get kind() {
|
|
3031
|
+
const result = FIXED_STRINGS[buffer[position + 2]];
|
|
3032
|
+
Object.defineProperty(node, 'kind', { value: result });
|
|
3033
|
+
return result;
|
|
3034
|
+
},
|
|
3035
|
+
get declarations() {
|
|
3036
|
+
const result = convertNodeList$1(buffer[position + 3], buffer);
|
|
3037
|
+
Object.defineProperty(node, 'declarations', { value: result });
|
|
3038
|
+
return result;
|
|
3039
|
+
}
|
|
3040
|
+
};
|
|
3041
|
+
return node;
|
|
3042
|
+
},
|
|
3043
|
+
function variableDeclarator(position, buffer) {
|
|
3044
|
+
const initPosition = buffer[position + 3];
|
|
3045
|
+
const node = {
|
|
3046
|
+
type: 'VariableDeclarator',
|
|
3047
|
+
start: buffer[position],
|
|
3048
|
+
end: buffer[position + 1],
|
|
3049
|
+
get id() {
|
|
3050
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
3051
|
+
Object.defineProperty(node, 'id', { value: result });
|
|
3052
|
+
return result;
|
|
3053
|
+
},
|
|
3054
|
+
get init() {
|
|
3055
|
+
const result = initPosition === 0 ? null : convertNode$1(initPosition, buffer);
|
|
3056
|
+
Object.defineProperty(node, 'init', { value: result });
|
|
3057
|
+
return result;
|
|
3058
|
+
}
|
|
3059
|
+
};
|
|
3060
|
+
return node;
|
|
3061
|
+
},
|
|
3062
|
+
function whileStatement(position, buffer) {
|
|
3063
|
+
const node = {
|
|
3064
|
+
type: 'WhileStatement',
|
|
3065
|
+
start: buffer[position],
|
|
3066
|
+
end: buffer[position + 1],
|
|
3067
|
+
get test() {
|
|
3068
|
+
const result = convertNode$1(buffer[position + 2], buffer);
|
|
3069
|
+
Object.defineProperty(node, 'test', { value: result });
|
|
3070
|
+
return result;
|
|
3071
|
+
},
|
|
3072
|
+
get body() {
|
|
3073
|
+
const result = convertNode$1(buffer[position + 3], buffer);
|
|
3074
|
+
Object.defineProperty(node, 'body', { value: result });
|
|
3075
|
+
return result;
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
return node;
|
|
3079
|
+
},
|
|
3080
|
+
function yieldExpression(position, buffer) {
|
|
3081
|
+
const flags = buffer[position + 2];
|
|
3082
|
+
const argumentPosition = buffer[position + 3];
|
|
3083
|
+
const node = {
|
|
3084
|
+
type: 'YieldExpression',
|
|
3085
|
+
start: buffer[position],
|
|
3086
|
+
end: buffer[position + 1],
|
|
3087
|
+
delegate: (flags & 1) === 1,
|
|
3088
|
+
get argument() {
|
|
3089
|
+
const result = argumentPosition === 0 ? null : convertNode$1(argumentPosition, buffer);
|
|
3090
|
+
Object.defineProperty(node, 'argument', { value: result });
|
|
3091
|
+
return result;
|
|
3092
|
+
}
|
|
3093
|
+
};
|
|
3094
|
+
return node;
|
|
3095
|
+
}
|
|
3096
|
+
];
|
|
3097
|
+
function convertNode$1(position, buffer) {
|
|
3098
|
+
const nodeType = buffer[position];
|
|
3099
|
+
const converter = nodeConverters$1[nodeType];
|
|
3100
|
+
/* istanbul ignore if: This should never be executed but is a safeguard against faulty buffers */
|
|
3101
|
+
if (!converter) {
|
|
3102
|
+
console.trace();
|
|
3103
|
+
throw new Error(`Unknown node type: ${nodeType}`);
|
|
3104
|
+
}
|
|
3105
|
+
return converter(position + 1, buffer);
|
|
3106
|
+
}
|
|
3107
|
+
function convertNodeList$1(position, buffer) {
|
|
3108
|
+
if (position === 0)
|
|
3109
|
+
return EMPTY_ARRAY;
|
|
3110
|
+
const length = buffer[position++];
|
|
3111
|
+
const list = new Array(length);
|
|
3112
|
+
for (let index = 0; index < length; index++) {
|
|
3113
|
+
const nodePosition = buffer[position++];
|
|
3114
|
+
list[index] = nodePosition ? convertNode$1(nodePosition, buffer) : null;
|
|
3115
|
+
}
|
|
3116
|
+
return list;
|
|
3117
|
+
}
|
|
3118
|
+
|
|
3119
|
+
function getAstBuffer(byteBuffer) {
|
|
3120
|
+
// Create an aligned copy for misaligned views, e.g. buffers restored by
|
|
3121
|
+
// v8.deserialize, as the Uint32Array below requires a 4-byte aligned offset
|
|
3122
|
+
const alignedByteBuffer = byteBuffer.byteOffset & 3 ? new Uint8Array(byteBuffer) : byteBuffer;
|
|
3123
|
+
const array = new Uint32Array(alignedByteBuffer.buffer, alignedByteBuffer.byteOffset, alignedByteBuffer.byteLength >> 2);
|
|
3124
|
+
let convertString;
|
|
3125
|
+
if (typeof Buffer !== 'undefined' && byteBuffer instanceof Buffer) {
|
|
3126
|
+
convertString = position => {
|
|
3127
|
+
const length = array[position];
|
|
3128
|
+
const bytePosition = (position + 1) << 2;
|
|
3129
|
+
return byteBuffer.toString('utf8', bytePosition, bytePosition + length);
|
|
3130
|
+
};
|
|
3131
|
+
}
|
|
3132
|
+
else {
|
|
3133
|
+
const textDecoder = new TextDecoder();
|
|
3134
|
+
convertString = position => {
|
|
3135
|
+
const length = array[position];
|
|
3136
|
+
const bytePosition = (position + 1) << 2;
|
|
3137
|
+
return textDecoder.decode(byteBuffer.subarray(bytePosition, bytePosition + length));
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
return Object.assign(array, { convertString });
|
|
3141
|
+
}
|
|
3142
|
+
function createAstBufferUint8(uInt32Size) {
|
|
3143
|
+
const buffer = new Uint32Array(uInt32Size);
|
|
3144
|
+
const encoder = new TextEncoder();
|
|
3145
|
+
return Object.assign(buffer, {
|
|
3146
|
+
addStringToBuffer(text, referencePosition) {
|
|
3147
|
+
const insertPosition = buffer.position;
|
|
3148
|
+
buffer[referencePosition] = insertPosition;
|
|
3149
|
+
const encoded = encoder.encode(text);
|
|
3150
|
+
const encodedByteLength = encoded.length;
|
|
3151
|
+
// Round up to the next 4-byte boundary, add 1 for the length
|
|
3152
|
+
const reservedSize = 1 + ((encodedByteLength + 3) >> 2);
|
|
3153
|
+
const extendedBuffer = buffer.reserve(reservedSize);
|
|
3154
|
+
extendedBuffer[insertPosition] = encodedByteLength;
|
|
3155
|
+
extendedBuffer.byteBuffer.set(encoded, (insertPosition + 1) << 2);
|
|
3156
|
+
return extendedBuffer;
|
|
3157
|
+
},
|
|
3158
|
+
byteBuffer: new Uint8Array(buffer.buffer),
|
|
3159
|
+
position: 0,
|
|
3160
|
+
reserve(size) {
|
|
3161
|
+
const newPosition = buffer.position + size;
|
|
3162
|
+
if (newPosition <= buffer.length) {
|
|
3163
|
+
buffer.position = newPosition;
|
|
3164
|
+
return buffer;
|
|
3165
|
+
}
|
|
3166
|
+
const newBuffer = createAstBufferUint8(newPosition * 2);
|
|
3167
|
+
newBuffer.set(buffer);
|
|
3168
|
+
newBuffer.position = newPosition;
|
|
3169
|
+
return newBuffer;
|
|
3170
|
+
},
|
|
3171
|
+
toOutput() {
|
|
3172
|
+
const byteSize = buffer.position << 2;
|
|
3173
|
+
return buffer.byteBuffer.slice(0, byteSize);
|
|
3174
|
+
}
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
function createAstBufferNode(uInt32Size) {
|
|
3178
|
+
const buffer = new Uint32Array(uInt32Size);
|
|
3179
|
+
return Object.assign(buffer, {
|
|
3180
|
+
addStringToBuffer(text, referencePosition) {
|
|
3181
|
+
let extendedBuffer = buffer;
|
|
3182
|
+
const requiredSize = buffer.position + 1 + ((text.length * 3 + 3) >> 2);
|
|
3183
|
+
if (requiredSize > buffer.length) {
|
|
3184
|
+
// Reserve more space if needed
|
|
3185
|
+
extendedBuffer = createAstBufferNode(requiredSize * 2);
|
|
3186
|
+
buffer.byteBuffer.copy(extendedBuffer.byteBuffer, 0, 0, buffer.position << 2);
|
|
3187
|
+
extendedBuffer.position = buffer.position;
|
|
3188
|
+
}
|
|
3189
|
+
const insertPosition = extendedBuffer.position;
|
|
3190
|
+
extendedBuffer[referencePosition] = insertPosition;
|
|
3191
|
+
const textBytePosition = (insertPosition + 1) << 2;
|
|
3192
|
+
const encodedLength = extendedBuffer.byteBuffer.write(text, textBytePosition);
|
|
3193
|
+
extendedBuffer[insertPosition] = encodedLength;
|
|
3194
|
+
// Round up to the next 4-byte boundary
|
|
3195
|
+
extendedBuffer.position = (textBytePosition + encodedLength + 3) >> 2;
|
|
3196
|
+
return extendedBuffer;
|
|
3197
|
+
},
|
|
3198
|
+
byteBuffer: Buffer.from(buffer.buffer),
|
|
3199
|
+
position: 0,
|
|
3200
|
+
reserve(size) {
|
|
3201
|
+
const newPosition = buffer.position + size;
|
|
3202
|
+
if (newPosition <= buffer.length) {
|
|
3203
|
+
buffer.position = newPosition;
|
|
3204
|
+
return buffer;
|
|
3205
|
+
}
|
|
3206
|
+
const newBuffer = createAstBufferNode(newPosition * 2);
|
|
3207
|
+
buffer.byteBuffer.copy(newBuffer.byteBuffer, 0, 0, buffer.position << 2);
|
|
3208
|
+
newBuffer.position = newPosition;
|
|
3209
|
+
return newBuffer;
|
|
3210
|
+
},
|
|
3211
|
+
toOutput() {
|
|
3212
|
+
const byteSize = buffer.position << 2;
|
|
3213
|
+
// The "slow" version will allocate exactly the needed size and is preferable
|
|
3214
|
+
// for long-term memory usage.
|
|
3215
|
+
const truncatedBuffer = Buffer.allocUnsafeSlow(byteSize);
|
|
3216
|
+
buffer.byteBuffer.copy(truncatedBuffer, 0, 0, byteSize);
|
|
3217
|
+
return truncatedBuffer;
|
|
3218
|
+
}
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
3221
|
+
|
|
3222
|
+
// This file is generated by scripts/generate-scope-constants.ts.
|
|
3223
|
+
// Do not edit this file directly.
|
|
3224
|
+
const SCOPE_PARENT_OFFSET = 0;
|
|
3225
|
+
const SCOPE_DECLARATION_COUNT_OFFSET = 1;
|
|
3226
|
+
const SCOPE_DECLARATIONS_OFFSET = 2;
|
|
3227
|
+
|
|
3228
|
+
const IDENTIFIER_NAME_OFFSET = 3;
|
|
3229
|
+
async function parseAndWalk(input, visitors, { allowReturnOutsideFunction = false, collectScopes = false, jsx = false } = {}) {
|
|
3230
|
+
const selectedNodesBuffer = getSelectedNodesBitsetBuffer(visitors);
|
|
3231
|
+
const astBuffer = getAstBuffer(await native_js.parseAndWalk(input, allowReturnOutsideFunction, jsx, selectedNodesBuffer, collectScopes));
|
|
3232
|
+
walkAstBuffer(astBuffer, visitors, collectScopes);
|
|
3233
|
+
}
|
|
3234
|
+
function getSelectedNodesBitsetBuffer(visitors) {
|
|
3235
|
+
let selectedNodesBitset = 0n;
|
|
3236
|
+
for (const nodeType of Object.keys(visitors)) {
|
|
3237
|
+
const ids = nodeIds[nodeType];
|
|
3238
|
+
if (ids) {
|
|
3239
|
+
for (const id of ids) {
|
|
3240
|
+
selectedNodesBitset |= 1n << BigInt(id);
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
else {
|
|
3244
|
+
throw new Error(`Unknown node type "${nodeType}" when calling "parseAndWalk".`);
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
const selectedNodesBuffer = new BigUint64Array(2); // 2 × 64 bits = 128 bits
|
|
3248
|
+
selectedNodesBuffer[0] = selectedNodesBitset & ((1n << 64n) - 1n);
|
|
3249
|
+
selectedNodesBuffer[1] = selectedNodesBitset >> 64n;
|
|
3250
|
+
return selectedNodesBuffer;
|
|
3251
|
+
}
|
|
3252
|
+
// TODO Lukas Can we expose parseAndWalk as a separate method? Can we also make
|
|
3253
|
+
// sure to include its tests in the smoke tests to test on a big endian system?
|
|
3254
|
+
function walkAstBuffer(astBuffer, visitors, collectScopes) {
|
|
3255
|
+
const walkingInfoOffset = astBuffer[0];
|
|
3256
|
+
const entrySize = 3;
|
|
3257
|
+
// If it is 0, there are no walking buffer or walked nodes
|
|
3258
|
+
if (walkingInfoOffset === 0) {
|
|
3259
|
+
// This will throw the correct error if there was a parse error
|
|
3260
|
+
return deserializeLazyAstBuffer(astBuffer, 1);
|
|
3261
|
+
}
|
|
3262
|
+
let walkingPosition = walkingInfoOffset;
|
|
3263
|
+
const scopeCache = new Map();
|
|
3264
|
+
const api = {
|
|
3265
|
+
parseChildren() {
|
|
3266
|
+
const endPosition = walkingInfoOffset + astBuffer[walkingPosition + 1] * entrySize;
|
|
3267
|
+
walkingPosition += entrySize;
|
|
3268
|
+
walkUntilPosition(endPosition);
|
|
3269
|
+
// After parseChildren, the walkingPosition must point to the last child,
|
|
3270
|
+
// not beyond. Otherwise, we would skip the next element.
|
|
3271
|
+
walkingPosition -= entrySize;
|
|
3272
|
+
},
|
|
3273
|
+
skipChildren() {
|
|
3274
|
+
// Like parseChildren, the pointer must point to the last child after
|
|
3275
|
+
// skipping, not beyond.
|
|
3276
|
+
walkingPosition = walkingInfoOffset + astBuffer[walkingPosition + 1] * entrySize - entrySize;
|
|
3277
|
+
}
|
|
3278
|
+
};
|
|
3279
|
+
function walkUntilPosition(endPosition) {
|
|
3280
|
+
for (; walkingPosition < endPosition; walkingPosition += entrySize) {
|
|
3281
|
+
const elementIndex = astBuffer[walkingPosition];
|
|
3282
|
+
if (collectScopes) {
|
|
3283
|
+
api.scope = getScope(astBuffer[walkingPosition + 2]);
|
|
3284
|
+
}
|
|
3285
|
+
const nodeTypeString = nodeTypeStrings[astBuffer[elementIndex]];
|
|
3286
|
+
visitors[nodeTypeString](deserializeLazyAstBuffer(astBuffer, elementIndex), api);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
function getScope(scopePosition) {
|
|
3290
|
+
/* istanbul ignore next */
|
|
3291
|
+
if (scopePosition === 0) {
|
|
3292
|
+
throw new Error('Internal Error: Missing scope information in parseAndWalk.');
|
|
3293
|
+
}
|
|
3294
|
+
let scope = scopeCache.get(scopePosition);
|
|
3295
|
+
if (!scope) {
|
|
3296
|
+
scope = {
|
|
3297
|
+
contains(name) {
|
|
3298
|
+
for (let currentScopePosition = scopePosition; currentScopePosition;) {
|
|
3299
|
+
const declarationCount = astBuffer[currentScopePosition + SCOPE_DECLARATION_COUNT_OFFSET];
|
|
3300
|
+
for (let index = 0; index < declarationCount; index++) {
|
|
3301
|
+
const identifierPosition = astBuffer[currentScopePosition + SCOPE_DECLARATIONS_OFFSET + index];
|
|
3302
|
+
if (astBuffer.convertString(astBuffer[identifierPosition + IDENTIFIER_NAME_OFFSET]) ===
|
|
3303
|
+
name) {
|
|
3304
|
+
return true;
|
|
3305
|
+
}
|
|
3306
|
+
}
|
|
3307
|
+
currentScopePosition = astBuffer[currentScopePosition + SCOPE_PARENT_OFFSET];
|
|
3308
|
+
}
|
|
3309
|
+
return false;
|
|
3310
|
+
}
|
|
3311
|
+
};
|
|
3312
|
+
scopeCache.set(scopePosition, scope);
|
|
3313
|
+
}
|
|
3314
|
+
return scope;
|
|
3315
|
+
}
|
|
3316
|
+
walkUntilPosition(astBuffer.length);
|
|
3317
|
+
}
|
|
3318
|
+
|
|
3319
|
+
// This file is generated by scripts/generate-buffer-to-ast.ts.
|
|
3320
|
+
// Do not edit this file directly.
|
|
3321
|
+
const deserializeAstBuffer = (buffer, position) => {
|
|
3322
|
+
const node = convertNode(position, buffer);
|
|
3323
|
+
switch (node.type) {
|
|
3324
|
+
case PanicError: {
|
|
3325
|
+
return error(getRollupError(logParseError(node.message)));
|
|
3326
|
+
}
|
|
3327
|
+
case ParseError: {
|
|
3328
|
+
return error(getRollupError(logParseError(node.message, node.start)));
|
|
3329
|
+
}
|
|
3330
|
+
default: {
|
|
3331
|
+
return node;
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
};
|
|
3335
|
+
/* eslint-disable sort-keys */
|
|
3336
|
+
const nodeConverters = [
|
|
3337
|
+
function panicError(position, buffer) {
|
|
3338
|
+
return {
|
|
3339
|
+
type: 'PanicError',
|
|
3340
|
+
start: buffer[position],
|
|
3341
|
+
end: buffer[position + 1],
|
|
3342
|
+
message: buffer.convertString(buffer[position + 2])
|
|
3343
|
+
};
|
|
3344
|
+
},
|
|
3345
|
+
function parseError(position, buffer) {
|
|
3346
|
+
return {
|
|
3347
|
+
type: 'ParseError',
|
|
3348
|
+
start: buffer[position],
|
|
3349
|
+
end: buffer[position + 1],
|
|
3350
|
+
message: buffer.convertString(buffer[position + 2])
|
|
3351
|
+
};
|
|
3352
|
+
},
|
|
3353
|
+
function arrayExpression(position, buffer) {
|
|
3354
|
+
return {
|
|
3355
|
+
type: 'ArrayExpression',
|
|
3356
|
+
start: buffer[position],
|
|
3357
|
+
end: buffer[position + 1],
|
|
3358
|
+
elements: convertNodeList(buffer[position + 2], buffer)
|
|
3359
|
+
};
|
|
3360
|
+
},
|
|
3361
|
+
function arrayPattern(position, buffer) {
|
|
3362
|
+
return {
|
|
3363
|
+
type: 'ArrayPattern',
|
|
3364
|
+
start: buffer[position],
|
|
3365
|
+
end: buffer[position + 1],
|
|
3366
|
+
elements: convertNodeList(buffer[position + 2], buffer)
|
|
3367
|
+
};
|
|
3368
|
+
},
|
|
3369
|
+
function arrowFunctionExpression(position, buffer) {
|
|
3370
|
+
const flags = buffer[position + 2];
|
|
3371
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3372
|
+
return {
|
|
3373
|
+
type: 'ArrowFunctionExpression',
|
|
3374
|
+
start: buffer[position],
|
|
3375
|
+
end: buffer[position + 1],
|
|
3376
|
+
async: (flags & 1) === 1,
|
|
3377
|
+
expression: (flags & 2) === 2,
|
|
3378
|
+
generator: (flags & 4) === 4,
|
|
3379
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3380
|
+
params: convertNodeList(buffer[position + 4], buffer),
|
|
3381
|
+
body: convertNode(buffer[position + 5], buffer),
|
|
3382
|
+
id: null
|
|
3383
|
+
};
|
|
3384
|
+
},
|
|
3385
|
+
function assignmentExpression(position, buffer) {
|
|
3386
|
+
return {
|
|
3387
|
+
type: 'AssignmentExpression',
|
|
3388
|
+
start: buffer[position],
|
|
3389
|
+
end: buffer[position + 1],
|
|
3390
|
+
operator: FIXED_STRINGS[buffer[position + 2]],
|
|
3391
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3392
|
+
right: convertNode(buffer[position + 4], buffer)
|
|
3393
|
+
};
|
|
3394
|
+
},
|
|
3395
|
+
function assignmentPattern(position, buffer) {
|
|
3396
|
+
return {
|
|
3397
|
+
type: 'AssignmentPattern',
|
|
3398
|
+
start: buffer[position],
|
|
3399
|
+
end: buffer[position + 1],
|
|
3400
|
+
left: convertNode(buffer[position + 2], buffer),
|
|
3401
|
+
right: convertNode(buffer[position + 3], buffer)
|
|
3402
|
+
};
|
|
3403
|
+
},
|
|
3404
|
+
function awaitExpression(position, buffer) {
|
|
3405
|
+
return {
|
|
3406
|
+
type: 'AwaitExpression',
|
|
3407
|
+
start: buffer[position],
|
|
3408
|
+
end: buffer[position + 1],
|
|
3409
|
+
argument: convertNode(buffer[position + 2], buffer)
|
|
3410
|
+
};
|
|
3411
|
+
},
|
|
3412
|
+
function binaryExpression(position, buffer) {
|
|
3413
|
+
return {
|
|
3414
|
+
type: 'BinaryExpression',
|
|
3415
|
+
start: buffer[position],
|
|
3416
|
+
end: buffer[position + 1],
|
|
3417
|
+
operator: FIXED_STRINGS[buffer[position + 2]],
|
|
3418
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3419
|
+
right: convertNode(buffer[position + 4], buffer)
|
|
3420
|
+
};
|
|
3421
|
+
},
|
|
3422
|
+
function blockStatement(position, buffer) {
|
|
3423
|
+
return {
|
|
3424
|
+
type: 'BlockStatement',
|
|
3425
|
+
start: buffer[position],
|
|
3426
|
+
end: buffer[position + 1],
|
|
3427
|
+
body: convertNodeList(buffer[position + 2], buffer)
|
|
3428
|
+
};
|
|
3429
|
+
},
|
|
3430
|
+
function breakStatement(position, buffer) {
|
|
3431
|
+
const labelPosition = buffer[position + 2];
|
|
3432
|
+
return {
|
|
3433
|
+
type: 'BreakStatement',
|
|
3434
|
+
start: buffer[position],
|
|
3435
|
+
end: buffer[position + 1],
|
|
3436
|
+
label: labelPosition === 0 ? null : convertNode(labelPosition, buffer)
|
|
3437
|
+
};
|
|
3438
|
+
},
|
|
3439
|
+
function callExpression(position, buffer) {
|
|
3440
|
+
const flags = buffer[position + 2];
|
|
3441
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3442
|
+
return {
|
|
3443
|
+
type: 'CallExpression',
|
|
3444
|
+
start: buffer[position],
|
|
3445
|
+
end: buffer[position + 1],
|
|
3446
|
+
optional: (flags & 1) === 1,
|
|
3447
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3448
|
+
callee: convertNode(buffer[position + 4], buffer),
|
|
3449
|
+
arguments: convertNodeList(buffer[position + 5], buffer)
|
|
3450
|
+
};
|
|
3451
|
+
},
|
|
3452
|
+
function catchClause(position, buffer) {
|
|
3453
|
+
const parameterPosition = buffer[position + 2];
|
|
3454
|
+
return {
|
|
3455
|
+
type: 'CatchClause',
|
|
3456
|
+
start: buffer[position],
|
|
3457
|
+
end: buffer[position + 1],
|
|
3458
|
+
param: parameterPosition === 0 ? null : convertNode(parameterPosition, buffer),
|
|
3459
|
+
body: convertNode(buffer[position + 3], buffer)
|
|
3460
|
+
};
|
|
3461
|
+
},
|
|
3462
|
+
function chainExpression(position, buffer) {
|
|
3463
|
+
return {
|
|
3464
|
+
type: 'ChainExpression',
|
|
3465
|
+
start: buffer[position],
|
|
3466
|
+
end: buffer[position + 1],
|
|
3467
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3468
|
+
};
|
|
3469
|
+
},
|
|
3470
|
+
function classBody(position, buffer) {
|
|
3471
|
+
return {
|
|
3472
|
+
type: 'ClassBody',
|
|
3473
|
+
start: buffer[position],
|
|
3474
|
+
end: buffer[position + 1],
|
|
3475
|
+
body: convertNodeList(buffer[position + 2], buffer)
|
|
3476
|
+
};
|
|
3477
|
+
},
|
|
3478
|
+
function classDeclaration(position, buffer) {
|
|
3479
|
+
const idPosition = buffer[position + 3];
|
|
3480
|
+
const superClassPosition = buffer[position + 4];
|
|
3481
|
+
return {
|
|
3482
|
+
type: 'ClassDeclaration',
|
|
3483
|
+
start: buffer[position],
|
|
3484
|
+
end: buffer[position + 1],
|
|
3485
|
+
decorators: convertNodeList(buffer[position + 2], buffer),
|
|
3486
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3487
|
+
superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer),
|
|
3488
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3489
|
+
};
|
|
3490
|
+
},
|
|
3491
|
+
function classExpression(position, buffer) {
|
|
3492
|
+
const idPosition = buffer[position + 3];
|
|
3493
|
+
const superClassPosition = buffer[position + 4];
|
|
3494
|
+
return {
|
|
3495
|
+
type: 'ClassExpression',
|
|
3496
|
+
start: buffer[position],
|
|
3497
|
+
end: buffer[position + 1],
|
|
3498
|
+
decorators: convertNodeList(buffer[position + 2], buffer),
|
|
3499
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3500
|
+
superClass: superClassPosition === 0 ? null : convertNode(superClassPosition, buffer),
|
|
3501
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3502
|
+
};
|
|
3503
|
+
},
|
|
3504
|
+
function conditionalExpression(position, buffer) {
|
|
3505
|
+
return {
|
|
3506
|
+
type: 'ConditionalExpression',
|
|
3507
|
+
start: buffer[position],
|
|
3508
|
+
end: buffer[position + 1],
|
|
3509
|
+
test: convertNode(buffer[position + 2], buffer),
|
|
3510
|
+
consequent: convertNode(buffer[position + 3], buffer),
|
|
3511
|
+
alternate: convertNode(buffer[position + 4], buffer)
|
|
3512
|
+
};
|
|
3513
|
+
},
|
|
3514
|
+
function continueStatement(position, buffer) {
|
|
3515
|
+
const labelPosition = buffer[position + 2];
|
|
3516
|
+
return {
|
|
3517
|
+
type: 'ContinueStatement',
|
|
3518
|
+
start: buffer[position],
|
|
3519
|
+
end: buffer[position + 1],
|
|
3520
|
+
label: labelPosition === 0 ? null : convertNode(labelPosition, buffer)
|
|
3521
|
+
};
|
|
3522
|
+
},
|
|
3523
|
+
function debuggerStatement(position, buffer) {
|
|
3524
|
+
return {
|
|
3525
|
+
type: 'DebuggerStatement',
|
|
3526
|
+
start: buffer[position],
|
|
3527
|
+
end: buffer[position + 1]
|
|
3528
|
+
};
|
|
3529
|
+
},
|
|
3530
|
+
function decorator(position, buffer) {
|
|
3531
|
+
return {
|
|
3532
|
+
type: 'Decorator',
|
|
3533
|
+
start: buffer[position],
|
|
3534
|
+
end: buffer[position + 1],
|
|
3535
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3536
|
+
};
|
|
3537
|
+
},
|
|
3538
|
+
function directive(position, buffer) {
|
|
3539
|
+
return {
|
|
3540
|
+
type: 'ExpressionStatement',
|
|
3541
|
+
start: buffer[position],
|
|
3542
|
+
end: buffer[position + 1],
|
|
3543
|
+
directive: buffer.convertString(buffer[position + 2]),
|
|
3544
|
+
expression: convertNode(buffer[position + 3], buffer)
|
|
3545
|
+
};
|
|
3546
|
+
},
|
|
3547
|
+
function doWhileStatement(position, buffer) {
|
|
3548
|
+
return {
|
|
3549
|
+
type: 'DoWhileStatement',
|
|
3550
|
+
start: buffer[position],
|
|
3551
|
+
end: buffer[position + 1],
|
|
3552
|
+
body: convertNode(buffer[position + 2], buffer),
|
|
3553
|
+
test: convertNode(buffer[position + 3], buffer)
|
|
3554
|
+
};
|
|
3555
|
+
},
|
|
3556
|
+
function emptyStatement(position, buffer) {
|
|
3557
|
+
return {
|
|
3558
|
+
type: 'EmptyStatement',
|
|
3559
|
+
start: buffer[position],
|
|
3560
|
+
end: buffer[position + 1]
|
|
3561
|
+
};
|
|
3562
|
+
},
|
|
3563
|
+
function exportAllDeclaration(position, buffer) {
|
|
3564
|
+
const exportedPosition = buffer[position + 2];
|
|
3565
|
+
return {
|
|
3566
|
+
type: 'ExportAllDeclaration',
|
|
3567
|
+
start: buffer[position],
|
|
3568
|
+
end: buffer[position + 1],
|
|
3569
|
+
exported: exportedPosition === 0 ? null : convertNode(exportedPosition, buffer),
|
|
3570
|
+
source: convertNode(buffer[position + 3], buffer),
|
|
3571
|
+
attributes: convertNodeList(buffer[position + 4], buffer)
|
|
3572
|
+
};
|
|
3573
|
+
},
|
|
3574
|
+
function exportDefaultDeclaration(position, buffer) {
|
|
3575
|
+
return {
|
|
3576
|
+
type: 'ExportDefaultDeclaration',
|
|
3577
|
+
start: buffer[position],
|
|
3578
|
+
end: buffer[position + 1],
|
|
3579
|
+
declaration: convertNode(buffer[position + 2], buffer)
|
|
3580
|
+
};
|
|
3581
|
+
},
|
|
3582
|
+
function exportNamedDeclaration(position, buffer) {
|
|
3583
|
+
const sourcePosition = buffer[position + 3];
|
|
3584
|
+
const declarationPosition = buffer[position + 5];
|
|
3585
|
+
return {
|
|
3586
|
+
type: 'ExportNamedDeclaration',
|
|
3587
|
+
start: buffer[position],
|
|
3588
|
+
end: buffer[position + 1],
|
|
3589
|
+
specifiers: convertNodeList(buffer[position + 2], buffer),
|
|
3590
|
+
source: sourcePosition === 0 ? null : convertNode(sourcePosition, buffer),
|
|
3591
|
+
attributes: convertNodeList(buffer[position + 4], buffer),
|
|
3592
|
+
declaration: declarationPosition === 0 ? null : convertNode(declarationPosition, buffer)
|
|
3593
|
+
};
|
|
3594
|
+
},
|
|
3595
|
+
function exportSpecifier(position, buffer) {
|
|
3596
|
+
const local = convertNode(buffer[position + 2], buffer);
|
|
3597
|
+
const exportedPosition = buffer[position + 3];
|
|
3598
|
+
return {
|
|
3599
|
+
type: 'ExportSpecifier',
|
|
3600
|
+
start: buffer[position],
|
|
3601
|
+
end: buffer[position + 1],
|
|
3602
|
+
local,
|
|
3603
|
+
exported: exportedPosition === 0 ? { ...local } : convertNode(exportedPosition, buffer)
|
|
3604
|
+
};
|
|
3605
|
+
},
|
|
3606
|
+
function expressionStatement(position, buffer) {
|
|
3607
|
+
return {
|
|
3608
|
+
type: 'ExpressionStatement',
|
|
3609
|
+
start: buffer[position],
|
|
3610
|
+
end: buffer[position + 1],
|
|
3611
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3612
|
+
};
|
|
3613
|
+
},
|
|
3614
|
+
function forInStatement(position, buffer) {
|
|
3615
|
+
return {
|
|
3616
|
+
type: 'ForInStatement',
|
|
3617
|
+
start: buffer[position],
|
|
3618
|
+
end: buffer[position + 1],
|
|
3619
|
+
left: convertNode(buffer[position + 2], buffer),
|
|
3620
|
+
right: convertNode(buffer[position + 3], buffer),
|
|
3621
|
+
body: convertNode(buffer[position + 4], buffer)
|
|
3622
|
+
};
|
|
3623
|
+
},
|
|
3624
|
+
function forOfStatement(position, buffer) {
|
|
3625
|
+
const flags = buffer[position + 2];
|
|
3626
|
+
return {
|
|
3627
|
+
type: 'ForOfStatement',
|
|
3628
|
+
start: buffer[position],
|
|
3629
|
+
end: buffer[position + 1],
|
|
3630
|
+
await: (flags & 1) === 1,
|
|
3631
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3632
|
+
right: convertNode(buffer[position + 4], buffer),
|
|
3633
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3634
|
+
};
|
|
3635
|
+
},
|
|
3636
|
+
function forStatement(position, buffer) {
|
|
3637
|
+
const initPosition = buffer[position + 2];
|
|
3638
|
+
const testPosition = buffer[position + 3];
|
|
3639
|
+
const updatePosition = buffer[position + 4];
|
|
3640
|
+
return {
|
|
3641
|
+
type: 'ForStatement',
|
|
3642
|
+
start: buffer[position],
|
|
3643
|
+
end: buffer[position + 1],
|
|
3644
|
+
init: initPosition === 0 ? null : convertNode(initPosition, buffer),
|
|
3645
|
+
test: testPosition === 0 ? null : convertNode(testPosition, buffer),
|
|
3646
|
+
update: updatePosition === 0 ? null : convertNode(updatePosition, buffer),
|
|
3647
|
+
body: convertNode(buffer[position + 5], buffer)
|
|
3648
|
+
};
|
|
3649
|
+
},
|
|
3650
|
+
function functionDeclaration(position, buffer) {
|
|
3651
|
+
const flags = buffer[position + 2];
|
|
3652
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3653
|
+
const idPosition = buffer[position + 4];
|
|
3654
|
+
return {
|
|
3655
|
+
type: 'FunctionDeclaration',
|
|
3656
|
+
start: buffer[position],
|
|
3657
|
+
end: buffer[position + 1],
|
|
3658
|
+
async: (flags & 1) === 1,
|
|
3659
|
+
generator: (flags & 2) === 2,
|
|
3660
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3661
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3662
|
+
params: convertNodeList(buffer[position + 5], buffer),
|
|
3663
|
+
body: convertNode(buffer[position + 6], buffer),
|
|
3664
|
+
expression: false
|
|
3665
|
+
};
|
|
3666
|
+
},
|
|
3667
|
+
function functionExpression(position, buffer) {
|
|
3668
|
+
const flags = buffer[position + 2];
|
|
3669
|
+
const annotations = convertAnnotations(buffer[position + 3], buffer);
|
|
3670
|
+
const idPosition = buffer[position + 4];
|
|
3671
|
+
return {
|
|
3672
|
+
type: 'FunctionExpression',
|
|
3673
|
+
start: buffer[position],
|
|
3674
|
+
end: buffer[position + 1],
|
|
3675
|
+
async: (flags & 1) === 1,
|
|
3676
|
+
generator: (flags & 2) === 2,
|
|
3677
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
3678
|
+
id: idPosition === 0 ? null : convertNode(idPosition, buffer),
|
|
3679
|
+
params: convertNodeList(buffer[position + 5], buffer),
|
|
3680
|
+
body: convertNode(buffer[position + 6], buffer),
|
|
3681
|
+
expression: false
|
|
3682
|
+
};
|
|
3683
|
+
},
|
|
3684
|
+
function identifier(position, buffer) {
|
|
3685
|
+
return {
|
|
3686
|
+
type: 'Identifier',
|
|
3687
|
+
start: buffer[position],
|
|
3688
|
+
end: buffer[position + 1],
|
|
3689
|
+
name: buffer.convertString(buffer[position + 2])
|
|
3690
|
+
};
|
|
3691
|
+
},
|
|
3692
|
+
function ifStatement(position, buffer) {
|
|
3693
|
+
const alternatePosition = buffer[position + 4];
|
|
3694
|
+
return {
|
|
3695
|
+
type: 'IfStatement',
|
|
3696
|
+
start: buffer[position],
|
|
3697
|
+
end: buffer[position + 1],
|
|
3698
|
+
test: convertNode(buffer[position + 2], buffer),
|
|
3699
|
+
consequent: convertNode(buffer[position + 3], buffer),
|
|
3700
|
+
alternate: alternatePosition === 0 ? null : convertNode(alternatePosition, buffer)
|
|
3701
|
+
};
|
|
3702
|
+
},
|
|
3703
|
+
function importAttribute(position, buffer) {
|
|
3704
|
+
return {
|
|
3705
|
+
type: 'ImportAttribute',
|
|
3706
|
+
start: buffer[position],
|
|
3707
|
+
end: buffer[position + 1],
|
|
3708
|
+
key: convertNode(buffer[position + 2], buffer),
|
|
3709
|
+
value: convertNode(buffer[position + 3], buffer)
|
|
3710
|
+
};
|
|
3711
|
+
},
|
|
3712
|
+
function importDeclaration(position, buffer) {
|
|
3713
|
+
const phasePosition = buffer[position + 5];
|
|
3714
|
+
return {
|
|
3715
|
+
type: 'ImportDeclaration',
|
|
3716
|
+
start: buffer[position],
|
|
3717
|
+
end: buffer[position + 1],
|
|
3718
|
+
specifiers: convertNodeList(buffer[position + 2], buffer),
|
|
3719
|
+
source: convertNode(buffer[position + 3], buffer),
|
|
3720
|
+
attributes: convertNodeList(buffer[position + 4], buffer),
|
|
3721
|
+
phase: phasePosition === 0
|
|
3722
|
+
? undefined
|
|
3723
|
+
: FIXED_STRINGS[buffer[position + 5]]
|
|
3724
|
+
};
|
|
3725
|
+
},
|
|
3726
|
+
function importDefaultSpecifier(position, buffer) {
|
|
3727
|
+
return {
|
|
3728
|
+
type: 'ImportDefaultSpecifier',
|
|
3729
|
+
start: buffer[position],
|
|
3730
|
+
end: buffer[position + 1],
|
|
3731
|
+
local: convertNode(buffer[position + 2], buffer)
|
|
3732
|
+
};
|
|
3733
|
+
},
|
|
3734
|
+
function importExpression(position, buffer) {
|
|
3735
|
+
const optionsPosition = buffer[position + 3];
|
|
3736
|
+
const phasePosition = buffer[position + 4];
|
|
3737
|
+
return {
|
|
3738
|
+
type: 'ImportExpression',
|
|
3739
|
+
start: buffer[position],
|
|
3740
|
+
end: buffer[position + 1],
|
|
3741
|
+
source: convertNode(buffer[position + 2], buffer),
|
|
3742
|
+
options: optionsPosition === 0 ? null : convertNode(optionsPosition, buffer),
|
|
3743
|
+
phase: phasePosition === 0
|
|
3744
|
+
? undefined
|
|
3745
|
+
: FIXED_STRINGS[buffer[position + 4]]
|
|
3746
|
+
};
|
|
3747
|
+
},
|
|
3748
|
+
function importNamespaceSpecifier(position, buffer) {
|
|
3749
|
+
return {
|
|
3750
|
+
type: 'ImportNamespaceSpecifier',
|
|
3751
|
+
start: buffer[position],
|
|
3752
|
+
end: buffer[position + 1],
|
|
3753
|
+
local: convertNode(buffer[position + 2], buffer)
|
|
3754
|
+
};
|
|
3755
|
+
},
|
|
3756
|
+
function importSpecifier(position, buffer) {
|
|
3757
|
+
const importedPosition = buffer[position + 2];
|
|
3758
|
+
const local = convertNode(buffer[position + 3], buffer);
|
|
3759
|
+
return {
|
|
3760
|
+
type: 'ImportSpecifier',
|
|
3761
|
+
start: buffer[position],
|
|
3762
|
+
end: buffer[position + 1],
|
|
3763
|
+
imported: importedPosition === 0 ? { ...local } : convertNode(importedPosition, buffer),
|
|
3764
|
+
local
|
|
3765
|
+
};
|
|
3766
|
+
},
|
|
3767
|
+
function jsxAttribute(position, buffer) {
|
|
3768
|
+
const valuePosition = buffer[position + 3];
|
|
3769
|
+
return {
|
|
3770
|
+
type: 'JSXAttribute',
|
|
3771
|
+
start: buffer[position],
|
|
3772
|
+
end: buffer[position + 1],
|
|
3773
|
+
name: convertNode(buffer[position + 2], buffer),
|
|
3774
|
+
value: valuePosition === 0 ? null : convertNode(valuePosition, buffer)
|
|
3775
|
+
};
|
|
3776
|
+
},
|
|
3777
|
+
function jsxClosingElement(position, buffer) {
|
|
3778
|
+
return {
|
|
3779
|
+
type: 'JSXClosingElement',
|
|
3780
|
+
start: buffer[position],
|
|
3781
|
+
end: buffer[position + 1],
|
|
3782
|
+
name: convertNode(buffer[position + 2], buffer)
|
|
3783
|
+
};
|
|
3784
|
+
},
|
|
3785
|
+
function jsxClosingFragment(position, buffer) {
|
|
3786
|
+
return {
|
|
3787
|
+
type: 'JSXClosingFragment',
|
|
3788
|
+
start: buffer[position],
|
|
3789
|
+
end: buffer[position + 1]
|
|
3790
|
+
};
|
|
3791
|
+
},
|
|
3792
|
+
function jsxElement(position, buffer) {
|
|
3793
|
+
const closingElementPosition = buffer[position + 4];
|
|
3794
|
+
return {
|
|
3795
|
+
type: 'JSXElement',
|
|
3796
|
+
start: buffer[position],
|
|
3797
|
+
end: buffer[position + 1],
|
|
3798
|
+
openingElement: convertNode(buffer[position + 2], buffer),
|
|
3799
|
+
children: convertNodeList(buffer[position + 3], buffer),
|
|
3800
|
+
closingElement: closingElementPosition === 0 ? null : convertNode(closingElementPosition, buffer)
|
|
3801
|
+
};
|
|
3802
|
+
},
|
|
3803
|
+
function jsxEmptyExpression(position, buffer) {
|
|
3804
|
+
return {
|
|
3805
|
+
type: 'JSXEmptyExpression',
|
|
3806
|
+
start: buffer[position],
|
|
3807
|
+
end: buffer[position + 1]
|
|
3808
|
+
};
|
|
3809
|
+
},
|
|
3810
|
+
function jsxExpressionContainer(position, buffer) {
|
|
3811
|
+
return {
|
|
3812
|
+
type: 'JSXExpressionContainer',
|
|
3813
|
+
start: buffer[position],
|
|
3814
|
+
end: buffer[position + 1],
|
|
3815
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3816
|
+
};
|
|
3817
|
+
},
|
|
3818
|
+
function jsxFragment(position, buffer) {
|
|
3819
|
+
return {
|
|
3820
|
+
type: 'JSXFragment',
|
|
3821
|
+
start: buffer[position],
|
|
3822
|
+
end: buffer[position + 1],
|
|
3823
|
+
openingFragment: convertNode(buffer[position + 2], buffer),
|
|
3824
|
+
children: convertNodeList(buffer[position + 3], buffer),
|
|
3825
|
+
closingFragment: convertNode(buffer[position + 4], buffer)
|
|
3826
|
+
};
|
|
3827
|
+
},
|
|
3828
|
+
function jsxIdentifier(position, buffer) {
|
|
3829
|
+
return {
|
|
3830
|
+
type: 'JSXIdentifier',
|
|
3831
|
+
start: buffer[position],
|
|
3832
|
+
end: buffer[position + 1],
|
|
3833
|
+
name: buffer.convertString(buffer[position + 2])
|
|
3834
|
+
};
|
|
3835
|
+
},
|
|
3836
|
+
function jsxMemberExpression(position, buffer) {
|
|
3837
|
+
return {
|
|
3838
|
+
type: 'JSXMemberExpression',
|
|
3839
|
+
start: buffer[position],
|
|
3840
|
+
end: buffer[position + 1],
|
|
3841
|
+
object: convertNode(buffer[position + 2], buffer),
|
|
3842
|
+
property: convertNode(buffer[position + 3], buffer)
|
|
3843
|
+
};
|
|
3844
|
+
},
|
|
3845
|
+
function jsxNamespacedName(position, buffer) {
|
|
3846
|
+
return {
|
|
3847
|
+
type: 'JSXNamespacedName',
|
|
3848
|
+
start: buffer[position],
|
|
3849
|
+
end: buffer[position + 1],
|
|
3850
|
+
namespace: convertNode(buffer[position + 2], buffer),
|
|
3851
|
+
name: convertNode(buffer[position + 3], buffer)
|
|
3852
|
+
};
|
|
3853
|
+
},
|
|
3854
|
+
function jsxOpeningElement(position, buffer) {
|
|
3855
|
+
const flags = buffer[position + 2];
|
|
3856
|
+
return {
|
|
3857
|
+
type: 'JSXOpeningElement',
|
|
3858
|
+
start: buffer[position],
|
|
3859
|
+
end: buffer[position + 1],
|
|
3860
|
+
selfClosing: (flags & 1) === 1,
|
|
3861
|
+
name: convertNode(buffer[position + 3], buffer),
|
|
3862
|
+
attributes: convertNodeList(buffer[position + 4], buffer)
|
|
3863
|
+
};
|
|
3864
|
+
},
|
|
3865
|
+
function jsxOpeningFragment(position, buffer) {
|
|
3866
|
+
return {
|
|
3867
|
+
type: 'JSXOpeningFragment',
|
|
3868
|
+
start: buffer[position],
|
|
3869
|
+
end: buffer[position + 1],
|
|
3870
|
+
attributes: [],
|
|
3871
|
+
selfClosing: false
|
|
3872
|
+
};
|
|
3873
|
+
},
|
|
3874
|
+
function jsxSpreadAttribute(position, buffer) {
|
|
3875
|
+
return {
|
|
3876
|
+
type: 'JSXSpreadAttribute',
|
|
3877
|
+
start: buffer[position],
|
|
3878
|
+
end: buffer[position + 1],
|
|
3879
|
+
argument: convertNode(buffer[position + 2], buffer)
|
|
3880
|
+
};
|
|
3881
|
+
},
|
|
3882
|
+
function jsxSpreadChild(position, buffer) {
|
|
3883
|
+
return {
|
|
3884
|
+
type: 'JSXSpreadChild',
|
|
3885
|
+
start: buffer[position],
|
|
3886
|
+
end: buffer[position + 1],
|
|
3887
|
+
expression: convertNode(buffer[position + 2], buffer)
|
|
3888
|
+
};
|
|
3889
|
+
},
|
|
3890
|
+
function jsxText(position, buffer) {
|
|
3891
|
+
return {
|
|
3892
|
+
type: 'JSXText',
|
|
3893
|
+
start: buffer[position],
|
|
3894
|
+
end: buffer[position + 1],
|
|
3895
|
+
value: buffer.convertString(buffer[position + 2]),
|
|
3896
|
+
raw: buffer.convertString(buffer[position + 3])
|
|
3897
|
+
};
|
|
3898
|
+
},
|
|
3899
|
+
function labeledStatement(position, buffer) {
|
|
3900
|
+
return {
|
|
3901
|
+
type: 'LabeledStatement',
|
|
3902
|
+
start: buffer[position],
|
|
3903
|
+
end: buffer[position + 1],
|
|
3904
|
+
label: convertNode(buffer[position + 2], buffer),
|
|
3905
|
+
body: convertNode(buffer[position + 3], buffer)
|
|
3906
|
+
};
|
|
3907
|
+
},
|
|
3908
|
+
function literalBigInt(position, buffer) {
|
|
3909
|
+
const bigint = buffer.convertString(buffer[position + 2]);
|
|
3910
|
+
return {
|
|
3911
|
+
type: 'Literal',
|
|
3912
|
+
start: buffer[position],
|
|
3913
|
+
end: buffer[position + 1],
|
|
3914
|
+
bigint,
|
|
3915
|
+
raw: buffer.convertString(buffer[position + 3]),
|
|
3916
|
+
value: BigInt(bigint)
|
|
3917
|
+
};
|
|
3918
|
+
},
|
|
3919
|
+
function literalBoolean(position, buffer) {
|
|
3920
|
+
const flags = buffer[position + 2];
|
|
3921
|
+
const value = (flags & 1) === 1;
|
|
3922
|
+
return {
|
|
3923
|
+
type: 'Literal',
|
|
3924
|
+
start: buffer[position],
|
|
3925
|
+
end: buffer[position + 1],
|
|
3926
|
+
value,
|
|
3927
|
+
raw: value ? 'true' : 'false'
|
|
3928
|
+
};
|
|
3929
|
+
},
|
|
3930
|
+
function literalNull(position, buffer) {
|
|
3931
|
+
return {
|
|
3932
|
+
type: 'Literal',
|
|
3933
|
+
start: buffer[position],
|
|
3934
|
+
end: buffer[position + 1],
|
|
3935
|
+
raw: 'null',
|
|
3936
|
+
value: null
|
|
3937
|
+
};
|
|
3938
|
+
},
|
|
3939
|
+
function literalNumber(position, buffer) {
|
|
3940
|
+
const rawPosition = buffer[position + 2];
|
|
3941
|
+
return {
|
|
3942
|
+
type: 'Literal',
|
|
3943
|
+
start: buffer[position],
|
|
3944
|
+
end: buffer[position + 1],
|
|
3945
|
+
raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition),
|
|
3946
|
+
value: new DataView(buffer.buffer).getFloat64((position + 3) << 2, true)
|
|
3947
|
+
};
|
|
3948
|
+
},
|
|
3949
|
+
function literalRegExp(position, buffer) {
|
|
3950
|
+
const flags = buffer.convertString(buffer[position + 2]);
|
|
3951
|
+
const pattern = buffer.convertString(buffer[position + 3]);
|
|
3952
|
+
return {
|
|
3953
|
+
type: 'Literal',
|
|
3954
|
+
start: buffer[position],
|
|
3955
|
+
end: buffer[position + 1],
|
|
3956
|
+
raw: `/${pattern}/${flags}`,
|
|
3957
|
+
regex: { flags, pattern },
|
|
3958
|
+
value: new RegExp(pattern, flags)
|
|
3959
|
+
};
|
|
3960
|
+
},
|
|
3961
|
+
function literalString(position, buffer) {
|
|
3962
|
+
const rawPosition = buffer[position + 3];
|
|
3963
|
+
return {
|
|
3964
|
+
type: 'Literal',
|
|
3965
|
+
start: buffer[position],
|
|
3966
|
+
end: buffer[position + 1],
|
|
3967
|
+
value: buffer.convertString(buffer[position + 2]),
|
|
3968
|
+
raw: rawPosition === 0 ? undefined : buffer.convertString(rawPosition)
|
|
3969
|
+
};
|
|
3970
|
+
},
|
|
3971
|
+
function logicalExpression(position, buffer) {
|
|
3972
|
+
return {
|
|
3973
|
+
type: 'LogicalExpression',
|
|
3974
|
+
start: buffer[position],
|
|
3975
|
+
end: buffer[position + 1],
|
|
3976
|
+
operator: FIXED_STRINGS[buffer[position + 2]],
|
|
3977
|
+
left: convertNode(buffer[position + 3], buffer),
|
|
3978
|
+
right: convertNode(buffer[position + 4], buffer)
|
|
3979
|
+
};
|
|
3980
|
+
},
|
|
3981
|
+
function memberExpression(position, buffer) {
|
|
3982
|
+
const flags = buffer[position + 2];
|
|
3983
|
+
return {
|
|
3984
|
+
type: 'MemberExpression',
|
|
3985
|
+
start: buffer[position],
|
|
3986
|
+
end: buffer[position + 1],
|
|
3987
|
+
computed: (flags & 1) === 1,
|
|
3988
|
+
optional: (flags & 2) === 2,
|
|
3989
|
+
object: convertNode(buffer[position + 3], buffer),
|
|
3990
|
+
property: convertNode(buffer[position + 4], buffer)
|
|
3991
|
+
};
|
|
3992
|
+
},
|
|
3993
|
+
function metaProperty(position, buffer) {
|
|
3994
|
+
return {
|
|
3995
|
+
type: 'MetaProperty',
|
|
3996
|
+
start: buffer[position],
|
|
3997
|
+
end: buffer[position + 1],
|
|
3998
|
+
meta: convertNode(buffer[position + 2], buffer),
|
|
3999
|
+
property: convertNode(buffer[position + 3], buffer)
|
|
4000
|
+
};
|
|
4001
|
+
},
|
|
4002
|
+
function methodDefinition(position, buffer) {
|
|
4003
|
+
const flags = buffer[position + 2];
|
|
4004
|
+
return {
|
|
4005
|
+
type: 'MethodDefinition',
|
|
4006
|
+
start: buffer[position],
|
|
4007
|
+
end: buffer[position + 1],
|
|
4008
|
+
static: (flags & 1) === 1,
|
|
4009
|
+
computed: (flags & 2) === 2,
|
|
4010
|
+
decorators: convertNodeList(buffer[position + 3], buffer),
|
|
4011
|
+
key: convertNode(buffer[position + 4], buffer),
|
|
4012
|
+
value: convertNode(buffer[position + 5], buffer),
|
|
4013
|
+
kind: FIXED_STRINGS[buffer[position + 6]]
|
|
4014
|
+
};
|
|
4015
|
+
},
|
|
4016
|
+
function newExpression(position, buffer) {
|
|
4017
|
+
const annotations = convertAnnotations(buffer[position + 2], buffer);
|
|
4018
|
+
return {
|
|
4019
|
+
type: 'NewExpression',
|
|
4020
|
+
start: buffer[position],
|
|
4021
|
+
end: buffer[position + 1],
|
|
4022
|
+
...(annotations.length > 0 ? { annotations } : {}),
|
|
4023
|
+
callee: convertNode(buffer[position + 3], buffer),
|
|
4024
|
+
arguments: convertNodeList(buffer[position + 4], buffer)
|
|
4025
|
+
};
|
|
4026
|
+
},
|
|
4027
|
+
function objectExpression(position, buffer) {
|
|
4028
|
+
return {
|
|
4029
|
+
type: 'ObjectExpression',
|
|
4030
|
+
start: buffer[position],
|
|
4031
|
+
end: buffer[position + 1],
|
|
4032
|
+
properties: convertNodeList(buffer[position + 2], buffer)
|
|
4033
|
+
};
|
|
4034
|
+
},
|
|
4035
|
+
function objectPattern(position, buffer) {
|
|
4036
|
+
return {
|
|
4037
|
+
type: 'ObjectPattern',
|
|
4038
|
+
start: buffer[position],
|
|
4039
|
+
end: buffer[position + 1],
|
|
4040
|
+
properties: convertNodeList(buffer[position + 2], buffer)
|
|
4041
|
+
};
|
|
4042
|
+
},
|
|
4043
|
+
function privateIdentifier(position, buffer) {
|
|
4044
|
+
return {
|
|
4045
|
+
type: 'PrivateIdentifier',
|
|
4046
|
+
start: buffer[position],
|
|
4047
|
+
end: buffer[position + 1],
|
|
4048
|
+
name: buffer.convertString(buffer[position + 2])
|
|
4049
|
+
};
|
|
4050
|
+
},
|
|
4051
|
+
function program(position, buffer) {
|
|
4052
|
+
const invalidAnnotations = convertAnnotations(buffer[position + 3], buffer);
|
|
4053
|
+
return {
|
|
4054
|
+
type: 'Program',
|
|
4055
|
+
start: buffer[position],
|
|
4056
|
+
end: buffer[position + 1],
|
|
4057
|
+
body: convertNodeList(buffer[position + 2], buffer),
|
|
4058
|
+
...(invalidAnnotations.length > 0 ? { invalidAnnotations } : {}),
|
|
4059
|
+
sourceType: 'module'
|
|
4060
|
+
};
|
|
4061
|
+
},
|
|
4062
|
+
function property(position, buffer) {
|
|
4063
|
+
const flags = buffer[position + 2];
|
|
4064
|
+
const keyPosition = buffer[position + 3];
|
|
4065
|
+
const value = convertNode(buffer[position + 4], buffer);
|
|
4066
|
+
return {
|
|
4067
|
+
type: 'Property',
|
|
4068
|
+
start: buffer[position],
|
|
4069
|
+
end: buffer[position + 1],
|
|
4070
|
+
method: (flags & 1) === 1,
|
|
4071
|
+
shorthand: (flags & 2) === 2,
|
|
4072
|
+
computed: (flags & 4) === 4,
|
|
4073
|
+
key: keyPosition === 0 ? { ...value } : convertNode(keyPosition, buffer),
|
|
4074
|
+
value,
|
|
4075
|
+
kind: FIXED_STRINGS[buffer[position + 5]]
|
|
4076
|
+
};
|
|
4077
|
+
},
|
|
4078
|
+
function propertyDefinition(position, buffer) {
|
|
4079
|
+
const flags = buffer[position + 2];
|
|
4080
|
+
const valuePosition = buffer[position + 5];
|
|
4081
|
+
return {
|
|
4082
|
+
type: 'PropertyDefinition',
|
|
4083
|
+
start: buffer[position],
|
|
4084
|
+
end: buffer[position + 1],
|
|
4085
|
+
static: (flags & 1) === 1,
|
|
4086
|
+
computed: (flags & 2) === 2,
|
|
4087
|
+
decorators: convertNodeList(buffer[position + 3], buffer),
|
|
4088
|
+
key: convertNode(buffer[position + 4], buffer),
|
|
4089
|
+
value: valuePosition === 0 ? null : convertNode(valuePosition, buffer)
|
|
4090
|
+
};
|
|
4091
|
+
},
|
|
4092
|
+
function restElement(position, buffer) {
|
|
4093
|
+
return {
|
|
4094
|
+
type: 'RestElement',
|
|
4095
|
+
start: buffer[position],
|
|
4096
|
+
end: buffer[position + 1],
|
|
4097
|
+
argument: convertNode(buffer[position + 2], buffer)
|
|
4098
|
+
};
|
|
4099
|
+
},
|
|
4100
|
+
function returnStatement(position, buffer) {
|
|
4101
|
+
const argumentPosition = buffer[position + 2];
|
|
4102
|
+
return {
|
|
4103
|
+
type: 'ReturnStatement',
|
|
4104
|
+
start: buffer[position],
|
|
4105
|
+
end: buffer[position + 1],
|
|
4106
|
+
argument: argumentPosition === 0 ? null : convertNode(argumentPosition, buffer)
|
|
4107
|
+
};
|
|
4108
|
+
},
|
|
4109
|
+
function sequenceExpression(position, buffer) {
|
|
4110
|
+
return {
|
|
4111
|
+
type: 'SequenceExpression',
|
|
4112
|
+
start: buffer[position],
|
|
4113
|
+
end: buffer[position + 1],
|
|
4114
|
+
expressions: convertNodeList(buffer[position + 2], buffer)
|
|
4115
|
+
};
|
|
4116
|
+
},
|
|
4117
|
+
function spreadElement(position, buffer) {
|
|
4118
|
+
return {
|
|
4119
|
+
type: 'SpreadElement',
|
|
4120
|
+
start: buffer[position],
|
|
4121
|
+
end: buffer[position + 1],
|
|
4122
|
+
argument: convertNode(buffer[position + 2], buffer)
|
|
4123
|
+
};
|
|
4124
|
+
},
|
|
4125
|
+
function staticBlock(position, buffer) {
|
|
4126
|
+
return {
|
|
4127
|
+
type: 'StaticBlock',
|
|
4128
|
+
start: buffer[position],
|
|
4129
|
+
end: buffer[position + 1],
|
|
4130
|
+
body: convertNodeList(buffer[position + 2], buffer)
|
|
4131
|
+
};
|
|
4132
|
+
},
|
|
4133
|
+
function superElement(position, buffer) {
|
|
4134
|
+
return {
|
|
4135
|
+
type: 'Super',
|
|
4136
|
+
start: buffer[position],
|
|
4137
|
+
end: buffer[position + 1]
|
|
4138
|
+
};
|
|
4139
|
+
},
|
|
4140
|
+
function switchCase(position, buffer) {
|
|
4141
|
+
const testPosition = buffer[position + 2];
|
|
4142
|
+
return {
|
|
4143
|
+
type: 'SwitchCase',
|
|
4144
|
+
start: buffer[position],
|
|
4145
|
+
end: buffer[position + 1],
|
|
4146
|
+
test: testPosition === 0 ? null : convertNode(testPosition, buffer),
|
|
4147
|
+
consequent: convertNodeList(buffer[position + 3], buffer)
|
|
4148
|
+
};
|
|
4149
|
+
},
|
|
4150
|
+
function switchStatement(position, buffer) {
|
|
4151
|
+
return {
|
|
4152
|
+
type: 'SwitchStatement',
|
|
4153
|
+
start: buffer[position],
|
|
4154
|
+
end: buffer[position + 1],
|
|
4155
|
+
discriminant: convertNode(buffer[position + 2], buffer),
|
|
4156
|
+
cases: convertNodeList(buffer[position + 3], buffer)
|
|
4157
|
+
};
|
|
4158
|
+
},
|
|
4159
|
+
function taggedTemplateExpression(position, buffer) {
|
|
4160
|
+
return {
|
|
4161
|
+
type: 'TaggedTemplateExpression',
|
|
4162
|
+
start: buffer[position],
|
|
4163
|
+
end: buffer[position + 1],
|
|
4164
|
+
tag: convertNode(buffer[position + 2], buffer),
|
|
4165
|
+
quasi: convertNode(buffer[position + 3], buffer)
|
|
4166
|
+
};
|
|
4167
|
+
},
|
|
4168
|
+
function templateElement(position, buffer) {
|
|
4169
|
+
const flags = buffer[position + 2];
|
|
4170
|
+
const cookedPosition = buffer[position + 3];
|
|
4171
|
+
const cooked = cookedPosition === 0 ? undefined : buffer.convertString(cookedPosition);
|
|
2037
4172
|
const raw = buffer.convertString(buffer[position + 4]);
|
|
2038
4173
|
return {
|
|
2039
4174
|
type: 'TemplateElement',
|
|
@@ -2162,31 +4297,1161 @@ function convertNodeList(position, buffer) {
|
|
|
2162
4297
|
return list;
|
|
2163
4298
|
}
|
|
2164
4299
|
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
4300
|
+
// This file is generated by scripts/generate-string-constants.ts.
|
|
4301
|
+
// Do not edit this file directly.
|
|
4302
|
+
const FIXED_STRING_INDICES = {
|
|
4303
|
+
'!': 10,
|
|
4304
|
+
'!=': 18,
|
|
4305
|
+
'!==': 20,
|
|
4306
|
+
'%': 30,
|
|
4307
|
+
'%=': 45,
|
|
4308
|
+
'&': 33,
|
|
4309
|
+
'&&': 35,
|
|
4310
|
+
'&&=': 53,
|
|
4311
|
+
'&=': 51,
|
|
4312
|
+
'*': 28,
|
|
4313
|
+
'**': 38,
|
|
4314
|
+
'**=': 52,
|
|
4315
|
+
'*=': 43,
|
|
4316
|
+
'+': 9,
|
|
4317
|
+
'++': 15,
|
|
4318
|
+
'+=': 41,
|
|
4319
|
+
'-': 8,
|
|
4320
|
+
'--': 16,
|
|
4321
|
+
'-=': 42,
|
|
4322
|
+
'/': 29,
|
|
4323
|
+
'/=': 44,
|
|
4324
|
+
'<': 21,
|
|
4325
|
+
'<<': 25,
|
|
4326
|
+
'<<=': 46,
|
|
4327
|
+
'<=': 22,
|
|
4328
|
+
'=': 40,
|
|
4329
|
+
'==': 17,
|
|
4330
|
+
'===': 19,
|
|
4331
|
+
'>': 23,
|
|
4332
|
+
'>=': 24,
|
|
4333
|
+
'>>': 26,
|
|
4334
|
+
'>>=': 47,
|
|
4335
|
+
'>>>': 27,
|
|
4336
|
+
'>>>=': 48,
|
|
4337
|
+
'??': 39,
|
|
4338
|
+
'??=': 55,
|
|
4339
|
+
'^': 32,
|
|
4340
|
+
'^=': 50,
|
|
4341
|
+
'await using': 60,
|
|
4342
|
+
const: 2,
|
|
4343
|
+
constructor: 6,
|
|
4344
|
+
defer: 62,
|
|
4345
|
+
delete: 14,
|
|
4346
|
+
get: 4,
|
|
4347
|
+
in: 36,
|
|
4348
|
+
init: 3,
|
|
4349
|
+
instanceof: 37,
|
|
4350
|
+
let: 1,
|
|
4351
|
+
method: 7,
|
|
4352
|
+
noSideEffects: 57,
|
|
4353
|
+
pure: 56,
|
|
4354
|
+
set: 5,
|
|
4355
|
+
source: 61,
|
|
4356
|
+
sourcemap: 58,
|
|
4357
|
+
typeof: 12,
|
|
4358
|
+
using: 59,
|
|
4359
|
+
var: 0,
|
|
4360
|
+
void: 13,
|
|
4361
|
+
'|': 31,
|
|
4362
|
+
'|=': 49,
|
|
4363
|
+
'||': 34,
|
|
4364
|
+
'||=': 54,
|
|
4365
|
+
'~': 11
|
|
4366
|
+
};
|
|
4367
|
+
|
|
4368
|
+
// This file is generated by scripts/generate-ast-to-buffer.ts.
|
|
4369
|
+
// Do not edit this file directly.
|
|
4370
|
+
const INITIAL_BUFFER_SIZE = 2 ** 16; // 64KB
|
|
4371
|
+
const serializeAst = node => {
|
|
4372
|
+
const initialBuffer = (typeof Buffer === 'undefined' ? createAstBufferUint8 : createAstBufferNode)(INITIAL_BUFFER_SIZE);
|
|
4373
|
+
const buffer = (nodeSerializers[node.type] || error(logUnknownNodeType(node.type, null, '')))(node, initialBuffer);
|
|
4374
|
+
return buffer.toOutput();
|
|
4375
|
+
};
|
|
4376
|
+
const serializeExpressionStatementNode = (node, buffer) => {
|
|
4377
|
+
return 'directive' in node
|
|
4378
|
+
? serializeDirective(node, buffer)
|
|
4379
|
+
: serializeExpressionStatement(node, buffer);
|
|
4380
|
+
};
|
|
4381
|
+
const serializeLiteralNode = (node, buffer) => {
|
|
4382
|
+
switch (typeof node.value) {
|
|
4383
|
+
case 'object':
|
|
4384
|
+
if (node.value === null) {
|
|
4385
|
+
return serializeLiteralNull(node, buffer);
|
|
4386
|
+
}
|
|
4387
|
+
return serializeLiteralRegExp(node, buffer);
|
|
4388
|
+
case 'boolean':
|
|
4389
|
+
return serializeLiteralBoolean(node, buffer);
|
|
4390
|
+
case 'number':
|
|
4391
|
+
return serializeLiteralNumber(node, buffer);
|
|
4392
|
+
case 'string':
|
|
4393
|
+
return serializeLiteralString(node, buffer);
|
|
4394
|
+
case 'bigint':
|
|
4395
|
+
return serializeLiteralBigInt(node, buffer);
|
|
4396
|
+
default: {
|
|
4397
|
+
/* istanbul ignore next */
|
|
4398
|
+
throw new Error(`Unexpected node value type for Literal: ${typeof node.value}`);
|
|
4399
|
+
}
|
|
2174
4400
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
4401
|
+
};
|
|
4402
|
+
const nodeSerializers = {
|
|
4403
|
+
ArrayExpression: (node, buffer) => {
|
|
4404
|
+
const nodePosition = buffer.position;
|
|
4405
|
+
buffer = buffer.reserve(4);
|
|
4406
|
+
buffer[nodePosition] = 2;
|
|
4407
|
+
buffer[nodePosition + 1] = node.start;
|
|
4408
|
+
buffer[nodePosition + 2] = node.end;
|
|
4409
|
+
buffer = serializeNodeList('elements', node, buffer, nodePosition + 3);
|
|
4410
|
+
return buffer;
|
|
4411
|
+
},
|
|
4412
|
+
ArrayPattern: (node, buffer) => {
|
|
4413
|
+
const nodePosition = buffer.position;
|
|
4414
|
+
buffer = buffer.reserve(4);
|
|
4415
|
+
buffer[nodePosition] = 3;
|
|
4416
|
+
buffer[nodePosition + 1] = node.start;
|
|
4417
|
+
buffer[nodePosition + 2] = node.end;
|
|
4418
|
+
buffer = serializeNodeList('elements', node, buffer, nodePosition + 3);
|
|
4419
|
+
return buffer;
|
|
4420
|
+
},
|
|
4421
|
+
ArrowFunctionExpression: (node, buffer) => {
|
|
4422
|
+
const nodePosition = buffer.position;
|
|
4423
|
+
buffer = buffer.reserve(8);
|
|
4424
|
+
buffer[nodePosition] = 4;
|
|
4425
|
+
buffer[nodePosition + 1] = node.start;
|
|
4426
|
+
buffer[nodePosition + 2] = node.end;
|
|
4427
|
+
buffer[nodePosition + 3] =
|
|
4428
|
+
(node.async << 0) | (node.expression << 1) | (node.generator << 2);
|
|
4429
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4430
|
+
buffer = serializeNodeList('params', node, buffer, nodePosition + 5);
|
|
4431
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4432
|
+
return buffer;
|
|
4433
|
+
},
|
|
4434
|
+
AssignmentExpression: (node, buffer) => {
|
|
4435
|
+
const nodePosition = buffer.position;
|
|
4436
|
+
buffer = buffer.reserve(6);
|
|
4437
|
+
buffer[nodePosition] = 5;
|
|
4438
|
+
buffer[nodePosition + 1] = node.start;
|
|
4439
|
+
buffer[nodePosition + 2] = node.end;
|
|
4440
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
4441
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4442
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4443
|
+
return buffer;
|
|
4444
|
+
},
|
|
4445
|
+
AssignmentPattern: (node, buffer) => {
|
|
4446
|
+
const nodePosition = buffer.position;
|
|
4447
|
+
buffer = buffer.reserve(5);
|
|
4448
|
+
buffer[nodePosition] = 6;
|
|
4449
|
+
buffer[nodePosition + 1] = node.start;
|
|
4450
|
+
buffer[nodePosition + 2] = node.end;
|
|
4451
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 3);
|
|
4452
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 4);
|
|
4453
|
+
return buffer;
|
|
4454
|
+
},
|
|
4455
|
+
AwaitExpression: (node, buffer) => {
|
|
4456
|
+
const nodePosition = buffer.position;
|
|
4457
|
+
buffer = buffer.reserve(4);
|
|
4458
|
+
buffer[nodePosition] = 7;
|
|
4459
|
+
buffer[nodePosition + 1] = node.start;
|
|
4460
|
+
buffer[nodePosition + 2] = node.end;
|
|
4461
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4462
|
+
return buffer;
|
|
4463
|
+
},
|
|
4464
|
+
BinaryExpression: (node, buffer) => {
|
|
4465
|
+
const nodePosition = buffer.position;
|
|
4466
|
+
buffer = buffer.reserve(6);
|
|
4467
|
+
buffer[nodePosition] = 8;
|
|
4468
|
+
buffer[nodePosition + 1] = node.start;
|
|
4469
|
+
buffer[nodePosition + 2] = node.end;
|
|
4470
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
4471
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4472
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4473
|
+
return buffer;
|
|
4474
|
+
},
|
|
4475
|
+
BlockStatement: (node, buffer) => {
|
|
4476
|
+
const nodePosition = buffer.position;
|
|
4477
|
+
buffer = buffer.reserve(5);
|
|
4478
|
+
buffer[nodePosition] = 9;
|
|
4479
|
+
buffer[nodePosition + 1] = node.start;
|
|
4480
|
+
buffer[nodePosition + 2] = node.end;
|
|
4481
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
4482
|
+
return buffer;
|
|
4483
|
+
},
|
|
4484
|
+
BreakStatement: (node, buffer) => {
|
|
4485
|
+
const nodePosition = buffer.position;
|
|
4486
|
+
buffer = buffer.reserve(4);
|
|
4487
|
+
buffer[nodePosition] = 10;
|
|
4488
|
+
buffer[nodePosition + 1] = node.start;
|
|
4489
|
+
buffer[nodePosition + 2] = node.end;
|
|
4490
|
+
if (node.label != null)
|
|
4491
|
+
buffer = serializeNode('label', node, buffer, nodePosition + 3);
|
|
4492
|
+
return buffer;
|
|
4493
|
+
},
|
|
4494
|
+
CallExpression: (node, buffer) => {
|
|
4495
|
+
const nodePosition = buffer.position;
|
|
4496
|
+
buffer = buffer.reserve(7);
|
|
4497
|
+
buffer[nodePosition] = 11;
|
|
4498
|
+
buffer[nodePosition + 1] = node.start;
|
|
4499
|
+
buffer[nodePosition + 2] = node.end;
|
|
4500
|
+
buffer[nodePosition + 3] = node.optional << 0;
|
|
4501
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4502
|
+
buffer = serializeNode('callee', node, buffer, nodePosition + 5);
|
|
4503
|
+
buffer = serializeNodeList('arguments', node, buffer, nodePosition + 6);
|
|
4504
|
+
return buffer;
|
|
4505
|
+
},
|
|
4506
|
+
CatchClause: (node, buffer) => {
|
|
4507
|
+
const nodePosition = buffer.position;
|
|
4508
|
+
buffer = buffer.reserve(6);
|
|
4509
|
+
buffer[nodePosition] = 12;
|
|
4510
|
+
buffer[nodePosition + 1] = node.start;
|
|
4511
|
+
buffer[nodePosition + 2] = node.end;
|
|
4512
|
+
if (node.param != null)
|
|
4513
|
+
buffer = serializeNode('param', node, buffer, nodePosition + 3);
|
|
4514
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 4);
|
|
4515
|
+
return buffer;
|
|
4516
|
+
},
|
|
4517
|
+
ChainExpression: (node, buffer) => {
|
|
4518
|
+
const nodePosition = buffer.position;
|
|
4519
|
+
buffer = buffer.reserve(4);
|
|
4520
|
+
buffer[nodePosition] = 13;
|
|
4521
|
+
buffer[nodePosition + 1] = node.start;
|
|
4522
|
+
buffer[nodePosition + 2] = node.end;
|
|
4523
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4524
|
+
return buffer;
|
|
4525
|
+
},
|
|
4526
|
+
ClassBody: (node, buffer) => {
|
|
4527
|
+
const nodePosition = buffer.position;
|
|
4528
|
+
buffer = buffer.reserve(4);
|
|
4529
|
+
buffer[nodePosition] = 14;
|
|
4530
|
+
buffer[nodePosition + 1] = node.start;
|
|
4531
|
+
buffer[nodePosition + 2] = node.end;
|
|
4532
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
4533
|
+
return buffer;
|
|
4534
|
+
},
|
|
4535
|
+
ClassDeclaration: (node, buffer) => {
|
|
4536
|
+
const nodePosition = buffer.position;
|
|
4537
|
+
buffer = buffer.reserve(8);
|
|
4538
|
+
buffer[nodePosition] = 15;
|
|
4539
|
+
buffer[nodePosition + 1] = node.start;
|
|
4540
|
+
buffer[nodePosition + 2] = node.end;
|
|
4541
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 3);
|
|
4542
|
+
if (node.id != null)
|
|
4543
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 4);
|
|
4544
|
+
if (node.superClass != null)
|
|
4545
|
+
buffer = serializeNode('superClass', node, buffer, nodePosition + 5);
|
|
4546
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4547
|
+
return buffer;
|
|
4548
|
+
},
|
|
4549
|
+
ClassExpression: (node, buffer) => {
|
|
4550
|
+
const nodePosition = buffer.position;
|
|
4551
|
+
buffer = buffer.reserve(8);
|
|
4552
|
+
buffer[nodePosition] = 16;
|
|
4553
|
+
buffer[nodePosition + 1] = node.start;
|
|
4554
|
+
buffer[nodePosition + 2] = node.end;
|
|
4555
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 3);
|
|
4556
|
+
if (node.id != null)
|
|
4557
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 4);
|
|
4558
|
+
if (node.superClass != null)
|
|
4559
|
+
buffer = serializeNode('superClass', node, buffer, nodePosition + 5);
|
|
4560
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4561
|
+
return buffer;
|
|
4562
|
+
},
|
|
4563
|
+
ConditionalExpression: (node, buffer) => {
|
|
4564
|
+
const nodePosition = buffer.position;
|
|
4565
|
+
buffer = buffer.reserve(6);
|
|
4566
|
+
buffer[nodePosition] = 17;
|
|
4567
|
+
buffer[nodePosition + 1] = node.start;
|
|
4568
|
+
buffer[nodePosition + 2] = node.end;
|
|
4569
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
4570
|
+
buffer = serializeNode('consequent', node, buffer, nodePosition + 4);
|
|
4571
|
+
buffer = serializeNode('alternate', node, buffer, nodePosition + 5);
|
|
4572
|
+
return buffer;
|
|
4573
|
+
},
|
|
4574
|
+
ContinueStatement: (node, buffer) => {
|
|
4575
|
+
const nodePosition = buffer.position;
|
|
4576
|
+
buffer = buffer.reserve(4);
|
|
4577
|
+
buffer[nodePosition] = 18;
|
|
4578
|
+
buffer[nodePosition + 1] = node.start;
|
|
4579
|
+
buffer[nodePosition + 2] = node.end;
|
|
4580
|
+
if (node.label != null)
|
|
4581
|
+
buffer = serializeNode('label', node, buffer, nodePosition + 3);
|
|
4582
|
+
return buffer;
|
|
4583
|
+
},
|
|
4584
|
+
DebuggerStatement: (node, buffer) => {
|
|
4585
|
+
const nodePosition = buffer.position;
|
|
4586
|
+
buffer = buffer.reserve(3);
|
|
4587
|
+
buffer[nodePosition] = 19;
|
|
4588
|
+
buffer[nodePosition + 1] = node.start;
|
|
4589
|
+
buffer[nodePosition + 2] = node.end;
|
|
4590
|
+
return buffer;
|
|
4591
|
+
},
|
|
4592
|
+
Decorator: (node, buffer) => {
|
|
4593
|
+
const nodePosition = buffer.position;
|
|
4594
|
+
buffer = buffer.reserve(4);
|
|
4595
|
+
buffer[nodePosition] = 20;
|
|
4596
|
+
buffer[nodePosition + 1] = node.start;
|
|
4597
|
+
buffer[nodePosition + 2] = node.end;
|
|
4598
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4599
|
+
return buffer;
|
|
4600
|
+
},
|
|
4601
|
+
DoWhileStatement: (node, buffer) => {
|
|
4602
|
+
const nodePosition = buffer.position;
|
|
4603
|
+
buffer = buffer.reserve(5);
|
|
4604
|
+
buffer[nodePosition] = 22;
|
|
4605
|
+
buffer[nodePosition + 1] = node.start;
|
|
4606
|
+
buffer[nodePosition + 2] = node.end;
|
|
4607
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 3);
|
|
4608
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 4);
|
|
4609
|
+
return buffer;
|
|
4610
|
+
},
|
|
4611
|
+
EmptyStatement: (node, buffer) => {
|
|
4612
|
+
const nodePosition = buffer.position;
|
|
4613
|
+
buffer = buffer.reserve(3);
|
|
4614
|
+
buffer[nodePosition] = 23;
|
|
4615
|
+
buffer[nodePosition + 1] = node.start;
|
|
4616
|
+
buffer[nodePosition + 2] = node.end;
|
|
4617
|
+
return buffer;
|
|
4618
|
+
},
|
|
4619
|
+
ExportAllDeclaration: (node, buffer) => {
|
|
4620
|
+
const nodePosition = buffer.position;
|
|
4621
|
+
buffer = buffer.reserve(6);
|
|
4622
|
+
buffer[nodePosition] = 24;
|
|
4623
|
+
buffer[nodePosition + 1] = node.start;
|
|
4624
|
+
buffer[nodePosition + 2] = node.end;
|
|
4625
|
+
if (node.exported != null)
|
|
4626
|
+
buffer = serializeNode('exported', node, buffer, nodePosition + 3);
|
|
4627
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 4);
|
|
4628
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4629
|
+
return buffer;
|
|
4630
|
+
},
|
|
4631
|
+
ExportDefaultDeclaration: (node, buffer) => {
|
|
4632
|
+
const nodePosition = buffer.position;
|
|
4633
|
+
buffer = buffer.reserve(4);
|
|
4634
|
+
buffer[nodePosition] = 25;
|
|
4635
|
+
buffer[nodePosition + 1] = node.start;
|
|
4636
|
+
buffer[nodePosition + 2] = node.end;
|
|
4637
|
+
buffer = serializeNode('declaration', node, buffer, nodePosition + 3);
|
|
4638
|
+
return buffer;
|
|
4639
|
+
},
|
|
4640
|
+
ExportNamedDeclaration: (node, buffer) => {
|
|
4641
|
+
const nodePosition = buffer.position;
|
|
4642
|
+
buffer = buffer.reserve(7);
|
|
4643
|
+
buffer[nodePosition] = 26;
|
|
4644
|
+
buffer[nodePosition + 1] = node.start;
|
|
4645
|
+
buffer[nodePosition + 2] = node.end;
|
|
4646
|
+
buffer = serializeNodeList('specifiers', node, buffer, nodePosition + 3);
|
|
4647
|
+
if (node.source != null)
|
|
4648
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 4);
|
|
4649
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4650
|
+
if (node.declaration != null)
|
|
4651
|
+
buffer = serializeNode('declaration', node, buffer, nodePosition + 6);
|
|
4652
|
+
return buffer;
|
|
4653
|
+
},
|
|
4654
|
+
ExportSpecifier: (node, buffer) => {
|
|
4655
|
+
const nodePosition = buffer.position;
|
|
4656
|
+
buffer = buffer.reserve(5);
|
|
4657
|
+
buffer[nodePosition] = 27;
|
|
4658
|
+
buffer[nodePosition + 1] = node.start;
|
|
4659
|
+
buffer[nodePosition + 2] = node.end;
|
|
4660
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 3);
|
|
4661
|
+
if (node.exported.end != node.local.end)
|
|
4662
|
+
buffer = serializeNode('exported', node, buffer, nodePosition + 4);
|
|
4663
|
+
return buffer;
|
|
4664
|
+
},
|
|
4665
|
+
ExpressionStatement: serializeExpressionStatementNode,
|
|
4666
|
+
ForInStatement: (node, buffer) => {
|
|
4667
|
+
const nodePosition = buffer.position;
|
|
4668
|
+
buffer = buffer.reserve(7);
|
|
4669
|
+
buffer[nodePosition] = 29;
|
|
4670
|
+
buffer[nodePosition + 1] = node.start;
|
|
4671
|
+
buffer[nodePosition + 2] = node.end;
|
|
4672
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 3);
|
|
4673
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 4);
|
|
4674
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 5);
|
|
4675
|
+
return buffer;
|
|
4676
|
+
},
|
|
4677
|
+
ForOfStatement: (node, buffer) => {
|
|
4678
|
+
const nodePosition = buffer.position;
|
|
4679
|
+
buffer = buffer.reserve(8);
|
|
4680
|
+
buffer[nodePosition] = 30;
|
|
4681
|
+
buffer[nodePosition + 1] = node.start;
|
|
4682
|
+
buffer[nodePosition + 2] = node.end;
|
|
4683
|
+
buffer[nodePosition + 3] = node.await << 0;
|
|
4684
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4685
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4686
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4687
|
+
return buffer;
|
|
4688
|
+
},
|
|
4689
|
+
ForStatement: (node, buffer) => {
|
|
4690
|
+
const nodePosition = buffer.position;
|
|
4691
|
+
buffer = buffer.reserve(8);
|
|
4692
|
+
buffer[nodePosition] = 31;
|
|
4693
|
+
buffer[nodePosition + 1] = node.start;
|
|
4694
|
+
buffer[nodePosition + 2] = node.end;
|
|
4695
|
+
if (node.init != null)
|
|
4696
|
+
buffer = serializeNode('init', node, buffer, nodePosition + 3);
|
|
4697
|
+
if (node.test != null)
|
|
4698
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 4);
|
|
4699
|
+
if (node.update != null)
|
|
4700
|
+
buffer = serializeNode('update', node, buffer, nodePosition + 5);
|
|
4701
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 6);
|
|
4702
|
+
return buffer;
|
|
4703
|
+
},
|
|
4704
|
+
FunctionDeclaration: (node, buffer) => {
|
|
4705
|
+
const nodePosition = buffer.position;
|
|
4706
|
+
buffer = buffer.reserve(9);
|
|
4707
|
+
buffer[nodePosition] = 32;
|
|
4708
|
+
buffer[nodePosition + 1] = node.start;
|
|
4709
|
+
buffer[nodePosition + 2] = node.end;
|
|
4710
|
+
buffer[nodePosition + 3] = (node.async << 0) | (node.generator << 1);
|
|
4711
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4712
|
+
if (node.id != null)
|
|
4713
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 5);
|
|
4714
|
+
buffer = serializeNodeList('params', node, buffer, nodePosition + 6);
|
|
4715
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 7);
|
|
4716
|
+
return buffer;
|
|
4717
|
+
},
|
|
4718
|
+
FunctionExpression: (node, buffer) => {
|
|
4719
|
+
const nodePosition = buffer.position;
|
|
4720
|
+
buffer = buffer.reserve(9);
|
|
4721
|
+
buffer[nodePosition] = 33;
|
|
4722
|
+
buffer[nodePosition + 1] = node.start;
|
|
4723
|
+
buffer[nodePosition + 2] = node.end;
|
|
4724
|
+
buffer[nodePosition + 3] = (node.async << 0) | (node.generator << 1);
|
|
4725
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 4);
|
|
4726
|
+
if (node.id != null)
|
|
4727
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 5);
|
|
4728
|
+
buffer = serializeNodeList('params', node, buffer, nodePosition + 6);
|
|
4729
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 7);
|
|
4730
|
+
return buffer;
|
|
4731
|
+
},
|
|
4732
|
+
Identifier: (node, buffer) => {
|
|
4733
|
+
const nodePosition = buffer.position;
|
|
4734
|
+
buffer = buffer.reserve(4);
|
|
4735
|
+
buffer[nodePosition] = 34;
|
|
4736
|
+
buffer[nodePosition + 1] = node.start;
|
|
4737
|
+
buffer[nodePosition + 2] = node.end;
|
|
4738
|
+
buffer = buffer.addStringToBuffer(node.name, nodePosition + 3);
|
|
4739
|
+
return buffer;
|
|
4740
|
+
},
|
|
4741
|
+
IfStatement: (node, buffer) => {
|
|
4742
|
+
const nodePosition = buffer.position;
|
|
4743
|
+
buffer = buffer.reserve(6);
|
|
4744
|
+
buffer[nodePosition] = 35;
|
|
4745
|
+
buffer[nodePosition + 1] = node.start;
|
|
4746
|
+
buffer[nodePosition + 2] = node.end;
|
|
4747
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
4748
|
+
buffer = serializeNode('consequent', node, buffer, nodePosition + 4);
|
|
4749
|
+
if (node.alternate != null)
|
|
4750
|
+
buffer = serializeNode('alternate', node, buffer, nodePosition + 5);
|
|
4751
|
+
return buffer;
|
|
4752
|
+
},
|
|
4753
|
+
ImportAttribute: (node, buffer) => {
|
|
4754
|
+
const nodePosition = buffer.position;
|
|
4755
|
+
buffer = buffer.reserve(5);
|
|
4756
|
+
buffer[nodePosition] = 36;
|
|
4757
|
+
buffer[nodePosition + 1] = node.start;
|
|
4758
|
+
buffer[nodePosition + 2] = node.end;
|
|
4759
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 3);
|
|
4760
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 4);
|
|
4761
|
+
return buffer;
|
|
4762
|
+
},
|
|
4763
|
+
ImportDeclaration: (node, buffer) => {
|
|
4764
|
+
const nodePosition = buffer.position;
|
|
4765
|
+
buffer = buffer.reserve(7);
|
|
4766
|
+
buffer[nodePosition] = 37;
|
|
4767
|
+
buffer[nodePosition + 1] = node.start;
|
|
4768
|
+
buffer[nodePosition + 2] = node.end;
|
|
4769
|
+
buffer = serializeNodeList('specifiers', node, buffer, nodePosition + 3);
|
|
4770
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 4);
|
|
4771
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4772
|
+
if (node.phase != null) {
|
|
4773
|
+
buffer[nodePosition + 6] = FIXED_STRING_INDICES[node.phase];
|
|
4774
|
+
}
|
|
4775
|
+
return buffer;
|
|
4776
|
+
},
|
|
4777
|
+
ImportDefaultSpecifier: (node, buffer) => {
|
|
4778
|
+
const nodePosition = buffer.position;
|
|
4779
|
+
buffer = buffer.reserve(4);
|
|
4780
|
+
buffer[nodePosition] = 38;
|
|
4781
|
+
buffer[nodePosition + 1] = node.start;
|
|
4782
|
+
buffer[nodePosition + 2] = node.end;
|
|
4783
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 3);
|
|
4784
|
+
return buffer;
|
|
4785
|
+
},
|
|
4786
|
+
ImportExpression: (node, buffer) => {
|
|
4787
|
+
const nodePosition = buffer.position;
|
|
4788
|
+
buffer = buffer.reserve(6);
|
|
4789
|
+
buffer[nodePosition] = 39;
|
|
4790
|
+
buffer[nodePosition + 1] = node.start;
|
|
4791
|
+
buffer[nodePosition + 2] = node.end;
|
|
4792
|
+
buffer = serializeNode('source', node, buffer, nodePosition + 3);
|
|
4793
|
+
if (node.options != null)
|
|
4794
|
+
buffer = serializeNode('options', node, buffer, nodePosition + 4);
|
|
4795
|
+
if (node.phase != null) {
|
|
4796
|
+
buffer[nodePosition + 5] = FIXED_STRING_INDICES[node.phase];
|
|
4797
|
+
}
|
|
4798
|
+
return buffer;
|
|
4799
|
+
},
|
|
4800
|
+
ImportNamespaceSpecifier: (node, buffer) => {
|
|
4801
|
+
const nodePosition = buffer.position;
|
|
4802
|
+
buffer = buffer.reserve(4);
|
|
4803
|
+
buffer[nodePosition] = 40;
|
|
4804
|
+
buffer[nodePosition + 1] = node.start;
|
|
4805
|
+
buffer[nodePosition + 2] = node.end;
|
|
4806
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 3);
|
|
4807
|
+
return buffer;
|
|
4808
|
+
},
|
|
4809
|
+
ImportSpecifier: (node, buffer) => {
|
|
4810
|
+
const nodePosition = buffer.position;
|
|
4811
|
+
buffer = buffer.reserve(5);
|
|
4812
|
+
buffer[nodePosition] = 41;
|
|
4813
|
+
buffer[nodePosition + 1] = node.start;
|
|
4814
|
+
buffer[nodePosition + 2] = node.end;
|
|
4815
|
+
if (node.imported.end != node.local.end)
|
|
4816
|
+
buffer = serializeNode('imported', node, buffer, nodePosition + 3);
|
|
4817
|
+
buffer = serializeNode('local', node, buffer, nodePosition + 4);
|
|
4818
|
+
return buffer;
|
|
4819
|
+
},
|
|
4820
|
+
JSXAttribute: (node, buffer) => {
|
|
4821
|
+
const nodePosition = buffer.position;
|
|
4822
|
+
buffer = buffer.reserve(5);
|
|
4823
|
+
buffer[nodePosition] = 42;
|
|
4824
|
+
buffer[nodePosition + 1] = node.start;
|
|
4825
|
+
buffer[nodePosition + 2] = node.end;
|
|
4826
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 3);
|
|
4827
|
+
if (node.value != null)
|
|
4828
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 4);
|
|
4829
|
+
return buffer;
|
|
4830
|
+
},
|
|
4831
|
+
JSXClosingElement: (node, buffer) => {
|
|
4832
|
+
const nodePosition = buffer.position;
|
|
4833
|
+
buffer = buffer.reserve(4);
|
|
4834
|
+
buffer[nodePosition] = 43;
|
|
4835
|
+
buffer[nodePosition + 1] = node.start;
|
|
4836
|
+
buffer[nodePosition + 2] = node.end;
|
|
4837
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 3);
|
|
4838
|
+
return buffer;
|
|
4839
|
+
},
|
|
4840
|
+
JSXClosingFragment: (node, buffer) => {
|
|
4841
|
+
const nodePosition = buffer.position;
|
|
4842
|
+
buffer = buffer.reserve(3);
|
|
4843
|
+
buffer[nodePosition] = 44;
|
|
4844
|
+
buffer[nodePosition + 1] = node.start;
|
|
4845
|
+
buffer[nodePosition + 2] = node.end;
|
|
4846
|
+
return buffer;
|
|
4847
|
+
},
|
|
4848
|
+
JSXElement: (node, buffer) => {
|
|
4849
|
+
const nodePosition = buffer.position;
|
|
4850
|
+
buffer = buffer.reserve(6);
|
|
4851
|
+
buffer[nodePosition] = 45;
|
|
4852
|
+
buffer[nodePosition + 1] = node.start;
|
|
4853
|
+
buffer[nodePosition + 2] = node.end;
|
|
4854
|
+
buffer = serializeNode('openingElement', node, buffer, nodePosition + 3);
|
|
4855
|
+
buffer = serializeNodeList('children', node, buffer, nodePosition + 4);
|
|
4856
|
+
if (node.closingElement != null)
|
|
4857
|
+
buffer = serializeNode('closingElement', node, buffer, nodePosition + 5);
|
|
4858
|
+
return buffer;
|
|
4859
|
+
},
|
|
4860
|
+
JSXEmptyExpression: (node, buffer) => {
|
|
4861
|
+
const nodePosition = buffer.position;
|
|
4862
|
+
buffer = buffer.reserve(3);
|
|
4863
|
+
buffer[nodePosition] = 46;
|
|
4864
|
+
buffer[nodePosition + 1] = node.start;
|
|
4865
|
+
buffer[nodePosition + 2] = node.end;
|
|
4866
|
+
return buffer;
|
|
4867
|
+
},
|
|
4868
|
+
JSXExpressionContainer: (node, buffer) => {
|
|
4869
|
+
const nodePosition = buffer.position;
|
|
4870
|
+
buffer = buffer.reserve(4);
|
|
4871
|
+
buffer[nodePosition] = 47;
|
|
4872
|
+
buffer[nodePosition + 1] = node.start;
|
|
4873
|
+
buffer[nodePosition + 2] = node.end;
|
|
4874
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4875
|
+
return buffer;
|
|
4876
|
+
},
|
|
4877
|
+
JSXFragment: (node, buffer) => {
|
|
4878
|
+
const nodePosition = buffer.position;
|
|
4879
|
+
buffer = buffer.reserve(6);
|
|
4880
|
+
buffer[nodePosition] = 48;
|
|
4881
|
+
buffer[nodePosition + 1] = node.start;
|
|
4882
|
+
buffer[nodePosition + 2] = node.end;
|
|
4883
|
+
buffer = serializeNode('openingFragment', node, buffer, nodePosition + 3);
|
|
4884
|
+
buffer = serializeNodeList('children', node, buffer, nodePosition + 4);
|
|
4885
|
+
buffer = serializeNode('closingFragment', node, buffer, nodePosition + 5);
|
|
4886
|
+
return buffer;
|
|
4887
|
+
},
|
|
4888
|
+
JSXIdentifier: (node, buffer) => {
|
|
4889
|
+
const nodePosition = buffer.position;
|
|
4890
|
+
buffer = buffer.reserve(4);
|
|
4891
|
+
buffer[nodePosition] = 49;
|
|
4892
|
+
buffer[nodePosition + 1] = node.start;
|
|
4893
|
+
buffer[nodePosition + 2] = node.end;
|
|
4894
|
+
buffer = buffer.addStringToBuffer(node.name, nodePosition + 3);
|
|
4895
|
+
return buffer;
|
|
4896
|
+
},
|
|
4897
|
+
JSXMemberExpression: (node, buffer) => {
|
|
4898
|
+
const nodePosition = buffer.position;
|
|
4899
|
+
buffer = buffer.reserve(5);
|
|
4900
|
+
buffer[nodePosition] = 50;
|
|
4901
|
+
buffer[nodePosition + 1] = node.start;
|
|
4902
|
+
buffer[nodePosition + 2] = node.end;
|
|
4903
|
+
buffer = serializeNode('object', node, buffer, nodePosition + 3);
|
|
4904
|
+
buffer = serializeNode('property', node, buffer, nodePosition + 4);
|
|
4905
|
+
return buffer;
|
|
4906
|
+
},
|
|
4907
|
+
JSXNamespacedName: (node, buffer) => {
|
|
4908
|
+
const nodePosition = buffer.position;
|
|
4909
|
+
buffer = buffer.reserve(5);
|
|
4910
|
+
buffer[nodePosition] = 51;
|
|
4911
|
+
buffer[nodePosition + 1] = node.start;
|
|
4912
|
+
buffer[nodePosition + 2] = node.end;
|
|
4913
|
+
buffer = serializeNode('namespace', node, buffer, nodePosition + 3);
|
|
4914
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 4);
|
|
4915
|
+
return buffer;
|
|
4916
|
+
},
|
|
4917
|
+
JSXOpeningElement: (node, buffer) => {
|
|
4918
|
+
const nodePosition = buffer.position;
|
|
4919
|
+
buffer = buffer.reserve(6);
|
|
4920
|
+
buffer[nodePosition] = 52;
|
|
4921
|
+
buffer[nodePosition + 1] = node.start;
|
|
4922
|
+
buffer[nodePosition + 2] = node.end;
|
|
4923
|
+
buffer[nodePosition + 3] = node.selfClosing << 0;
|
|
4924
|
+
buffer = serializeNode('name', node, buffer, nodePosition + 4);
|
|
4925
|
+
buffer = serializeNodeList('attributes', node, buffer, nodePosition + 5);
|
|
4926
|
+
return buffer;
|
|
4927
|
+
},
|
|
4928
|
+
JSXOpeningFragment: (node, buffer) => {
|
|
4929
|
+
const nodePosition = buffer.position;
|
|
4930
|
+
buffer = buffer.reserve(3);
|
|
4931
|
+
buffer[nodePosition] = 53;
|
|
4932
|
+
buffer[nodePosition + 1] = node.start;
|
|
4933
|
+
buffer[nodePosition + 2] = node.end;
|
|
4934
|
+
return buffer;
|
|
4935
|
+
},
|
|
4936
|
+
JSXSpreadAttribute: (node, buffer) => {
|
|
4937
|
+
const nodePosition = buffer.position;
|
|
4938
|
+
buffer = buffer.reserve(4);
|
|
4939
|
+
buffer[nodePosition] = 54;
|
|
4940
|
+
buffer[nodePosition + 1] = node.start;
|
|
4941
|
+
buffer[nodePosition + 2] = node.end;
|
|
4942
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
4943
|
+
return buffer;
|
|
4944
|
+
},
|
|
4945
|
+
JSXSpreadChild: (node, buffer) => {
|
|
4946
|
+
const nodePosition = buffer.position;
|
|
4947
|
+
buffer = buffer.reserve(4);
|
|
4948
|
+
buffer[nodePosition] = 55;
|
|
4949
|
+
buffer[nodePosition + 1] = node.start;
|
|
4950
|
+
buffer[nodePosition + 2] = node.end;
|
|
4951
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
4952
|
+
return buffer;
|
|
4953
|
+
},
|
|
4954
|
+
JSXText: (node, buffer) => {
|
|
4955
|
+
const nodePosition = buffer.position;
|
|
4956
|
+
buffer = buffer.reserve(5);
|
|
4957
|
+
buffer[nodePosition] = 56;
|
|
4958
|
+
buffer[nodePosition + 1] = node.start;
|
|
4959
|
+
buffer[nodePosition + 2] = node.end;
|
|
4960
|
+
buffer = buffer.addStringToBuffer(node.value, nodePosition + 3);
|
|
4961
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 4);
|
|
4962
|
+
return buffer;
|
|
4963
|
+
},
|
|
4964
|
+
LabeledStatement: (node, buffer) => {
|
|
4965
|
+
const nodePosition = buffer.position;
|
|
4966
|
+
buffer = buffer.reserve(5);
|
|
4967
|
+
buffer[nodePosition] = 57;
|
|
4968
|
+
buffer[nodePosition + 1] = node.start;
|
|
4969
|
+
buffer[nodePosition + 2] = node.end;
|
|
4970
|
+
buffer = serializeNode('label', node, buffer, nodePosition + 3);
|
|
4971
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 4);
|
|
4972
|
+
return buffer;
|
|
4973
|
+
},
|
|
4974
|
+
Literal: serializeLiteralNode,
|
|
4975
|
+
LogicalExpression: (node, buffer) => {
|
|
4976
|
+
const nodePosition = buffer.position;
|
|
4977
|
+
buffer = buffer.reserve(6);
|
|
4978
|
+
buffer[nodePosition] = 64;
|
|
4979
|
+
buffer[nodePosition + 1] = node.start;
|
|
4980
|
+
buffer[nodePosition + 2] = node.end;
|
|
4981
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
4982
|
+
buffer = serializeNode('left', node, buffer, nodePosition + 4);
|
|
4983
|
+
buffer = serializeNode('right', node, buffer, nodePosition + 5);
|
|
4984
|
+
return buffer;
|
|
4985
|
+
},
|
|
4986
|
+
MemberExpression: (node, buffer) => {
|
|
4987
|
+
const nodePosition = buffer.position;
|
|
4988
|
+
buffer = buffer.reserve(6);
|
|
4989
|
+
buffer[nodePosition] = 65;
|
|
4990
|
+
buffer[nodePosition + 1] = node.start;
|
|
4991
|
+
buffer[nodePosition + 2] = node.end;
|
|
4992
|
+
buffer[nodePosition + 3] = (node.computed << 0) | (node.optional << 1);
|
|
4993
|
+
buffer = serializeNode('object', node, buffer, nodePosition + 4);
|
|
4994
|
+
buffer = serializeNode('property', node, buffer, nodePosition + 5);
|
|
4995
|
+
return buffer;
|
|
4996
|
+
},
|
|
4997
|
+
MetaProperty: (node, buffer) => {
|
|
4998
|
+
const nodePosition = buffer.position;
|
|
4999
|
+
buffer = buffer.reserve(5);
|
|
5000
|
+
buffer[nodePosition] = 66;
|
|
5001
|
+
buffer[nodePosition + 1] = node.start;
|
|
5002
|
+
buffer[nodePosition + 2] = node.end;
|
|
5003
|
+
buffer = serializeNode('meta', node, buffer, nodePosition + 3);
|
|
5004
|
+
buffer = serializeNode('property', node, buffer, nodePosition + 4);
|
|
5005
|
+
return buffer;
|
|
5006
|
+
},
|
|
5007
|
+
MethodDefinition: (node, buffer) => {
|
|
5008
|
+
const nodePosition = buffer.position;
|
|
5009
|
+
buffer = buffer.reserve(8);
|
|
5010
|
+
buffer[nodePosition] = 67;
|
|
5011
|
+
buffer[nodePosition + 1] = node.start;
|
|
5012
|
+
buffer[nodePosition + 2] = node.end;
|
|
5013
|
+
buffer[nodePosition + 3] = (node.static << 0) | (node.computed << 1);
|
|
5014
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 4);
|
|
5015
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 5);
|
|
5016
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 6);
|
|
5017
|
+
buffer[nodePosition + 7] = FIXED_STRING_INDICES[node.kind];
|
|
5018
|
+
return buffer;
|
|
5019
|
+
},
|
|
5020
|
+
NewExpression: (node, buffer) => {
|
|
5021
|
+
const nodePosition = buffer.position;
|
|
5022
|
+
buffer = buffer.reserve(6);
|
|
5023
|
+
buffer[nodePosition] = 68;
|
|
5024
|
+
buffer[nodePosition + 1] = node.start;
|
|
5025
|
+
buffer[nodePosition + 2] = node.end;
|
|
5026
|
+
buffer = serializeAnnotations(node.annotations, buffer, nodePosition + 3);
|
|
5027
|
+
buffer = serializeNode('callee', node, buffer, nodePosition + 4);
|
|
5028
|
+
buffer = serializeNodeList('arguments', node, buffer, nodePosition + 5);
|
|
5029
|
+
return buffer;
|
|
5030
|
+
},
|
|
5031
|
+
ObjectExpression: (node, buffer) => {
|
|
5032
|
+
const nodePosition = buffer.position;
|
|
5033
|
+
buffer = buffer.reserve(4);
|
|
5034
|
+
buffer[nodePosition] = 69;
|
|
5035
|
+
buffer[nodePosition + 1] = node.start;
|
|
5036
|
+
buffer[nodePosition + 2] = node.end;
|
|
5037
|
+
buffer = serializeNodeList('properties', node, buffer, nodePosition + 3);
|
|
5038
|
+
return buffer;
|
|
5039
|
+
},
|
|
5040
|
+
ObjectPattern: (node, buffer) => {
|
|
5041
|
+
const nodePosition = buffer.position;
|
|
5042
|
+
buffer = buffer.reserve(4);
|
|
5043
|
+
buffer[nodePosition] = 70;
|
|
5044
|
+
buffer[nodePosition + 1] = node.start;
|
|
5045
|
+
buffer[nodePosition + 2] = node.end;
|
|
5046
|
+
buffer = serializeNodeList('properties', node, buffer, nodePosition + 3);
|
|
5047
|
+
return buffer;
|
|
5048
|
+
},
|
|
5049
|
+
PanicError: (node, buffer) => {
|
|
5050
|
+
const nodePosition = buffer.position;
|
|
5051
|
+
buffer = buffer.reserve(4);
|
|
5052
|
+
buffer[nodePosition] = 0;
|
|
5053
|
+
buffer[nodePosition + 1] = node.start;
|
|
5054
|
+
buffer[nodePosition + 2] = node.end;
|
|
5055
|
+
buffer = buffer.addStringToBuffer(node.message, nodePosition + 3);
|
|
5056
|
+
return buffer;
|
|
5057
|
+
},
|
|
5058
|
+
ParseError: (node, buffer) => {
|
|
5059
|
+
const nodePosition = buffer.position;
|
|
5060
|
+
buffer = buffer.reserve(4);
|
|
5061
|
+
buffer[nodePosition] = 1;
|
|
5062
|
+
buffer[nodePosition + 1] = node.start;
|
|
5063
|
+
buffer[nodePosition + 2] = node.end;
|
|
5064
|
+
buffer = buffer.addStringToBuffer(node.message, nodePosition + 3);
|
|
5065
|
+
return buffer;
|
|
5066
|
+
},
|
|
5067
|
+
PrivateIdentifier: (node, buffer) => {
|
|
5068
|
+
const nodePosition = buffer.position;
|
|
5069
|
+
buffer = buffer.reserve(4);
|
|
5070
|
+
buffer[nodePosition] = 71;
|
|
5071
|
+
buffer[nodePosition + 1] = node.start;
|
|
5072
|
+
buffer[nodePosition + 2] = node.end;
|
|
5073
|
+
buffer = buffer.addStringToBuffer(node.name, nodePosition + 3);
|
|
5074
|
+
return buffer;
|
|
5075
|
+
},
|
|
5076
|
+
Program: (node, buffer) => {
|
|
5077
|
+
const nodePosition = buffer.position;
|
|
5078
|
+
buffer = buffer.reserve(6);
|
|
5079
|
+
buffer[nodePosition] = 72;
|
|
5080
|
+
buffer[nodePosition + 1] = node.start;
|
|
5081
|
+
buffer[nodePosition + 2] = node.end;
|
|
5082
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
5083
|
+
buffer = serializeAnnotations(node.invalidAnnotations, buffer, nodePosition + 4);
|
|
5084
|
+
return buffer;
|
|
5085
|
+
},
|
|
5086
|
+
Property: (node, buffer) => {
|
|
5087
|
+
const nodePosition = buffer.position;
|
|
5088
|
+
buffer = buffer.reserve(7);
|
|
5089
|
+
buffer[nodePosition] = 73;
|
|
5090
|
+
buffer[nodePosition + 1] = node.start;
|
|
5091
|
+
buffer[nodePosition + 2] = node.end;
|
|
5092
|
+
buffer[nodePosition + 3] =
|
|
5093
|
+
(node.method << 0) | (node.shorthand << 1) | (node.computed << 2);
|
|
5094
|
+
if (node.key.end != node.value.end)
|
|
5095
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 4);
|
|
5096
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 5);
|
|
5097
|
+
buffer[nodePosition + 6] = FIXED_STRING_INDICES[node.kind];
|
|
5098
|
+
return buffer;
|
|
5099
|
+
},
|
|
5100
|
+
PropertyDefinition: (node, buffer) => {
|
|
5101
|
+
const nodePosition = buffer.position;
|
|
5102
|
+
buffer = buffer.reserve(7);
|
|
5103
|
+
buffer[nodePosition] = 74;
|
|
5104
|
+
buffer[nodePosition + 1] = node.start;
|
|
5105
|
+
buffer[nodePosition + 2] = node.end;
|
|
5106
|
+
buffer[nodePosition + 3] = (node.static << 0) | (node.computed << 1);
|
|
5107
|
+
buffer = serializeNodeList('decorators', node, buffer, nodePosition + 4);
|
|
5108
|
+
buffer = serializeNode('key', node, buffer, nodePosition + 5);
|
|
5109
|
+
if (node.value != null)
|
|
5110
|
+
buffer = serializeNode('value', node, buffer, nodePosition + 6);
|
|
5111
|
+
return buffer;
|
|
5112
|
+
},
|
|
5113
|
+
RestElement: (node, buffer) => {
|
|
5114
|
+
const nodePosition = buffer.position;
|
|
5115
|
+
buffer = buffer.reserve(4);
|
|
5116
|
+
buffer[nodePosition] = 75;
|
|
5117
|
+
buffer[nodePosition + 1] = node.start;
|
|
5118
|
+
buffer[nodePosition + 2] = node.end;
|
|
5119
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
5120
|
+
return buffer;
|
|
5121
|
+
},
|
|
5122
|
+
ReturnStatement: (node, buffer) => {
|
|
5123
|
+
const nodePosition = buffer.position;
|
|
5124
|
+
buffer = buffer.reserve(4);
|
|
5125
|
+
buffer[nodePosition] = 76;
|
|
5126
|
+
buffer[nodePosition + 1] = node.start;
|
|
5127
|
+
buffer[nodePosition + 2] = node.end;
|
|
5128
|
+
if (node.argument != null)
|
|
5129
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
5130
|
+
return buffer;
|
|
5131
|
+
},
|
|
5132
|
+
SequenceExpression: (node, buffer) => {
|
|
5133
|
+
const nodePosition = buffer.position;
|
|
5134
|
+
buffer = buffer.reserve(4);
|
|
5135
|
+
buffer[nodePosition] = 77;
|
|
5136
|
+
buffer[nodePosition + 1] = node.start;
|
|
5137
|
+
buffer[nodePosition + 2] = node.end;
|
|
5138
|
+
buffer = serializeNodeList('expressions', node, buffer, nodePosition + 3);
|
|
5139
|
+
return buffer;
|
|
5140
|
+
},
|
|
5141
|
+
SpreadElement: (node, buffer) => {
|
|
5142
|
+
const nodePosition = buffer.position;
|
|
5143
|
+
buffer = buffer.reserve(4);
|
|
5144
|
+
buffer[nodePosition] = 78;
|
|
5145
|
+
buffer[nodePosition + 1] = node.start;
|
|
5146
|
+
buffer[nodePosition + 2] = node.end;
|
|
5147
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
5148
|
+
return buffer;
|
|
5149
|
+
},
|
|
5150
|
+
StaticBlock: (node, buffer) => {
|
|
5151
|
+
const nodePosition = buffer.position;
|
|
5152
|
+
buffer = buffer.reserve(5);
|
|
5153
|
+
buffer[nodePosition] = 79;
|
|
5154
|
+
buffer[nodePosition + 1] = node.start;
|
|
5155
|
+
buffer[nodePosition + 2] = node.end;
|
|
5156
|
+
buffer = serializeNodeList('body', node, buffer, nodePosition + 3);
|
|
5157
|
+
return buffer;
|
|
5158
|
+
},
|
|
5159
|
+
Super: (node, buffer) => {
|
|
5160
|
+
const nodePosition = buffer.position;
|
|
5161
|
+
buffer = buffer.reserve(3);
|
|
5162
|
+
buffer[nodePosition] = 80;
|
|
5163
|
+
buffer[nodePosition + 1] = node.start;
|
|
5164
|
+
buffer[nodePosition + 2] = node.end;
|
|
5165
|
+
return buffer;
|
|
5166
|
+
},
|
|
5167
|
+
SwitchCase: (node, buffer) => {
|
|
5168
|
+
const nodePosition = buffer.position;
|
|
5169
|
+
buffer = buffer.reserve(5);
|
|
5170
|
+
buffer[nodePosition] = 81;
|
|
5171
|
+
buffer[nodePosition + 1] = node.start;
|
|
5172
|
+
buffer[nodePosition + 2] = node.end;
|
|
5173
|
+
if (node.test != null)
|
|
5174
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
5175
|
+
buffer = serializeNodeList('consequent', node, buffer, nodePosition + 4);
|
|
5176
|
+
return buffer;
|
|
5177
|
+
},
|
|
5178
|
+
SwitchStatement: (node, buffer) => {
|
|
5179
|
+
const nodePosition = buffer.position;
|
|
5180
|
+
buffer = buffer.reserve(6);
|
|
5181
|
+
buffer[nodePosition] = 82;
|
|
5182
|
+
buffer[nodePosition + 1] = node.start;
|
|
5183
|
+
buffer[nodePosition + 2] = node.end;
|
|
5184
|
+
buffer = serializeNode('discriminant', node, buffer, nodePosition + 3);
|
|
5185
|
+
buffer = serializeNodeList('cases', node, buffer, nodePosition + 4);
|
|
5186
|
+
return buffer;
|
|
5187
|
+
},
|
|
5188
|
+
TaggedTemplateExpression: (node, buffer) => {
|
|
5189
|
+
const nodePosition = buffer.position;
|
|
5190
|
+
buffer = buffer.reserve(5);
|
|
5191
|
+
buffer[nodePosition] = 83;
|
|
5192
|
+
buffer[nodePosition + 1] = node.start;
|
|
5193
|
+
buffer[nodePosition + 2] = node.end;
|
|
5194
|
+
buffer = serializeNode('tag', node, buffer, nodePosition + 3);
|
|
5195
|
+
buffer = serializeNode('quasi', node, buffer, nodePosition + 4);
|
|
5196
|
+
return buffer;
|
|
5197
|
+
},
|
|
5198
|
+
TemplateElement: (node, buffer) => {
|
|
5199
|
+
const nodePosition = buffer.position;
|
|
5200
|
+
buffer = buffer.reserve(6);
|
|
5201
|
+
buffer[nodePosition] = 84;
|
|
5202
|
+
buffer[nodePosition + 1] = node.start;
|
|
5203
|
+
buffer[nodePosition + 2] = node.end;
|
|
5204
|
+
buffer[nodePosition + 3] = node.tail << 0;
|
|
5205
|
+
if (node.value.cooked != null) {
|
|
5206
|
+
buffer = buffer.addStringToBuffer(node.value.cooked, nodePosition + 4);
|
|
5207
|
+
}
|
|
5208
|
+
buffer = buffer.addStringToBuffer(node.value.raw, nodePosition + 5);
|
|
5209
|
+
return buffer;
|
|
5210
|
+
},
|
|
5211
|
+
TemplateLiteral: (node, buffer) => {
|
|
5212
|
+
const nodePosition = buffer.position;
|
|
5213
|
+
buffer = buffer.reserve(5);
|
|
5214
|
+
buffer[nodePosition] = 85;
|
|
5215
|
+
buffer[nodePosition + 1] = node.start;
|
|
5216
|
+
buffer[nodePosition + 2] = node.end;
|
|
5217
|
+
buffer = serializeNodeList('quasis', node, buffer, nodePosition + 3);
|
|
5218
|
+
buffer = serializeNodeList('expressions', node, buffer, nodePosition + 4);
|
|
5219
|
+
return buffer;
|
|
5220
|
+
},
|
|
5221
|
+
ThisExpression: (node, buffer) => {
|
|
5222
|
+
const nodePosition = buffer.position;
|
|
5223
|
+
buffer = buffer.reserve(3);
|
|
5224
|
+
buffer[nodePosition] = 86;
|
|
5225
|
+
buffer[nodePosition + 1] = node.start;
|
|
5226
|
+
buffer[nodePosition + 2] = node.end;
|
|
5227
|
+
return buffer;
|
|
5228
|
+
},
|
|
5229
|
+
ThrowStatement: (node, buffer) => {
|
|
5230
|
+
const nodePosition = buffer.position;
|
|
5231
|
+
buffer = buffer.reserve(4);
|
|
5232
|
+
buffer[nodePosition] = 87;
|
|
5233
|
+
buffer[nodePosition + 1] = node.start;
|
|
5234
|
+
buffer[nodePosition + 2] = node.end;
|
|
5235
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 3);
|
|
5236
|
+
return buffer;
|
|
5237
|
+
},
|
|
5238
|
+
TryStatement: (node, buffer) => {
|
|
5239
|
+
const nodePosition = buffer.position;
|
|
5240
|
+
buffer = buffer.reserve(6);
|
|
5241
|
+
buffer[nodePosition] = 88;
|
|
5242
|
+
buffer[nodePosition + 1] = node.start;
|
|
5243
|
+
buffer[nodePosition + 2] = node.end;
|
|
5244
|
+
buffer = serializeNode('block', node, buffer, nodePosition + 3);
|
|
5245
|
+
if (node.handler != null)
|
|
5246
|
+
buffer = serializeNode('handler', node, buffer, nodePosition + 4);
|
|
5247
|
+
if (node.finalizer != null)
|
|
5248
|
+
buffer = serializeNode('finalizer', node, buffer, nodePosition + 5);
|
|
5249
|
+
return buffer;
|
|
5250
|
+
},
|
|
5251
|
+
UnaryExpression: (node, buffer) => {
|
|
5252
|
+
const nodePosition = buffer.position;
|
|
5253
|
+
buffer = buffer.reserve(5);
|
|
5254
|
+
buffer[nodePosition] = 89;
|
|
5255
|
+
buffer[nodePosition + 1] = node.start;
|
|
5256
|
+
buffer[nodePosition + 2] = node.end;
|
|
5257
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.operator];
|
|
5258
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 4);
|
|
5259
|
+
return buffer;
|
|
5260
|
+
},
|
|
5261
|
+
UpdateExpression: (node, buffer) => {
|
|
5262
|
+
const nodePosition = buffer.position;
|
|
5263
|
+
buffer = buffer.reserve(6);
|
|
5264
|
+
buffer[nodePosition] = 90;
|
|
5265
|
+
buffer[nodePosition + 1] = node.start;
|
|
5266
|
+
buffer[nodePosition + 2] = node.end;
|
|
5267
|
+
buffer[nodePosition + 3] = node.prefix << 0;
|
|
5268
|
+
buffer[nodePosition + 4] = FIXED_STRING_INDICES[node.operator];
|
|
5269
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 5);
|
|
5270
|
+
return buffer;
|
|
5271
|
+
},
|
|
5272
|
+
VariableDeclaration: (node, buffer) => {
|
|
5273
|
+
const nodePosition = buffer.position;
|
|
5274
|
+
buffer = buffer.reserve(5);
|
|
5275
|
+
buffer[nodePosition] = 91;
|
|
5276
|
+
buffer[nodePosition + 1] = node.start;
|
|
5277
|
+
buffer[nodePosition + 2] = node.end;
|
|
5278
|
+
buffer[nodePosition + 3] = FIXED_STRING_INDICES[node.kind];
|
|
5279
|
+
buffer = serializeNodeList('declarations', node, buffer, nodePosition + 4);
|
|
5280
|
+
return buffer;
|
|
5281
|
+
},
|
|
5282
|
+
VariableDeclarator: (node, buffer) => {
|
|
5283
|
+
const nodePosition = buffer.position;
|
|
5284
|
+
buffer = buffer.reserve(5);
|
|
5285
|
+
buffer[nodePosition] = 92;
|
|
5286
|
+
buffer[nodePosition + 1] = node.start;
|
|
5287
|
+
buffer[nodePosition + 2] = node.end;
|
|
5288
|
+
buffer = serializeNode('id', node, buffer, nodePosition + 3);
|
|
5289
|
+
if (node.init != null)
|
|
5290
|
+
buffer = serializeNode('init', node, buffer, nodePosition + 4);
|
|
5291
|
+
return buffer;
|
|
5292
|
+
},
|
|
5293
|
+
WhileStatement: (node, buffer) => {
|
|
5294
|
+
const nodePosition = buffer.position;
|
|
5295
|
+
buffer = buffer.reserve(5);
|
|
5296
|
+
buffer[nodePosition] = 93;
|
|
5297
|
+
buffer[nodePosition + 1] = node.start;
|
|
5298
|
+
buffer[nodePosition + 2] = node.end;
|
|
5299
|
+
buffer = serializeNode('test', node, buffer, nodePosition + 3);
|
|
5300
|
+
buffer = serializeNode('body', node, buffer, nodePosition + 4);
|
|
5301
|
+
return buffer;
|
|
5302
|
+
},
|
|
5303
|
+
YieldExpression: (node, buffer) => {
|
|
5304
|
+
const nodePosition = buffer.position;
|
|
5305
|
+
buffer = buffer.reserve(5);
|
|
5306
|
+
buffer[nodePosition] = 94;
|
|
5307
|
+
buffer[nodePosition + 1] = node.start;
|
|
5308
|
+
buffer[nodePosition + 2] = node.end;
|
|
5309
|
+
buffer[nodePosition + 3] = node.delegate << 0;
|
|
5310
|
+
if (node.argument != null)
|
|
5311
|
+
buffer = serializeNode('argument', node, buffer, nodePosition + 4);
|
|
5312
|
+
return buffer;
|
|
2182
5313
|
}
|
|
2183
|
-
|
|
5314
|
+
};
|
|
5315
|
+
const serializeDirective = (node, buffer) => {
|
|
5316
|
+
const nodePosition = buffer.position;
|
|
5317
|
+
buffer = buffer.reserve(5);
|
|
5318
|
+
buffer[nodePosition] = 21;
|
|
5319
|
+
buffer[nodePosition + 1] = node.start;
|
|
5320
|
+
buffer[nodePosition + 2] = node.end;
|
|
5321
|
+
buffer = buffer.addStringToBuffer(node.directive, nodePosition + 3);
|
|
5322
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 4);
|
|
5323
|
+
return buffer;
|
|
5324
|
+
};
|
|
5325
|
+
const serializeExpressionStatement = (node, buffer) => {
|
|
5326
|
+
const nodePosition = buffer.position;
|
|
5327
|
+
buffer = buffer.reserve(4);
|
|
5328
|
+
buffer[nodePosition] = 28;
|
|
5329
|
+
buffer[nodePosition + 1] = node.start;
|
|
5330
|
+
buffer[nodePosition + 2] = node.end;
|
|
5331
|
+
buffer = serializeNode('expression', node, buffer, nodePosition + 3);
|
|
5332
|
+
return buffer;
|
|
5333
|
+
};
|
|
5334
|
+
const serializeLiteralBigInt = (node, buffer) => {
|
|
5335
|
+
const nodePosition = buffer.position;
|
|
5336
|
+
buffer = buffer.reserve(5);
|
|
5337
|
+
buffer[nodePosition] = 58;
|
|
5338
|
+
buffer[nodePosition + 1] = node.start;
|
|
5339
|
+
buffer[nodePosition + 2] = node.end;
|
|
5340
|
+
buffer = buffer.addStringToBuffer(node.bigint, nodePosition + 3);
|
|
5341
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 4);
|
|
5342
|
+
return buffer;
|
|
5343
|
+
};
|
|
5344
|
+
const serializeLiteralBoolean = (node, buffer) => {
|
|
5345
|
+
const nodePosition = buffer.position;
|
|
5346
|
+
buffer = buffer.reserve(4);
|
|
5347
|
+
buffer[nodePosition] = 59;
|
|
5348
|
+
buffer[nodePosition + 1] = node.start;
|
|
5349
|
+
buffer[nodePosition + 2] = node.end;
|
|
5350
|
+
buffer[nodePosition + 3] = node.value << 0;
|
|
5351
|
+
return buffer;
|
|
5352
|
+
};
|
|
5353
|
+
const serializeLiteralNull = (node, buffer) => {
|
|
5354
|
+
const nodePosition = buffer.position;
|
|
5355
|
+
buffer = buffer.reserve(3);
|
|
5356
|
+
buffer[nodePosition] = 60;
|
|
5357
|
+
buffer[nodePosition + 1] = node.start;
|
|
5358
|
+
buffer[nodePosition + 2] = node.end;
|
|
5359
|
+
return buffer;
|
|
5360
|
+
};
|
|
5361
|
+
const serializeLiteralNumber = (node, buffer) => {
|
|
5362
|
+
const nodePosition = buffer.position;
|
|
5363
|
+
buffer = buffer.reserve(6);
|
|
5364
|
+
buffer[nodePosition] = 61;
|
|
5365
|
+
buffer[nodePosition + 1] = node.start;
|
|
5366
|
+
buffer[nodePosition + 2] = node.end;
|
|
5367
|
+
if (node.raw != null) {
|
|
5368
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 3);
|
|
5369
|
+
}
|
|
5370
|
+
new DataView(buffer.buffer).setFloat64((nodePosition + 4) << 2, node.value, true);
|
|
5371
|
+
return buffer;
|
|
5372
|
+
};
|
|
5373
|
+
const serializeLiteralRegExp = (node, buffer) => {
|
|
5374
|
+
const nodePosition = buffer.position;
|
|
5375
|
+
buffer = buffer.reserve(5);
|
|
5376
|
+
buffer[nodePosition] = 62;
|
|
5377
|
+
buffer[nodePosition + 1] = node.start;
|
|
5378
|
+
buffer[nodePosition + 2] = node.end;
|
|
5379
|
+
buffer = buffer.addStringToBuffer(node.regex.flags, nodePosition + 3);
|
|
5380
|
+
buffer = buffer.addStringToBuffer(node.regex.pattern, nodePosition + 4);
|
|
5381
|
+
return buffer;
|
|
5382
|
+
};
|
|
5383
|
+
const serializeLiteralString = (node, buffer) => {
|
|
5384
|
+
const nodePosition = buffer.position;
|
|
5385
|
+
buffer = buffer.reserve(5);
|
|
5386
|
+
buffer[nodePosition] = 63;
|
|
5387
|
+
buffer[nodePosition + 1] = node.start;
|
|
5388
|
+
buffer[nodePosition + 2] = node.end;
|
|
5389
|
+
buffer = buffer.addStringToBuffer(node.value, nodePosition + 3);
|
|
5390
|
+
if (node.raw != null) {
|
|
5391
|
+
buffer = buffer.addStringToBuffer(node.raw, nodePosition + 4);
|
|
5392
|
+
}
|
|
5393
|
+
return buffer;
|
|
5394
|
+
};
|
|
5395
|
+
function serializeNode(field, parent, buffer, referencePosition) {
|
|
5396
|
+
buffer[referencePosition] = buffer.position;
|
|
5397
|
+
const node = parent[field];
|
|
5398
|
+
return (nodeSerializers[node.type] || error(logUnknownNodeType(node.type, parent.type, field)))(node, buffer);
|
|
5399
|
+
}
|
|
5400
|
+
function serializeNodeList(field, parent, buffer, referencePosition) {
|
|
5401
|
+
const nodes = parent[field];
|
|
5402
|
+
if (nodes == null) {
|
|
5403
|
+
return buffer;
|
|
5404
|
+
}
|
|
5405
|
+
const { length } = nodes;
|
|
5406
|
+
if (length === 0) {
|
|
5407
|
+
return buffer;
|
|
5408
|
+
}
|
|
5409
|
+
if (length == null) {
|
|
5410
|
+
return error(logExpectedNodeList(parent.type, field, parent[field]));
|
|
5411
|
+
}
|
|
5412
|
+
let insertPosition = buffer.position;
|
|
5413
|
+
buffer = buffer.reserve(length + 1);
|
|
5414
|
+
buffer[referencePosition] = insertPosition;
|
|
5415
|
+
buffer[insertPosition] = length;
|
|
5416
|
+
insertPosition++;
|
|
5417
|
+
for (let index = 0; index < length; index++) {
|
|
5418
|
+
const node = nodes[index];
|
|
5419
|
+
if (node != null) {
|
|
5420
|
+
buffer[insertPosition + index] = buffer.position;
|
|
5421
|
+
buffer = (nodeSerializers[node.type] || error(logUnknownNodeType(node.type, parent.type, field)))(node, buffer);
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
return buffer;
|
|
5425
|
+
}
|
|
5426
|
+
function serializeAnnotations(annotations, buffer, referencePosition) {
|
|
5427
|
+
if (!annotations?.length) {
|
|
5428
|
+
return buffer;
|
|
5429
|
+
}
|
|
5430
|
+
const { length } = annotations;
|
|
5431
|
+
let insertPosition = buffer.position;
|
|
5432
|
+
buffer = buffer.reserve(length + 1);
|
|
5433
|
+
buffer[referencePosition] = insertPosition;
|
|
5434
|
+
buffer[insertPosition] = length;
|
|
5435
|
+
insertPosition++;
|
|
5436
|
+
for (let index = 0; index < length; index++) {
|
|
5437
|
+
const annotation = annotations[index];
|
|
5438
|
+
const annotationPosition = buffer.position;
|
|
5439
|
+
buffer = buffer.reserve(3); // 3 for start, end, type
|
|
5440
|
+
buffer[insertPosition + index] = annotationPosition;
|
|
5441
|
+
buffer[annotationPosition] = annotation.start;
|
|
5442
|
+
buffer[annotationPosition + 1] = annotation.end;
|
|
5443
|
+
buffer[annotationPosition + 2] = FIXED_STRING_INDICES[annotation.type];
|
|
5444
|
+
}
|
|
5445
|
+
return buffer;
|
|
2184
5446
|
}
|
|
2185
5447
|
|
|
2186
|
-
const
|
|
2187
|
-
const
|
|
5448
|
+
const deserializeAst = (buffer, position = 0) => deserializeAstBuffer(getAstBuffer(buffer), position);
|
|
5449
|
+
const deserializeLazyAst = (buffer, position = 0) => deserializeLazyAstBuffer(getAstBuffer(buffer), position);
|
|
5450
|
+
const parseAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeAst(native_js.parse(input, allowReturnOutsideFunction, jsx));
|
|
5451
|
+
const parseAstAsync = async (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeAst(await native_js.parseAsync(input, allowReturnOutsideFunction, jsx));
|
|
5452
|
+
const parseLazyAst = (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeLazyAst(native_js.parse(input, allowReturnOutsideFunction, jsx));
|
|
5453
|
+
const parseLazyAstAsync = async (input, { allowReturnOutsideFunction = false, jsx = false } = {}) => deserializeLazyAst(await native_js.parseAsync(input, allowReturnOutsideFunction, jsx));
|
|
2188
5454
|
|
|
2189
|
-
exports.ANNOTATION_KEY = ANNOTATION_KEY;
|
|
2190
5455
|
exports.ArrowFunctionExpression = ArrowFunctionExpression;
|
|
2191
5456
|
exports.AwaitExpression = AwaitExpression;
|
|
2192
5457
|
exports.BLANK = BLANK;
|
|
@@ -2199,9 +5464,10 @@ exports.EMPTY_SET = EMPTY_SET;
|
|
|
2199
5464
|
exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
|
|
2200
5465
|
exports.ExpressionStatement = ExpressionStatement;
|
|
2201
5466
|
exports.FIXED_STRINGS = FIXED_STRINGS;
|
|
5467
|
+
exports.FunctionDeclaration = FunctionDeclaration;
|
|
2202
5468
|
exports.FunctionExpression = FunctionExpression;
|
|
2203
|
-
exports.INVALID_ANNOTATION_KEY = INVALID_ANNOTATION_KEY;
|
|
2204
5469
|
exports.Identifier = Identifier;
|
|
5470
|
+
exports.IfStatement = IfStatement$1;
|
|
2205
5471
|
exports.LOGLEVEL_DEBUG = LOGLEVEL_DEBUG;
|
|
2206
5472
|
exports.LOGLEVEL_ERROR = LOGLEVEL_ERROR;
|
|
2207
5473
|
exports.LOGLEVEL_INFO = LOGLEVEL_INFO;
|
|
@@ -2228,6 +5494,7 @@ exports.URL_OUTPUT_EXTERNALIMPORTATTRIBUTES = URL_OUTPUT_EXTERNALIMPORTATTRIBUTE
|
|
|
2228
5494
|
exports.URL_OUTPUT_FORMAT = URL_OUTPUT_FORMAT;
|
|
2229
5495
|
exports.URL_OUTPUT_GENERATEDCODE = URL_OUTPUT_GENERATEDCODE;
|
|
2230
5496
|
exports.URL_OUTPUT_GLOBALS = URL_OUTPUT_GLOBALS;
|
|
5497
|
+
exports.URL_OUTPUT_IMPORTATTRIBUTESKEY = URL_OUTPUT_IMPORTATTRIBUTESKEY;
|
|
2231
5498
|
exports.URL_OUTPUT_INLINEDYNAMICIMPORTS = URL_OUTPUT_INLINEDYNAMICIMPORTS;
|
|
2232
5499
|
exports.URL_OUTPUT_INTEROP = URL_OUTPUT_INTEROP;
|
|
2233
5500
|
exports.URL_OUTPUT_MANUALCHUNKS = URL_OUTPUT_MANUALCHUNKS;
|
|
@@ -2236,6 +5503,7 @@ exports.URL_OUTPUT_SOURCEMAPFILE = URL_OUTPUT_SOURCEMAPFILE;
|
|
|
2236
5503
|
exports.URL_PRESERVEENTRYSIGNATURES = URL_PRESERVEENTRYSIGNATURES;
|
|
2237
5504
|
exports.URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT = URL_SOURCEMAP_IS_LIKELY_TO_BE_INCORRECT;
|
|
2238
5505
|
exports.URL_THIS_IS_UNDEFINED = URL_THIS_IS_UNDEFINED;
|
|
5506
|
+
exports.URL_THIS_RESOLVE = URL_THIS_RESOLVE;
|
|
2239
5507
|
exports.URL_TRANSFORM = URL_TRANSFORM;
|
|
2240
5508
|
exports.URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY = URL_TREATING_MODULE_AS_EXTERNAL_DEPENDENCY;
|
|
2241
5509
|
exports.URL_TREESHAKE = URL_TREESHAKE;
|
|
@@ -2246,7 +5514,9 @@ exports.addTrailingSlashIfMissed = addTrailingSlashIfMissed;
|
|
|
2246
5514
|
exports.augmentCodeLocation = augmentCodeLocation;
|
|
2247
5515
|
exports.augmentLogMessage = augmentLogMessage;
|
|
2248
5516
|
exports.convertAnnotations = convertAnnotations;
|
|
2249
|
-
exports.convertNode = convertNode;
|
|
5517
|
+
exports.convertNode = convertNode$1;
|
|
5518
|
+
exports.deserializeAst = deserializeAst;
|
|
5519
|
+
exports.deserializeLazyAst = deserializeLazyAst;
|
|
2250
5520
|
exports.error = error;
|
|
2251
5521
|
exports.getAliasName = getAliasName;
|
|
2252
5522
|
exports.getAstBuffer = getAstBuffer;
|
|
@@ -2261,6 +5531,7 @@ exports.locate = locate;
|
|
|
2261
5531
|
exports.logAddonNotGenerated = logAddonNotGenerated;
|
|
2262
5532
|
exports.logAlreadyClosed = logAlreadyClosed;
|
|
2263
5533
|
exports.logAmbiguousExternalNamespaces = logAmbiguousExternalNamespaces;
|
|
5534
|
+
exports.logAmbiguousGlobalName = logAmbiguousGlobalName;
|
|
2264
5535
|
exports.logAnonymousPluginCache = logAnonymousPluginCache;
|
|
2265
5536
|
exports.logAssetNotFinalisedForFileName = logAssetNotFinalisedForFileName;
|
|
2266
5537
|
exports.logAssetReferenceIdNotFoundForSetSource = logAssetReferenceIdNotFoundForSetSource;
|
|
@@ -2285,6 +5556,7 @@ exports.logDuplicateExportError = logDuplicateExportError;
|
|
|
2285
5556
|
exports.logDuplicateImportOptions = logDuplicateImportOptions;
|
|
2286
5557
|
exports.logDuplicatePluginName = logDuplicatePluginName;
|
|
2287
5558
|
exports.logEmptyChunk = logEmptyChunk;
|
|
5559
|
+
exports.logEmptyManualChunk = logEmptyManualChunk;
|
|
2288
5560
|
exports.logEntryCannotBeExternal = logEntryCannotBeExternal;
|
|
2289
5561
|
exports.logEval = logEval;
|
|
2290
5562
|
exports.logExternalModulesCannotBeIncludedInManualChunks = logExternalModulesCannotBeIncludedInManualChunks;
|
|
@@ -2303,7 +5575,6 @@ exports.logImplicitDependantIsNotIncluded = logImplicitDependantIsNotIncluded;
|
|
|
2303
5575
|
exports.logImportAttributeIsInvalid = logImportAttributeIsInvalid;
|
|
2304
5576
|
exports.logImportOptionsAreInvalid = logImportOptionsAreInvalid;
|
|
2305
5577
|
exports.logIncompatibleExportOptionValue = logIncompatibleExportOptionValue;
|
|
2306
|
-
exports.logInconsistentImportAttributes = logInconsistentImportAttributes;
|
|
2307
5578
|
exports.logInputHookInOutputPlugin = logInputHookInOutputPlugin;
|
|
2308
5579
|
exports.logInternalIdCannotBeExternal = logInternalIdCannotBeExternal;
|
|
2309
5580
|
exports.logInvalidAddonPluginHook = logInvalidAddonPluginHook;
|
|
@@ -2353,11 +5624,16 @@ exports.logUnresolvedImplicitDependant = logUnresolvedImplicitDependant;
|
|
|
2353
5624
|
exports.logUnresolvedImport = logUnresolvedImport;
|
|
2354
5625
|
exports.logUnresolvedImportTreatedAsExternal = logUnresolvedImportTreatedAsExternal;
|
|
2355
5626
|
exports.logUnusedExternalImports = logUnusedExternalImports;
|
|
5627
|
+
exports.nodeTypeStrings = nodeTypeStrings;
|
|
2356
5628
|
exports.normalize = normalize;
|
|
5629
|
+
exports.parseAndWalk = parseAndWalk;
|
|
2357
5630
|
exports.parseAst = parseAst;
|
|
2358
5631
|
exports.parseAstAsync = parseAstAsync;
|
|
5632
|
+
exports.parseLazyAst = parseLazyAst;
|
|
5633
|
+
exports.parseLazyAstAsync = parseLazyAstAsync;
|
|
2359
5634
|
exports.printQuotedStringList = printQuotedStringList;
|
|
2360
5635
|
exports.relative = relative;
|
|
2361
5636
|
exports.relativeId = relativeId;
|
|
5637
|
+
exports.serializeAst = serializeAst;
|
|
2362
5638
|
exports.warnDeprecation = warnDeprecation;
|
|
2363
5639
|
//# sourceMappingURL=parseAst.js.map
|