@rollup/wasm-node 4.31.0-0 → 4.32.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 +683 -1498
- package/dist/es/shared/parseAst.js +3 -3
- package/dist/es/shared/watch.js +10 -9
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.d.ts +1 -0
- 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 +3 -3
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +679 -1494
- package/dist/shared/watch-cli.js +21 -9
- package/dist/shared/watch.js +7 -6
- package/dist/wasm-node/bindings_wasm.js +16 -16
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +21 -21
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.32.0
|
|
4
|
+
Fri, 24 Jan 2025 08:27:05 GMT - commit 2538304efdc05ecb7c52e6376d5777565139f075
|
|
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 } 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
|
|
|
18
|
-
var version = "4.
|
|
18
|
+
var version = "4.32.0";
|
|
19
19
|
|
|
20
20
|
const comma = ','.charCodeAt(0);
|
|
21
21
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -1964,6 +1964,71 @@ function renderSystemExportSequenceBeforeExpression(exportedVariable, expression
|
|
|
1964
1964
|
}
|
|
1965
1965
|
}
|
|
1966
1966
|
|
|
1967
|
+
/** @import { Node } from 'estree' */
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* @param {Node} node
|
|
1971
|
+
* @param {Node} parent
|
|
1972
|
+
* @returns {boolean}
|
|
1973
|
+
*/
|
|
1974
|
+
function is_reference(node, parent) {
|
|
1975
|
+
if (node.type === 'MemberExpression') {
|
|
1976
|
+
return !node.computed && is_reference(node.object, node);
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
if (node.type !== 'Identifier') return false;
|
|
1980
|
+
|
|
1981
|
+
switch (parent?.type) {
|
|
1982
|
+
// disregard `bar` in `foo.bar`
|
|
1983
|
+
case 'MemberExpression':
|
|
1984
|
+
return parent.computed || node === parent.object;
|
|
1985
|
+
|
|
1986
|
+
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
1987
|
+
case 'MethodDefinition':
|
|
1988
|
+
return parent.computed;
|
|
1989
|
+
|
|
1990
|
+
// disregard the `meta` in `import.meta`
|
|
1991
|
+
case 'MetaProperty':
|
|
1992
|
+
return parent.meta === node;
|
|
1993
|
+
|
|
1994
|
+
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
1995
|
+
case 'PropertyDefinition':
|
|
1996
|
+
return parent.computed || node === parent.value;
|
|
1997
|
+
|
|
1998
|
+
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
1999
|
+
case 'Property':
|
|
2000
|
+
return parent.computed || node === parent.value;
|
|
2001
|
+
|
|
2002
|
+
// disregard the `bar` in `export { foo as bar }` or
|
|
2003
|
+
// the foo in `import { foo as bar }`
|
|
2004
|
+
case 'ExportSpecifier':
|
|
2005
|
+
case 'ImportSpecifier':
|
|
2006
|
+
return node === parent.local;
|
|
2007
|
+
|
|
2008
|
+
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2009
|
+
case 'LabeledStatement':
|
|
2010
|
+
case 'BreakStatement':
|
|
2011
|
+
case 'ContinueStatement':
|
|
2012
|
+
return false;
|
|
2013
|
+
|
|
2014
|
+
default:
|
|
2015
|
+
return true;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
|
|
2019
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
2020
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
2021
|
+
const pureFunctions = Object.create(null);
|
|
2022
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2023
|
+
let currentFunctions = pureFunctions;
|
|
2024
|
+
for (const pathSegment of functionName.split('.')) {
|
|
2025
|
+
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2026
|
+
}
|
|
2027
|
+
currentFunctions[PureFunctionKey] = true;
|
|
2028
|
+
}
|
|
2029
|
+
return pureFunctions;
|
|
2030
|
+
};
|
|
2031
|
+
|
|
1967
2032
|
function getOrCreate(map, key, init) {
|
|
1968
2033
|
const existing = map.get(key);
|
|
1969
2034
|
if (existing !== undefined) {
|
|
@@ -1994,7 +2059,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
1994
2059
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
1995
2060
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
1996
2061
|
const EntitiesKey = Symbol('Entities');
|
|
1997
|
-
class
|
|
2062
|
+
class PathTracker {
|
|
1998
2063
|
constructor() {
|
|
1999
2064
|
this.entityPaths = Object.create(null, {
|
|
2000
2065
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -2019,14 +2084,14 @@ class EntityPathTracker {
|
|
|
2019
2084
|
getEntities(path) {
|
|
2020
2085
|
let currentPaths = this.entityPaths;
|
|
2021
2086
|
for (const pathSegment of path) {
|
|
2022
|
-
currentPaths = currentPaths[pathSegment]
|
|
2023
|
-
[
|
|
2024
|
-
|
|
2087
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2088
|
+
currentPaths[pathSegment] ||
|
|
2089
|
+
Object.create(null, { [EntitiesKey]: { value: new Set() } });
|
|
2025
2090
|
}
|
|
2026
2091
|
return currentPaths[EntitiesKey];
|
|
2027
2092
|
}
|
|
2028
2093
|
}
|
|
2029
|
-
const SHARED_RECURSION_TRACKER = new
|
|
2094
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
2030
2095
|
class DiscriminatedPathTracker {
|
|
2031
2096
|
constructor() {
|
|
2032
2097
|
this.entityPaths = Object.create(null, {
|
|
@@ -2036,9 +2101,9 @@ class DiscriminatedPathTracker {
|
|
|
2036
2101
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
2037
2102
|
let currentPaths = this.entityPaths;
|
|
2038
2103
|
for (const pathSegment of path) {
|
|
2039
|
-
currentPaths = currentPaths[pathSegment]
|
|
2040
|
-
[
|
|
2041
|
-
|
|
2104
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2105
|
+
currentPaths[pathSegment] ||
|
|
2106
|
+
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
2042
2107
|
}
|
|
2043
2108
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
2044
2109
|
if (trackedEntities.has(entity))
|
|
@@ -2047,137 +2112,6 @@ class DiscriminatedPathTracker {
|
|
|
2047
2112
|
return false;
|
|
2048
2113
|
}
|
|
2049
2114
|
}
|
|
2050
|
-
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: EMPTY_OBJECT });
|
|
2051
|
-
class IncludedPathTracker {
|
|
2052
|
-
constructor() {
|
|
2053
|
-
this.includedPaths = null;
|
|
2054
|
-
}
|
|
2055
|
-
includePathAndGetIfIncluded(path) {
|
|
2056
|
-
let included = true;
|
|
2057
|
-
let parent = this;
|
|
2058
|
-
let parentSegment = 'includedPaths';
|
|
2059
|
-
let currentPaths = (this.includedPaths ||=
|
|
2060
|
-
((included = false), Object.create(null)));
|
|
2061
|
-
for (const pathSegment of path) {
|
|
2062
|
-
// This means from here, all paths are included
|
|
2063
|
-
if (currentPaths[UnknownKey]) {
|
|
2064
|
-
return true;
|
|
2065
|
-
}
|
|
2066
|
-
// Including UnknownKey automatically includes all nested paths.
|
|
2067
|
-
// From above, we know that UnknownKey is not included yet.
|
|
2068
|
-
if (typeof pathSegment === 'symbol') {
|
|
2069
|
-
// Hopefully, this saves some memory over just setting
|
|
2070
|
-
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2071
|
-
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
2072
|
-
return false;
|
|
2073
|
-
}
|
|
2074
|
-
parent = currentPaths;
|
|
2075
|
-
parentSegment = pathSegment;
|
|
2076
|
-
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
2077
|
-
}
|
|
2078
|
-
return included;
|
|
2079
|
-
}
|
|
2080
|
-
includeAllPaths(entity, context, basePath) {
|
|
2081
|
-
const { includedPaths } = this;
|
|
2082
|
-
if (includedPaths) {
|
|
2083
|
-
includeAllPaths(entity, context, basePath, includedPaths);
|
|
2084
|
-
}
|
|
2085
|
-
}
|
|
2086
|
-
}
|
|
2087
|
-
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
2088
|
-
if (currentPaths[UnknownKey]) {
|
|
2089
|
-
return entity.includePath([...basePath, UnknownKey], context);
|
|
2090
|
-
}
|
|
2091
|
-
const keys = Object.keys(currentPaths);
|
|
2092
|
-
if (keys.length === 0) {
|
|
2093
|
-
return entity.includePath(basePath, context);
|
|
2094
|
-
}
|
|
2095
|
-
for (const key of keys) {
|
|
2096
|
-
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
|
|
2100
|
-
/** @import { Node } from 'estree' */
|
|
2101
|
-
|
|
2102
|
-
/**
|
|
2103
|
-
* @param {Node} node
|
|
2104
|
-
* @param {Node} parent
|
|
2105
|
-
* @returns {boolean}
|
|
2106
|
-
*/
|
|
2107
|
-
function is_reference(node, parent) {
|
|
2108
|
-
if (node.type === 'MemberExpression') {
|
|
2109
|
-
return !node.computed && is_reference(node.object, node);
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
if (node.type !== 'Identifier') return false;
|
|
2113
|
-
|
|
2114
|
-
switch (parent?.type) {
|
|
2115
|
-
// disregard `bar` in `foo.bar`
|
|
2116
|
-
case 'MemberExpression':
|
|
2117
|
-
return parent.computed || node === parent.object;
|
|
2118
|
-
|
|
2119
|
-
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
2120
|
-
case 'MethodDefinition':
|
|
2121
|
-
return parent.computed;
|
|
2122
|
-
|
|
2123
|
-
// disregard the `meta` in `import.meta`
|
|
2124
|
-
case 'MetaProperty':
|
|
2125
|
-
return parent.meta === node;
|
|
2126
|
-
|
|
2127
|
-
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
2128
|
-
case 'PropertyDefinition':
|
|
2129
|
-
return parent.computed || node === parent.value;
|
|
2130
|
-
|
|
2131
|
-
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
2132
|
-
case 'Property':
|
|
2133
|
-
return parent.computed || node === parent.value;
|
|
2134
|
-
|
|
2135
|
-
// disregard the `bar` in `export { foo as bar }` or
|
|
2136
|
-
// the foo in `import { foo as bar }`
|
|
2137
|
-
case 'ExportSpecifier':
|
|
2138
|
-
case 'ImportSpecifier':
|
|
2139
|
-
return node === parent.local;
|
|
2140
|
-
|
|
2141
|
-
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
2142
|
-
case 'LabeledStatement':
|
|
2143
|
-
case 'BreakStatement':
|
|
2144
|
-
case 'ContinueStatement':
|
|
2145
|
-
return false;
|
|
2146
|
-
|
|
2147
|
-
default:
|
|
2148
|
-
return true;
|
|
2149
|
-
}
|
|
2150
|
-
}
|
|
2151
|
-
|
|
2152
|
-
function createInclusionContext() {
|
|
2153
|
-
return {
|
|
2154
|
-
brokenFlow: false,
|
|
2155
|
-
hasBreak: false,
|
|
2156
|
-
hasContinue: false,
|
|
2157
|
-
includedCallArguments: new Set(),
|
|
2158
|
-
includedLabels: new Set()
|
|
2159
|
-
};
|
|
2160
|
-
}
|
|
2161
|
-
function createHasEffectsContext() {
|
|
2162
|
-
return {
|
|
2163
|
-
accessed: new EntityPathTracker(),
|
|
2164
|
-
assigned: new EntityPathTracker(),
|
|
2165
|
-
brokenFlow: false,
|
|
2166
|
-
called: new DiscriminatedPathTracker(),
|
|
2167
|
-
hasBreak: false,
|
|
2168
|
-
hasContinue: false,
|
|
2169
|
-
ignore: {
|
|
2170
|
-
breaks: false,
|
|
2171
|
-
continues: false,
|
|
2172
|
-
labels: new Set(),
|
|
2173
|
-
returnYield: false,
|
|
2174
|
-
this: false
|
|
2175
|
-
},
|
|
2176
|
-
includedLabels: new Set(),
|
|
2177
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
2178
|
-
replacedVariableInits: new Map()
|
|
2179
|
-
};
|
|
2180
|
-
}
|
|
2181
2115
|
|
|
2182
2116
|
function isFlagSet(flags, flag) {
|
|
2183
2117
|
return (flags & flag) !== 0;
|
|
@@ -2217,25 +2151,12 @@ class ExpressionEntity {
|
|
|
2217
2151
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2218
2152
|
return true;
|
|
2219
2153
|
}
|
|
2220
|
-
include(
|
|
2221
|
-
if (!this.included)
|
|
2222
|
-
this.includeNode(context);
|
|
2223
|
-
}
|
|
2224
|
-
includeNode(_context) {
|
|
2154
|
+
include(_context, _includeChildrenRecursively, _options) {
|
|
2225
2155
|
this.included = true;
|
|
2226
2156
|
}
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
}
|
|
2231
|
-
/* We are both including and including an unknown path here as the former
|
|
2232
|
-
* ensures that nested nodes are included while the latter ensures that all
|
|
2233
|
-
* paths of the expression are included.
|
|
2234
|
-
* */
|
|
2235
|
-
includeCallArguments(context, interaction) {
|
|
2236
|
-
for (const argument of interaction.args) {
|
|
2237
|
-
argument?.includePath(UNKNOWN_PATH, context);
|
|
2238
|
-
argument?.include(context, false);
|
|
2157
|
+
includeCallArguments(context, parameters) {
|
|
2158
|
+
for (const argument of parameters) {
|
|
2159
|
+
argument.include(context, false);
|
|
2239
2160
|
}
|
|
2240
2161
|
}
|
|
2241
2162
|
shouldBeIncluded(_context) {
|
|
@@ -2274,19 +2195,6 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
2274
2195
|
withNew: false
|
|
2275
2196
|
};
|
|
2276
2197
|
|
|
2277
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
2278
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
2279
|
-
const pureFunctions = Object.create(null);
|
|
2280
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2281
|
-
let currentFunctions = pureFunctions;
|
|
2282
|
-
for (const pathSegment of functionName.split('.')) {
|
|
2283
|
-
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2284
|
-
}
|
|
2285
|
-
currentFunctions[PureFunctionKey] = true;
|
|
2286
|
-
}
|
|
2287
|
-
return pureFunctions;
|
|
2288
|
-
};
|
|
2289
|
-
|
|
2290
2198
|
class Variable extends ExpressionEntity {
|
|
2291
2199
|
markReassigned() {
|
|
2292
2200
|
this.isReassigned = true;
|
|
@@ -2363,9 +2271,9 @@ class Variable extends ExpressionEntity {
|
|
|
2363
2271
|
* has not been included previously. Once a variable is included, it should
|
|
2364
2272
|
* take care all its declarations are included.
|
|
2365
2273
|
*/
|
|
2366
|
-
|
|
2274
|
+
include() {
|
|
2367
2275
|
this.included = true;
|
|
2368
|
-
this.renderedLikeHoisted?.
|
|
2276
|
+
this.renderedLikeHoisted?.include();
|
|
2369
2277
|
}
|
|
2370
2278
|
/**
|
|
2371
2279
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -2397,8 +2305,8 @@ class ExternalVariable extends Variable {
|
|
|
2397
2305
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2398
2306
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2399
2307
|
}
|
|
2400
|
-
|
|
2401
|
-
super.
|
|
2308
|
+
include() {
|
|
2309
|
+
super.include();
|
|
2402
2310
|
this.module.used = true;
|
|
2403
2311
|
}
|
|
2404
2312
|
}
|
|
@@ -2699,6 +2607,36 @@ const childNodeKeys = {
|
|
|
2699
2607
|
YieldExpression: ['argument']
|
|
2700
2608
|
};
|
|
2701
2609
|
|
|
2610
|
+
function createInclusionContext() {
|
|
2611
|
+
return {
|
|
2612
|
+
brokenFlow: false,
|
|
2613
|
+
hasBreak: false,
|
|
2614
|
+
hasContinue: false,
|
|
2615
|
+
includedCallArguments: new Set(),
|
|
2616
|
+
includedLabels: new Set()
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
function createHasEffectsContext() {
|
|
2620
|
+
return {
|
|
2621
|
+
accessed: new PathTracker(),
|
|
2622
|
+
assigned: new PathTracker(),
|
|
2623
|
+
brokenFlow: false,
|
|
2624
|
+
called: new DiscriminatedPathTracker(),
|
|
2625
|
+
hasBreak: false,
|
|
2626
|
+
hasContinue: false,
|
|
2627
|
+
ignore: {
|
|
2628
|
+
breaks: false,
|
|
2629
|
+
continues: false,
|
|
2630
|
+
labels: new Set(),
|
|
2631
|
+
returnYield: false,
|
|
2632
|
+
this: false
|
|
2633
|
+
},
|
|
2634
|
+
includedLabels: new Set(),
|
|
2635
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
2636
|
+
replacedVariableInits: new Map()
|
|
2637
|
+
};
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2702
2640
|
const INCLUDE_PARAMETERS = 'variables';
|
|
2703
2641
|
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
2704
2642
|
class NodeBase extends ExpressionEntity {
|
|
@@ -2768,37 +2706,20 @@ class NodeBase extends ExpressionEntity {
|
|
|
2768
2706
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
2769
2707
|
}
|
|
2770
2708
|
include(context, includeChildrenRecursively, _options) {
|
|
2771
|
-
if (!this.included)
|
|
2772
|
-
this.includeNode(context);
|
|
2773
|
-
for (const key of childNodeKeys[this.type]) {
|
|
2774
|
-
const value = this[key];
|
|
2775
|
-
if (value === null)
|
|
2776
|
-
continue;
|
|
2777
|
-
if (Array.isArray(value)) {
|
|
2778
|
-
for (const child of value) {
|
|
2779
|
-
child?.include(context, includeChildrenRecursively);
|
|
2780
|
-
}
|
|
2781
|
-
}
|
|
2782
|
-
else {
|
|
2783
|
-
value.include(context, includeChildrenRecursively);
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
includeNode(context) {
|
|
2788
|
-
this.included = true;
|
|
2789
2709
|
if (!this.deoptimized)
|
|
2790
2710
|
this.applyDeoptimizations();
|
|
2711
|
+
this.included = true;
|
|
2791
2712
|
for (const key of childNodeKeys[this.type]) {
|
|
2792
2713
|
const value = this[key];
|
|
2793
2714
|
if (value === null)
|
|
2794
2715
|
continue;
|
|
2795
2716
|
if (Array.isArray(value)) {
|
|
2796
2717
|
for (const child of value) {
|
|
2797
|
-
child?.
|
|
2718
|
+
child?.include(context, includeChildrenRecursively);
|
|
2798
2719
|
}
|
|
2799
2720
|
}
|
|
2800
2721
|
else {
|
|
2801
|
-
value.
|
|
2722
|
+
value.include(context, includeChildrenRecursively);
|
|
2802
2723
|
}
|
|
2803
2724
|
}
|
|
2804
2725
|
}
|
|
@@ -2905,17 +2826,6 @@ class NodeBase extends ExpressionEntity {
|
|
|
2905
2826
|
function createChildNodeKeysForNode(esTreeNode) {
|
|
2906
2827
|
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
2907
2828
|
}
|
|
2908
|
-
function onlyIncludeSelf() {
|
|
2909
|
-
this.included = true;
|
|
2910
|
-
if (!this.deoptimized)
|
|
2911
|
-
this.applyDeoptimizations();
|
|
2912
|
-
}
|
|
2913
|
-
function onlyIncludeSelfNoDeoptimize() {
|
|
2914
|
-
this.included = true;
|
|
2915
|
-
}
|
|
2916
|
-
function doNotDeoptimize() {
|
|
2917
|
-
this.deoptimized = true;
|
|
2918
|
-
}
|
|
2919
2829
|
|
|
2920
2830
|
function isObjectExpressionNode(node) {
|
|
2921
2831
|
return node instanceof NodeBase && node.type === ObjectExpression$1;
|
|
@@ -2928,8 +2838,8 @@ function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions =
|
|
|
2928
2838
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
2929
2839
|
}
|
|
2930
2840
|
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
2931
|
-
getLiteralValueAtPath(
|
|
2932
|
-
return
|
|
2841
|
+
getLiteralValueAtPath() {
|
|
2842
|
+
return undefined;
|
|
2933
2843
|
}
|
|
2934
2844
|
})();
|
|
2935
2845
|
const returnsUnknown = {
|
|
@@ -3126,6 +3036,31 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
3126
3036
|
return [members[memberName].returns, false];
|
|
3127
3037
|
}
|
|
3128
3038
|
|
|
3039
|
+
class SpreadElement extends NodeBase {
|
|
3040
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3041
|
+
if (path.length > 0) {
|
|
3042
|
+
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
hasEffects(context) {
|
|
3046
|
+
if (!this.deoptimized)
|
|
3047
|
+
this.applyDeoptimizations();
|
|
3048
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
3049
|
+
.treeshake;
|
|
3050
|
+
return (this.argument.hasEffects(context) ||
|
|
3051
|
+
(propertyReadSideEffects &&
|
|
3052
|
+
(propertyReadSideEffects === 'always' ||
|
|
3053
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3054
|
+
}
|
|
3055
|
+
applyDeoptimizations() {
|
|
3056
|
+
this.deoptimized = true;
|
|
3057
|
+
// Only properties of properties of the argument could become subject to reassignment
|
|
3058
|
+
// This will also reassign the return values of iterators
|
|
3059
|
+
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3060
|
+
this.scope.context.requestTreeshakingPass();
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3129
3064
|
class Method extends ExpressionEntity {
|
|
3130
3065
|
constructor(description) {
|
|
3131
3066
|
super();
|
|
@@ -3251,7 +3186,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3251
3186
|
this.unknownIntegerProps = [];
|
|
3252
3187
|
this.unmatchableGetters = [];
|
|
3253
3188
|
this.unmatchablePropertiesAndGetters = [];
|
|
3254
|
-
this.unmatchablePropertiesAndSetters = [];
|
|
3255
3189
|
this.unmatchableSetters = [];
|
|
3256
3190
|
if (Array.isArray(properties)) {
|
|
3257
3191
|
this.buildPropertyMaps(properties);
|
|
@@ -3408,12 +3342,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3408
3342
|
}
|
|
3409
3343
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
3410
3344
|
if (path.length === 0) {
|
|
3411
|
-
|
|
3412
|
-
// causes an issue with TypeScript enums in files with moduleSideEffects:
|
|
3413
|
-
// false because we cannot properly track whether a "var" has been
|
|
3414
|
-
// initialized. This should be reverted once we can properly track this.
|
|
3415
|
-
// return UnknownTruthyValue;
|
|
3416
|
-
return UnknownValue;
|
|
3345
|
+
return UnknownTruthyValue;
|
|
3417
3346
|
}
|
|
3418
3347
|
const key = path[0];
|
|
3419
3348
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
@@ -3491,38 +3420,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3491
3420
|
}
|
|
3492
3421
|
return false;
|
|
3493
3422
|
}
|
|
3494
|
-
include(context, includeChildrenRecursively) {
|
|
3495
|
-
this.included = true;
|
|
3496
|
-
for (const property of this.allProperties) {
|
|
3497
|
-
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
3498
|
-
property.include(context, includeChildrenRecursively);
|
|
3499
|
-
}
|
|
3500
|
-
}
|
|
3501
|
-
this.prototypeExpression?.include(context, includeChildrenRecursively);
|
|
3502
|
-
}
|
|
3503
|
-
includePath(path, context) {
|
|
3504
|
-
this.included = true;
|
|
3505
|
-
if (path.length === 0)
|
|
3506
|
-
return;
|
|
3507
|
-
const [key, ...subPath] = path;
|
|
3508
|
-
const [includedMembers, includedPath] = typeof key === 'string'
|
|
3509
|
-
? [
|
|
3510
|
-
[
|
|
3511
|
-
...new Set([
|
|
3512
|
-
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
3513
|
-
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
3514
|
-
])
|
|
3515
|
-
],
|
|
3516
|
-
subPath
|
|
3517
|
-
]
|
|
3518
|
-
: [this.allProperties, UNKNOWN_PATH];
|
|
3519
|
-
for (const property of includedMembers) {
|
|
3520
|
-
property.includePath(includedPath, context);
|
|
3521
|
-
}
|
|
3522
|
-
this.prototypeExpression?.includePath(path, context);
|
|
3523
|
-
}
|
|
3524
3423
|
buildPropertyMaps(properties) {
|
|
3525
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters,
|
|
3424
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3425
|
+
const unmatchablePropertiesAndSetters = [];
|
|
3526
3426
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3527
3427
|
const { key, kind, property } = properties[index];
|
|
3528
3428
|
allProperties.push(property);
|
|
@@ -3792,37 +3692,6 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
3792
3692
|
values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
|
|
3793
3693
|
}, OBJECT_PROTOTYPE, true);
|
|
3794
3694
|
|
|
3795
|
-
class SpreadElement extends NodeBase {
|
|
3796
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
3797
|
-
if (path.length > 0) {
|
|
3798
|
-
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
3799
|
-
}
|
|
3800
|
-
}
|
|
3801
|
-
hasEffects(context) {
|
|
3802
|
-
if (!this.deoptimized)
|
|
3803
|
-
this.applyDeoptimizations();
|
|
3804
|
-
const { propertyReadSideEffects } = this.scope.context.options
|
|
3805
|
-
.treeshake;
|
|
3806
|
-
return (this.argument.hasEffects(context) ||
|
|
3807
|
-
(propertyReadSideEffects &&
|
|
3808
|
-
(propertyReadSideEffects === 'always' ||
|
|
3809
|
-
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
3810
|
-
}
|
|
3811
|
-
includeNode(context) {
|
|
3812
|
-
this.included = true;
|
|
3813
|
-
if (!this.deoptimized)
|
|
3814
|
-
this.applyDeoptimizations();
|
|
3815
|
-
this.argument.includePath(UNKNOWN_PATH, context);
|
|
3816
|
-
}
|
|
3817
|
-
applyDeoptimizations() {
|
|
3818
|
-
this.deoptimized = true;
|
|
3819
|
-
// Only properties of properties of the argument could become subject to reassignment
|
|
3820
|
-
// This will also reassign the return values of iterators
|
|
3821
|
-
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
3822
|
-
this.scope.context.requestTreeshakingPass();
|
|
3823
|
-
}
|
|
3824
|
-
}
|
|
3825
|
-
|
|
3826
3695
|
class ArrayExpression extends NodeBase {
|
|
3827
3696
|
constructor() {
|
|
3828
3697
|
super(...arguments);
|
|
@@ -3843,16 +3712,6 @@ class ArrayExpression extends NodeBase {
|
|
|
3843
3712
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
3844
3713
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
3845
3714
|
}
|
|
3846
|
-
includeNode(context) {
|
|
3847
|
-
this.included = true;
|
|
3848
|
-
if (!this.deoptimized)
|
|
3849
|
-
this.applyDeoptimizations();
|
|
3850
|
-
for (const element of this.elements) {
|
|
3851
|
-
if (element) {
|
|
3852
|
-
element?.includePath(UNKNOWN_PATH, context);
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
3715
|
applyDeoptimizations() {
|
|
3857
3716
|
this.deoptimized = true;
|
|
3858
3717
|
let hasSpread = false;
|
|
@@ -4920,37 +4779,17 @@ class GlobalVariable extends Variable {
|
|
|
4920
4779
|
}
|
|
4921
4780
|
}
|
|
4922
4781
|
|
|
4923
|
-
// To avoid infinite recursions
|
|
4924
|
-
const MAX_PATH_DEPTH = 6;
|
|
4925
|
-
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
4926
|
-
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
4927
|
-
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
4928
|
-
const { length: length1 } = path1;
|
|
4929
|
-
const { length: length2 } = path2;
|
|
4930
|
-
return length1 === 0
|
|
4931
|
-
? path2
|
|
4932
|
-
: length2 === 0
|
|
4933
|
-
? path1
|
|
4934
|
-
: length1 + length2 > MAX_PATH_DEPTH
|
|
4935
|
-
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
4936
|
-
: [...path1, ...path2];
|
|
4937
|
-
};
|
|
4938
|
-
|
|
4939
4782
|
class LocalVariable extends Variable {
|
|
4940
|
-
constructor(name, declarator, init,
|
|
4941
|
-
/** if this is non-empty, the actual init is this path of this.init */
|
|
4942
|
-
initPath, context, kind) {
|
|
4783
|
+
constructor(name, declarator, init, context, kind) {
|
|
4943
4784
|
super(name);
|
|
4944
4785
|
this.init = init;
|
|
4945
|
-
this.initPath = initPath;
|
|
4946
|
-
this.kind = kind;
|
|
4947
4786
|
this.calledFromTryStatement = false;
|
|
4948
4787
|
this.additionalInitializers = null;
|
|
4949
|
-
this.includedPathTracker = new IncludedPathTracker();
|
|
4950
4788
|
this.expressionsToBeDeoptimized = [];
|
|
4951
4789
|
this.declarations = declarator ? [declarator] : [];
|
|
4952
4790
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
4953
4791
|
this.module = context.module;
|
|
4792
|
+
this.kind = kind;
|
|
4954
4793
|
}
|
|
4955
4794
|
addDeclaration(identifier, init) {
|
|
4956
4795
|
this.declarations.push(identifier);
|
|
@@ -4961,16 +4800,15 @@ class LocalVariable extends Variable {
|
|
|
4961
4800
|
for (const initializer of this.additionalInitializers) {
|
|
4962
4801
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
4963
4802
|
}
|
|
4803
|
+
this.additionalInitializers = null;
|
|
4964
4804
|
}
|
|
4965
4805
|
}
|
|
4966
4806
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
4967
|
-
if (this.isReassigned
|
|
4807
|
+
if (this.isReassigned) {
|
|
4968
4808
|
deoptimizeInteraction(interaction);
|
|
4969
4809
|
return;
|
|
4970
4810
|
}
|
|
4971
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () =>
|
|
4972
|
-
this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker);
|
|
4973
|
-
}, undefined);
|
|
4811
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
4974
4812
|
}
|
|
4975
4813
|
deoptimizePath(path) {
|
|
4976
4814
|
if (this.isReassigned ||
|
|
@@ -4984,40 +4822,37 @@ class LocalVariable extends Variable {
|
|
|
4984
4822
|
for (const expression of expressionsToBeDeoptimized) {
|
|
4985
4823
|
expression.deoptimizeCache();
|
|
4986
4824
|
}
|
|
4987
|
-
this.init.deoptimizePath(
|
|
4825
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
4988
4826
|
}
|
|
4989
4827
|
else {
|
|
4990
|
-
this.init.deoptimizePath(
|
|
4828
|
+
this.init.deoptimizePath(path);
|
|
4991
4829
|
}
|
|
4992
4830
|
}
|
|
4993
4831
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
4994
|
-
if (this.isReassigned
|
|
4832
|
+
if (this.isReassigned) {
|
|
4995
4833
|
return UnknownValue;
|
|
4996
4834
|
}
|
|
4997
4835
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4998
4836
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4999
|
-
return this.init.getLiteralValueAtPath(
|
|
4837
|
+
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
5000
4838
|
}, UnknownValue);
|
|
5001
4839
|
}
|
|
5002
4840
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5003
|
-
if (this.isReassigned
|
|
4841
|
+
if (this.isReassigned) {
|
|
5004
4842
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
5005
4843
|
}
|
|
5006
4844
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
5007
4845
|
this.expressionsToBeDeoptimized.push(origin);
|
|
5008
|
-
return this.init.getReturnExpressionWhenCalledAtPath(
|
|
4846
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
5009
4847
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
5010
4848
|
}
|
|
5011
4849
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5012
|
-
if (path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5013
|
-
return true;
|
|
5014
|
-
}
|
|
5015
4850
|
switch (interaction.type) {
|
|
5016
4851
|
case INTERACTION_ACCESSED: {
|
|
5017
4852
|
if (this.isReassigned)
|
|
5018
4853
|
return true;
|
|
5019
4854
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
5020
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4855
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5021
4856
|
}
|
|
5022
4857
|
case INTERACTION_ASSIGNED: {
|
|
5023
4858
|
if (this.included)
|
|
@@ -5027,63 +4862,44 @@ class LocalVariable extends Variable {
|
|
|
5027
4862
|
if (this.isReassigned)
|
|
5028
4863
|
return true;
|
|
5029
4864
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
5030
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4865
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5031
4866
|
}
|
|
5032
4867
|
case INTERACTION_CALLED: {
|
|
5033
4868
|
if (this.isReassigned)
|
|
5034
4869
|
return true;
|
|
5035
4870
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
5036
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4871
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
5037
4872
|
}
|
|
5038
4873
|
}
|
|
5039
4874
|
}
|
|
5040
|
-
|
|
5041
|
-
if (!this.
|
|
5042
|
-
|
|
5043
|
-
if (!this.included) {
|
|
5044
|
-
// This will reduce the number of tree-shaking passes by eagerly
|
|
5045
|
-
// including inits. By pushing this here instead of directly including
|
|
5046
|
-
// we avoid deep call stacks.
|
|
5047
|
-
this.module.scope.context.newlyIncludedVariableInits.add(this.init);
|
|
5048
|
-
}
|
|
5049
|
-
super.includePath(path, context);
|
|
4875
|
+
include() {
|
|
4876
|
+
if (!this.included) {
|
|
4877
|
+
super.include();
|
|
5050
4878
|
for (const declaration of this.declarations) {
|
|
5051
4879
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
5052
4880
|
if (!declaration.included)
|
|
5053
|
-
declaration.include(
|
|
4881
|
+
declaration.include(createInclusionContext(), false);
|
|
5054
4882
|
let node = declaration.parent;
|
|
5055
4883
|
while (!node.included) {
|
|
5056
4884
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
5057
4885
|
// in which case .include() might pull in more dead code
|
|
5058
|
-
node.
|
|
4886
|
+
node.included = true;
|
|
5059
4887
|
if (node.type === Program$1)
|
|
5060
4888
|
break;
|
|
5061
4889
|
node = node.parent;
|
|
5062
4890
|
}
|
|
5063
4891
|
}
|
|
5064
|
-
// We need to make sure we include the correct path of the init
|
|
5065
|
-
if (path.length > 0) {
|
|
5066
|
-
this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context);
|
|
5067
|
-
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context));
|
|
5068
|
-
}
|
|
5069
4892
|
}
|
|
5070
4893
|
}
|
|
5071
|
-
includeCallArguments(context,
|
|
5072
|
-
if (this.isReassigned ||
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
// a specific path
|
|
5076
|
-
this.initPath.length > 0) {
|
|
5077
|
-
for (const argument of interaction.args) {
|
|
5078
|
-
if (argument) {
|
|
5079
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
5080
|
-
argument.include(context, false);
|
|
5081
|
-
}
|
|
4894
|
+
includeCallArguments(context, parameters) {
|
|
4895
|
+
if (this.isReassigned || context.includedCallArguments.has(this.init)) {
|
|
4896
|
+
for (const argument of parameters) {
|
|
4897
|
+
argument.include(context, false);
|
|
5082
4898
|
}
|
|
5083
4899
|
}
|
|
5084
4900
|
else {
|
|
5085
4901
|
context.includedCallArguments.add(this.init);
|
|
5086
|
-
this.init.includeCallArguments(context,
|
|
4902
|
+
this.init.includeCallArguments(context, parameters);
|
|
5087
4903
|
context.includedCallArguments.delete(this.init);
|
|
5088
4904
|
}
|
|
5089
4905
|
}
|
|
@@ -5163,31 +4979,18 @@ class IdentifierBase extends NodeBase {
|
|
|
5163
4979
|
}
|
|
5164
4980
|
}
|
|
5165
4981
|
}
|
|
5166
|
-
include(
|
|
5167
|
-
if (!this.included)
|
|
5168
|
-
this.includeNode(context);
|
|
5169
|
-
}
|
|
5170
|
-
includeNode(context) {
|
|
5171
|
-
this.included = true;
|
|
4982
|
+
include() {
|
|
5172
4983
|
if (!this.deoptimized)
|
|
5173
4984
|
this.applyDeoptimizations();
|
|
5174
|
-
if (this.variable !== null) {
|
|
5175
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5176
|
-
}
|
|
5177
|
-
}
|
|
5178
|
-
includePath(path, context) {
|
|
5179
4985
|
if (!this.included) {
|
|
5180
4986
|
this.included = true;
|
|
5181
4987
|
if (this.variable !== null) {
|
|
5182
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
4988
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
5183
4989
|
}
|
|
5184
4990
|
}
|
|
5185
|
-
else if (path.length > 0) {
|
|
5186
|
-
this.variable?.includePath(path, context);
|
|
5187
|
-
}
|
|
5188
4991
|
}
|
|
5189
|
-
includeCallArguments(context,
|
|
5190
|
-
this.variable.includeCallArguments(context,
|
|
4992
|
+
includeCallArguments(context, parameters) {
|
|
4993
|
+
this.variable.includeCallArguments(context, parameters);
|
|
5191
4994
|
}
|
|
5192
4995
|
isPossibleTDZ() {
|
|
5193
4996
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -5270,40 +5073,11 @@ function closestParentFunctionOrProgram(node) {
|
|
|
5270
5073
|
return node;
|
|
5271
5074
|
}
|
|
5272
5075
|
|
|
5273
|
-
class ObjectMember extends ExpressionEntity {
|
|
5274
|
-
constructor(object, path) {
|
|
5275
|
-
super();
|
|
5276
|
-
this.object = object;
|
|
5277
|
-
this.path = path;
|
|
5278
|
-
}
|
|
5279
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5280
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.path, ...path], recursionTracker);
|
|
5281
|
-
}
|
|
5282
|
-
deoptimizePath(path) {
|
|
5283
|
-
this.object.deoptimizePath([...this.path, ...path]);
|
|
5284
|
-
}
|
|
5285
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5286
|
-
return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin);
|
|
5287
|
-
}
|
|
5288
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5289
|
-
return this.object.getReturnExpressionWhenCalledAtPath([...this.path, ...path], interaction, recursionTracker, origin);
|
|
5290
|
-
}
|
|
5291
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5292
|
-
return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context);
|
|
5293
|
-
}
|
|
5294
|
-
}
|
|
5295
|
-
|
|
5296
5076
|
class Identifier extends IdentifierBase {
|
|
5297
5077
|
constructor() {
|
|
5298
5078
|
super(...arguments);
|
|
5299
5079
|
this.variable = null;
|
|
5300
5080
|
}
|
|
5301
|
-
get isDestructuringDeoptimized() {
|
|
5302
|
-
return isFlagSet(this.flags, 16777216 /* Flag.destructuringDeoptimized */);
|
|
5303
|
-
}
|
|
5304
|
-
set isDestructuringDeoptimized(value) {
|
|
5305
|
-
this.flags = setFlag(this.flags, 16777216 /* Flag.destructuringDeoptimized */, value);
|
|
5306
|
-
}
|
|
5307
5081
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
5308
5082
|
if (exportNamesByVariable.has(this.variable)) {
|
|
5309
5083
|
variables.push(this.variable);
|
|
@@ -5316,52 +5090,42 @@ class Identifier extends IdentifierBase {
|
|
|
5316
5090
|
this.isVariableReference = true;
|
|
5317
5091
|
}
|
|
5318
5092
|
}
|
|
5319
|
-
declare(kind,
|
|
5093
|
+
declare(kind, init) {
|
|
5320
5094
|
let variable;
|
|
5321
5095
|
const { treeshake } = this.scope.context.options;
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5096
|
+
switch (kind) {
|
|
5097
|
+
case 'var': {
|
|
5098
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5099
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
5100
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
5101
|
+
variable.markInitializersForDeoptimization();
|
|
5102
|
+
}
|
|
5103
|
+
break;
|
|
5104
|
+
}
|
|
5105
|
+
case 'function': {
|
|
5106
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
5107
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5108
|
+
break;
|
|
5330
5109
|
}
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
type: INTERACTION_ACCESSED
|
|
5348
|
-
}, destructuredInitPath, SHARED_RECURSION_TRACKER);
|
|
5349
|
-
}
|
|
5350
|
-
const { propertyReadSideEffects } = this.scope.context.options
|
|
5351
|
-
.treeshake;
|
|
5352
|
-
if ((this.included ||=
|
|
5353
|
-
destructuredInitPath.length > 0 &&
|
|
5354
|
-
!context.brokenFlow &&
|
|
5355
|
-
propertyReadSideEffects &&
|
|
5356
|
-
(propertyReadSideEffects === 'always' ||
|
|
5357
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext())))) {
|
|
5358
|
-
if (this.variable && !this.variable.included) {
|
|
5359
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
5110
|
+
case 'let':
|
|
5111
|
+
case 'const':
|
|
5112
|
+
case 'using':
|
|
5113
|
+
case 'await using':
|
|
5114
|
+
case 'class': {
|
|
5115
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5116
|
+
break;
|
|
5117
|
+
}
|
|
5118
|
+
case 'parameter': {
|
|
5119
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
5120
|
+
break;
|
|
5121
|
+
}
|
|
5122
|
+
/* istanbul ignore next */
|
|
5123
|
+
default: {
|
|
5124
|
+
/* istanbul ignore next */
|
|
5125
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
5360
5126
|
}
|
|
5361
|
-
init.includePath(destructuredInitPath, context);
|
|
5362
|
-
return true;
|
|
5363
5127
|
}
|
|
5364
|
-
return
|
|
5128
|
+
return [(this.variable = variable)];
|
|
5365
5129
|
}
|
|
5366
5130
|
markDeclarationReached() {
|
|
5367
5131
|
this.variable.initReached = true;
|
|
@@ -5427,17 +5191,18 @@ class Scope {
|
|
|
5427
5191
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
5428
5192
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
5429
5193
|
*/
|
|
5430
|
-
addDeclaration(identifier, context, init,
|
|
5194
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5431
5195
|
const name = identifier.name;
|
|
5432
5196
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5433
5197
|
if (existingVariable) {
|
|
5434
|
-
|
|
5198
|
+
const existingKind = existingVariable.kind;
|
|
5199
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
5435
5200
|
existingVariable.addDeclaration(identifier, init);
|
|
5436
5201
|
return existingVariable;
|
|
5437
5202
|
}
|
|
5438
5203
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5439
5204
|
}
|
|
5440
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5205
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5441
5206
|
this.variables.set(name, newVariable);
|
|
5442
5207
|
return newVariable;
|
|
5443
5208
|
}
|
|
@@ -5613,6 +5378,7 @@ class MethodBase extends NodeBase {
|
|
|
5613
5378
|
}
|
|
5614
5379
|
return this.getAccessedValue()[0].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5615
5380
|
}
|
|
5381
|
+
applyDeoptimizations() { }
|
|
5616
5382
|
getAccessedValue() {
|
|
5617
5383
|
if (this.accessedValue === null) {
|
|
5618
5384
|
if (this.kind === 'get') {
|
|
@@ -5626,20 +5392,19 @@ class MethodBase extends NodeBase {
|
|
|
5626
5392
|
return this.accessedValue;
|
|
5627
5393
|
}
|
|
5628
5394
|
}
|
|
5629
|
-
MethodBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5630
|
-
MethodBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5631
5395
|
|
|
5632
5396
|
class MethodDefinition extends MethodBase {
|
|
5633
5397
|
hasEffects(context) {
|
|
5634
5398
|
return super.hasEffects(context) || checkEffectForNodes(this.decorators, context);
|
|
5635
5399
|
}
|
|
5400
|
+
applyDeoptimizations() { }
|
|
5636
5401
|
}
|
|
5637
5402
|
|
|
5638
5403
|
class BlockScope extends ChildScope {
|
|
5639
5404
|
constructor(parent) {
|
|
5640
5405
|
super(parent, parent.context);
|
|
5641
5406
|
}
|
|
5642
|
-
addDeclaration(identifier, context, init,
|
|
5407
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5643
5408
|
if (kind === 'var') {
|
|
5644
5409
|
const name = identifier.name;
|
|
5645
5410
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5651,7 +5416,7 @@ class BlockScope extends ChildScope {
|
|
|
5651
5416
|
}
|
|
5652
5417
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5653
5418
|
}
|
|
5654
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init,
|
|
5419
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
5655
5420
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5656
5421
|
// We cannot call deoptimizePath here.
|
|
5657
5422
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5659,7 +5424,7 @@ class BlockScope extends ChildScope {
|
|
|
5659
5424
|
this.addHoistedVariable(name, declaredVariable);
|
|
5660
5425
|
return declaredVariable;
|
|
5661
5426
|
}
|
|
5662
|
-
return super.addDeclaration(identifier, context, init,
|
|
5427
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
5663
5428
|
}
|
|
5664
5429
|
}
|
|
5665
5430
|
|
|
@@ -5691,12 +5456,33 @@ class StaticBlock extends NodeBase {
|
|
|
5691
5456
|
}
|
|
5692
5457
|
}
|
|
5693
5458
|
}
|
|
5694
|
-
StaticBlock.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
5695
|
-
StaticBlock.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
5696
5459
|
function isStaticBlock(statement) {
|
|
5697
5460
|
return statement.type === StaticBlock$1;
|
|
5698
5461
|
}
|
|
5699
5462
|
|
|
5463
|
+
class ObjectMember extends ExpressionEntity {
|
|
5464
|
+
constructor(object, key) {
|
|
5465
|
+
super();
|
|
5466
|
+
this.object = object;
|
|
5467
|
+
this.key = key;
|
|
5468
|
+
}
|
|
5469
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5470
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
5471
|
+
}
|
|
5472
|
+
deoptimizePath(path) {
|
|
5473
|
+
this.object.deoptimizePath([this.key, ...path]);
|
|
5474
|
+
}
|
|
5475
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5476
|
+
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
5477
|
+
}
|
|
5478
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5479
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
5480
|
+
}
|
|
5481
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5482
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
|
|
5700
5486
|
class ClassNode extends NodeBase {
|
|
5701
5487
|
constructor() {
|
|
5702
5488
|
super(...arguments);
|
|
@@ -5737,20 +5523,21 @@ class ClassNode extends NodeBase {
|
|
|
5737
5523
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5738
5524
|
}
|
|
5739
5525
|
include(context, includeChildrenRecursively) {
|
|
5740
|
-
if (!this.
|
|
5741
|
-
this.
|
|
5526
|
+
if (!this.deoptimized)
|
|
5527
|
+
this.applyDeoptimizations();
|
|
5528
|
+
this.included = true;
|
|
5742
5529
|
this.superClass?.include(context, includeChildrenRecursively);
|
|
5743
5530
|
this.body.include(context, includeChildrenRecursively);
|
|
5744
5531
|
for (const decorator of this.decorators)
|
|
5745
5532
|
decorator.include(context, includeChildrenRecursively);
|
|
5746
5533
|
if (this.id) {
|
|
5747
5534
|
this.id.markDeclarationReached();
|
|
5748
|
-
this.id.include(
|
|
5535
|
+
this.id.include();
|
|
5749
5536
|
}
|
|
5750
5537
|
}
|
|
5751
5538
|
initialise() {
|
|
5752
5539
|
super.initialise();
|
|
5753
|
-
this.id?.declare('class',
|
|
5540
|
+
this.id?.declare('class', this);
|
|
5754
5541
|
for (const method of this.body.body) {
|
|
5755
5542
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
5756
5543
|
this.classConstructor = method;
|
|
@@ -5808,12 +5595,11 @@ class ClassNode extends NodeBase {
|
|
|
5808
5595
|
staticProperties.unshift({
|
|
5809
5596
|
key: 'prototype',
|
|
5810
5597
|
kind: 'init',
|
|
5811
|
-
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass,
|
|
5598
|
+
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, 'prototype') : OBJECT_PROTOTYPE)
|
|
5812
5599
|
});
|
|
5813
5600
|
return (this.objectEntity = new ObjectEntity(staticProperties, this.superClass || OBJECT_PROTOTYPE));
|
|
5814
5601
|
}
|
|
5815
5602
|
}
|
|
5816
|
-
ClassNode.prototype.includeNode = onlyIncludeSelf;
|
|
5817
5603
|
|
|
5818
5604
|
class ClassDeclaration extends ClassNode {
|
|
5819
5605
|
initialise() {
|
|
@@ -5866,7 +5652,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
5866
5652
|
|
|
5867
5653
|
class ArgumentsVariable extends LocalVariable {
|
|
5868
5654
|
constructor(context) {
|
|
5869
|
-
super('arguments', null, UNKNOWN_EXPRESSION,
|
|
5655
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
5870
5656
|
this.deoptimizedArguments = [];
|
|
5871
5657
|
}
|
|
5872
5658
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -5880,8 +5666,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5880
5666
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5881
5667
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
5882
5668
|
}
|
|
5883
|
-
|
|
5884
|
-
super.
|
|
5669
|
+
include() {
|
|
5670
|
+
super.include();
|
|
5885
5671
|
for (const argument of this.deoptimizedArguments) {
|
|
5886
5672
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
5887
5673
|
}
|
|
@@ -5889,31 +5675,30 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5889
5675
|
}
|
|
5890
5676
|
}
|
|
5891
5677
|
|
|
5892
|
-
const MAX_TRACKED_INTERACTIONS =
|
|
5893
|
-
const MAX_DEOPTIMIZED_FIELDS = 5;
|
|
5678
|
+
const MAX_TRACKED_INTERACTIONS = 20;
|
|
5894
5679
|
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
5895
5680
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
5896
|
-
const EMPTY_PATH_TRACKER = new
|
|
5681
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
5897
5682
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
5898
5683
|
class ParameterVariable extends LocalVariable {
|
|
5899
|
-
constructor(name, declarator,
|
|
5900
|
-
super(name, declarator, UNKNOWN_EXPRESSION,
|
|
5901
|
-
this.argumentsToBeDeoptimized = new Set();
|
|
5684
|
+
constructor(name, declarator, context) {
|
|
5685
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
5902
5686
|
this.deoptimizationInteractions = [];
|
|
5903
|
-
this.deoptimizations = new
|
|
5687
|
+
this.deoptimizations = new PathTracker();
|
|
5904
5688
|
this.deoptimizedFields = new Set();
|
|
5905
|
-
this.
|
|
5689
|
+
this.entitiesToBeDeoptimized = new Set();
|
|
5690
|
+
this.expressionsUseTheKnownValue = [];
|
|
5906
5691
|
this.knownValue = null;
|
|
5907
5692
|
this.knownValueLiteral = UnknownValue;
|
|
5693
|
+
this.frozenValue = null;
|
|
5908
5694
|
}
|
|
5909
|
-
|
|
5910
|
-
this.updateKnownValue(entity);
|
|
5695
|
+
addEntityToBeDeoptimized(entity) {
|
|
5911
5696
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
5912
5697
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
5913
5698
|
// the interaction cache at this point provided we keep this optimization
|
|
5914
5699
|
// in mind when adding new interactions
|
|
5915
|
-
if (!this.
|
|
5916
|
-
this.
|
|
5700
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5701
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
5917
5702
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
5918
5703
|
deoptimizeInteraction(interaction);
|
|
5919
5704
|
}
|
|
@@ -5923,30 +5708,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
5923
5708
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5924
5709
|
// This means that we already deoptimized all interactions and no longer
|
|
5925
5710
|
// track them
|
|
5926
|
-
entity.deoptimizePath(
|
|
5711
|
+
entity.deoptimizePath(UNKNOWN_PATH);
|
|
5927
5712
|
}
|
|
5928
|
-
else if (!this.
|
|
5929
|
-
this.
|
|
5713
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
5714
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
5930
5715
|
for (const field of this.deoptimizedFields) {
|
|
5931
|
-
entity.deoptimizePath([
|
|
5716
|
+
entity.deoptimizePath([field]);
|
|
5932
5717
|
}
|
|
5933
5718
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
5934
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5719
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5935
5720
|
}
|
|
5936
5721
|
}
|
|
5937
5722
|
}
|
|
5938
|
-
/** This says we should not make assumptions about the value of the parameter.
|
|
5939
|
-
* This is different from deoptimization that will also cause argument values
|
|
5940
|
-
* to be deoptimized. */
|
|
5941
5723
|
markReassigned() {
|
|
5942
5724
|
if (this.isReassigned) {
|
|
5943
5725
|
return;
|
|
5944
5726
|
}
|
|
5945
5727
|
super.markReassigned();
|
|
5946
|
-
for (const expression of this.
|
|
5728
|
+
for (const expression of this.expressionsUseTheKnownValue) {
|
|
5947
5729
|
expression.deoptimizeCache();
|
|
5948
5730
|
}
|
|
5949
|
-
this.
|
|
5731
|
+
this.expressionsUseTheKnownValue = EMPTY_ARRAY;
|
|
5950
5732
|
}
|
|
5951
5733
|
deoptimizeCache() {
|
|
5952
5734
|
this.markReassigned();
|
|
@@ -5963,7 +5745,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5963
5745
|
}
|
|
5964
5746
|
if (this.knownValue === null) {
|
|
5965
5747
|
this.knownValue = argument;
|
|
5966
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
5748
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5967
5749
|
return;
|
|
5968
5750
|
}
|
|
5969
5751
|
// the same literal or identifier, do nothing
|
|
@@ -5973,10 +5755,14 @@ class ParameterVariable extends LocalVariable {
|
|
|
5973
5755
|
this.knownValue.variable === argument.variable)) {
|
|
5974
5756
|
return;
|
|
5975
5757
|
}
|
|
5976
|
-
const
|
|
5977
|
-
if (typeof
|
|
5978
|
-
|
|
5979
|
-
|
|
5758
|
+
const oldValue = this.knownValueLiteral;
|
|
5759
|
+
if (typeof oldValue === 'symbol') {
|
|
5760
|
+
this.markReassigned();
|
|
5761
|
+
return;
|
|
5762
|
+
}
|
|
5763
|
+
// add tracking for the new argument
|
|
5764
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5765
|
+
if (newValue !== oldValue) {
|
|
5980
5766
|
this.markReassigned();
|
|
5981
5767
|
}
|
|
5982
5768
|
}
|
|
@@ -5987,47 +5773,42 @@ class ParameterVariable extends LocalVariable {
|
|
|
5987
5773
|
* @returns the frozen value
|
|
5988
5774
|
*/
|
|
5989
5775
|
getKnownValue() {
|
|
5990
|
-
|
|
5776
|
+
if (this.frozenValue === null) {
|
|
5777
|
+
this.frozenValue = this.knownValue || UNKNOWN_EXPRESSION;
|
|
5778
|
+
}
|
|
5779
|
+
return this.frozenValue;
|
|
5991
5780
|
}
|
|
5992
5781
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5993
|
-
if (this.isReassigned
|
|
5782
|
+
if (this.isReassigned) {
|
|
5994
5783
|
return UnknownValue;
|
|
5995
5784
|
}
|
|
5996
5785
|
const knownValue = this.getKnownValue();
|
|
5997
|
-
this.
|
|
5998
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(
|
|
5786
|
+
this.expressionsUseTheKnownValue.push(origin);
|
|
5787
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
5999
5788
|
}
|
|
6000
5789
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6001
|
-
|
|
6002
|
-
if (this.isReassigned ||
|
|
6003
|
-
type === INTERACTION_ASSIGNED ||
|
|
6004
|
-
path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5790
|
+
if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) {
|
|
6005
5791
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6006
5792
|
}
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
? context.instantiated
|
|
6010
|
-
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
6011
|
-
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
6012
|
-
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
5793
|
+
const knownValue = this.getKnownValue();
|
|
5794
|
+
return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6013
5795
|
}
|
|
6014
5796
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
6015
5797
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
6016
5798
|
if (path.length >= 2 ||
|
|
6017
|
-
this.
|
|
5799
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
6018
5800
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
6019
5801
|
(path.length === 1 &&
|
|
6020
5802
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
6021
|
-
(interaction.type === INTERACTION_CALLED && this.deoptimizedFields.has(path[0]))))
|
|
6022
|
-
this.initPath.length + path.length > MAX_PATH_DEPTH) {
|
|
5803
|
+
(interaction.type === INTERACTION_CALLED && this.deoptimizedFields.has(path[0]))))) {
|
|
6023
5804
|
deoptimizeInteraction(interaction);
|
|
6024
5805
|
return;
|
|
6025
5806
|
}
|
|
6026
5807
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
6027
|
-
for (const entity of this.
|
|
6028
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5808
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5809
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
6029
5810
|
}
|
|
6030
|
-
if (!this.
|
|
5811
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
6031
5812
|
this.deoptimizationInteractions.push({
|
|
6032
5813
|
interaction,
|
|
6033
5814
|
path
|
|
@@ -6043,27 +5824,22 @@ class ParameterVariable extends LocalVariable {
|
|
|
6043
5824
|
if (this.deoptimizedFields.has(UnknownKey)) {
|
|
6044
5825
|
return;
|
|
6045
5826
|
}
|
|
6046
|
-
|
|
5827
|
+
const key = path[0];
|
|
6047
5828
|
if (this.deoptimizedFields.has(key)) {
|
|
6048
5829
|
return;
|
|
6049
5830
|
}
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
}
|
|
6053
|
-
else {
|
|
6054
|
-
this.deoptimizedFields.add(key);
|
|
6055
|
-
}
|
|
6056
|
-
for (const entity of this.argumentsToBeDeoptimized) {
|
|
5831
|
+
this.deoptimizedFields.add(key);
|
|
5832
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
6057
5833
|
// We do not need a recursion tracker here as we already track whether
|
|
6058
5834
|
// this field is deoptimized
|
|
6059
|
-
entity.deoptimizePath([
|
|
5835
|
+
entity.deoptimizePath([key]);
|
|
6060
5836
|
}
|
|
6061
5837
|
if (key === UnknownKey) {
|
|
6062
5838
|
// save some memory
|
|
6063
5839
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
6064
5840
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
6065
5841
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
6066
|
-
this.
|
|
5842
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
6067
5843
|
}
|
|
6068
5844
|
}
|
|
6069
5845
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -6078,14 +5854,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
6078
5854
|
}
|
|
6079
5855
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
6080
5856
|
}
|
|
6081
|
-
includeArgumentPaths(entity, context) {
|
|
6082
|
-
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
6083
|
-
}
|
|
6084
5857
|
}
|
|
6085
5858
|
|
|
6086
5859
|
class ThisVariable extends ParameterVariable {
|
|
6087
5860
|
constructor(context) {
|
|
6088
|
-
super('this', null,
|
|
5861
|
+
super('this', null, context);
|
|
6089
5862
|
}
|
|
6090
5863
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6091
5864
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -6097,7 +5870,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6097
5870
|
super(parent, parent.context);
|
|
6098
5871
|
this.parent = parent;
|
|
6099
5872
|
}
|
|
6100
|
-
addDeclaration(identifier, context, init,
|
|
5873
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6101
5874
|
if (kind === 'var') {
|
|
6102
5875
|
const name = identifier.name;
|
|
6103
5876
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -6110,7 +5883,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6110
5883
|
// the assignment actually goes to the parameter and the var is
|
|
6111
5884
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
6112
5885
|
// parameter
|
|
6113
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION,
|
|
5886
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
6114
5887
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
6115
5888
|
// names. If we ever implement a logic that splits initialization and
|
|
6116
5889
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -6129,7 +5902,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6129
5902
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
6130
5903
|
}
|
|
6131
5904
|
// We only add parameters to parameter scopes
|
|
6132
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init,
|
|
5905
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
6133
5906
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
6134
5907
|
// We cannot call deoptimizePath here.
|
|
6135
5908
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -6137,7 +5910,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6137
5910
|
this.addHoistedVariable(name, declaredVariable);
|
|
6138
5911
|
return declaredVariable;
|
|
6139
5912
|
}
|
|
6140
|
-
return super.addDeclaration(identifier, context, init,
|
|
5913
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
6141
5914
|
}
|
|
6142
5915
|
}
|
|
6143
5916
|
|
|
@@ -6147,7 +5920,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6147
5920
|
}
|
|
6148
5921
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
6149
5922
|
// be redeclared, functions and var can redeclare each other
|
|
6150
|
-
addDeclaration(identifier, context, init,
|
|
5923
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6151
5924
|
const name = identifier.name;
|
|
6152
5925
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6153
5926
|
if (existingVariable) {
|
|
@@ -6159,7 +5932,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6159
5932
|
}
|
|
6160
5933
|
context.error(logRedeclarationError(name), identifier.start);
|
|
6161
5934
|
}
|
|
6162
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5935
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6163
5936
|
this.variables.set(name, newVariable);
|
|
6164
5937
|
return newVariable;
|
|
6165
5938
|
}
|
|
@@ -6168,21 +5941,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6168
5941
|
class ParameterScope extends ChildScope {
|
|
6169
5942
|
constructor(parent, isCatchScope) {
|
|
6170
5943
|
super(parent, parent.context);
|
|
6171
|
-
this.hasRest = false;
|
|
6172
5944
|
this.parameters = [];
|
|
5945
|
+
this.hasRest = false;
|
|
6173
5946
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
6174
5947
|
}
|
|
6175
5948
|
/**
|
|
6176
5949
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
6177
5950
|
* order, i.e. from left to right.
|
|
6178
5951
|
*/
|
|
6179
|
-
addParameterDeclaration(identifier
|
|
5952
|
+
addParameterDeclaration(identifier) {
|
|
6180
5953
|
const { name, start } = identifier;
|
|
6181
5954
|
const existingParameter = this.variables.get(name);
|
|
6182
5955
|
if (existingParameter) {
|
|
6183
5956
|
return this.context.error(logDuplicateArgumentNameError(name), start);
|
|
6184
5957
|
}
|
|
6185
|
-
const variable = new ParameterVariable(name, identifier,
|
|
5958
|
+
const variable = new ParameterVariable(name, identifier, this.context);
|
|
6186
5959
|
this.variables.set(name, variable);
|
|
6187
5960
|
// We also add it to the body scope to detect name conflicts with local
|
|
6188
5961
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -6200,56 +5973,42 @@ class ParameterScope extends ChildScope {
|
|
|
6200
5973
|
}
|
|
6201
5974
|
this.hasRest = hasRest;
|
|
6202
5975
|
}
|
|
6203
|
-
includeCallArguments(context,
|
|
5976
|
+
includeCallArguments(context, parameters) {
|
|
6204
5977
|
let calledFromTryStatement = false;
|
|
6205
5978
|
let argumentIncluded = false;
|
|
6206
5979
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
6207
|
-
const
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
|
|
6211
|
-
|
|
6212
|
-
|
|
6213
|
-
if (argument instanceof SpreadElement && !argumentIncluded) {
|
|
6214
|
-
argumentIncluded = true;
|
|
6215
|
-
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
6216
|
-
}
|
|
6217
|
-
if (argumentIncluded) {
|
|
6218
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6219
|
-
argument.include(context, false);
|
|
5980
|
+
for (const checkedArgument of parameters) {
|
|
5981
|
+
if (checkedArgument instanceof SpreadElement) {
|
|
5982
|
+
for (const argument of parameters) {
|
|
5983
|
+
argument.include(context, false);
|
|
5984
|
+
}
|
|
5985
|
+
break;
|
|
6220
5986
|
}
|
|
6221
5987
|
}
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
6226
|
-
const argument = args[index];
|
|
5988
|
+
for (let index = parameters.length - 1; index >= 0; index--) {
|
|
5989
|
+
const parameterVariables = this.parameters[index] || restParameter;
|
|
5990
|
+
const argument = parameters[index];
|
|
6227
5991
|
if (parameterVariables) {
|
|
6228
5992
|
calledFromTryStatement = false;
|
|
6229
5993
|
if (parameterVariables.length === 0) {
|
|
6230
|
-
// handle empty destructuring
|
|
5994
|
+
// handle empty destructuring
|
|
6231
5995
|
argumentIncluded = true;
|
|
6232
5996
|
}
|
|
6233
5997
|
else {
|
|
6234
5998
|
for (const variable of parameterVariables) {
|
|
6235
|
-
if (variable.calledFromTryStatement) {
|
|
6236
|
-
calledFromTryStatement = true;
|
|
6237
|
-
}
|
|
6238
5999
|
if (variable.included) {
|
|
6239
6000
|
argumentIncluded = true;
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
else {
|
|
6244
|
-
variable.includeArgumentPaths(argument, context);
|
|
6245
|
-
argument.include(context, false);
|
|
6246
|
-
}
|
|
6001
|
+
}
|
|
6002
|
+
if (variable.calledFromTryStatement) {
|
|
6003
|
+
calledFromTryStatement = true;
|
|
6247
6004
|
}
|
|
6248
6005
|
}
|
|
6249
6006
|
}
|
|
6250
6007
|
}
|
|
6251
|
-
if (!
|
|
6008
|
+
if (!argumentIncluded && argument.shouldBeIncluded(context)) {
|
|
6252
6009
|
argumentIncluded = true;
|
|
6010
|
+
}
|
|
6011
|
+
if (argumentIncluded) {
|
|
6253
6012
|
argument.include(context, calledFromTryStatement);
|
|
6254
6013
|
}
|
|
6255
6014
|
}
|
|
@@ -6265,62 +6024,11 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6265
6024
|
addReturnExpression(expression) {
|
|
6266
6025
|
this.returnExpressions.push(expression);
|
|
6267
6026
|
}
|
|
6268
|
-
deoptimizeArgumentsOnCall(interaction) {
|
|
6269
|
-
const { parameters } = this;
|
|
6270
|
-
const { args } = interaction;
|
|
6271
|
-
let position = 0;
|
|
6272
|
-
for (; position < args.length - 1; position++) {
|
|
6273
|
-
// Only the "this" argument arg[0] can be null
|
|
6274
|
-
const argument = args[position + 1];
|
|
6275
|
-
if (argument instanceof SpreadElement) {
|
|
6276
|
-
// This deoptimizes the current and remaining parameters and arguments
|
|
6277
|
-
for (; position < parameters.length; position++) {
|
|
6278
|
-
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
6279
|
-
parameters[position].forEach(variable => variable.markReassigned());
|
|
6280
|
-
}
|
|
6281
|
-
break;
|
|
6282
|
-
}
|
|
6283
|
-
if (this.hasRest && position >= parameters.length - 1) {
|
|
6284
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6285
|
-
}
|
|
6286
|
-
else {
|
|
6287
|
-
const variables = parameters[position];
|
|
6288
|
-
if (variables) {
|
|
6289
|
-
for (const variable of variables) {
|
|
6290
|
-
variable.addArgumentValue(argument);
|
|
6291
|
-
}
|
|
6292
|
-
}
|
|
6293
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
6294
|
-
}
|
|
6295
|
-
}
|
|
6296
|
-
const nonRestParameterLength = this.hasRest ? parameters.length - 1 : parameters.length;
|
|
6297
|
-
for (; position < nonRestParameterLength; position++) {
|
|
6298
|
-
for (const variable of parameters[position]) {
|
|
6299
|
-
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
6300
|
-
}
|
|
6301
|
-
}
|
|
6302
|
-
}
|
|
6303
6027
|
getReturnExpression() {
|
|
6304
6028
|
if (this.returnExpression === null)
|
|
6305
6029
|
this.updateReturnExpression();
|
|
6306
6030
|
return this.returnExpression;
|
|
6307
6031
|
}
|
|
6308
|
-
deoptimizeAllParameters() {
|
|
6309
|
-
for (const parameter of this.parameters) {
|
|
6310
|
-
for (const variable of parameter) {
|
|
6311
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
6312
|
-
variable.markReassigned();
|
|
6313
|
-
}
|
|
6314
|
-
}
|
|
6315
|
-
}
|
|
6316
|
-
reassignAllParameters() {
|
|
6317
|
-
for (const parameter of this.parameters) {
|
|
6318
|
-
for (const variable of parameter) {
|
|
6319
|
-
variable.markReassigned();
|
|
6320
|
-
}
|
|
6321
|
-
}
|
|
6322
|
-
}
|
|
6323
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
6324
6032
|
updateReturnExpression() {
|
|
6325
6033
|
if (this.returnExpressions.length === 1) {
|
|
6326
6034
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -6336,30 +6044,24 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6336
6044
|
|
|
6337
6045
|
class FunctionScope extends ReturnValueScope {
|
|
6338
6046
|
constructor(parent) {
|
|
6339
|
-
super(parent, false);
|
|
6340
6047
|
const { context } = parent;
|
|
6048
|
+
super(parent, false);
|
|
6341
6049
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
6342
6050
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
6343
6051
|
}
|
|
6344
6052
|
findLexicalBoundary() {
|
|
6345
6053
|
return this;
|
|
6346
6054
|
}
|
|
6347
|
-
includeCallArguments(context,
|
|
6348
|
-
super.includeCallArguments(context,
|
|
6055
|
+
includeCallArguments(context, parameters) {
|
|
6056
|
+
super.includeCallArguments(context, parameters);
|
|
6349
6057
|
if (this.argumentsVariable.included) {
|
|
6350
|
-
const
|
|
6351
|
-
|
|
6352
|
-
const argument = args[argumentIndex];
|
|
6353
|
-
if (argument) {
|
|
6354
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6058
|
+
for (const argument of parameters) {
|
|
6059
|
+
if (!argument.included) {
|
|
6355
6060
|
argument.include(context, false);
|
|
6356
6061
|
}
|
|
6357
6062
|
}
|
|
6358
6063
|
}
|
|
6359
6064
|
}
|
|
6360
|
-
addArgumentToBeDeoptimized(argument) {
|
|
6361
|
-
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6362
|
-
}
|
|
6363
6065
|
}
|
|
6364
6066
|
|
|
6365
6067
|
class ExpressionStatement extends NodeBase {
|
|
@@ -6387,9 +6089,8 @@ class ExpressionStatement extends NodeBase {
|
|
|
6387
6089
|
return this.parent.type !== Program$1;
|
|
6388
6090
|
return super.shouldBeIncluded(context);
|
|
6389
6091
|
}
|
|
6092
|
+
applyDeoptimizations() { }
|
|
6390
6093
|
}
|
|
6391
|
-
ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6392
|
-
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6393
6094
|
|
|
6394
6095
|
class BlockStatement extends NodeBase {
|
|
6395
6096
|
get deoptimizeBody() {
|
|
@@ -6454,8 +6155,6 @@ class BlockStatement extends NodeBase {
|
|
|
6454
6155
|
}
|
|
6455
6156
|
}
|
|
6456
6157
|
}
|
|
6457
|
-
BlockStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6458
|
-
BlockStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6459
6158
|
|
|
6460
6159
|
class RestElement extends NodeBase {
|
|
6461
6160
|
constructor() {
|
|
@@ -6465,12 +6164,9 @@ class RestElement extends NodeBase {
|
|
|
6465
6164
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6466
6165
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6467
6166
|
}
|
|
6468
|
-
declare(kind,
|
|
6167
|
+
declare(kind, init) {
|
|
6469
6168
|
this.declarationInit = init;
|
|
6470
|
-
return this.argument.declare(kind,
|
|
6471
|
-
}
|
|
6472
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
6473
|
-
this.argument.deoptimizeAssignment(getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6169
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
6474
6170
|
}
|
|
6475
6171
|
deoptimizePath(path) {
|
|
6476
6172
|
if (path.length === 0) {
|
|
@@ -6481,20 +6177,6 @@ class RestElement extends NodeBase {
|
|
|
6481
6177
|
return (path.length > 0 ||
|
|
6482
6178
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
6483
6179
|
}
|
|
6484
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
6485
|
-
return this.argument.hasEffectsWhenDestructuring(context, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6486
|
-
}
|
|
6487
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
6488
|
-
return (this.included =
|
|
6489
|
-
this.argument.includeDestructuredIfNecessary(context, getIncludedPatternPath$1(destructuredInitPath), init) || this.included);
|
|
6490
|
-
}
|
|
6491
|
-
include(context, includeChildrenRecursively) {
|
|
6492
|
-
if (!this.included)
|
|
6493
|
-
this.includeNode(context);
|
|
6494
|
-
// This should just include the identifier, its properties should be
|
|
6495
|
-
// included where the variable is used.
|
|
6496
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
6497
|
-
}
|
|
6498
6180
|
markDeclarationReached() {
|
|
6499
6181
|
this.argument.markDeclarationReached();
|
|
6500
6182
|
}
|
|
@@ -6506,16 +6188,12 @@ class RestElement extends NodeBase {
|
|
|
6506
6188
|
}
|
|
6507
6189
|
}
|
|
6508
6190
|
}
|
|
6509
|
-
RestElement.prototype.includeNode = onlyIncludeSelf;
|
|
6510
|
-
const getIncludedPatternPath$1 = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
6511
|
-
? destructuredInitPath
|
|
6512
|
-
: [...destructuredInitPath, UnknownKey];
|
|
6513
6191
|
|
|
6514
6192
|
class FunctionBase extends NodeBase {
|
|
6515
6193
|
constructor() {
|
|
6516
6194
|
super(...arguments);
|
|
6195
|
+
this.objectEntity = null;
|
|
6517
6196
|
this.parameterVariableValuesDeoptimized = false;
|
|
6518
|
-
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
6519
6197
|
}
|
|
6520
6198
|
get async() {
|
|
6521
6199
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -6535,15 +6213,53 @@ class FunctionBase extends NodeBase {
|
|
|
6535
6213
|
set generator(value) {
|
|
6536
6214
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
6537
6215
|
}
|
|
6538
|
-
|
|
6539
|
-
|
|
6216
|
+
updateParameterVariableValues(_arguments) {
|
|
6217
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
6218
|
+
const parameter = this.params[position];
|
|
6219
|
+
if (!(parameter instanceof Identifier)) {
|
|
6220
|
+
continue;
|
|
6221
|
+
}
|
|
6222
|
+
const parameterVariable = parameter.variable;
|
|
6223
|
+
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
6224
|
+
parameterVariable.updateKnownValue(argument);
|
|
6225
|
+
}
|
|
6540
6226
|
}
|
|
6541
|
-
|
|
6542
|
-
|
|
6227
|
+
deoptimizeParameterVariableValues() {
|
|
6228
|
+
for (const parameter of this.params) {
|
|
6229
|
+
if (parameter instanceof Identifier) {
|
|
6230
|
+
const parameterVariable = parameter.variable;
|
|
6231
|
+
parameterVariable.markReassigned();
|
|
6232
|
+
}
|
|
6233
|
+
}
|
|
6543
6234
|
}
|
|
6544
6235
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6545
|
-
if (interaction.type === INTERACTION_CALLED
|
|
6546
|
-
this.scope
|
|
6236
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
6237
|
+
const { parameters } = this.scope;
|
|
6238
|
+
const { args } = interaction;
|
|
6239
|
+
let hasRest = false;
|
|
6240
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
6241
|
+
const parameter = this.params[position];
|
|
6242
|
+
// Only the "this" argument arg[0] can be null
|
|
6243
|
+
const argument = args[position + 1];
|
|
6244
|
+
if (argument instanceof SpreadElement) {
|
|
6245
|
+
this.deoptimizeParameterVariableValues();
|
|
6246
|
+
}
|
|
6247
|
+
if (hasRest || parameter instanceof RestElement) {
|
|
6248
|
+
hasRest = true;
|
|
6249
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6250
|
+
}
|
|
6251
|
+
else if (parameter instanceof Identifier) {
|
|
6252
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
6253
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6254
|
+
}
|
|
6255
|
+
else if (parameter) {
|
|
6256
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6257
|
+
}
|
|
6258
|
+
else {
|
|
6259
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
this.updateParameterVariableValues(args);
|
|
6547
6263
|
}
|
|
6548
6264
|
else {
|
|
6549
6265
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -6555,7 +6271,12 @@ class FunctionBase extends NodeBase {
|
|
|
6555
6271
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6556
6272
|
// which means the return expression and parameters need to be reassigned
|
|
6557
6273
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
6558
|
-
this.scope.
|
|
6274
|
+
for (const parameterList of this.scope.parameters) {
|
|
6275
|
+
for (const parameter of parameterList) {
|
|
6276
|
+
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
6277
|
+
parameter.markReassigned();
|
|
6278
|
+
}
|
|
6279
|
+
}
|
|
6559
6280
|
}
|
|
6560
6281
|
}
|
|
6561
6282
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6579,8 +6300,8 @@ class FunctionBase extends NodeBase {
|
|
|
6579
6300
|
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
6580
6301
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6581
6302
|
}
|
|
6582
|
-
if (this.
|
|
6583
|
-
return
|
|
6303
|
+
if (this.annotationNoSideEffects) {
|
|
6304
|
+
return false;
|
|
6584
6305
|
}
|
|
6585
6306
|
if (this.async) {
|
|
6586
6307
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -6590,20 +6311,12 @@ class FunctionBase extends NodeBase {
|
|
|
6590
6311
|
(propertyReadSideEffects &&
|
|
6591
6312
|
(propertyReadSideEffects === 'always' ||
|
|
6592
6313
|
returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_ACCESS, context)))) {
|
|
6593
|
-
this.hasCachedEffects = true;
|
|
6594
6314
|
return true;
|
|
6595
6315
|
}
|
|
6596
6316
|
}
|
|
6597
|
-
const
|
|
6598
|
-
.
|
|
6599
|
-
for (let index = 0; index < this.params.length; index++) {
|
|
6600
|
-
const parameter = this.params[index];
|
|
6601
|
-
if (parameter.hasEffects(context) ||
|
|
6602
|
-
(propertyReadSideEffects &&
|
|
6603
|
-
parameter.hasEffectsWhenDestructuring(context, EMPTY_PATH, interaction.args[index + 1] || UNDEFINED_EXPRESSION))) {
|
|
6604
|
-
this.hasCachedEffects = true;
|
|
6317
|
+
for (const parameter of this.params) {
|
|
6318
|
+
if (parameter.hasEffects(context))
|
|
6605
6319
|
return true;
|
|
6606
|
-
}
|
|
6607
6320
|
}
|
|
6608
6321
|
return false;
|
|
6609
6322
|
}
|
|
@@ -6621,17 +6334,21 @@ class FunctionBase extends NodeBase {
|
|
|
6621
6334
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
6622
6335
|
}
|
|
6623
6336
|
include(context, includeChildrenRecursively) {
|
|
6624
|
-
if (!this.
|
|
6625
|
-
this.includeNode(context);
|
|
6626
|
-
if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) {
|
|
6337
|
+
if (!this.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) {
|
|
6627
6338
|
this.parameterVariableValuesDeoptimized = true;
|
|
6628
|
-
this.
|
|
6339
|
+
this.deoptimizeParameterVariableValues();
|
|
6629
6340
|
}
|
|
6341
|
+
if (!this.deoptimized)
|
|
6342
|
+
this.applyDeoptimizations();
|
|
6343
|
+
this.included = true;
|
|
6630
6344
|
const { brokenFlow } = context;
|
|
6631
6345
|
context.brokenFlow = false;
|
|
6632
6346
|
this.body.include(context, includeChildrenRecursively);
|
|
6633
6347
|
context.brokenFlow = brokenFlow;
|
|
6634
6348
|
}
|
|
6349
|
+
includeCallArguments(context, parameters) {
|
|
6350
|
+
this.scope.includeCallArguments(context, parameters);
|
|
6351
|
+
}
|
|
6635
6352
|
initialise() {
|
|
6636
6353
|
super.initialise();
|
|
6637
6354
|
if (this.body instanceof BlockStatement) {
|
|
@@ -6653,14 +6370,14 @@ class FunctionBase extends NodeBase {
|
|
|
6653
6370
|
// so that the scope already knows all parameters and can detect conflicts
|
|
6654
6371
|
// when parsing the body.
|
|
6655
6372
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
6656
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
6373
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6657
6374
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
6658
6375
|
return super.parseNode(esTreeNode);
|
|
6659
6376
|
}
|
|
6377
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
6378
|
+
applyDeoptimizations() { }
|
|
6660
6379
|
}
|
|
6661
6380
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
6662
|
-
FunctionBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6663
|
-
FunctionBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6664
6381
|
|
|
6665
6382
|
class FunctionNode extends FunctionBase {
|
|
6666
6383
|
constructor() {
|
|
@@ -6672,31 +6389,30 @@ class FunctionNode extends FunctionBase {
|
|
|
6672
6389
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
6673
6390
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6674
6391
|
// constructed entity.
|
|
6675
|
-
this.scope.thisVariable.
|
|
6392
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
|
|
6676
6393
|
}
|
|
6677
6394
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6678
6395
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6679
6396
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
6680
6397
|
// args[0] is the "this" argument
|
|
6681
|
-
this.scope.thisVariable.
|
|
6398
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
6682
6399
|
}
|
|
6683
6400
|
}
|
|
6684
6401
|
hasEffects(context) {
|
|
6402
|
+
if (!this.deoptimized)
|
|
6403
|
+
this.applyDeoptimizations();
|
|
6685
6404
|
if (this.annotationNoSideEffects) {
|
|
6686
6405
|
return false;
|
|
6687
6406
|
}
|
|
6688
6407
|
return !!this.id?.hasEffects(context);
|
|
6689
6408
|
}
|
|
6690
6409
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6691
|
-
if (
|
|
6692
|
-
path.length === 0 &&
|
|
6693
|
-
interaction.type === INTERACTION_CALLED) {
|
|
6694
|
-
return false;
|
|
6695
|
-
}
|
|
6696
|
-
if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
|
|
6410
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
6697
6411
|
return true;
|
|
6412
|
+
if (this.annotationNoSideEffects) {
|
|
6413
|
+
return false;
|
|
6698
6414
|
}
|
|
6699
|
-
if (
|
|
6415
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
6700
6416
|
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
6701
6417
|
context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew ? this.constructedEntity : UNKNOWN_EXPRESSION);
|
|
6702
6418
|
const { brokenFlow, ignore, replacedVariableInits } = context;
|
|
@@ -6707,10 +6423,8 @@ class FunctionNode extends FunctionBase {
|
|
|
6707
6423
|
returnYield: true,
|
|
6708
6424
|
this: interaction.withNew
|
|
6709
6425
|
};
|
|
6710
|
-
if (this.body.hasEffects(context))
|
|
6711
|
-
this.hasCachedEffects = true;
|
|
6426
|
+
if (this.body.hasEffects(context))
|
|
6712
6427
|
return true;
|
|
6713
|
-
}
|
|
6714
6428
|
context.brokenFlow = brokenFlow;
|
|
6715
6429
|
if (thisInit) {
|
|
6716
6430
|
replacedVariableInits.set(this.scope.thisVariable, thisInit);
|
|
@@ -6724,7 +6438,7 @@ class FunctionNode extends FunctionBase {
|
|
|
6724
6438
|
}
|
|
6725
6439
|
include(context, includeChildrenRecursively) {
|
|
6726
6440
|
super.include(context, includeChildrenRecursively);
|
|
6727
|
-
this.id?.include(
|
|
6441
|
+
this.id?.include();
|
|
6728
6442
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
6729
6443
|
for (const parameter of this.params) {
|
|
6730
6444
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
@@ -6732,18 +6446,12 @@ class FunctionNode extends FunctionBase {
|
|
|
6732
6446
|
}
|
|
6733
6447
|
}
|
|
6734
6448
|
}
|
|
6735
|
-
includeNode(context) {
|
|
6736
|
-
this.included = true;
|
|
6737
|
-
const hasArguments = this.scope.argumentsVariable.included;
|
|
6738
|
-
for (const parameter of this.params) {
|
|
6739
|
-
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
6740
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
6741
|
-
}
|
|
6742
|
-
}
|
|
6743
|
-
}
|
|
6744
6449
|
initialise() {
|
|
6745
6450
|
super.initialise();
|
|
6746
|
-
this.id?.declare('function',
|
|
6451
|
+
this.id?.declare('function', this);
|
|
6452
|
+
}
|
|
6453
|
+
addArgumentToBeDeoptimized(argument) {
|
|
6454
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6747
6455
|
}
|
|
6748
6456
|
getObjectEntity() {
|
|
6749
6457
|
if (this.objectEntity !== null) {
|
|
@@ -6793,16 +6501,11 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
6793
6501
|
}
|
|
6794
6502
|
class ExportDefaultDeclaration extends NodeBase {
|
|
6795
6503
|
include(context, includeChildrenRecursively) {
|
|
6796
|
-
|
|
6797
|
-
this.declaration.include(context, includeChildrenRecursively);
|
|
6504
|
+
super.include(context, includeChildrenRecursively);
|
|
6798
6505
|
if (includeChildrenRecursively) {
|
|
6799
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
6506
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
6800
6507
|
}
|
|
6801
6508
|
}
|
|
6802
|
-
includePath(path, context) {
|
|
6803
|
-
this.included = true;
|
|
6804
|
-
this.declaration.includePath(path, context);
|
|
6805
|
-
}
|
|
6806
6509
|
initialise() {
|
|
6807
6510
|
super.initialise();
|
|
6808
6511
|
const declaration = this.declaration;
|
|
@@ -6847,6 +6550,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6847
6550
|
}
|
|
6848
6551
|
this.declaration.render(code, options);
|
|
6849
6552
|
}
|
|
6553
|
+
applyDeoptimizations() { }
|
|
6850
6554
|
renderNamedDeclaration(code, declarationStart, idInsertPosition, options) {
|
|
6851
6555
|
const { exportNamesByVariable, format, snippets: { getPropertyAccess } } = options;
|
|
6852
6556
|
const name = this.variable.getName(getPropertyAccess);
|
|
@@ -6877,8 +6581,6 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
6877
6581
|
}
|
|
6878
6582
|
}
|
|
6879
6583
|
ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
6880
|
-
ExportDefaultDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
6881
|
-
ExportDefaultDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
6882
6584
|
|
|
6883
6585
|
const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
|
|
6884
6586
|
const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
|
|
@@ -7148,7 +6850,6 @@ class Literal extends NodeBase {
|
|
|
7148
6850
|
}
|
|
7149
6851
|
}
|
|
7150
6852
|
}
|
|
7151
|
-
Literal.prototype.includeNode = onlyIncludeSelf;
|
|
7152
6853
|
|
|
7153
6854
|
function getChainElementLiteralValueAtPath(element, object, path, recursionTracker, origin) {
|
|
7154
6855
|
if ('getLiteralValueAtPathAsChainElement' in object) {
|
|
@@ -7164,6 +6865,8 @@ function getChainElementLiteralValueAtPath(element, object, path, recursionTrack
|
|
|
7164
6865
|
return element.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7165
6866
|
}
|
|
7166
6867
|
|
|
6868
|
+
// To avoid infinite recursions
|
|
6869
|
+
const MAX_PATH_DEPTH = 7;
|
|
7167
6870
|
function getResolvablePropertyKey(memberExpression) {
|
|
7168
6871
|
return memberExpression.computed
|
|
7169
6872
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -7262,27 +6965,18 @@ class MemberExpression extends NodeBase {
|
|
|
7262
6965
|
}
|
|
7263
6966
|
else if (!this.isUndefined) {
|
|
7264
6967
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7265
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
6968
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
7266
6969
|
}
|
|
7267
6970
|
else {
|
|
7268
6971
|
deoptimizeInteraction(interaction);
|
|
7269
6972
|
}
|
|
7270
6973
|
}
|
|
7271
6974
|
}
|
|
7272
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
7273
|
-
this.deoptimizePath(EMPTY_PATH);
|
|
7274
|
-
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
7275
|
-
}
|
|
7276
6975
|
deoptimizeCache() {
|
|
7277
|
-
if (this.propertyKey === this.dynamicPropertyKey)
|
|
7278
|
-
return;
|
|
7279
6976
|
const { expressionsToBeDeoptimized, object } = this;
|
|
7280
6977
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
7281
|
-
this.
|
|
6978
|
+
this.propertyKey = UnknownKey;
|
|
7282
6979
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
7283
|
-
if (this.included) {
|
|
7284
|
-
object.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
7285
|
-
}
|
|
7286
6980
|
for (const expression of expressionsToBeDeoptimized) {
|
|
7287
6981
|
expression.deoptimizeCache();
|
|
7288
6982
|
}
|
|
@@ -7293,13 +6987,11 @@ class MemberExpression extends NodeBase {
|
|
|
7293
6987
|
if (this.variable) {
|
|
7294
6988
|
this.variable.deoptimizePath(path);
|
|
7295
6989
|
}
|
|
7296
|
-
else if (!this.isUndefined) {
|
|
7297
|
-
const
|
|
6990
|
+
else if (!this.isUndefined && path.length < MAX_PATH_DEPTH) {
|
|
6991
|
+
const propertyKey = this.getPropertyKey();
|
|
7298
6992
|
this.object.deoptimizePath([
|
|
7299
6993
|
propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey,
|
|
7300
|
-
...
|
|
7301
|
-
? path
|
|
7302
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
6994
|
+
...path
|
|
7303
6995
|
]);
|
|
7304
6996
|
}
|
|
7305
6997
|
}
|
|
@@ -7310,11 +7002,9 @@ class MemberExpression extends NodeBase {
|
|
|
7310
7002
|
if (this.isUndefined) {
|
|
7311
7003
|
return undefined;
|
|
7312
7004
|
}
|
|
7313
|
-
|
|
7314
|
-
|
|
7315
|
-
|
|
7316
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7317
|
-
return this.object.getLiteralValueAtPath([propertyKey, ...path], recursionTracker, origin);
|
|
7005
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7006
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7007
|
+
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
7318
7008
|
}
|
|
7319
7009
|
return UnknownValue;
|
|
7320
7010
|
}
|
|
@@ -7334,11 +7024,9 @@ class MemberExpression extends NodeBase {
|
|
|
7334
7024
|
if (this.isUndefined) {
|
|
7335
7025
|
return [UNDEFINED_EXPRESSION, false];
|
|
7336
7026
|
}
|
|
7337
|
-
|
|
7338
|
-
|
|
7339
|
-
|
|
7340
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7341
|
-
return this.object.getReturnExpressionWhenCalledAtPath([propertyKey, ...path], interaction, recursionTracker, origin);
|
|
7027
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
7028
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
7029
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
7342
7030
|
}
|
|
7343
7031
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
7344
7032
|
}
|
|
@@ -7384,45 +7072,14 @@ class MemberExpression extends NodeBase {
|
|
|
7384
7072
|
return true;
|
|
7385
7073
|
}
|
|
7386
7074
|
if (path.length < MAX_PATH_DEPTH) {
|
|
7387
|
-
return this.object.hasEffectsOnInteractionAtPath([this.
|
|
7075
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
7388
7076
|
}
|
|
7389
7077
|
return true;
|
|
7390
7078
|
}
|
|
7391
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
7392
|
-
return (destructuredInitPath.length > 0 &&
|
|
7393
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7394
|
-
}
|
|
7395
7079
|
include(context, includeChildrenRecursively) {
|
|
7396
|
-
if (!this.included)
|
|
7397
|
-
this.includeNode(context);
|
|
7398
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7399
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7400
|
-
}
|
|
7401
|
-
includeNode(context) {
|
|
7402
|
-
this.included = true;
|
|
7403
7080
|
if (!this.deoptimized)
|
|
7404
7081
|
this.applyDeoptimizations();
|
|
7405
|
-
|
|
7406
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
7407
|
-
}
|
|
7408
|
-
else if (!this.isUndefined) {
|
|
7409
|
-
this.object.includePath([this.propertyKey], context);
|
|
7410
|
-
}
|
|
7411
|
-
}
|
|
7412
|
-
includePath(path, context) {
|
|
7413
|
-
if (!this.included)
|
|
7414
|
-
this.includeNode(context);
|
|
7415
|
-
if (this.variable) {
|
|
7416
|
-
this.variable?.includePath(path, context);
|
|
7417
|
-
}
|
|
7418
|
-
else if (!this.isUndefined) {
|
|
7419
|
-
this.object.includePath([
|
|
7420
|
-
this.propertyKey,
|
|
7421
|
-
...(path.length < MAX_PATH_DEPTH
|
|
7422
|
-
? path
|
|
7423
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
7424
|
-
], context);
|
|
7425
|
-
}
|
|
7082
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7426
7083
|
}
|
|
7427
7084
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
7428
7085
|
if (!this.assignmentDeoptimized)
|
|
@@ -7431,34 +7088,20 @@ class MemberExpression extends NodeBase {
|
|
|
7431
7088
|
this.include(context, includeChildrenRecursively);
|
|
7432
7089
|
}
|
|
7433
7090
|
else {
|
|
7434
|
-
|
|
7435
|
-
this.includeNode(context);
|
|
7436
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7437
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7091
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7438
7092
|
}
|
|
7439
7093
|
}
|
|
7440
|
-
includeCallArguments(context,
|
|
7094
|
+
includeCallArguments(context, parameters) {
|
|
7441
7095
|
if (this.variable) {
|
|
7442
|
-
this.variable.includeCallArguments(context,
|
|
7096
|
+
this.variable.includeCallArguments(context, parameters);
|
|
7443
7097
|
}
|
|
7444
7098
|
else {
|
|
7445
|
-
super.includeCallArguments(context,
|
|
7446
|
-
}
|
|
7447
|
-
}
|
|
7448
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
7449
|
-
if ((this.included ||=
|
|
7450
|
-
destructuredInitPath.length > 0 &&
|
|
7451
|
-
!context.brokenFlow &&
|
|
7452
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext()))) {
|
|
7453
|
-
init.include(context, false);
|
|
7454
|
-
return true;
|
|
7099
|
+
super.includeCallArguments(context, parameters);
|
|
7455
7100
|
}
|
|
7456
|
-
return false;
|
|
7457
7101
|
}
|
|
7458
7102
|
initialise() {
|
|
7459
7103
|
super.initialise();
|
|
7460
|
-
this.
|
|
7461
|
-
this.propertyKey = this.dynamicPropertyKey === null ? UnknownKey : this.dynamicPropertyKey;
|
|
7104
|
+
this.propertyKey = getResolvablePropertyKey(this);
|
|
7462
7105
|
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
7463
7106
|
}
|
|
7464
7107
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
@@ -7495,7 +7138,8 @@ class MemberExpression extends NodeBase {
|
|
|
7495
7138
|
this.bound &&
|
|
7496
7139
|
propertyReadSideEffects &&
|
|
7497
7140
|
!(this.variable || this.isUndefined)) {
|
|
7498
|
-
this.
|
|
7141
|
+
const propertyKey = this.getPropertyKey();
|
|
7142
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
7499
7143
|
this.scope.context.requestTreeshakingPass();
|
|
7500
7144
|
}
|
|
7501
7145
|
if (this.variable) {
|
|
@@ -7512,7 +7156,7 @@ class MemberExpression extends NodeBase {
|
|
|
7512
7156
|
this.bound &&
|
|
7513
7157
|
propertyReadSideEffects &&
|
|
7514
7158
|
!(this.variable || this.isUndefined)) {
|
|
7515
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.
|
|
7159
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
7516
7160
|
this.scope.context.requestTreeshakingPass();
|
|
7517
7161
|
}
|
|
7518
7162
|
}
|
|
@@ -7521,24 +7165,24 @@ class MemberExpression extends NodeBase {
|
|
|
7521
7165
|
const variable = this.scope.findVariable(this.object.name);
|
|
7522
7166
|
if (variable.isNamespace) {
|
|
7523
7167
|
if (this.variable) {
|
|
7524
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7168
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7525
7169
|
}
|
|
7526
7170
|
this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
7527
7171
|
}
|
|
7528
7172
|
}
|
|
7529
7173
|
}
|
|
7530
|
-
|
|
7531
|
-
if (this.
|
|
7532
|
-
this.
|
|
7174
|
+
getPropertyKey() {
|
|
7175
|
+
if (this.propertyKey === null) {
|
|
7176
|
+
this.propertyKey = UnknownKey;
|
|
7533
7177
|
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7534
|
-
return (this.
|
|
7178
|
+
return (this.propertyKey =
|
|
7535
7179
|
value === SymbolToStringTag
|
|
7536
7180
|
? value
|
|
7537
7181
|
: typeof value === 'symbol'
|
|
7538
7182
|
? UnknownKey
|
|
7539
7183
|
: String(value));
|
|
7540
7184
|
}
|
|
7541
|
-
return this.
|
|
7185
|
+
return this.propertyKey;
|
|
7542
7186
|
}
|
|
7543
7187
|
hasAccessEffect(context) {
|
|
7544
7188
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -7546,7 +7190,17 @@ class MemberExpression extends NodeBase {
|
|
|
7546
7190
|
return (!(this.variable || this.isUndefined) &&
|
|
7547
7191
|
propertyReadSideEffects &&
|
|
7548
7192
|
(propertyReadSideEffects === 'always' ||
|
|
7549
|
-
this.object.hasEffectsOnInteractionAtPath([this.
|
|
7193
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
7194
|
+
}
|
|
7195
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
7196
|
+
if (!this.included) {
|
|
7197
|
+
this.included = true;
|
|
7198
|
+
if (this.variable) {
|
|
7199
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7200
|
+
}
|
|
7201
|
+
}
|
|
7202
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7203
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7550
7204
|
}
|
|
7551
7205
|
}
|
|
7552
7206
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -7590,20 +7244,18 @@ class MetaProperty extends NodeBase {
|
|
|
7590
7244
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
7591
7245
|
}
|
|
7592
7246
|
include() {
|
|
7593
|
-
if (!this.included)
|
|
7594
|
-
this.
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7606
|
-
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7247
|
+
if (!this.included) {
|
|
7248
|
+
this.included = true;
|
|
7249
|
+
if (this.meta.name === IMPORT) {
|
|
7250
|
+
this.scope.context.addImportMeta(this);
|
|
7251
|
+
const parent = this.parent;
|
|
7252
|
+
const metaProperty = (this.metaProperty =
|
|
7253
|
+
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
7254
|
+
? parent.propertyKey
|
|
7255
|
+
: null);
|
|
7256
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
7257
|
+
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
7258
|
+
}
|
|
7607
7259
|
}
|
|
7608
7260
|
}
|
|
7609
7261
|
}
|
|
@@ -7710,7 +7362,7 @@ class UndefinedVariable extends Variable {
|
|
|
7710
7362
|
|
|
7711
7363
|
class ExportDefaultVariable extends LocalVariable {
|
|
7712
7364
|
constructor(name, exportDefaultDeclaration, context) {
|
|
7713
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration,
|
|
7365
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
7714
7366
|
this.hasId = false;
|
|
7715
7367
|
this.originalId = null;
|
|
7716
7368
|
this.originalVariable = null;
|
|
@@ -7859,8 +7511,8 @@ class NamespaceVariable extends Variable {
|
|
|
7859
7511
|
return (!memberVariable ||
|
|
7860
7512
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
7861
7513
|
}
|
|
7862
|
-
|
|
7863
|
-
super.
|
|
7514
|
+
include() {
|
|
7515
|
+
super.include();
|
|
7864
7516
|
this.context.includeAllExports();
|
|
7865
7517
|
}
|
|
7866
7518
|
prepare(accessedGlobalsByScope) {
|
|
@@ -7953,9 +7605,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
7953
7605
|
getName(getPropertyAccess) {
|
|
7954
7606
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
7955
7607
|
}
|
|
7956
|
-
|
|
7957
|
-
super.
|
|
7958
|
-
this.context.includeVariableInModule(this.syntheticNamespace
|
|
7608
|
+
include() {
|
|
7609
|
+
super.include();
|
|
7610
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
7959
7611
|
}
|
|
7960
7612
|
setRenderNames(baseName, name) {
|
|
7961
7613
|
super.setRenderNames(baseName, name);
|
|
@@ -11160,37 +10812,21 @@ class ArrayPattern extends NodeBase {
|
|
|
11160
10812
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
11161
10813
|
}
|
|
11162
10814
|
}
|
|
11163
|
-
declare(kind
|
|
10815
|
+
declare(kind) {
|
|
11164
10816
|
const variables = [];
|
|
11165
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11166
10817
|
for (const element of this.elements) {
|
|
11167
10818
|
if (element !== null) {
|
|
11168
|
-
variables.push(...element.declare(kind,
|
|
10819
|
+
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
|
|
11169
10820
|
}
|
|
11170
10821
|
}
|
|
11171
10822
|
return variables;
|
|
11172
10823
|
}
|
|
11173
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11174
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11175
|
-
for (const element of this.elements) {
|
|
11176
|
-
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
11177
|
-
}
|
|
11178
|
-
}
|
|
11179
10824
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
11180
10825
|
deoptimizePath() {
|
|
11181
10826
|
for (const element of this.elements) {
|
|
11182
10827
|
element?.deoptimizePath(EMPTY_PATH);
|
|
11183
10828
|
}
|
|
11184
10829
|
}
|
|
11185
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11186
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11187
|
-
for (const element of this.elements) {
|
|
11188
|
-
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
11189
|
-
return true;
|
|
11190
|
-
}
|
|
11191
|
-
}
|
|
11192
|
-
return false;
|
|
11193
|
-
}
|
|
11194
10830
|
// Patterns are only checked at the empty path at the moment
|
|
11195
10831
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
11196
10832
|
for (const element of this.elements) {
|
|
@@ -11199,38 +10835,12 @@ class ArrayPattern extends NodeBase {
|
|
|
11199
10835
|
}
|
|
11200
10836
|
return false;
|
|
11201
10837
|
}
|
|
11202
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11203
|
-
let included = false;
|
|
11204
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11205
|
-
for (const element of this.elements) {
|
|
11206
|
-
if (element) {
|
|
11207
|
-
element.included ||= included;
|
|
11208
|
-
included =
|
|
11209
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
11210
|
-
}
|
|
11211
|
-
}
|
|
11212
|
-
if (included) {
|
|
11213
|
-
// This is necessary so that if any pattern element is included, all are
|
|
11214
|
-
// included for proper deconflicting
|
|
11215
|
-
for (const element of this.elements) {
|
|
11216
|
-
if (element && !element.included) {
|
|
11217
|
-
element.included = true;
|
|
11218
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init);
|
|
11219
|
-
}
|
|
11220
|
-
}
|
|
11221
|
-
}
|
|
11222
|
-
return (this.included ||= included);
|
|
11223
|
-
}
|
|
11224
10838
|
markDeclarationReached() {
|
|
11225
10839
|
for (const element of this.elements) {
|
|
11226
10840
|
element?.markDeclarationReached();
|
|
11227
10841
|
}
|
|
11228
10842
|
}
|
|
11229
10843
|
}
|
|
11230
|
-
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
11231
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
11232
|
-
? destructuredInitPath
|
|
11233
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
11234
10844
|
|
|
11235
10845
|
class ArrowFunctionExpression extends FunctionBase {
|
|
11236
10846
|
constructor() {
|
|
@@ -11247,17 +10857,17 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11247
10857
|
this.scope = new ReturnValueScope(parentScope, false);
|
|
11248
10858
|
}
|
|
11249
10859
|
hasEffects() {
|
|
10860
|
+
if (!this.deoptimized)
|
|
10861
|
+
this.applyDeoptimizations();
|
|
11250
10862
|
return false;
|
|
11251
10863
|
}
|
|
11252
10864
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11253
|
-
if (this.annotationNoSideEffects &&
|
|
11254
|
-
path.length === 0 &&
|
|
11255
|
-
interaction.type === INTERACTION_CALLED) {
|
|
11256
|
-
return false;
|
|
11257
|
-
}
|
|
11258
10865
|
if (super.hasEffectsOnInteractionAtPath(path, interaction, context)) {
|
|
11259
10866
|
return true;
|
|
11260
10867
|
}
|
|
10868
|
+
if (this.annotationNoSideEffects) {
|
|
10869
|
+
return false;
|
|
10870
|
+
}
|
|
11261
10871
|
if (interaction.type === INTERACTION_CALLED) {
|
|
11262
10872
|
const { ignore, brokenFlow } = context;
|
|
11263
10873
|
context.ignore = {
|
|
@@ -11287,15 +10897,6 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11287
10897
|
}
|
|
11288
10898
|
}
|
|
11289
10899
|
}
|
|
11290
|
-
includeNode(context) {
|
|
11291
|
-
this.included = true;
|
|
11292
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
11293
|
-
for (const parameter of this.params) {
|
|
11294
|
-
if (!(parameter instanceof Identifier)) {
|
|
11295
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
11296
|
-
}
|
|
11297
|
-
}
|
|
11298
|
-
}
|
|
11299
10900
|
getObjectEntity() {
|
|
11300
10901
|
if (this.objectEntity !== null) {
|
|
11301
10902
|
return this.objectEntity;
|
|
@@ -11315,18 +10916,13 @@ class ObjectPattern extends NodeBase {
|
|
|
11315
10916
|
}
|
|
11316
10917
|
}
|
|
11317
10918
|
}
|
|
11318
|
-
declare(kind,
|
|
10919
|
+
declare(kind, init) {
|
|
11319
10920
|
const variables = [];
|
|
11320
10921
|
for (const property of this.properties) {
|
|
11321
|
-
variables.push(...property.declare(kind,
|
|
10922
|
+
variables.push(...property.declare(kind, init));
|
|
11322
10923
|
}
|
|
11323
10924
|
return variables;
|
|
11324
10925
|
}
|
|
11325
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11326
|
-
for (const property of this.properties) {
|
|
11327
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
11328
|
-
}
|
|
11329
|
-
}
|
|
11330
10926
|
deoptimizePath(path) {
|
|
11331
10927
|
if (path.length === 0) {
|
|
11332
10928
|
for (const property of this.properties) {
|
|
@@ -11344,46 +10940,12 @@ class ObjectPattern extends NodeBase {
|
|
|
11344
10940
|
}
|
|
11345
10941
|
return false;
|
|
11346
10942
|
}
|
|
11347
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11348
|
-
for (const property of this.properties) {
|
|
11349
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
11350
|
-
return true;
|
|
11351
|
-
}
|
|
11352
|
-
return false;
|
|
11353
|
-
}
|
|
11354
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11355
|
-
let included = false;
|
|
11356
|
-
for (const property of this.properties) {
|
|
11357
|
-
included =
|
|
11358
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
11359
|
-
}
|
|
11360
|
-
return (this.included ||= included);
|
|
11361
|
-
}
|
|
11362
10943
|
markDeclarationReached() {
|
|
11363
10944
|
for (const property of this.properties) {
|
|
11364
10945
|
property.markDeclarationReached();
|
|
11365
10946
|
}
|
|
11366
10947
|
}
|
|
11367
|
-
render(code, options) {
|
|
11368
|
-
if (this.properties.length > 0) {
|
|
11369
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
11370
|
-
let lastSeparatorPos = null;
|
|
11371
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
11372
|
-
if (!node.included) {
|
|
11373
|
-
treeshakeNode(node, code, start, end);
|
|
11374
|
-
continue;
|
|
11375
|
-
}
|
|
11376
|
-
lastSeparatorPos = separator;
|
|
11377
|
-
node.render(code, options);
|
|
11378
|
-
}
|
|
11379
|
-
if (lastSeparatorPos) {
|
|
11380
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
11381
|
-
}
|
|
11382
|
-
}
|
|
11383
|
-
}
|
|
11384
10948
|
}
|
|
11385
|
-
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11386
|
-
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11387
10949
|
|
|
11388
10950
|
class AssignmentExpression extends NodeBase {
|
|
11389
10951
|
hasEffects(context) {
|
|
@@ -11392,9 +10954,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
11392
10954
|
this.applyDeoptimizations();
|
|
11393
10955
|
// MemberExpressions do not access the property before assignments if the
|
|
11394
10956
|
// operator is '='.
|
|
11395
|
-
return (right.hasEffects(context) ||
|
|
11396
|
-
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
11397
|
-
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
10957
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, operator !== '='));
|
|
11398
10958
|
}
|
|
11399
10959
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11400
10960
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -11403,24 +10963,15 @@ class AssignmentExpression extends NodeBase {
|
|
|
11403
10963
|
const { deoptimized, left, right, operator } = this;
|
|
11404
10964
|
if (!deoptimized)
|
|
11405
10965
|
this.applyDeoptimizations();
|
|
11406
|
-
|
|
11407
|
-
this.includeNode(context);
|
|
11408
|
-
const hasEffectsContext = createHasEffectsContext();
|
|
10966
|
+
this.included = true;
|
|
11409
10967
|
if (includeChildrenRecursively ||
|
|
11410
10968
|
operator !== '=' ||
|
|
11411
10969
|
left.included ||
|
|
11412
|
-
left.hasEffectsAsAssignmentTarget(
|
|
11413
|
-
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
10970
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
11414
10971
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
11415
10972
|
}
|
|
11416
10973
|
right.include(context, includeChildrenRecursively);
|
|
11417
10974
|
}
|
|
11418
|
-
includeNode(context) {
|
|
11419
|
-
this.included = true;
|
|
11420
|
-
if (!this.deoptimized)
|
|
11421
|
-
this.applyDeoptimizations();
|
|
11422
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11423
|
-
}
|
|
11424
10975
|
initialise() {
|
|
11425
10976
|
super.initialise();
|
|
11426
10977
|
if (this.left instanceof Identifier) {
|
|
@@ -11481,7 +11032,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
11481
11032
|
}
|
|
11482
11033
|
applyDeoptimizations() {
|
|
11483
11034
|
this.deoptimized = true;
|
|
11484
|
-
this.left.
|
|
11035
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
11036
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
11485
11037
|
this.scope.context.requestTreeshakingPass();
|
|
11486
11038
|
}
|
|
11487
11039
|
}
|
|
@@ -11490,11 +11042,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
11490
11042
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11491
11043
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11492
11044
|
}
|
|
11493
|
-
declare(kind,
|
|
11494
|
-
return this.left.declare(kind,
|
|
11495
|
-
}
|
|
11496
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11497
|
-
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
11045
|
+
declare(kind, init) {
|
|
11046
|
+
return this.left.declare(kind, init);
|
|
11498
11047
|
}
|
|
11499
11048
|
deoptimizePath(path) {
|
|
11500
11049
|
if (path.length === 0) {
|
|
@@ -11504,29 +11053,6 @@ class AssignmentPattern extends NodeBase {
|
|
|
11504
11053
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11505
11054
|
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11506
11055
|
}
|
|
11507
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11508
|
-
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
11509
|
-
}
|
|
11510
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11511
|
-
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
11512
|
-
this.included;
|
|
11513
|
-
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
11514
|
-
this.right.include(context, false);
|
|
11515
|
-
if (!this.left.included) {
|
|
11516
|
-
this.left.included = true;
|
|
11517
|
-
// Unfortunately, we need to include the left side again now, so that
|
|
11518
|
-
// any declared variables are properly included.
|
|
11519
|
-
this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
11520
|
-
}
|
|
11521
|
-
}
|
|
11522
|
-
return (this.included = included);
|
|
11523
|
-
}
|
|
11524
|
-
includeNode(context) {
|
|
11525
|
-
this.included = true;
|
|
11526
|
-
if (!this.deoptimized)
|
|
11527
|
-
this.applyDeoptimizations();
|
|
11528
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11529
|
-
}
|
|
11530
11056
|
markDeclarationReached() {
|
|
11531
11057
|
this.left.markDeclarationReached();
|
|
11532
11058
|
}
|
|
@@ -11549,34 +11075,22 @@ class AwaitExpression extends NodeBase {
|
|
|
11549
11075
|
return true;
|
|
11550
11076
|
}
|
|
11551
11077
|
include(context, includeChildrenRecursively) {
|
|
11552
|
-
if (!this.included)
|
|
11553
|
-
this.includeNode(context);
|
|
11554
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
11555
|
-
}
|
|
11556
|
-
includeNode(context) {
|
|
11557
|
-
this.included = true;
|
|
11558
11078
|
if (!this.deoptimized)
|
|
11559
11079
|
this.applyDeoptimizations();
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11080
|
+
if (!this.included) {
|
|
11081
|
+
this.included = true;
|
|
11082
|
+
checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
|
|
11083
|
+
let parent = this.parent;
|
|
11084
|
+
do {
|
|
11085
|
+
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
11086
|
+
break checkTopLevelAwait;
|
|
11087
|
+
} while ((parent = parent.parent));
|
|
11088
|
+
this.scope.context.usesTopLevelAwait = true;
|
|
11089
|
+
}
|
|
11567
11090
|
}
|
|
11568
|
-
|
|
11569
|
-
this.argument.includePath(THEN_PATH, context);
|
|
11570
|
-
}
|
|
11571
|
-
includePath(path, context) {
|
|
11572
|
-
if (!this.deoptimized)
|
|
11573
|
-
this.applyDeoptimizations();
|
|
11574
|
-
if (!this.included)
|
|
11575
|
-
this.includeNode(context);
|
|
11576
|
-
this.argument.includePath(path, context);
|
|
11091
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11577
11092
|
}
|
|
11578
11093
|
}
|
|
11579
|
-
const THEN_PATH = ['then'];
|
|
11580
11094
|
|
|
11581
11095
|
const binaryOperators = {
|
|
11582
11096
|
'!=': (left, right) => left != right,
|
|
@@ -11632,12 +11146,6 @@ class BinaryExpression extends NodeBase {
|
|
|
11632
11146
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11633
11147
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
11634
11148
|
}
|
|
11635
|
-
includeNode(context) {
|
|
11636
|
-
this.included = true;
|
|
11637
|
-
if (this.operator === 'in') {
|
|
11638
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
11639
|
-
}
|
|
11640
|
-
}
|
|
11641
11149
|
removeAnnotations(code) {
|
|
11642
11150
|
this.left.removeAnnotations(code);
|
|
11643
11151
|
}
|
|
@@ -11646,7 +11154,6 @@ class BinaryExpression extends NodeBase {
|
|
|
11646
11154
|
this.right.render(code, options);
|
|
11647
11155
|
}
|
|
11648
11156
|
}
|
|
11649
|
-
BinaryExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11650
11157
|
|
|
11651
11158
|
class BreakStatement extends NodeBase {
|
|
11652
11159
|
hasEffects(context) {
|
|
@@ -11666,7 +11173,7 @@ class BreakStatement extends NodeBase {
|
|
|
11666
11173
|
include(context) {
|
|
11667
11174
|
this.included = true;
|
|
11668
11175
|
if (this.label) {
|
|
11669
|
-
this.label.include(
|
|
11176
|
+
this.label.include();
|
|
11670
11177
|
context.includedLabels.add(this.label.name);
|
|
11671
11178
|
}
|
|
11672
11179
|
else {
|
|
@@ -11675,8 +11182,6 @@ class BreakStatement extends NodeBase {
|
|
|
11675
11182
|
context.brokenFlow = true;
|
|
11676
11183
|
}
|
|
11677
11184
|
}
|
|
11678
|
-
BreakStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11679
|
-
BreakStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11680
11185
|
|
|
11681
11186
|
function renderCallArguments(code, options, node) {
|
|
11682
11187
|
if (node.arguments.length > 0) {
|
|
@@ -11863,14 +11368,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
11863
11368
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11864
11369
|
}
|
|
11865
11370
|
include(context, includeChildrenRecursively) {
|
|
11866
|
-
if (!this.
|
|
11867
|
-
this.
|
|
11371
|
+
if (!this.deoptimized)
|
|
11372
|
+
this.applyDeoptimizations();
|
|
11868
11373
|
if (includeChildrenRecursively) {
|
|
11869
|
-
|
|
11870
|
-
for (const argument of this.arguments) {
|
|
11871
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
11872
|
-
argument.include(context, true);
|
|
11873
|
-
}
|
|
11374
|
+
super.include(context, includeChildrenRecursively);
|
|
11874
11375
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
11875
11376
|
this.callee instanceof Identifier &&
|
|
11876
11377
|
this.callee.variable) {
|
|
@@ -11878,24 +11379,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
11878
11379
|
}
|
|
11879
11380
|
}
|
|
11880
11381
|
else {
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
11884
|
-
// severe performance problems.
|
|
11885
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11886
|
-
this.callee.property.include(context, false);
|
|
11887
|
-
}
|
|
11888
|
-
else {
|
|
11889
|
-
this.callee.include(context, false);
|
|
11890
|
-
}
|
|
11891
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
11382
|
+
this.included = true;
|
|
11383
|
+
this.callee.include(context, false);
|
|
11892
11384
|
}
|
|
11893
|
-
|
|
11894
|
-
includeNode(context) {
|
|
11895
|
-
this.included = true;
|
|
11896
|
-
if (!this.deoptimized)
|
|
11897
|
-
this.applyDeoptimizations();
|
|
11898
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
11385
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
11899
11386
|
}
|
|
11900
11387
|
initialise() {
|
|
11901
11388
|
super.initialise();
|
|
@@ -11934,14 +11421,13 @@ class CatchClause extends NodeBase {
|
|
|
11934
11421
|
this.type = type;
|
|
11935
11422
|
if (param) {
|
|
11936
11423
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11937
|
-
this.param.declare('parameter',
|
|
11424
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11938
11425
|
}
|
|
11939
11426
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11940
11427
|
return super.parseNode(esTreeNode);
|
|
11941
11428
|
}
|
|
11942
11429
|
}
|
|
11943
11430
|
CatchClause.prototype.preventChildBlockScope = true;
|
|
11944
|
-
CatchClause.prototype.includeNode = onlyIncludeSelf;
|
|
11945
11431
|
|
|
11946
11432
|
class ChainExpression extends NodeBase {
|
|
11947
11433
|
// deoptimizations are not relevant as we are not caching values
|
|
@@ -11953,22 +11439,17 @@ class ChainExpression extends NodeBase {
|
|
|
11953
11439
|
hasEffects(context) {
|
|
11954
11440
|
return this.expression.hasEffectsAsChainElement(context) === true;
|
|
11955
11441
|
}
|
|
11956
|
-
includePath(path, context) {
|
|
11957
|
-
this.included = true;
|
|
11958
|
-
this.expression.includePath(path, context);
|
|
11959
|
-
}
|
|
11960
11442
|
removeAnnotations(code) {
|
|
11961
11443
|
this.expression.removeAnnotations(code);
|
|
11962
11444
|
}
|
|
11445
|
+
applyDeoptimizations() { }
|
|
11963
11446
|
}
|
|
11964
|
-
ChainExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
11965
|
-
ChainExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
11966
11447
|
|
|
11967
11448
|
class ClassBodyScope extends ChildScope {
|
|
11968
11449
|
constructor(parent, classNode) {
|
|
11969
11450
|
const { context } = parent;
|
|
11970
11451
|
super(parent, context);
|
|
11971
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode,
|
|
11452
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
11972
11453
|
this.instanceScope = new ChildScope(this, context);
|
|
11973
11454
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11974
11455
|
}
|
|
@@ -11983,7 +11464,7 @@ class ClassBody extends NodeBase {
|
|
|
11983
11464
|
}
|
|
11984
11465
|
include(context, includeChildrenRecursively) {
|
|
11985
11466
|
this.included = true;
|
|
11986
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
11467
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11987
11468
|
for (const definition of this.body) {
|
|
11988
11469
|
definition.include(context, includeChildrenRecursively);
|
|
11989
11470
|
}
|
|
@@ -11996,9 +11477,8 @@ class ClassBody extends NodeBase {
|
|
|
11996
11477
|
}
|
|
11997
11478
|
return super.parseNode(esTreeNode);
|
|
11998
11479
|
}
|
|
11480
|
+
applyDeoptimizations() { }
|
|
11999
11481
|
}
|
|
12000
|
-
ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12001
|
-
ClassBody.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12002
11482
|
|
|
12003
11483
|
class ClassExpression extends ClassNode {
|
|
12004
11484
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
@@ -12069,9 +11549,6 @@ class ConditionalExpression extends NodeBase {
|
|
|
12069
11549
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
12070
11550
|
this.usedBranch = null;
|
|
12071
11551
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
12072
|
-
if (this.included) {
|
|
12073
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
12074
|
-
}
|
|
12075
11552
|
const { expressionsToBeDeoptimized } = this;
|
|
12076
11553
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
12077
11554
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -12129,7 +11606,7 @@ class ConditionalExpression extends NodeBase {
|
|
|
12129
11606
|
include(context, includeChildrenRecursively) {
|
|
12130
11607
|
this.included = true;
|
|
12131
11608
|
const usedBranch = this.getUsedBranch();
|
|
12132
|
-
if (
|
|
11609
|
+
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
12133
11610
|
this.test.include(context, includeChildrenRecursively);
|
|
12134
11611
|
this.consequent.include(context, includeChildrenRecursively);
|
|
12135
11612
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -12138,38 +11615,27 @@ class ConditionalExpression extends NodeBase {
|
|
|
12138
11615
|
usedBranch.include(context, includeChildrenRecursively);
|
|
12139
11616
|
}
|
|
12140
11617
|
}
|
|
12141
|
-
|
|
12142
|
-
this.included = true;
|
|
12143
|
-
const usedBranch = this.getUsedBranch();
|
|
12144
|
-
if (usedBranch === null || this.test.shouldBeIncluded(context)) {
|
|
12145
|
-
this.consequent.includePath(path, context);
|
|
12146
|
-
this.alternate.includePath(path, context);
|
|
12147
|
-
}
|
|
12148
|
-
else {
|
|
12149
|
-
usedBranch.includePath(path, context);
|
|
12150
|
-
}
|
|
12151
|
-
}
|
|
12152
|
-
includeCallArguments(context, interaction) {
|
|
11618
|
+
includeCallArguments(context, parameters) {
|
|
12153
11619
|
const usedBranch = this.getUsedBranch();
|
|
12154
11620
|
if (usedBranch) {
|
|
12155
|
-
usedBranch.includeCallArguments(context,
|
|
11621
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
12156
11622
|
}
|
|
12157
11623
|
else {
|
|
12158
|
-
this.consequent.includeCallArguments(context,
|
|
12159
|
-
this.alternate.includeCallArguments(context,
|
|
11624
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
11625
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
12160
11626
|
}
|
|
12161
11627
|
}
|
|
12162
11628
|
removeAnnotations(code) {
|
|
12163
11629
|
this.test.removeAnnotations(code);
|
|
12164
11630
|
}
|
|
12165
11631
|
render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
11632
|
+
const usedBranch = this.getUsedBranch();
|
|
12166
11633
|
if (this.test.included) {
|
|
12167
11634
|
this.test.render(code, options, { renderedSurroundingElement });
|
|
12168
11635
|
this.consequent.render(code, options);
|
|
12169
11636
|
this.alternate.render(code, options);
|
|
12170
11637
|
}
|
|
12171
11638
|
else {
|
|
12172
|
-
const usedBranch = this.getUsedBranch();
|
|
12173
11639
|
const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);
|
|
12174
11640
|
const inclusionStart = findNonWhiteSpace(code.original, (this.consequent.included
|
|
12175
11641
|
? findFirstOccurrenceOutsideComment(code.original, '?', this.test.end)
|
|
@@ -12201,8 +11667,6 @@ class ConditionalExpression extends NodeBase {
|
|
|
12201
11667
|
: (this.usedBranch = testValue ? this.consequent : this.alternate);
|
|
12202
11668
|
}
|
|
12203
11669
|
}
|
|
12204
|
-
ConditionalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12205
|
-
ConditionalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12206
11670
|
|
|
12207
11671
|
class ContinueStatement extends NodeBase {
|
|
12208
11672
|
hasEffects(context) {
|
|
@@ -12222,7 +11686,7 @@ class ContinueStatement extends NodeBase {
|
|
|
12222
11686
|
include(context) {
|
|
12223
11687
|
this.included = true;
|
|
12224
11688
|
if (this.label) {
|
|
12225
|
-
this.label.include(
|
|
11689
|
+
this.label.include();
|
|
12226
11690
|
context.includedLabels.add(this.label.name);
|
|
12227
11691
|
}
|
|
12228
11692
|
else {
|
|
@@ -12231,15 +11695,12 @@ class ContinueStatement extends NodeBase {
|
|
|
12231
11695
|
context.brokenFlow = true;
|
|
12232
11696
|
}
|
|
12233
11697
|
}
|
|
12234
|
-
ContinueStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12235
|
-
ContinueStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12236
11698
|
|
|
12237
11699
|
class DebuggerStatement extends NodeBase {
|
|
12238
11700
|
hasEffects() {
|
|
12239
11701
|
return true;
|
|
12240
11702
|
}
|
|
12241
11703
|
}
|
|
12242
|
-
DebuggerStatement.prototype.includeNode = onlyIncludeSelf;
|
|
12243
11704
|
|
|
12244
11705
|
class Decorator extends NodeBase {
|
|
12245
11706
|
hasEffects(context) {
|
|
@@ -12247,7 +11708,6 @@ class Decorator extends NodeBase {
|
|
|
12247
11708
|
this.expression.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context));
|
|
12248
11709
|
}
|
|
12249
11710
|
}
|
|
12250
|
-
Decorator.prototype.includeNode = onlyIncludeSelf;
|
|
12251
11711
|
|
|
12252
11712
|
function hasLoopBodyEffects(context, body) {
|
|
12253
11713
|
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
@@ -12287,15 +11747,12 @@ class DoWhileStatement extends NodeBase {
|
|
|
12287
11747
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12288
11748
|
}
|
|
12289
11749
|
}
|
|
12290
|
-
DoWhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12291
|
-
DoWhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12292
11750
|
|
|
12293
11751
|
class EmptyStatement extends NodeBase {
|
|
12294
11752
|
hasEffects() {
|
|
12295
11753
|
return false;
|
|
12296
11754
|
}
|
|
12297
11755
|
}
|
|
12298
|
-
EmptyStatement.prototype.includeNode = onlyIncludeSelf;
|
|
12299
11756
|
|
|
12300
11757
|
class ExportAllDeclaration extends NodeBase {
|
|
12301
11758
|
hasEffects() {
|
|
@@ -12308,10 +11765,9 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
12308
11765
|
render(code, _options, nodeRenderOptions) {
|
|
12309
11766
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12310
11767
|
}
|
|
11768
|
+
applyDeoptimizations() { }
|
|
12311
11769
|
}
|
|
12312
11770
|
ExportAllDeclaration.prototype.needsBoundaries = true;
|
|
12313
|
-
ExportAllDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12314
|
-
ExportAllDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12315
11771
|
|
|
12316
11772
|
class ExportNamedDeclaration extends NodeBase {
|
|
12317
11773
|
bind() {
|
|
@@ -12338,15 +11794,13 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
12338
11794
|
this.declaration.render(code, options, { end, start });
|
|
12339
11795
|
}
|
|
12340
11796
|
}
|
|
11797
|
+
applyDeoptimizations() { }
|
|
12341
11798
|
}
|
|
12342
11799
|
ExportNamedDeclaration.prototype.needsBoundaries = true;
|
|
12343
|
-
ExportNamedDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12344
|
-
ExportNamedDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12345
11800
|
|
|
12346
11801
|
class ExportSpecifier extends NodeBase {
|
|
11802
|
+
applyDeoptimizations() { }
|
|
12347
11803
|
}
|
|
12348
|
-
ExportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12349
|
-
ExportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12350
11804
|
|
|
12351
11805
|
class ForInStatement extends NodeBase {
|
|
12352
11806
|
createScope(parentScope) {
|
|
@@ -12364,18 +11818,11 @@ class ForInStatement extends NodeBase {
|
|
|
12364
11818
|
const { body, deoptimized, left, right } = this;
|
|
12365
11819
|
if (!deoptimized)
|
|
12366
11820
|
this.applyDeoptimizations();
|
|
12367
|
-
|
|
12368
|
-
this.includeNode(context);
|
|
11821
|
+
this.included = true;
|
|
12369
11822
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12370
11823
|
right.include(context, includeChildrenRecursively);
|
|
12371
11824
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12372
11825
|
}
|
|
12373
|
-
includeNode(context) {
|
|
12374
|
-
this.included = true;
|
|
12375
|
-
if (!this.deoptimized)
|
|
12376
|
-
this.applyDeoptimizations();
|
|
12377
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12378
|
-
}
|
|
12379
11826
|
initialise() {
|
|
12380
11827
|
super.initialise();
|
|
12381
11828
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -12416,18 +11863,11 @@ class ForOfStatement extends NodeBase {
|
|
|
12416
11863
|
const { body, deoptimized, left, right } = this;
|
|
12417
11864
|
if (!deoptimized)
|
|
12418
11865
|
this.applyDeoptimizations();
|
|
12419
|
-
|
|
12420
|
-
this.includeNode(context);
|
|
11866
|
+
this.included = true;
|
|
12421
11867
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12422
11868
|
right.include(context, includeChildrenRecursively);
|
|
12423
11869
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12424
11870
|
}
|
|
12425
|
-
includeNode(context) {
|
|
12426
|
-
this.included = true;
|
|
12427
|
-
if (!this.deoptimized)
|
|
12428
|
-
this.applyDeoptimizations();
|
|
12429
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12430
|
-
}
|
|
12431
11871
|
initialise() {
|
|
12432
11872
|
super.initialise();
|
|
12433
11873
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -12463,9 +11903,7 @@ class ForStatement extends NodeBase {
|
|
|
12463
11903
|
}
|
|
12464
11904
|
include(context, includeChildrenRecursively) {
|
|
12465
11905
|
this.included = true;
|
|
12466
|
-
this.init?.include(context, includeChildrenRecursively, {
|
|
12467
|
-
asSingleStatement: true
|
|
12468
|
-
});
|
|
11906
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
12469
11907
|
this.test?.include(context, includeChildrenRecursively);
|
|
12470
11908
|
this.update?.include(context, includeChildrenRecursively);
|
|
12471
11909
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
@@ -12477,8 +11915,6 @@ class ForStatement extends NodeBase {
|
|
|
12477
11915
|
this.body.render(code, options);
|
|
12478
11916
|
}
|
|
12479
11917
|
}
|
|
12480
|
-
ForStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12481
|
-
ForStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12482
11918
|
|
|
12483
11919
|
class FunctionExpression extends FunctionNode {
|
|
12484
11920
|
createScope(parentScope) {
|
|
@@ -12510,9 +11946,9 @@ class TrackingScope extends BlockScope {
|
|
|
12510
11946
|
super(...arguments);
|
|
12511
11947
|
this.hoistedDeclarations = [];
|
|
12512
11948
|
}
|
|
12513
|
-
addDeclaration(identifier, context, init,
|
|
11949
|
+
addDeclaration(identifier, context, init, kind) {
|
|
12514
11950
|
this.hoistedDeclarations.push(identifier);
|
|
12515
|
-
return super.addDeclaration(identifier, context, init,
|
|
11951
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
12516
11952
|
}
|
|
12517
11953
|
}
|
|
12518
11954
|
|
|
@@ -12611,6 +12047,7 @@ class IfStatement extends NodeBase {
|
|
|
12611
12047
|
}
|
|
12612
12048
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
12613
12049
|
}
|
|
12050
|
+
applyDeoptimizations() { }
|
|
12614
12051
|
getTestValue() {
|
|
12615
12052
|
if (this.testValue === unset) {
|
|
12616
12053
|
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
@@ -12679,8 +12116,6 @@ class IfStatement extends NodeBase {
|
|
|
12679
12116
|
return false;
|
|
12680
12117
|
}
|
|
12681
12118
|
}
|
|
12682
|
-
IfStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12683
|
-
IfStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12684
12119
|
|
|
12685
12120
|
class ImportAttribute extends NodeBase {
|
|
12686
12121
|
}
|
|
@@ -12698,15 +12133,13 @@ class ImportDeclaration extends NodeBase {
|
|
|
12698
12133
|
render(code, _options, nodeRenderOptions) {
|
|
12699
12134
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
12700
12135
|
}
|
|
12136
|
+
applyDeoptimizations() { }
|
|
12701
12137
|
}
|
|
12702
12138
|
ImportDeclaration.prototype.needsBoundaries = true;
|
|
12703
|
-
ImportDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12704
|
-
ImportDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12705
12139
|
|
|
12706
12140
|
class ImportDefaultSpecifier extends NodeBase {
|
|
12141
|
+
applyDeoptimizations() { }
|
|
12707
12142
|
}
|
|
12708
|
-
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12709
|
-
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12710
12143
|
|
|
12711
12144
|
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
12712
12145
|
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
@@ -12715,33 +12148,28 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12715
12148
|
class VariableDeclarator extends NodeBase {
|
|
12716
12149
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12717
12150
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12718
|
-
this.id.declare(kind,
|
|
12151
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12719
12152
|
}
|
|
12720
12153
|
deoptimizePath(path) {
|
|
12721
12154
|
this.id.deoptimizePath(path);
|
|
12722
12155
|
}
|
|
12723
12156
|
hasEffects(context) {
|
|
12157
|
+
if (!this.deoptimized)
|
|
12158
|
+
this.applyDeoptimizations();
|
|
12724
12159
|
const initEffect = this.init?.hasEffects(context);
|
|
12725
12160
|
this.id.markDeclarationReached();
|
|
12726
|
-
return
|
|
12727
|
-
this.isUsingDeclaration ||
|
|
12728
|
-
this.id.hasEffects(context) ||
|
|
12729
|
-
(this.scope.context.options.treeshake
|
|
12730
|
-
.propertyReadSideEffects &&
|
|
12731
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
12161
|
+
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
12732
12162
|
}
|
|
12733
12163
|
include(context, includeChildrenRecursively) {
|
|
12734
|
-
const { id, init } = this;
|
|
12735
|
-
if (!
|
|
12736
|
-
this.
|
|
12164
|
+
const { deoptimized, id, init } = this;
|
|
12165
|
+
if (!deoptimized)
|
|
12166
|
+
this.applyDeoptimizations();
|
|
12167
|
+
this.included = true;
|
|
12737
12168
|
init?.include(context, includeChildrenRecursively);
|
|
12738
12169
|
id.markDeclarationReached();
|
|
12739
|
-
if (includeChildrenRecursively) {
|
|
12170
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12740
12171
|
id.include(context, includeChildrenRecursively);
|
|
12741
12172
|
}
|
|
12742
|
-
else {
|
|
12743
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
12744
|
-
}
|
|
12745
12173
|
}
|
|
12746
12174
|
removeAnnotations(code) {
|
|
12747
12175
|
this.init?.removeAnnotations(code);
|
|
@@ -12771,8 +12199,8 @@ class VariableDeclarator extends NodeBase {
|
|
|
12771
12199
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
12772
12200
|
}
|
|
12773
12201
|
}
|
|
12774
|
-
|
|
12775
|
-
this.
|
|
12202
|
+
applyDeoptimizations() {
|
|
12203
|
+
this.deoptimized = true;
|
|
12776
12204
|
const { id, init } = this;
|
|
12777
12205
|
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
12778
12206
|
const { name, variable } = id;
|
|
@@ -12784,14 +12212,11 @@ class VariableDeclarator extends NodeBase {
|
|
|
12784
12212
|
}
|
|
12785
12213
|
}
|
|
12786
12214
|
}
|
|
12787
|
-
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12788
12215
|
|
|
12789
12216
|
class ImportExpression extends NodeBase {
|
|
12790
12217
|
constructor() {
|
|
12791
12218
|
super(...arguments);
|
|
12792
12219
|
this.inlineNamespace = null;
|
|
12793
|
-
this.hasUnknownAccessedKey = false;
|
|
12794
|
-
this.accessedPropKey = new Set();
|
|
12795
12220
|
this.attributes = null;
|
|
12796
12221
|
this.mechanism = null;
|
|
12797
12222
|
this.namespaceExportName = undefined;
|
|
@@ -12824,15 +12249,12 @@ class ImportExpression extends NodeBase {
|
|
|
12824
12249
|
if (parent2 instanceof ExpressionStatement) {
|
|
12825
12250
|
return EMPTY_ARRAY;
|
|
12826
12251
|
}
|
|
12827
|
-
// Case 1: const { foo }
|
|
12252
|
+
// Case 1: const { foo } = await import('bar')
|
|
12828
12253
|
if (parent2 instanceof VariableDeclarator) {
|
|
12829
12254
|
const declaration = parent2.id;
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
if (declaration instanceof ObjectPattern) {
|
|
12834
|
-
return getDeterministicObjectDestructure(declaration);
|
|
12835
|
-
}
|
|
12255
|
+
return declaration instanceof ObjectPattern
|
|
12256
|
+
? getDeterministicObjectDestructure(declaration)
|
|
12257
|
+
: undefined;
|
|
12836
12258
|
}
|
|
12837
12259
|
// Case 2: (await import('bar')).foo
|
|
12838
12260
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12882,29 +12304,12 @@ class ImportExpression extends NodeBase {
|
|
|
12882
12304
|
return true;
|
|
12883
12305
|
}
|
|
12884
12306
|
include(context, includeChildrenRecursively) {
|
|
12885
|
-
if (!this.included)
|
|
12886
|
-
this.
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
includeNode() {
|
|
12890
|
-
this.included = true;
|
|
12891
|
-
this.scope.context.includeDynamicImport(this);
|
|
12892
|
-
this.scope.addAccessedDynamicImport(this);
|
|
12893
|
-
}
|
|
12894
|
-
includePath(path) {
|
|
12895
|
-
if (!this.included)
|
|
12896
|
-
this.includeNode();
|
|
12897
|
-
// Technically, this is not correct as dynamic imports return a Promise.
|
|
12898
|
-
if (this.hasUnknownAccessedKey)
|
|
12899
|
-
return;
|
|
12900
|
-
if (path[0] === UnknownKey) {
|
|
12901
|
-
this.hasUnknownAccessedKey = true;
|
|
12902
|
-
}
|
|
12903
|
-
else if (typeof path[0] === 'string') {
|
|
12904
|
-
this.accessedPropKey.add(path[0]);
|
|
12307
|
+
if (!this.included) {
|
|
12308
|
+
this.included = true;
|
|
12309
|
+
this.scope.context.includeDynamicImport(this);
|
|
12310
|
+
this.scope.addAccessedDynamicImport(this);
|
|
12905
12311
|
}
|
|
12906
|
-
|
|
12907
|
-
this.scope.context.includeDynamicImport(this);
|
|
12312
|
+
this.source.include(context, includeChildrenRecursively);
|
|
12908
12313
|
}
|
|
12909
12314
|
initialise() {
|
|
12910
12315
|
super.initialise();
|
|
@@ -12974,6 +12379,7 @@ class ImportExpression extends NodeBase {
|
|
|
12974
12379
|
setInternalResolution(inlineNamespace) {
|
|
12975
12380
|
this.inlineNamespace = inlineNamespace;
|
|
12976
12381
|
}
|
|
12382
|
+
applyDeoptimizations() { }
|
|
12977
12383
|
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
12978
12384
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
12979
12385
|
{
|
|
@@ -13063,7 +12469,6 @@ class ImportExpression extends NodeBase {
|
|
|
13063
12469
|
return { helper: null, mechanism: null };
|
|
13064
12470
|
}
|
|
13065
12471
|
}
|
|
13066
|
-
ImportExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13067
12472
|
function getInteropHelper(resolution, exportMode, interop) {
|
|
13068
12473
|
return exportMode === 'external'
|
|
13069
12474
|
? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
|
|
@@ -13087,14 +12492,12 @@ function getDeterministicObjectDestructure(objectPattern) {
|
|
|
13087
12492
|
}
|
|
13088
12493
|
|
|
13089
12494
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
12495
|
+
applyDeoptimizations() { }
|
|
13090
12496
|
}
|
|
13091
|
-
ImportNamespaceSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13092
|
-
ImportNamespaceSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13093
12497
|
|
|
13094
12498
|
class ImportSpecifier extends NodeBase {
|
|
12499
|
+
applyDeoptimizations() { }
|
|
13095
12500
|
}
|
|
13096
|
-
ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13097
|
-
ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13098
12501
|
|
|
13099
12502
|
class JSXIdentifier extends IdentifierBase {
|
|
13100
12503
|
constructor() {
|
|
@@ -13111,29 +12514,6 @@ class JSXIdentifier extends IdentifierBase {
|
|
|
13111
12514
|
this.isNativeElement = true;
|
|
13112
12515
|
}
|
|
13113
12516
|
}
|
|
13114
|
-
include(context) {
|
|
13115
|
-
if (!this.included)
|
|
13116
|
-
this.includeNode(context);
|
|
13117
|
-
}
|
|
13118
|
-
includeNode(context) {
|
|
13119
|
-
this.included = true;
|
|
13120
|
-
if (!this.deoptimized)
|
|
13121
|
-
this.applyDeoptimizations();
|
|
13122
|
-
if (this.variable !== null) {
|
|
13123
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13124
|
-
}
|
|
13125
|
-
}
|
|
13126
|
-
includePath(path, context) {
|
|
13127
|
-
if (!this.included) {
|
|
13128
|
-
this.included = true;
|
|
13129
|
-
if (this.variable !== null) {
|
|
13130
|
-
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
13131
|
-
}
|
|
13132
|
-
}
|
|
13133
|
-
else if (path.length > 0) {
|
|
13134
|
-
this.variable?.includePath(path, context);
|
|
13135
|
-
}
|
|
13136
|
-
}
|
|
13137
12517
|
render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
|
|
13138
12518
|
if (this.variable) {
|
|
13139
12519
|
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
@@ -13195,7 +12575,6 @@ class JSXAttribute extends NodeBase {
|
|
|
13195
12575
|
}
|
|
13196
12576
|
}
|
|
13197
12577
|
}
|
|
13198
|
-
JSXAttribute.prototype.includeNode = onlyIncludeSelf;
|
|
13199
12578
|
|
|
13200
12579
|
class JSXClosingBase extends NodeBase {
|
|
13201
12580
|
render(code, options) {
|
|
@@ -13208,7 +12587,6 @@ class JSXClosingBase extends NodeBase {
|
|
|
13208
12587
|
}
|
|
13209
12588
|
}
|
|
13210
12589
|
}
|
|
13211
|
-
JSXClosingBase.prototype.includeNode = onlyIncludeSelf;
|
|
13212
12590
|
|
|
13213
12591
|
class JSXClosingElement extends JSXClosingBase {
|
|
13214
12592
|
}
|
|
@@ -13229,15 +12607,8 @@ class JSXSpreadAttribute extends NodeBase {
|
|
|
13229
12607
|
|
|
13230
12608
|
class JSXEmptyExpression extends NodeBase {
|
|
13231
12609
|
}
|
|
13232
|
-
JSXEmptyExpression.prototype.includeNode = onlyIncludeSelf;
|
|
13233
12610
|
|
|
13234
12611
|
class JSXExpressionContainer extends NodeBase {
|
|
13235
|
-
includeNode(context) {
|
|
13236
|
-
this.included = true;
|
|
13237
|
-
if (!this.deoptimized)
|
|
13238
|
-
this.applyDeoptimizations();
|
|
13239
|
-
this.expression.includePath(UNKNOWN_PATH, context);
|
|
13240
|
-
}
|
|
13241
12612
|
render(code, options) {
|
|
13242
12613
|
const { mode } = this.scope.context.options.jsx;
|
|
13243
12614
|
if (mode !== 'preserve') {
|
|
@@ -13258,7 +12629,7 @@ function getRenderedJsxChildren(children) {
|
|
|
13258
12629
|
return renderedChildren;
|
|
13259
12630
|
}
|
|
13260
12631
|
|
|
13261
|
-
function getAndIncludeFactoryVariable(factory, preserve, importSource, node
|
|
12632
|
+
function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
13262
12633
|
const [baseName, nestedName] = factory.split('.');
|
|
13263
12634
|
let factoryVariable;
|
|
13264
12635
|
if (importSource) {
|
|
@@ -13266,7 +12637,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
13266
12637
|
if (preserve) {
|
|
13267
12638
|
// This pretends we are accessing an included global variable of the same name
|
|
13268
12639
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
13269
|
-
globalVariable.
|
|
12640
|
+
globalVariable.include();
|
|
13270
12641
|
// This excludes this variable from renaming
|
|
13271
12642
|
factoryVariable.globalName = baseName;
|
|
13272
12643
|
}
|
|
@@ -13274,7 +12645,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
13274
12645
|
else {
|
|
13275
12646
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
13276
12647
|
}
|
|
13277
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
12648
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
13278
12649
|
if (factoryVariable instanceof LocalVariable) {
|
|
13279
12650
|
factoryVariable.consolidateInitializers();
|
|
13280
12651
|
factoryVariable.addUsedPlace(node);
|
|
@@ -13297,20 +12668,16 @@ class JSXElementBase extends NodeBase {
|
|
|
13297
12668
|
}
|
|
13298
12669
|
}
|
|
13299
12670
|
include(context, includeChildrenRecursively) {
|
|
13300
|
-
if (!this.included)
|
|
13301
|
-
this.
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13305
|
-
|
|
13306
|
-
includeNode(context) {
|
|
13307
|
-
this.included = true;
|
|
13308
|
-
const { factory, importSource, mode } = this.jsxMode;
|
|
13309
|
-
if (factory) {
|
|
13310
|
-
this.factory = factory;
|
|
13311
|
-
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this, context);
|
|
12671
|
+
if (!this.included) {
|
|
12672
|
+
const { factory, importSource, mode } = this.jsxMode;
|
|
12673
|
+
if (factory) {
|
|
12674
|
+
this.factory = factory;
|
|
12675
|
+
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
12676
|
+
}
|
|
13312
12677
|
}
|
|
12678
|
+
super.include(context, includeChildrenRecursively);
|
|
13313
12679
|
}
|
|
12680
|
+
applyDeoptimizations() { }
|
|
13314
12681
|
getRenderingMode() {
|
|
13315
12682
|
const jsx = this.scope.context.options.jsx;
|
|
13316
12683
|
const { mode, factory, importSource } = jsx;
|
|
@@ -13348,14 +12715,8 @@ class JSXElementBase extends NodeBase {
|
|
|
13348
12715
|
return { childrenEnd, firstChild, hasMultipleChildren };
|
|
13349
12716
|
}
|
|
13350
12717
|
}
|
|
13351
|
-
JSXElementBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13352
12718
|
|
|
13353
12719
|
class JSXElement extends JSXElementBase {
|
|
13354
|
-
include(context, includeChildrenRecursively) {
|
|
13355
|
-
super.include(context, includeChildrenRecursively);
|
|
13356
|
-
this.openingElement.include(context, includeChildrenRecursively);
|
|
13357
|
-
this.closingElement?.include(context, includeChildrenRecursively);
|
|
13358
|
-
}
|
|
13359
12720
|
render(code, options) {
|
|
13360
12721
|
switch (this.jsxMode.mode) {
|
|
13361
12722
|
case 'classic': {
|
|
@@ -13507,11 +12868,6 @@ class JSXElement extends JSXElementBase {
|
|
|
13507
12868
|
}
|
|
13508
12869
|
|
|
13509
12870
|
class JSXFragment extends JSXElementBase {
|
|
13510
|
-
include(context, includeChildrenRecursively) {
|
|
13511
|
-
super.include(context, includeChildrenRecursively);
|
|
13512
|
-
this.openingFragment.include(context, includeChildrenRecursively);
|
|
13513
|
-
this.closingFragment.include(context, includeChildrenRecursively);
|
|
13514
|
-
}
|
|
13515
12871
|
render(code, options) {
|
|
13516
12872
|
switch (this.jsxMode.mode) {
|
|
13517
12873
|
case 'classic': {
|
|
@@ -13561,22 +12917,10 @@ class JSXFragment extends JSXElementBase {
|
|
|
13561
12917
|
}
|
|
13562
12918
|
|
|
13563
12919
|
class JSXMemberExpression extends NodeBase {
|
|
13564
|
-
includeNode(context) {
|
|
13565
|
-
this.included = true;
|
|
13566
|
-
if (!this.deoptimized)
|
|
13567
|
-
this.applyDeoptimizations();
|
|
13568
|
-
this.object.includePath([this.property.name], context);
|
|
13569
|
-
}
|
|
13570
|
-
includePath(path, context) {
|
|
13571
|
-
if (!this.included)
|
|
13572
|
-
this.includeNode(context);
|
|
13573
|
-
this.object.includePath([this.property.name, ...path], context);
|
|
13574
|
-
}
|
|
13575
12920
|
}
|
|
13576
12921
|
|
|
13577
12922
|
class JSXNamespacedName extends NodeBase {
|
|
13578
12923
|
}
|
|
13579
|
-
JSXNamespacedName.prototype.includeNode = onlyIncludeSelf;
|
|
13580
12924
|
|
|
13581
12925
|
class JSXOpeningElement extends NodeBase {
|
|
13582
12926
|
render(code, options, { jsxMode = this.scope.context.options.jsx.mode } = {}) {
|
|
@@ -13586,7 +12930,6 @@ class JSXOpeningElement extends NodeBase {
|
|
|
13586
12930
|
}
|
|
13587
12931
|
}
|
|
13588
12932
|
}
|
|
13589
|
-
JSXOpeningElement.prototype.includeNode = onlyIncludeSelf;
|
|
13590
12933
|
|
|
13591
12934
|
class JSXOpeningFragment extends NodeBase {
|
|
13592
12935
|
constructor() {
|
|
@@ -13594,22 +12937,22 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13594
12937
|
this.fragment = null;
|
|
13595
12938
|
this.fragmentVariable = null;
|
|
13596
12939
|
}
|
|
13597
|
-
|
|
13598
|
-
this.included
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this, context);
|
|
12940
|
+
include(context, includeChildrenRecursively) {
|
|
12941
|
+
if (!this.included) {
|
|
12942
|
+
const jsx = this.scope.context.options.jsx;
|
|
12943
|
+
if (jsx.mode === 'automatic') {
|
|
12944
|
+
this.fragment = 'Fragment';
|
|
12945
|
+
this.fragmentVariable = getAndIncludeFactoryVariable('Fragment', false, jsx.jsxImportSource, this);
|
|
12946
|
+
}
|
|
12947
|
+
else {
|
|
12948
|
+
const { fragment, importSource, mode } = jsx;
|
|
12949
|
+
if (fragment != null) {
|
|
12950
|
+
this.fragment = fragment;
|
|
12951
|
+
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this);
|
|
12952
|
+
}
|
|
13611
12953
|
}
|
|
13612
12954
|
}
|
|
12955
|
+
super.include(context, includeChildrenRecursively);
|
|
13613
12956
|
}
|
|
13614
12957
|
render(code, options) {
|
|
13615
12958
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -13646,7 +12989,6 @@ class JSXText extends NodeBase {
|
|
|
13646
12989
|
}
|
|
13647
12990
|
}
|
|
13648
12991
|
}
|
|
13649
|
-
JSXText.prototype.includeNode = onlyIncludeSelf;
|
|
13650
12992
|
|
|
13651
12993
|
class LabeledStatement extends NodeBase {
|
|
13652
12994
|
hasEffects(context) {
|
|
@@ -13668,22 +13010,17 @@ class LabeledStatement extends NodeBase {
|
|
|
13668
13010
|
return bodyHasEffects;
|
|
13669
13011
|
}
|
|
13670
13012
|
include(context, includeChildrenRecursively) {
|
|
13671
|
-
|
|
13672
|
-
this.includeNode(context);
|
|
13013
|
+
this.included = true;
|
|
13673
13014
|
const { brokenFlow, includedLabels } = context;
|
|
13674
13015
|
context.includedLabels = new Set();
|
|
13675
13016
|
this.body.include(context, includeChildrenRecursively);
|
|
13676
13017
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13677
|
-
this.label.include(
|
|
13018
|
+
this.label.include();
|
|
13678
13019
|
context.includedLabels.delete(this.label.name);
|
|
13679
13020
|
context.brokenFlow = brokenFlow;
|
|
13680
13021
|
}
|
|
13681
13022
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13682
13023
|
}
|
|
13683
|
-
includeNode(context) {
|
|
13684
|
-
this.included = true;
|
|
13685
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
13686
|
-
}
|
|
13687
13024
|
render(code, options) {
|
|
13688
13025
|
if (this.label.included) {
|
|
13689
13026
|
this.label.render(code, options);
|
|
@@ -13694,7 +13031,6 @@ class LabeledStatement extends NodeBase {
|
|
|
13694
13031
|
this.body.render(code, options);
|
|
13695
13032
|
}
|
|
13696
13033
|
}
|
|
13697
|
-
LabeledStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13698
13034
|
|
|
13699
13035
|
class LogicalExpression extends NodeBase {
|
|
13700
13036
|
constructor() {
|
|
@@ -13711,10 +13047,10 @@ class LogicalExpression extends NodeBase {
|
|
|
13711
13047
|
this.flags = setFlag(this.flags, 65536 /* Flag.isBranchResolutionAnalysed */, value);
|
|
13712
13048
|
}
|
|
13713
13049
|
get hasDeoptimizedCache() {
|
|
13714
|
-
return isFlagSet(this.flags,
|
|
13050
|
+
return isFlagSet(this.flags, 16777216 /* Flag.hasDeoptimizedCache */);
|
|
13715
13051
|
}
|
|
13716
13052
|
set hasDeoptimizedCache(value) {
|
|
13717
|
-
this.flags = setFlag(this.flags,
|
|
13053
|
+
this.flags = setFlag(this.flags, 16777216 /* Flag.hasDeoptimizedCache */, value);
|
|
13718
13054
|
}
|
|
13719
13055
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13720
13056
|
this.left.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13727,10 +13063,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13727
13063
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
13728
13064
|
this.usedBranch = null;
|
|
13729
13065
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
13730
|
-
if (this.included) {
|
|
13731
|
-
// As we are not tracking inclusions, we just include everything
|
|
13732
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
13733
|
-
}
|
|
13734
13066
|
}
|
|
13735
13067
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
13736
13068
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
@@ -13776,17 +13108,16 @@ class LogicalExpression extends NodeBase {
|
|
|
13776
13108
|
}
|
|
13777
13109
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
13778
13110
|
const usedBranch = this.getUsedBranch();
|
|
13779
|
-
if (usedBranch)
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
];
|
|
13111
|
+
if (!usedBranch)
|
|
13112
|
+
return [
|
|
13113
|
+
new MultiExpression([
|
|
13114
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0],
|
|
13115
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0]
|
|
13116
|
+
]),
|
|
13117
|
+
false
|
|
13118
|
+
];
|
|
13119
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
13120
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
13790
13121
|
}
|
|
13791
13122
|
hasEffects(context) {
|
|
13792
13123
|
if (this.left.hasEffects(context)) {
|
|
@@ -13799,18 +13130,18 @@ class LogicalExpression extends NodeBase {
|
|
|
13799
13130
|
}
|
|
13800
13131
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13801
13132
|
const usedBranch = this.getUsedBranch();
|
|
13802
|
-
if (usedBranch) {
|
|
13803
|
-
return
|
|
13133
|
+
if (!usedBranch) {
|
|
13134
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
13135
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13804
13136
|
}
|
|
13805
|
-
return
|
|
13806
|
-
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
13137
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13807
13138
|
}
|
|
13808
13139
|
include(context, includeChildrenRecursively) {
|
|
13809
13140
|
this.included = true;
|
|
13810
13141
|
const usedBranch = this.getUsedBranch();
|
|
13811
13142
|
if (includeChildrenRecursively ||
|
|
13812
|
-
|
|
13813
|
-
|
|
13143
|
+
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
13144
|
+
!usedBranch) {
|
|
13814
13145
|
this.left.include(context, includeChildrenRecursively);
|
|
13815
13146
|
this.right.include(context, includeChildrenRecursively);
|
|
13816
13147
|
}
|
|
@@ -13818,17 +13149,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13818
13149
|
usedBranch.include(context, includeChildrenRecursively);
|
|
13819
13150
|
}
|
|
13820
13151
|
}
|
|
13821
|
-
includePath(path, context) {
|
|
13822
|
-
this.included = true;
|
|
13823
|
-
const usedBranch = this.getUsedBranch();
|
|
13824
|
-
if (!usedBranch || (usedBranch === this.right && this.left.shouldBeIncluded(context))) {
|
|
13825
|
-
this.left.includePath(path, context);
|
|
13826
|
-
this.right.includePath(path, context);
|
|
13827
|
-
}
|
|
13828
|
-
else {
|
|
13829
|
-
usedBranch.includePath(path, context);
|
|
13830
|
-
}
|
|
13831
|
-
}
|
|
13832
13152
|
removeAnnotations(code) {
|
|
13833
13153
|
this.left.removeAnnotations(code);
|
|
13834
13154
|
}
|
|
@@ -13881,8 +13201,6 @@ class LogicalExpression extends NodeBase {
|
|
|
13881
13201
|
return this.usedBranch;
|
|
13882
13202
|
}
|
|
13883
13203
|
}
|
|
13884
|
-
LogicalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13885
|
-
LogicalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13886
13204
|
|
|
13887
13205
|
class NewExpression extends NodeBase {
|
|
13888
13206
|
hasEffects(context) {
|
|
@@ -13902,21 +13220,16 @@ class NewExpression extends NodeBase {
|
|
|
13902
13220
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13903
13221
|
}
|
|
13904
13222
|
include(context, includeChildrenRecursively) {
|
|
13223
|
+
if (!this.deoptimized)
|
|
13224
|
+
this.applyDeoptimizations();
|
|
13905
13225
|
if (includeChildrenRecursively) {
|
|
13906
13226
|
super.include(context, includeChildrenRecursively);
|
|
13907
13227
|
}
|
|
13908
13228
|
else {
|
|
13909
|
-
|
|
13910
|
-
this.includeNode(context);
|
|
13229
|
+
this.included = true;
|
|
13911
13230
|
this.callee.include(context, false);
|
|
13912
13231
|
}
|
|
13913
|
-
this.callee.includeCallArguments(context, this.
|
|
13914
|
-
}
|
|
13915
|
-
includeNode(context) {
|
|
13916
|
-
this.included = true;
|
|
13917
|
-
if (!this.deoptimized)
|
|
13918
|
-
this.applyDeoptimizations();
|
|
13919
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
13232
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13920
13233
|
}
|
|
13921
13234
|
initialise() {
|
|
13922
13235
|
super.initialise();
|
|
@@ -13945,7 +13258,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13945
13258
|
constructor() {
|
|
13946
13259
|
super(...arguments);
|
|
13947
13260
|
this.objectEntity = null;
|
|
13948
|
-
this.protoProp = null;
|
|
13949
13261
|
}
|
|
13950
13262
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13951
13263
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13965,43 +13277,15 @@ class ObjectExpression extends NodeBase {
|
|
|
13965
13277
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13966
13278
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13967
13279
|
}
|
|
13968
|
-
include(context, includeChildrenRecursively) {
|
|
13969
|
-
if (!this.included)
|
|
13970
|
-
this.includeNode(context);
|
|
13971
|
-
this.getObjectEntity().include(context, includeChildrenRecursively);
|
|
13972
|
-
this.protoProp?.include(context, includeChildrenRecursively);
|
|
13973
|
-
}
|
|
13974
|
-
includeNode(context) {
|
|
13975
|
-
this.included = true;
|
|
13976
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context);
|
|
13977
|
-
}
|
|
13978
|
-
includePath(path, context) {
|
|
13979
|
-
if (!this.included)
|
|
13980
|
-
this.includeNode(context);
|
|
13981
|
-
this.getObjectEntity().includePath(path, context);
|
|
13982
|
-
}
|
|
13983
13280
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13281
|
+
super.render(code, options);
|
|
13984
13282
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13985
13283
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13986
13284
|
code.appendRight(this.start, '(');
|
|
13987
13285
|
code.prependLeft(this.end, ')');
|
|
13988
13286
|
}
|
|
13989
|
-
if (this.properties.length > 0) {
|
|
13990
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13991
|
-
let lastSeparatorPos = null;
|
|
13992
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
13993
|
-
if (!node.included) {
|
|
13994
|
-
treeshakeNode(node, code, start, end);
|
|
13995
|
-
continue;
|
|
13996
|
-
}
|
|
13997
|
-
lastSeparatorPos = separator;
|
|
13998
|
-
node.render(code, options);
|
|
13999
|
-
}
|
|
14000
|
-
if (lastSeparatorPos) {
|
|
14001
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
14002
|
-
}
|
|
14003
|
-
}
|
|
14004
13287
|
}
|
|
13288
|
+
applyDeoptimizations() { }
|
|
14005
13289
|
getObjectEntity() {
|
|
14006
13290
|
if (this.objectEntity !== null) {
|
|
14007
13291
|
return this.objectEntity;
|
|
@@ -14030,7 +13314,6 @@ class ObjectExpression extends NodeBase {
|
|
|
14030
13314
|
? property.key.name
|
|
14031
13315
|
: String(property.key.value);
|
|
14032
13316
|
if (key === '__proto__' && property.kind === 'init') {
|
|
14033
|
-
this.protoProp = property;
|
|
14034
13317
|
prototype =
|
|
14035
13318
|
property.value instanceof Literal && property.value.value === null
|
|
14036
13319
|
? null
|
|
@@ -14043,7 +13326,6 @@ class ObjectExpression extends NodeBase {
|
|
|
14043
13326
|
return (this.objectEntity = new ObjectEntity(properties, prototype));
|
|
14044
13327
|
}
|
|
14045
13328
|
}
|
|
14046
|
-
ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14047
13329
|
|
|
14048
13330
|
class PanicError extends NodeBase {
|
|
14049
13331
|
initialise() {
|
|
@@ -14070,7 +13352,6 @@ class ParseError extends NodeBase {
|
|
|
14070
13352
|
|
|
14071
13353
|
class PrivateIdentifier extends NodeBase {
|
|
14072
13354
|
}
|
|
14073
|
-
PrivateIdentifier.prototype.includeNode = onlyIncludeSelf;
|
|
14074
13355
|
|
|
14075
13356
|
class Program extends NodeBase {
|
|
14076
13357
|
constructor() {
|
|
@@ -14138,11 +13419,14 @@ class Program extends NodeBase {
|
|
|
14138
13419
|
super.render(code, options);
|
|
14139
13420
|
}
|
|
14140
13421
|
}
|
|
13422
|
+
applyDeoptimizations() { }
|
|
14141
13423
|
}
|
|
14142
|
-
Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14143
|
-
Program.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14144
13424
|
|
|
14145
13425
|
class Property extends MethodBase {
|
|
13426
|
+
constructor() {
|
|
13427
|
+
super(...arguments);
|
|
13428
|
+
this.declarationInit = null;
|
|
13429
|
+
}
|
|
14146
13430
|
//declare method: boolean;
|
|
14147
13431
|
get method() {
|
|
14148
13432
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -14157,41 +13441,17 @@ class Property extends MethodBase {
|
|
|
14157
13441
|
set shorthand(value) {
|
|
14158
13442
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
14159
13443
|
}
|
|
14160
|
-
declare(kind,
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
14164
|
-
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
13444
|
+
declare(kind, init) {
|
|
13445
|
+
this.declarationInit = init;
|
|
13446
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
14165
13447
|
}
|
|
14166
13448
|
hasEffects(context) {
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
return this.
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
const path = this.getPathInProperty(destructuredInitPath);
|
|
14174
|
-
let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
|
|
14175
|
-
this.included;
|
|
14176
|
-
if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
|
|
14177
|
-
this.key.include(context, false);
|
|
14178
|
-
if (!this.value.included) {
|
|
14179
|
-
this.value.included = true;
|
|
14180
|
-
// Unfortunately, we need to include the value again now, so that any
|
|
14181
|
-
// declared variables are properly included.
|
|
14182
|
-
this.value.includeDestructuredIfNecessary(context, path, init);
|
|
14183
|
-
}
|
|
14184
|
-
}
|
|
14185
|
-
return (this.included = included);
|
|
14186
|
-
}
|
|
14187
|
-
include(context, includeChildrenRecursively) {
|
|
14188
|
-
this.included = true;
|
|
14189
|
-
this.key.include(context, includeChildrenRecursively);
|
|
14190
|
-
this.value.include(context, includeChildrenRecursively);
|
|
14191
|
-
}
|
|
14192
|
-
includePath(path, context) {
|
|
14193
|
-
this.included = true;
|
|
14194
|
-
this.value.includePath(path, context);
|
|
13449
|
+
if (!this.deoptimized)
|
|
13450
|
+
this.applyDeoptimizations();
|
|
13451
|
+
const propertyReadSideEffects = this.scope.context.options.treeshake.propertyReadSideEffects;
|
|
13452
|
+
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
13453
|
+
this.key.hasEffects(context) ||
|
|
13454
|
+
this.value.hasEffects(context));
|
|
14195
13455
|
}
|
|
14196
13456
|
markDeclarationReached() {
|
|
14197
13457
|
this.value.markDeclarationReached();
|
|
@@ -14202,20 +13462,14 @@ class Property extends MethodBase {
|
|
|
14202
13462
|
}
|
|
14203
13463
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
14204
13464
|
}
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
? [...destructuredInitPath, UnknownKey]
|
|
14212
|
-
: this.key instanceof Identifier
|
|
14213
|
-
? [...destructuredInitPath, this.key.name]
|
|
14214
|
-
: [...destructuredInitPath, String(this.key.value)];
|
|
13465
|
+
applyDeoptimizations() {
|
|
13466
|
+
this.deoptimized = true;
|
|
13467
|
+
if (this.declarationInit !== null) {
|
|
13468
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
13469
|
+
this.scope.context.requestTreeshakingPass();
|
|
13470
|
+
}
|
|
14215
13471
|
}
|
|
14216
13472
|
}
|
|
14217
|
-
Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14218
|
-
Property.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14219
13473
|
|
|
14220
13474
|
class PropertyDefinition extends NodeBase {
|
|
14221
13475
|
get computed() {
|
|
@@ -14248,15 +13502,8 @@ class PropertyDefinition extends NodeBase {
|
|
|
14248
13502
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
14249
13503
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14250
13504
|
}
|
|
14251
|
-
|
|
14252
|
-
this.included = true;
|
|
14253
|
-
this.value?.includePath(UNKNOWN_PATH, context);
|
|
14254
|
-
for (const decorator of this.decorators) {
|
|
14255
|
-
decorator.includePath(UNKNOWN_PATH, context);
|
|
14256
|
-
}
|
|
14257
|
-
}
|
|
13505
|
+
applyDeoptimizations() { }
|
|
14258
13506
|
}
|
|
14259
|
-
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14260
13507
|
|
|
14261
13508
|
class ReturnStatement extends NodeBase {
|
|
14262
13509
|
hasEffects(context) {
|
|
@@ -14266,15 +13513,10 @@ class ReturnStatement extends NodeBase {
|
|
|
14266
13513
|
return false;
|
|
14267
13514
|
}
|
|
14268
13515
|
include(context, includeChildrenRecursively) {
|
|
14269
|
-
|
|
14270
|
-
this.includeNode(context);
|
|
13516
|
+
this.included = true;
|
|
14271
13517
|
this.argument?.include(context, includeChildrenRecursively);
|
|
14272
13518
|
context.brokenFlow = true;
|
|
14273
13519
|
}
|
|
14274
|
-
includeNode(context) {
|
|
14275
|
-
this.included = true;
|
|
14276
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
14277
|
-
}
|
|
14278
13520
|
initialise() {
|
|
14279
13521
|
super.initialise();
|
|
14280
13522
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -14288,7 +13530,6 @@ class ReturnStatement extends NodeBase {
|
|
|
14288
13530
|
}
|
|
14289
13531
|
}
|
|
14290
13532
|
}
|
|
14291
|
-
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14292
13533
|
|
|
14293
13534
|
class SequenceExpression extends NodeBase {
|
|
14294
13535
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -14316,15 +13557,10 @@ class SequenceExpression extends NodeBase {
|
|
|
14316
13557
|
for (const expression of this.expressions) {
|
|
14317
13558
|
if (includeChildrenRecursively ||
|
|
14318
13559
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
14319
|
-
expression.shouldBeIncluded(context))
|
|
13560
|
+
expression.shouldBeIncluded(context))
|
|
14320
13561
|
expression.include(context, includeChildrenRecursively);
|
|
14321
|
-
}
|
|
14322
13562
|
}
|
|
14323
13563
|
}
|
|
14324
|
-
includePath(path, context) {
|
|
14325
|
-
this.included = true;
|
|
14326
|
-
this.expressions[this.expressions.length - 1].includePath(path, context);
|
|
14327
|
-
}
|
|
14328
13564
|
removeAnnotations(code) {
|
|
14329
13565
|
this.expressions[0].removeAnnotations(code);
|
|
14330
13566
|
}
|
|
@@ -14359,8 +13595,6 @@ class SequenceExpression extends NodeBase {
|
|
|
14359
13595
|
}
|
|
14360
13596
|
}
|
|
14361
13597
|
}
|
|
14362
|
-
SequenceExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14363
|
-
SequenceExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14364
13598
|
|
|
14365
13599
|
class Super extends NodeBase {
|
|
14366
13600
|
bind() {
|
|
@@ -14372,15 +13606,11 @@ class Super extends NodeBase {
|
|
|
14372
13606
|
deoptimizePath(path) {
|
|
14373
13607
|
this.variable.deoptimizePath(path);
|
|
14374
13608
|
}
|
|
14375
|
-
include(
|
|
14376
|
-
if (!this.included)
|
|
14377
|
-
this.
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
this.included = true;
|
|
14381
|
-
if (!this.deoptimized)
|
|
14382
|
-
this.applyDeoptimizations();
|
|
14383
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
13609
|
+
include() {
|
|
13610
|
+
if (!this.included) {
|
|
13611
|
+
this.included = true;
|
|
13612
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13613
|
+
}
|
|
14384
13614
|
}
|
|
14385
13615
|
}
|
|
14386
13616
|
|
|
@@ -14421,8 +13651,6 @@ class SwitchCase extends NodeBase {
|
|
|
14421
13651
|
}
|
|
14422
13652
|
}
|
|
14423
13653
|
SwitchCase.prototype.needsBoundaries = true;
|
|
14424
|
-
SwitchCase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14425
|
-
SwitchCase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14426
13654
|
|
|
14427
13655
|
class SwitchStatement extends NodeBase {
|
|
14428
13656
|
createScope(parentScope) {
|
|
@@ -14505,8 +13733,6 @@ class SwitchStatement extends NodeBase {
|
|
|
14505
13733
|
}
|
|
14506
13734
|
}
|
|
14507
13735
|
}
|
|
14508
|
-
SwitchStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14509
|
-
SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14510
13736
|
|
|
14511
13737
|
class TaggedTemplateExpression extends CallExpressionBase {
|
|
14512
13738
|
bind() {
|
|
@@ -14530,8 +13756,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14530
13756
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
14531
13757
|
}
|
|
14532
13758
|
include(context, includeChildrenRecursively) {
|
|
14533
|
-
if (!this.
|
|
14534
|
-
this.
|
|
13759
|
+
if (!this.deoptimized)
|
|
13760
|
+
this.applyDeoptimizations();
|
|
14535
13761
|
if (includeChildrenRecursively) {
|
|
14536
13762
|
super.include(context, includeChildrenRecursively);
|
|
14537
13763
|
}
|
|
@@ -14540,7 +13766,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14540
13766
|
this.tag.include(context, includeChildrenRecursively);
|
|
14541
13767
|
this.quasi.include(context, includeChildrenRecursively);
|
|
14542
13768
|
}
|
|
14543
|
-
this.tag.includeCallArguments(context, this.
|
|
13769
|
+
this.tag.includeCallArguments(context, this.args);
|
|
14544
13770
|
const [returnExpression] = this.getReturnExpression();
|
|
14545
13771
|
if (!returnExpression.included) {
|
|
14546
13772
|
returnExpression.include(context, false);
|
|
@@ -14575,7 +13801,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14575
13801
|
return this.returnExpression;
|
|
14576
13802
|
}
|
|
14577
13803
|
}
|
|
14578
|
-
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14579
13804
|
|
|
14580
13805
|
class TemplateElement extends NodeBase {
|
|
14581
13806
|
get tail() {
|
|
@@ -14589,13 +13814,15 @@ class TemplateElement extends NodeBase {
|
|
|
14589
13814
|
hasEffects() {
|
|
14590
13815
|
return false;
|
|
14591
13816
|
}
|
|
13817
|
+
include() {
|
|
13818
|
+
this.included = true;
|
|
13819
|
+
}
|
|
14592
13820
|
parseNode(esTreeNode) {
|
|
14593
13821
|
this.value = esTreeNode.value;
|
|
14594
13822
|
return super.parseNode(esTreeNode);
|
|
14595
13823
|
}
|
|
14596
13824
|
render() { }
|
|
14597
13825
|
}
|
|
14598
|
-
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
14599
13826
|
|
|
14600
13827
|
class TemplateLiteral extends NodeBase {
|
|
14601
13828
|
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
@@ -14620,14 +13847,6 @@ class TemplateLiteral extends NodeBase {
|
|
|
14620
13847
|
}
|
|
14621
13848
|
return true;
|
|
14622
13849
|
}
|
|
14623
|
-
includeNode(context) {
|
|
14624
|
-
this.included = true;
|
|
14625
|
-
if (!this.deoptimized)
|
|
14626
|
-
this.applyDeoptimizations();
|
|
14627
|
-
for (const node of this.expressions) {
|
|
14628
|
-
node.includePath(UNKNOWN_PATH, context);
|
|
14629
|
-
}
|
|
14630
|
-
}
|
|
14631
13850
|
render(code, options) {
|
|
14632
13851
|
code.indentExclusionRanges.push([this.start, this.end]);
|
|
14633
13852
|
super.render(code, options);
|
|
@@ -14637,13 +13856,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
14637
13856
|
class ModuleScope extends ChildScope {
|
|
14638
13857
|
constructor(parent, context) {
|
|
14639
13858
|
super(parent, context);
|
|
14640
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
13859
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
14641
13860
|
}
|
|
14642
|
-
addDeclaration(identifier, context, init,
|
|
13861
|
+
addDeclaration(identifier, context, init, kind) {
|
|
14643
13862
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
14644
13863
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
14645
13864
|
}
|
|
14646
|
-
return super.addDeclaration(identifier, context, init,
|
|
13865
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
14647
13866
|
}
|
|
14648
13867
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
14649
13868
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -14688,23 +13907,10 @@ class ThisExpression extends NodeBase {
|
|
|
14688
13907
|
}
|
|
14689
13908
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14690
13909
|
}
|
|
14691
|
-
include(
|
|
14692
|
-
if (!this.included)
|
|
14693
|
-
this.includeNode(context);
|
|
14694
|
-
}
|
|
14695
|
-
includeNode(context) {
|
|
14696
|
-
this.included = true;
|
|
14697
|
-
if (!this.deoptimized)
|
|
14698
|
-
this.applyDeoptimizations();
|
|
14699
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
14700
|
-
}
|
|
14701
|
-
includePath(path, context) {
|
|
13910
|
+
include() {
|
|
14702
13911
|
if (!this.included) {
|
|
14703
13912
|
this.included = true;
|
|
14704
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
14705
|
-
}
|
|
14706
|
-
else if (path.length > 0) {
|
|
14707
|
-
this.variable.includePath(path, context);
|
|
13913
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
14708
13914
|
}
|
|
14709
13915
|
}
|
|
14710
13916
|
initialise() {
|
|
@@ -14732,8 +13938,7 @@ class ThrowStatement extends NodeBase {
|
|
|
14732
13938
|
return true;
|
|
14733
13939
|
}
|
|
14734
13940
|
include(context, includeChildrenRecursively) {
|
|
14735
|
-
|
|
14736
|
-
this.includeNode(context);
|
|
13941
|
+
this.included = true;
|
|
14737
13942
|
this.argument.include(context, includeChildrenRecursively);
|
|
14738
13943
|
context.brokenFlow = true;
|
|
14739
13944
|
}
|
|
@@ -14744,7 +13949,6 @@ class ThrowStatement extends NodeBase {
|
|
|
14744
13949
|
}
|
|
14745
13950
|
}
|
|
14746
13951
|
}
|
|
14747
|
-
ThrowStatement.prototype.includeNode = onlyIncludeSelf;
|
|
14748
13952
|
|
|
14749
13953
|
class TryStatement extends NodeBase {
|
|
14750
13954
|
constructor() {
|
|
@@ -14781,8 +13985,6 @@ class TryStatement extends NodeBase {
|
|
|
14781
13985
|
this.finalizer?.include(context, includeChildrenRecursively);
|
|
14782
13986
|
}
|
|
14783
13987
|
}
|
|
14784
|
-
TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14785
|
-
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14786
13988
|
|
|
14787
13989
|
const unaryOperators = {
|
|
14788
13990
|
'!': value => !value,
|
|
@@ -14889,7 +14091,6 @@ function getSimplifiedNumber(value) {
|
|
|
14889
14091
|
const stringifiedValue = String(value).replace('+', '');
|
|
14890
14092
|
return finalizedExp.length < stringifiedValue.length ? finalizedExp : stringifiedValue;
|
|
14891
14093
|
}
|
|
14892
|
-
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14893
14094
|
|
|
14894
14095
|
class UpdateExpression extends NodeBase {
|
|
14895
14096
|
hasEffects(context) {
|
|
@@ -14901,8 +14102,9 @@ class UpdateExpression extends NodeBase {
|
|
|
14901
14102
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14902
14103
|
}
|
|
14903
14104
|
include(context, includeChildrenRecursively) {
|
|
14904
|
-
if (!this.
|
|
14905
|
-
this.
|
|
14105
|
+
if (!this.deoptimized)
|
|
14106
|
+
this.applyDeoptimizations();
|
|
14107
|
+
this.included = true;
|
|
14906
14108
|
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
14907
14109
|
}
|
|
14908
14110
|
initialise() {
|
|
@@ -14941,7 +14143,6 @@ class UpdateExpression extends NodeBase {
|
|
|
14941
14143
|
this.scope.context.requestTreeshakingPass();
|
|
14942
14144
|
}
|
|
14943
14145
|
}
|
|
14944
|
-
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14945
14146
|
|
|
14946
14147
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
14947
14148
|
for (const declarator of declarations) {
|
|
@@ -14972,9 +14173,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14972
14173
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14973
14174
|
this.included = true;
|
|
14974
14175
|
for (const declarator of this.declarations) {
|
|
14975
|
-
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14176
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14976
14177
|
declarator.include(context, includeChildrenRecursively);
|
|
14977
|
-
}
|
|
14978
14178
|
const { id, init } = declarator;
|
|
14979
14179
|
if (asSingleStatement) {
|
|
14980
14180
|
id.include(context, includeChildrenRecursively);
|
|
@@ -15012,6 +14212,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
15012
14212
|
this.renderReplacedDeclarations(code, options);
|
|
15013
14213
|
}
|
|
15014
14214
|
}
|
|
14215
|
+
applyDeoptimizations() { }
|
|
15015
14216
|
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
15016
14217
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
15017
14218
|
code.remove(this.end - 1, this.end);
|
|
@@ -15054,7 +14255,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
15054
14255
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
15055
14256
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
15056
14257
|
if (!node.included) {
|
|
15057
|
-
|
|
14258
|
+
code.remove(start, end);
|
|
14259
|
+
node.removeAnnotations(code);
|
|
15058
14260
|
continue;
|
|
15059
14261
|
}
|
|
15060
14262
|
node.render(code, options);
|
|
@@ -15124,8 +14326,6 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
15124
14326
|
}
|
|
15125
14327
|
return singleSystemExport;
|
|
15126
14328
|
}
|
|
15127
|
-
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15128
|
-
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15129
14329
|
|
|
15130
14330
|
class WhileStatement extends NodeBase {
|
|
15131
14331
|
hasEffects(context) {
|
|
@@ -15139,25 +14339,13 @@ class WhileStatement extends NodeBase {
|
|
|
15139
14339
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
15140
14340
|
}
|
|
15141
14341
|
}
|
|
15142
|
-
WhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15143
|
-
WhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15144
14342
|
|
|
15145
14343
|
class YieldExpression extends NodeBase {
|
|
15146
|
-
applyDeoptimizations() {
|
|
15147
|
-
this.deoptimized = true;
|
|
15148
|
-
this.argument?.deoptimizePath(UNKNOWN_PATH);
|
|
15149
|
-
}
|
|
15150
14344
|
hasEffects(context) {
|
|
15151
14345
|
if (!this.deoptimized)
|
|
15152
14346
|
this.applyDeoptimizations();
|
|
15153
14347
|
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
15154
14348
|
}
|
|
15155
|
-
includeNode(context) {
|
|
15156
|
-
this.included = true;
|
|
15157
|
-
if (!this.deoptimized)
|
|
15158
|
-
this.applyDeoptimizations();
|
|
15159
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
15160
|
-
}
|
|
15161
14349
|
render(code, options) {
|
|
15162
14350
|
if (this.argument) {
|
|
15163
14351
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -15391,7 +14579,7 @@ const bufferParsers = [
|
|
|
15391
14579
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
15392
14580
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
15393
14581
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
15394
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14582
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15395
14583
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
15396
14584
|
},
|
|
15397
14585
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -15437,7 +14625,7 @@ const bufferParsers = [
|
|
|
15437
14625
|
const parameterPosition = buffer[position];
|
|
15438
14626
|
const parameter = (node.param =
|
|
15439
14627
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
15440
|
-
parameter?.declare('parameter',
|
|
14628
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
15441
14629
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
15442
14630
|
},
|
|
15443
14631
|
function chainExpression(node, position, buffer) {
|
|
@@ -15575,7 +14763,7 @@ const bufferParsers = [
|
|
|
15575
14763
|
node.id =
|
|
15576
14764
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
15577
14765
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15578
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14766
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15579
14767
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15580
14768
|
},
|
|
15581
14769
|
function functionExpression(node, position, buffer) {
|
|
@@ -15588,7 +14776,7 @@ const bufferParsers = [
|
|
|
15588
14776
|
const idPosition = buffer[position + 2];
|
|
15589
14777
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
15590
14778
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15591
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14779
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15592
14780
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15593
14781
|
},
|
|
15594
14782
|
function identifier(node, position, buffer) {
|
|
@@ -16052,8 +15240,8 @@ class ExportShimVariable extends Variable {
|
|
|
16052
15240
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
16053
15241
|
this.module = module;
|
|
16054
15242
|
}
|
|
16055
|
-
|
|
16056
|
-
super.
|
|
15243
|
+
include() {
|
|
15244
|
+
super.include();
|
|
16057
15245
|
this.module.needsExportShim = true;
|
|
16058
15246
|
}
|
|
16059
15247
|
}
|
|
@@ -16751,15 +15939,16 @@ class Module {
|
|
|
16751
15939
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
16752
15940
|
this.graph.needsTreeshakingPass = true;
|
|
16753
15941
|
}
|
|
16754
|
-
const inclusionContext = createInclusionContext();
|
|
16755
15942
|
for (const exportName of this.exports.keys()) {
|
|
16756
15943
|
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
16757
15944
|
const variable = this.getVariableForExportName(exportName)[0];
|
|
16758
15945
|
if (!variable) {
|
|
16759
15946
|
return error(logMissingEntryExport(exportName, this.id));
|
|
16760
15947
|
}
|
|
16761
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
16762
15948
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
15949
|
+
if (!variable.included) {
|
|
15950
|
+
this.includeVariable(variable);
|
|
15951
|
+
}
|
|
16763
15952
|
}
|
|
16764
15953
|
}
|
|
16765
15954
|
for (const name of this.getReexports()) {
|
|
@@ -16767,7 +15956,7 @@ class Module {
|
|
|
16767
15956
|
if (variable) {
|
|
16768
15957
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16769
15958
|
if (!variable.included) {
|
|
16770
|
-
this.includeVariable(variable
|
|
15959
|
+
this.includeVariable(variable);
|
|
16771
15960
|
}
|
|
16772
15961
|
if (variable instanceof ExternalVariable) {
|
|
16773
15962
|
variable.module.reexported = true;
|
|
@@ -16788,12 +15977,13 @@ class Module {
|
|
|
16788
15977
|
this.graph.needsTreeshakingPass = true;
|
|
16789
15978
|
}
|
|
16790
15979
|
let includeNamespaceMembers = false;
|
|
16791
|
-
const inclusionContext = createInclusionContext();
|
|
16792
15980
|
for (const name of names) {
|
|
16793
15981
|
const variable = this.getVariableForExportName(name)[0];
|
|
16794
15982
|
if (variable) {
|
|
16795
15983
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16796
|
-
|
|
15984
|
+
if (!variable.included) {
|
|
15985
|
+
this.includeVariable(variable);
|
|
15986
|
+
}
|
|
16797
15987
|
}
|
|
16798
15988
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
16799
15989
|
includeNamespaceMembers = true;
|
|
@@ -16894,7 +16084,6 @@ class Module {
|
|
|
16894
16084
|
manualPureFunctions: this.graph.pureFunctions,
|
|
16895
16085
|
module: this,
|
|
16896
16086
|
moduleContext: this.context,
|
|
16897
|
-
newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
|
|
16898
16087
|
options: this.options,
|
|
16899
16088
|
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
|
|
16900
16089
|
traceExport: (name) => this.getVariableForExportName(name)[0],
|
|
@@ -17235,13 +16424,13 @@ class Module {
|
|
|
17235
16424
|
for (const module of [this, ...this.exportAllModules]) {
|
|
17236
16425
|
if (module instanceof ExternalModule) {
|
|
17237
16426
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
17238
|
-
externalVariable.
|
|
16427
|
+
externalVariable.include();
|
|
17239
16428
|
this.includedImports.add(externalVariable);
|
|
17240
16429
|
externalNamespaces.add(externalVariable);
|
|
17241
16430
|
}
|
|
17242
16431
|
else if (module.info.syntheticNamedExports) {
|
|
17243
16432
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
17244
|
-
syntheticNamespace.
|
|
16433
|
+
syntheticNamespace.include();
|
|
17245
16434
|
this.includedImports.add(syntheticNamespace);
|
|
17246
16435
|
syntheticNamespaces.add(syntheticNamespace);
|
|
17247
16436
|
}
|
|
@@ -17251,9 +16440,7 @@ class Module {
|
|
|
17251
16440
|
includeDynamicImport(node) {
|
|
17252
16441
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
17253
16442
|
if (resolution instanceof Module) {
|
|
17254
|
-
|
|
17255
|
-
resolution.includedDynamicImporters.push(this);
|
|
17256
|
-
}
|
|
16443
|
+
resolution.includedDynamicImporters.push(this);
|
|
17257
16444
|
const importedNames = this.options.treeshake
|
|
17258
16445
|
? node.getDeterministicImportedNames()
|
|
17259
16446
|
: undefined;
|
|
@@ -17265,15 +16452,15 @@ class Module {
|
|
|
17265
16452
|
}
|
|
17266
16453
|
}
|
|
17267
16454
|
}
|
|
17268
|
-
includeVariable(variable
|
|
17269
|
-
const
|
|
17270
|
-
variable.
|
|
17271
|
-
if (included) {
|
|
16455
|
+
includeVariable(variable) {
|
|
16456
|
+
const variableModule = variable.module;
|
|
16457
|
+
if (variable.included) {
|
|
17272
16458
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
17273
16459
|
getAndExtendSideEffectModules(variable, this);
|
|
17274
16460
|
}
|
|
17275
16461
|
}
|
|
17276
16462
|
else {
|
|
16463
|
+
variable.include();
|
|
17277
16464
|
this.graph.needsTreeshakingPass = true;
|
|
17278
16465
|
if (variableModule instanceof Module) {
|
|
17279
16466
|
if (!variableModule.isExecuted) {
|
|
@@ -17290,8 +16477,8 @@ class Module {
|
|
|
17290
16477
|
}
|
|
17291
16478
|
}
|
|
17292
16479
|
}
|
|
17293
|
-
includeVariableInModule(variable
|
|
17294
|
-
this.includeVariable(variable
|
|
16480
|
+
includeVariableInModule(variable) {
|
|
16481
|
+
this.includeVariable(variable);
|
|
17295
16482
|
const variableModule = variable.module;
|
|
17296
16483
|
if (variableModule && variableModule !== this) {
|
|
17297
16484
|
this.includedImports.add(variable);
|
|
@@ -20300,6 +19487,13 @@ async function findFile(file, preserveSymlinks) {
|
|
|
20300
19487
|
}
|
|
20301
19488
|
}
|
|
20302
19489
|
|
|
19490
|
+
function stripBom(content) {
|
|
19491
|
+
if (content.charCodeAt(0) === 0xfe_ff) {
|
|
19492
|
+
return stripBom(content.slice(1));
|
|
19493
|
+
}
|
|
19494
|
+
return content;
|
|
19495
|
+
}
|
|
19496
|
+
|
|
20303
19497
|
const ANONYMOUS_PLUGIN_PREFIX = 'at position ';
|
|
20304
19498
|
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = 'at output position ';
|
|
20305
19499
|
|
|
@@ -20786,10 +19980,7 @@ class ModuleLoader {
|
|
|
20786
19980
|
: source != null && typeof source === 'object' && typeof source.code === 'string'
|
|
20787
19981
|
? source
|
|
20788
19982
|
: error(logBadLoader(id));
|
|
20789
|
-
|
|
20790
|
-
if (code.charCodeAt(0) === 0xfe_ff) {
|
|
20791
|
-
sourceDescription.code = code.slice(1);
|
|
20792
|
-
}
|
|
19983
|
+
sourceDescription.code = stripBom(sourceDescription.code);
|
|
20793
19984
|
const cachedModule = this.graph.cachedModules.get(id);
|
|
20794
19985
|
if (cachedModule &&
|
|
20795
19986
|
!cachedModule.customTransformCache &&
|
|
@@ -21890,11 +21081,10 @@ class Graph {
|
|
|
21890
21081
|
this.options = options;
|
|
21891
21082
|
this.astLru = flru(5);
|
|
21892
21083
|
this.cachedModules = new Map();
|
|
21893
|
-
this.deoptimizationTracker = new
|
|
21084
|
+
this.deoptimizationTracker = new PathTracker();
|
|
21894
21085
|
this.entryModules = [];
|
|
21895
21086
|
this.modulesById = new Map();
|
|
21896
21087
|
this.needsTreeshakingPass = false;
|
|
21897
|
-
this.newlyIncludedVariableInits = new Set();
|
|
21898
21088
|
this.phase = BuildPhase.LOAD_AND_PARSE;
|
|
21899
21089
|
this.scope = new GlobalScope();
|
|
21900
21090
|
this.watchFiles = Object.create(null);
|
|
@@ -21988,7 +21178,6 @@ class Graph {
|
|
|
21988
21178
|
}
|
|
21989
21179
|
if (this.options.treeshake) {
|
|
21990
21180
|
let treeshakingPass = 1;
|
|
21991
|
-
this.newlyIncludedVariableInits.clear();
|
|
21992
21181
|
do {
|
|
21993
21182
|
timeStart(`treeshaking pass ${treeshakingPass}`, 3);
|
|
21994
21183
|
this.needsTreeshakingPass = false;
|
|
@@ -22001,10 +21190,6 @@ class Graph {
|
|
|
22001
21190
|
else {
|
|
22002
21191
|
module.include();
|
|
22003
21192
|
}
|
|
22004
|
-
for (const entity of this.newlyIncludedVariableInits) {
|
|
22005
|
-
this.newlyIncludedVariableInits.delete(entity);
|
|
22006
|
-
entity.include(createInclusionContext(), false);
|
|
22007
|
-
}
|
|
22008
21193
|
}
|
|
22009
21194
|
}
|
|
22010
21195
|
if (treeshakingPass === 1) {
|
|
@@ -22877,7 +22062,7 @@ const pc = /*@__PURE__*/getDefaultExportFromCjs(picocolorsExports);
|
|
|
22877
22062
|
|
|
22878
22063
|
// @see https://no-color.org
|
|
22879
22064
|
// @see https://www.npmjs.com/package/chalk
|
|
22880
|
-
const { bold, cyan, dim, red} = pc.createColors(env.FORCE_COLOR !== '0' && !env.NO_COLOR);
|
|
22065
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = pc.createColors(env.FORCE_COLOR !== '0' && !env.NO_COLOR);
|
|
22881
22066
|
|
|
22882
22067
|
// log to stderr to keep `rollup main.js > bundle.js` from breaking
|
|
22883
22068
|
const stderr = (...parameters) => process$1.stderr.write(`${parameters.join('')}\n`);
|