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