@rollup/wasm-node 4.29.0-1 → 4.29.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/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +734 -1477
- package/dist/es/shared/parseAst.js +3 -3
- package/dist/es/shared/watch.js +6 -6
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +6 -6
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +771 -1474
- package/dist/shared/watch-cli.js +20 -4
- package/dist/shared/watch.js +3 -3
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +16 -16
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.29.0
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.29.0
|
|
4
|
+
Fri, 20 Dec 2024 18:36:54 GMT - commit dadd4882c4984d7875af799ad56e506784d50e1c
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
8
8
|
Released under the MIT License.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { ExportDefaultDeclaration as ExportDefaultDeclaration$1, CallExpression as CallExpression$1, EMPTY_ARRAY, LOGLEVEL_WARN, logUnusedExternalImports, ANNOTATION_KEY, INVALID_ANNOTATION_KEY, ObjectExpression as ObjectExpression$1, Property as Property$1, Program as Program$1, logIllegalImportReassignment, BLANK, logRedeclarationError, StaticBlock as StaticBlock$1, CatchClause as CatchClause$1, logDuplicateArgumentNameError, logModuleLevelDirective, ReturnStatement as ReturnStatement$1, VariableDeclarator as VariableDeclarator$1, ExpressionStatement as ExpressionStatement$1, logMissingExport, normalize, getImportPath, logMissingNodeBuiltins, logReservedNamespace, error, logIllegalIdentifierAsName, logMissingNameOptionForIifeExport, logMissingNameOptionForUmdExport, logConstVariableReassignError, ArrowFunctionExpression as ArrowFunctionExpression$1, EMPTY_SET, logCannotCallNamespace, logEval, BlockStatement as BlockStatement$1, getRollupError, logParseError, logModuleParseError, LOGLEVEL_INFO, logFirstSideEffect, locate, logInvalidAnnotation, Identifier as Identifier$1, logThisIsUndefined, getAstBuffer, convertAnnotations, FIXED_STRINGS, convertNode as convertNode$1, EMPTY_OBJECT, logImportAttributeIsInvalid, logImportOptionsAreInvalid, logSyntheticNamedExportsNeedNamespaceExport, logMissingEntryExport, logDuplicateExportError, logInvalidSourcemapForError, augmentCodeLocation, logInconsistentImportAttributes, logMissingJsxExport, logNamespaceConflict, logAmbiguousExternalNamespaces, logShimmedExport, parseAst, logCircularReexport, logInvalidFormatForTopLevelAwait, TemplateLiteral as TemplateLiteral$1, Literal as Literal$1, logAddonNotGenerated, logIncompatibleExportOptionValue, logMixedExport, logFailedValidation, isPathFragment, logCyclicCrossChunkReexport, getAliasName, logUnexpectedNamedImport, isAbsolute as isAbsolute$1, relative as relative$1, logUnexpectedNamespaceReexport, logEmptyChunk, logMissingGlobalName, logOptimizeChunkStatus, logSourcemapBroken, logConflictingSourcemapSources, logChunkInvalid, logInvalidOption, URL_OUTPUT_FORMAT, URL_OUTPUT_DIR, URL_OUTPUT_SOURCEMAPFILE, URL_OUTPUT_AMD_ID, logCannotAssignModuleToChunk, logAnonymousPluginCache, logDuplicatePluginName, logUnknownOption, printQuotedStringList, LOGLEVEL_ERROR, logLevelPriority, LOGLEVEL_DEBUG, logInvalidSetAssetSourceCall, logPluginError, logNoTransformMapOrAstWithoutCode, relativeId, logBadLoader, logExternalModulesCannotBeTransformedToModules, logInternalIdCannotBeExternal, isRelative, logUnresolvedImport, logUnresolvedImportTreatedAsExternal, logExternalSyntheticExports, logUnresolvedEntry, logUnresolvedImplicitDependant, logExternalModulesCannotBeIncludedInManualChunks, logEntryCannotBeExternal, logImplicitDependantCannotBeExternal, logNoAssetSourceSet, logFileReferenceIdNotFoundForFilename, logAssetReferenceIdNotFoundForSetSource, logAssetSourceAlreadySet, logInvalidRollupPhaseForChunkEmission, warnDeprecation, URL_GENERATEBUNDLE, logFileNameConflict, logAssetNotFinalisedForFileName, logChunkNotGeneratedForFileName, logInvalidLogPosition, logInputHookInOutputPlugin, logInvalidFunctionPluginHook, logInvalidAddonPluginHook, logImplicitDependantIsNotIncluded, logCircularDependency, augmentLogMessage, URL_JSX, URL_TREESHAKE, URL_TREESHAKE_MODULESIDEEFFECTS, logInvalidExportOptionValue, URL_OUTPUT_INTEROP, isValidUrl, addTrailingSlashIfMissed, URL_OUTPUT_SOURCEMAPBASEURL, URL_OUTPUT_INLINEDYNAMICIMPORTS, URL_PRESERVEENTRYSIGNATURES, URL_OUTPUT_AMD_BASEPATH, URL_OUTPUT_GENERATEDCODE, URL_OUTPUT_MANUALCHUNKS, URL_OUTPUT_EXTERNALIMPORTATTRIBUTES, logAlreadyClosed, logMissingFileOrDirOption, logCannotEmitFromOptionsHook, URL_WATCH } from './parseAst.js';
|
|
11
11
|
import { relative, dirname, basename, extname, resolve as resolve$1 } from 'node:path';
|
|
12
|
-
import { posix, isAbsolute, resolve
|
|
13
|
-
import { parseAsync,
|
|
12
|
+
import { posix, win32, isAbsolute, resolve } from 'path';
|
|
13
|
+
import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
|
|
14
14
|
import process$1, { env as env$1 } from 'node:process';
|
|
15
15
|
import { performance } from 'node:perf_hooks';
|
|
16
16
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version = "4.29.0
|
|
19
|
+
var version = "4.29.0";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -328,7 +328,7 @@ let Chunk$1 = class Chunk {
|
|
|
328
328
|
// ' test'.trim()
|
|
329
329
|
// split -> ' ' + 'test'
|
|
330
330
|
// ✔️ edit -> '' + 'test'
|
|
331
|
-
// ✖️ edit -> 'test' + ''
|
|
331
|
+
// ✖️ edit -> 'test' + ''
|
|
332
332
|
// TODO is this block necessary?...
|
|
333
333
|
newChunk.edit('', false);
|
|
334
334
|
this.content = '';
|
|
@@ -575,6 +575,7 @@ class Mappings {
|
|
|
575
575
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
576
576
|
this.generatedCodeColumn = 0;
|
|
577
577
|
first = true;
|
|
578
|
+
charInHiresBoundary = false;
|
|
578
579
|
} else {
|
|
579
580
|
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
580
581
|
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
@@ -652,6 +653,7 @@ class MagicString {
|
|
|
652
653
|
storedNames: { writable: true, value: {} },
|
|
653
654
|
indentStr: { writable: true, value: undefined },
|
|
654
655
|
ignoreList: { writable: true, value: options.ignoreList },
|
|
656
|
+
offset: { writable: true, value: options.offset || 0 },
|
|
655
657
|
});
|
|
656
658
|
|
|
657
659
|
this.byStart[0] = chunk;
|
|
@@ -670,6 +672,8 @@ class MagicString {
|
|
|
670
672
|
}
|
|
671
673
|
|
|
672
674
|
appendLeft(index, content) {
|
|
675
|
+
index = index + this.offset;
|
|
676
|
+
|
|
673
677
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
674
678
|
|
|
675
679
|
this._split(index);
|
|
@@ -685,6 +689,8 @@ class MagicString {
|
|
|
685
689
|
}
|
|
686
690
|
|
|
687
691
|
appendRight(index, content) {
|
|
692
|
+
index = index + this.offset;
|
|
693
|
+
|
|
688
694
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
689
695
|
|
|
690
696
|
this._split(index);
|
|
@@ -700,7 +706,7 @@ class MagicString {
|
|
|
700
706
|
}
|
|
701
707
|
|
|
702
708
|
clone() {
|
|
703
|
-
const cloned = new MagicString(this.original, { filename: this.filename });
|
|
709
|
+
const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
|
|
704
710
|
|
|
705
711
|
let originalChunk = this.firstChunk;
|
|
706
712
|
let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
|
|
@@ -898,7 +904,7 @@ class MagicString {
|
|
|
898
904
|
if (!warned.insertLeft) {
|
|
899
905
|
console.warn(
|
|
900
906
|
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
901
|
-
);
|
|
907
|
+
);
|
|
902
908
|
warned.insertLeft = true;
|
|
903
909
|
}
|
|
904
910
|
|
|
@@ -909,7 +915,7 @@ class MagicString {
|
|
|
909
915
|
if (!warned.insertRight) {
|
|
910
916
|
console.warn(
|
|
911
917
|
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
912
|
-
);
|
|
918
|
+
);
|
|
913
919
|
warned.insertRight = true;
|
|
914
920
|
}
|
|
915
921
|
|
|
@@ -917,6 +923,10 @@ class MagicString {
|
|
|
917
923
|
}
|
|
918
924
|
|
|
919
925
|
move(start, end, index) {
|
|
926
|
+
start = start + this.offset;
|
|
927
|
+
end = end + this.offset;
|
|
928
|
+
index = index + this.offset;
|
|
929
|
+
|
|
920
930
|
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
|
921
931
|
|
|
922
932
|
this._split(start);
|
|
@@ -959,6 +969,9 @@ class MagicString {
|
|
|
959
969
|
}
|
|
960
970
|
|
|
961
971
|
update(start, end, content, options) {
|
|
972
|
+
start = start + this.offset;
|
|
973
|
+
end = end + this.offset;
|
|
974
|
+
|
|
962
975
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
963
976
|
|
|
964
977
|
if (this.original.length !== 0) {
|
|
@@ -979,7 +992,7 @@ class MagicString {
|
|
|
979
992
|
if (!warned.storeName) {
|
|
980
993
|
console.warn(
|
|
981
994
|
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
982
|
-
);
|
|
995
|
+
);
|
|
983
996
|
warned.storeName = true;
|
|
984
997
|
}
|
|
985
998
|
|
|
@@ -1030,6 +1043,8 @@ class MagicString {
|
|
|
1030
1043
|
}
|
|
1031
1044
|
|
|
1032
1045
|
prependLeft(index, content) {
|
|
1046
|
+
index = index + this.offset;
|
|
1047
|
+
|
|
1033
1048
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1034
1049
|
|
|
1035
1050
|
this._split(index);
|
|
@@ -1045,6 +1060,8 @@ class MagicString {
|
|
|
1045
1060
|
}
|
|
1046
1061
|
|
|
1047
1062
|
prependRight(index, content) {
|
|
1063
|
+
index = index + this.offset;
|
|
1064
|
+
|
|
1048
1065
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
1049
1066
|
|
|
1050
1067
|
this._split(index);
|
|
@@ -1060,6 +1077,9 @@ class MagicString {
|
|
|
1060
1077
|
}
|
|
1061
1078
|
|
|
1062
1079
|
remove(start, end) {
|
|
1080
|
+
start = start + this.offset;
|
|
1081
|
+
end = end + this.offset;
|
|
1082
|
+
|
|
1063
1083
|
if (this.original.length !== 0) {
|
|
1064
1084
|
while (start < 0) start += this.original.length;
|
|
1065
1085
|
while (end < 0) end += this.original.length;
|
|
@@ -1086,6 +1106,9 @@ class MagicString {
|
|
|
1086
1106
|
}
|
|
1087
1107
|
|
|
1088
1108
|
reset(start, end) {
|
|
1109
|
+
start = start + this.offset;
|
|
1110
|
+
end = end + this.offset;
|
|
1111
|
+
|
|
1089
1112
|
if (this.original.length !== 0) {
|
|
1090
1113
|
while (start < 0) start += this.original.length;
|
|
1091
1114
|
while (end < 0) end += this.original.length;
|
|
@@ -1150,7 +1173,10 @@ class MagicString {
|
|
|
1150
1173
|
return this.intro + lineStr;
|
|
1151
1174
|
}
|
|
1152
1175
|
|
|
1153
|
-
slice(start = 0, end = this.original.length) {
|
|
1176
|
+
slice(start = 0, end = this.original.length - this.offset) {
|
|
1177
|
+
start = start + this.offset;
|
|
1178
|
+
end = end + this.offset;
|
|
1179
|
+
|
|
1154
1180
|
if (this.original.length !== 0) {
|
|
1155
1181
|
while (start < 0) start += this.original.length;
|
|
1156
1182
|
while (end < 0) end += this.original.length;
|
|
@@ -1386,11 +1412,7 @@ class MagicString {
|
|
|
1386
1412
|
if (match.index != null) {
|
|
1387
1413
|
const replacement = getReplacement(match, this.original);
|
|
1388
1414
|
if (replacement !== match[0]) {
|
|
1389
|
-
this.overwrite(
|
|
1390
|
-
match.index,
|
|
1391
|
-
match.index + match[0].length,
|
|
1392
|
-
replacement
|
|
1393
|
-
);
|
|
1415
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1394
1416
|
}
|
|
1395
1417
|
}
|
|
1396
1418
|
});
|
|
@@ -1399,11 +1421,7 @@ class MagicString {
|
|
|
1399
1421
|
if (match && match.index != null) {
|
|
1400
1422
|
const replacement = getReplacement(match, this.original);
|
|
1401
1423
|
if (replacement !== match[0]) {
|
|
1402
|
-
this.overwrite(
|
|
1403
|
-
match.index,
|
|
1404
|
-
match.index + match[0].length,
|
|
1405
|
-
replacement
|
|
1406
|
-
);
|
|
1424
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
1407
1425
|
}
|
|
1408
1426
|
}
|
|
1409
1427
|
}
|
|
@@ -1438,8 +1456,7 @@ class MagicString {
|
|
|
1438
1456
|
index = original.indexOf(string, index + stringLength)
|
|
1439
1457
|
) {
|
|
1440
1458
|
const previous = original.slice(index, index + stringLength);
|
|
1441
|
-
if (previous !== replacement)
|
|
1442
|
-
this.overwrite(index, index + stringLength, replacement);
|
|
1459
|
+
if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
|
|
1443
1460
|
}
|
|
1444
1461
|
|
|
1445
1462
|
return this;
|
|
@@ -1948,6 +1965,71 @@ function renderSystemExportSequenceBeforeExpression(exportedVariable, expression
|
|
|
1948
1965
|
}
|
|
1949
1966
|
}
|
|
1950
1967
|
|
|
1968
|
+
/** @import { Node } from 'estree' */
|
|
1969
|
+
|
|
1970
|
+
/**
|
|
1971
|
+
* @param {Node} node
|
|
1972
|
+
* @param {Node} parent
|
|
1973
|
+
* @returns {boolean}
|
|
1974
|
+
*/
|
|
1975
|
+
function is_reference(node, parent) {
|
|
1976
|
+
if (node.type === 'MemberExpression') {
|
|
1977
|
+
return !node.computed && is_reference(node.object, node);
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
if (node.type !== 'Identifier') return false;
|
|
1981
|
+
|
|
1982
|
+
switch (parent?.type) {
|
|
1983
|
+
// disregard `bar` in `foo.bar`
|
|
1984
|
+
case 'MemberExpression':
|
|
1985
|
+
return parent.computed || node === parent.object;
|
|
1986
|
+
|
|
1987
|
+
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
1988
|
+
case 'MethodDefinition':
|
|
1989
|
+
return parent.computed;
|
|
1990
|
+
|
|
1991
|
+
// disregard the `meta` in `import.meta`
|
|
1992
|
+
case 'MetaProperty':
|
|
1993
|
+
return parent.meta === node;
|
|
1994
|
+
|
|
1995
|
+
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
1996
|
+
case 'PropertyDefinition':
|
|
1997
|
+
return parent.computed || node === parent.value;
|
|
1998
|
+
|
|
1999
|
+
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
2000
|
+
case 'Property':
|
|
2001
|
+
return parent.computed || node === parent.value;
|
|
2002
|
+
|
|
2003
|
+
// disregard the `bar` in `export { foo as bar }` or
|
|
2004
|
+
// the foo in `import { foo as bar }`
|
|
2005
|
+
case 'ExportSpecifier':
|
|
2006
|
+
case 'ImportSpecifier':
|
|
2007
|
+
return node === parent.local;
|
|
2008
|
+
|
|
2009
|
+
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2010
|
+
case 'LabeledStatement':
|
|
2011
|
+
case 'BreakStatement':
|
|
2012
|
+
case 'ContinueStatement':
|
|
2013
|
+
return false;
|
|
2014
|
+
|
|
2015
|
+
default:
|
|
2016
|
+
return true;
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
2021
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
2022
|
+
const pureFunctions = Object.create(null);
|
|
2023
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2024
|
+
let currentFunctions = pureFunctions;
|
|
2025
|
+
for (const pathSegment of functionName.split('.')) {
|
|
2026
|
+
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2027
|
+
}
|
|
2028
|
+
currentFunctions[PureFunctionKey] = true;
|
|
2029
|
+
}
|
|
2030
|
+
return pureFunctions;
|
|
2031
|
+
};
|
|
2032
|
+
|
|
1951
2033
|
function getOrCreate(map, key, init) {
|
|
1952
2034
|
const existing = map.get(key);
|
|
1953
2035
|
if (existing !== undefined) {
|
|
@@ -1978,7 +2060,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
1978
2060
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
1979
2061
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
1980
2062
|
const EntitiesKey = Symbol('Entities');
|
|
1981
|
-
class
|
|
2063
|
+
class PathTracker {
|
|
1982
2064
|
constructor() {
|
|
1983
2065
|
this.entityPaths = Object.create(null, {
|
|
1984
2066
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -2003,14 +2085,14 @@ class EntityPathTracker {
|
|
|
2003
2085
|
getEntities(path) {
|
|
2004
2086
|
let currentPaths = this.entityPaths;
|
|
2005
2087
|
for (const pathSegment of path) {
|
|
2006
|
-
currentPaths = currentPaths[pathSegment]
|
|
2007
|
-
[
|
|
2008
|
-
|
|
2088
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2089
|
+
currentPaths[pathSegment] ||
|
|
2090
|
+
Object.create(null, { [EntitiesKey]: { value: new Set() } });
|
|
2009
2091
|
}
|
|
2010
2092
|
return currentPaths[EntitiesKey];
|
|
2011
2093
|
}
|
|
2012
2094
|
}
|
|
2013
|
-
const SHARED_RECURSION_TRACKER = new
|
|
2095
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
2014
2096
|
class DiscriminatedPathTracker {
|
|
2015
2097
|
constructor() {
|
|
2016
2098
|
this.entityPaths = Object.create(null, {
|
|
@@ -2020,9 +2102,9 @@ class DiscriminatedPathTracker {
|
|
|
2020
2102
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
2021
2103
|
let currentPaths = this.entityPaths;
|
|
2022
2104
|
for (const pathSegment of path) {
|
|
2023
|
-
currentPaths = currentPaths[pathSegment]
|
|
2024
|
-
[
|
|
2025
|
-
|
|
2105
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2106
|
+
currentPaths[pathSegment] ||
|
|
2107
|
+
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
2026
2108
|
}
|
|
2027
2109
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
2028
2110
|
if (trackedEntities.has(entity))
|
|
@@ -2031,137 +2113,6 @@ class DiscriminatedPathTracker {
|
|
|
2031
2113
|
return false;
|
|
2032
2114
|
}
|
|
2033
2115
|
}
|
|
2034
|
-
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: EMPTY_OBJECT });
|
|
2035
|
-
class IncludedPathTracker {
|
|
2036
|
-
constructor() {
|
|
2037
|
-
this.includedPaths = null;
|
|
2038
|
-
}
|
|
2039
|
-
includePathAndGetIfIncluded(path) {
|
|
2040
|
-
let included = true;
|
|
2041
|
-
let parent = this;
|
|
2042
|
-
let parentSegment = 'includedPaths';
|
|
2043
|
-
let currentPaths = (this.includedPaths ||=
|
|
2044
|
-
((included = false), Object.create(null)));
|
|
2045
|
-
for (const pathSegment of path) {
|
|
2046
|
-
// This means from here, all paths are included
|
|
2047
|
-
if (currentPaths[UnknownKey]) {
|
|
2048
|
-
return true;
|
|
2049
|
-
}
|
|
2050
|
-
// Including UnknownKey automatically includes all nested paths.
|
|
2051
|
-
// From above, we know that UnknownKey is not included yet.
|
|
2052
|
-
if (typeof pathSegment === 'symbol') {
|
|
2053
|
-
// Hopefully, this saves some memory over just setting
|
|
2054
|
-
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2055
|
-
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
2056
|
-
return false;
|
|
2057
|
-
}
|
|
2058
|
-
parent = currentPaths;
|
|
2059
|
-
parentSegment = pathSegment;
|
|
2060
|
-
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
2061
|
-
}
|
|
2062
|
-
return included;
|
|
2063
|
-
}
|
|
2064
|
-
includeAllPaths(entity, context, basePath) {
|
|
2065
|
-
const { includedPaths } = this;
|
|
2066
|
-
if (includedPaths) {
|
|
2067
|
-
includeAllPaths(entity, context, basePath, includedPaths);
|
|
2068
|
-
}
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
2072
|
-
if (currentPaths[UnknownKey]) {
|
|
2073
|
-
return entity.includePath([...basePath, UnknownKey], context);
|
|
2074
|
-
}
|
|
2075
|
-
const keys = Object.keys(currentPaths);
|
|
2076
|
-
if (keys.length === 0) {
|
|
2077
|
-
return entity.includePath(basePath, context);
|
|
2078
|
-
}
|
|
2079
|
-
for (const key of keys) {
|
|
2080
|
-
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
/** @import { Node } from 'estree' */
|
|
2085
|
-
|
|
2086
|
-
/**
|
|
2087
|
-
* @param {Node} node
|
|
2088
|
-
* @param {Node} parent
|
|
2089
|
-
* @returns {boolean}
|
|
2090
|
-
*/
|
|
2091
|
-
function is_reference(node, parent) {
|
|
2092
|
-
if (node.type === 'MemberExpression') {
|
|
2093
|
-
return !node.computed && is_reference(node.object, node);
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
if (node.type !== 'Identifier') return false;
|
|
2097
|
-
|
|
2098
|
-
switch (parent?.type) {
|
|
2099
|
-
// disregard `bar` in `foo.bar`
|
|
2100
|
-
case 'MemberExpression':
|
|
2101
|
-
return parent.computed || node === parent.object;
|
|
2102
|
-
|
|
2103
|
-
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
2104
|
-
case 'MethodDefinition':
|
|
2105
|
-
return parent.computed;
|
|
2106
|
-
|
|
2107
|
-
// disregard the `meta` in `import.meta`
|
|
2108
|
-
case 'MetaProperty':
|
|
2109
|
-
return parent.meta === node;
|
|
2110
|
-
|
|
2111
|
-
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
2112
|
-
case 'PropertyDefinition':
|
|
2113
|
-
return parent.computed || node === parent.value;
|
|
2114
|
-
|
|
2115
|
-
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
2116
|
-
case 'Property':
|
|
2117
|
-
return parent.computed || node === parent.value;
|
|
2118
|
-
|
|
2119
|
-
// disregard the `bar` in `export { foo as bar }` or
|
|
2120
|
-
// the foo in `import { foo as bar }`
|
|
2121
|
-
case 'ExportSpecifier':
|
|
2122
|
-
case 'ImportSpecifier':
|
|
2123
|
-
return node === parent.local;
|
|
2124
|
-
|
|
2125
|
-
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2126
|
-
case 'LabeledStatement':
|
|
2127
|
-
case 'BreakStatement':
|
|
2128
|
-
case 'ContinueStatement':
|
|
2129
|
-
return false;
|
|
2130
|
-
|
|
2131
|
-
default:
|
|
2132
|
-
return true;
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
|
|
2136
|
-
function createInclusionContext() {
|
|
2137
|
-
return {
|
|
2138
|
-
brokenFlow: false,
|
|
2139
|
-
hasBreak: false,
|
|
2140
|
-
hasContinue: false,
|
|
2141
|
-
includedCallArguments: new Set(),
|
|
2142
|
-
includedLabels: new Set()
|
|
2143
|
-
};
|
|
2144
|
-
}
|
|
2145
|
-
function createHasEffectsContext() {
|
|
2146
|
-
return {
|
|
2147
|
-
accessed: new EntityPathTracker(),
|
|
2148
|
-
assigned: new EntityPathTracker(),
|
|
2149
|
-
brokenFlow: false,
|
|
2150
|
-
called: new DiscriminatedPathTracker(),
|
|
2151
|
-
hasBreak: false,
|
|
2152
|
-
hasContinue: false,
|
|
2153
|
-
ignore: {
|
|
2154
|
-
breaks: false,
|
|
2155
|
-
continues: false,
|
|
2156
|
-
labels: new Set(),
|
|
2157
|
-
returnYield: false,
|
|
2158
|
-
this: false
|
|
2159
|
-
},
|
|
2160
|
-
includedLabels: new Set(),
|
|
2161
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
2162
|
-
replacedVariableInits: new Map()
|
|
2163
|
-
};
|
|
2164
|
-
}
|
|
2165
2116
|
|
|
2166
2117
|
function isFlagSet(flags, flag) {
|
|
2167
2118
|
return (flags & flag) !== 0;
|
|
@@ -2172,6 +2123,7 @@ function setFlag(flags, flag, value) {
|
|
|
2172
2123
|
|
|
2173
2124
|
const UnknownValue = Symbol('Unknown Value');
|
|
2174
2125
|
const UnknownTruthyValue = Symbol('Unknown Truthy Value');
|
|
2126
|
+
const UnknownFalsyValue = Symbol('Unknown Falsy Value');
|
|
2175
2127
|
class ExpressionEntity {
|
|
2176
2128
|
constructor() {
|
|
2177
2129
|
this.flags = 0;
|
|
@@ -2200,25 +2152,12 @@ class ExpressionEntity {
|
|
|
2200
2152
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2201
2153
|
return true;
|
|
2202
2154
|
}
|
|
2203
|
-
include(
|
|
2204
|
-
if (!this.included)
|
|
2205
|
-
this.includeNode(context);
|
|
2206
|
-
}
|
|
2207
|
-
includeNode(_context) {
|
|
2155
|
+
include(_context, _includeChildrenRecursively, _options) {
|
|
2208
2156
|
this.included = true;
|
|
2209
2157
|
}
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
}
|
|
2214
|
-
/* We are both including and including an unknown path here as the former
|
|
2215
|
-
* ensures that nested nodes are included while the latter ensures that all
|
|
2216
|
-
* paths of the expression are included.
|
|
2217
|
-
* */
|
|
2218
|
-
includeCallArguments(context, interaction) {
|
|
2219
|
-
for (const argument of interaction.args) {
|
|
2220
|
-
argument?.includePath(UNKNOWN_PATH, context);
|
|
2221
|
-
argument?.include(context, false);
|
|
2158
|
+
includeCallArguments(context, parameters) {
|
|
2159
|
+
for (const argument of parameters) {
|
|
2160
|
+
argument.include(context, false);
|
|
2222
2161
|
}
|
|
2223
2162
|
}
|
|
2224
2163
|
shouldBeIncluded(_context) {
|
|
@@ -2257,19 +2196,6 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
2257
2196
|
withNew: false
|
|
2258
2197
|
};
|
|
2259
2198
|
|
|
2260
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
2261
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
2262
|
-
const pureFunctions = Object.create(null);
|
|
2263
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2264
|
-
let currentFunctions = pureFunctions;
|
|
2265
|
-
for (const pathSegment of functionName.split('.')) {
|
|
2266
|
-
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2267
|
-
}
|
|
2268
|
-
currentFunctions[PureFunctionKey] = true;
|
|
2269
|
-
}
|
|
2270
|
-
return pureFunctions;
|
|
2271
|
-
};
|
|
2272
|
-
|
|
2273
2199
|
class Variable extends ExpressionEntity {
|
|
2274
2200
|
markReassigned() {
|
|
2275
2201
|
this.isReassigned = true;
|
|
@@ -2346,9 +2272,9 @@ class Variable extends ExpressionEntity {
|
|
|
2346
2272
|
* has not been included previously. Once a variable is included, it should
|
|
2347
2273
|
* take care all its declarations are included.
|
|
2348
2274
|
*/
|
|
2349
|
-
|
|
2275
|
+
include() {
|
|
2350
2276
|
this.included = true;
|
|
2351
|
-
this.renderedLikeHoisted?.
|
|
2277
|
+
this.renderedLikeHoisted?.include();
|
|
2352
2278
|
}
|
|
2353
2279
|
/**
|
|
2354
2280
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -2380,8 +2306,8 @@ class ExternalVariable extends Variable {
|
|
|
2380
2306
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2381
2307
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2382
2308
|
}
|
|
2383
|
-
|
|
2384
|
-
super.
|
|
2309
|
+
include() {
|
|
2310
|
+
super.include();
|
|
2385
2311
|
this.module.used = true;
|
|
2386
2312
|
}
|
|
2387
2313
|
}
|
|
@@ -2682,6 +2608,36 @@ const childNodeKeys = {
|
|
|
2682
2608
|
YieldExpression: ['argument']
|
|
2683
2609
|
};
|
|
2684
2610
|
|
|
2611
|
+
function createInclusionContext() {
|
|
2612
|
+
return {
|
|
2613
|
+
brokenFlow: false,
|
|
2614
|
+
hasBreak: false,
|
|
2615
|
+
hasContinue: false,
|
|
2616
|
+
includedCallArguments: new Set(),
|
|
2617
|
+
includedLabels: new Set()
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
function createHasEffectsContext() {
|
|
2621
|
+
return {
|
|
2622
|
+
accessed: new PathTracker(),
|
|
2623
|
+
assigned: new PathTracker(),
|
|
2624
|
+
brokenFlow: false,
|
|
2625
|
+
called: new DiscriminatedPathTracker(),
|
|
2626
|
+
hasBreak: false,
|
|
2627
|
+
hasContinue: false,
|
|
2628
|
+
ignore: {
|
|
2629
|
+
breaks: false,
|
|
2630
|
+
continues: false,
|
|
2631
|
+
labels: new Set(),
|
|
2632
|
+
returnYield: false,
|
|
2633
|
+
this: false
|
|
2634
|
+
},
|
|
2635
|
+
includedLabels: new Set(),
|
|
2636
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
2637
|
+
replacedVariableInits: new Map()
|
|
2638
|
+
};
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2685
2641
|
const INCLUDE_PARAMETERS = 'variables';
|
|
2686
2642
|
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
2687
2643
|
class NodeBase extends ExpressionEntity {
|
|
@@ -2751,37 +2707,20 @@ class NodeBase extends ExpressionEntity {
|
|
|
2751
2707
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
2752
2708
|
}
|
|
2753
2709
|
include(context, includeChildrenRecursively, _options) {
|
|
2754
|
-
if (!this.included)
|
|
2755
|
-
this.includeNode(context);
|
|
2756
|
-
for (const key of childNodeKeys[this.type]) {
|
|
2757
|
-
const value = this[key];
|
|
2758
|
-
if (value === null)
|
|
2759
|
-
continue;
|
|
2760
|
-
if (Array.isArray(value)) {
|
|
2761
|
-
for (const child of value) {
|
|
2762
|
-
child?.include(context, includeChildrenRecursively);
|
|
2763
|
-
}
|
|
2764
|
-
}
|
|
2765
|
-
else {
|
|
2766
|
-
value.include(context, includeChildrenRecursively);
|
|
2767
|
-
}
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
includeNode(context) {
|
|
2771
|
-
this.included = true;
|
|
2772
2710
|
if (!this.deoptimized)
|
|
2773
2711
|
this.applyDeoptimizations();
|
|
2712
|
+
this.included = true;
|
|
2774
2713
|
for (const key of childNodeKeys[this.type]) {
|
|
2775
2714
|
const value = this[key];
|
|
2776
2715
|
if (value === null)
|
|
2777
2716
|
continue;
|
|
2778
2717
|
if (Array.isArray(value)) {
|
|
2779
2718
|
for (const child of value) {
|
|
2780
|
-
child?.
|
|
2719
|
+
child?.include(context, includeChildrenRecursively);
|
|
2781
2720
|
}
|
|
2782
2721
|
}
|
|
2783
2722
|
else {
|
|
2784
|
-
value.
|
|
2723
|
+
value.include(context, includeChildrenRecursively);
|
|
2785
2724
|
}
|
|
2786
2725
|
}
|
|
2787
2726
|
}
|
|
@@ -2888,17 +2827,6 @@ class NodeBase extends ExpressionEntity {
|
|
|
2888
2827
|
function createChildNodeKeysForNode(esTreeNode) {
|
|
2889
2828
|
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
2890
2829
|
}
|
|
2891
|
-
function onlyIncludeSelf() {
|
|
2892
|
-
this.included = true;
|
|
2893
|
-
if (!this.deoptimized)
|
|
2894
|
-
this.applyDeoptimizations();
|
|
2895
|
-
}
|
|
2896
|
-
function onlyIncludeSelfNoDeoptimize() {
|
|
2897
|
-
this.included = true;
|
|
2898
|
-
}
|
|
2899
|
-
function doNotDeoptimize() {
|
|
2900
|
-
this.deoptimized = true;
|
|
2901
|
-
}
|
|
2902
2830
|
|
|
2903
2831
|
function isObjectExpressionNode(node) {
|
|
2904
2832
|
return node instanceof NodeBase && node.type === ObjectExpression$1;
|
|
@@ -2911,8 +2839,8 @@ function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions =
|
|
|
2911
2839
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2912
2840
|
}
|
|
2913
2841
|
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2914
|
-
getLiteralValueAtPath(
|
|
2915
|
-
return
|
|
2842
|
+
getLiteralValueAtPath() {
|
|
2843
|
+
return undefined;
|
|
2916
2844
|
}
|
|
2917
2845
|
})();
|
|
2918
2846
|
const returnsUnknown = {
|
|
@@ -3109,6 +3037,31 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
3109
3037
|
return [members[memberName].returns, false];
|
|
3110
3038
|
}
|
|
3111
3039
|
|
|
3040
|
+
class SpreadElement extends NodeBase {
|
|
3041
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3042
|
+
if (path.length > 0) {
|
|
3043
|
+
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3044
|
+
}
|
|
3045
|
+
}
|
|
3046
|
+
hasEffects(context) {
|
|
3047
|
+
if (!this.deoptimized)
|
|
3048
|
+
this.applyDeoptimizations();
|
|
3049
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
3050
|
+
.treeshake;
|
|
3051
|
+
return (this.argument.hasEffects(context) ||
|
|
3052
|
+
(propertyReadSideEffects &&
|
|
3053
|
+
(propertyReadSideEffects === 'always' ||
|
|
3054
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3055
|
+
}
|
|
3056
|
+
applyDeoptimizations() {
|
|
3057
|
+
this.deoptimized = true;
|
|
3058
|
+
// Only properties of properties of the argument could become subject to reassignment
|
|
3059
|
+
// This will also reassign the return values of iterators
|
|
3060
|
+
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3061
|
+
this.scope.context.requestTreeshakingPass();
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
|
|
3112
3065
|
class Method extends ExpressionEntity {
|
|
3113
3066
|
constructor(description) {
|
|
3114
3067
|
super();
|
|
@@ -3234,7 +3187,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3234
3187
|
this.unknownIntegerProps = [];
|
|
3235
3188
|
this.unmatchableGetters = [];
|
|
3236
3189
|
this.unmatchablePropertiesAndGetters = [];
|
|
3237
|
-
this.unmatchablePropertiesAndSetters = [];
|
|
3238
3190
|
this.unmatchableSetters = [];
|
|
3239
3191
|
if (Array.isArray(properties)) {
|
|
3240
3192
|
this.buildPropertyMaps(properties);
|
|
@@ -3469,38 +3421,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3469
3421
|
}
|
|
3470
3422
|
return false;
|
|
3471
3423
|
}
|
|
3472
|
-
include(context, includeChildrenRecursively) {
|
|
3473
|
-
this.included = true;
|
|
3474
|
-
for (const property of this.allProperties) {
|
|
3475
|
-
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
3476
|
-
property.include(context, includeChildrenRecursively);
|
|
3477
|
-
}
|
|
3478
|
-
}
|
|
3479
|
-
this.prototypeExpression?.include(context, includeChildrenRecursively);
|
|
3480
|
-
}
|
|
3481
|
-
includePath(path, context) {
|
|
3482
|
-
this.included = true;
|
|
3483
|
-
if (path.length === 0)
|
|
3484
|
-
return;
|
|
3485
|
-
const [key, ...subPath] = path;
|
|
3486
|
-
const [includedMembers, includedPath] = typeof key === 'string'
|
|
3487
|
-
? [
|
|
3488
|
-
[
|
|
3489
|
-
...new Set([
|
|
3490
|
-
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
3491
|
-
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
3492
|
-
])
|
|
3493
|
-
],
|
|
3494
|
-
subPath
|
|
3495
|
-
]
|
|
3496
|
-
: [this.allProperties, UNKNOWN_PATH];
|
|
3497
|
-
for (const property of includedMembers) {
|
|
3498
|
-
property.includePath(includedPath, context);
|
|
3499
|
-
}
|
|
3500
|
-
this.prototypeExpression?.includePath(path, context);
|
|
3501
|
-
}
|
|
3502
3424
|
buildPropertyMaps(properties) {
|
|
3503
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters,
|
|
3425
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3426
|
+
const unmatchablePropertiesAndSetters = [];
|
|
3504
3427
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3505
3428
|
const { key, kind, property } = properties[index];
|
|
3506
3429
|
allProperties.push(property);
|
|
@@ -3770,37 +3693,6 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
3770
3693
|
values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
|
|
3771
3694
|
}, OBJECT_PROTOTYPE, true);
|
|
3772
3695
|
|
|
3773
|
-
class SpreadElement extends NodeBase {
|
|
3774
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3775
|
-
if (path.length > 0) {
|
|
3776
|
-
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3777
|
-
}
|
|
3778
|
-
}
|
|
3779
|
-
hasEffects(context) {
|
|
3780
|
-
if (!this.deoptimized)
|
|
3781
|
-
this.applyDeoptimizations();
|
|
3782
|
-
const { propertyReadSideEffects } = this.scope.context.options
|
|
3783
|
-
.treeshake;
|
|
3784
|
-
return (this.argument.hasEffects(context) ||
|
|
3785
|
-
(propertyReadSideEffects &&
|
|
3786
|
-
(propertyReadSideEffects === 'always' ||
|
|
3787
|
-
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3788
|
-
}
|
|
3789
|
-
includeNode(context) {
|
|
3790
|
-
this.included = true;
|
|
3791
|
-
if (!this.deoptimized)
|
|
3792
|
-
this.applyDeoptimizations();
|
|
3793
|
-
this.argument.includePath(UNKNOWN_PATH, context);
|
|
3794
|
-
}
|
|
3795
|
-
applyDeoptimizations() {
|
|
3796
|
-
this.deoptimized = true;
|
|
3797
|
-
// Only properties of properties of the argument could become subject to reassignment
|
|
3798
|
-
// This will also reassign the return values of iterators
|
|
3799
|
-
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3800
|
-
this.scope.context.requestTreeshakingPass();
|
|
3801
|
-
}
|
|
3802
|
-
}
|
|
3803
|
-
|
|
3804
3696
|
class ArrayExpression extends NodeBase {
|
|
3805
3697
|
constructor() {
|
|
3806
3698
|
super(...arguments);
|
|
@@ -3821,16 +3713,6 @@ class ArrayExpression extends NodeBase {
|
|
|
3821
3713
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
3822
3714
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
3823
3715
|
}
|
|
3824
|
-
includeNode(context) {
|
|
3825
|
-
this.included = true;
|
|
3826
|
-
if (!this.deoptimized)
|
|
3827
|
-
this.applyDeoptimizations();
|
|
3828
|
-
for (const element of this.elements) {
|
|
3829
|
-
if (element) {
|
|
3830
|
-
element?.includePath(UNKNOWN_PATH, context);
|
|
3831
|
-
}
|
|
3832
|
-
}
|
|
3833
|
-
}
|
|
3834
3716
|
applyDeoptimizations() {
|
|
3835
3717
|
this.deoptimized = true;
|
|
3836
3718
|
let hasSpread = false;
|
|
@@ -3872,29 +3754,29 @@ class ArrayExpression extends NodeBase {
|
|
|
3872
3754
|
|
|
3873
3755
|
/* eslint sort-keys: "off" */
|
|
3874
3756
|
const ValueProperties = Symbol('Value Properties');
|
|
3875
|
-
const
|
|
3757
|
+
const getUnknownValue = () => UnknownValue;
|
|
3876
3758
|
const returnFalse = () => false;
|
|
3877
3759
|
const returnTrue = () => true;
|
|
3878
3760
|
const PURE = {
|
|
3879
3761
|
deoptimizeArgumentsOnCall: doNothing,
|
|
3880
|
-
getLiteralValue:
|
|
3762
|
+
getLiteralValue: getUnknownValue,
|
|
3881
3763
|
hasEffectsWhenCalled: returnFalse
|
|
3882
3764
|
};
|
|
3883
3765
|
const IMPURE = {
|
|
3884
3766
|
deoptimizeArgumentsOnCall: doNothing,
|
|
3885
|
-
getLiteralValue:
|
|
3767
|
+
getLiteralValue: getUnknownValue,
|
|
3886
3768
|
hasEffectsWhenCalled: returnTrue
|
|
3887
3769
|
};
|
|
3888
3770
|
const PURE_WITH_ARRAY = {
|
|
3889
3771
|
deoptimizeArgumentsOnCall: doNothing,
|
|
3890
|
-
getLiteralValue:
|
|
3772
|
+
getLiteralValue: getUnknownValue,
|
|
3891
3773
|
hasEffectsWhenCalled({ args }) {
|
|
3892
3774
|
return args.length > 1 && !(args[1] instanceof ArrayExpression);
|
|
3893
3775
|
}
|
|
3894
3776
|
};
|
|
3895
3777
|
const GETTER_ACCESS = {
|
|
3896
3778
|
deoptimizeArgumentsOnCall: doNothing,
|
|
3897
|
-
getLiteralValue:
|
|
3779
|
+
getLiteralValue: getUnknownValue,
|
|
3898
3780
|
hasEffectsWhenCalled({ args }, context) {
|
|
3899
3781
|
const [_thisArgument, firstArgument] = args;
|
|
3900
3782
|
return (!(firstArgument instanceof ExpressionEntity) ||
|
|
@@ -3924,7 +3806,7 @@ const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
|
3924
3806
|
deoptimizeArgumentsOnCall({ args: [, firstArgument] }) {
|
|
3925
3807
|
firstArgument?.deoptimizePath(UNKNOWN_PATH);
|
|
3926
3808
|
},
|
|
3927
|
-
getLiteralValue:
|
|
3809
|
+
getLiteralValue: getUnknownValue,
|
|
3928
3810
|
hasEffectsWhenCalled({ args }, context) {
|
|
3929
3811
|
return (args.length <= 1 ||
|
|
3930
3812
|
args[1].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
@@ -4131,7 +4013,7 @@ const knownGlobals = {
|
|
|
4131
4013
|
}
|
|
4132
4014
|
target.deoptimizePath(UNKNOWN_PATH);
|
|
4133
4015
|
},
|
|
4134
|
-
getLiteralValue:
|
|
4016
|
+
getLiteralValue: getUnknownValue,
|
|
4135
4017
|
hasEffectsWhenCalled: returnTrue
|
|
4136
4018
|
}
|
|
4137
4019
|
},
|
|
@@ -4321,7 +4203,7 @@ const knownGlobals = {
|
|
|
4321
4203
|
deoptimizeArgumentsOnCall({ args }) {
|
|
4322
4204
|
args[2]?.deoptimizePath(['detail']);
|
|
4323
4205
|
},
|
|
4324
|
-
getLiteralValue:
|
|
4206
|
+
getLiteralValue: getUnknownValue,
|
|
4325
4207
|
hasEffectsWhenCalled: returnFalse
|
|
4326
4208
|
},
|
|
4327
4209
|
prototype: O
|
|
@@ -4898,37 +4780,17 @@ class GlobalVariable extends Variable {
|
|
|
4898
4780
|
}
|
|
4899
4781
|
}
|
|
4900
4782
|
|
|
4901
|
-
// To avoid infinite recursions
|
|
4902
|
-
const MAX_PATH_DEPTH = 6;
|
|
4903
|
-
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
4904
|
-
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
4905
|
-
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
4906
|
-
const { length: length1 } = path1;
|
|
4907
|
-
const { length: length2 } = path2;
|
|
4908
|
-
return length1 === 0
|
|
4909
|
-
? path2
|
|
4910
|
-
: length2 === 0
|
|
4911
|
-
? path1
|
|
4912
|
-
: length1 + length2 > MAX_PATH_DEPTH
|
|
4913
|
-
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
4914
|
-
: [...path1, ...path2];
|
|
4915
|
-
};
|
|
4916
|
-
|
|
4917
4783
|
class LocalVariable extends Variable {
|
|
4918
|
-
constructor(name, declarator, init,
|
|
4919
|
-
/** if this is non-empty, the actual init is this path of this.init */
|
|
4920
|
-
initPath, context, kind) {
|
|
4784
|
+
constructor(name, declarator, init, context, kind) {
|
|
4921
4785
|
super(name);
|
|
4922
4786
|
this.init = init;
|
|
4923
|
-
this.initPath = initPath;
|
|
4924
|
-
this.kind = kind;
|
|
4925
4787
|
this.calledFromTryStatement = false;
|
|
4926
4788
|
this.additionalInitializers = null;
|
|
4927
|
-
this.includedPathTracker = new IncludedPathTracker();
|
|
4928
4789
|
this.expressionsToBeDeoptimized = [];
|
|
4929
4790
|
this.declarations = declarator ? [declarator] : [];
|
|
4930
4791
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
4931
4792
|
this.module = context.module;
|
|
4793
|
+
this.kind = kind;
|
|
4932
4794
|
}
|
|
4933
4795
|
addDeclaration(identifier, init) {
|
|
4934
4796
|
this.declarations.push(identifier);
|
|
@@ -4939,16 +4801,15 @@ class LocalVariable extends Variable {
|
|
|
4939
4801
|
for (const initializer of this.additionalInitializers) {
|
|
4940
4802
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
4941
4803
|
}
|
|
4804
|
+
this.additionalInitializers = null;
|
|
4942
4805
|
}
|
|
4943
4806
|
}
|
|
4944
4807
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
4945
|
-
if (this.isReassigned
|
|
4808
|
+
if (this.isReassigned) {
|
|
4946
4809
|
deoptimizeInteraction(interaction);
|
|
4947
4810
|
return;
|
|
4948
4811
|
}
|
|
4949
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () =>
|
|
4950
|
-
this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker);
|
|
4951
|
-
}, undefined);
|
|
4812
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
4952
4813
|
}
|
|
4953
4814
|
deoptimizePath(path) {
|
|
4954
4815
|
if (this.isReassigned ||
|
|
@@ -4962,40 +4823,37 @@ class LocalVariable extends Variable {
|
|
|
4962
4823
|
for (const expression of expressionsToBeDeoptimized) {
|
|
4963
4824
|
expression.deoptimizeCache();
|
|
4964
4825
|
}
|
|
4965
|
-
this.init.deoptimizePath(
|
|
4826
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
4966
4827
|
}
|
|
4967
4828
|
else {
|
|
4968
|
-
this.init.deoptimizePath(
|
|
4829
|
+
this.init.deoptimizePath(path);
|
|
4969
4830
|
}
|
|
4970
4831
|
}
|
|
4971
4832
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
4972
|
-
if (this.isReassigned
|
|
4833
|
+
if (this.isReassigned) {
|
|
4973
4834
|
return UnknownValue;
|
|
4974
4835
|
}
|
|
4975
4836
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4976
4837
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4977
|
-
return this.init.getLiteralValueAtPath(
|
|
4838
|
+
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
4978
4839
|
}, UnknownValue);
|
|
4979
4840
|
}
|
|
4980
4841
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
4981
|
-
if (this.isReassigned
|
|
4842
|
+
if (this.isReassigned) {
|
|
4982
4843
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
4983
4844
|
}
|
|
4984
4845
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4985
4846
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4986
|
-
return this.init.getReturnExpressionWhenCalledAtPath(
|
|
4847
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
4987
4848
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
4988
4849
|
}
|
|
4989
4850
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4990
|
-
if (path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
4991
|
-
return true;
|
|
4992
|
-
}
|
|
4993
4851
|
switch (interaction.type) {
|
|
4994
4852
|
case INTERACTION_ACCESSED: {
|
|
4995
4853
|
if (this.isReassigned)
|
|
4996
4854
|
return true;
|
|
4997
4855
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4998
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4856
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4999
4857
|
}
|
|
5000
4858
|
case INTERACTION_ASSIGNED: {
|
|
5001
4859
|
if (this.included)
|
|
@@ -5005,63 +4863,44 @@ class LocalVariable extends Variable {
|
|
|
5005
4863
|
if (this.isReassigned)
|
|
5006
4864
|
return true;
|
|
5007
4865
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
5008
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4866
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5009
4867
|
}
|
|
5010
4868
|
case INTERACTION_CALLED: {
|
|
5011
4869
|
if (this.isReassigned)
|
|
5012
4870
|
return true;
|
|
5013
4871
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
5014
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4872
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5015
4873
|
}
|
|
5016
4874
|
}
|
|
5017
4875
|
}
|
|
5018
|
-
|
|
5019
|
-
if (!this.
|
|
5020
|
-
|
|
5021
|
-
if (!this.included) {
|
|
5022
|
-
// This will reduce the number of tree-shaking passes by eagerly
|
|
5023
|
-
// including inits. By pushing this here instead of directly including
|
|
5024
|
-
// we avoid deep call stacks.
|
|
5025
|
-
this.module.scope.context.newlyIncludedVariableInits.add(this.init);
|
|
5026
|
-
}
|
|
5027
|
-
super.includePath(path, context);
|
|
4876
|
+
include() {
|
|
4877
|
+
if (!this.included) {
|
|
4878
|
+
super.include();
|
|
5028
4879
|
for (const declaration of this.declarations) {
|
|
5029
4880
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
5030
4881
|
if (!declaration.included)
|
|
5031
|
-
declaration.include(
|
|
4882
|
+
declaration.include(createInclusionContext(), false);
|
|
5032
4883
|
let node = declaration.parent;
|
|
5033
4884
|
while (!node.included) {
|
|
5034
4885
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
5035
4886
|
// in which case .include() might pull in more dead code
|
|
5036
|
-
node.
|
|
4887
|
+
node.included = true;
|
|
5037
4888
|
if (node.type === Program$1)
|
|
5038
4889
|
break;
|
|
5039
4890
|
node = node.parent;
|
|
5040
4891
|
}
|
|
5041
4892
|
}
|
|
5042
|
-
// We need to make sure we include the correct path of the init
|
|
5043
|
-
if (path.length > 0) {
|
|
5044
|
-
this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context);
|
|
5045
|
-
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context));
|
|
5046
|
-
}
|
|
5047
4893
|
}
|
|
5048
4894
|
}
|
|
5049
|
-
includeCallArguments(context,
|
|
5050
|
-
if (this.isReassigned ||
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
// a specific path
|
|
5054
|
-
this.initPath.length > 0) {
|
|
5055
|
-
for (const argument of interaction.args) {
|
|
5056
|
-
if (argument) {
|
|
5057
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
5058
|
-
argument.include(context, false);
|
|
5059
|
-
}
|
|
4895
|
+
includeCallArguments(context, parameters) {
|
|
4896
|
+
if (this.isReassigned || context.includedCallArguments.has(this.init)) {
|
|
4897
|
+
for (const argument of parameters) {
|
|
4898
|
+
argument.include(context, false);
|
|
5060
4899
|
}
|
|
5061
4900
|
}
|
|
5062
4901
|
else {
|
|
5063
4902
|
context.includedCallArguments.add(this.init);
|
|
5064
|
-
this.init.includeCallArguments(context,
|
|
4903
|
+
this.init.includeCallArguments(context, parameters);
|
|
5065
4904
|
context.includedCallArguments.delete(this.init);
|
|
5066
4905
|
}
|
|
5067
4906
|
}
|
|
@@ -5141,31 +4980,18 @@ class IdentifierBase extends NodeBase {
|
|
|
5141
4980
|
}
|
|
5142
4981
|
}
|
|
5143
4982
|
}
|
|
5144
|
-
include(
|
|
5145
|
-
if (!this.included)
|
|
5146
|
-
this.includeNode(context);
|
|
5147
|
-
}
|
|
5148
|
-
includeNode(context) {
|
|
5149
|
-
this.included = true;
|
|
4983
|
+
include() {
|
|
5150
4984
|
if (!this.deoptimized)
|
|
5151
4985
|
this.applyDeoptimizations();
|
|
5152
|
-
if (this.variable !== null) {
|
|
5153
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5154
|
-
}
|
|
5155
|
-
}
|
|
5156
|
-
includePath(path, context) {
|
|
5157
4986
|
if (!this.included) {
|
|
5158
4987
|
this.included = true;
|
|
5159
4988
|
if (this.variable !== null) {
|
|
5160
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
4989
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
5161
4990
|
}
|
|
5162
4991
|
}
|
|
5163
|
-
else if (path.length > 0) {
|
|
5164
|
-
this.variable?.includePath(path, context);
|
|
5165
|
-
}
|
|
5166
4992
|
}
|
|
5167
|
-
includeCallArguments(context,
|
|
5168
|
-
this.variable.includeCallArguments(context,
|
|
4993
|
+
includeCallArguments(context, parameters) {
|
|
4994
|
+
this.variable.includeCallArguments(context, parameters);
|
|
5169
4995
|
}
|
|
5170
4996
|
isPossibleTDZ() {
|
|
5171
4997
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -5248,39 +5074,10 @@ function closestParentFunctionOrProgram(node) {
|
|
|
5248
5074
|
return node;
|
|
5249
5075
|
}
|
|
5250
5076
|
|
|
5251
|
-
class ObjectMember extends ExpressionEntity {
|
|
5252
|
-
constructor(object, path) {
|
|
5253
|
-
super();
|
|
5254
|
-
this.object = object;
|
|
5255
|
-
this.path = path;
|
|
5256
|
-
}
|
|
5257
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5258
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.path, ...path], recursionTracker);
|
|
5259
|
-
}
|
|
5260
|
-
deoptimizePath(path) {
|
|
5261
|
-
this.object.deoptimizePath([...this.path, ...path]);
|
|
5262
|
-
}
|
|
5263
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5264
|
-
return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin);
|
|
5265
|
-
}
|
|
5266
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5267
|
-
return this.object.getReturnExpressionWhenCalledAtPath([...this.path, ...path], interaction, recursionTracker, origin);
|
|
5268
|
-
}
|
|
5269
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5270
|
-
return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context);
|
|
5271
|
-
}
|
|
5272
|
-
}
|
|
5273
|
-
|
|
5274
5077
|
class Identifier extends IdentifierBase {
|
|
5275
5078
|
constructor() {
|
|
5276
5079
|
super(...arguments);
|
|
5277
|
-
this.variable = null;
|
|
5278
|
-
}
|
|
5279
|
-
get isDestructuringDeoptimized() {
|
|
5280
|
-
return isFlagSet(this.flags, 8388608 /* Flag.destructuringDeoptimized */);
|
|
5281
|
-
}
|
|
5282
|
-
set isDestructuringDeoptimized(value) {
|
|
5283
|
-
this.flags = setFlag(this.flags, 8388608 /* Flag.destructuringDeoptimized */, value);
|
|
5080
|
+
this.variable = null;
|
|
5284
5081
|
}
|
|
5285
5082
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
5286
5083
|
if (exportNamesByVariable.has(this.variable)) {
|
|
@@ -5294,52 +5091,42 @@ class Identifier extends IdentifierBase {
|
|
|
5294
5091
|
this.isVariableReference = true;
|
|
5295
5092
|
}
|
|
5296
5093
|
}
|
|
5297
|
-
declare(kind,
|
|
5094
|
+
declare(kind, init) {
|
|
5298
5095
|
let variable;
|
|
5299
5096
|
const { treeshake } = this.scope.context.options;
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5097
|
+
switch (kind) {
|
|
5098
|
+
case 'var': {
|
|
5099
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5100
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
5101
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
5102
|
+
variable.markInitializersForDeoptimization();
|
|
5103
|
+
}
|
|
5104
|
+
break;
|
|
5308
5105
|
}
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
if ((this.included ||=
|
|
5331
|
-
destructuredInitPath.length > 0 &&
|
|
5332
|
-
!context.brokenFlow &&
|
|
5333
|
-
propertyReadSideEffects &&
|
|
5334
|
-
(propertyReadSideEffects === 'always' ||
|
|
5335
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext())))) {
|
|
5336
|
-
if (this.variable && !this.variable.included) {
|
|
5337
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5106
|
+
case 'function': {
|
|
5107
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
5108
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5109
|
+
break;
|
|
5110
|
+
}
|
|
5111
|
+
case 'let':
|
|
5112
|
+
case 'const':
|
|
5113
|
+
case 'using':
|
|
5114
|
+
case 'await using':
|
|
5115
|
+
case 'class': {
|
|
5116
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5117
|
+
break;
|
|
5118
|
+
}
|
|
5119
|
+
case 'parameter': {
|
|
5120
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
5121
|
+
break;
|
|
5122
|
+
}
|
|
5123
|
+
/* istanbul ignore next */
|
|
5124
|
+
default: {
|
|
5125
|
+
/* istanbul ignore next */
|
|
5126
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
5338
5127
|
}
|
|
5339
|
-
init.includePath(destructuredInitPath, context);
|
|
5340
|
-
return true;
|
|
5341
5128
|
}
|
|
5342
|
-
return
|
|
5129
|
+
return [(this.variable = variable)];
|
|
5343
5130
|
}
|
|
5344
5131
|
markDeclarationReached() {
|
|
5345
5132
|
this.variable.initReached = true;
|
|
@@ -5405,17 +5192,18 @@ class Scope {
|
|
|
5405
5192
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
5406
5193
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
5407
5194
|
*/
|
|
5408
|
-
addDeclaration(identifier, context, init,
|
|
5195
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5409
5196
|
const name = identifier.name;
|
|
5410
5197
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5411
5198
|
if (existingVariable) {
|
|
5412
|
-
|
|
5199
|
+
const existingKind = existingVariable.kind;
|
|
5200
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
5413
5201
|
existingVariable.addDeclaration(identifier, init);
|
|
5414
5202
|
return existingVariable;
|
|
5415
5203
|
}
|
|
5416
5204
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5417
5205
|
}
|
|
5418
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5206
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5419
5207
|
this.variables.set(name, newVariable);
|
|
5420
5208
|
return newVariable;
|
|
5421
5209
|
}
|
|
@@ -5591,6 +5379,7 @@ class MethodBase extends NodeBase {
|
|
|
5591
5379
|
}
|
|
5592
5380
|
return this.getAccessedValue()[0].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5593
5381
|
}
|
|
5382
|
+
applyDeoptimizations() { }
|
|
5594
5383
|
getAccessedValue() {
|
|
5595
5384
|
if (this.accessedValue === null) {
|
|
5596
5385
|
if (this.kind === 'get') {
|
|
@@ -5604,20 +5393,19 @@ class MethodBase extends NodeBase {
|
|
|
5604
5393
|
return this.accessedValue;
|
|
5605
5394
|
}
|
|
5606
5395
|
}
|
|
5607
|
-
MethodBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5608
|
-
MethodBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5609
5396
|
|
|
5610
5397
|
class MethodDefinition extends MethodBase {
|
|
5611
5398
|
hasEffects(context) {
|
|
5612
5399
|
return super.hasEffects(context) || checkEffectForNodes(this.decorators, context);
|
|
5613
5400
|
}
|
|
5401
|
+
applyDeoptimizations() { }
|
|
5614
5402
|
}
|
|
5615
5403
|
|
|
5616
5404
|
class BlockScope extends ChildScope {
|
|
5617
5405
|
constructor(parent) {
|
|
5618
5406
|
super(parent, parent.context);
|
|
5619
5407
|
}
|
|
5620
|
-
addDeclaration(identifier, context, init,
|
|
5408
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5621
5409
|
if (kind === 'var') {
|
|
5622
5410
|
const name = identifier.name;
|
|
5623
5411
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5629,7 +5417,7 @@ class BlockScope extends ChildScope {
|
|
|
5629
5417
|
}
|
|
5630
5418
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5631
5419
|
}
|
|
5632
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init,
|
|
5420
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
5633
5421
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5634
5422
|
// We cannot call deoptimizePath here.
|
|
5635
5423
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5637,7 +5425,7 @@ class BlockScope extends ChildScope {
|
|
|
5637
5425
|
this.addHoistedVariable(name, declaredVariable);
|
|
5638
5426
|
return declaredVariable;
|
|
5639
5427
|
}
|
|
5640
|
-
return super.addDeclaration(identifier, context, init,
|
|
5428
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
5641
5429
|
}
|
|
5642
5430
|
}
|
|
5643
5431
|
|
|
@@ -5669,12 +5457,33 @@ class StaticBlock extends NodeBase {
|
|
|
5669
5457
|
}
|
|
5670
5458
|
}
|
|
5671
5459
|
}
|
|
5672
|
-
StaticBlock.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5673
|
-
StaticBlock.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5674
5460
|
function isStaticBlock(statement) {
|
|
5675
5461
|
return statement.type === StaticBlock$1;
|
|
5676
5462
|
}
|
|
5677
5463
|
|
|
5464
|
+
class ObjectMember extends ExpressionEntity {
|
|
5465
|
+
constructor(object, key) {
|
|
5466
|
+
super();
|
|
5467
|
+
this.object = object;
|
|
5468
|
+
this.key = key;
|
|
5469
|
+
}
|
|
5470
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5471
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
5472
|
+
}
|
|
5473
|
+
deoptimizePath(path) {
|
|
5474
|
+
this.object.deoptimizePath([this.key, ...path]);
|
|
5475
|
+
}
|
|
5476
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5477
|
+
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
5478
|
+
}
|
|
5479
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5480
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
5481
|
+
}
|
|
5482
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5483
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
5484
|
+
}
|
|
5485
|
+
}
|
|
5486
|
+
|
|
5678
5487
|
class ClassNode extends NodeBase {
|
|
5679
5488
|
constructor() {
|
|
5680
5489
|
super(...arguments);
|
|
@@ -5715,20 +5524,21 @@ class ClassNode extends NodeBase {
|
|
|
5715
5524
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5716
5525
|
}
|
|
5717
5526
|
include(context, includeChildrenRecursively) {
|
|
5718
|
-
if (!this.
|
|
5719
|
-
this.
|
|
5527
|
+
if (!this.deoptimized)
|
|
5528
|
+
this.applyDeoptimizations();
|
|
5529
|
+
this.included = true;
|
|
5720
5530
|
this.superClass?.include(context, includeChildrenRecursively);
|
|
5721
5531
|
this.body.include(context, includeChildrenRecursively);
|
|
5722
5532
|
for (const decorator of this.decorators)
|
|
5723
5533
|
decorator.include(context, includeChildrenRecursively);
|
|
5724
5534
|
if (this.id) {
|
|
5725
5535
|
this.id.markDeclarationReached();
|
|
5726
|
-
this.id.include(
|
|
5536
|
+
this.id.include();
|
|
5727
5537
|
}
|
|
5728
5538
|
}
|
|
5729
5539
|
initialise() {
|
|
5730
5540
|
super.initialise();
|
|
5731
|
-
this.id?.declare('class',
|
|
5541
|
+
this.id?.declare('class', this);
|
|
5732
5542
|
for (const method of this.body.body) {
|
|
5733
5543
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
5734
5544
|
this.classConstructor = method;
|
|
@@ -5786,12 +5596,11 @@ class ClassNode extends NodeBase {
|
|
|
5786
5596
|
staticProperties.unshift({
|
|
5787
5597
|
key: 'prototype',
|
|
5788
5598
|
kind: 'init',
|
|
5789
|
-
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass,
|
|
5599
|
+
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, 'prototype') : OBJECT_PROTOTYPE)
|
|
5790
5600
|
});
|
|
5791
5601
|
return (this.objectEntity = new ObjectEntity(staticProperties, this.superClass || OBJECT_PROTOTYPE));
|
|
5792
5602
|
}
|
|
5793
5603
|
}
|
|
5794
|
-
ClassNode.prototype.includeNode = onlyIncludeSelf;
|
|
5795
5604
|
|
|
5796
5605
|
class ClassDeclaration extends ClassNode {
|
|
5797
5606
|
initialise() {
|
|
@@ -5844,7 +5653,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
5844
5653
|
|
|
5845
5654
|
class ArgumentsVariable extends LocalVariable {
|
|
5846
5655
|
constructor(context) {
|
|
5847
|
-
super('arguments', null, UNKNOWN_EXPRESSION,
|
|
5656
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
5848
5657
|
this.deoptimizedArguments = [];
|
|
5849
5658
|
}
|
|
5850
5659
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -5858,8 +5667,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5858
5667
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5859
5668
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
5860
5669
|
}
|
|
5861
|
-
|
|
5862
|
-
super.
|
|
5670
|
+
include() {
|
|
5671
|
+
super.include();
|
|
5863
5672
|
for (const argument of this.deoptimizedArguments) {
|
|
5864
5673
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
5865
5674
|
}
|
|
@@ -5870,28 +5679,27 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5870
5679
|
const MAX_TRACKED_INTERACTIONS = 20;
|
|
5871
5680
|
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
5872
5681
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
5873
|
-
const EMPTY_PATH_TRACKER = new
|
|
5682
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
5874
5683
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
5875
5684
|
class ParameterVariable extends LocalVariable {
|
|
5876
|
-
constructor(name, declarator,
|
|
5877
|
-
super(name, declarator, UNKNOWN_EXPRESSION,
|
|
5685
|
+
constructor(name, declarator, context) {
|
|
5686
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
5878
5687
|
this.deoptimizationInteractions = [];
|
|
5879
|
-
this.deoptimizations = new
|
|
5688
|
+
this.deoptimizations = new PathTracker();
|
|
5880
5689
|
this.deoptimizedFields = new Set();
|
|
5881
|
-
this.
|
|
5882
|
-
this.
|
|
5690
|
+
this.entitiesToBeDeoptimized = new Set();
|
|
5691
|
+
this.expressionsUseTheKnownValue = [];
|
|
5883
5692
|
this.knownValue = null;
|
|
5884
5693
|
this.knownValueLiteral = UnknownValue;
|
|
5885
5694
|
this.frozenValue = null;
|
|
5886
5695
|
}
|
|
5887
|
-
|
|
5888
|
-
this.updateKnownValue(entity);
|
|
5696
|
+
addEntityToBeDeoptimized(entity) {
|
|
5889
5697
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
5890
5698
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
5891
5699
|
// the interaction cache at this point provided we keep this optimization
|
|
5892
5700
|
// in mind when adding new interactions
|
|
5893
|
-
if (!this.
|
|
5894
|
-
this.
|
|
5701
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5702
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
5895
5703
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
5896
5704
|
deoptimizeInteraction(interaction);
|
|
5897
5705
|
}
|
|
@@ -5901,34 +5709,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
5901
5709
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5902
5710
|
// This means that we already deoptimized all interactions and no longer
|
|
5903
5711
|
// track them
|
|
5904
|
-
entity.deoptimizePath(
|
|
5712
|
+
entity.deoptimizePath(UNKNOWN_PATH);
|
|
5905
5713
|
}
|
|
5906
|
-
else if (!this.
|
|
5907
|
-
this.
|
|
5714
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
5715
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
5908
5716
|
for (const field of this.deoptimizedFields) {
|
|
5909
|
-
entity.deoptimizePath([
|
|
5717
|
+
entity.deoptimizePath([field]);
|
|
5910
5718
|
}
|
|
5911
5719
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
5912
|
-
|
|
5913
|
-
deoptimizeInteraction(interaction);
|
|
5914
|
-
continue;
|
|
5915
|
-
}
|
|
5916
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
5720
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5917
5721
|
}
|
|
5918
5722
|
}
|
|
5919
5723
|
}
|
|
5920
|
-
/** This says we should not make assumptions about the value of the parameter.
|
|
5921
|
-
* This is different from deoptimization that will also cause argument values
|
|
5922
|
-
* to be deoptimized. */
|
|
5923
5724
|
markReassigned() {
|
|
5924
5725
|
if (this.isReassigned) {
|
|
5925
5726
|
return;
|
|
5926
5727
|
}
|
|
5927
5728
|
super.markReassigned();
|
|
5928
|
-
for (const expression of this.
|
|
5729
|
+
for (const expression of this.expressionsUseTheKnownValue) {
|
|
5929
5730
|
expression.deoptimizeCache();
|
|
5930
5731
|
}
|
|
5931
|
-
this.
|
|
5732
|
+
this.expressionsUseTheKnownValue = EMPTY_ARRAY;
|
|
5932
5733
|
}
|
|
5933
5734
|
deoptimizeCache() {
|
|
5934
5735
|
this.markReassigned();
|
|
@@ -5945,7 +5746,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5945
5746
|
}
|
|
5946
5747
|
if (this.knownValue === null) {
|
|
5947
5748
|
this.knownValue = argument;
|
|
5948
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
5749
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5949
5750
|
return;
|
|
5950
5751
|
}
|
|
5951
5752
|
// the same literal or identifier, do nothing
|
|
@@ -5961,7 +5762,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5961
5762
|
return;
|
|
5962
5763
|
}
|
|
5963
5764
|
// add tracking for the new argument
|
|
5964
|
-
const newValue = argument.getLiteralValueAtPath(
|
|
5765
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5965
5766
|
if (newValue !== oldValue) {
|
|
5966
5767
|
this.markReassigned();
|
|
5967
5768
|
}
|
|
@@ -5979,31 +5780,24 @@ class ParameterVariable extends LocalVariable {
|
|
|
5979
5780
|
return this.frozenValue;
|
|
5980
5781
|
}
|
|
5981
5782
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5982
|
-
if (this.isReassigned
|
|
5783
|
+
if (this.isReassigned) {
|
|
5983
5784
|
return UnknownValue;
|
|
5984
5785
|
}
|
|
5985
5786
|
const knownValue = this.getKnownValue();
|
|
5986
|
-
this.
|
|
5987
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(
|
|
5787
|
+
this.expressionsUseTheKnownValue.push(origin);
|
|
5788
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
5988
5789
|
}
|
|
5989
5790
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5990
|
-
|
|
5991
|
-
if (this.isReassigned ||
|
|
5992
|
-
type === INTERACTION_ASSIGNED ||
|
|
5993
|
-
path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5791
|
+
if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) {
|
|
5994
5792
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5995
5793
|
}
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
? context.instantiated
|
|
5999
|
-
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
6000
|
-
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
6001
|
-
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
5794
|
+
const knownValue = this.getKnownValue();
|
|
5795
|
+
return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6002
5796
|
}
|
|
6003
5797
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
6004
5798
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
6005
5799
|
if (path.length >= 2 ||
|
|
6006
|
-
this.
|
|
5800
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
6007
5801
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
6008
5802
|
(path.length === 1 &&
|
|
6009
5803
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
@@ -6012,10 +5806,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
6012
5806
|
return;
|
|
6013
5807
|
}
|
|
6014
5808
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
6015
|
-
for (const entity of this.
|
|
6016
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5809
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5810
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6017
5811
|
}
|
|
6018
|
-
if (!this.
|
|
5812
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
6019
5813
|
this.deoptimizationInteractions.push({
|
|
6020
5814
|
interaction,
|
|
6021
5815
|
path
|
|
@@ -6036,17 +5830,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
6036
5830
|
return;
|
|
6037
5831
|
}
|
|
6038
5832
|
this.deoptimizedFields.add(key);
|
|
6039
|
-
for (const entity of this.
|
|
5833
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
6040
5834
|
// We do not need a recursion tracker here as we already track whether
|
|
6041
5835
|
// this field is deoptimized
|
|
6042
|
-
entity.deoptimizePath([
|
|
5836
|
+
entity.deoptimizePath([key]);
|
|
6043
5837
|
}
|
|
6044
5838
|
if (key === UnknownKey) {
|
|
6045
5839
|
// save some memory
|
|
6046
5840
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
6047
5841
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
6048
5842
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
6049
|
-
this.
|
|
5843
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
6050
5844
|
}
|
|
6051
5845
|
}
|
|
6052
5846
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -6061,14 +5855,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
6061
5855
|
}
|
|
6062
5856
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
6063
5857
|
}
|
|
6064
|
-
includeArgumentPaths(entity, context) {
|
|
6065
|
-
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
6066
|
-
}
|
|
6067
5858
|
}
|
|
6068
5859
|
|
|
6069
5860
|
class ThisVariable extends ParameterVariable {
|
|
6070
5861
|
constructor(context) {
|
|
6071
|
-
super('this', null,
|
|
5862
|
+
super('this', null, context);
|
|
6072
5863
|
}
|
|
6073
5864
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6074
5865
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -6080,7 +5871,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6080
5871
|
super(parent, parent.context);
|
|
6081
5872
|
this.parent = parent;
|
|
6082
5873
|
}
|
|
6083
|
-
addDeclaration(identifier, context, init,
|
|
5874
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6084
5875
|
if (kind === 'var') {
|
|
6085
5876
|
const name = identifier.name;
|
|
6086
5877
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -6093,7 +5884,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6093
5884
|
// the assignment actually goes to the parameter and the var is
|
|
6094
5885
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
6095
5886
|
// parameter
|
|
6096
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION,
|
|
5887
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
6097
5888
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
6098
5889
|
// names. If we ever implement a logic that splits initialization and
|
|
6099
5890
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -6112,7 +5903,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6112
5903
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
6113
5904
|
}
|
|
6114
5905
|
// We only add parameters to parameter scopes
|
|
6115
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init,
|
|
5906
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
6116
5907
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
6117
5908
|
// We cannot call deoptimizePath here.
|
|
6118
5909
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -6120,7 +5911,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6120
5911
|
this.addHoistedVariable(name, declaredVariable);
|
|
6121
5912
|
return declaredVariable;
|
|
6122
5913
|
}
|
|
6123
|
-
return super.addDeclaration(identifier, context, init,
|
|
5914
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
6124
5915
|
}
|
|
6125
5916
|
}
|
|
6126
5917
|
|
|
@@ -6130,7 +5921,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6130
5921
|
}
|
|
6131
5922
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
6132
5923
|
// be redeclared, functions and var can redeclare each other
|
|
6133
|
-
addDeclaration(identifier, context, init,
|
|
5924
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6134
5925
|
const name = identifier.name;
|
|
6135
5926
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6136
5927
|
if (existingVariable) {
|
|
@@ -6142,7 +5933,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6142
5933
|
}
|
|
6143
5934
|
context.error(logRedeclarationError(name), identifier.start);
|
|
6144
5935
|
}
|
|
6145
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5936
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6146
5937
|
this.variables.set(name, newVariable);
|
|
6147
5938
|
return newVariable;
|
|
6148
5939
|
}
|
|
@@ -6151,21 +5942,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6151
5942
|
class ParameterScope extends ChildScope {
|
|
6152
5943
|
constructor(parent, isCatchScope) {
|
|
6153
5944
|
super(parent, parent.context);
|
|
6154
|
-
this.hasRest = false;
|
|
6155
5945
|
this.parameters = [];
|
|
5946
|
+
this.hasRest = false;
|
|
6156
5947
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
6157
5948
|
}
|
|
6158
5949
|
/**
|
|
6159
5950
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
6160
5951
|
* order, i.e. from left to right.
|
|
6161
5952
|
*/
|
|
6162
|
-
addParameterDeclaration(identifier
|
|
5953
|
+
addParameterDeclaration(identifier) {
|
|
6163
5954
|
const { name, start } = identifier;
|
|
6164
5955
|
const existingParameter = this.variables.get(name);
|
|
6165
5956
|
if (existingParameter) {
|
|
6166
5957
|
return this.context.error(logDuplicateArgumentNameError(name), start);
|
|
6167
5958
|
}
|
|
6168
|
-
const variable = new ParameterVariable(name, identifier,
|
|
5959
|
+
const variable = new ParameterVariable(name, identifier, this.context);
|
|
6169
5960
|
this.variables.set(name, variable);
|
|
6170
5961
|
// We also add it to the body scope to detect name conflicts with local
|
|
6171
5962
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -6183,56 +5974,42 @@ class ParameterScope extends ChildScope {
|
|
|
6183
5974
|
}
|
|
6184
5975
|
this.hasRest = hasRest;
|
|
6185
5976
|
}
|
|
6186
|
-
includeCallArguments(context,
|
|
5977
|
+
includeCallArguments(context, parameters) {
|
|
6187
5978
|
let calledFromTryStatement = false;
|
|
6188
5979
|
let argumentIncluded = false;
|
|
6189
5980
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
6190
|
-
const
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
if (argument instanceof SpreadElement && !argumentIncluded) {
|
|
6197
|
-
argumentIncluded = true;
|
|
6198
|
-
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
6199
|
-
}
|
|
6200
|
-
if (argumentIncluded) {
|
|
6201
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6202
|
-
argument.include(context, false);
|
|
5981
|
+
for (const checkedArgument of parameters) {
|
|
5982
|
+
if (checkedArgument instanceof SpreadElement) {
|
|
5983
|
+
for (const argument of parameters) {
|
|
5984
|
+
argument.include(context, false);
|
|
5985
|
+
}
|
|
5986
|
+
break;
|
|
6203
5987
|
}
|
|
6204
5988
|
}
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
6209
|
-
const argument = args[index];
|
|
5989
|
+
for (let index = parameters.length - 1; index >= 0; index--) {
|
|
5990
|
+
const parameterVariables = this.parameters[index] || restParameter;
|
|
5991
|
+
const argument = parameters[index];
|
|
6210
5992
|
if (parameterVariables) {
|
|
6211
5993
|
calledFromTryStatement = false;
|
|
6212
5994
|
if (parameterVariables.length === 0) {
|
|
6213
|
-
// handle empty destructuring
|
|
5995
|
+
// handle empty destructuring
|
|
6214
5996
|
argumentIncluded = true;
|
|
6215
5997
|
}
|
|
6216
5998
|
else {
|
|
6217
5999
|
for (const variable of parameterVariables) {
|
|
6218
|
-
if (variable.calledFromTryStatement) {
|
|
6219
|
-
calledFromTryStatement = true;
|
|
6220
|
-
}
|
|
6221
6000
|
if (variable.included) {
|
|
6222
6001
|
argumentIncluded = true;
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
else {
|
|
6227
|
-
variable.includeArgumentPaths(argument, context);
|
|
6228
|
-
argument.include(context, false);
|
|
6229
|
-
}
|
|
6002
|
+
}
|
|
6003
|
+
if (variable.calledFromTryStatement) {
|
|
6004
|
+
calledFromTryStatement = true;
|
|
6230
6005
|
}
|
|
6231
6006
|
}
|
|
6232
6007
|
}
|
|
6233
6008
|
}
|
|
6234
|
-
if (!
|
|
6009
|
+
if (!argumentIncluded && argument.shouldBeIncluded(context)) {
|
|
6235
6010
|
argumentIncluded = true;
|
|
6011
|
+
}
|
|
6012
|
+
if (argumentIncluded) {
|
|
6236
6013
|
argument.include(context, calledFromTryStatement);
|
|
6237
6014
|
}
|
|
6238
6015
|
}
|
|
@@ -6248,62 +6025,11 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6248
6025
|
addReturnExpression(expression) {
|
|
6249
6026
|
this.returnExpressions.push(expression);
|
|
6250
6027
|
}
|
|
6251
|
-
deoptimizeArgumentsOnCall(interaction) {
|
|
6252
|
-
const { parameters } = this;
|
|
6253
|
-
const { args } = interaction;
|
|
6254
|
-
let position = 0;
|
|
6255
|
-
for (; position < args.length - 1; position++) {
|
|
6256
|
-
// Only the "this" argument arg[0] can be null
|
|
6257
|
-
const argument = args[position + 1];
|
|
6258
|
-
if (argument instanceof SpreadElement) {
|
|
6259
|
-
// This deoptimizes the current and remaining parameters and arguments
|
|
6260
|
-
for (; position < parameters.length; position++) {
|
|
6261
|
-
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
6262
|
-
parameters[position].forEach(variable => variable.markReassigned());
|
|
6263
|
-
}
|
|
6264
|
-
break;
|
|
6265
|
-
}
|
|
6266
|
-
if (this.hasRest && position >= parameters.length - 1) {
|
|
6267
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6268
|
-
}
|
|
6269
|
-
else {
|
|
6270
|
-
const variables = parameters[position];
|
|
6271
|
-
if (variables) {
|
|
6272
|
-
for (const variable of variables) {
|
|
6273
|
-
variable.addArgumentValue(argument);
|
|
6274
|
-
}
|
|
6275
|
-
}
|
|
6276
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
6277
|
-
}
|
|
6278
|
-
}
|
|
6279
|
-
const nonRestParameterLength = this.hasRest ? parameters.length - 1 : parameters.length;
|
|
6280
|
-
for (; position < nonRestParameterLength; position++) {
|
|
6281
|
-
for (const variable of parameters[position]) {
|
|
6282
|
-
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
6283
|
-
}
|
|
6284
|
-
}
|
|
6285
|
-
}
|
|
6286
6028
|
getReturnExpression() {
|
|
6287
6029
|
if (this.returnExpression === null)
|
|
6288
6030
|
this.updateReturnExpression();
|
|
6289
6031
|
return this.returnExpression;
|
|
6290
6032
|
}
|
|
6291
|
-
deoptimizeAllParameters() {
|
|
6292
|
-
for (const parameter of this.parameters) {
|
|
6293
|
-
for (const variable of parameter) {
|
|
6294
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
6295
|
-
variable.markReassigned();
|
|
6296
|
-
}
|
|
6297
|
-
}
|
|
6298
|
-
}
|
|
6299
|
-
reassignAllParameters() {
|
|
6300
|
-
for (const parameter of this.parameters) {
|
|
6301
|
-
for (const variable of parameter) {
|
|
6302
|
-
variable.markReassigned();
|
|
6303
|
-
}
|
|
6304
|
-
}
|
|
6305
|
-
}
|
|
6306
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
6307
6033
|
updateReturnExpression() {
|
|
6308
6034
|
if (this.returnExpressions.length === 1) {
|
|
6309
6035
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -6319,30 +6045,24 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6319
6045
|
|
|
6320
6046
|
class FunctionScope extends ReturnValueScope {
|
|
6321
6047
|
constructor(parent) {
|
|
6322
|
-
super(parent, false);
|
|
6323
6048
|
const { context } = parent;
|
|
6049
|
+
super(parent, false);
|
|
6324
6050
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
6325
6051
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
6326
6052
|
}
|
|
6327
6053
|
findLexicalBoundary() {
|
|
6328
6054
|
return this;
|
|
6329
6055
|
}
|
|
6330
|
-
includeCallArguments(context,
|
|
6331
|
-
super.includeCallArguments(context,
|
|
6056
|
+
includeCallArguments(context, parameters) {
|
|
6057
|
+
super.includeCallArguments(context, parameters);
|
|
6332
6058
|
if (this.argumentsVariable.included) {
|
|
6333
|
-
const
|
|
6334
|
-
|
|
6335
|
-
const argument = args[argumentIndex];
|
|
6336
|
-
if (argument) {
|
|
6337
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6059
|
+
for (const argument of parameters) {
|
|
6060
|
+
if (!argument.included) {
|
|
6338
6061
|
argument.include(context, false);
|
|
6339
6062
|
}
|
|
6340
6063
|
}
|
|
6341
6064
|
}
|
|
6342
6065
|
}
|
|
6343
|
-
addArgumentToBeDeoptimized(argument) {
|
|
6344
|
-
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6345
|
-
}
|
|
6346
6066
|
}
|
|
6347
6067
|
|
|
6348
6068
|
class ExpressionStatement extends NodeBase {
|
|
@@ -6370,9 +6090,8 @@ class ExpressionStatement extends NodeBase {
|
|
|
6370
6090
|
return this.parent.type !== Program$1;
|
|
6371
6091
|
return super.shouldBeIncluded(context);
|
|
6372
6092
|
}
|
|
6093
|
+
applyDeoptimizations() { }
|
|
6373
6094
|
}
|
|
6374
|
-
ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6375
|
-
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6376
6095
|
|
|
6377
6096
|
class BlockStatement extends NodeBase {
|
|
6378
6097
|
get deoptimizeBody() {
|
|
@@ -6437,8 +6156,6 @@ class BlockStatement extends NodeBase {
|
|
|
6437
6156
|
}
|
|
6438
6157
|
}
|
|
6439
6158
|
}
|
|
6440
|
-
BlockStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6441
|
-
BlockStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6442
6159
|
|
|
6443
6160
|
class RestElement extends NodeBase {
|
|
6444
6161
|
constructor() {
|
|
@@ -6448,12 +6165,9 @@ class RestElement extends NodeBase {
|
|
|
6448
6165
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6449
6166
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6450
6167
|
}
|
|
6451
|
-
declare(kind,
|
|
6168
|
+
declare(kind, init) {
|
|
6452
6169
|
this.declarationInit = init;
|
|
6453
|
-
return this.argument.declare(kind,
|
|
6454
|
-
}
|
|
6455
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
6456
|
-
this.argument.deoptimizeAssignment(getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6170
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
6457
6171
|
}
|
|
6458
6172
|
deoptimizePath(path) {
|
|
6459
6173
|
if (path.length === 0) {
|
|
@@ -6464,20 +6178,6 @@ class RestElement extends NodeBase {
|
|
|
6464
6178
|
return (path.length > 0 ||
|
|
6465
6179
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
6466
6180
|
}
|
|
6467
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
6468
|
-
return this.argument.hasEffectsWhenDestructuring(context, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6469
|
-
}
|
|
6470
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
6471
|
-
return (this.included =
|
|
6472
|
-
this.argument.includeDestructuredIfNecessary(context, getIncludedPatternPath$1(destructuredInitPath), init) || this.included);
|
|
6473
|
-
}
|
|
6474
|
-
include(context, includeChildrenRecursively) {
|
|
6475
|
-
if (!this.included)
|
|
6476
|
-
this.includeNode(context);
|
|
6477
|
-
// This should just include the identifier, its properties should be
|
|
6478
|
-
// included where the variable is used.
|
|
6479
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
6480
|
-
}
|
|
6481
6181
|
markDeclarationReached() {
|
|
6482
6182
|
this.argument.markDeclarationReached();
|
|
6483
6183
|
}
|
|
@@ -6489,16 +6189,12 @@ class RestElement extends NodeBase {
|
|
|
6489
6189
|
}
|
|
6490
6190
|
}
|
|
6491
6191
|
}
|
|
6492
|
-
RestElement.prototype.includeNode = onlyIncludeSelf;
|
|
6493
|
-
const getIncludedPatternPath$1 = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
6494
|
-
? destructuredInitPath
|
|
6495
|
-
: [...destructuredInitPath, UnknownKey];
|
|
6496
6192
|
|
|
6497
6193
|
class FunctionBase extends NodeBase {
|
|
6498
6194
|
constructor() {
|
|
6499
6195
|
super(...arguments);
|
|
6196
|
+
this.objectEntity = null;
|
|
6500
6197
|
this.parameterVariableValuesDeoptimized = false;
|
|
6501
|
-
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
6502
6198
|
}
|
|
6503
6199
|
get async() {
|
|
6504
6200
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -6518,9 +6214,53 @@ class FunctionBase extends NodeBase {
|
|
|
6518
6214
|
set generator(value) {
|
|
6519
6215
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
6520
6216
|
}
|
|
6217
|
+
updateParameterVariableValues(_arguments) {
|
|
6218
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
6219
|
+
const parameter = this.params[position];
|
|
6220
|
+
if (!(parameter instanceof Identifier)) {
|
|
6221
|
+
continue;
|
|
6222
|
+
}
|
|
6223
|
+
const parameterVariable = parameter.variable;
|
|
6224
|
+
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
6225
|
+
parameterVariable.updateKnownValue(argument);
|
|
6226
|
+
}
|
|
6227
|
+
}
|
|
6228
|
+
deoptimizeParameterVariableValues() {
|
|
6229
|
+
for (const parameter of this.params) {
|
|
6230
|
+
if (parameter instanceof Identifier) {
|
|
6231
|
+
const parameterVariable = parameter.variable;
|
|
6232
|
+
parameterVariable.markReassigned();
|
|
6233
|
+
}
|
|
6234
|
+
}
|
|
6235
|
+
}
|
|
6521
6236
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6522
|
-
if (interaction.type === INTERACTION_CALLED
|
|
6523
|
-
this.scope
|
|
6237
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
6238
|
+
const { parameters } = this.scope;
|
|
6239
|
+
const { args } = interaction;
|
|
6240
|
+
let hasRest = false;
|
|
6241
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
6242
|
+
const parameter = this.params[position];
|
|
6243
|
+
// Only the "this" argument arg[0] can be null
|
|
6244
|
+
const argument = args[position + 1];
|
|
6245
|
+
if (argument instanceof SpreadElement) {
|
|
6246
|
+
this.deoptimizeParameterVariableValues();
|
|
6247
|
+
}
|
|
6248
|
+
if (hasRest || parameter instanceof RestElement) {
|
|
6249
|
+
hasRest = true;
|
|
6250
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6251
|
+
}
|
|
6252
|
+
else if (parameter instanceof Identifier) {
|
|
6253
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
6254
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6255
|
+
}
|
|
6256
|
+
else if (parameter) {
|
|
6257
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6258
|
+
}
|
|
6259
|
+
else {
|
|
6260
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
this.updateParameterVariableValues(args);
|
|
6524
6264
|
}
|
|
6525
6265
|
else {
|
|
6526
6266
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -6532,7 +6272,12 @@ class FunctionBase extends NodeBase {
|
|
|
6532
6272
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6533
6273
|
// which means the return expression and parameters need to be reassigned
|
|
6534
6274
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
6535
|
-
this.scope.
|
|
6275
|
+
for (const parameterList of this.scope.parameters) {
|
|
6276
|
+
for (const parameter of parameterList) {
|
|
6277
|
+
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
6278
|
+
parameter.markReassigned();
|
|
6279
|
+
}
|
|
6280
|
+
}
|
|
6536
6281
|
}
|
|
6537
6282
|
}
|
|
6538
6283
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6570,13 +6315,8 @@ class FunctionBase extends NodeBase {
|
|
|
6570
6315
|
return true;
|
|
6571
6316
|
}
|
|
6572
6317
|
}
|
|
6573
|
-
const
|
|
6574
|
-
.
|
|
6575
|
-
for (let index = 0; index < this.params.length; index++) {
|
|
6576
|
-
const parameter = this.params[index];
|
|
6577
|
-
if (parameter.hasEffects(context) ||
|
|
6578
|
-
(propertyReadSideEffects &&
|
|
6579
|
-
parameter.hasEffectsWhenDestructuring(context, EMPTY_PATH, interaction.args[index + 1] || UNDEFINED_EXPRESSION)))
|
|
6318
|
+
for (const parameter of this.params) {
|
|
6319
|
+
if (parameter.hasEffects(context))
|
|
6580
6320
|
return true;
|
|
6581
6321
|
}
|
|
6582
6322
|
return false;
|
|
@@ -6595,17 +6335,21 @@ class FunctionBase extends NodeBase {
|
|
|
6595
6335
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
6596
6336
|
}
|
|
6597
6337
|
include(context, includeChildrenRecursively) {
|
|
6598
|
-
if (!this.
|
|
6599
|
-
this.includeNode(context);
|
|
6600
|
-
if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) {
|
|
6338
|
+
if (!this.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) {
|
|
6601
6339
|
this.parameterVariableValuesDeoptimized = true;
|
|
6602
|
-
this.
|
|
6340
|
+
this.deoptimizeParameterVariableValues();
|
|
6603
6341
|
}
|
|
6342
|
+
if (!this.deoptimized)
|
|
6343
|
+
this.applyDeoptimizations();
|
|
6344
|
+
this.included = true;
|
|
6604
6345
|
const { brokenFlow } = context;
|
|
6605
6346
|
context.brokenFlow = false;
|
|
6606
6347
|
this.body.include(context, includeChildrenRecursively);
|
|
6607
6348
|
context.brokenFlow = brokenFlow;
|
|
6608
6349
|
}
|
|
6350
|
+
includeCallArguments(context, parameters) {
|
|
6351
|
+
this.scope.includeCallArguments(context, parameters);
|
|
6352
|
+
}
|
|
6609
6353
|
initialise() {
|
|
6610
6354
|
super.initialise();
|
|
6611
6355
|
if (this.body instanceof BlockStatement) {
|
|
@@ -6627,14 +6371,14 @@ class FunctionBase extends NodeBase {
|
|
|
6627
6371
|
// so that the scope already knows all parameters and can detect conflicts
|
|
6628
6372
|
// when parsing the body.
|
|
6629
6373
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
6630
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
6374
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6631
6375
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
6632
6376
|
return super.parseNode(esTreeNode);
|
|
6633
6377
|
}
|
|
6378
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
6379
|
+
applyDeoptimizations() { }
|
|
6634
6380
|
}
|
|
6635
6381
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
6636
|
-
FunctionBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6637
|
-
FunctionBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6638
6382
|
|
|
6639
6383
|
class FunctionNode extends FunctionBase {
|
|
6640
6384
|
constructor() {
|
|
@@ -6646,16 +6390,18 @@ class FunctionNode extends FunctionBase {
|
|
|
6646
6390
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
6647
6391
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6648
6392
|
// constructed entity.
|
|
6649
|
-
this.scope.thisVariable.
|
|
6393
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
|
|
6650
6394
|
}
|
|
6651
6395
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6652
6396
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6653
6397
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
6654
6398
|
// args[0] is the "this" argument
|
|
6655
|
-
this.scope.thisVariable.
|
|
6399
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
6656
6400
|
}
|
|
6657
6401
|
}
|
|
6658
6402
|
hasEffects(context) {
|
|
6403
|
+
if (!this.deoptimized)
|
|
6404
|
+
this.applyDeoptimizations();
|
|
6659
6405
|
if (this.annotationNoSideEffects) {
|
|
6660
6406
|
return false;
|
|
6661
6407
|
}
|
|
@@ -6693,7 +6439,7 @@ class FunctionNode extends FunctionBase {
|
|
|
6693
6439
|
}
|
|
6694
6440
|
include(context, includeChildrenRecursively) {
|
|
6695
6441
|
super.include(context, includeChildrenRecursively);
|
|
6696
|
-
this.id?.include(
|
|
6442
|
+
this.id?.include();
|
|
6697
6443
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
6698
6444
|
for (const parameter of this.params) {
|
|
6699
6445
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
@@ -6701,18 +6447,12 @@ class FunctionNode extends FunctionBase {
|
|
|
6701
6447
|
}
|
|
6702
6448
|
}
|
|
6703
6449
|
}
|
|
6704
|
-
includeNode(context) {
|
|
6705
|
-
this.included = true;
|
|
6706
|
-
const hasArguments = this.scope.argumentsVariable.included;
|
|
6707
|
-
for (const parameter of this.params) {
|
|
6708
|
-
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
6709
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
6710
|
-
}
|
|
6711
|
-
}
|
|
6712
|
-
}
|
|
6713
6450
|
initialise() {
|
|
6714
6451
|
super.initialise();
|
|
6715
|
-
this.id?.declare('function',
|
|
6452
|
+
this.id?.declare('function', this);
|
|
6453
|
+
}
|
|
6454
|
+
addArgumentToBeDeoptimized(argument) {
|
|
6455
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6716
6456
|
}
|
|
6717
6457
|
getObjectEntity() {
|
|
6718
6458
|
if (this.objectEntity !== null) {
|
|
@@ -6762,16 +6502,11 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
6762
6502
|
}
|
|
6763
6503
|
class ExportDefaultDeclaration extends NodeBase {
|
|
6764
6504
|
include(context, includeChildrenRecursively) {
|
|
6765
|
-
|
|
6766
|
-
this.declaration.include(context, includeChildrenRecursively);
|
|
6505
|
+
super.include(context, includeChildrenRecursively);
|
|
6767
6506
|
if (includeChildrenRecursively) {
|
|
6768
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
6507
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
6769
6508
|
}
|
|
6770
6509
|
}
|
|
6771
|
-
includePath(path, context) {
|
|
6772
|
-
this.included = true;
|
|
6773
|
-
this.declaration.includePath(path, context);
|
|
6774
|
-
}
|
|
6775
6510
|
initialise() {
|
|
6776
6511
|
super.initialise();
|
|
6777
6512
|
const declaration = this.declaration;
|
|
@@ -6816,6 +6551,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6816
6551
|
}
|
|
6817
6552
|
this.declaration.render(code, options);
|
|
6818
6553
|
}
|
|
6554
|
+
applyDeoptimizations() { }
|
|
6819
6555
|
renderNamedDeclaration(code, declarationStart, idInsertPosition, options) {
|
|
6820
6556
|
const { exportNamesByVariable, format, snippets: { getPropertyAccess } } = options;
|
|
6821
6557
|
const name = this.variable.getName(getPropertyAccess);
|
|
@@ -6846,8 +6582,6 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6846
6582
|
}
|
|
6847
6583
|
}
|
|
6848
6584
|
ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
6849
|
-
ExportDefaultDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6850
|
-
ExportDefaultDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6851
6585
|
|
|
6852
6586
|
const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
|
|
6853
6587
|
const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
|
|
@@ -7117,7 +6851,6 @@ class Literal extends NodeBase {
|
|
|
7117
6851
|
}
|
|
7118
6852
|
}
|
|
7119
6853
|
}
|
|
7120
|
-
Literal.prototype.includeNode = onlyIncludeSelf;
|
|
7121
6854
|
|
|
7122
6855
|
function getChainElementLiteralValueAtPath(element, object, path, recursionTracker, origin) {
|
|
7123
6856
|
if ('getLiteralValueAtPathAsChainElement' in object) {
|
|
@@ -7133,6 +6866,8 @@ function getChainElementLiteralValueAtPath(element, object, path, recursionTrack
|
|
|
7133
6866
|
return element.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7134
6867
|
}
|
|
7135
6868
|
|
|
6869
|
+
// To avoid infinite recursions
|
|
6870
|
+
const MAX_PATH_DEPTH = 7;
|
|
7136
6871
|
function getResolvablePropertyKey(memberExpression) {
|
|
7137
6872
|
return memberExpression.computed
|
|
7138
6873
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -7231,27 +6966,18 @@ class MemberExpression extends NodeBase {
|
|
|
7231
6966
|
}
|
|
7232
6967
|
else if (!this.isUndefined) {
|
|
7233
6968
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7234
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
6969
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
7235
6970
|
}
|
|
7236
6971
|
else {
|
|
7237
6972
|
deoptimizeInteraction(interaction);
|
|
7238
6973
|
}
|
|
7239
6974
|
}
|
|
7240
6975
|
}
|
|
7241
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
7242
|
-
this.deoptimizePath(EMPTY_PATH);
|
|
7243
|
-
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
7244
|
-
}
|
|
7245
6976
|
deoptimizeCache() {
|
|
7246
|
-
if (this.propertyKey === this.dynamicPropertyKey)
|
|
7247
|
-
return;
|
|
7248
6977
|
const { expressionsToBeDeoptimized, object } = this;
|
|
7249
6978
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
7250
|
-
this.
|
|
6979
|
+
this.propertyKey = UnknownKey;
|
|
7251
6980
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
7252
|
-
if (this.included) {
|
|
7253
|
-
object.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
7254
|
-
}
|
|
7255
6981
|
for (const expression of expressionsToBeDeoptimized) {
|
|
7256
6982
|
expression.deoptimizeCache();
|
|
7257
6983
|
}
|
|
@@ -7262,13 +6988,11 @@ class MemberExpression extends NodeBase {
|
|
|
7262
6988
|
if (this.variable) {
|
|
7263
6989
|
this.variable.deoptimizePath(path);
|
|
7264
6990
|
}
|
|
7265
|
-
else if (!this.isUndefined) {
|
|
7266
|
-
const
|
|
6991
|
+
else if (!this.isUndefined && path.length < MAX_PATH_DEPTH) {
|
|
6992
|
+
const propertyKey = this.getPropertyKey();
|
|
7267
6993
|
this.object.deoptimizePath([
|
|
7268
6994
|
propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey,
|
|
7269
|
-
...
|
|
7270
|
-
? path
|
|
7271
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
6995
|
+
...path
|
|
7272
6996
|
]);
|
|
7273
6997
|
}
|
|
7274
6998
|
}
|
|
@@ -7279,11 +7003,9 @@ class MemberExpression extends NodeBase {
|
|
|
7279
7003
|
if (this.isUndefined) {
|
|
7280
7004
|
return undefined;
|
|
7281
7005
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7286
|
-
return this.object.getLiteralValueAtPath([propertyKey, ...path], recursionTracker, origin);
|
|
7006
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7007
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7008
|
+
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
7287
7009
|
}
|
|
7288
7010
|
return UnknownValue;
|
|
7289
7011
|
}
|
|
@@ -7303,11 +7025,9 @@ class MemberExpression extends NodeBase {
|
|
|
7303
7025
|
if (this.isUndefined) {
|
|
7304
7026
|
return [UNDEFINED_EXPRESSION, false];
|
|
7305
7027
|
}
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7310
|
-
return this.object.getReturnExpressionWhenCalledAtPath([propertyKey, ...path], interaction, recursionTracker, origin);
|
|
7028
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7029
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7030
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
7311
7031
|
}
|
|
7312
7032
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
7313
7033
|
}
|
|
@@ -7353,45 +7073,14 @@ class MemberExpression extends NodeBase {
|
|
|
7353
7073
|
return true;
|
|
7354
7074
|
}
|
|
7355
7075
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7356
|
-
return this.object.hasEffectsOnInteractionAtPath([this.
|
|
7076
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
7357
7077
|
}
|
|
7358
7078
|
return true;
|
|
7359
7079
|
}
|
|
7360
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
7361
|
-
return (destructuredInitPath.length > 0 &&
|
|
7362
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7363
|
-
}
|
|
7364
7080
|
include(context, includeChildrenRecursively) {
|
|
7365
|
-
if (!this.included)
|
|
7366
|
-
this.includeNode(context);
|
|
7367
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7368
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7369
|
-
}
|
|
7370
|
-
includeNode(context) {
|
|
7371
|
-
this.included = true;
|
|
7372
7081
|
if (!this.deoptimized)
|
|
7373
7082
|
this.applyDeoptimizations();
|
|
7374
|
-
|
|
7375
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
7376
|
-
}
|
|
7377
|
-
else if (!this.isUndefined) {
|
|
7378
|
-
this.object.includePath([this.propertyKey], context);
|
|
7379
|
-
}
|
|
7380
|
-
}
|
|
7381
|
-
includePath(path, context) {
|
|
7382
|
-
if (!this.included)
|
|
7383
|
-
this.includeNode(context);
|
|
7384
|
-
if (this.variable) {
|
|
7385
|
-
this.variable?.includePath(path, context);
|
|
7386
|
-
}
|
|
7387
|
-
else if (!this.isUndefined) {
|
|
7388
|
-
this.object.includePath([
|
|
7389
|
-
this.propertyKey,
|
|
7390
|
-
...(path.length < MAX_PATH_DEPTH
|
|
7391
|
-
? path
|
|
7392
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
7393
|
-
], context);
|
|
7394
|
-
}
|
|
7083
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7395
7084
|
}
|
|
7396
7085
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
7397
7086
|
if (!this.assignmentDeoptimized)
|
|
@@ -7400,34 +7089,20 @@ class MemberExpression extends NodeBase {
|
|
|
7400
7089
|
this.include(context, includeChildrenRecursively);
|
|
7401
7090
|
}
|
|
7402
7091
|
else {
|
|
7403
|
-
|
|
7404
|
-
this.includeNode(context);
|
|
7405
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7406
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7092
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7407
7093
|
}
|
|
7408
7094
|
}
|
|
7409
|
-
includeCallArguments(context,
|
|
7095
|
+
includeCallArguments(context, parameters) {
|
|
7410
7096
|
if (this.variable) {
|
|
7411
|
-
this.variable.includeCallArguments(context,
|
|
7097
|
+
this.variable.includeCallArguments(context, parameters);
|
|
7412
7098
|
}
|
|
7413
7099
|
else {
|
|
7414
|
-
super.includeCallArguments(context,
|
|
7415
|
-
}
|
|
7416
|
-
}
|
|
7417
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
7418
|
-
if ((this.included ||=
|
|
7419
|
-
destructuredInitPath.length > 0 &&
|
|
7420
|
-
!context.brokenFlow &&
|
|
7421
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext()))) {
|
|
7422
|
-
init.include(context, false);
|
|
7423
|
-
return true;
|
|
7100
|
+
super.includeCallArguments(context, parameters);
|
|
7424
7101
|
}
|
|
7425
|
-
return false;
|
|
7426
7102
|
}
|
|
7427
7103
|
initialise() {
|
|
7428
7104
|
super.initialise();
|
|
7429
|
-
this.
|
|
7430
|
-
this.propertyKey = this.dynamicPropertyKey === null ? UnknownKey : this.dynamicPropertyKey;
|
|
7105
|
+
this.propertyKey = getResolvablePropertyKey(this);
|
|
7431
7106
|
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
7432
7107
|
}
|
|
7433
7108
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
@@ -7464,7 +7139,8 @@ class MemberExpression extends NodeBase {
|
|
|
7464
7139
|
this.bound &&
|
|
7465
7140
|
propertyReadSideEffects &&
|
|
7466
7141
|
!(this.variable || this.isUndefined)) {
|
|
7467
|
-
this.
|
|
7142
|
+
const propertyKey = this.getPropertyKey();
|
|
7143
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
7468
7144
|
this.scope.context.requestTreeshakingPass();
|
|
7469
7145
|
}
|
|
7470
7146
|
if (this.variable) {
|
|
@@ -7481,7 +7157,7 @@ class MemberExpression extends NodeBase {
|
|
|
7481
7157
|
this.bound &&
|
|
7482
7158
|
propertyReadSideEffects &&
|
|
7483
7159
|
!(this.variable || this.isUndefined)) {
|
|
7484
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.
|
|
7160
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
7485
7161
|
this.scope.context.requestTreeshakingPass();
|
|
7486
7162
|
}
|
|
7487
7163
|
}
|
|
@@ -7490,24 +7166,24 @@ class MemberExpression extends NodeBase {
|
|
|
7490
7166
|
const variable = this.scope.findVariable(this.object.name);
|
|
7491
7167
|
if (variable.isNamespace) {
|
|
7492
7168
|
if (this.variable) {
|
|
7493
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7169
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7494
7170
|
}
|
|
7495
7171
|
this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
7496
7172
|
}
|
|
7497
7173
|
}
|
|
7498
7174
|
}
|
|
7499
|
-
|
|
7500
|
-
if (this.
|
|
7501
|
-
this.
|
|
7175
|
+
getPropertyKey() {
|
|
7176
|
+
if (this.propertyKey === null) {
|
|
7177
|
+
this.propertyKey = UnknownKey;
|
|
7502
7178
|
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7503
|
-
return (this.
|
|
7179
|
+
return (this.propertyKey =
|
|
7504
7180
|
value === SymbolToStringTag
|
|
7505
7181
|
? value
|
|
7506
7182
|
: typeof value === 'symbol'
|
|
7507
7183
|
? UnknownKey
|
|
7508
7184
|
: String(value));
|
|
7509
7185
|
}
|
|
7510
|
-
return this.
|
|
7186
|
+
return this.propertyKey;
|
|
7511
7187
|
}
|
|
7512
7188
|
hasAccessEffect(context) {
|
|
7513
7189
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -7515,7 +7191,17 @@ class MemberExpression extends NodeBase {
|
|
|
7515
7191
|
return (!(this.variable || this.isUndefined) &&
|
|
7516
7192
|
propertyReadSideEffects &&
|
|
7517
7193
|
(propertyReadSideEffects === 'always' ||
|
|
7518
|
-
this.object.hasEffectsOnInteractionAtPath([this.
|
|
7194
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
7195
|
+
}
|
|
7196
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
7197
|
+
if (!this.included) {
|
|
7198
|
+
this.included = true;
|
|
7199
|
+
if (this.variable) {
|
|
7200
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7201
|
+
}
|
|
7202
|
+
}
|
|
7203
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7204
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7519
7205
|
}
|
|
7520
7206
|
}
|
|
7521
7207
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -7559,20 +7245,18 @@ class MetaProperty extends NodeBase {
|
|
|
7559
7245
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
7560
7246
|
}
|
|
7561
7247
|
include() {
|
|
7562
|
-
if (!this.included)
|
|
7563
|
-
this.
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7575
|
-
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7248
|
+
if (!this.included) {
|
|
7249
|
+
this.included = true;
|
|
7250
|
+
if (this.meta.name === IMPORT) {
|
|
7251
|
+
this.scope.context.addImportMeta(this);
|
|
7252
|
+
const parent = this.parent;
|
|
7253
|
+
const metaProperty = (this.metaProperty =
|
|
7254
|
+
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
7255
|
+
? parent.propertyKey
|
|
7256
|
+
: null);
|
|
7257
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7258
|
+
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7259
|
+
}
|
|
7576
7260
|
}
|
|
7577
7261
|
}
|
|
7578
7262
|
}
|
|
@@ -7679,7 +7363,7 @@ class UndefinedVariable extends Variable {
|
|
|
7679
7363
|
|
|
7680
7364
|
class ExportDefaultVariable extends LocalVariable {
|
|
7681
7365
|
constructor(name, exportDefaultDeclaration, context) {
|
|
7682
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration,
|
|
7366
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
7683
7367
|
this.hasId = false;
|
|
7684
7368
|
this.originalId = null;
|
|
7685
7369
|
this.originalVariable = null;
|
|
@@ -7828,8 +7512,8 @@ class NamespaceVariable extends Variable {
|
|
|
7828
7512
|
return (!memberVariable ||
|
|
7829
7513
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
7830
7514
|
}
|
|
7831
|
-
|
|
7832
|
-
super.
|
|
7515
|
+
include() {
|
|
7516
|
+
super.include();
|
|
7833
7517
|
this.context.includeAllExports();
|
|
7834
7518
|
}
|
|
7835
7519
|
prepare(accessedGlobalsByScope) {
|
|
@@ -7922,9 +7606,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
7922
7606
|
getName(getPropertyAccess) {
|
|
7923
7607
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
7924
7608
|
}
|
|
7925
|
-
|
|
7926
|
-
super.
|
|
7927
|
-
this.context.includeVariableInModule(this.syntheticNamespace
|
|
7609
|
+
include() {
|
|
7610
|
+
super.include();
|
|
7611
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
7928
7612
|
}
|
|
7929
7613
|
setRenderNames(baseName, name) {
|
|
7930
7614
|
super.setRenderNames(baseName, name);
|
|
@@ -11100,11 +10784,17 @@ const createFilter = function createFilter(include, exclude, options) {
|
|
|
11100
10784
|
const pathId = normalizePath(id);
|
|
11101
10785
|
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
11102
10786
|
const matcher = excludeMatchers[i];
|
|
10787
|
+
if (matcher instanceof RegExp) {
|
|
10788
|
+
matcher.lastIndex = 0;
|
|
10789
|
+
}
|
|
11103
10790
|
if (matcher.test(pathId))
|
|
11104
10791
|
return false;
|
|
11105
10792
|
}
|
|
11106
10793
|
for (let i = 0; i < includeMatchers.length; ++i) {
|
|
11107
10794
|
const matcher = includeMatchers[i];
|
|
10795
|
+
if (matcher instanceof RegExp) {
|
|
10796
|
+
matcher.lastIndex = 0;
|
|
10797
|
+
}
|
|
11108
10798
|
if (matcher.test(pathId))
|
|
11109
10799
|
return true;
|
|
11110
10800
|
}
|
|
@@ -11123,37 +10813,21 @@ class ArrayPattern extends NodeBase {
|
|
|
11123
10813
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
11124
10814
|
}
|
|
11125
10815
|
}
|
|
11126
|
-
declare(kind
|
|
10816
|
+
declare(kind) {
|
|
11127
10817
|
const variables = [];
|
|
11128
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11129
10818
|
for (const element of this.elements) {
|
|
11130
10819
|
if (element !== null) {
|
|
11131
|
-
variables.push(...element.declare(kind,
|
|
10820
|
+
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
|
|
11132
10821
|
}
|
|
11133
10822
|
}
|
|
11134
10823
|
return variables;
|
|
11135
10824
|
}
|
|
11136
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11137
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11138
|
-
for (const element of this.elements) {
|
|
11139
|
-
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
11140
|
-
}
|
|
11141
|
-
}
|
|
11142
10825
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
11143
10826
|
deoptimizePath() {
|
|
11144
10827
|
for (const element of this.elements) {
|
|
11145
10828
|
element?.deoptimizePath(EMPTY_PATH);
|
|
11146
10829
|
}
|
|
11147
10830
|
}
|
|
11148
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11149
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11150
|
-
for (const element of this.elements) {
|
|
11151
|
-
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
11152
|
-
return true;
|
|
11153
|
-
}
|
|
11154
|
-
}
|
|
11155
|
-
return false;
|
|
11156
|
-
}
|
|
11157
10831
|
// Patterns are only checked at the empty path at the moment
|
|
11158
10832
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
11159
10833
|
for (const element of this.elements) {
|
|
@@ -11162,38 +10836,12 @@ class ArrayPattern extends NodeBase {
|
|
|
11162
10836
|
}
|
|
11163
10837
|
return false;
|
|
11164
10838
|
}
|
|
11165
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11166
|
-
let included = false;
|
|
11167
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11168
|
-
for (const element of this.elements) {
|
|
11169
|
-
if (element) {
|
|
11170
|
-
element.included ||= included;
|
|
11171
|
-
included =
|
|
11172
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
11173
|
-
}
|
|
11174
|
-
}
|
|
11175
|
-
if (included) {
|
|
11176
|
-
// This is necessary so that if any pattern element is included, all are
|
|
11177
|
-
// included for proper deconflicting
|
|
11178
|
-
for (const element of this.elements) {
|
|
11179
|
-
if (element && !element.included) {
|
|
11180
|
-
element.included = true;
|
|
11181
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init);
|
|
11182
|
-
}
|
|
11183
|
-
}
|
|
11184
|
-
}
|
|
11185
|
-
return (this.included ||= included);
|
|
11186
|
-
}
|
|
11187
10839
|
markDeclarationReached() {
|
|
11188
10840
|
for (const element of this.elements) {
|
|
11189
10841
|
element?.markDeclarationReached();
|
|
11190
10842
|
}
|
|
11191
10843
|
}
|
|
11192
10844
|
}
|
|
11193
|
-
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
11194
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
11195
|
-
? destructuredInitPath
|
|
11196
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
11197
10845
|
|
|
11198
10846
|
class ArrowFunctionExpression extends FunctionBase {
|
|
11199
10847
|
constructor() {
|
|
@@ -11210,6 +10858,8 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11210
10858
|
this.scope = new ReturnValueScope(parentScope, false);
|
|
11211
10859
|
}
|
|
11212
10860
|
hasEffects() {
|
|
10861
|
+
if (!this.deoptimized)
|
|
10862
|
+
this.applyDeoptimizations();
|
|
11213
10863
|
return false;
|
|
11214
10864
|
}
|
|
11215
10865
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -11248,15 +10898,6 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11248
10898
|
}
|
|
11249
10899
|
}
|
|
11250
10900
|
}
|
|
11251
|
-
includeNode(context) {
|
|
11252
|
-
this.included = true;
|
|
11253
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
11254
|
-
for (const parameter of this.params) {
|
|
11255
|
-
if (!(parameter instanceof Identifier)) {
|
|
11256
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
11257
|
-
}
|
|
11258
|
-
}
|
|
11259
|
-
}
|
|
11260
10901
|
getObjectEntity() {
|
|
11261
10902
|
if (this.objectEntity !== null) {
|
|
11262
10903
|
return this.objectEntity;
|
|
@@ -11276,18 +10917,13 @@ class ObjectPattern extends NodeBase {
|
|
|
11276
10917
|
}
|
|
11277
10918
|
}
|
|
11278
10919
|
}
|
|
11279
|
-
declare(kind,
|
|
10920
|
+
declare(kind, init) {
|
|
11280
10921
|
const variables = [];
|
|
11281
10922
|
for (const property of this.properties) {
|
|
11282
|
-
variables.push(...property.declare(kind,
|
|
10923
|
+
variables.push(...property.declare(kind, init));
|
|
11283
10924
|
}
|
|
11284
10925
|
return variables;
|
|
11285
10926
|
}
|
|
11286
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11287
|
-
for (const property of this.properties) {
|
|
11288
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
11289
|
-
}
|
|
11290
|
-
}
|
|
11291
10927
|
deoptimizePath(path) {
|
|
11292
10928
|
if (path.length === 0) {
|
|
11293
10929
|
for (const property of this.properties) {
|
|
@@ -11305,46 +10941,12 @@ class ObjectPattern extends NodeBase {
|
|
|
11305
10941
|
}
|
|
11306
10942
|
return false;
|
|
11307
10943
|
}
|
|
11308
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11309
|
-
for (const property of this.properties) {
|
|
11310
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
11311
|
-
return true;
|
|
11312
|
-
}
|
|
11313
|
-
return false;
|
|
11314
|
-
}
|
|
11315
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11316
|
-
let included = false;
|
|
11317
|
-
for (const property of this.properties) {
|
|
11318
|
-
included =
|
|
11319
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
11320
|
-
}
|
|
11321
|
-
return (this.included ||= included);
|
|
11322
|
-
}
|
|
11323
10944
|
markDeclarationReached() {
|
|
11324
10945
|
for (const property of this.properties) {
|
|
11325
10946
|
property.markDeclarationReached();
|
|
11326
10947
|
}
|
|
11327
10948
|
}
|
|
11328
|
-
render(code, options) {
|
|
11329
|
-
if (this.properties.length > 0) {
|
|
11330
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
11331
|
-
let lastSeparatorPos = null;
|
|
11332
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
11333
|
-
if (!node.included) {
|
|
11334
|
-
treeshakeNode(node, code, start, end);
|
|
11335
|
-
continue;
|
|
11336
|
-
}
|
|
11337
|
-
lastSeparatorPos = separator;
|
|
11338
|
-
node.render(code, options);
|
|
11339
|
-
}
|
|
11340
|
-
if (lastSeparatorPos) {
|
|
11341
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
11342
|
-
}
|
|
11343
|
-
}
|
|
11344
|
-
}
|
|
11345
10949
|
}
|
|
11346
|
-
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11347
|
-
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11348
10950
|
|
|
11349
10951
|
class AssignmentExpression extends NodeBase {
|
|
11350
10952
|
hasEffects(context) {
|
|
@@ -11353,9 +10955,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
11353
10955
|
this.applyDeoptimizations();
|
|
11354
10956
|
// MemberExpressions do not access the property before assignments if the
|
|
11355
10957
|
// operator is '='.
|
|
11356
|
-
return (right.hasEffects(context) ||
|
|
11357
|
-
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
11358
|
-
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
10958
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, operator !== '='));
|
|
11359
10959
|
}
|
|
11360
10960
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11361
10961
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -11364,24 +10964,15 @@ class AssignmentExpression extends NodeBase {
|
|
|
11364
10964
|
const { deoptimized, left, right, operator } = this;
|
|
11365
10965
|
if (!deoptimized)
|
|
11366
10966
|
this.applyDeoptimizations();
|
|
11367
|
-
|
|
11368
|
-
this.includeNode(context);
|
|
11369
|
-
const hasEffectsContext = createHasEffectsContext();
|
|
10967
|
+
this.included = true;
|
|
11370
10968
|
if (includeChildrenRecursively ||
|
|
11371
10969
|
operator !== '=' ||
|
|
11372
10970
|
left.included ||
|
|
11373
|
-
left.hasEffectsAsAssignmentTarget(
|
|
11374
|
-
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
10971
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
11375
10972
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
11376
10973
|
}
|
|
11377
10974
|
right.include(context, includeChildrenRecursively);
|
|
11378
10975
|
}
|
|
11379
|
-
includeNode(context) {
|
|
11380
|
-
this.included = true;
|
|
11381
|
-
if (!this.deoptimized)
|
|
11382
|
-
this.applyDeoptimizations();
|
|
11383
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11384
|
-
}
|
|
11385
10976
|
initialise() {
|
|
11386
10977
|
super.initialise();
|
|
11387
10978
|
if (this.left instanceof Identifier) {
|
|
@@ -11442,7 +11033,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
11442
11033
|
}
|
|
11443
11034
|
applyDeoptimizations() {
|
|
11444
11035
|
this.deoptimized = true;
|
|
11445
|
-
this.left.
|
|
11036
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
11037
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
11446
11038
|
this.scope.context.requestTreeshakingPass();
|
|
11447
11039
|
}
|
|
11448
11040
|
}
|
|
@@ -11451,42 +11043,16 @@ class AssignmentPattern extends NodeBase {
|
|
|
11451
11043
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11452
11044
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11453
11045
|
}
|
|
11454
|
-
declare(kind,
|
|
11455
|
-
return this.left.declare(kind,
|
|
11456
|
-
}
|
|
11457
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11458
|
-
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
11046
|
+
declare(kind, init) {
|
|
11047
|
+
return this.left.declare(kind, init);
|
|
11459
11048
|
}
|
|
11460
11049
|
deoptimizePath(path) {
|
|
11461
11050
|
if (path.length === 0) {
|
|
11462
11051
|
this.left.deoptimizePath(path);
|
|
11463
|
-
}
|
|
11464
|
-
}
|
|
11465
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11466
|
-
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11467
|
-
}
|
|
11468
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11469
|
-
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
11470
|
-
}
|
|
11471
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11472
|
-
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
11473
|
-
this.included;
|
|
11474
|
-
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
11475
|
-
this.right.include(context, false);
|
|
11476
|
-
if (!this.left.included) {
|
|
11477
|
-
this.left.included = true;
|
|
11478
|
-
// Unfortunately, we need to include the left side again now, so that
|
|
11479
|
-
// any declared variables are properly included.
|
|
11480
|
-
this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
11481
|
-
}
|
|
11482
|
-
}
|
|
11483
|
-
return (this.included = included);
|
|
11484
|
-
}
|
|
11485
|
-
includeNode(context) {
|
|
11486
|
-
this.included = true;
|
|
11487
|
-
if (!this.deoptimized)
|
|
11488
|
-
this.applyDeoptimizations();
|
|
11489
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11052
|
+
}
|
|
11053
|
+
}
|
|
11054
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11055
|
+
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11490
11056
|
}
|
|
11491
11057
|
markDeclarationReached() {
|
|
11492
11058
|
this.left.markDeclarationReached();
|
|
@@ -11510,34 +11076,22 @@ class AwaitExpression extends NodeBase {
|
|
|
11510
11076
|
return true;
|
|
11511
11077
|
}
|
|
11512
11078
|
include(context, includeChildrenRecursively) {
|
|
11513
|
-
if (!this.included)
|
|
11514
|
-
this.includeNode(context);
|
|
11515
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
11516
|
-
}
|
|
11517
|
-
includeNode(context) {
|
|
11518
|
-
this.included = true;
|
|
11519
11079
|
if (!this.deoptimized)
|
|
11520
11080
|
this.applyDeoptimizations();
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11081
|
+
if (!this.included) {
|
|
11082
|
+
this.included = true;
|
|
11083
|
+
checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
|
|
11084
|
+
let parent = this.parent;
|
|
11085
|
+
do {
|
|
11086
|
+
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
11087
|
+
break checkTopLevelAwait;
|
|
11088
|
+
} while ((parent = parent.parent));
|
|
11089
|
+
this.scope.context.usesTopLevelAwait = true;
|
|
11090
|
+
}
|
|
11528
11091
|
}
|
|
11529
|
-
|
|
11530
|
-
this.argument.includePath(THEN_PATH, context);
|
|
11531
|
-
}
|
|
11532
|
-
includePath(path, context) {
|
|
11533
|
-
if (!this.deoptimized)
|
|
11534
|
-
this.applyDeoptimizations();
|
|
11535
|
-
if (!this.included)
|
|
11536
|
-
this.includeNode(context);
|
|
11537
|
-
this.argument.includePath(path, context);
|
|
11092
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11538
11093
|
}
|
|
11539
11094
|
}
|
|
11540
|
-
const THEN_PATH = ['then'];
|
|
11541
11095
|
|
|
11542
11096
|
const binaryOperators = {
|
|
11543
11097
|
'!=': (left, right) => left != right,
|
|
@@ -11601,8 +11155,6 @@ class BinaryExpression extends NodeBase {
|
|
|
11601
11155
|
this.right.render(code, options);
|
|
11602
11156
|
}
|
|
11603
11157
|
}
|
|
11604
|
-
BinaryExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11605
|
-
BinaryExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11606
11158
|
|
|
11607
11159
|
class BreakStatement extends NodeBase {
|
|
11608
11160
|
hasEffects(context) {
|
|
@@ -11622,7 +11174,7 @@ class BreakStatement extends NodeBase {
|
|
|
11622
11174
|
include(context) {
|
|
11623
11175
|
this.included = true;
|
|
11624
11176
|
if (this.label) {
|
|
11625
|
-
this.label.include(
|
|
11177
|
+
this.label.include();
|
|
11626
11178
|
context.includedLabels.add(this.label.name);
|
|
11627
11179
|
}
|
|
11628
11180
|
else {
|
|
@@ -11631,8 +11183,6 @@ class BreakStatement extends NodeBase {
|
|
|
11631
11183
|
context.brokenFlow = true;
|
|
11632
11184
|
}
|
|
11633
11185
|
}
|
|
11634
|
-
BreakStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11635
|
-
BreakStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11636
11186
|
|
|
11637
11187
|
function renderCallArguments(code, options, node) {
|
|
11638
11188
|
if (node.arguments.length > 0) {
|
|
@@ -11819,6 +11369,8 @@ class CallExpression extends CallExpressionBase {
|
|
|
11819
11369
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11820
11370
|
}
|
|
11821
11371
|
include(context, includeChildrenRecursively) {
|
|
11372
|
+
if (!this.deoptimized)
|
|
11373
|
+
this.applyDeoptimizations();
|
|
11822
11374
|
if (includeChildrenRecursively) {
|
|
11823
11375
|
super.include(context, includeChildrenRecursively);
|
|
11824
11376
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
@@ -11828,26 +11380,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
11828
11380
|
}
|
|
11829
11381
|
}
|
|
11830
11382
|
else {
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
// If the callee is a member expression and does not have a variable, its
|
|
11834
|
-
// object will already be included via the first argument of the
|
|
11835
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
11836
|
-
// severe performance problems.
|
|
11837
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11838
|
-
this.callee.property.include(context, false);
|
|
11839
|
-
}
|
|
11840
|
-
else {
|
|
11841
|
-
this.callee.include(context, false);
|
|
11842
|
-
}
|
|
11843
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
11383
|
+
this.included = true;
|
|
11384
|
+
this.callee.include(context, false);
|
|
11844
11385
|
}
|
|
11845
|
-
|
|
11846
|
-
includeNode(context) {
|
|
11847
|
-
this.included = true;
|
|
11848
|
-
if (!this.deoptimized)
|
|
11849
|
-
this.applyDeoptimizations();
|
|
11850
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
11386
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
11851
11387
|
}
|
|
11852
11388
|
initialise() {
|
|
11853
11389
|
super.initialise();
|
|
@@ -11886,14 +11422,13 @@ class CatchClause extends NodeBase {
|
|
|
11886
11422
|
this.type = type;
|
|
11887
11423
|
if (param) {
|
|
11888
11424
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11889
|
-
this.param.declare('parameter',
|
|
11425
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11890
11426
|
}
|
|
11891
11427
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11892
11428
|
return super.parseNode(esTreeNode);
|
|
11893
11429
|
}
|
|
11894
11430
|
}
|
|
11895
11431
|
CatchClause.prototype.preventChildBlockScope = true;
|
|
11896
|
-
CatchClause.prototype.includeNode = onlyIncludeSelf;
|
|
11897
11432
|
|
|
11898
11433
|
class ChainExpression extends NodeBase {
|
|
11899
11434
|
// deoptimizations are not relevant as we are not caching values
|
|
@@ -11905,22 +11440,17 @@ class ChainExpression extends NodeBase {
|
|
|
11905
11440
|
hasEffects(context) {
|
|
11906
11441
|
return this.expression.hasEffectsAsChainElement(context) === true;
|
|
11907
11442
|
}
|
|
11908
|
-
includePath(path, context) {
|
|
11909
|
-
this.included = true;
|
|
11910
|
-
this.expression.includePath(path, context);
|
|
11911
|
-
}
|
|
11912
11443
|
removeAnnotations(code) {
|
|
11913
11444
|
this.expression.removeAnnotations(code);
|
|
11914
11445
|
}
|
|
11446
|
+
applyDeoptimizations() { }
|
|
11915
11447
|
}
|
|
11916
|
-
ChainExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11917
|
-
ChainExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11918
11448
|
|
|
11919
11449
|
class ClassBodyScope extends ChildScope {
|
|
11920
11450
|
constructor(parent, classNode) {
|
|
11921
11451
|
const { context } = parent;
|
|
11922
11452
|
super(parent, context);
|
|
11923
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode,
|
|
11453
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
11924
11454
|
this.instanceScope = new ChildScope(this, context);
|
|
11925
11455
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11926
11456
|
}
|
|
@@ -11935,7 +11465,7 @@ class ClassBody extends NodeBase {
|
|
|
11935
11465
|
}
|
|
11936
11466
|
include(context, includeChildrenRecursively) {
|
|
11937
11467
|
this.included = true;
|
|
11938
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
11468
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11939
11469
|
for (const definition of this.body) {
|
|
11940
11470
|
definition.include(context, includeChildrenRecursively);
|
|
11941
11471
|
}
|
|
@@ -11948,9 +11478,8 @@ class ClassBody extends NodeBase {
|
|
|
11948
11478
|
}
|
|
11949
11479
|
return super.parseNode(esTreeNode);
|
|
11950
11480
|
}
|
|
11481
|
+
applyDeoptimizations() { }
|
|
11951
11482
|
}
|
|
11952
|
-
ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11953
|
-
ClassBody.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11954
11483
|
|
|
11955
11484
|
class ClassExpression extends ClassNode {
|
|
11956
11485
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
@@ -11962,6 +11491,19 @@ class ClassExpression extends ClassNode {
|
|
|
11962
11491
|
}
|
|
11963
11492
|
}
|
|
11964
11493
|
|
|
11494
|
+
function tryCastLiteralValueToBoolean(literalValue) {
|
|
11495
|
+
if (typeof literalValue === 'symbol') {
|
|
11496
|
+
if (literalValue === UnknownFalsyValue) {
|
|
11497
|
+
return false;
|
|
11498
|
+
}
|
|
11499
|
+
if (literalValue === UnknownTruthyValue) {
|
|
11500
|
+
return true;
|
|
11501
|
+
}
|
|
11502
|
+
return UnknownValue;
|
|
11503
|
+
}
|
|
11504
|
+
return !!literalValue;
|
|
11505
|
+
}
|
|
11506
|
+
|
|
11965
11507
|
class MultiExpression extends ExpressionEntity {
|
|
11966
11508
|
constructor(expressions) {
|
|
11967
11509
|
super();
|
|
@@ -12008,9 +11550,6 @@ class ConditionalExpression extends NodeBase {
|
|
|
12008
11550
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
12009
11551
|
this.usedBranch = null;
|
|
12010
11552
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12011
|
-
if (this.included) {
|
|
12012
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
12013
|
-
}
|
|
12014
11553
|
const { expressionsToBeDeoptimized } = this;
|
|
12015
11554
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
12016
11555
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -12068,7 +11607,7 @@ class ConditionalExpression extends NodeBase {
|
|
|
12068
11607
|
include(context, includeChildrenRecursively) {
|
|
12069
11608
|
this.included = true;
|
|
12070
11609
|
const usedBranch = this.getUsedBranch();
|
|
12071
|
-
if (
|
|
11610
|
+
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
12072
11611
|
this.test.include(context, includeChildrenRecursively);
|
|
12073
11612
|
this.consequent.include(context, includeChildrenRecursively);
|
|
12074
11613
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -12077,38 +11616,27 @@ class ConditionalExpression extends NodeBase {
|
|
|
12077
11616
|
usedBranch.include(context, includeChildrenRecursively);
|
|
12078
11617
|
}
|
|
12079
11618
|
}
|
|
12080
|
-
|
|
12081
|
-
this.included = true;
|
|
12082
|
-
const usedBranch = this.getUsedBranch();
|
|
12083
|
-
if (usedBranch === null || this.test.shouldBeIncluded(context)) {
|
|
12084
|
-
this.consequent.includePath(path, context);
|
|
12085
|
-
this.alternate.includePath(path, context);
|
|
12086
|
-
}
|
|
12087
|
-
else {
|
|
12088
|
-
usedBranch.includePath(path, context);
|
|
12089
|
-
}
|
|
12090
|
-
}
|
|
12091
|
-
includeCallArguments(context, interaction) {
|
|
11619
|
+
includeCallArguments(context, parameters) {
|
|
12092
11620
|
const usedBranch = this.getUsedBranch();
|
|
12093
11621
|
if (usedBranch) {
|
|
12094
|
-
usedBranch.includeCallArguments(context,
|
|
11622
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
12095
11623
|
}
|
|
12096
11624
|
else {
|
|
12097
|
-
this.consequent.includeCallArguments(context,
|
|
12098
|
-
this.alternate.includeCallArguments(context,
|
|
11625
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
11626
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
12099
11627
|
}
|
|
12100
11628
|
}
|
|
12101
11629
|
removeAnnotations(code) {
|
|
12102
11630
|
this.test.removeAnnotations(code);
|
|
12103
11631
|
}
|
|
12104
11632
|
render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
11633
|
+
const usedBranch = this.getUsedBranch();
|
|
12105
11634
|
if (this.test.included) {
|
|
12106
11635
|
this.test.render(code, options, { renderedSurroundingElement });
|
|
12107
11636
|
this.consequent.render(code, options);
|
|
12108
11637
|
this.alternate.render(code, options);
|
|
12109
11638
|
}
|
|
12110
11639
|
else {
|
|
12111
|
-
const usedBranch = this.getUsedBranch();
|
|
12112
11640
|
const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);
|
|
12113
11641
|
const inclusionStart = findNonWhiteSpace(code.original, (this.consequent.included
|
|
12114
11642
|
? findFirstOccurrenceOutsideComment(code.original, '?', this.test.end)
|
|
@@ -12134,14 +11662,12 @@ class ConditionalExpression extends NodeBase {
|
|
|
12134
11662
|
return this.usedBranch;
|
|
12135
11663
|
}
|
|
12136
11664
|
this.isBranchResolutionAnalysed = true;
|
|
12137
|
-
const testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
11665
|
+
const testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
12138
11666
|
return typeof testValue === 'symbol'
|
|
12139
11667
|
? null
|
|
12140
11668
|
: (this.usedBranch = testValue ? this.consequent : this.alternate);
|
|
12141
11669
|
}
|
|
12142
11670
|
}
|
|
12143
|
-
ConditionalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12144
|
-
ConditionalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12145
11671
|
|
|
12146
11672
|
class ContinueStatement extends NodeBase {
|
|
12147
11673
|
hasEffects(context) {
|
|
@@ -12161,7 +11687,7 @@ class ContinueStatement extends NodeBase {
|
|
|
12161
11687
|
include(context) {
|
|
12162
11688
|
this.included = true;
|
|
12163
11689
|
if (this.label) {
|
|
12164
|
-
this.label.include(
|
|
11690
|
+
this.label.include();
|
|
12165
11691
|
context.includedLabels.add(this.label.name);
|
|
12166
11692
|
}
|
|
12167
11693
|
else {
|
|
@@ -12170,15 +11696,12 @@ class ContinueStatement extends NodeBase {
|
|
|
12170
11696
|
context.brokenFlow = true;
|
|
12171
11697
|
}
|
|
12172
11698
|
}
|
|
12173
|
-
ContinueStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12174
|
-
ContinueStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12175
11699
|
|
|
12176
11700
|
class DebuggerStatement extends NodeBase {
|
|
12177
11701
|
hasEffects() {
|
|
12178
11702
|
return true;
|
|
12179
11703
|
}
|
|
12180
11704
|
}
|
|
12181
|
-
DebuggerStatement.prototype.includeNode = onlyIncludeSelf;
|
|
12182
11705
|
|
|
12183
11706
|
class Decorator extends NodeBase {
|
|
12184
11707
|
hasEffects(context) {
|
|
@@ -12186,7 +11709,6 @@ class Decorator extends NodeBase {
|
|
|
12186
11709
|
this.expression.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context));
|
|
12187
11710
|
}
|
|
12188
11711
|
}
|
|
12189
|
-
Decorator.prototype.includeNode = onlyIncludeSelf;
|
|
12190
11712
|
|
|
12191
11713
|
function hasLoopBodyEffects(context, body) {
|
|
12192
11714
|
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
@@ -12226,15 +11748,12 @@ class DoWhileStatement extends NodeBase {
|
|
|
12226
11748
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12227
11749
|
}
|
|
12228
11750
|
}
|
|
12229
|
-
DoWhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12230
|
-
DoWhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12231
11751
|
|
|
12232
11752
|
class EmptyStatement extends NodeBase {
|
|
12233
11753
|
hasEffects() {
|
|
12234
11754
|
return false;
|
|
12235
11755
|
}
|
|
12236
11756
|
}
|
|
12237
|
-
EmptyStatement.prototype.includeNode = onlyIncludeSelf;
|
|
12238
11757
|
|
|
12239
11758
|
class ExportAllDeclaration extends NodeBase {
|
|
12240
11759
|
hasEffects() {
|
|
@@ -12247,10 +11766,9 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
12247
11766
|
render(code, _options, nodeRenderOptions) {
|
|
12248
11767
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12249
11768
|
}
|
|
11769
|
+
applyDeoptimizations() { }
|
|
12250
11770
|
}
|
|
12251
11771
|
ExportAllDeclaration.prototype.needsBoundaries = true;
|
|
12252
|
-
ExportAllDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12253
|
-
ExportAllDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12254
11772
|
|
|
12255
11773
|
class ExportNamedDeclaration extends NodeBase {
|
|
12256
11774
|
bind() {
|
|
@@ -12277,15 +11795,13 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
12277
11795
|
this.declaration.render(code, options, { end, start });
|
|
12278
11796
|
}
|
|
12279
11797
|
}
|
|
11798
|
+
applyDeoptimizations() { }
|
|
12280
11799
|
}
|
|
12281
11800
|
ExportNamedDeclaration.prototype.needsBoundaries = true;
|
|
12282
|
-
ExportNamedDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12283
|
-
ExportNamedDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12284
11801
|
|
|
12285
11802
|
class ExportSpecifier extends NodeBase {
|
|
11803
|
+
applyDeoptimizations() { }
|
|
12286
11804
|
}
|
|
12287
|
-
ExportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12288
|
-
ExportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12289
11805
|
|
|
12290
11806
|
class ForInStatement extends NodeBase {
|
|
12291
11807
|
createScope(parentScope) {
|
|
@@ -12303,18 +11819,11 @@ class ForInStatement extends NodeBase {
|
|
|
12303
11819
|
const { body, deoptimized, left, right } = this;
|
|
12304
11820
|
if (!deoptimized)
|
|
12305
11821
|
this.applyDeoptimizations();
|
|
12306
|
-
|
|
12307
|
-
this.includeNode(context);
|
|
11822
|
+
this.included = true;
|
|
12308
11823
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12309
11824
|
right.include(context, includeChildrenRecursively);
|
|
12310
11825
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12311
11826
|
}
|
|
12312
|
-
includeNode(context) {
|
|
12313
|
-
this.included = true;
|
|
12314
|
-
if (!this.deoptimized)
|
|
12315
|
-
this.applyDeoptimizations();
|
|
12316
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12317
|
-
}
|
|
12318
11827
|
initialise() {
|
|
12319
11828
|
super.initialise();
|
|
12320
11829
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -12355,18 +11864,11 @@ class ForOfStatement extends NodeBase {
|
|
|
12355
11864
|
const { body, deoptimized, left, right } = this;
|
|
12356
11865
|
if (!deoptimized)
|
|
12357
11866
|
this.applyDeoptimizations();
|
|
12358
|
-
|
|
12359
|
-
this.includeNode(context);
|
|
11867
|
+
this.included = true;
|
|
12360
11868
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12361
11869
|
right.include(context, includeChildrenRecursively);
|
|
12362
11870
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12363
11871
|
}
|
|
12364
|
-
includeNode(context) {
|
|
12365
|
-
this.included = true;
|
|
12366
|
-
if (!this.deoptimized)
|
|
12367
|
-
this.applyDeoptimizations();
|
|
12368
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12369
|
-
}
|
|
12370
11872
|
initialise() {
|
|
12371
11873
|
super.initialise();
|
|
12372
11874
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -12402,9 +11904,7 @@ class ForStatement extends NodeBase {
|
|
|
12402
11904
|
}
|
|
12403
11905
|
include(context, includeChildrenRecursively) {
|
|
12404
11906
|
this.included = true;
|
|
12405
|
-
this.init?.include(context, includeChildrenRecursively, {
|
|
12406
|
-
asSingleStatement: true
|
|
12407
|
-
});
|
|
11907
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
12408
11908
|
this.test?.include(context, includeChildrenRecursively);
|
|
12409
11909
|
this.update?.include(context, includeChildrenRecursively);
|
|
12410
11910
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
@@ -12416,8 +11916,6 @@ class ForStatement extends NodeBase {
|
|
|
12416
11916
|
this.body.render(code, options);
|
|
12417
11917
|
}
|
|
12418
11918
|
}
|
|
12419
|
-
ForStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12420
|
-
ForStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12421
11919
|
|
|
12422
11920
|
class FunctionExpression extends FunctionNode {
|
|
12423
11921
|
createScope(parentScope) {
|
|
@@ -12449,9 +11947,9 @@ class TrackingScope extends BlockScope {
|
|
|
12449
11947
|
super(...arguments);
|
|
12450
11948
|
this.hoistedDeclarations = [];
|
|
12451
11949
|
}
|
|
12452
|
-
addDeclaration(identifier, context, init,
|
|
11950
|
+
addDeclaration(identifier, context, init, kind) {
|
|
12453
11951
|
this.hoistedDeclarations.push(identifier);
|
|
12454
|
-
return super.addDeclaration(identifier, context, init,
|
|
11952
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
12455
11953
|
}
|
|
12456
11954
|
}
|
|
12457
11955
|
|
|
@@ -12550,9 +12048,10 @@ class IfStatement extends NodeBase {
|
|
|
12550
12048
|
}
|
|
12551
12049
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
12552
12050
|
}
|
|
12051
|
+
applyDeoptimizations() { }
|
|
12553
12052
|
getTestValue() {
|
|
12554
12053
|
if (this.testValue === unset) {
|
|
12555
|
-
return (this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
12054
|
+
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
12556
12055
|
}
|
|
12557
12056
|
return this.testValue;
|
|
12558
12057
|
}
|
|
@@ -12618,8 +12117,6 @@ class IfStatement extends NodeBase {
|
|
|
12618
12117
|
return false;
|
|
12619
12118
|
}
|
|
12620
12119
|
}
|
|
12621
|
-
IfStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12622
|
-
IfStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12623
12120
|
|
|
12624
12121
|
class ImportAttribute extends NodeBase {
|
|
12625
12122
|
}
|
|
@@ -12637,15 +12134,13 @@ class ImportDeclaration extends NodeBase {
|
|
|
12637
12134
|
render(code, _options, nodeRenderOptions) {
|
|
12638
12135
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12639
12136
|
}
|
|
12137
|
+
applyDeoptimizations() { }
|
|
12640
12138
|
}
|
|
12641
12139
|
ImportDeclaration.prototype.needsBoundaries = true;
|
|
12642
|
-
ImportDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12643
|
-
ImportDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12644
12140
|
|
|
12645
12141
|
class ImportDefaultSpecifier extends NodeBase {
|
|
12142
|
+
applyDeoptimizations() { }
|
|
12646
12143
|
}
|
|
12647
|
-
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12648
|
-
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12649
12144
|
|
|
12650
12145
|
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
12651
12146
|
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
@@ -12654,33 +12149,28 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12654
12149
|
class VariableDeclarator extends NodeBase {
|
|
12655
12150
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12656
12151
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12657
|
-
this.id.declare(kind,
|
|
12152
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12658
12153
|
}
|
|
12659
12154
|
deoptimizePath(path) {
|
|
12660
12155
|
this.id.deoptimizePath(path);
|
|
12661
12156
|
}
|
|
12662
12157
|
hasEffects(context) {
|
|
12158
|
+
if (!this.deoptimized)
|
|
12159
|
+
this.applyDeoptimizations();
|
|
12663
12160
|
const initEffect = this.init?.hasEffects(context);
|
|
12664
12161
|
this.id.markDeclarationReached();
|
|
12665
|
-
return
|
|
12666
|
-
this.isUsingDeclaration ||
|
|
12667
|
-
this.id.hasEffects(context) ||
|
|
12668
|
-
(this.scope.context.options.treeshake
|
|
12669
|
-
.propertyReadSideEffects &&
|
|
12670
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
12162
|
+
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
12671
12163
|
}
|
|
12672
12164
|
include(context, includeChildrenRecursively) {
|
|
12673
|
-
const { id, init } = this;
|
|
12674
|
-
if (!
|
|
12675
|
-
this.
|
|
12165
|
+
const { deoptimized, id, init } = this;
|
|
12166
|
+
if (!deoptimized)
|
|
12167
|
+
this.applyDeoptimizations();
|
|
12168
|
+
this.included = true;
|
|
12676
12169
|
init?.include(context, includeChildrenRecursively);
|
|
12677
12170
|
id.markDeclarationReached();
|
|
12678
|
-
if (includeChildrenRecursively) {
|
|
12171
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12679
12172
|
id.include(context, includeChildrenRecursively);
|
|
12680
12173
|
}
|
|
12681
|
-
else {
|
|
12682
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
12683
|
-
}
|
|
12684
12174
|
}
|
|
12685
12175
|
removeAnnotations(code) {
|
|
12686
12176
|
this.init?.removeAnnotations(code);
|
|
@@ -12710,8 +12200,8 @@ class VariableDeclarator extends NodeBase {
|
|
|
12710
12200
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12711
12201
|
}
|
|
12712
12202
|
}
|
|
12713
|
-
|
|
12714
|
-
this.
|
|
12203
|
+
applyDeoptimizations() {
|
|
12204
|
+
this.deoptimized = true;
|
|
12715
12205
|
const { id, init } = this;
|
|
12716
12206
|
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12717
12207
|
const { name, variable } = id;
|
|
@@ -12723,14 +12213,11 @@ class VariableDeclarator extends NodeBase {
|
|
|
12723
12213
|
}
|
|
12724
12214
|
}
|
|
12725
12215
|
}
|
|
12726
|
-
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12727
12216
|
|
|
12728
12217
|
class ImportExpression extends NodeBase {
|
|
12729
12218
|
constructor() {
|
|
12730
12219
|
super(...arguments);
|
|
12731
12220
|
this.inlineNamespace = null;
|
|
12732
|
-
this.hasUnknownAccessedKey = false;
|
|
12733
|
-
this.accessedPropKey = new Set();
|
|
12734
12221
|
this.attributes = null;
|
|
12735
12222
|
this.mechanism = null;
|
|
12736
12223
|
this.namespaceExportName = undefined;
|
|
@@ -12763,15 +12250,12 @@ class ImportExpression extends NodeBase {
|
|
|
12763
12250
|
if (parent2 instanceof ExpressionStatement) {
|
|
12764
12251
|
return EMPTY_ARRAY;
|
|
12765
12252
|
}
|
|
12766
|
-
// Case 1: const { foo }
|
|
12253
|
+
// Case 1: const { foo } = await import('bar')
|
|
12767
12254
|
if (parent2 instanceof VariableDeclarator) {
|
|
12768
12255
|
const declaration = parent2.id;
|
|
12769
|
-
|
|
12770
|
-
|
|
12771
|
-
|
|
12772
|
-
if (declaration instanceof ObjectPattern) {
|
|
12773
|
-
return getDeterministicObjectDestructure(declaration);
|
|
12774
|
-
}
|
|
12256
|
+
return declaration instanceof ObjectPattern
|
|
12257
|
+
? getDeterministicObjectDestructure(declaration)
|
|
12258
|
+
: undefined;
|
|
12775
12259
|
}
|
|
12776
12260
|
// Case 2: (await import('bar')).foo
|
|
12777
12261
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12821,29 +12305,12 @@ class ImportExpression extends NodeBase {
|
|
|
12821
12305
|
return true;
|
|
12822
12306
|
}
|
|
12823
12307
|
include(context, includeChildrenRecursively) {
|
|
12824
|
-
if (!this.included)
|
|
12825
|
-
this.
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
includeNode() {
|
|
12829
|
-
this.included = true;
|
|
12830
|
-
this.scope.context.includeDynamicImport(this);
|
|
12831
|
-
this.scope.addAccessedDynamicImport(this);
|
|
12832
|
-
}
|
|
12833
|
-
includePath(path) {
|
|
12834
|
-
if (!this.included)
|
|
12835
|
-
this.includeNode();
|
|
12836
|
-
// Technically, this is not correct as dynamic imports return a Promise.
|
|
12837
|
-
if (this.hasUnknownAccessedKey)
|
|
12838
|
-
return;
|
|
12839
|
-
if (path[0] === UnknownKey) {
|
|
12840
|
-
this.hasUnknownAccessedKey = true;
|
|
12841
|
-
}
|
|
12842
|
-
else if (typeof path[0] === 'string') {
|
|
12843
|
-
this.accessedPropKey.add(path[0]);
|
|
12308
|
+
if (!this.included) {
|
|
12309
|
+
this.included = true;
|
|
12310
|
+
this.scope.context.includeDynamicImport(this);
|
|
12311
|
+
this.scope.addAccessedDynamicImport(this);
|
|
12844
12312
|
}
|
|
12845
|
-
|
|
12846
|
-
this.scope.context.includeDynamicImport(this);
|
|
12313
|
+
this.source.include(context, includeChildrenRecursively);
|
|
12847
12314
|
}
|
|
12848
12315
|
initialise() {
|
|
12849
12316
|
super.initialise();
|
|
@@ -12913,6 +12380,7 @@ class ImportExpression extends NodeBase {
|
|
|
12913
12380
|
setInternalResolution(inlineNamespace) {
|
|
12914
12381
|
this.inlineNamespace = inlineNamespace;
|
|
12915
12382
|
}
|
|
12383
|
+
applyDeoptimizations() { }
|
|
12916
12384
|
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
12917
12385
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
12918
12386
|
{
|
|
@@ -13002,7 +12470,6 @@ class ImportExpression extends NodeBase {
|
|
|
13002
12470
|
return { helper: null, mechanism: null };
|
|
13003
12471
|
}
|
|
13004
12472
|
}
|
|
13005
|
-
ImportExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13006
12473
|
function getInteropHelper(resolution, exportMode, interop) {
|
|
13007
12474
|
return exportMode === 'external'
|
|
13008
12475
|
? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
|
|
@@ -13026,14 +12493,12 @@ function getDeterministicObjectDestructure(objectPattern) {
|
|
|
13026
12493
|
}
|
|
13027
12494
|
|
|
13028
12495
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
12496
|
+
applyDeoptimizations() { }
|
|
13029
12497
|
}
|
|
13030
|
-
ImportNamespaceSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13031
|
-
ImportNamespaceSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13032
12498
|
|
|
13033
12499
|
class ImportSpecifier extends NodeBase {
|
|
12500
|
+
applyDeoptimizations() { }
|
|
13034
12501
|
}
|
|
13035
|
-
ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13036
|
-
ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13037
12502
|
|
|
13038
12503
|
class JSXIdentifier extends IdentifierBase {
|
|
13039
12504
|
constructor() {
|
|
@@ -13050,29 +12515,6 @@ class JSXIdentifier extends IdentifierBase {
|
|
|
13050
12515
|
this.isNativeElement = true;
|
|
13051
12516
|
}
|
|
13052
12517
|
}
|
|
13053
|
-
include(context) {
|
|
13054
|
-
if (!this.included)
|
|
13055
|
-
this.includeNode(context);
|
|
13056
|
-
}
|
|
13057
|
-
includeNode(context) {
|
|
13058
|
-
this.included = true;
|
|
13059
|
-
if (!this.deoptimized)
|
|
13060
|
-
this.applyDeoptimizations();
|
|
13061
|
-
if (this.variable !== null) {
|
|
13062
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13063
|
-
}
|
|
13064
|
-
}
|
|
13065
|
-
includePath(path, context) {
|
|
13066
|
-
if (!this.included) {
|
|
13067
|
-
this.included = true;
|
|
13068
|
-
if (this.variable !== null) {
|
|
13069
|
-
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
13070
|
-
}
|
|
13071
|
-
}
|
|
13072
|
-
else if (path.length > 0) {
|
|
13073
|
-
this.variable?.includePath(path, context);
|
|
13074
|
-
}
|
|
13075
|
-
}
|
|
13076
12518
|
render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
|
|
13077
12519
|
if (this.variable) {
|
|
13078
12520
|
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
@@ -13134,7 +12576,6 @@ class JSXAttribute extends NodeBase {
|
|
|
13134
12576
|
}
|
|
13135
12577
|
}
|
|
13136
12578
|
}
|
|
13137
|
-
JSXAttribute.prototype.includeNode = onlyIncludeSelf;
|
|
13138
12579
|
|
|
13139
12580
|
class JSXClosingBase extends NodeBase {
|
|
13140
12581
|
render(code, options) {
|
|
@@ -13147,7 +12588,6 @@ class JSXClosingBase extends NodeBase {
|
|
|
13147
12588
|
}
|
|
13148
12589
|
}
|
|
13149
12590
|
}
|
|
13150
|
-
JSXClosingBase.prototype.includeNode = onlyIncludeSelf;
|
|
13151
12591
|
|
|
13152
12592
|
class JSXClosingElement extends JSXClosingBase {
|
|
13153
12593
|
}
|
|
@@ -13168,15 +12608,8 @@ class JSXSpreadAttribute extends NodeBase {
|
|
|
13168
12608
|
|
|
13169
12609
|
class JSXEmptyExpression extends NodeBase {
|
|
13170
12610
|
}
|
|
13171
|
-
JSXEmptyExpression.prototype.includeNode = onlyIncludeSelf;
|
|
13172
12611
|
|
|
13173
12612
|
class JSXExpressionContainer extends NodeBase {
|
|
13174
|
-
includeNode(context) {
|
|
13175
|
-
this.included = true;
|
|
13176
|
-
if (!this.deoptimized)
|
|
13177
|
-
this.applyDeoptimizations();
|
|
13178
|
-
this.expression.includePath(UNKNOWN_PATH, context);
|
|
13179
|
-
}
|
|
13180
12613
|
render(code, options) {
|
|
13181
12614
|
const { mode } = this.scope.context.options.jsx;
|
|
13182
12615
|
if (mode !== 'preserve') {
|
|
@@ -13197,7 +12630,7 @@ function getRenderedJsxChildren(children) {
|
|
|
13197
12630
|
return renderedChildren;
|
|
13198
12631
|
}
|
|
13199
12632
|
|
|
13200
|
-
function getAndIncludeFactoryVariable(factory, preserve, importSource, node
|
|
12633
|
+
function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
13201
12634
|
const [baseName, nestedName] = factory.split('.');
|
|
13202
12635
|
let factoryVariable;
|
|
13203
12636
|
if (importSource) {
|
|
@@ -13205,7 +12638,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
13205
12638
|
if (preserve) {
|
|
13206
12639
|
// This pretends we are accessing an included global variable of the same name
|
|
13207
12640
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
13208
|
-
globalVariable.
|
|
12641
|
+
globalVariable.include();
|
|
13209
12642
|
// This excludes this variable from renaming
|
|
13210
12643
|
factoryVariable.globalName = baseName;
|
|
13211
12644
|
}
|
|
@@ -13213,7 +12646,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
13213
12646
|
else {
|
|
13214
12647
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
13215
12648
|
}
|
|
13216
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
12649
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
13217
12650
|
if (factoryVariable instanceof LocalVariable) {
|
|
13218
12651
|
factoryVariable.consolidateInitializers();
|
|
13219
12652
|
factoryVariable.addUsedPlace(node);
|
|
@@ -13236,20 +12669,16 @@ class JSXElementBase extends NodeBase {
|
|
|
13236
12669
|
}
|
|
13237
12670
|
}
|
|
13238
12671
|
include(context, includeChildrenRecursively) {
|
|
13239
|
-
if (!this.included)
|
|
13240
|
-
this.
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
includeNode(context) {
|
|
13246
|
-
this.included = true;
|
|
13247
|
-
const { factory, importSource, mode } = this.jsxMode;
|
|
13248
|
-
if (factory) {
|
|
13249
|
-
this.factory = factory;
|
|
13250
|
-
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this, context);
|
|
12672
|
+
if (!this.included) {
|
|
12673
|
+
const { factory, importSource, mode } = this.jsxMode;
|
|
12674
|
+
if (factory) {
|
|
12675
|
+
this.factory = factory;
|
|
12676
|
+
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
12677
|
+
}
|
|
13251
12678
|
}
|
|
12679
|
+
super.include(context, includeChildrenRecursively);
|
|
13252
12680
|
}
|
|
12681
|
+
applyDeoptimizations() { }
|
|
13253
12682
|
getRenderingMode() {
|
|
13254
12683
|
const jsx = this.scope.context.options.jsx;
|
|
13255
12684
|
const { mode, factory, importSource } = jsx;
|
|
@@ -13287,14 +12716,8 @@ class JSXElementBase extends NodeBase {
|
|
|
13287
12716
|
return { childrenEnd, firstChild, hasMultipleChildren };
|
|
13288
12717
|
}
|
|
13289
12718
|
}
|
|
13290
|
-
JSXElementBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13291
12719
|
|
|
13292
12720
|
class JSXElement extends JSXElementBase {
|
|
13293
|
-
include(context, includeChildrenRecursively) {
|
|
13294
|
-
super.include(context, includeChildrenRecursively);
|
|
13295
|
-
this.openingElement.include(context, includeChildrenRecursively);
|
|
13296
|
-
this.closingElement?.include(context, includeChildrenRecursively);
|
|
13297
|
-
}
|
|
13298
12721
|
render(code, options) {
|
|
13299
12722
|
switch (this.jsxMode.mode) {
|
|
13300
12723
|
case 'classic': {
|
|
@@ -13446,11 +12869,6 @@ class JSXElement extends JSXElementBase {
|
|
|
13446
12869
|
}
|
|
13447
12870
|
|
|
13448
12871
|
class JSXFragment extends JSXElementBase {
|
|
13449
|
-
include(context, includeChildrenRecursively) {
|
|
13450
|
-
super.include(context, includeChildrenRecursively);
|
|
13451
|
-
this.openingFragment.include(context, includeChildrenRecursively);
|
|
13452
|
-
this.closingFragment.include(context, includeChildrenRecursively);
|
|
13453
|
-
}
|
|
13454
12872
|
render(code, options) {
|
|
13455
12873
|
switch (this.jsxMode.mode) {
|
|
13456
12874
|
case 'classic': {
|
|
@@ -13500,22 +12918,10 @@ class JSXFragment extends JSXElementBase {
|
|
|
13500
12918
|
}
|
|
13501
12919
|
|
|
13502
12920
|
class JSXMemberExpression extends NodeBase {
|
|
13503
|
-
includeNode(context) {
|
|
13504
|
-
this.included = true;
|
|
13505
|
-
if (!this.deoptimized)
|
|
13506
|
-
this.applyDeoptimizations();
|
|
13507
|
-
this.object.includePath([this.property.name], context);
|
|
13508
|
-
}
|
|
13509
|
-
includePath(path, context) {
|
|
13510
|
-
if (!this.included)
|
|
13511
|
-
this.includeNode(context);
|
|
13512
|
-
this.object.includePath([this.property.name, ...path], context);
|
|
13513
|
-
}
|
|
13514
12921
|
}
|
|
13515
12922
|
|
|
13516
12923
|
class JSXNamespacedName extends NodeBase {
|
|
13517
12924
|
}
|
|
13518
|
-
JSXNamespacedName.prototype.includeNode = onlyIncludeSelf;
|
|
13519
12925
|
|
|
13520
12926
|
class JSXOpeningElement extends NodeBase {
|
|
13521
12927
|
render(code, options, { jsxMode = this.scope.context.options.jsx.mode } = {}) {
|
|
@@ -13525,7 +12931,6 @@ class JSXOpeningElement extends NodeBase {
|
|
|
13525
12931
|
}
|
|
13526
12932
|
}
|
|
13527
12933
|
}
|
|
13528
|
-
JSXOpeningElement.prototype.includeNode = onlyIncludeSelf;
|
|
13529
12934
|
|
|
13530
12935
|
class JSXOpeningFragment extends NodeBase {
|
|
13531
12936
|
constructor() {
|
|
@@ -13533,22 +12938,22 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13533
12938
|
this.fragment = null;
|
|
13534
12939
|
this.fragmentVariable = null;
|
|
13535
12940
|
}
|
|
13536
|
-
|
|
13537
|
-
this.included
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this, context);
|
|
12941
|
+
include(context, includeChildrenRecursively) {
|
|
12942
|
+
if (!this.included) {
|
|
12943
|
+
const jsx = this.scope.context.options.jsx;
|
|
12944
|
+
if (jsx.mode === 'automatic') {
|
|
12945
|
+
this.fragment = 'Fragment';
|
|
12946
|
+
this.fragmentVariable = getAndIncludeFactoryVariable('Fragment', false, jsx.jsxImportSource, this);
|
|
12947
|
+
}
|
|
12948
|
+
else {
|
|
12949
|
+
const { fragment, importSource, mode } = jsx;
|
|
12950
|
+
if (fragment != null) {
|
|
12951
|
+
this.fragment = fragment;
|
|
12952
|
+
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this);
|
|
12953
|
+
}
|
|
13550
12954
|
}
|
|
13551
12955
|
}
|
|
12956
|
+
super.include(context, includeChildrenRecursively);
|
|
13552
12957
|
}
|
|
13553
12958
|
render(code, options) {
|
|
13554
12959
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -13585,7 +12990,6 @@ class JSXText extends NodeBase {
|
|
|
13585
12990
|
}
|
|
13586
12991
|
}
|
|
13587
12992
|
}
|
|
13588
|
-
JSXText.prototype.includeNode = onlyIncludeSelf;
|
|
13589
12993
|
|
|
13590
12994
|
class LabeledStatement extends NodeBase {
|
|
13591
12995
|
hasEffects(context) {
|
|
@@ -13607,22 +13011,17 @@ class LabeledStatement extends NodeBase {
|
|
|
13607
13011
|
return bodyHasEffects;
|
|
13608
13012
|
}
|
|
13609
13013
|
include(context, includeChildrenRecursively) {
|
|
13610
|
-
|
|
13611
|
-
this.includeNode(context);
|
|
13014
|
+
this.included = true;
|
|
13612
13015
|
const { brokenFlow, includedLabels } = context;
|
|
13613
13016
|
context.includedLabels = new Set();
|
|
13614
13017
|
this.body.include(context, includeChildrenRecursively);
|
|
13615
13018
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13616
|
-
this.label.include(
|
|
13019
|
+
this.label.include();
|
|
13617
13020
|
context.includedLabels.delete(this.label.name);
|
|
13618
13021
|
context.brokenFlow = brokenFlow;
|
|
13619
13022
|
}
|
|
13620
13023
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13621
13024
|
}
|
|
13622
|
-
includeNode(context) {
|
|
13623
|
-
this.included = true;
|
|
13624
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
13625
|
-
}
|
|
13626
13025
|
render(code, options) {
|
|
13627
13026
|
if (this.label.included) {
|
|
13628
13027
|
this.label.render(code, options);
|
|
@@ -13633,7 +13032,6 @@ class LabeledStatement extends NodeBase {
|
|
|
13633
13032
|
this.body.render(code, options);
|
|
13634
13033
|
}
|
|
13635
13034
|
}
|
|
13636
|
-
LabeledStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13637
13035
|
|
|
13638
13036
|
class LogicalExpression extends NodeBase {
|
|
13639
13037
|
constructor() {
|
|
@@ -13658,10 +13056,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13658
13056
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
13659
13057
|
this.usedBranch = null;
|
|
13660
13058
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
13661
|
-
if (this.included) {
|
|
13662
|
-
// As we are not tracking inclusions, we just include everything
|
|
13663
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
13664
|
-
}
|
|
13665
13059
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
13666
13060
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
13667
13061
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -13688,21 +13082,33 @@ class LogicalExpression extends NodeBase {
|
|
|
13688
13082
|
this.expressionsToBeDeoptimized.push(origin);
|
|
13689
13083
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
13690
13084
|
}
|
|
13085
|
+
else {
|
|
13086
|
+
const rightValue = this.right.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
13087
|
+
const booleanOrUnknown = tryCastLiteralValueToBoolean(rightValue);
|
|
13088
|
+
if (typeof booleanOrUnknown !== 'symbol') {
|
|
13089
|
+
if (!booleanOrUnknown && this.operator === '&&') {
|
|
13090
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
13091
|
+
return UnknownFalsyValue;
|
|
13092
|
+
}
|
|
13093
|
+
if (booleanOrUnknown && this.operator === '||') {
|
|
13094
|
+
return UnknownTruthyValue;
|
|
13095
|
+
}
|
|
13096
|
+
}
|
|
13097
|
+
}
|
|
13691
13098
|
return UnknownValue;
|
|
13692
13099
|
}
|
|
13693
13100
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
13694
13101
|
const usedBranch = this.getUsedBranch();
|
|
13695
|
-
if (usedBranch)
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
];
|
|
13102
|
+
if (!usedBranch)
|
|
13103
|
+
return [
|
|
13104
|
+
new MultiExpression([
|
|
13105
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0],
|
|
13106
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0]
|
|
13107
|
+
]),
|
|
13108
|
+
false
|
|
13109
|
+
];
|
|
13110
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
13111
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
13706
13112
|
}
|
|
13707
13113
|
hasEffects(context) {
|
|
13708
13114
|
if (this.left.hasEffects(context)) {
|
|
@@ -13715,18 +13121,18 @@ class LogicalExpression extends NodeBase {
|
|
|
13715
13121
|
}
|
|
13716
13122
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13717
13123
|
const usedBranch = this.getUsedBranch();
|
|
13718
|
-
if (usedBranch) {
|
|
13719
|
-
return
|
|
13124
|
+
if (!usedBranch) {
|
|
13125
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
13126
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13720
13127
|
}
|
|
13721
|
-
return
|
|
13722
|
-
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13128
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13723
13129
|
}
|
|
13724
13130
|
include(context, includeChildrenRecursively) {
|
|
13725
13131
|
this.included = true;
|
|
13726
13132
|
const usedBranch = this.getUsedBranch();
|
|
13727
13133
|
if (includeChildrenRecursively ||
|
|
13728
|
-
|
|
13729
|
-
|
|
13134
|
+
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
13135
|
+
!usedBranch) {
|
|
13730
13136
|
this.left.include(context, includeChildrenRecursively);
|
|
13731
13137
|
this.right.include(context, includeChildrenRecursively);
|
|
13732
13138
|
}
|
|
@@ -13734,17 +13140,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13734
13140
|
usedBranch.include(context, includeChildrenRecursively);
|
|
13735
13141
|
}
|
|
13736
13142
|
}
|
|
13737
|
-
includePath(path, context) {
|
|
13738
|
-
this.included = true;
|
|
13739
|
-
const usedBranch = this.getUsedBranch();
|
|
13740
|
-
if (!usedBranch || (usedBranch === this.right && this.left.shouldBeIncluded(context))) {
|
|
13741
|
-
this.left.includePath(path, context);
|
|
13742
|
-
this.right.includePath(path, context);
|
|
13743
|
-
}
|
|
13744
|
-
else {
|
|
13745
|
-
usedBranch.includePath(path, context);
|
|
13746
|
-
}
|
|
13747
|
-
}
|
|
13748
13143
|
removeAnnotations(code) {
|
|
13749
13144
|
this.left.removeAnnotations(code);
|
|
13750
13145
|
}
|
|
@@ -13781,13 +13176,14 @@ class LogicalExpression extends NodeBase {
|
|
|
13781
13176
|
if (!this.isBranchResolutionAnalysed) {
|
|
13782
13177
|
this.isBranchResolutionAnalysed = true;
|
|
13783
13178
|
const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
13784
|
-
|
|
13179
|
+
const booleanOrUnknown = tryCastLiteralValueToBoolean(leftValue);
|
|
13180
|
+
if (typeof booleanOrUnknown === 'symbol') {
|
|
13785
13181
|
return null;
|
|
13786
13182
|
}
|
|
13787
13183
|
else {
|
|
13788
13184
|
this.usedBranch =
|
|
13789
|
-
(this.operator === '||' &&
|
|
13790
|
-
(this.operator === '&&' && !
|
|
13185
|
+
(this.operator === '||' && booleanOrUnknown) ||
|
|
13186
|
+
(this.operator === '&&' && !booleanOrUnknown) ||
|
|
13791
13187
|
(this.operator === '??' && leftValue != null)
|
|
13792
13188
|
? this.left
|
|
13793
13189
|
: this.right;
|
|
@@ -13796,8 +13192,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13796
13192
|
return this.usedBranch;
|
|
13797
13193
|
}
|
|
13798
13194
|
}
|
|
13799
|
-
LogicalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13800
|
-
LogicalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13801
13195
|
|
|
13802
13196
|
class NewExpression extends NodeBase {
|
|
13803
13197
|
hasEffects(context) {
|
|
@@ -13817,21 +13211,16 @@ class NewExpression extends NodeBase {
|
|
|
13817
13211
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13818
13212
|
}
|
|
13819
13213
|
include(context, includeChildrenRecursively) {
|
|
13214
|
+
if (!this.deoptimized)
|
|
13215
|
+
this.applyDeoptimizations();
|
|
13820
13216
|
if (includeChildrenRecursively) {
|
|
13821
13217
|
super.include(context, includeChildrenRecursively);
|
|
13822
13218
|
}
|
|
13823
13219
|
else {
|
|
13824
|
-
|
|
13825
|
-
this.includeNode(context);
|
|
13220
|
+
this.included = true;
|
|
13826
13221
|
this.callee.include(context, false);
|
|
13827
13222
|
}
|
|
13828
|
-
this.callee.includeCallArguments(context, this.
|
|
13829
|
-
}
|
|
13830
|
-
includeNode(context) {
|
|
13831
|
-
this.included = true;
|
|
13832
|
-
if (!this.deoptimized)
|
|
13833
|
-
this.applyDeoptimizations();
|
|
13834
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
13223
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13835
13224
|
}
|
|
13836
13225
|
initialise() {
|
|
13837
13226
|
super.initialise();
|
|
@@ -13860,7 +13249,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13860
13249
|
constructor() {
|
|
13861
13250
|
super(...arguments);
|
|
13862
13251
|
this.objectEntity = null;
|
|
13863
|
-
this.protoProp = null;
|
|
13864
13252
|
}
|
|
13865
13253
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13866
13254
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13880,43 +13268,15 @@ class ObjectExpression extends NodeBase {
|
|
|
13880
13268
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13881
13269
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13882
13270
|
}
|
|
13883
|
-
include(context, includeChildrenRecursively) {
|
|
13884
|
-
if (!this.included)
|
|
13885
|
-
this.includeNode(context);
|
|
13886
|
-
this.getObjectEntity().include(context, includeChildrenRecursively);
|
|
13887
|
-
this.protoProp?.include(context, includeChildrenRecursively);
|
|
13888
|
-
}
|
|
13889
|
-
includeNode(context) {
|
|
13890
|
-
this.included = true;
|
|
13891
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context);
|
|
13892
|
-
}
|
|
13893
|
-
includePath(path, context) {
|
|
13894
|
-
if (!this.included)
|
|
13895
|
-
this.includeNode(context);
|
|
13896
|
-
this.getObjectEntity().includePath(path, context);
|
|
13897
|
-
}
|
|
13898
13271
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13272
|
+
super.render(code, options);
|
|
13899
13273
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13900
13274
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13901
13275
|
code.appendRight(this.start, '(');
|
|
13902
13276
|
code.prependLeft(this.end, ')');
|
|
13903
13277
|
}
|
|
13904
|
-
if (this.properties.length > 0) {
|
|
13905
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13906
|
-
let lastSeparatorPos = null;
|
|
13907
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
13908
|
-
if (!node.included) {
|
|
13909
|
-
treeshakeNode(node, code, start, end);
|
|
13910
|
-
continue;
|
|
13911
|
-
}
|
|
13912
|
-
lastSeparatorPos = separator;
|
|
13913
|
-
node.render(code, options);
|
|
13914
|
-
}
|
|
13915
|
-
if (lastSeparatorPos) {
|
|
13916
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
13917
|
-
}
|
|
13918
|
-
}
|
|
13919
13278
|
}
|
|
13279
|
+
applyDeoptimizations() { }
|
|
13920
13280
|
getObjectEntity() {
|
|
13921
13281
|
if (this.objectEntity !== null) {
|
|
13922
13282
|
return this.objectEntity;
|
|
@@ -13945,7 +13305,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13945
13305
|
? property.key.name
|
|
13946
13306
|
: String(property.key.value);
|
|
13947
13307
|
if (key === '__proto__' && property.kind === 'init') {
|
|
13948
|
-
this.protoProp = property;
|
|
13949
13308
|
prototype =
|
|
13950
13309
|
property.value instanceof Literal && property.value.value === null
|
|
13951
13310
|
? null
|
|
@@ -13958,7 +13317,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13958
13317
|
return (this.objectEntity = new ObjectEntity(properties, prototype));
|
|
13959
13318
|
}
|
|
13960
13319
|
}
|
|
13961
|
-
ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13962
13320
|
|
|
13963
13321
|
class PanicError extends NodeBase {
|
|
13964
13322
|
initialise() {
|
|
@@ -13985,7 +13343,6 @@ class ParseError extends NodeBase {
|
|
|
13985
13343
|
|
|
13986
13344
|
class PrivateIdentifier extends NodeBase {
|
|
13987
13345
|
}
|
|
13988
|
-
PrivateIdentifier.prototype.includeNode = onlyIncludeSelf;
|
|
13989
13346
|
|
|
13990
13347
|
class Program extends NodeBase {
|
|
13991
13348
|
constructor() {
|
|
@@ -14053,11 +13410,14 @@ class Program extends NodeBase {
|
|
|
14053
13410
|
super.render(code, options);
|
|
14054
13411
|
}
|
|
14055
13412
|
}
|
|
13413
|
+
applyDeoptimizations() { }
|
|
14056
13414
|
}
|
|
14057
|
-
Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14058
|
-
Program.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14059
13415
|
|
|
14060
13416
|
class Property extends MethodBase {
|
|
13417
|
+
constructor() {
|
|
13418
|
+
super(...arguments);
|
|
13419
|
+
this.declarationInit = null;
|
|
13420
|
+
}
|
|
14061
13421
|
//declare method: boolean;
|
|
14062
13422
|
get method() {
|
|
14063
13423
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -14072,41 +13432,17 @@ class Property extends MethodBase {
|
|
|
14072
13432
|
set shorthand(value) {
|
|
14073
13433
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
14074
13434
|
}
|
|
14075
|
-
declare(kind,
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
14079
|
-
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
13435
|
+
declare(kind, init) {
|
|
13436
|
+
this.declarationInit = init;
|
|
13437
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
14080
13438
|
}
|
|
14081
13439
|
hasEffects(context) {
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
return this.
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
const path = this.getPathInProperty(destructuredInitPath);
|
|
14089
|
-
let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
|
|
14090
|
-
this.included;
|
|
14091
|
-
if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
|
|
14092
|
-
this.key.include(context, false);
|
|
14093
|
-
if (!this.value.included) {
|
|
14094
|
-
this.value.included = true;
|
|
14095
|
-
// Unfortunately, we need to include the value again now, so that any
|
|
14096
|
-
// declared variables are properly included.
|
|
14097
|
-
this.value.includeDestructuredIfNecessary(context, path, init);
|
|
14098
|
-
}
|
|
14099
|
-
}
|
|
14100
|
-
return (this.included = included);
|
|
14101
|
-
}
|
|
14102
|
-
include(context, includeChildrenRecursively) {
|
|
14103
|
-
this.included = true;
|
|
14104
|
-
this.key.include(context, includeChildrenRecursively);
|
|
14105
|
-
this.value.include(context, includeChildrenRecursively);
|
|
14106
|
-
}
|
|
14107
|
-
includePath(path, context) {
|
|
14108
|
-
this.included = true;
|
|
14109
|
-
this.value.includePath(path, context);
|
|
13440
|
+
if (!this.deoptimized)
|
|
13441
|
+
this.applyDeoptimizations();
|
|
13442
|
+
const propertyReadSideEffects = this.scope.context.options.treeshake.propertyReadSideEffects;
|
|
13443
|
+
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
13444
|
+
this.key.hasEffects(context) ||
|
|
13445
|
+
this.value.hasEffects(context));
|
|
14110
13446
|
}
|
|
14111
13447
|
markDeclarationReached() {
|
|
14112
13448
|
this.value.markDeclarationReached();
|
|
@@ -14117,20 +13453,14 @@ class Property extends MethodBase {
|
|
|
14117
13453
|
}
|
|
14118
13454
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
14119
13455
|
}
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
? [...destructuredInitPath, UnknownKey]
|
|
14127
|
-
: this.key instanceof Identifier
|
|
14128
|
-
? [...destructuredInitPath, this.key.name]
|
|
14129
|
-
: [...destructuredInitPath, String(this.key.value)];
|
|
13456
|
+
applyDeoptimizations() {
|
|
13457
|
+
this.deoptimized = true;
|
|
13458
|
+
if (this.declarationInit !== null) {
|
|
13459
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
13460
|
+
this.scope.context.requestTreeshakingPass();
|
|
13461
|
+
}
|
|
14130
13462
|
}
|
|
14131
13463
|
}
|
|
14132
|
-
Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14133
|
-
Property.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14134
13464
|
|
|
14135
13465
|
class PropertyDefinition extends NodeBase {
|
|
14136
13466
|
get computed() {
|
|
@@ -14163,15 +13493,8 @@ class PropertyDefinition extends NodeBase {
|
|
|
14163
13493
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
14164
13494
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14165
13495
|
}
|
|
14166
|
-
|
|
14167
|
-
this.included = true;
|
|
14168
|
-
this.value?.includePath(UNKNOWN_PATH, context);
|
|
14169
|
-
for (const decorator of this.decorators) {
|
|
14170
|
-
decorator.includePath(UNKNOWN_PATH, context);
|
|
14171
|
-
}
|
|
14172
|
-
}
|
|
13496
|
+
applyDeoptimizations() { }
|
|
14173
13497
|
}
|
|
14174
|
-
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14175
13498
|
|
|
14176
13499
|
class ReturnStatement extends NodeBase {
|
|
14177
13500
|
hasEffects(context) {
|
|
@@ -14181,15 +13504,10 @@ class ReturnStatement extends NodeBase {
|
|
|
14181
13504
|
return false;
|
|
14182
13505
|
}
|
|
14183
13506
|
include(context, includeChildrenRecursively) {
|
|
14184
|
-
|
|
14185
|
-
this.includeNode(context);
|
|
13507
|
+
this.included = true;
|
|
14186
13508
|
this.argument?.include(context, includeChildrenRecursively);
|
|
14187
13509
|
context.brokenFlow = true;
|
|
14188
13510
|
}
|
|
14189
|
-
includeNode(context) {
|
|
14190
|
-
this.included = true;
|
|
14191
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14192
|
-
}
|
|
14193
13511
|
initialise() {
|
|
14194
13512
|
super.initialise();
|
|
14195
13513
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -14203,7 +13521,6 @@ class ReturnStatement extends NodeBase {
|
|
|
14203
13521
|
}
|
|
14204
13522
|
}
|
|
14205
13523
|
}
|
|
14206
|
-
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14207
13524
|
|
|
14208
13525
|
class SequenceExpression extends NodeBase {
|
|
14209
13526
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -14231,15 +13548,10 @@ class SequenceExpression extends NodeBase {
|
|
|
14231
13548
|
for (const expression of this.expressions) {
|
|
14232
13549
|
if (includeChildrenRecursively ||
|
|
14233
13550
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
14234
|
-
expression.shouldBeIncluded(context))
|
|
13551
|
+
expression.shouldBeIncluded(context))
|
|
14235
13552
|
expression.include(context, includeChildrenRecursively);
|
|
14236
|
-
}
|
|
14237
13553
|
}
|
|
14238
13554
|
}
|
|
14239
|
-
includePath(path, context) {
|
|
14240
|
-
this.included = true;
|
|
14241
|
-
this.expressions[this.expressions.length - 1].includePath(path, context);
|
|
14242
|
-
}
|
|
14243
13555
|
removeAnnotations(code) {
|
|
14244
13556
|
this.expressions[0].removeAnnotations(code);
|
|
14245
13557
|
}
|
|
@@ -14274,8 +13586,6 @@ class SequenceExpression extends NodeBase {
|
|
|
14274
13586
|
}
|
|
14275
13587
|
}
|
|
14276
13588
|
}
|
|
14277
|
-
SequenceExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14278
|
-
SequenceExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14279
13589
|
|
|
14280
13590
|
class Super extends NodeBase {
|
|
14281
13591
|
bind() {
|
|
@@ -14287,15 +13597,11 @@ class Super extends NodeBase {
|
|
|
14287
13597
|
deoptimizePath(path) {
|
|
14288
13598
|
this.variable.deoptimizePath(path);
|
|
14289
13599
|
}
|
|
14290
|
-
include(
|
|
14291
|
-
if (!this.included)
|
|
14292
|
-
this.
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
this.included = true;
|
|
14296
|
-
if (!this.deoptimized)
|
|
14297
|
-
this.applyDeoptimizations();
|
|
14298
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13600
|
+
include() {
|
|
13601
|
+
if (!this.included) {
|
|
13602
|
+
this.included = true;
|
|
13603
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13604
|
+
}
|
|
14299
13605
|
}
|
|
14300
13606
|
}
|
|
14301
13607
|
|
|
@@ -14336,8 +13642,6 @@ class SwitchCase extends NodeBase {
|
|
|
14336
13642
|
}
|
|
14337
13643
|
}
|
|
14338
13644
|
SwitchCase.prototype.needsBoundaries = true;
|
|
14339
|
-
SwitchCase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14340
|
-
SwitchCase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14341
13645
|
|
|
14342
13646
|
class SwitchStatement extends NodeBase {
|
|
14343
13647
|
createScope(parentScope) {
|
|
@@ -14420,8 +13724,6 @@ class SwitchStatement extends NodeBase {
|
|
|
14420
13724
|
}
|
|
14421
13725
|
}
|
|
14422
13726
|
}
|
|
14423
|
-
SwitchStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14424
|
-
SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14425
13727
|
|
|
14426
13728
|
class TaggedTemplateExpression extends CallExpressionBase {
|
|
14427
13729
|
bind() {
|
|
@@ -14445,8 +13747,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14445
13747
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
14446
13748
|
}
|
|
14447
13749
|
include(context, includeChildrenRecursively) {
|
|
14448
|
-
if (!this.
|
|
14449
|
-
this.
|
|
13750
|
+
if (!this.deoptimized)
|
|
13751
|
+
this.applyDeoptimizations();
|
|
14450
13752
|
if (includeChildrenRecursively) {
|
|
14451
13753
|
super.include(context, includeChildrenRecursively);
|
|
14452
13754
|
}
|
|
@@ -14455,7 +13757,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14455
13757
|
this.tag.include(context, includeChildrenRecursively);
|
|
14456
13758
|
this.quasi.include(context, includeChildrenRecursively);
|
|
14457
13759
|
}
|
|
14458
|
-
this.tag.includeCallArguments(context, this.
|
|
13760
|
+
this.tag.includeCallArguments(context, this.args);
|
|
14459
13761
|
const [returnExpression] = this.getReturnExpression();
|
|
14460
13762
|
if (!returnExpression.included) {
|
|
14461
13763
|
returnExpression.include(context, false);
|
|
@@ -14490,7 +13792,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14490
13792
|
return this.returnExpression;
|
|
14491
13793
|
}
|
|
14492
13794
|
}
|
|
14493
|
-
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14494
13795
|
|
|
14495
13796
|
class TemplateElement extends NodeBase {
|
|
14496
13797
|
get tail() {
|
|
@@ -14504,13 +13805,15 @@ class TemplateElement extends NodeBase {
|
|
|
14504
13805
|
hasEffects() {
|
|
14505
13806
|
return false;
|
|
14506
13807
|
}
|
|
13808
|
+
include() {
|
|
13809
|
+
this.included = true;
|
|
13810
|
+
}
|
|
14507
13811
|
parseNode(esTreeNode) {
|
|
14508
13812
|
this.value = esTreeNode.value;
|
|
14509
13813
|
return super.parseNode(esTreeNode);
|
|
14510
13814
|
}
|
|
14511
13815
|
render() { }
|
|
14512
13816
|
}
|
|
14513
|
-
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
14514
13817
|
|
|
14515
13818
|
class TemplateLiteral extends NodeBase {
|
|
14516
13819
|
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
@@ -14535,14 +13838,6 @@ class TemplateLiteral extends NodeBase {
|
|
|
14535
13838
|
}
|
|
14536
13839
|
return true;
|
|
14537
13840
|
}
|
|
14538
|
-
includeNode(context) {
|
|
14539
|
-
this.included = true;
|
|
14540
|
-
if (!this.deoptimized)
|
|
14541
|
-
this.applyDeoptimizations();
|
|
14542
|
-
for (const node of this.expressions) {
|
|
14543
|
-
node.includePath(UNKNOWN_PATH, context);
|
|
14544
|
-
}
|
|
14545
|
-
}
|
|
14546
13841
|
render(code, options) {
|
|
14547
13842
|
code.indentExclusionRanges.push([this.start, this.end]);
|
|
14548
13843
|
super.render(code, options);
|
|
@@ -14552,13 +13847,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
14552
13847
|
class ModuleScope extends ChildScope {
|
|
14553
13848
|
constructor(parent, context) {
|
|
14554
13849
|
super(parent, context);
|
|
14555
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
13850
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
14556
13851
|
}
|
|
14557
|
-
addDeclaration(identifier, context, init,
|
|
13852
|
+
addDeclaration(identifier, context, init, kind) {
|
|
14558
13853
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
14559
13854
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
14560
13855
|
}
|
|
14561
|
-
return super.addDeclaration(identifier, context, init,
|
|
13856
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
14562
13857
|
}
|
|
14563
13858
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
14564
13859
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -14603,23 +13898,10 @@ class ThisExpression extends NodeBase {
|
|
|
14603
13898
|
}
|
|
14604
13899
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14605
13900
|
}
|
|
14606
|
-
include(
|
|
14607
|
-
if (!this.included)
|
|
14608
|
-
this.includeNode(context);
|
|
14609
|
-
}
|
|
14610
|
-
includeNode(context) {
|
|
14611
|
-
this.included = true;
|
|
14612
|
-
if (!this.deoptimized)
|
|
14613
|
-
this.applyDeoptimizations();
|
|
14614
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
14615
|
-
}
|
|
14616
|
-
includePath(path, context) {
|
|
13901
|
+
include() {
|
|
14617
13902
|
if (!this.included) {
|
|
14618
13903
|
this.included = true;
|
|
14619
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
14620
|
-
}
|
|
14621
|
-
else if (path.length > 0) {
|
|
14622
|
-
this.variable.includePath(path, context);
|
|
13904
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
14623
13905
|
}
|
|
14624
13906
|
}
|
|
14625
13907
|
initialise() {
|
|
@@ -14647,8 +13929,7 @@ class ThrowStatement extends NodeBase {
|
|
|
14647
13929
|
return true;
|
|
14648
13930
|
}
|
|
14649
13931
|
include(context, includeChildrenRecursively) {
|
|
14650
|
-
|
|
14651
|
-
this.includeNode(context);
|
|
13932
|
+
this.included = true;
|
|
14652
13933
|
this.argument.include(context, includeChildrenRecursively);
|
|
14653
13934
|
context.brokenFlow = true;
|
|
14654
13935
|
}
|
|
@@ -14659,7 +13940,6 @@ class ThrowStatement extends NodeBase {
|
|
|
14659
13940
|
}
|
|
14660
13941
|
}
|
|
14661
13942
|
}
|
|
14662
|
-
ThrowStatement.prototype.includeNode = onlyIncludeSelf;
|
|
14663
13943
|
|
|
14664
13944
|
class TryStatement extends NodeBase {
|
|
14665
13945
|
constructor() {
|
|
@@ -14696,8 +13976,6 @@ class TryStatement extends NodeBase {
|
|
|
14696
13976
|
this.finalizer?.include(context, includeChildrenRecursively);
|
|
14697
13977
|
}
|
|
14698
13978
|
}
|
|
14699
|
-
TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14700
|
-
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14701
13979
|
|
|
14702
13980
|
const unaryOperators = {
|
|
14703
13981
|
'!': value => !value,
|
|
@@ -14743,7 +14021,6 @@ class UnaryExpression extends NodeBase {
|
|
|
14743
14021
|
}
|
|
14744
14022
|
}
|
|
14745
14023
|
}
|
|
14746
|
-
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14747
14024
|
|
|
14748
14025
|
class UpdateExpression extends NodeBase {
|
|
14749
14026
|
hasEffects(context) {
|
|
@@ -14755,8 +14032,9 @@ class UpdateExpression extends NodeBase {
|
|
|
14755
14032
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14756
14033
|
}
|
|
14757
14034
|
include(context, includeChildrenRecursively) {
|
|
14758
|
-
if (!this.
|
|
14759
|
-
this.
|
|
14035
|
+
if (!this.deoptimized)
|
|
14036
|
+
this.applyDeoptimizations();
|
|
14037
|
+
this.included = true;
|
|
14760
14038
|
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
14761
14039
|
}
|
|
14762
14040
|
initialise() {
|
|
@@ -14795,7 +14073,6 @@ class UpdateExpression extends NodeBase {
|
|
|
14795
14073
|
this.scope.context.requestTreeshakingPass();
|
|
14796
14074
|
}
|
|
14797
14075
|
}
|
|
14798
|
-
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14799
14076
|
|
|
14800
14077
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
14801
14078
|
for (const declarator of declarations) {
|
|
@@ -14826,9 +14103,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14826
14103
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14827
14104
|
this.included = true;
|
|
14828
14105
|
for (const declarator of this.declarations) {
|
|
14829
|
-
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14106
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14830
14107
|
declarator.include(context, includeChildrenRecursively);
|
|
14831
|
-
}
|
|
14832
14108
|
const { id, init } = declarator;
|
|
14833
14109
|
if (asSingleStatement) {
|
|
14834
14110
|
id.include(context, includeChildrenRecursively);
|
|
@@ -14866,6 +14142,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
14866
14142
|
this.renderReplacedDeclarations(code, options);
|
|
14867
14143
|
}
|
|
14868
14144
|
}
|
|
14145
|
+
applyDeoptimizations() { }
|
|
14869
14146
|
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
14870
14147
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
14871
14148
|
code.remove(this.end - 1, this.end);
|
|
@@ -14908,7 +14185,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14908
14185
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
14909
14186
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
14910
14187
|
if (!node.included) {
|
|
14911
|
-
|
|
14188
|
+
code.remove(start, end);
|
|
14189
|
+
node.removeAnnotations(code);
|
|
14912
14190
|
continue;
|
|
14913
14191
|
}
|
|
14914
14192
|
node.render(code, options);
|
|
@@ -14978,8 +14256,6 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
14978
14256
|
}
|
|
14979
14257
|
return singleSystemExport;
|
|
14980
14258
|
}
|
|
14981
|
-
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14982
|
-
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14983
14259
|
|
|
14984
14260
|
class WhileStatement extends NodeBase {
|
|
14985
14261
|
hasEffects(context) {
|
|
@@ -14993,25 +14269,13 @@ class WhileStatement extends NodeBase {
|
|
|
14993
14269
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
14994
14270
|
}
|
|
14995
14271
|
}
|
|
14996
|
-
WhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14997
|
-
WhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14998
14272
|
|
|
14999
14273
|
class YieldExpression extends NodeBase {
|
|
15000
|
-
applyDeoptimizations() {
|
|
15001
|
-
this.deoptimized = true;
|
|
15002
|
-
this.argument?.deoptimizePath(UNKNOWN_PATH);
|
|
15003
|
-
}
|
|
15004
14274
|
hasEffects(context) {
|
|
15005
14275
|
if (!this.deoptimized)
|
|
15006
14276
|
this.applyDeoptimizations();
|
|
15007
14277
|
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
15008
14278
|
}
|
|
15009
|
-
includeNode(context) {
|
|
15010
|
-
this.included = true;
|
|
15011
|
-
if (!this.deoptimized)
|
|
15012
|
-
this.applyDeoptimizations();
|
|
15013
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
15014
|
-
}
|
|
15015
14279
|
render(code, options) {
|
|
15016
14280
|
if (this.argument) {
|
|
15017
14281
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -15245,7 +14509,7 @@ const bufferParsers = [
|
|
|
15245
14509
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
15246
14510
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
15247
14511
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
15248
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14512
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15249
14513
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
15250
14514
|
},
|
|
15251
14515
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -15291,7 +14555,7 @@ const bufferParsers = [
|
|
|
15291
14555
|
const parameterPosition = buffer[position];
|
|
15292
14556
|
const parameter = (node.param =
|
|
15293
14557
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
15294
|
-
parameter?.declare('parameter',
|
|
14558
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
15295
14559
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
15296
14560
|
},
|
|
15297
14561
|
function chainExpression(node, position, buffer) {
|
|
@@ -15429,7 +14693,7 @@ const bufferParsers = [
|
|
|
15429
14693
|
node.id =
|
|
15430
14694
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
15431
14695
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15432
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14696
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15433
14697
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15434
14698
|
},
|
|
15435
14699
|
function functionExpression(node, position, buffer) {
|
|
@@ -15442,7 +14706,7 @@ const bufferParsers = [
|
|
|
15442
14706
|
const idPosition = buffer[position + 2];
|
|
15443
14707
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
15444
14708
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15445
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14709
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15446
14710
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15447
14711
|
},
|
|
15448
14712
|
function identifier(node, position, buffer) {
|
|
@@ -15906,8 +15170,8 @@ class ExportShimVariable extends Variable {
|
|
|
15906
15170
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
15907
15171
|
this.module = module;
|
|
15908
15172
|
}
|
|
15909
|
-
|
|
15910
|
-
super.
|
|
15173
|
+
include() {
|
|
15174
|
+
super.include();
|
|
15911
15175
|
this.module.needsExportShim = true;
|
|
15912
15176
|
}
|
|
15913
15177
|
}
|
|
@@ -16605,15 +15869,16 @@ class Module {
|
|
|
16605
15869
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
16606
15870
|
this.graph.needsTreeshakingPass = true;
|
|
16607
15871
|
}
|
|
16608
|
-
const inclusionContext = createInclusionContext();
|
|
16609
15872
|
for (const exportName of this.exports.keys()) {
|
|
16610
15873
|
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
16611
15874
|
const variable = this.getVariableForExportName(exportName)[0];
|
|
16612
15875
|
if (!variable) {
|
|
16613
15876
|
return error(logMissingEntryExport(exportName, this.id));
|
|
16614
15877
|
}
|
|
16615
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
16616
15878
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15879
|
+
if (!variable.included) {
|
|
15880
|
+
this.includeVariable(variable);
|
|
15881
|
+
}
|
|
16617
15882
|
}
|
|
16618
15883
|
}
|
|
16619
15884
|
for (const name of this.getReexports()) {
|
|
@@ -16621,7 +15886,7 @@ class Module {
|
|
|
16621
15886
|
if (variable) {
|
|
16622
15887
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16623
15888
|
if (!variable.included) {
|
|
16624
|
-
this.includeVariable(variable
|
|
15889
|
+
this.includeVariable(variable);
|
|
16625
15890
|
}
|
|
16626
15891
|
if (variable instanceof ExternalVariable) {
|
|
16627
15892
|
variable.module.reexported = true;
|
|
@@ -16642,12 +15907,13 @@ class Module {
|
|
|
16642
15907
|
this.graph.needsTreeshakingPass = true;
|
|
16643
15908
|
}
|
|
16644
15909
|
let includeNamespaceMembers = false;
|
|
16645
|
-
const inclusionContext = createInclusionContext();
|
|
16646
15910
|
for (const name of names) {
|
|
16647
15911
|
const variable = this.getVariableForExportName(name)[0];
|
|
16648
15912
|
if (variable) {
|
|
16649
15913
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16650
|
-
|
|
15914
|
+
if (!variable.included) {
|
|
15915
|
+
this.includeVariable(variable);
|
|
15916
|
+
}
|
|
16651
15917
|
}
|
|
16652
15918
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
16653
15919
|
includeNamespaceMembers = true;
|
|
@@ -16748,7 +16014,6 @@ class Module {
|
|
|
16748
16014
|
manualPureFunctions: this.graph.pureFunctions,
|
|
16749
16015
|
module: this,
|
|
16750
16016
|
moduleContext: this.context,
|
|
16751
|
-
newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
|
|
16752
16017
|
options: this.options,
|
|
16753
16018
|
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
|
|
16754
16019
|
traceExport: (name) => this.getVariableForExportName(name)[0],
|
|
@@ -17089,13 +16354,13 @@ class Module {
|
|
|
17089
16354
|
for (const module of [this, ...this.exportAllModules]) {
|
|
17090
16355
|
if (module instanceof ExternalModule) {
|
|
17091
16356
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
17092
|
-
externalVariable.
|
|
16357
|
+
externalVariable.include();
|
|
17093
16358
|
this.includedImports.add(externalVariable);
|
|
17094
16359
|
externalNamespaces.add(externalVariable);
|
|
17095
16360
|
}
|
|
17096
16361
|
else if (module.info.syntheticNamedExports) {
|
|
17097
16362
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
17098
|
-
syntheticNamespace.
|
|
16363
|
+
syntheticNamespace.include();
|
|
17099
16364
|
this.includedImports.add(syntheticNamespace);
|
|
17100
16365
|
syntheticNamespaces.add(syntheticNamespace);
|
|
17101
16366
|
}
|
|
@@ -17105,9 +16370,7 @@ class Module {
|
|
|
17105
16370
|
includeDynamicImport(node) {
|
|
17106
16371
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
17107
16372
|
if (resolution instanceof Module) {
|
|
17108
|
-
|
|
17109
|
-
resolution.includedDynamicImporters.push(this);
|
|
17110
|
-
}
|
|
16373
|
+
resolution.includedDynamicImporters.push(this);
|
|
17111
16374
|
const importedNames = this.options.treeshake
|
|
17112
16375
|
? node.getDeterministicImportedNames()
|
|
17113
16376
|
: undefined;
|
|
@@ -17119,15 +16382,15 @@ class Module {
|
|
|
17119
16382
|
}
|
|
17120
16383
|
}
|
|
17121
16384
|
}
|
|
17122
|
-
includeVariable(variable
|
|
17123
|
-
const
|
|
17124
|
-
variable.
|
|
17125
|
-
if (included) {
|
|
16385
|
+
includeVariable(variable) {
|
|
16386
|
+
const variableModule = variable.module;
|
|
16387
|
+
if (variable.included) {
|
|
17126
16388
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
17127
16389
|
getAndExtendSideEffectModules(variable, this);
|
|
17128
16390
|
}
|
|
17129
16391
|
}
|
|
17130
16392
|
else {
|
|
16393
|
+
variable.include();
|
|
17131
16394
|
this.graph.needsTreeshakingPass = true;
|
|
17132
16395
|
if (variableModule instanceof Module) {
|
|
17133
16396
|
if (!variableModule.isExecuted) {
|
|
@@ -17144,8 +16407,8 @@ class Module {
|
|
|
17144
16407
|
}
|
|
17145
16408
|
}
|
|
17146
16409
|
}
|
|
17147
|
-
includeVariableInModule(variable
|
|
17148
|
-
this.includeVariable(variable
|
|
16410
|
+
includeVariableInModule(variable) {
|
|
16411
|
+
this.includeVariable(variable);
|
|
17149
16412
|
const variableModule = variable.module;
|
|
17150
16413
|
if (variableModule && variableModule !== this) {
|
|
17151
16414
|
this.includedImports.add(variable);
|
|
@@ -21742,11 +21005,10 @@ class Graph {
|
|
|
21742
21005
|
this.options = options;
|
|
21743
21006
|
this.astLru = flru(5);
|
|
21744
21007
|
this.cachedModules = new Map();
|
|
21745
|
-
this.deoptimizationTracker = new
|
|
21008
|
+
this.deoptimizationTracker = new PathTracker();
|
|
21746
21009
|
this.entryModules = [];
|
|
21747
21010
|
this.modulesById = new Map();
|
|
21748
21011
|
this.needsTreeshakingPass = false;
|
|
21749
|
-
this.newlyIncludedVariableInits = new Set();
|
|
21750
21012
|
this.phase = BuildPhase.LOAD_AND_PARSE;
|
|
21751
21013
|
this.scope = new GlobalScope();
|
|
21752
21014
|
this.watchFiles = Object.create(null);
|
|
@@ -21840,7 +21102,6 @@ class Graph {
|
|
|
21840
21102
|
}
|
|
21841
21103
|
if (this.options.treeshake) {
|
|
21842
21104
|
let treeshakingPass = 1;
|
|
21843
|
-
this.newlyIncludedVariableInits.clear();
|
|
21844
21105
|
do {
|
|
21845
21106
|
timeStart(`treeshaking pass ${treeshakingPass}`, 3);
|
|
21846
21107
|
this.needsTreeshakingPass = false;
|
|
@@ -21865,10 +21126,6 @@ class Graph {
|
|
|
21865
21126
|
}
|
|
21866
21127
|
}
|
|
21867
21128
|
}
|
|
21868
|
-
for (const entity of this.newlyIncludedVariableInits) {
|
|
21869
|
-
this.newlyIncludedVariableInits.delete(entity);
|
|
21870
|
-
entity.include(createInclusionContext(), false);
|
|
21871
|
-
}
|
|
21872
21129
|
timeEnd(`treeshaking pass ${treeshakingPass++}`, 3);
|
|
21873
21130
|
} while (this.needsTreeshakingPass);
|
|
21874
21131
|
}
|
|
@@ -22748,7 +22005,7 @@ createColors();
|
|
|
22748
22005
|
|
|
22749
22006
|
// @see https://no-color.org
|
|
22750
22007
|
// @see https://www.npmjs.com/package/chalk
|
|
22751
|
-
const { bold, cyan, dim, red} = createColors({
|
|
22008
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({
|
|
22752
22009
|
useColor: env$1.FORCE_COLOR !== '0' && !env$1.NO_COLOR
|
|
22753
22010
|
});
|
|
22754
22011
|
|