rollup 4.27.2 → 4.27.3
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 +7 -7
- 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 +516 -906
- package/dist/es/shared/parseAst.js +3 -3
- package/dist/es/shared/watch.js +3 -3
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +3 -3
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +553 -903
- package/dist/shared/watch-cli.js +20 -4
- package/dist/shared/watch.js +3 -3
- package/package.json +19 -19
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.27.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.27.3
|
|
4
|
+
Mon, 18 Nov 2024 16:39:05 GMT - commit 7c0b1f8810013b5a351a976df30a6a5da4fa164b
|
|
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 {
|
|
13
|
-
import { parseAsync,
|
|
12
|
+
import { posix, win32, isAbsolute, resolve } from 'path';
|
|
13
|
+
import { parseAsync, xxhashBase64Url, xxhashBase36, xxhashBase16 } from '../../native.js';
|
|
14
14
|
import process$1, { env as env$1 } from 'node:process';
|
|
15
15
|
import { performance } from 'node:perf_hooks';
|
|
16
16
|
import { lstat, realpath, readdir, readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
17
17
|
import * as tty from 'tty';
|
|
18
18
|
|
|
19
|
-
var version = "4.27.
|
|
19
|
+
var version = "4.27.3";
|
|
20
20
|
|
|
21
21
|
const comma = ','.charCodeAt(0);
|
|
22
22
|
const semicolon = ';'.charCodeAt(0);
|
|
@@ -1997,6 +1997,19 @@ function is_reference(node, parent) {
|
|
|
1997
1997
|
}
|
|
1998
1998
|
}
|
|
1999
1999
|
|
|
2000
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
2001
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
2002
|
+
const pureFunctions = Object.create(null);
|
|
2003
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2004
|
+
let currentFunctions = pureFunctions;
|
|
2005
|
+
for (const pathSegment of functionName.split('.')) {
|
|
2006
|
+
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2007
|
+
}
|
|
2008
|
+
currentFunctions[PureFunctionKey] = true;
|
|
2009
|
+
}
|
|
2010
|
+
return pureFunctions;
|
|
2011
|
+
};
|
|
2012
|
+
|
|
2000
2013
|
function getOrCreate(map, key, init) {
|
|
2001
2014
|
const existing = map.get(key);
|
|
2002
2015
|
if (existing !== undefined) {
|
|
@@ -2027,7 +2040,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
2027
2040
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
2028
2041
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
2029
2042
|
const EntitiesKey = Symbol('Entities');
|
|
2030
|
-
class
|
|
2043
|
+
class PathTracker {
|
|
2031
2044
|
constructor() {
|
|
2032
2045
|
this.entityPaths = Object.create(null, {
|
|
2033
2046
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -2052,14 +2065,14 @@ class EntityPathTracker {
|
|
|
2052
2065
|
getEntities(path) {
|
|
2053
2066
|
let currentPaths = this.entityPaths;
|
|
2054
2067
|
for (const pathSegment of path) {
|
|
2055
|
-
currentPaths = currentPaths[pathSegment]
|
|
2056
|
-
[
|
|
2057
|
-
|
|
2068
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2069
|
+
currentPaths[pathSegment] ||
|
|
2070
|
+
Object.create(null, { [EntitiesKey]: { value: new Set() } });
|
|
2058
2071
|
}
|
|
2059
2072
|
return currentPaths[EntitiesKey];
|
|
2060
2073
|
}
|
|
2061
2074
|
}
|
|
2062
|
-
const SHARED_RECURSION_TRACKER = new
|
|
2075
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
2063
2076
|
class DiscriminatedPathTracker {
|
|
2064
2077
|
constructor() {
|
|
2065
2078
|
this.entityPaths = Object.create(null, {
|
|
@@ -2069,9 +2082,9 @@ class DiscriminatedPathTracker {
|
|
|
2069
2082
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
2070
2083
|
let currentPaths = this.entityPaths;
|
|
2071
2084
|
for (const pathSegment of path) {
|
|
2072
|
-
currentPaths = currentPaths[pathSegment]
|
|
2073
|
-
[
|
|
2074
|
-
|
|
2085
|
+
currentPaths = currentPaths[pathSegment] =
|
|
2086
|
+
currentPaths[pathSegment] ||
|
|
2087
|
+
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
2075
2088
|
}
|
|
2076
2089
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
2077
2090
|
if (trackedEntities.has(entity))
|
|
@@ -2080,85 +2093,6 @@ class DiscriminatedPathTracker {
|
|
|
2080
2093
|
return false;
|
|
2081
2094
|
}
|
|
2082
2095
|
}
|
|
2083
|
-
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: EMPTY_OBJECT });
|
|
2084
|
-
class IncludedPathTracker {
|
|
2085
|
-
constructor() {
|
|
2086
|
-
this.includedPaths = null;
|
|
2087
|
-
}
|
|
2088
|
-
includePathAndGetIfIncluded(path) {
|
|
2089
|
-
let included = true;
|
|
2090
|
-
let parent = this;
|
|
2091
|
-
let parentSegment = 'includedPaths';
|
|
2092
|
-
let currentPaths = (this.includedPaths ||=
|
|
2093
|
-
((included = false), Object.create(null)));
|
|
2094
|
-
for (const pathSegment of path) {
|
|
2095
|
-
// This means from here, all paths are included
|
|
2096
|
-
if (currentPaths[UnknownKey]) {
|
|
2097
|
-
return true;
|
|
2098
|
-
}
|
|
2099
|
-
// Including UnknownKey automatically includes all nested paths.
|
|
2100
|
-
// From above, we know that UnknownKey is not included yet.
|
|
2101
|
-
if (typeof pathSegment === 'symbol') {
|
|
2102
|
-
// Hopefully, this saves some memory over just setting
|
|
2103
|
-
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
2104
|
-
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
2105
|
-
return false;
|
|
2106
|
-
}
|
|
2107
|
-
parent = currentPaths;
|
|
2108
|
-
parentSegment = pathSegment;
|
|
2109
|
-
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
2110
|
-
}
|
|
2111
|
-
return included;
|
|
2112
|
-
}
|
|
2113
|
-
includeAllPaths(entity, context, basePath) {
|
|
2114
|
-
const { includedPaths } = this;
|
|
2115
|
-
if (includedPaths) {
|
|
2116
|
-
includeAllPaths(entity, context, basePath, includedPaths);
|
|
2117
|
-
}
|
|
2118
|
-
}
|
|
2119
|
-
}
|
|
2120
|
-
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
2121
|
-
if (currentPaths[UnknownKey]) {
|
|
2122
|
-
return entity.includePath([...basePath, UnknownKey], context, false);
|
|
2123
|
-
}
|
|
2124
|
-
const keys = Object.keys(currentPaths);
|
|
2125
|
-
if (keys.length === 0) {
|
|
2126
|
-
return entity.includePath(basePath, context, false);
|
|
2127
|
-
}
|
|
2128
|
-
for (const key of keys) {
|
|
2129
|
-
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
|
|
2133
|
-
function createInclusionContext() {
|
|
2134
|
-
return {
|
|
2135
|
-
brokenFlow: false,
|
|
2136
|
-
hasBreak: false,
|
|
2137
|
-
hasContinue: false,
|
|
2138
|
-
includedCallArguments: new Set(),
|
|
2139
|
-
includedLabels: new Set()
|
|
2140
|
-
};
|
|
2141
|
-
}
|
|
2142
|
-
function createHasEffectsContext() {
|
|
2143
|
-
return {
|
|
2144
|
-
accessed: new EntityPathTracker(),
|
|
2145
|
-
assigned: new EntityPathTracker(),
|
|
2146
|
-
brokenFlow: false,
|
|
2147
|
-
called: new DiscriminatedPathTracker(),
|
|
2148
|
-
hasBreak: false,
|
|
2149
|
-
hasContinue: false,
|
|
2150
|
-
ignore: {
|
|
2151
|
-
breaks: false,
|
|
2152
|
-
continues: false,
|
|
2153
|
-
labels: new Set(),
|
|
2154
|
-
returnYield: false,
|
|
2155
|
-
this: false
|
|
2156
|
-
},
|
|
2157
|
-
includedLabels: new Set(),
|
|
2158
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
2159
|
-
replacedVariableInits: new Map()
|
|
2160
|
-
};
|
|
2161
|
-
}
|
|
2162
2096
|
|
|
2163
2097
|
function isFlagSet(flags, flag) {
|
|
2164
2098
|
return (flags & flag) !== 0;
|
|
@@ -2197,12 +2131,12 @@ class ExpressionEntity {
|
|
|
2197
2131
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2198
2132
|
return true;
|
|
2199
2133
|
}
|
|
2200
|
-
|
|
2134
|
+
include(_context, _includeChildrenRecursively, _options) {
|
|
2201
2135
|
this.included = true;
|
|
2202
2136
|
}
|
|
2203
|
-
includeCallArguments(context,
|
|
2204
|
-
for (const argument of
|
|
2205
|
-
argument
|
|
2137
|
+
includeCallArguments(context, parameters) {
|
|
2138
|
+
for (const argument of parameters) {
|
|
2139
|
+
argument.include(context, false);
|
|
2206
2140
|
}
|
|
2207
2141
|
}
|
|
2208
2142
|
shouldBeIncluded(_context) {
|
|
@@ -2241,19 +2175,6 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
2241
2175
|
withNew: false
|
|
2242
2176
|
};
|
|
2243
2177
|
|
|
2244
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
2245
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
2246
|
-
const pureFunctions = Object.create(null);
|
|
2247
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
2248
|
-
let currentFunctions = pureFunctions;
|
|
2249
|
-
for (const pathSegment of functionName.split('.')) {
|
|
2250
|
-
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
2251
|
-
}
|
|
2252
|
-
currentFunctions[PureFunctionKey] = true;
|
|
2253
|
-
}
|
|
2254
|
-
return pureFunctions;
|
|
2255
|
-
};
|
|
2256
|
-
|
|
2257
2178
|
class Variable extends ExpressionEntity {
|
|
2258
2179
|
markReassigned() {
|
|
2259
2180
|
this.isReassigned = true;
|
|
@@ -2330,9 +2251,9 @@ class Variable extends ExpressionEntity {
|
|
|
2330
2251
|
* has not been included previously. Once a variable is included, it should
|
|
2331
2252
|
* take care all its declarations are included.
|
|
2332
2253
|
*/
|
|
2333
|
-
|
|
2254
|
+
include() {
|
|
2334
2255
|
this.included = true;
|
|
2335
|
-
this.renderedLikeHoisted?.
|
|
2256
|
+
this.renderedLikeHoisted?.include();
|
|
2336
2257
|
}
|
|
2337
2258
|
/**
|
|
2338
2259
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -2364,8 +2285,8 @@ class ExternalVariable extends Variable {
|
|
|
2364
2285
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2365
2286
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2366
2287
|
}
|
|
2367
|
-
|
|
2368
|
-
super.
|
|
2288
|
+
include() {
|
|
2289
|
+
super.include();
|
|
2369
2290
|
this.module.used = true;
|
|
2370
2291
|
}
|
|
2371
2292
|
}
|
|
@@ -2666,6 +2587,36 @@ const childNodeKeys = {
|
|
|
2666
2587
|
YieldExpression: ['argument']
|
|
2667
2588
|
};
|
|
2668
2589
|
|
|
2590
|
+
function createInclusionContext() {
|
|
2591
|
+
return {
|
|
2592
|
+
brokenFlow: false,
|
|
2593
|
+
hasBreak: false,
|
|
2594
|
+
hasContinue: false,
|
|
2595
|
+
includedCallArguments: new Set(),
|
|
2596
|
+
includedLabels: new Set()
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function createHasEffectsContext() {
|
|
2600
|
+
return {
|
|
2601
|
+
accessed: new PathTracker(),
|
|
2602
|
+
assigned: new PathTracker(),
|
|
2603
|
+
brokenFlow: false,
|
|
2604
|
+
called: new DiscriminatedPathTracker(),
|
|
2605
|
+
hasBreak: false,
|
|
2606
|
+
hasContinue: false,
|
|
2607
|
+
ignore: {
|
|
2608
|
+
breaks: false,
|
|
2609
|
+
continues: false,
|
|
2610
|
+
labels: new Set(),
|
|
2611
|
+
returnYield: false,
|
|
2612
|
+
this: false
|
|
2613
|
+
},
|
|
2614
|
+
includedLabels: new Set(),
|
|
2615
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
2616
|
+
replacedVariableInits: new Map()
|
|
2617
|
+
};
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2669
2620
|
const INCLUDE_PARAMETERS = 'variables';
|
|
2670
2621
|
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
2671
2622
|
class NodeBase extends ExpressionEntity {
|
|
@@ -2734,7 +2685,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
2734
2685
|
return (this.hasEffects(context) ||
|
|
2735
2686
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
2736
2687
|
}
|
|
2737
|
-
|
|
2688
|
+
include(context, includeChildrenRecursively, _options) {
|
|
2738
2689
|
if (!this.deoptimized)
|
|
2739
2690
|
this.applyDeoptimizations();
|
|
2740
2691
|
this.included = true;
|
|
@@ -2744,16 +2695,16 @@ class NodeBase extends ExpressionEntity {
|
|
|
2744
2695
|
continue;
|
|
2745
2696
|
if (Array.isArray(value)) {
|
|
2746
2697
|
for (const child of value) {
|
|
2747
|
-
child?.
|
|
2698
|
+
child?.include(context, includeChildrenRecursively);
|
|
2748
2699
|
}
|
|
2749
2700
|
}
|
|
2750
2701
|
else {
|
|
2751
|
-
value.
|
|
2702
|
+
value.include(context, includeChildrenRecursively);
|
|
2752
2703
|
}
|
|
2753
2704
|
}
|
|
2754
2705
|
}
|
|
2755
2706
|
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
2756
|
-
this.
|
|
2707
|
+
this.include(context, includeChildrenRecursively);
|
|
2757
2708
|
}
|
|
2758
2709
|
/**
|
|
2759
2710
|
* Override to perform special initialisation steps after the scope is
|
|
@@ -3215,7 +3166,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3215
3166
|
this.unknownIntegerProps = [];
|
|
3216
3167
|
this.unmatchableGetters = [];
|
|
3217
3168
|
this.unmatchablePropertiesAndGetters = [];
|
|
3218
|
-
this.unmatchablePropertiesAndSetters = [];
|
|
3219
3169
|
this.unmatchableSetters = [];
|
|
3220
3170
|
if (Array.isArray(properties)) {
|
|
3221
3171
|
this.buildPropertyMaps(properties);
|
|
@@ -3450,37 +3400,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
3450
3400
|
}
|
|
3451
3401
|
return false;
|
|
3452
3402
|
}
|
|
3453
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
3454
|
-
this.included = true;
|
|
3455
|
-
const [key, ...subPath] = path;
|
|
3456
|
-
if (key == null || includeChildrenRecursively) {
|
|
3457
|
-
for (const property of this.allProperties) {
|
|
3458
|
-
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
3459
|
-
property.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
3460
|
-
}
|
|
3461
|
-
}
|
|
3462
|
-
this.prototypeExpression?.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
3463
|
-
}
|
|
3464
|
-
else {
|
|
3465
|
-
const [includedMembers, includedPath] = typeof key === 'string'
|
|
3466
|
-
? [
|
|
3467
|
-
[
|
|
3468
|
-
...new Set([
|
|
3469
|
-
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
3470
|
-
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
3471
|
-
])
|
|
3472
|
-
],
|
|
3473
|
-
subPath
|
|
3474
|
-
]
|
|
3475
|
-
: [this.allProperties, UNKNOWN_PATH];
|
|
3476
|
-
for (const property of includedMembers) {
|
|
3477
|
-
property.includePath(includedPath, context, includeChildrenRecursively);
|
|
3478
|
-
}
|
|
3479
|
-
this.prototypeExpression?.includePath(path, context, includeChildrenRecursively);
|
|
3480
|
-
}
|
|
3481
|
-
}
|
|
3482
3403
|
buildPropertyMaps(properties) {
|
|
3483
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters,
|
|
3404
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
3405
|
+
const unmatchablePropertiesAndSetters = [];
|
|
3484
3406
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
3485
3407
|
const { key, kind, property } = properties[index];
|
|
3486
3408
|
allProperties.push(property);
|
|
@@ -4837,37 +4759,17 @@ class GlobalVariable extends Variable {
|
|
|
4837
4759
|
}
|
|
4838
4760
|
}
|
|
4839
4761
|
|
|
4840
|
-
// To avoid infinite recursions
|
|
4841
|
-
const MAX_PATH_DEPTH = 6;
|
|
4842
|
-
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
4843
|
-
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
4844
|
-
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
4845
|
-
const { length: length1 } = path1;
|
|
4846
|
-
const { length: length2 } = path2;
|
|
4847
|
-
return length1 === 0
|
|
4848
|
-
? path2
|
|
4849
|
-
: length2 === 0
|
|
4850
|
-
? path1
|
|
4851
|
-
: length1 + length2 > MAX_PATH_DEPTH
|
|
4852
|
-
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
4853
|
-
: [...path1, ...path2];
|
|
4854
|
-
};
|
|
4855
|
-
|
|
4856
4762
|
class LocalVariable extends Variable {
|
|
4857
|
-
constructor(name, declarator, init,
|
|
4858
|
-
/** if this is non-empty, the actual init is this path of this.init */
|
|
4859
|
-
initPath, context, kind) {
|
|
4763
|
+
constructor(name, declarator, init, context, kind) {
|
|
4860
4764
|
super(name);
|
|
4861
4765
|
this.init = init;
|
|
4862
|
-
this.initPath = initPath;
|
|
4863
|
-
this.kind = kind;
|
|
4864
4766
|
this.calledFromTryStatement = false;
|
|
4865
4767
|
this.additionalInitializers = null;
|
|
4866
|
-
this.includedPathTracker = new IncludedPathTracker();
|
|
4867
4768
|
this.expressionsToBeDeoptimized = [];
|
|
4868
4769
|
this.declarations = declarator ? [declarator] : [];
|
|
4869
4770
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
4870
4771
|
this.module = context.module;
|
|
4772
|
+
this.kind = kind;
|
|
4871
4773
|
}
|
|
4872
4774
|
addDeclaration(identifier, init) {
|
|
4873
4775
|
this.declarations.push(identifier);
|
|
@@ -4878,16 +4780,15 @@ class LocalVariable extends Variable {
|
|
|
4878
4780
|
for (const initializer of this.additionalInitializers) {
|
|
4879
4781
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
4880
4782
|
}
|
|
4783
|
+
this.additionalInitializers = null;
|
|
4881
4784
|
}
|
|
4882
4785
|
}
|
|
4883
4786
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
4884
|
-
if (this.isReassigned
|
|
4787
|
+
if (this.isReassigned) {
|
|
4885
4788
|
deoptimizeInteraction(interaction);
|
|
4886
4789
|
return;
|
|
4887
4790
|
}
|
|
4888
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () =>
|
|
4889
|
-
this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker);
|
|
4890
|
-
}, undefined);
|
|
4791
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
4891
4792
|
}
|
|
4892
4793
|
deoptimizePath(path) {
|
|
4893
4794
|
if (this.isReassigned ||
|
|
@@ -4901,40 +4802,37 @@ class LocalVariable extends Variable {
|
|
|
4901
4802
|
for (const expression of expressionsToBeDeoptimized) {
|
|
4902
4803
|
expression.deoptimizeCache();
|
|
4903
4804
|
}
|
|
4904
|
-
this.init.deoptimizePath(
|
|
4805
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
4905
4806
|
}
|
|
4906
4807
|
else {
|
|
4907
|
-
this.init.deoptimizePath(
|
|
4808
|
+
this.init.deoptimizePath(path);
|
|
4908
4809
|
}
|
|
4909
4810
|
}
|
|
4910
4811
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
4911
|
-
if (this.isReassigned
|
|
4812
|
+
if (this.isReassigned) {
|
|
4912
4813
|
return UnknownValue;
|
|
4913
4814
|
}
|
|
4914
4815
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4915
4816
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4916
|
-
return this.init.getLiteralValueAtPath(
|
|
4817
|
+
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
4917
4818
|
}, UnknownValue);
|
|
4918
4819
|
}
|
|
4919
4820
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
4920
|
-
if (this.isReassigned
|
|
4821
|
+
if (this.isReassigned) {
|
|
4921
4822
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
4922
4823
|
}
|
|
4923
4824
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
4924
4825
|
this.expressionsToBeDeoptimized.push(origin);
|
|
4925
|
-
return this.init.getReturnExpressionWhenCalledAtPath(
|
|
4826
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
4926
4827
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
4927
4828
|
}
|
|
4928
4829
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4929
|
-
if (path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
4930
|
-
return true;
|
|
4931
|
-
}
|
|
4932
4830
|
switch (interaction.type) {
|
|
4933
4831
|
case INTERACTION_ACCESSED: {
|
|
4934
4832
|
if (this.isReassigned)
|
|
4935
4833
|
return true;
|
|
4936
4834
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4937
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4835
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4938
4836
|
}
|
|
4939
4837
|
case INTERACTION_ASSIGNED: {
|
|
4940
4838
|
if (this.included)
|
|
@@ -4944,23 +4842,23 @@ class LocalVariable extends Variable {
|
|
|
4944
4842
|
if (this.isReassigned)
|
|
4945
4843
|
return true;
|
|
4946
4844
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
4947
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4845
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4948
4846
|
}
|
|
4949
4847
|
case INTERACTION_CALLED: {
|
|
4950
4848
|
if (this.isReassigned)
|
|
4951
4849
|
return true;
|
|
4952
4850
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
4953
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
4851
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
4954
4852
|
}
|
|
4955
4853
|
}
|
|
4956
4854
|
}
|
|
4957
|
-
|
|
4958
|
-
if (!this.
|
|
4959
|
-
super.
|
|
4855
|
+
include() {
|
|
4856
|
+
if (!this.included) {
|
|
4857
|
+
super.include();
|
|
4960
4858
|
for (const declaration of this.declarations) {
|
|
4961
4859
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
4962
4860
|
if (!declaration.included)
|
|
4963
|
-
declaration.
|
|
4861
|
+
declaration.include(createInclusionContext(), false);
|
|
4964
4862
|
let node = declaration.parent;
|
|
4965
4863
|
while (!node.included) {
|
|
4966
4864
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
@@ -4971,26 +4869,17 @@ class LocalVariable extends Variable {
|
|
|
4971
4869
|
node = node.parent;
|
|
4972
4870
|
}
|
|
4973
4871
|
}
|
|
4974
|
-
// We need to make sure we include the correct path of the init
|
|
4975
|
-
if (path.length > 0) {
|
|
4976
|
-
this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context, false);
|
|
4977
|
-
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context, false));
|
|
4978
|
-
}
|
|
4979
4872
|
}
|
|
4980
4873
|
}
|
|
4981
|
-
includeCallArguments(context,
|
|
4982
|
-
if (this.isReassigned ||
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
// a specific path
|
|
4986
|
-
this.initPath.length > 0) {
|
|
4987
|
-
for (const argument of interaction.args) {
|
|
4988
|
-
argument?.includePath(UNKNOWN_PATH, context, false);
|
|
4874
|
+
includeCallArguments(context, parameters) {
|
|
4875
|
+
if (this.isReassigned || context.includedCallArguments.has(this.init)) {
|
|
4876
|
+
for (const argument of parameters) {
|
|
4877
|
+
argument.include(context, false);
|
|
4989
4878
|
}
|
|
4990
4879
|
}
|
|
4991
4880
|
else {
|
|
4992
4881
|
context.includedCallArguments.add(this.init);
|
|
4993
|
-
this.init.includeCallArguments(context,
|
|
4882
|
+
this.init.includeCallArguments(context, parameters);
|
|
4994
4883
|
context.includedCallArguments.delete(this.init);
|
|
4995
4884
|
}
|
|
4996
4885
|
}
|
|
@@ -5070,21 +4959,18 @@ class IdentifierBase extends NodeBase {
|
|
|
5070
4959
|
}
|
|
5071
4960
|
}
|
|
5072
4961
|
}
|
|
5073
|
-
|
|
4962
|
+
include() {
|
|
5074
4963
|
if (!this.deoptimized)
|
|
5075
4964
|
this.applyDeoptimizations();
|
|
5076
4965
|
if (!this.included) {
|
|
5077
4966
|
this.included = true;
|
|
5078
4967
|
if (this.variable !== null) {
|
|
5079
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
4968
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
5080
4969
|
}
|
|
5081
4970
|
}
|
|
5082
|
-
else if (path.length > 0) {
|
|
5083
|
-
this.variable?.includePath(path, context);
|
|
5084
|
-
}
|
|
5085
4971
|
}
|
|
5086
|
-
includeCallArguments(context,
|
|
5087
|
-
this.variable.includeCallArguments(context,
|
|
4972
|
+
includeCallArguments(context, parameters) {
|
|
4973
|
+
this.variable.includeCallArguments(context, parameters);
|
|
5088
4974
|
}
|
|
5089
4975
|
isPossibleTDZ() {
|
|
5090
4976
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -5167,40 +5053,11 @@ function closestParentFunctionOrProgram(node) {
|
|
|
5167
5053
|
return node;
|
|
5168
5054
|
}
|
|
5169
5055
|
|
|
5170
|
-
class ObjectMember extends ExpressionEntity {
|
|
5171
|
-
constructor(object, path) {
|
|
5172
|
-
super();
|
|
5173
|
-
this.object = object;
|
|
5174
|
-
this.path = path;
|
|
5175
|
-
}
|
|
5176
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5177
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.path, ...path], recursionTracker);
|
|
5178
|
-
}
|
|
5179
|
-
deoptimizePath(path) {
|
|
5180
|
-
this.object.deoptimizePath([...this.path, ...path]);
|
|
5181
|
-
}
|
|
5182
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5183
|
-
return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin);
|
|
5184
|
-
}
|
|
5185
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5186
|
-
return this.object.getReturnExpressionWhenCalledAtPath([...this.path, ...path], interaction, recursionTracker, origin);
|
|
5187
|
-
}
|
|
5188
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5189
|
-
return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context);
|
|
5190
|
-
}
|
|
5191
|
-
}
|
|
5192
|
-
|
|
5193
5056
|
class Identifier extends IdentifierBase {
|
|
5194
5057
|
constructor() {
|
|
5195
5058
|
super(...arguments);
|
|
5196
5059
|
this.variable = null;
|
|
5197
5060
|
}
|
|
5198
|
-
get isDestructuringDeoptimized() {
|
|
5199
|
-
return isFlagSet(this.flags, 8388608 /* Flag.destructuringDeoptimized */);
|
|
5200
|
-
}
|
|
5201
|
-
set isDestructuringDeoptimized(value) {
|
|
5202
|
-
this.flags = setFlag(this.flags, 8388608 /* Flag.destructuringDeoptimized */, value);
|
|
5203
|
-
}
|
|
5204
5061
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
5205
5062
|
if (exportNamesByVariable.has(this.variable)) {
|
|
5206
5063
|
variables.push(this.variable);
|
|
@@ -5213,52 +5070,42 @@ class Identifier extends IdentifierBase {
|
|
|
5213
5070
|
this.isVariableReference = true;
|
|
5214
5071
|
}
|
|
5215
5072
|
}
|
|
5216
|
-
declare(kind,
|
|
5073
|
+
declare(kind, init) {
|
|
5217
5074
|
let variable;
|
|
5218
5075
|
const { treeshake } = this.scope.context.options;
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5076
|
+
switch (kind) {
|
|
5077
|
+
case 'var': {
|
|
5078
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5079
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
5080
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
5081
|
+
variable.markInitializersForDeoptimization();
|
|
5082
|
+
}
|
|
5083
|
+
break;
|
|
5227
5084
|
}
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
if ((this.included ||=
|
|
5250
|
-
destructuredInitPath.length > 0 &&
|
|
5251
|
-
!context.brokenFlow &&
|
|
5252
|
-
propertyReadSideEffects &&
|
|
5253
|
-
(propertyReadSideEffects === 'always' ||
|
|
5254
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext())))) {
|
|
5255
|
-
if (this.variable && !this.variable.included) {
|
|
5256
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH);
|
|
5085
|
+
case 'function': {
|
|
5086
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
5087
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5088
|
+
break;
|
|
5089
|
+
}
|
|
5090
|
+
case 'let':
|
|
5091
|
+
case 'const':
|
|
5092
|
+
case 'using':
|
|
5093
|
+
case 'await using':
|
|
5094
|
+
case 'class': {
|
|
5095
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
5096
|
+
break;
|
|
5097
|
+
}
|
|
5098
|
+
case 'parameter': {
|
|
5099
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
5100
|
+
break;
|
|
5101
|
+
}
|
|
5102
|
+
/* istanbul ignore next */
|
|
5103
|
+
default: {
|
|
5104
|
+
/* istanbul ignore next */
|
|
5105
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
5257
5106
|
}
|
|
5258
|
-
init.includePath(destructuredInitPath, context, false);
|
|
5259
|
-
return true;
|
|
5260
5107
|
}
|
|
5261
|
-
return
|
|
5108
|
+
return [(this.variable = variable)];
|
|
5262
5109
|
}
|
|
5263
5110
|
markDeclarationReached() {
|
|
5264
5111
|
this.variable.initReached = true;
|
|
@@ -5324,17 +5171,18 @@ class Scope {
|
|
|
5324
5171
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
5325
5172
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
5326
5173
|
*/
|
|
5327
|
-
addDeclaration(identifier, context, init,
|
|
5174
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5328
5175
|
const name = identifier.name;
|
|
5329
5176
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
5330
5177
|
if (existingVariable) {
|
|
5331
|
-
|
|
5178
|
+
const existingKind = existingVariable.kind;
|
|
5179
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
5332
5180
|
existingVariable.addDeclaration(identifier, init);
|
|
5333
5181
|
return existingVariable;
|
|
5334
5182
|
}
|
|
5335
5183
|
context.error(logRedeclarationError(name), identifier.start);
|
|
5336
5184
|
}
|
|
5337
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5185
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
5338
5186
|
this.variables.set(name, newVariable);
|
|
5339
5187
|
return newVariable;
|
|
5340
5188
|
}
|
|
@@ -5536,7 +5384,7 @@ class BlockScope extends ChildScope {
|
|
|
5536
5384
|
constructor(parent) {
|
|
5537
5385
|
super(parent, parent.context);
|
|
5538
5386
|
}
|
|
5539
|
-
addDeclaration(identifier, context, init,
|
|
5387
|
+
addDeclaration(identifier, context, init, kind) {
|
|
5540
5388
|
if (kind === 'var') {
|
|
5541
5389
|
const name = identifier.name;
|
|
5542
5390
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -5548,7 +5396,7 @@ class BlockScope extends ChildScope {
|
|
|
5548
5396
|
}
|
|
5549
5397
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
5550
5398
|
}
|
|
5551
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init,
|
|
5399
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
5552
5400
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
5553
5401
|
// We cannot call deoptimizePath here.
|
|
5554
5402
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -5556,7 +5404,7 @@ class BlockScope extends ChildScope {
|
|
|
5556
5404
|
this.addHoistedVariable(name, declaredVariable);
|
|
5557
5405
|
return declaredVariable;
|
|
5558
5406
|
}
|
|
5559
|
-
return super.addDeclaration(identifier, context, init,
|
|
5407
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
5560
5408
|
}
|
|
5561
5409
|
}
|
|
5562
5410
|
|
|
@@ -5571,11 +5419,11 @@ class StaticBlock extends NodeBase {
|
|
|
5571
5419
|
}
|
|
5572
5420
|
return false;
|
|
5573
5421
|
}
|
|
5574
|
-
|
|
5422
|
+
include(context, includeChildrenRecursively) {
|
|
5575
5423
|
this.included = true;
|
|
5576
5424
|
for (const node of this.body) {
|
|
5577
5425
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
5578
|
-
node.
|
|
5426
|
+
node.include(context, includeChildrenRecursively);
|
|
5579
5427
|
}
|
|
5580
5428
|
}
|
|
5581
5429
|
render(code, options) {
|
|
@@ -5592,6 +5440,29 @@ function isStaticBlock(statement) {
|
|
|
5592
5440
|
return statement.type === StaticBlock$1;
|
|
5593
5441
|
}
|
|
5594
5442
|
|
|
5443
|
+
class ObjectMember extends ExpressionEntity {
|
|
5444
|
+
constructor(object, key) {
|
|
5445
|
+
super();
|
|
5446
|
+
this.object = object;
|
|
5447
|
+
this.key = key;
|
|
5448
|
+
}
|
|
5449
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5450
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
5451
|
+
}
|
|
5452
|
+
deoptimizePath(path) {
|
|
5453
|
+
this.object.deoptimizePath([this.key, ...path]);
|
|
5454
|
+
}
|
|
5455
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5456
|
+
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
5457
|
+
}
|
|
5458
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5459
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
5460
|
+
}
|
|
5461
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5462
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
5463
|
+
}
|
|
5464
|
+
}
|
|
5465
|
+
|
|
5595
5466
|
class ClassNode extends NodeBase {
|
|
5596
5467
|
constructor() {
|
|
5597
5468
|
super(...arguments);
|
|
@@ -5631,22 +5502,22 @@ class ClassNode extends NodeBase {
|
|
|
5631
5502
|
false
|
|
5632
5503
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5633
5504
|
}
|
|
5634
|
-
|
|
5505
|
+
include(context, includeChildrenRecursively) {
|
|
5635
5506
|
if (!this.deoptimized)
|
|
5636
5507
|
this.applyDeoptimizations();
|
|
5637
5508
|
this.included = true;
|
|
5638
|
-
this.superClass?.
|
|
5639
|
-
this.body.
|
|
5509
|
+
this.superClass?.include(context, includeChildrenRecursively);
|
|
5510
|
+
this.body.include(context, includeChildrenRecursively);
|
|
5640
5511
|
for (const decorator of this.decorators)
|
|
5641
|
-
decorator.
|
|
5512
|
+
decorator.include(context, includeChildrenRecursively);
|
|
5642
5513
|
if (this.id) {
|
|
5643
5514
|
this.id.markDeclarationReached();
|
|
5644
|
-
this.id.
|
|
5515
|
+
this.id.include();
|
|
5645
5516
|
}
|
|
5646
5517
|
}
|
|
5647
5518
|
initialise() {
|
|
5648
5519
|
super.initialise();
|
|
5649
|
-
this.id?.declare('class',
|
|
5520
|
+
this.id?.declare('class', this);
|
|
5650
5521
|
for (const method of this.body.body) {
|
|
5651
5522
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
5652
5523
|
this.classConstructor = method;
|
|
@@ -5704,7 +5575,7 @@ class ClassNode extends NodeBase {
|
|
|
5704
5575
|
staticProperties.unshift({
|
|
5705
5576
|
key: 'prototype',
|
|
5706
5577
|
kind: 'init',
|
|
5707
|
-
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass,
|
|
5578
|
+
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, 'prototype') : OBJECT_PROTOTYPE)
|
|
5708
5579
|
});
|
|
5709
5580
|
return (this.objectEntity = new ObjectEntity(staticProperties, this.superClass || OBJECT_PROTOTYPE));
|
|
5710
5581
|
}
|
|
@@ -5761,7 +5632,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
5761
5632
|
|
|
5762
5633
|
class ArgumentsVariable extends LocalVariable {
|
|
5763
5634
|
constructor(context) {
|
|
5764
|
-
super('arguments', null, UNKNOWN_EXPRESSION,
|
|
5635
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
5765
5636
|
this.deoptimizedArguments = [];
|
|
5766
5637
|
}
|
|
5767
5638
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -5775,8 +5646,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5775
5646
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5776
5647
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
5777
5648
|
}
|
|
5778
|
-
|
|
5779
|
-
super.
|
|
5649
|
+
include() {
|
|
5650
|
+
super.include();
|
|
5780
5651
|
for (const argument of this.deoptimizedArguments) {
|
|
5781
5652
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
5782
5653
|
}
|
|
@@ -5787,28 +5658,27 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
5787
5658
|
const MAX_TRACKED_INTERACTIONS = 20;
|
|
5788
5659
|
const NO_INTERACTIONS = EMPTY_ARRAY;
|
|
5789
5660
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
5790
|
-
const EMPTY_PATH_TRACKER = new
|
|
5661
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
5791
5662
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
5792
5663
|
class ParameterVariable extends LocalVariable {
|
|
5793
|
-
constructor(name, declarator,
|
|
5794
|
-
super(name, declarator, UNKNOWN_EXPRESSION,
|
|
5664
|
+
constructor(name, declarator, context) {
|
|
5665
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
5795
5666
|
this.deoptimizationInteractions = [];
|
|
5796
|
-
this.deoptimizations = new
|
|
5667
|
+
this.deoptimizations = new PathTracker();
|
|
5797
5668
|
this.deoptimizedFields = new Set();
|
|
5798
|
-
this.
|
|
5799
|
-
this.
|
|
5669
|
+
this.entitiesToBeDeoptimized = new Set();
|
|
5670
|
+
this.expressionsUseTheKnownValue = [];
|
|
5800
5671
|
this.knownValue = null;
|
|
5801
5672
|
this.knownValueLiteral = UnknownValue;
|
|
5802
5673
|
this.frozenValue = null;
|
|
5803
5674
|
}
|
|
5804
|
-
|
|
5805
|
-
this.updateKnownValue(entity);
|
|
5675
|
+
addEntityToBeDeoptimized(entity) {
|
|
5806
5676
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
5807
5677
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
5808
5678
|
// the interaction cache at this point provided we keep this optimization
|
|
5809
5679
|
// in mind when adding new interactions
|
|
5810
|
-
if (!this.
|
|
5811
|
-
this.
|
|
5680
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5681
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
5812
5682
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
5813
5683
|
deoptimizeInteraction(interaction);
|
|
5814
5684
|
}
|
|
@@ -5818,34 +5688,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
5818
5688
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
5819
5689
|
// This means that we already deoptimized all interactions and no longer
|
|
5820
5690
|
// track them
|
|
5821
|
-
entity.deoptimizePath(
|
|
5691
|
+
entity.deoptimizePath(UNKNOWN_PATH);
|
|
5822
5692
|
}
|
|
5823
|
-
else if (!this.
|
|
5824
|
-
this.
|
|
5693
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
5694
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
5825
5695
|
for (const field of this.deoptimizedFields) {
|
|
5826
|
-
entity.deoptimizePath([
|
|
5696
|
+
entity.deoptimizePath([field]);
|
|
5827
5697
|
}
|
|
5828
5698
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
5829
|
-
|
|
5830
|
-
deoptimizeInteraction(interaction);
|
|
5831
|
-
continue;
|
|
5832
|
-
}
|
|
5833
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
5699
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5834
5700
|
}
|
|
5835
5701
|
}
|
|
5836
5702
|
}
|
|
5837
|
-
/** This says we should not make assumptions about the value of the parameter.
|
|
5838
|
-
* This is different from deoptimization that will also cause argument values
|
|
5839
|
-
* to be deoptimized. */
|
|
5840
5703
|
markReassigned() {
|
|
5841
5704
|
if (this.isReassigned) {
|
|
5842
5705
|
return;
|
|
5843
5706
|
}
|
|
5844
5707
|
super.markReassigned();
|
|
5845
|
-
for (const expression of this.
|
|
5708
|
+
for (const expression of this.expressionsUseTheKnownValue) {
|
|
5846
5709
|
expression.deoptimizeCache();
|
|
5847
5710
|
}
|
|
5848
|
-
this.
|
|
5711
|
+
this.expressionsUseTheKnownValue = EMPTY_ARRAY;
|
|
5849
5712
|
}
|
|
5850
5713
|
deoptimizeCache() {
|
|
5851
5714
|
this.markReassigned();
|
|
@@ -5862,7 +5725,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5862
5725
|
}
|
|
5863
5726
|
if (this.knownValue === null) {
|
|
5864
5727
|
this.knownValue = argument;
|
|
5865
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
5728
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5866
5729
|
return;
|
|
5867
5730
|
}
|
|
5868
5731
|
// the same literal or identifier, do nothing
|
|
@@ -5878,7 +5741,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
5878
5741
|
return;
|
|
5879
5742
|
}
|
|
5880
5743
|
// add tracking for the new argument
|
|
5881
|
-
const newValue = argument.getLiteralValueAtPath(
|
|
5744
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
5882
5745
|
if (newValue !== oldValue) {
|
|
5883
5746
|
this.markReassigned();
|
|
5884
5747
|
}
|
|
@@ -5896,31 +5759,24 @@ class ParameterVariable extends LocalVariable {
|
|
|
5896
5759
|
return this.frozenValue;
|
|
5897
5760
|
}
|
|
5898
5761
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5899
|
-
if (this.isReassigned
|
|
5762
|
+
if (this.isReassigned) {
|
|
5900
5763
|
return UnknownValue;
|
|
5901
5764
|
}
|
|
5902
5765
|
const knownValue = this.getKnownValue();
|
|
5903
|
-
this.
|
|
5904
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(
|
|
5766
|
+
this.expressionsUseTheKnownValue.push(origin);
|
|
5767
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
5905
5768
|
}
|
|
5906
5769
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5907
|
-
|
|
5908
|
-
if (this.isReassigned ||
|
|
5909
|
-
type === INTERACTION_ASSIGNED ||
|
|
5910
|
-
path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
5770
|
+
if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) {
|
|
5911
5771
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5912
5772
|
}
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
? context.instantiated
|
|
5916
|
-
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
5917
|
-
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
5918
|
-
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
5773
|
+
const knownValue = this.getKnownValue();
|
|
5774
|
+
return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5919
5775
|
}
|
|
5920
5776
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
5921
5777
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
5922
5778
|
if (path.length >= 2 ||
|
|
5923
|
-
this.
|
|
5779
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
5924
5780
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
5925
5781
|
(path.length === 1 &&
|
|
5926
5782
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
@@ -5929,10 +5785,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
5929
5785
|
return;
|
|
5930
5786
|
}
|
|
5931
5787
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
5932
|
-
for (const entity of this.
|
|
5933
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
5788
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5789
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
5934
5790
|
}
|
|
5935
|
-
if (!this.
|
|
5791
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
5936
5792
|
this.deoptimizationInteractions.push({
|
|
5937
5793
|
interaction,
|
|
5938
5794
|
path
|
|
@@ -5953,17 +5809,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
5953
5809
|
return;
|
|
5954
5810
|
}
|
|
5955
5811
|
this.deoptimizedFields.add(key);
|
|
5956
|
-
for (const entity of this.
|
|
5812
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
5957
5813
|
// We do not need a recursion tracker here as we already track whether
|
|
5958
5814
|
// this field is deoptimized
|
|
5959
|
-
entity.deoptimizePath([
|
|
5815
|
+
entity.deoptimizePath([key]);
|
|
5960
5816
|
}
|
|
5961
5817
|
if (key === UnknownKey) {
|
|
5962
5818
|
// save some memory
|
|
5963
5819
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
5964
5820
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
5965
5821
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
5966
|
-
this.
|
|
5822
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
5967
5823
|
}
|
|
5968
5824
|
}
|
|
5969
5825
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -5978,14 +5834,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
5978
5834
|
}
|
|
5979
5835
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
5980
5836
|
}
|
|
5981
|
-
includeArgumentPaths(entity, context) {
|
|
5982
|
-
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
5983
|
-
}
|
|
5984
5837
|
}
|
|
5985
5838
|
|
|
5986
5839
|
class ThisVariable extends ParameterVariable {
|
|
5987
5840
|
constructor(context) {
|
|
5988
|
-
super('this', null,
|
|
5841
|
+
super('this', null, context);
|
|
5989
5842
|
}
|
|
5990
5843
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5991
5844
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -5997,7 +5850,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
5997
5850
|
super(parent, parent.context);
|
|
5998
5851
|
this.parent = parent;
|
|
5999
5852
|
}
|
|
6000
|
-
addDeclaration(identifier, context, init,
|
|
5853
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6001
5854
|
if (kind === 'var') {
|
|
6002
5855
|
const name = identifier.name;
|
|
6003
5856
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -6010,7 +5863,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6010
5863
|
// the assignment actually goes to the parameter and the var is
|
|
6011
5864
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
6012
5865
|
// parameter
|
|
6013
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION,
|
|
5866
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
6014
5867
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
6015
5868
|
// names. If we ever implement a logic that splits initialization and
|
|
6016
5869
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -6029,7 +5882,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6029
5882
|
return context.error(logRedeclarationError(name), identifier.start);
|
|
6030
5883
|
}
|
|
6031
5884
|
// We only add parameters to parameter scopes
|
|
6032
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init,
|
|
5885
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
6033
5886
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
6034
5887
|
// We cannot call deoptimizePath here.
|
|
6035
5888
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -6037,7 +5890,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
6037
5890
|
this.addHoistedVariable(name, declaredVariable);
|
|
6038
5891
|
return declaredVariable;
|
|
6039
5892
|
}
|
|
6040
|
-
return super.addDeclaration(identifier, context, init,
|
|
5893
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
6041
5894
|
}
|
|
6042
5895
|
}
|
|
6043
5896
|
|
|
@@ -6047,7 +5900,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6047
5900
|
}
|
|
6048
5901
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
6049
5902
|
// be redeclared, functions and var can redeclare each other
|
|
6050
|
-
addDeclaration(identifier, context, init,
|
|
5903
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6051
5904
|
const name = identifier.name;
|
|
6052
5905
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6053
5906
|
if (existingVariable) {
|
|
@@ -6059,7 +5912,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6059
5912
|
}
|
|
6060
5913
|
context.error(logRedeclarationError(name), identifier.start);
|
|
6061
5914
|
}
|
|
6062
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
5915
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6063
5916
|
this.variables.set(name, newVariable);
|
|
6064
5917
|
return newVariable;
|
|
6065
5918
|
}
|
|
@@ -6068,21 +5921,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
6068
5921
|
class ParameterScope extends ChildScope {
|
|
6069
5922
|
constructor(parent, isCatchScope) {
|
|
6070
5923
|
super(parent, parent.context);
|
|
6071
|
-
this.hasRest = false;
|
|
6072
5924
|
this.parameters = [];
|
|
5925
|
+
this.hasRest = false;
|
|
6073
5926
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
6074
5927
|
}
|
|
6075
5928
|
/**
|
|
6076
5929
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
6077
5930
|
* order, i.e. from left to right.
|
|
6078
5931
|
*/
|
|
6079
|
-
addParameterDeclaration(identifier
|
|
5932
|
+
addParameterDeclaration(identifier) {
|
|
6080
5933
|
const { name, start } = identifier;
|
|
6081
5934
|
const existingParameter = this.variables.get(name);
|
|
6082
5935
|
if (existingParameter) {
|
|
6083
5936
|
return this.context.error(logDuplicateArgumentNameError(name), start);
|
|
6084
5937
|
}
|
|
6085
|
-
const variable = new ParameterVariable(name, identifier,
|
|
5938
|
+
const variable = new ParameterVariable(name, identifier, this.context);
|
|
6086
5939
|
this.variables.set(name, variable);
|
|
6087
5940
|
// We also add it to the body scope to detect name conflicts with local
|
|
6088
5941
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -6100,54 +5953,43 @@ class ParameterScope extends ChildScope {
|
|
|
6100
5953
|
}
|
|
6101
5954
|
this.hasRest = hasRest;
|
|
6102
5955
|
}
|
|
6103
|
-
includeCallArguments(context,
|
|
5956
|
+
includeCallArguments(context, parameters) {
|
|
6104
5957
|
let calledFromTryStatement = false;
|
|
6105
5958
|
let argumentIncluded = false;
|
|
6106
5959
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
6107
|
-
const
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
argumentIncluded = true;
|
|
6114
|
-
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
6115
|
-
}
|
|
6116
|
-
if (argumentIncluded) {
|
|
6117
|
-
args[argumentIndex].includePath(UNKNOWN_PATH, context, false);
|
|
5960
|
+
for (const checkedArgument of parameters) {
|
|
5961
|
+
if (checkedArgument instanceof SpreadElement) {
|
|
5962
|
+
for (const argument of parameters) {
|
|
5963
|
+
argument.include(context, false);
|
|
5964
|
+
}
|
|
5965
|
+
break;
|
|
6118
5966
|
}
|
|
6119
5967
|
}
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
6124
|
-
const argument = args[index];
|
|
5968
|
+
for (let index = parameters.length - 1; index >= 0; index--) {
|
|
5969
|
+
const parameterVariables = this.parameters[index] || restParameter;
|
|
5970
|
+
const argument = parameters[index];
|
|
6125
5971
|
if (parameterVariables) {
|
|
6126
5972
|
calledFromTryStatement = false;
|
|
6127
5973
|
if (parameterVariables.length === 0) {
|
|
6128
|
-
// handle empty destructuring
|
|
5974
|
+
// handle empty destructuring
|
|
6129
5975
|
argumentIncluded = true;
|
|
6130
5976
|
}
|
|
6131
5977
|
else {
|
|
6132
5978
|
for (const variable of parameterVariables) {
|
|
6133
|
-
if (variable.calledFromTryStatement) {
|
|
6134
|
-
calledFromTryStatement = true;
|
|
6135
|
-
}
|
|
6136
5979
|
if (variable.included) {
|
|
6137
5980
|
argumentIncluded = true;
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
else {
|
|
6142
|
-
variable.includeArgumentPaths(argument, context);
|
|
6143
|
-
}
|
|
5981
|
+
}
|
|
5982
|
+
if (variable.calledFromTryStatement) {
|
|
5983
|
+
calledFromTryStatement = true;
|
|
6144
5984
|
}
|
|
6145
5985
|
}
|
|
6146
5986
|
}
|
|
6147
5987
|
}
|
|
6148
|
-
if (!
|
|
5988
|
+
if (!argumentIncluded && argument.shouldBeIncluded(context)) {
|
|
6149
5989
|
argumentIncluded = true;
|
|
6150
|
-
|
|
5990
|
+
}
|
|
5991
|
+
if (argumentIncluded) {
|
|
5992
|
+
argument.include(context, calledFromTryStatement);
|
|
6151
5993
|
}
|
|
6152
5994
|
}
|
|
6153
5995
|
}
|
|
@@ -6162,61 +6004,11 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6162
6004
|
addReturnExpression(expression) {
|
|
6163
6005
|
this.returnExpressions.push(expression);
|
|
6164
6006
|
}
|
|
6165
|
-
deoptimizeArgumentsOnCall(interaction) {
|
|
6166
|
-
const { parameters } = this;
|
|
6167
|
-
const { args } = interaction;
|
|
6168
|
-
let position = 0;
|
|
6169
|
-
for (; position < args.length - 1; position++) {
|
|
6170
|
-
// Only the "this" argument arg[0] can be null
|
|
6171
|
-
const argument = args[position + 1];
|
|
6172
|
-
if (argument instanceof SpreadElement) {
|
|
6173
|
-
// This deoptimizes the current and remaining parameters and arguments
|
|
6174
|
-
for (; position < parameters.length; position++) {
|
|
6175
|
-
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
6176
|
-
parameters[position].forEach(variable => variable.markReassigned());
|
|
6177
|
-
}
|
|
6178
|
-
break;
|
|
6179
|
-
}
|
|
6180
|
-
if (this.hasRest && position >= parameters.length - 1) {
|
|
6181
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6182
|
-
}
|
|
6183
|
-
else {
|
|
6184
|
-
const variables = parameters[position];
|
|
6185
|
-
if (variables) {
|
|
6186
|
-
for (const variable of variables) {
|
|
6187
|
-
variable.addArgumentValue(argument);
|
|
6188
|
-
}
|
|
6189
|
-
}
|
|
6190
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
6191
|
-
}
|
|
6192
|
-
}
|
|
6193
|
-
for (; position < parameters.length; position++) {
|
|
6194
|
-
for (const variable of parameters[position]) {
|
|
6195
|
-
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
6196
|
-
}
|
|
6197
|
-
}
|
|
6198
|
-
}
|
|
6199
6007
|
getReturnExpression() {
|
|
6200
6008
|
if (this.returnExpression === null)
|
|
6201
6009
|
this.updateReturnExpression();
|
|
6202
6010
|
return this.returnExpression;
|
|
6203
6011
|
}
|
|
6204
|
-
deoptimizeAllParameters() {
|
|
6205
|
-
for (const parameter of this.parameters) {
|
|
6206
|
-
for (const variable of parameter) {
|
|
6207
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
6208
|
-
variable.markReassigned();
|
|
6209
|
-
}
|
|
6210
|
-
}
|
|
6211
|
-
}
|
|
6212
|
-
reassignAllParameters() {
|
|
6213
|
-
for (const parameter of this.parameters) {
|
|
6214
|
-
for (const variable of parameter) {
|
|
6215
|
-
variable.markReassigned();
|
|
6216
|
-
}
|
|
6217
|
-
}
|
|
6218
|
-
}
|
|
6219
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
6220
6012
|
updateReturnExpression() {
|
|
6221
6013
|
if (this.returnExpressions.length === 1) {
|
|
6222
6014
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -6232,26 +6024,24 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6232
6024
|
|
|
6233
6025
|
class FunctionScope extends ReturnValueScope {
|
|
6234
6026
|
constructor(parent) {
|
|
6235
|
-
super(parent, false);
|
|
6236
6027
|
const { context } = parent;
|
|
6028
|
+
super(parent, false);
|
|
6237
6029
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
6238
6030
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
6239
6031
|
}
|
|
6240
6032
|
findLexicalBoundary() {
|
|
6241
6033
|
return this;
|
|
6242
6034
|
}
|
|
6243
|
-
includeCallArguments(context,
|
|
6244
|
-
super.includeCallArguments(context,
|
|
6035
|
+
includeCallArguments(context, parameters) {
|
|
6036
|
+
super.includeCallArguments(context, parameters);
|
|
6245
6037
|
if (this.argumentsVariable.included) {
|
|
6246
|
-
const
|
|
6247
|
-
|
|
6248
|
-
|
|
6038
|
+
for (const argument of parameters) {
|
|
6039
|
+
if (!argument.included) {
|
|
6040
|
+
argument.include(context, false);
|
|
6041
|
+
}
|
|
6249
6042
|
}
|
|
6250
6043
|
}
|
|
6251
6044
|
}
|
|
6252
|
-
addArgumentToBeDeoptimized(argument) {
|
|
6253
|
-
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6254
|
-
}
|
|
6255
6045
|
}
|
|
6256
6046
|
|
|
6257
6047
|
class ExpressionStatement extends NodeBase {
|
|
@@ -6317,7 +6107,7 @@ class BlockStatement extends NodeBase {
|
|
|
6317
6107
|
}
|
|
6318
6108
|
return false;
|
|
6319
6109
|
}
|
|
6320
|
-
|
|
6110
|
+
include(context, includeChildrenRecursively) {
|
|
6321
6111
|
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
6322
6112
|
this.included = true;
|
|
6323
6113
|
this.directlyIncluded = true;
|
|
@@ -6325,7 +6115,7 @@ class BlockStatement extends NodeBase {
|
|
|
6325
6115
|
includeChildrenRecursively = true;
|
|
6326
6116
|
for (const node of this.body) {
|
|
6327
6117
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
6328
|
-
node.
|
|
6118
|
+
node.include(context, includeChildrenRecursively);
|
|
6329
6119
|
}
|
|
6330
6120
|
}
|
|
6331
6121
|
}
|
|
@@ -6354,12 +6144,9 @@ class RestElement extends NodeBase {
|
|
|
6354
6144
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6355
6145
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6356
6146
|
}
|
|
6357
|
-
declare(kind,
|
|
6147
|
+
declare(kind, init) {
|
|
6358
6148
|
this.declarationInit = init;
|
|
6359
|
-
return this.argument.declare(kind,
|
|
6360
|
-
}
|
|
6361
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
6362
|
-
this.argument.deoptimizeAssignment(getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6149
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
6363
6150
|
}
|
|
6364
6151
|
deoptimizePath(path) {
|
|
6365
6152
|
if (path.length === 0) {
|
|
@@ -6370,19 +6157,6 @@ class RestElement extends NodeBase {
|
|
|
6370
6157
|
return (path.length > 0 ||
|
|
6371
6158
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
6372
6159
|
}
|
|
6373
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
6374
|
-
return this.argument.hasEffectsWhenDestructuring(context, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
6375
|
-
}
|
|
6376
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
6377
|
-
return (this.included =
|
|
6378
|
-
this.argument.includeDestructuredIfNecessary(context, getIncludedPatternPath$1(destructuredInitPath), init) || this.included);
|
|
6379
|
-
}
|
|
6380
|
-
includePath(_path, context, includeChildrenRecursively) {
|
|
6381
|
-
this.included = true;
|
|
6382
|
-
// This should just include the identifier, its properties should be
|
|
6383
|
-
// included where the variable is used.
|
|
6384
|
-
this.argument.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
6385
|
-
}
|
|
6386
6160
|
markDeclarationReached() {
|
|
6387
6161
|
this.argument.markDeclarationReached();
|
|
6388
6162
|
}
|
|
@@ -6394,15 +6168,12 @@ class RestElement extends NodeBase {
|
|
|
6394
6168
|
}
|
|
6395
6169
|
}
|
|
6396
6170
|
}
|
|
6397
|
-
const getIncludedPatternPath$1 = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
6398
|
-
? destructuredInitPath
|
|
6399
|
-
: [...destructuredInitPath, UnknownKey];
|
|
6400
6171
|
|
|
6401
6172
|
class FunctionBase extends NodeBase {
|
|
6402
6173
|
constructor() {
|
|
6403
6174
|
super(...arguments);
|
|
6175
|
+
this.objectEntity = null;
|
|
6404
6176
|
this.parameterVariableValuesDeoptimized = false;
|
|
6405
|
-
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
6406
6177
|
}
|
|
6407
6178
|
get async() {
|
|
6408
6179
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -6422,9 +6193,53 @@ class FunctionBase extends NodeBase {
|
|
|
6422
6193
|
set generator(value) {
|
|
6423
6194
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
6424
6195
|
}
|
|
6196
|
+
updateParameterVariableValues(_arguments) {
|
|
6197
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
6198
|
+
const parameter = this.params[position];
|
|
6199
|
+
if (!(parameter instanceof Identifier)) {
|
|
6200
|
+
continue;
|
|
6201
|
+
}
|
|
6202
|
+
const parameterVariable = parameter.variable;
|
|
6203
|
+
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
6204
|
+
parameterVariable.updateKnownValue(argument);
|
|
6205
|
+
}
|
|
6206
|
+
}
|
|
6207
|
+
deoptimizeParameterVariableValues() {
|
|
6208
|
+
for (const parameter of this.params) {
|
|
6209
|
+
if (parameter instanceof Identifier) {
|
|
6210
|
+
const parameterVariable = parameter.variable;
|
|
6211
|
+
parameterVariable.markReassigned();
|
|
6212
|
+
}
|
|
6213
|
+
}
|
|
6214
|
+
}
|
|
6425
6215
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6426
|
-
if (interaction.type === INTERACTION_CALLED
|
|
6427
|
-
this.scope
|
|
6216
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
6217
|
+
const { parameters } = this.scope;
|
|
6218
|
+
const { args } = interaction;
|
|
6219
|
+
let hasRest = false;
|
|
6220
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
6221
|
+
const parameter = this.params[position];
|
|
6222
|
+
// Only the "this" argument arg[0] can be null
|
|
6223
|
+
const argument = args[position + 1];
|
|
6224
|
+
if (argument instanceof SpreadElement) {
|
|
6225
|
+
this.deoptimizeParameterVariableValues();
|
|
6226
|
+
}
|
|
6227
|
+
if (hasRest || parameter instanceof RestElement) {
|
|
6228
|
+
hasRest = true;
|
|
6229
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6230
|
+
}
|
|
6231
|
+
else if (parameter instanceof Identifier) {
|
|
6232
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
6233
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6234
|
+
}
|
|
6235
|
+
else if (parameter) {
|
|
6236
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
6237
|
+
}
|
|
6238
|
+
else {
|
|
6239
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
6240
|
+
}
|
|
6241
|
+
}
|
|
6242
|
+
this.updateParameterVariableValues(args);
|
|
6428
6243
|
}
|
|
6429
6244
|
else {
|
|
6430
6245
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -6436,7 +6251,12 @@ class FunctionBase extends NodeBase {
|
|
|
6436
6251
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6437
6252
|
// which means the return expression and parameters need to be reassigned
|
|
6438
6253
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
6439
|
-
this.scope.
|
|
6254
|
+
for (const parameterList of this.scope.parameters) {
|
|
6255
|
+
for (const parameter of parameterList) {
|
|
6256
|
+
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
6257
|
+
parameter.markReassigned();
|
|
6258
|
+
}
|
|
6259
|
+
}
|
|
6440
6260
|
}
|
|
6441
6261
|
}
|
|
6442
6262
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6474,13 +6294,8 @@ class FunctionBase extends NodeBase {
|
|
|
6474
6294
|
return true;
|
|
6475
6295
|
}
|
|
6476
6296
|
}
|
|
6477
|
-
const
|
|
6478
|
-
.
|
|
6479
|
-
for (let index = 0; index < this.params.length; index++) {
|
|
6480
|
-
const parameter = this.params[index];
|
|
6481
|
-
if (parameter.hasEffects(context) ||
|
|
6482
|
-
(propertyReadSideEffects &&
|
|
6483
|
-
parameter.hasEffectsWhenDestructuring(context, EMPTY_PATH, interaction.args[index + 1] || UNDEFINED_EXPRESSION)))
|
|
6297
|
+
for (const parameter of this.params) {
|
|
6298
|
+
if (parameter.hasEffects(context))
|
|
6484
6299
|
return true;
|
|
6485
6300
|
}
|
|
6486
6301
|
return false;
|
|
@@ -6498,19 +6313,22 @@ class FunctionBase extends NodeBase {
|
|
|
6498
6313
|
}
|
|
6499
6314
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
6500
6315
|
}
|
|
6501
|
-
|
|
6502
|
-
if (!
|
|
6316
|
+
include(context, includeChildrenRecursively) {
|
|
6317
|
+
if (!this.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) {
|
|
6503
6318
|
this.parameterVariableValuesDeoptimized = true;
|
|
6504
|
-
this.
|
|
6319
|
+
this.deoptimizeParameterVariableValues();
|
|
6505
6320
|
}
|
|
6506
6321
|
if (!this.deoptimized)
|
|
6507
6322
|
this.applyDeoptimizations();
|
|
6508
6323
|
this.included = true;
|
|
6509
6324
|
const { brokenFlow } = context;
|
|
6510
6325
|
context.brokenFlow = false;
|
|
6511
|
-
this.body.
|
|
6326
|
+
this.body.include(context, includeChildrenRecursively);
|
|
6512
6327
|
context.brokenFlow = brokenFlow;
|
|
6513
6328
|
}
|
|
6329
|
+
includeCallArguments(context, parameters) {
|
|
6330
|
+
this.scope.includeCallArguments(context, parameters);
|
|
6331
|
+
}
|
|
6514
6332
|
initialise() {
|
|
6515
6333
|
super.initialise();
|
|
6516
6334
|
if (this.body instanceof BlockStatement) {
|
|
@@ -6532,10 +6350,11 @@ class FunctionBase extends NodeBase {
|
|
|
6532
6350
|
// so that the scope already knows all parameters and can detect conflicts
|
|
6533
6351
|
// when parsing the body.
|
|
6534
6352
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
6535
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
6353
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
6536
6354
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
6537
6355
|
return super.parseNode(esTreeNode);
|
|
6538
6356
|
}
|
|
6357
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
6539
6358
|
applyDeoptimizations() { }
|
|
6540
6359
|
}
|
|
6541
6360
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
@@ -6550,13 +6369,13 @@ class FunctionNode extends FunctionBase {
|
|
|
6550
6369
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
6551
6370
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
6552
6371
|
// constructed entity.
|
|
6553
|
-
this.scope.thisVariable.
|
|
6372
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
|
|
6554
6373
|
}
|
|
6555
6374
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6556
6375
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6557
6376
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
6558
6377
|
// args[0] is the "this" argument
|
|
6559
|
-
this.scope.thisVariable.
|
|
6378
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
6560
6379
|
}
|
|
6561
6380
|
}
|
|
6562
6381
|
hasEffects(context) {
|
|
@@ -6597,19 +6416,22 @@ class FunctionNode extends FunctionBase {
|
|
|
6597
6416
|
}
|
|
6598
6417
|
return false;
|
|
6599
6418
|
}
|
|
6600
|
-
|
|
6601
|
-
super.
|
|
6602
|
-
this.id?.
|
|
6419
|
+
include(context, includeChildrenRecursively) {
|
|
6420
|
+
super.include(context, includeChildrenRecursively);
|
|
6421
|
+
this.id?.include();
|
|
6603
6422
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
6604
6423
|
for (const parameter of this.params) {
|
|
6605
6424
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
6606
|
-
parameter.
|
|
6425
|
+
parameter.include(context, includeChildrenRecursively);
|
|
6607
6426
|
}
|
|
6608
6427
|
}
|
|
6609
6428
|
}
|
|
6610
6429
|
initialise() {
|
|
6611
6430
|
super.initialise();
|
|
6612
|
-
this.id?.declare('function',
|
|
6431
|
+
this.id?.declare('function', this);
|
|
6432
|
+
}
|
|
6433
|
+
addArgumentToBeDeoptimized(argument) {
|
|
6434
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
6613
6435
|
}
|
|
6614
6436
|
getObjectEntity() {
|
|
6615
6437
|
if (this.objectEntity !== null) {
|
|
@@ -6658,11 +6480,10 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
6658
6480
|
return declarationEnd + generatorStarPos + 1;
|
|
6659
6481
|
}
|
|
6660
6482
|
class ExportDefaultDeclaration extends NodeBase {
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
this.declaration.includePath(path, context, includeChildrenRecursively);
|
|
6483
|
+
include(context, includeChildrenRecursively) {
|
|
6484
|
+
super.include(context, includeChildrenRecursively);
|
|
6664
6485
|
if (includeChildrenRecursively) {
|
|
6665
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
6486
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
6666
6487
|
}
|
|
6667
6488
|
}
|
|
6668
6489
|
initialise() {
|
|
@@ -7024,6 +6845,8 @@ function getChainElementLiteralValueAtPath(element, object, path, recursionTrack
|
|
|
7024
6845
|
return element.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7025
6846
|
}
|
|
7026
6847
|
|
|
6848
|
+
// To avoid infinite recursions
|
|
6849
|
+
const MAX_PATH_DEPTH = 7;
|
|
7027
6850
|
function getResolvablePropertyKey(memberExpression) {
|
|
7028
6851
|
return memberExpression.computed
|
|
7029
6852
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -7129,10 +6952,6 @@ class MemberExpression extends NodeBase {
|
|
|
7129
6952
|
}
|
|
7130
6953
|
}
|
|
7131
6954
|
}
|
|
7132
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
7133
|
-
this.deoptimizePath(EMPTY_PATH);
|
|
7134
|
-
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
7135
|
-
}
|
|
7136
6955
|
deoptimizeCache() {
|
|
7137
6956
|
const { expressionsToBeDeoptimized, object } = this;
|
|
7138
6957
|
this.expressionsToBeDeoptimized = EMPTY_ARRAY;
|
|
@@ -7148,13 +6967,11 @@ class MemberExpression extends NodeBase {
|
|
|
7148
6967
|
if (this.variable) {
|
|
7149
6968
|
this.variable.deoptimizePath(path);
|
|
7150
6969
|
}
|
|
7151
|
-
else if (!this.isUndefined) {
|
|
6970
|
+
else if (!this.isUndefined && path.length < MAX_PATH_DEPTH) {
|
|
7152
6971
|
const propertyKey = this.getPropertyKey();
|
|
7153
6972
|
this.object.deoptimizePath([
|
|
7154
6973
|
propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey,
|
|
7155
|
-
...
|
|
7156
|
-
? path
|
|
7157
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
6974
|
+
...path
|
|
7158
6975
|
]);
|
|
7159
6976
|
}
|
|
7160
6977
|
}
|
|
@@ -7239,47 +7056,28 @@ class MemberExpression extends NodeBase {
|
|
|
7239
7056
|
}
|
|
7240
7057
|
return true;
|
|
7241
7058
|
}
|
|
7242
|
-
|
|
7243
|
-
return (destructuredInitPath.length > 0 &&
|
|
7244
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7245
|
-
}
|
|
7246
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
7059
|
+
include(context, includeChildrenRecursively) {
|
|
7247
7060
|
if (!this.deoptimized)
|
|
7248
7061
|
this.applyDeoptimizations();
|
|
7249
|
-
this.includeProperties(
|
|
7250
|
-
this.getPropertyKey(),
|
|
7251
|
-
...(path.length < MAX_PATH_DEPTH
|
|
7252
|
-
? path
|
|
7253
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
7254
|
-
], context, includeChildrenRecursively);
|
|
7062
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7255
7063
|
}
|
|
7256
7064
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
7257
7065
|
if (!this.assignmentDeoptimized)
|
|
7258
7066
|
this.applyAssignmentDeoptimization();
|
|
7259
7067
|
if (deoptimizeAccess) {
|
|
7260
|
-
this.
|
|
7068
|
+
this.include(context, includeChildrenRecursively);
|
|
7261
7069
|
}
|
|
7262
7070
|
else {
|
|
7263
|
-
this.includeProperties(
|
|
7071
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
7264
7072
|
}
|
|
7265
7073
|
}
|
|
7266
|
-
includeCallArguments(context,
|
|
7074
|
+
includeCallArguments(context, parameters) {
|
|
7267
7075
|
if (this.variable) {
|
|
7268
|
-
this.variable.includeCallArguments(context,
|
|
7076
|
+
this.variable.includeCallArguments(context, parameters);
|
|
7269
7077
|
}
|
|
7270
7078
|
else {
|
|
7271
|
-
super.includeCallArguments(context,
|
|
7272
|
-
}
|
|
7273
|
-
}
|
|
7274
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
7275
|
-
if ((this.included ||=
|
|
7276
|
-
destructuredInitPath.length > 0 &&
|
|
7277
|
-
!context.brokenFlow &&
|
|
7278
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext()))) {
|
|
7279
|
-
init.includePath(destructuredInitPath, context, false);
|
|
7280
|
-
return true;
|
|
7079
|
+
super.includeCallArguments(context, parameters);
|
|
7281
7080
|
}
|
|
7282
|
-
return false;
|
|
7283
7081
|
}
|
|
7284
7082
|
initialise() {
|
|
7285
7083
|
super.initialise();
|
|
@@ -7347,7 +7145,7 @@ class MemberExpression extends NodeBase {
|
|
|
7347
7145
|
const variable = this.scope.findVariable(this.object.name);
|
|
7348
7146
|
if (variable.isNamespace) {
|
|
7349
7147
|
if (this.variable) {
|
|
7350
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7148
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7351
7149
|
}
|
|
7352
7150
|
this.scope.context.log(LOGLEVEL_WARN, logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
7353
7151
|
}
|
|
@@ -7374,18 +7172,15 @@ class MemberExpression extends NodeBase {
|
|
|
7374
7172
|
(propertyReadSideEffects === 'always' ||
|
|
7375
7173
|
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
7376
7174
|
}
|
|
7377
|
-
includeProperties(
|
|
7175
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
7378
7176
|
if (!this.included) {
|
|
7379
7177
|
this.included = true;
|
|
7380
7178
|
if (this.variable) {
|
|
7381
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
7179
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
7382
7180
|
}
|
|
7383
7181
|
}
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
}
|
|
7387
|
-
this.object.includePath(objectPath, context, includeChildrenRecursively);
|
|
7388
|
-
this.property.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7182
|
+
this.object.include(context, includeChildrenRecursively);
|
|
7183
|
+
this.property.include(context, includeChildrenRecursively);
|
|
7389
7184
|
}
|
|
7390
7185
|
}
|
|
7391
7186
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -7428,7 +7223,7 @@ class MetaProperty extends NodeBase {
|
|
|
7428
7223
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
7429
7224
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
7430
7225
|
}
|
|
7431
|
-
|
|
7226
|
+
include() {
|
|
7432
7227
|
if (!this.included) {
|
|
7433
7228
|
this.included = true;
|
|
7434
7229
|
if (this.meta.name === IMPORT) {
|
|
@@ -7547,7 +7342,7 @@ class UndefinedVariable extends Variable {
|
|
|
7547
7342
|
|
|
7548
7343
|
class ExportDefaultVariable extends LocalVariable {
|
|
7549
7344
|
constructor(name, exportDefaultDeclaration, context) {
|
|
7550
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration,
|
|
7345
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
7551
7346
|
this.hasId = false;
|
|
7552
7347
|
this.originalId = null;
|
|
7553
7348
|
this.originalVariable = null;
|
|
@@ -7696,8 +7491,8 @@ class NamespaceVariable extends Variable {
|
|
|
7696
7491
|
return (!memberVariable ||
|
|
7697
7492
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
7698
7493
|
}
|
|
7699
|
-
|
|
7700
|
-
super.
|
|
7494
|
+
include() {
|
|
7495
|
+
super.include();
|
|
7701
7496
|
this.context.includeAllExports();
|
|
7702
7497
|
}
|
|
7703
7498
|
prepare(accessedGlobalsByScope) {
|
|
@@ -7790,9 +7585,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
7790
7585
|
getName(getPropertyAccess) {
|
|
7791
7586
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
7792
7587
|
}
|
|
7793
|
-
|
|
7794
|
-
super.
|
|
7795
|
-
this.context.includeVariableInModule(this.syntheticNamespace
|
|
7588
|
+
include() {
|
|
7589
|
+
super.include();
|
|
7590
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
7796
7591
|
}
|
|
7797
7592
|
setRenderNames(baseName, name) {
|
|
7798
7593
|
super.setRenderNames(baseName, name);
|
|
@@ -10991,37 +10786,21 @@ class ArrayPattern extends NodeBase {
|
|
|
10991
10786
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
10992
10787
|
}
|
|
10993
10788
|
}
|
|
10994
|
-
declare(kind
|
|
10789
|
+
declare(kind) {
|
|
10995
10790
|
const variables = [];
|
|
10996
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
10997
10791
|
for (const element of this.elements) {
|
|
10998
10792
|
if (element !== null) {
|
|
10999
|
-
variables.push(...element.declare(kind,
|
|
10793
|
+
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
|
|
11000
10794
|
}
|
|
11001
10795
|
}
|
|
11002
10796
|
return variables;
|
|
11003
10797
|
}
|
|
11004
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11005
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11006
|
-
for (const element of this.elements) {
|
|
11007
|
-
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
11008
|
-
}
|
|
11009
|
-
}
|
|
11010
10798
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
11011
10799
|
deoptimizePath() {
|
|
11012
10800
|
for (const element of this.elements) {
|
|
11013
10801
|
element?.deoptimizePath(EMPTY_PATH);
|
|
11014
10802
|
}
|
|
11015
10803
|
}
|
|
11016
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11017
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11018
|
-
for (const element of this.elements) {
|
|
11019
|
-
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
11020
|
-
return true;
|
|
11021
|
-
}
|
|
11022
|
-
}
|
|
11023
|
-
return false;
|
|
11024
|
-
}
|
|
11025
10804
|
// Patterns are only checked at the empty path at the moment
|
|
11026
10805
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
11027
10806
|
for (const element of this.elements) {
|
|
@@ -11030,37 +10809,12 @@ class ArrayPattern extends NodeBase {
|
|
|
11030
10809
|
}
|
|
11031
10810
|
return false;
|
|
11032
10811
|
}
|
|
11033
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11034
|
-
let included = false;
|
|
11035
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
11036
|
-
for (const element of this.elements) {
|
|
11037
|
-
if (element) {
|
|
11038
|
-
element.included ||= included;
|
|
11039
|
-
included =
|
|
11040
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
11041
|
-
}
|
|
11042
|
-
}
|
|
11043
|
-
if (included) {
|
|
11044
|
-
// This is necessary so that if any pattern element is included, all are
|
|
11045
|
-
// included for proper deconflicting
|
|
11046
|
-
for (const element of this.elements) {
|
|
11047
|
-
if (element && !element.included) {
|
|
11048
|
-
element.included = true;
|
|
11049
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init);
|
|
11050
|
-
}
|
|
11051
|
-
}
|
|
11052
|
-
}
|
|
11053
|
-
return (this.included ||= included);
|
|
11054
|
-
}
|
|
11055
10812
|
markDeclarationReached() {
|
|
11056
10813
|
for (const element of this.elements) {
|
|
11057
10814
|
element?.markDeclarationReached();
|
|
11058
10815
|
}
|
|
11059
10816
|
}
|
|
11060
10817
|
}
|
|
11061
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
11062
|
-
? destructuredInitPath
|
|
11063
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
11064
10818
|
|
|
11065
10819
|
class ArrowFunctionExpression extends FunctionBase {
|
|
11066
10820
|
constructor() {
|
|
@@ -11109,11 +10863,11 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11109
10863
|
this.parent.callee === this;
|
|
11110
10864
|
return isIIFE || super.onlyFunctionCallUsed();
|
|
11111
10865
|
}
|
|
11112
|
-
|
|
11113
|
-
super.
|
|
10866
|
+
include(context, includeChildrenRecursively) {
|
|
10867
|
+
super.include(context, includeChildrenRecursively);
|
|
11114
10868
|
for (const parameter of this.params) {
|
|
11115
10869
|
if (!(parameter instanceof Identifier)) {
|
|
11116
|
-
parameter.
|
|
10870
|
+
parameter.include(context, includeChildrenRecursively);
|
|
11117
10871
|
}
|
|
11118
10872
|
}
|
|
11119
10873
|
}
|
|
@@ -11136,18 +10890,13 @@ class ObjectPattern extends NodeBase {
|
|
|
11136
10890
|
}
|
|
11137
10891
|
}
|
|
11138
10892
|
}
|
|
11139
|
-
declare(kind,
|
|
10893
|
+
declare(kind, init) {
|
|
11140
10894
|
const variables = [];
|
|
11141
10895
|
for (const property of this.properties) {
|
|
11142
|
-
variables.push(...property.declare(kind,
|
|
10896
|
+
variables.push(...property.declare(kind, init));
|
|
11143
10897
|
}
|
|
11144
10898
|
return variables;
|
|
11145
10899
|
}
|
|
11146
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11147
|
-
for (const property of this.properties) {
|
|
11148
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
11149
|
-
}
|
|
11150
|
-
}
|
|
11151
10900
|
deoptimizePath(path) {
|
|
11152
10901
|
if (path.length === 0) {
|
|
11153
10902
|
for (const property of this.properties) {
|
|
@@ -11165,44 +10914,11 @@ class ObjectPattern extends NodeBase {
|
|
|
11165
10914
|
}
|
|
11166
10915
|
return false;
|
|
11167
10916
|
}
|
|
11168
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11169
|
-
for (const property of this.properties) {
|
|
11170
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
11171
|
-
return true;
|
|
11172
|
-
}
|
|
11173
|
-
return false;
|
|
11174
|
-
}
|
|
11175
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11176
|
-
let included = false;
|
|
11177
|
-
for (const property of this.properties) {
|
|
11178
|
-
included =
|
|
11179
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
11180
|
-
}
|
|
11181
|
-
return (this.included ||= included);
|
|
11182
|
-
}
|
|
11183
10917
|
markDeclarationReached() {
|
|
11184
10918
|
for (const property of this.properties) {
|
|
11185
10919
|
property.markDeclarationReached();
|
|
11186
10920
|
}
|
|
11187
10921
|
}
|
|
11188
|
-
render(code, options) {
|
|
11189
|
-
if (this.properties.length > 0) {
|
|
11190
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
11191
|
-
let lastSeparatorPos = null;
|
|
11192
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
11193
|
-
if (!node.included) {
|
|
11194
|
-
treeshakeNode(node, code, start, end);
|
|
11195
|
-
continue;
|
|
11196
|
-
}
|
|
11197
|
-
lastSeparatorPos = separator;
|
|
11198
|
-
node.render(code, options);
|
|
11199
|
-
}
|
|
11200
|
-
if (lastSeparatorPos) {
|
|
11201
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
11202
|
-
}
|
|
11203
|
-
}
|
|
11204
|
-
}
|
|
11205
|
-
applyDeoptimizations() { }
|
|
11206
10922
|
}
|
|
11207
10923
|
|
|
11208
10924
|
class AssignmentExpression extends NodeBase {
|
|
@@ -11212,27 +10928,23 @@ class AssignmentExpression extends NodeBase {
|
|
|
11212
10928
|
this.applyDeoptimizations();
|
|
11213
10929
|
// MemberExpressions do not access the property before assignments if the
|
|
11214
10930
|
// operator is '='.
|
|
11215
|
-
return (right.hasEffects(context) ||
|
|
11216
|
-
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
11217
|
-
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
10931
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, operator !== '='));
|
|
11218
10932
|
}
|
|
11219
10933
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11220
10934
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11221
10935
|
}
|
|
11222
|
-
|
|
10936
|
+
include(context, includeChildrenRecursively) {
|
|
11223
10937
|
const { deoptimized, left, right, operator } = this;
|
|
11224
10938
|
if (!deoptimized)
|
|
11225
10939
|
this.applyDeoptimizations();
|
|
11226
10940
|
this.included = true;
|
|
11227
|
-
const hasEffectsContext = createHasEffectsContext();
|
|
11228
10941
|
if (includeChildrenRecursively ||
|
|
11229
10942
|
operator !== '=' ||
|
|
11230
10943
|
left.included ||
|
|
11231
|
-
left.hasEffectsAsAssignmentTarget(
|
|
11232
|
-
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
10944
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
11233
10945
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
11234
10946
|
}
|
|
11235
|
-
right.
|
|
10947
|
+
right.include(context, includeChildrenRecursively);
|
|
11236
10948
|
}
|
|
11237
10949
|
initialise() {
|
|
11238
10950
|
super.initialise();
|
|
@@ -11294,7 +11006,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
11294
11006
|
}
|
|
11295
11007
|
applyDeoptimizations() {
|
|
11296
11008
|
this.deoptimized = true;
|
|
11297
|
-
this.left.
|
|
11009
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
11010
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
11298
11011
|
this.scope.context.requestTreeshakingPass();
|
|
11299
11012
|
}
|
|
11300
11013
|
}
|
|
@@ -11303,11 +11016,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
11303
11016
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11304
11017
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11305
11018
|
}
|
|
11306
|
-
declare(kind,
|
|
11307
|
-
return this.left.declare(kind,
|
|
11308
|
-
}
|
|
11309
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11310
|
-
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
11019
|
+
declare(kind, init) {
|
|
11020
|
+
return this.left.declare(kind, init);
|
|
11311
11021
|
}
|
|
11312
11022
|
deoptimizePath(path) {
|
|
11313
11023
|
if (path.length === 0) {
|
|
@@ -11317,23 +11027,6 @@ class AssignmentPattern extends NodeBase {
|
|
|
11317
11027
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11318
11028
|
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11319
11029
|
}
|
|
11320
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11321
|
-
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
11322
|
-
}
|
|
11323
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11324
|
-
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
11325
|
-
this.included;
|
|
11326
|
-
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
11327
|
-
this.right.includePath(UNKNOWN_PATH, context, false);
|
|
11328
|
-
if (!this.left.included) {
|
|
11329
|
-
this.left.included = true;
|
|
11330
|
-
// Unfortunately, we need to include the left side again now, so that
|
|
11331
|
-
// any declared variables are properly included.
|
|
11332
|
-
this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
11333
|
-
}
|
|
11334
|
-
}
|
|
11335
|
-
return (this.included = included);
|
|
11336
|
-
}
|
|
11337
11030
|
markDeclarationReached() {
|
|
11338
11031
|
this.left.markDeclarationReached();
|
|
11339
11032
|
}
|
|
@@ -11355,7 +11048,7 @@ class AwaitExpression extends NodeBase {
|
|
|
11355
11048
|
this.applyDeoptimizations();
|
|
11356
11049
|
return true;
|
|
11357
11050
|
}
|
|
11358
|
-
|
|
11051
|
+
include(context, includeChildrenRecursively) {
|
|
11359
11052
|
if (!this.deoptimized)
|
|
11360
11053
|
this.applyDeoptimizations();
|
|
11361
11054
|
if (!this.included) {
|
|
@@ -11369,7 +11062,7 @@ class AwaitExpression extends NodeBase {
|
|
|
11369
11062
|
this.scope.context.usesTopLevelAwait = true;
|
|
11370
11063
|
}
|
|
11371
11064
|
}
|
|
11372
|
-
this.argument.
|
|
11065
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11373
11066
|
}
|
|
11374
11067
|
}
|
|
11375
11068
|
|
|
@@ -11451,10 +11144,10 @@ class BreakStatement extends NodeBase {
|
|
|
11451
11144
|
context.brokenFlow = true;
|
|
11452
11145
|
return false;
|
|
11453
11146
|
}
|
|
11454
|
-
|
|
11147
|
+
include(context) {
|
|
11455
11148
|
this.included = true;
|
|
11456
11149
|
if (this.label) {
|
|
11457
|
-
this.label.
|
|
11150
|
+
this.label.include();
|
|
11458
11151
|
context.includedLabels.add(this.label.name);
|
|
11459
11152
|
}
|
|
11460
11153
|
else {
|
|
@@ -11648,11 +11341,11 @@ class CallExpression extends CallExpressionBase {
|
|
|
11648
11341
|
(calleeHasEffects ||
|
|
11649
11342
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11650
11343
|
}
|
|
11651
|
-
|
|
11344
|
+
include(context, includeChildrenRecursively) {
|
|
11652
11345
|
if (!this.deoptimized)
|
|
11653
11346
|
this.applyDeoptimizations();
|
|
11654
11347
|
if (includeChildrenRecursively) {
|
|
11655
|
-
super.
|
|
11348
|
+
super.include(context, includeChildrenRecursively);
|
|
11656
11349
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
11657
11350
|
this.callee instanceof Identifier &&
|
|
11658
11351
|
this.callee.variable) {
|
|
@@ -11661,18 +11354,9 @@ class CallExpression extends CallExpressionBase {
|
|
|
11661
11354
|
}
|
|
11662
11355
|
else {
|
|
11663
11356
|
this.included = true;
|
|
11664
|
-
|
|
11665
|
-
// object will already be included via the first argument of the
|
|
11666
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
11667
|
-
// severe performance problems.
|
|
11668
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11669
|
-
this.callee.property.includePath(UNKNOWN_PATH, context, false);
|
|
11670
|
-
}
|
|
11671
|
-
else {
|
|
11672
|
-
this.callee.includePath(UNKNOWN_PATH, context, false);
|
|
11673
|
-
}
|
|
11674
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
11357
|
+
this.callee.include(context, false);
|
|
11675
11358
|
}
|
|
11359
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
11676
11360
|
}
|
|
11677
11361
|
initialise() {
|
|
11678
11362
|
super.initialise();
|
|
@@ -11711,7 +11395,7 @@ class CatchClause extends NodeBase {
|
|
|
11711
11395
|
this.type = type;
|
|
11712
11396
|
if (param) {
|
|
11713
11397
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11714
|
-
this.param.declare('parameter',
|
|
11398
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11715
11399
|
}
|
|
11716
11400
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11717
11401
|
return super.parseNode(esTreeNode);
|
|
@@ -11739,7 +11423,7 @@ class ClassBodyScope extends ChildScope {
|
|
|
11739
11423
|
constructor(parent, classNode) {
|
|
11740
11424
|
const { context } = parent;
|
|
11741
11425
|
super(parent, context);
|
|
11742
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode,
|
|
11426
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
11743
11427
|
this.instanceScope = new ChildScope(this, context);
|
|
11744
11428
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11745
11429
|
}
|
|
@@ -11752,11 +11436,11 @@ class ClassBody extends NodeBase {
|
|
|
11752
11436
|
createScope(parentScope) {
|
|
11753
11437
|
this.scope = new ClassBodyScope(parentScope, this.parent);
|
|
11754
11438
|
}
|
|
11755
|
-
|
|
11439
|
+
include(context, includeChildrenRecursively) {
|
|
11756
11440
|
this.included = true;
|
|
11757
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
11441
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11758
11442
|
for (const definition of this.body) {
|
|
11759
|
-
definition.
|
|
11443
|
+
definition.include(context, includeChildrenRecursively);
|
|
11760
11444
|
}
|
|
11761
11445
|
}
|
|
11762
11446
|
parseNode(esTreeNode) {
|
|
@@ -11880,26 +11564,26 @@ class ConditionalExpression extends NodeBase {
|
|
|
11880
11564
|
}
|
|
11881
11565
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11882
11566
|
}
|
|
11883
|
-
|
|
11567
|
+
include(context, includeChildrenRecursively) {
|
|
11884
11568
|
this.included = true;
|
|
11885
11569
|
const usedBranch = this.getUsedBranch();
|
|
11886
11570
|
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
11887
|
-
this.test.
|
|
11888
|
-
this.consequent.
|
|
11889
|
-
this.alternate.
|
|
11571
|
+
this.test.include(context, includeChildrenRecursively);
|
|
11572
|
+
this.consequent.include(context, includeChildrenRecursively);
|
|
11573
|
+
this.alternate.include(context, includeChildrenRecursively);
|
|
11890
11574
|
}
|
|
11891
11575
|
else {
|
|
11892
|
-
usedBranch.
|
|
11576
|
+
usedBranch.include(context, includeChildrenRecursively);
|
|
11893
11577
|
}
|
|
11894
11578
|
}
|
|
11895
|
-
includeCallArguments(context,
|
|
11579
|
+
includeCallArguments(context, parameters) {
|
|
11896
11580
|
const usedBranch = this.getUsedBranch();
|
|
11897
11581
|
if (usedBranch) {
|
|
11898
|
-
usedBranch.includeCallArguments(context,
|
|
11582
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
11899
11583
|
}
|
|
11900
11584
|
else {
|
|
11901
|
-
this.consequent.includeCallArguments(context,
|
|
11902
|
-
this.alternate.includeCallArguments(context,
|
|
11585
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
11586
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
11903
11587
|
}
|
|
11904
11588
|
}
|
|
11905
11589
|
removeAnnotations(code) {
|
|
@@ -11960,10 +11644,10 @@ class ContinueStatement extends NodeBase {
|
|
|
11960
11644
|
context.brokenFlow = true;
|
|
11961
11645
|
return false;
|
|
11962
11646
|
}
|
|
11963
|
-
|
|
11647
|
+
include(context) {
|
|
11964
11648
|
this.included = true;
|
|
11965
11649
|
if (this.label) {
|
|
11966
|
-
this.label.
|
|
11650
|
+
this.label.include();
|
|
11967
11651
|
context.includedLabels.add(this.label.name);
|
|
11968
11652
|
}
|
|
11969
11653
|
else {
|
|
@@ -12006,7 +11690,7 @@ function includeLoopBody(context, body, includeChildrenRecursively) {
|
|
|
12006
11690
|
const { brokenFlow, hasBreak, hasContinue } = context;
|
|
12007
11691
|
context.hasBreak = false;
|
|
12008
11692
|
context.hasContinue = false;
|
|
12009
|
-
body.
|
|
11693
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
12010
11694
|
context.hasBreak = hasBreak;
|
|
12011
11695
|
context.hasContinue = hasContinue;
|
|
12012
11696
|
context.brokenFlow = brokenFlow;
|
|
@@ -12018,9 +11702,9 @@ class DoWhileStatement extends NodeBase {
|
|
|
12018
11702
|
return true;
|
|
12019
11703
|
return hasLoopBodyEffects(context, this.body);
|
|
12020
11704
|
}
|
|
12021
|
-
|
|
11705
|
+
include(context, includeChildrenRecursively) {
|
|
12022
11706
|
this.included = true;
|
|
12023
|
-
this.test.
|
|
11707
|
+
this.test.include(context, includeChildrenRecursively);
|
|
12024
11708
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12025
11709
|
}
|
|
12026
11710
|
}
|
|
@@ -12091,13 +11775,13 @@ class ForInStatement extends NodeBase {
|
|
|
12091
11775
|
return true;
|
|
12092
11776
|
return hasLoopBodyEffects(context, body);
|
|
12093
11777
|
}
|
|
12094
|
-
|
|
11778
|
+
include(context, includeChildrenRecursively) {
|
|
12095
11779
|
const { body, deoptimized, left, right } = this;
|
|
12096
11780
|
if (!deoptimized)
|
|
12097
11781
|
this.applyDeoptimizations();
|
|
12098
11782
|
this.included = true;
|
|
12099
11783
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12100
|
-
right.
|
|
11784
|
+
right.include(context, includeChildrenRecursively);
|
|
12101
11785
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12102
11786
|
}
|
|
12103
11787
|
initialise() {
|
|
@@ -12136,13 +11820,13 @@ class ForOfStatement extends NodeBase {
|
|
|
12136
11820
|
// Placeholder until proper Symbol.Iterator support
|
|
12137
11821
|
return true;
|
|
12138
11822
|
}
|
|
12139
|
-
|
|
11823
|
+
include(context, includeChildrenRecursively) {
|
|
12140
11824
|
const { body, deoptimized, left, right } = this;
|
|
12141
11825
|
if (!deoptimized)
|
|
12142
11826
|
this.applyDeoptimizations();
|
|
12143
11827
|
this.included = true;
|
|
12144
11828
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12145
|
-
right.
|
|
11829
|
+
right.include(context, includeChildrenRecursively);
|
|
12146
11830
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12147
11831
|
}
|
|
12148
11832
|
initialise() {
|
|
@@ -12178,13 +11862,11 @@ class ForStatement extends NodeBase {
|
|
|
12178
11862
|
}
|
|
12179
11863
|
return hasLoopBodyEffects(context, this.body);
|
|
12180
11864
|
}
|
|
12181
|
-
|
|
11865
|
+
include(context, includeChildrenRecursively) {
|
|
12182
11866
|
this.included = true;
|
|
12183
|
-
this.init?.
|
|
12184
|
-
|
|
12185
|
-
|
|
12186
|
-
this.test?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
12187
|
-
this.update?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
11867
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
11868
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
11869
|
+
this.update?.include(context, includeChildrenRecursively);
|
|
12188
11870
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12189
11871
|
}
|
|
12190
11872
|
render(code, options) {
|
|
@@ -12225,9 +11907,9 @@ class TrackingScope extends BlockScope {
|
|
|
12225
11907
|
super(...arguments);
|
|
12226
11908
|
this.hoistedDeclarations = [];
|
|
12227
11909
|
}
|
|
12228
|
-
addDeclaration(identifier, context, init,
|
|
11910
|
+
addDeclaration(identifier, context, init, kind) {
|
|
12229
11911
|
this.hoistedDeclarations.push(identifier);
|
|
12230
|
-
return super.addDeclaration(identifier, context, init,
|
|
11912
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
12231
11913
|
}
|
|
12232
11914
|
}
|
|
12233
11915
|
|
|
@@ -12260,7 +11942,7 @@ class IfStatement extends NodeBase {
|
|
|
12260
11942
|
}
|
|
12261
11943
|
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
12262
11944
|
}
|
|
12263
|
-
|
|
11945
|
+
include(context, includeChildrenRecursively) {
|
|
12264
11946
|
this.included = true;
|
|
12265
11947
|
if (includeChildrenRecursively) {
|
|
12266
11948
|
this.includeRecursively(includeChildrenRecursively, context);
|
|
@@ -12335,31 +12017,31 @@ class IfStatement extends NodeBase {
|
|
|
12335
12017
|
}
|
|
12336
12018
|
includeKnownTest(context, testValue) {
|
|
12337
12019
|
if (this.test.shouldBeIncluded(context)) {
|
|
12338
|
-
this.test.
|
|
12020
|
+
this.test.include(context, false);
|
|
12339
12021
|
}
|
|
12340
12022
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
12341
|
-
this.consequent.
|
|
12023
|
+
this.consequent.include(context, false, { asSingleStatement: true });
|
|
12342
12024
|
}
|
|
12343
12025
|
if (!testValue && this.alternate?.shouldBeIncluded(context)) {
|
|
12344
|
-
this.alternate.
|
|
12026
|
+
this.alternate.include(context, false, { asSingleStatement: true });
|
|
12345
12027
|
}
|
|
12346
12028
|
}
|
|
12347
12029
|
includeRecursively(includeChildrenRecursively, context) {
|
|
12348
|
-
this.test.
|
|
12349
|
-
this.consequent.
|
|
12350
|
-
this.alternate?.
|
|
12030
|
+
this.test.include(context, includeChildrenRecursively);
|
|
12031
|
+
this.consequent.include(context, includeChildrenRecursively);
|
|
12032
|
+
this.alternate?.include(context, includeChildrenRecursively);
|
|
12351
12033
|
}
|
|
12352
12034
|
includeUnknownTest(context) {
|
|
12353
|
-
this.test.
|
|
12035
|
+
this.test.include(context, false);
|
|
12354
12036
|
const { brokenFlow } = context;
|
|
12355
12037
|
let consequentBrokenFlow = false;
|
|
12356
12038
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
12357
|
-
this.consequent.
|
|
12039
|
+
this.consequent.include(context, false, { asSingleStatement: true });
|
|
12358
12040
|
consequentBrokenFlow = context.brokenFlow;
|
|
12359
12041
|
context.brokenFlow = brokenFlow;
|
|
12360
12042
|
}
|
|
12361
12043
|
if (this.alternate?.shouldBeIncluded(context)) {
|
|
12362
|
-
this.alternate.
|
|
12044
|
+
this.alternate.include(context, false, { asSingleStatement: true });
|
|
12363
12045
|
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
12364
12046
|
}
|
|
12365
12047
|
}
|
|
@@ -12427,7 +12109,7 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12427
12109
|
class VariableDeclarator extends NodeBase {
|
|
12428
12110
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12429
12111
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12430
|
-
this.id.declare(kind,
|
|
12112
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12431
12113
|
}
|
|
12432
12114
|
deoptimizePath(path) {
|
|
12433
12115
|
this.id.deoptimizePath(path);
|
|
@@ -12437,25 +12119,17 @@ class VariableDeclarator extends NodeBase {
|
|
|
12437
12119
|
this.applyDeoptimizations();
|
|
12438
12120
|
const initEffect = this.init?.hasEffects(context);
|
|
12439
12121
|
this.id.markDeclarationReached();
|
|
12440
|
-
return
|
|
12441
|
-
|
|
12442
|
-
|
|
12443
|
-
(this.scope.context.options.treeshake
|
|
12444
|
-
.propertyReadSideEffects &&
|
|
12445
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
12446
|
-
}
|
|
12447
|
-
includePath(_path, context, includeChildrenRecursively) {
|
|
12122
|
+
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
12123
|
+
}
|
|
12124
|
+
include(context, includeChildrenRecursively) {
|
|
12448
12125
|
const { deoptimized, id, init } = this;
|
|
12449
12126
|
if (!deoptimized)
|
|
12450
12127
|
this.applyDeoptimizations();
|
|
12451
12128
|
this.included = true;
|
|
12452
|
-
init?.
|
|
12129
|
+
init?.include(context, includeChildrenRecursively);
|
|
12453
12130
|
id.markDeclarationReached();
|
|
12454
|
-
if (includeChildrenRecursively) {
|
|
12455
|
-
id.
|
|
12456
|
-
}
|
|
12457
|
-
else {
|
|
12458
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
12131
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12132
|
+
id.include(context, includeChildrenRecursively);
|
|
12459
12133
|
}
|
|
12460
12134
|
}
|
|
12461
12135
|
removeAnnotations(code) {
|
|
@@ -12504,8 +12178,6 @@ class ImportExpression extends NodeBase {
|
|
|
12504
12178
|
constructor() {
|
|
12505
12179
|
super(...arguments);
|
|
12506
12180
|
this.inlineNamespace = null;
|
|
12507
|
-
this.hasUnknownAccessedKey = false;
|
|
12508
|
-
this.accessedPropKey = new Set();
|
|
12509
12181
|
this.attributes = null;
|
|
12510
12182
|
this.mechanism = null;
|
|
12511
12183
|
this.namespaceExportName = undefined;
|
|
@@ -12538,15 +12210,12 @@ class ImportExpression extends NodeBase {
|
|
|
12538
12210
|
if (parent2 instanceof ExpressionStatement) {
|
|
12539
12211
|
return EMPTY_ARRAY;
|
|
12540
12212
|
}
|
|
12541
|
-
// Case 1: const { foo }
|
|
12213
|
+
// Case 1: const { foo } = await import('bar')
|
|
12542
12214
|
if (parent2 instanceof VariableDeclarator) {
|
|
12543
12215
|
const declaration = parent2.id;
|
|
12544
|
-
|
|
12545
|
-
|
|
12546
|
-
|
|
12547
|
-
if (declaration instanceof ObjectPattern) {
|
|
12548
|
-
return getDeterministicObjectDestructure(declaration);
|
|
12549
|
-
}
|
|
12216
|
+
return declaration instanceof ObjectPattern
|
|
12217
|
+
? getDeterministicObjectDestructure(declaration)
|
|
12218
|
+
: undefined;
|
|
12550
12219
|
}
|
|
12551
12220
|
// Case 2: (await import('bar')).foo
|
|
12552
12221
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12595,23 +12264,13 @@ class ImportExpression extends NodeBase {
|
|
|
12595
12264
|
hasEffects() {
|
|
12596
12265
|
return true;
|
|
12597
12266
|
}
|
|
12598
|
-
|
|
12267
|
+
include(context, includeChildrenRecursively) {
|
|
12599
12268
|
if (!this.included) {
|
|
12600
12269
|
this.included = true;
|
|
12601
12270
|
this.scope.context.includeDynamicImport(this);
|
|
12602
12271
|
this.scope.addAccessedDynamicImport(this);
|
|
12603
|
-
this.source.includePath(path, context, includeChildrenRecursively);
|
|
12604
|
-
}
|
|
12605
|
-
if (this.hasUnknownAccessedKey)
|
|
12606
|
-
return;
|
|
12607
|
-
if (path[0] === UnknownKey) {
|
|
12608
|
-
this.hasUnknownAccessedKey = true;
|
|
12609
|
-
this.scope.context.includeDynamicImport(this);
|
|
12610
|
-
}
|
|
12611
|
-
else if (typeof path[0] === 'string') {
|
|
12612
|
-
this.accessedPropKey.add(path[0]);
|
|
12613
|
-
this.scope.context.includeDynamicImport(this);
|
|
12614
12272
|
}
|
|
12273
|
+
this.source.include(context, includeChildrenRecursively);
|
|
12615
12274
|
}
|
|
12616
12275
|
initialise() {
|
|
12617
12276
|
super.initialise();
|
|
@@ -12939,7 +12598,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12939
12598
|
if (preserve) {
|
|
12940
12599
|
// This pretends we are accessing an included global variable of the same name
|
|
12941
12600
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
12942
|
-
globalVariable.
|
|
12601
|
+
globalVariable.include();
|
|
12943
12602
|
// This excludes this variable from renaming
|
|
12944
12603
|
factoryVariable.globalName = baseName;
|
|
12945
12604
|
}
|
|
@@ -12947,7 +12606,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12947
12606
|
else {
|
|
12948
12607
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
12949
12608
|
}
|
|
12950
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
12609
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
12951
12610
|
if (factoryVariable instanceof LocalVariable) {
|
|
12952
12611
|
factoryVariable.consolidateInitializers();
|
|
12953
12612
|
factoryVariable.addUsedPlace(node);
|
|
@@ -12969,7 +12628,7 @@ class JSXElementBase extends NodeBase {
|
|
|
12969
12628
|
this.scope.context.addImportSource(importSource);
|
|
12970
12629
|
}
|
|
12971
12630
|
}
|
|
12972
|
-
|
|
12631
|
+
include(context, includeChildrenRecursively) {
|
|
12973
12632
|
if (!this.included) {
|
|
12974
12633
|
const { factory, importSource, mode } = this.jsxMode;
|
|
12975
12634
|
if (factory) {
|
|
@@ -12977,7 +12636,7 @@ class JSXElementBase extends NodeBase {
|
|
|
12977
12636
|
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
12978
12637
|
}
|
|
12979
12638
|
}
|
|
12980
|
-
super.
|
|
12639
|
+
super.include(context, includeChildrenRecursively);
|
|
12981
12640
|
}
|
|
12982
12641
|
applyDeoptimizations() { }
|
|
12983
12642
|
getRenderingMode() {
|
|
@@ -13239,7 +12898,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13239
12898
|
this.fragment = null;
|
|
13240
12899
|
this.fragmentVariable = null;
|
|
13241
12900
|
}
|
|
13242
|
-
|
|
12901
|
+
include(context, includeChildrenRecursively) {
|
|
13243
12902
|
if (!this.included) {
|
|
13244
12903
|
const jsx = this.scope.context.options.jsx;
|
|
13245
12904
|
if (jsx.mode === 'automatic') {
|
|
@@ -13254,7 +12913,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13254
12913
|
}
|
|
13255
12914
|
}
|
|
13256
12915
|
}
|
|
13257
|
-
super.
|
|
12916
|
+
super.include(context, includeChildrenRecursively);
|
|
13258
12917
|
}
|
|
13259
12918
|
render(code, options) {
|
|
13260
12919
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -13311,13 +12970,13 @@ class LabeledStatement extends NodeBase {
|
|
|
13311
12970
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13312
12971
|
return bodyHasEffects;
|
|
13313
12972
|
}
|
|
13314
|
-
|
|
12973
|
+
include(context, includeChildrenRecursively) {
|
|
13315
12974
|
this.included = true;
|
|
13316
12975
|
const { brokenFlow, includedLabels } = context;
|
|
13317
12976
|
context.includedLabels = new Set();
|
|
13318
|
-
this.body.
|
|
12977
|
+
this.body.include(context, includeChildrenRecursively);
|
|
13319
12978
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13320
|
-
this.label.
|
|
12979
|
+
this.label.include();
|
|
13321
12980
|
context.includedLabels.delete(this.label.name);
|
|
13322
12981
|
context.brokenFlow = brokenFlow;
|
|
13323
12982
|
}
|
|
@@ -13414,17 +13073,17 @@ class LogicalExpression extends NodeBase {
|
|
|
13414
13073
|
}
|
|
13415
13074
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13416
13075
|
}
|
|
13417
|
-
|
|
13076
|
+
include(context, includeChildrenRecursively) {
|
|
13418
13077
|
this.included = true;
|
|
13419
13078
|
const usedBranch = this.getUsedBranch();
|
|
13420
13079
|
if (includeChildrenRecursively ||
|
|
13421
13080
|
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
13422
13081
|
!usedBranch) {
|
|
13423
|
-
this.left.
|
|
13424
|
-
this.right.
|
|
13082
|
+
this.left.include(context, includeChildrenRecursively);
|
|
13083
|
+
this.right.include(context, includeChildrenRecursively);
|
|
13425
13084
|
}
|
|
13426
13085
|
else {
|
|
13427
|
-
usedBranch.
|
|
13086
|
+
usedBranch.include(context, includeChildrenRecursively);
|
|
13428
13087
|
}
|
|
13429
13088
|
}
|
|
13430
13089
|
removeAnnotations(code) {
|
|
@@ -13496,17 +13155,17 @@ class NewExpression extends NodeBase {
|
|
|
13496
13155
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
13497
13156
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13498
13157
|
}
|
|
13499
|
-
|
|
13158
|
+
include(context, includeChildrenRecursively) {
|
|
13500
13159
|
if (!this.deoptimized)
|
|
13501
13160
|
this.applyDeoptimizations();
|
|
13502
13161
|
if (includeChildrenRecursively) {
|
|
13503
|
-
super.
|
|
13162
|
+
super.include(context, includeChildrenRecursively);
|
|
13504
13163
|
}
|
|
13505
13164
|
else {
|
|
13506
13165
|
this.included = true;
|
|
13507
|
-
this.callee.
|
|
13166
|
+
this.callee.include(context, false);
|
|
13508
13167
|
}
|
|
13509
|
-
this.callee.includeCallArguments(context, this.
|
|
13168
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13510
13169
|
}
|
|
13511
13170
|
initialise() {
|
|
13512
13171
|
super.initialise();
|
|
@@ -13535,7 +13194,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13535
13194
|
constructor() {
|
|
13536
13195
|
super(...arguments);
|
|
13537
13196
|
this.objectEntity = null;
|
|
13538
|
-
this.protoProp = null;
|
|
13539
13197
|
}
|
|
13540
13198
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13541
13199
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13555,32 +13213,13 @@ class ObjectExpression extends NodeBase {
|
|
|
13555
13213
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13556
13214
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13557
13215
|
}
|
|
13558
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
13559
|
-
this.included = true;
|
|
13560
|
-
this.getObjectEntity().includePath(path, context, includeChildrenRecursively);
|
|
13561
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13562
|
-
}
|
|
13563
13216
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13217
|
+
super.render(code, options);
|
|
13564
13218
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13565
13219
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13566
13220
|
code.appendRight(this.start, '(');
|
|
13567
13221
|
code.prependLeft(this.end, ')');
|
|
13568
13222
|
}
|
|
13569
|
-
if (this.properties.length > 0) {
|
|
13570
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13571
|
-
let lastSeparatorPos = null;
|
|
13572
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
13573
|
-
if (!node.included) {
|
|
13574
|
-
treeshakeNode(node, code, start, end);
|
|
13575
|
-
continue;
|
|
13576
|
-
}
|
|
13577
|
-
lastSeparatorPos = separator;
|
|
13578
|
-
node.render(code, options);
|
|
13579
|
-
}
|
|
13580
|
-
if (lastSeparatorPos) {
|
|
13581
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
13582
|
-
}
|
|
13583
|
-
}
|
|
13584
13223
|
}
|
|
13585
13224
|
applyDeoptimizations() { }
|
|
13586
13225
|
getObjectEntity() {
|
|
@@ -13611,7 +13250,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13611
13250
|
? property.key.name
|
|
13612
13251
|
: String(property.key.value);
|
|
13613
13252
|
if (key === '__proto__' && property.kind === 'init') {
|
|
13614
|
-
this.protoProp = property;
|
|
13615
13253
|
prototype =
|
|
13616
13254
|
property.value instanceof Literal && property.value.value === null
|
|
13617
13255
|
? null
|
|
@@ -13678,11 +13316,11 @@ class Program extends NodeBase {
|
|
|
13678
13316
|
}
|
|
13679
13317
|
return false;
|
|
13680
13318
|
}
|
|
13681
|
-
|
|
13319
|
+
include(context, includeChildrenRecursively) {
|
|
13682
13320
|
this.included = true;
|
|
13683
13321
|
for (const node of this.body) {
|
|
13684
13322
|
if (includeChildrenRecursively || node.shouldBeIncluded(context)) {
|
|
13685
|
-
node.
|
|
13323
|
+
node.include(context, includeChildrenRecursively);
|
|
13686
13324
|
}
|
|
13687
13325
|
}
|
|
13688
13326
|
}
|
|
@@ -13721,6 +13359,10 @@ class Program extends NodeBase {
|
|
|
13721
13359
|
}
|
|
13722
13360
|
|
|
13723
13361
|
class Property extends MethodBase {
|
|
13362
|
+
constructor() {
|
|
13363
|
+
super(...arguments);
|
|
13364
|
+
this.declarationInit = null;
|
|
13365
|
+
}
|
|
13724
13366
|
//declare method: boolean;
|
|
13725
13367
|
get method() {
|
|
13726
13368
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -13735,39 +13377,17 @@ class Property extends MethodBase {
|
|
|
13735
13377
|
set shorthand(value) {
|
|
13736
13378
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
13737
13379
|
}
|
|
13738
|
-
declare(kind,
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
13742
|
-
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
13380
|
+
declare(kind, init) {
|
|
13381
|
+
this.declarationInit = init;
|
|
13382
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
13743
13383
|
}
|
|
13744
13384
|
hasEffects(context) {
|
|
13745
13385
|
if (!this.deoptimized)
|
|
13746
13386
|
this.applyDeoptimizations();
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
}
|
|
13752
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
13753
|
-
const path = this.getPathInProperty(destructuredInitPath);
|
|
13754
|
-
let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
|
|
13755
|
-
this.included;
|
|
13756
|
-
if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
|
|
13757
|
-
this.key.includePath(EMPTY_PATH, context, false);
|
|
13758
|
-
if (!this.value.included) {
|
|
13759
|
-
this.value.included = true;
|
|
13760
|
-
// Unfortunately, we need to include the value again now, so that any
|
|
13761
|
-
// declared variables are properly included.
|
|
13762
|
-
this.value.includeDestructuredIfNecessary(context, path, init);
|
|
13763
|
-
}
|
|
13764
|
-
}
|
|
13765
|
-
return (this.included = included);
|
|
13766
|
-
}
|
|
13767
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
13768
|
-
this.included = true;
|
|
13769
|
-
this.key.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
13770
|
-
this.value.includePath(path, context, includeChildrenRecursively);
|
|
13387
|
+
const propertyReadSideEffects = this.scope.context.options.treeshake.propertyReadSideEffects;
|
|
13388
|
+
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
13389
|
+
this.key.hasEffects(context) ||
|
|
13390
|
+
this.value.hasEffects(context));
|
|
13771
13391
|
}
|
|
13772
13392
|
markDeclarationReached() {
|
|
13773
13393
|
this.value.markDeclarationReached();
|
|
@@ -13778,17 +13398,12 @@ class Property extends MethodBase {
|
|
|
13778
13398
|
}
|
|
13779
13399
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
13780
13400
|
}
|
|
13781
|
-
applyDeoptimizations() {
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
this.computed
|
|
13788
|
-
? [...destructuredInitPath, UnknownKey]
|
|
13789
|
-
: this.key instanceof Identifier
|
|
13790
|
-
? [...destructuredInitPath, this.key.name]
|
|
13791
|
-
: [...destructuredInitPath, String(this.key.value)];
|
|
13401
|
+
applyDeoptimizations() {
|
|
13402
|
+
this.deoptimized = true;
|
|
13403
|
+
if (this.declarationInit !== null) {
|
|
13404
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
13405
|
+
this.scope.context.requestTreeshakingPass();
|
|
13406
|
+
}
|
|
13792
13407
|
}
|
|
13793
13408
|
}
|
|
13794
13409
|
|
|
@@ -13833,9 +13448,9 @@ class ReturnStatement extends NodeBase {
|
|
|
13833
13448
|
context.brokenFlow = true;
|
|
13834
13449
|
return false;
|
|
13835
13450
|
}
|
|
13836
|
-
|
|
13451
|
+
include(context, includeChildrenRecursively) {
|
|
13837
13452
|
this.included = true;
|
|
13838
|
-
this.argument?.
|
|
13453
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
13839
13454
|
context.brokenFlow = true;
|
|
13840
13455
|
}
|
|
13841
13456
|
initialise() {
|
|
@@ -13872,14 +13487,14 @@ class SequenceExpression extends NodeBase {
|
|
|
13872
13487
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13873
13488
|
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13874
13489
|
}
|
|
13875
|
-
|
|
13490
|
+
include(context, includeChildrenRecursively) {
|
|
13876
13491
|
this.included = true;
|
|
13877
13492
|
const lastExpression = this.expressions[this.expressions.length - 1];
|
|
13878
13493
|
for (const expression of this.expressions) {
|
|
13879
13494
|
if (includeChildrenRecursively ||
|
|
13880
13495
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
13881
13496
|
expression.shouldBeIncluded(context))
|
|
13882
|
-
expression.
|
|
13497
|
+
expression.include(context, includeChildrenRecursively);
|
|
13883
13498
|
}
|
|
13884
13499
|
}
|
|
13885
13500
|
removeAnnotations(code) {
|
|
@@ -13927,13 +13542,10 @@ class Super extends NodeBase {
|
|
|
13927
13542
|
deoptimizePath(path) {
|
|
13928
13543
|
this.variable.deoptimizePath(path);
|
|
13929
13544
|
}
|
|
13930
|
-
|
|
13545
|
+
include() {
|
|
13931
13546
|
if (!this.included) {
|
|
13932
13547
|
this.included = true;
|
|
13933
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
13934
|
-
}
|
|
13935
|
-
else if (path.length > 0) {
|
|
13936
|
-
this.variable.includePath(path, context);
|
|
13548
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13937
13549
|
}
|
|
13938
13550
|
}
|
|
13939
13551
|
}
|
|
@@ -13950,12 +13562,12 @@ class SwitchCase extends NodeBase {
|
|
|
13950
13562
|
}
|
|
13951
13563
|
return false;
|
|
13952
13564
|
}
|
|
13953
|
-
|
|
13565
|
+
include(context, includeChildrenRecursively) {
|
|
13954
13566
|
this.included = true;
|
|
13955
|
-
this.test?.
|
|
13567
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
13956
13568
|
for (const node of this.consequent) {
|
|
13957
13569
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
13958
|
-
node.
|
|
13570
|
+
node.include(context, includeChildrenRecursively);
|
|
13959
13571
|
}
|
|
13960
13572
|
}
|
|
13961
13573
|
render(code, options, nodeRenderOptions) {
|
|
@@ -14003,9 +13615,9 @@ class SwitchStatement extends NodeBase {
|
|
|
14003
13615
|
context.hasBreak = hasBreak;
|
|
14004
13616
|
return false;
|
|
14005
13617
|
}
|
|
14006
|
-
|
|
13618
|
+
include(context, includeChildrenRecursively) {
|
|
14007
13619
|
this.included = true;
|
|
14008
|
-
this.discriminant.
|
|
13620
|
+
this.discriminant.include(context, includeChildrenRecursively);
|
|
14009
13621
|
const { brokenFlow, hasBreak } = context;
|
|
14010
13622
|
context.hasBreak = false;
|
|
14011
13623
|
let onlyHasBrokenFlow = true;
|
|
@@ -14022,7 +13634,7 @@ class SwitchStatement extends NodeBase {
|
|
|
14022
13634
|
isCaseIncluded = switchCase.hasEffects(hasEffectsContext);
|
|
14023
13635
|
}
|
|
14024
13636
|
if (isCaseIncluded) {
|
|
14025
|
-
switchCase.
|
|
13637
|
+
switchCase.include(context, includeChildrenRecursively);
|
|
14026
13638
|
onlyHasBrokenFlow &&= context.brokenFlow && !context.hasBreak;
|
|
14027
13639
|
context.hasBreak = false;
|
|
14028
13640
|
context.brokenFlow = brokenFlow;
|
|
@@ -14079,21 +13691,21 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14079
13691
|
return (this.tag.hasEffects(context) ||
|
|
14080
13692
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
14081
13693
|
}
|
|
14082
|
-
|
|
13694
|
+
include(context, includeChildrenRecursively) {
|
|
14083
13695
|
if (!this.deoptimized)
|
|
14084
13696
|
this.applyDeoptimizations();
|
|
14085
13697
|
if (includeChildrenRecursively) {
|
|
14086
|
-
super.
|
|
13698
|
+
super.include(context, includeChildrenRecursively);
|
|
14087
13699
|
}
|
|
14088
13700
|
else {
|
|
14089
13701
|
this.included = true;
|
|
14090
|
-
this.tag.
|
|
14091
|
-
this.quasi.
|
|
13702
|
+
this.tag.include(context, includeChildrenRecursively);
|
|
13703
|
+
this.quasi.include(context, includeChildrenRecursively);
|
|
14092
13704
|
}
|
|
14093
|
-
this.tag.includeCallArguments(context, this.
|
|
13705
|
+
this.tag.includeCallArguments(context, this.args);
|
|
14094
13706
|
const [returnExpression] = this.getReturnExpression();
|
|
14095
13707
|
if (!returnExpression.included) {
|
|
14096
|
-
returnExpression.
|
|
13708
|
+
returnExpression.include(context, false);
|
|
14097
13709
|
}
|
|
14098
13710
|
}
|
|
14099
13711
|
initialise() {
|
|
@@ -14138,7 +13750,7 @@ class TemplateElement extends NodeBase {
|
|
|
14138
13750
|
hasEffects() {
|
|
14139
13751
|
return false;
|
|
14140
13752
|
}
|
|
14141
|
-
|
|
13753
|
+
include() {
|
|
14142
13754
|
this.included = true;
|
|
14143
13755
|
}
|
|
14144
13756
|
parseNode(esTreeNode) {
|
|
@@ -14180,13 +13792,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
14180
13792
|
class ModuleScope extends ChildScope {
|
|
14181
13793
|
constructor(parent, context) {
|
|
14182
13794
|
super(parent, context);
|
|
14183
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
13795
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
14184
13796
|
}
|
|
14185
|
-
addDeclaration(identifier, context, init,
|
|
13797
|
+
addDeclaration(identifier, context, init, kind) {
|
|
14186
13798
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
14187
13799
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
14188
13800
|
}
|
|
14189
|
-
return super.addDeclaration(identifier, context, init,
|
|
13801
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
14190
13802
|
}
|
|
14191
13803
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
14192
13804
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -14231,13 +13843,10 @@ class ThisExpression extends NodeBase {
|
|
|
14231
13843
|
}
|
|
14232
13844
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14233
13845
|
}
|
|
14234
|
-
|
|
13846
|
+
include() {
|
|
14235
13847
|
if (!this.included) {
|
|
14236
13848
|
this.included = true;
|
|
14237
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
14238
|
-
}
|
|
14239
|
-
else if (path.length > 0) {
|
|
14240
|
-
this.variable.includePath(path, context);
|
|
13849
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
14241
13850
|
}
|
|
14242
13851
|
}
|
|
14243
13852
|
initialise() {
|
|
@@ -14264,9 +13873,9 @@ class ThrowStatement extends NodeBase {
|
|
|
14264
13873
|
hasEffects() {
|
|
14265
13874
|
return true;
|
|
14266
13875
|
}
|
|
14267
|
-
|
|
13876
|
+
include(context, includeChildrenRecursively) {
|
|
14268
13877
|
this.included = true;
|
|
14269
|
-
this.argument.
|
|
13878
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
14270
13879
|
context.brokenFlow = true;
|
|
14271
13880
|
}
|
|
14272
13881
|
render(code, options) {
|
|
@@ -14288,13 +13897,13 @@ class TryStatement extends NodeBase {
|
|
|
14288
13897
|
? this.block.body.length > 0
|
|
14289
13898
|
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
14290
13899
|
}
|
|
14291
|
-
|
|
13900
|
+
include(context, includeChildrenRecursively) {
|
|
14292
13901
|
const tryCatchDeoptimization = this.scope.context.options.treeshake?.tryCatchDeoptimization;
|
|
14293
13902
|
const { brokenFlow, includedLabels } = context;
|
|
14294
13903
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
14295
13904
|
this.included = true;
|
|
14296
13905
|
this.directlyIncluded = true;
|
|
14297
|
-
this.block.
|
|
13906
|
+
this.block.include(context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
|
|
14298
13907
|
if (includedLabels.size > 0) {
|
|
14299
13908
|
this.includedLabelsAfterBlock = [...includedLabels];
|
|
14300
13909
|
}
|
|
@@ -14306,10 +13915,10 @@ class TryStatement extends NodeBase {
|
|
|
14306
13915
|
}
|
|
14307
13916
|
}
|
|
14308
13917
|
if (this.handler !== null) {
|
|
14309
|
-
this.handler.
|
|
13918
|
+
this.handler.include(context, includeChildrenRecursively);
|
|
14310
13919
|
context.brokenFlow = brokenFlow;
|
|
14311
13920
|
}
|
|
14312
|
-
this.finalizer?.
|
|
13921
|
+
this.finalizer?.include(context, includeChildrenRecursively);
|
|
14313
13922
|
}
|
|
14314
13923
|
}
|
|
14315
13924
|
|
|
@@ -14367,7 +13976,7 @@ class UpdateExpression extends NodeBase {
|
|
|
14367
13976
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
14368
13977
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14369
13978
|
}
|
|
14370
|
-
|
|
13979
|
+
include(context, includeChildrenRecursively) {
|
|
14371
13980
|
if (!this.deoptimized)
|
|
14372
13981
|
this.applyDeoptimizations();
|
|
14373
13982
|
this.included = true;
|
|
@@ -14436,20 +14045,20 @@ class VariableDeclaration extends NodeBase {
|
|
|
14436
14045
|
hasEffectsOnInteractionAtPath() {
|
|
14437
14046
|
return false;
|
|
14438
14047
|
}
|
|
14439
|
-
|
|
14048
|
+
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14440
14049
|
this.included = true;
|
|
14441
14050
|
for (const declarator of this.declarations) {
|
|
14442
14051
|
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14443
|
-
declarator.
|
|
14052
|
+
declarator.include(context, includeChildrenRecursively);
|
|
14444
14053
|
const { id, init } = declarator;
|
|
14445
14054
|
if (asSingleStatement) {
|
|
14446
|
-
id.
|
|
14055
|
+
id.include(context, includeChildrenRecursively);
|
|
14447
14056
|
}
|
|
14448
14057
|
if (init &&
|
|
14449
14058
|
id.included &&
|
|
14450
14059
|
!init.included &&
|
|
14451
14060
|
(id instanceof ObjectPattern || id instanceof ArrayPattern)) {
|
|
14452
|
-
init.
|
|
14061
|
+
init.include(context, includeChildrenRecursively);
|
|
14453
14062
|
}
|
|
14454
14063
|
}
|
|
14455
14064
|
}
|
|
@@ -14521,7 +14130,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14521
14130
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
14522
14131
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
14523
14132
|
if (!node.included) {
|
|
14524
|
-
|
|
14133
|
+
code.remove(start, end);
|
|
14134
|
+
node.removeAnnotations(code);
|
|
14525
14135
|
continue;
|
|
14526
14136
|
}
|
|
14527
14137
|
node.render(code, options);
|
|
@@ -14598,9 +14208,9 @@ class WhileStatement extends NodeBase {
|
|
|
14598
14208
|
return true;
|
|
14599
14209
|
return hasLoopBodyEffects(context, this.body);
|
|
14600
14210
|
}
|
|
14601
|
-
|
|
14211
|
+
include(context, includeChildrenRecursively) {
|
|
14602
14212
|
this.included = true;
|
|
14603
|
-
this.test.
|
|
14213
|
+
this.test.include(context, includeChildrenRecursively);
|
|
14604
14214
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
14605
14215
|
}
|
|
14606
14216
|
}
|
|
@@ -14844,7 +14454,7 @@ const bufferParsers = [
|
|
|
14844
14454
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
14845
14455
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
14846
14456
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
14847
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14457
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
14848
14458
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
14849
14459
|
},
|
|
14850
14460
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -14890,7 +14500,7 @@ const bufferParsers = [
|
|
|
14890
14500
|
const parameterPosition = buffer[position];
|
|
14891
14501
|
const parameter = (node.param =
|
|
14892
14502
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
14893
|
-
parameter?.declare('parameter',
|
|
14503
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
14894
14504
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
14895
14505
|
},
|
|
14896
14506
|
function chainExpression(node, position, buffer) {
|
|
@@ -15028,7 +14638,7 @@ const bufferParsers = [
|
|
|
15028
14638
|
node.id =
|
|
15029
14639
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
15030
14640
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15031
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14641
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15032
14642
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15033
14643
|
},
|
|
15034
14644
|
function functionExpression(node, position, buffer) {
|
|
@@ -15041,7 +14651,7 @@ const bufferParsers = [
|
|
|
15041
14651
|
const idPosition = buffer[position + 2];
|
|
15042
14652
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
15043
14653
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15044
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
14654
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15045
14655
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15046
14656
|
},
|
|
15047
14657
|
function identifier(node, position, buffer) {
|
|
@@ -15400,8 +15010,8 @@ class UnknownNode extends NodeBase {
|
|
|
15400
15010
|
hasEffects() {
|
|
15401
15011
|
return true;
|
|
15402
15012
|
}
|
|
15403
|
-
|
|
15404
|
-
super.
|
|
15013
|
+
include(context) {
|
|
15014
|
+
super.include(context, true);
|
|
15405
15015
|
}
|
|
15406
15016
|
}
|
|
15407
15017
|
|
|
@@ -15505,8 +15115,8 @@ class ExportShimVariable extends Variable {
|
|
|
15505
15115
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
15506
15116
|
this.module = module;
|
|
15507
15117
|
}
|
|
15508
|
-
|
|
15509
|
-
super.
|
|
15118
|
+
include() {
|
|
15119
|
+
super.include();
|
|
15510
15120
|
this.module.needsExportShim = true;
|
|
15511
15121
|
}
|
|
15512
15122
|
}
|
|
@@ -16197,7 +15807,7 @@ class Module {
|
|
|
16197
15807
|
include() {
|
|
16198
15808
|
const context = createInclusionContext();
|
|
16199
15809
|
if (this.ast.shouldBeIncluded(context))
|
|
16200
|
-
this.ast.
|
|
15810
|
+
this.ast.include(context, false);
|
|
16201
15811
|
}
|
|
16202
15812
|
includeAllExports(includeNamespaceMembers) {
|
|
16203
15813
|
if (!this.isExecuted) {
|
|
@@ -16211,7 +15821,9 @@ class Module {
|
|
|
16211
15821
|
return error(logMissingEntryExport(exportName, this.id));
|
|
16212
15822
|
}
|
|
16213
15823
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16214
|
-
|
|
15824
|
+
if (!variable.included) {
|
|
15825
|
+
this.includeVariable(variable);
|
|
15826
|
+
}
|
|
16215
15827
|
}
|
|
16216
15828
|
}
|
|
16217
15829
|
for (const name of this.getReexports()) {
|
|
@@ -16219,7 +15831,7 @@ class Module {
|
|
|
16219
15831
|
if (variable) {
|
|
16220
15832
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16221
15833
|
if (!variable.included) {
|
|
16222
|
-
this.includeVariable(variable
|
|
15834
|
+
this.includeVariable(variable);
|
|
16223
15835
|
}
|
|
16224
15836
|
if (variable instanceof ExternalVariable) {
|
|
16225
15837
|
variable.module.reexported = true;
|
|
@@ -16231,7 +15843,7 @@ class Module {
|
|
|
16231
15843
|
}
|
|
16232
15844
|
}
|
|
16233
15845
|
includeAllInBundle() {
|
|
16234
|
-
this.ast.
|
|
15846
|
+
this.ast.include(createInclusionContext(), true);
|
|
16235
15847
|
this.includeAllExports(false);
|
|
16236
15848
|
}
|
|
16237
15849
|
includeExportsByNames(names) {
|
|
@@ -16245,7 +15857,7 @@ class Module {
|
|
|
16245
15857
|
if (variable) {
|
|
16246
15858
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16247
15859
|
if (!variable.included) {
|
|
16248
|
-
this.includeVariable(variable
|
|
15860
|
+
this.includeVariable(variable);
|
|
16249
15861
|
}
|
|
16250
15862
|
}
|
|
16251
15863
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
@@ -16687,13 +16299,13 @@ class Module {
|
|
|
16687
16299
|
for (const module of [this, ...this.exportAllModules]) {
|
|
16688
16300
|
if (module instanceof ExternalModule) {
|
|
16689
16301
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
16690
|
-
externalVariable.
|
|
16302
|
+
externalVariable.include();
|
|
16691
16303
|
this.includedImports.add(externalVariable);
|
|
16692
16304
|
externalNamespaces.add(externalVariable);
|
|
16693
16305
|
}
|
|
16694
16306
|
else if (module.info.syntheticNamedExports) {
|
|
16695
16307
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
16696
|
-
syntheticNamespace.
|
|
16308
|
+
syntheticNamespace.include();
|
|
16697
16309
|
this.includedImports.add(syntheticNamespace);
|
|
16698
16310
|
syntheticNamespaces.add(syntheticNamespace);
|
|
16699
16311
|
}
|
|
@@ -16703,9 +16315,7 @@ class Module {
|
|
|
16703
16315
|
includeDynamicImport(node) {
|
|
16704
16316
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
16705
16317
|
if (resolution instanceof Module) {
|
|
16706
|
-
|
|
16707
|
-
resolution.includedDynamicImporters.push(this);
|
|
16708
|
-
}
|
|
16318
|
+
resolution.includedDynamicImporters.push(this);
|
|
16709
16319
|
const importedNames = this.options.treeshake
|
|
16710
16320
|
? node.getDeterministicImportedNames()
|
|
16711
16321
|
: undefined;
|
|
@@ -16717,7 +16327,7 @@ class Module {
|
|
|
16717
16327
|
}
|
|
16718
16328
|
}
|
|
16719
16329
|
}
|
|
16720
|
-
includeVariable(variable
|
|
16330
|
+
includeVariable(variable) {
|
|
16721
16331
|
const variableModule = variable.module;
|
|
16722
16332
|
if (variable.included) {
|
|
16723
16333
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
@@ -16725,6 +16335,7 @@ class Module {
|
|
|
16725
16335
|
}
|
|
16726
16336
|
}
|
|
16727
16337
|
else {
|
|
16338
|
+
variable.include();
|
|
16728
16339
|
this.graph.needsTreeshakingPass = true;
|
|
16729
16340
|
if (variableModule instanceof Module) {
|
|
16730
16341
|
if (!variableModule.isExecuted) {
|
|
@@ -16740,10 +16351,9 @@ class Module {
|
|
|
16740
16351
|
}
|
|
16741
16352
|
}
|
|
16742
16353
|
}
|
|
16743
|
-
variable.includePath(path, createInclusionContext());
|
|
16744
16354
|
}
|
|
16745
|
-
includeVariableInModule(variable
|
|
16746
|
-
this.includeVariable(variable
|
|
16355
|
+
includeVariableInModule(variable) {
|
|
16356
|
+
this.includeVariable(variable);
|
|
16747
16357
|
const variableModule = variable.module;
|
|
16748
16358
|
if (variableModule && variableModule !== this) {
|
|
16749
16359
|
this.includedImports.add(variable);
|
|
@@ -21340,7 +20950,7 @@ class Graph {
|
|
|
21340
20950
|
this.options = options;
|
|
21341
20951
|
this.astLru = flru(5);
|
|
21342
20952
|
this.cachedModules = new Map();
|
|
21343
|
-
this.deoptimizationTracker = new
|
|
20953
|
+
this.deoptimizationTracker = new PathTracker();
|
|
21344
20954
|
this.entryModules = [];
|
|
21345
20955
|
this.modulesById = new Map();
|
|
21346
20956
|
this.needsTreeshakingPass = false;
|
|
@@ -22340,7 +21950,7 @@ createColors();
|
|
|
22340
21950
|
|
|
22341
21951
|
// @see https://no-color.org
|
|
22342
21952
|
// @see https://www.npmjs.com/package/chalk
|
|
22343
|
-
const { bold, cyan, dim, red} = createColors({
|
|
21953
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({
|
|
22344
21954
|
useColor: env$1.FORCE_COLOR !== '0' && !env$1.NO_COLOR
|
|
22345
21955
|
});
|
|
22346
21956
|
|