@rollup/wasm-node 4.27.1 → 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 -880
- 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 -877
- package/dist/shared/watch-cli.js +20 -4
- package/dist/shared/watch.js +3 -3
- package/package.json +1 -1
|
@@ -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,48 +7056,29 @@ 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,
|
|
7079
|
+
super.includeCallArguments(context, parameters);
|
|
7272
7080
|
}
|
|
7273
7081
|
}
|
|
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;
|
|
7281
|
-
}
|
|
7282
|
-
return false;
|
|
7283
|
-
}
|
|
7284
7082
|
initialise() {
|
|
7285
7083
|
super.initialise();
|
|
7286
7084
|
this.propertyKey = getResolvablePropertyKey(this);
|
|
@@ -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,24 +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
|
-
included =
|
|
11038
|
-
element?.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
11039
|
-
}
|
|
11040
|
-
return (this.included ||= included);
|
|
11041
|
-
}
|
|
11042
10812
|
markDeclarationReached() {
|
|
11043
10813
|
for (const element of this.elements) {
|
|
11044
10814
|
element?.markDeclarationReached();
|
|
11045
10815
|
}
|
|
11046
10816
|
}
|
|
11047
10817
|
}
|
|
11048
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
11049
|
-
? destructuredInitPath
|
|
11050
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
11051
10818
|
|
|
11052
10819
|
class ArrowFunctionExpression extends FunctionBase {
|
|
11053
10820
|
constructor() {
|
|
@@ -11096,11 +10863,11 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
11096
10863
|
this.parent.callee === this;
|
|
11097
10864
|
return isIIFE || super.onlyFunctionCallUsed();
|
|
11098
10865
|
}
|
|
11099
|
-
|
|
11100
|
-
super.
|
|
10866
|
+
include(context, includeChildrenRecursively) {
|
|
10867
|
+
super.include(context, includeChildrenRecursively);
|
|
11101
10868
|
for (const parameter of this.params) {
|
|
11102
10869
|
if (!(parameter instanceof Identifier)) {
|
|
11103
|
-
parameter.
|
|
10870
|
+
parameter.include(context, includeChildrenRecursively);
|
|
11104
10871
|
}
|
|
11105
10872
|
}
|
|
11106
10873
|
}
|
|
@@ -11123,18 +10890,13 @@ class ObjectPattern extends NodeBase {
|
|
|
11123
10890
|
}
|
|
11124
10891
|
}
|
|
11125
10892
|
}
|
|
11126
|
-
declare(kind,
|
|
10893
|
+
declare(kind, init) {
|
|
11127
10894
|
const variables = [];
|
|
11128
10895
|
for (const property of this.properties) {
|
|
11129
|
-
variables.push(...property.declare(kind,
|
|
10896
|
+
variables.push(...property.declare(kind, init));
|
|
11130
10897
|
}
|
|
11131
10898
|
return variables;
|
|
11132
10899
|
}
|
|
11133
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11134
|
-
for (const property of this.properties) {
|
|
11135
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
11136
|
-
}
|
|
11137
|
-
}
|
|
11138
10900
|
deoptimizePath(path) {
|
|
11139
10901
|
if (path.length === 0) {
|
|
11140
10902
|
for (const property of this.properties) {
|
|
@@ -11152,44 +10914,11 @@ class ObjectPattern extends NodeBase {
|
|
|
11152
10914
|
}
|
|
11153
10915
|
return false;
|
|
11154
10916
|
}
|
|
11155
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11156
|
-
for (const property of this.properties) {
|
|
11157
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
11158
|
-
return true;
|
|
11159
|
-
}
|
|
11160
|
-
return false;
|
|
11161
|
-
}
|
|
11162
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11163
|
-
let included = false;
|
|
11164
|
-
for (const property of this.properties) {
|
|
11165
|
-
included =
|
|
11166
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
11167
|
-
}
|
|
11168
|
-
return (this.included ||= included);
|
|
11169
|
-
}
|
|
11170
10917
|
markDeclarationReached() {
|
|
11171
10918
|
for (const property of this.properties) {
|
|
11172
10919
|
property.markDeclarationReached();
|
|
11173
10920
|
}
|
|
11174
10921
|
}
|
|
11175
|
-
render(code, options) {
|
|
11176
|
-
if (this.properties.length > 0) {
|
|
11177
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
11178
|
-
let lastSeparatorPos = null;
|
|
11179
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
11180
|
-
if (!node.included) {
|
|
11181
|
-
treeshakeNode(node, code, start, end);
|
|
11182
|
-
continue;
|
|
11183
|
-
}
|
|
11184
|
-
lastSeparatorPos = separator;
|
|
11185
|
-
node.render(code, options);
|
|
11186
|
-
}
|
|
11187
|
-
if (lastSeparatorPos) {
|
|
11188
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
11189
|
-
}
|
|
11190
|
-
}
|
|
11191
|
-
}
|
|
11192
|
-
applyDeoptimizations() { }
|
|
11193
10922
|
}
|
|
11194
10923
|
|
|
11195
10924
|
class AssignmentExpression extends NodeBase {
|
|
@@ -11199,27 +10928,23 @@ class AssignmentExpression extends NodeBase {
|
|
|
11199
10928
|
this.applyDeoptimizations();
|
|
11200
10929
|
// MemberExpressions do not access the property before assignments if the
|
|
11201
10930
|
// operator is '='.
|
|
11202
|
-
return (right.hasEffects(context) ||
|
|
11203
|
-
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
11204
|
-
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
10931
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, operator !== '='));
|
|
11205
10932
|
}
|
|
11206
10933
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11207
10934
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11208
10935
|
}
|
|
11209
|
-
|
|
10936
|
+
include(context, includeChildrenRecursively) {
|
|
11210
10937
|
const { deoptimized, left, right, operator } = this;
|
|
11211
10938
|
if (!deoptimized)
|
|
11212
10939
|
this.applyDeoptimizations();
|
|
11213
10940
|
this.included = true;
|
|
11214
|
-
const hasEffectsContext = createHasEffectsContext();
|
|
11215
10941
|
if (includeChildrenRecursively ||
|
|
11216
10942
|
operator !== '=' ||
|
|
11217
10943
|
left.included ||
|
|
11218
|
-
left.hasEffectsAsAssignmentTarget(
|
|
11219
|
-
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
10944
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
11220
10945
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
11221
10946
|
}
|
|
11222
|
-
right.
|
|
10947
|
+
right.include(context, includeChildrenRecursively);
|
|
11223
10948
|
}
|
|
11224
10949
|
initialise() {
|
|
11225
10950
|
super.initialise();
|
|
@@ -11281,7 +11006,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
11281
11006
|
}
|
|
11282
11007
|
applyDeoptimizations() {
|
|
11283
11008
|
this.deoptimized = true;
|
|
11284
|
-
this.left.
|
|
11009
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
11010
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
11285
11011
|
this.scope.context.requestTreeshakingPass();
|
|
11286
11012
|
}
|
|
11287
11013
|
}
|
|
@@ -11290,11 +11016,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
11290
11016
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
11291
11017
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
11292
11018
|
}
|
|
11293
|
-
declare(kind,
|
|
11294
|
-
return this.left.declare(kind,
|
|
11295
|
-
}
|
|
11296
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
11297
|
-
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
11019
|
+
declare(kind, init) {
|
|
11020
|
+
return this.left.declare(kind, init);
|
|
11298
11021
|
}
|
|
11299
11022
|
deoptimizePath(path) {
|
|
11300
11023
|
if (path.length === 0) {
|
|
@@ -11304,17 +11027,6 @@ class AssignmentPattern extends NodeBase {
|
|
|
11304
11027
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11305
11028
|
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
11306
11029
|
}
|
|
11307
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
11308
|
-
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
11309
|
-
}
|
|
11310
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
11311
|
-
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
11312
|
-
this.included;
|
|
11313
|
-
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
11314
|
-
this.right.includePath(UNKNOWN_PATH, context, false);
|
|
11315
|
-
}
|
|
11316
|
-
return (this.included = included);
|
|
11317
|
-
}
|
|
11318
11030
|
markDeclarationReached() {
|
|
11319
11031
|
this.left.markDeclarationReached();
|
|
11320
11032
|
}
|
|
@@ -11336,7 +11048,7 @@ class AwaitExpression extends NodeBase {
|
|
|
11336
11048
|
this.applyDeoptimizations();
|
|
11337
11049
|
return true;
|
|
11338
11050
|
}
|
|
11339
|
-
|
|
11051
|
+
include(context, includeChildrenRecursively) {
|
|
11340
11052
|
if (!this.deoptimized)
|
|
11341
11053
|
this.applyDeoptimizations();
|
|
11342
11054
|
if (!this.included) {
|
|
@@ -11350,7 +11062,7 @@ class AwaitExpression extends NodeBase {
|
|
|
11350
11062
|
this.scope.context.usesTopLevelAwait = true;
|
|
11351
11063
|
}
|
|
11352
11064
|
}
|
|
11353
|
-
this.argument.
|
|
11065
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
11354
11066
|
}
|
|
11355
11067
|
}
|
|
11356
11068
|
|
|
@@ -11432,10 +11144,10 @@ class BreakStatement extends NodeBase {
|
|
|
11432
11144
|
context.brokenFlow = true;
|
|
11433
11145
|
return false;
|
|
11434
11146
|
}
|
|
11435
|
-
|
|
11147
|
+
include(context) {
|
|
11436
11148
|
this.included = true;
|
|
11437
11149
|
if (this.label) {
|
|
11438
|
-
this.label.
|
|
11150
|
+
this.label.include();
|
|
11439
11151
|
context.includedLabels.add(this.label.name);
|
|
11440
11152
|
}
|
|
11441
11153
|
else {
|
|
@@ -11629,11 +11341,11 @@ class CallExpression extends CallExpressionBase {
|
|
|
11629
11341
|
(calleeHasEffects ||
|
|
11630
11342
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
11631
11343
|
}
|
|
11632
|
-
|
|
11344
|
+
include(context, includeChildrenRecursively) {
|
|
11633
11345
|
if (!this.deoptimized)
|
|
11634
11346
|
this.applyDeoptimizations();
|
|
11635
11347
|
if (includeChildrenRecursively) {
|
|
11636
|
-
super.
|
|
11348
|
+
super.include(context, includeChildrenRecursively);
|
|
11637
11349
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
11638
11350
|
this.callee instanceof Identifier &&
|
|
11639
11351
|
this.callee.variable) {
|
|
@@ -11642,18 +11354,9 @@ class CallExpression extends CallExpressionBase {
|
|
|
11642
11354
|
}
|
|
11643
11355
|
else {
|
|
11644
11356
|
this.included = true;
|
|
11645
|
-
|
|
11646
|
-
// object will already be included via the first argument of the
|
|
11647
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
11648
|
-
// severe performance problems.
|
|
11649
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
11650
|
-
this.callee.property.includePath(UNKNOWN_PATH, context, false);
|
|
11651
|
-
}
|
|
11652
|
-
else {
|
|
11653
|
-
this.callee.includePath(UNKNOWN_PATH, context, false);
|
|
11654
|
-
}
|
|
11655
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
11357
|
+
this.callee.include(context, false);
|
|
11656
11358
|
}
|
|
11359
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
11657
11360
|
}
|
|
11658
11361
|
initialise() {
|
|
11659
11362
|
super.initialise();
|
|
@@ -11692,7 +11395,7 @@ class CatchClause extends NodeBase {
|
|
|
11692
11395
|
this.type = type;
|
|
11693
11396
|
if (param) {
|
|
11694
11397
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
11695
|
-
this.param.declare('parameter',
|
|
11398
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
11696
11399
|
}
|
|
11697
11400
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
11698
11401
|
return super.parseNode(esTreeNode);
|
|
@@ -11720,7 +11423,7 @@ class ClassBodyScope extends ChildScope {
|
|
|
11720
11423
|
constructor(parent, classNode) {
|
|
11721
11424
|
const { context } = parent;
|
|
11722
11425
|
super(parent, context);
|
|
11723
|
-
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')));
|
|
11724
11427
|
this.instanceScope = new ChildScope(this, context);
|
|
11725
11428
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
11726
11429
|
}
|
|
@@ -11733,11 +11436,11 @@ class ClassBody extends NodeBase {
|
|
|
11733
11436
|
createScope(parentScope) {
|
|
11734
11437
|
this.scope = new ClassBodyScope(parentScope, this.parent);
|
|
11735
11438
|
}
|
|
11736
|
-
|
|
11439
|
+
include(context, includeChildrenRecursively) {
|
|
11737
11440
|
this.included = true;
|
|
11738
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
11441
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
11739
11442
|
for (const definition of this.body) {
|
|
11740
|
-
definition.
|
|
11443
|
+
definition.include(context, includeChildrenRecursively);
|
|
11741
11444
|
}
|
|
11742
11445
|
}
|
|
11743
11446
|
parseNode(esTreeNode) {
|
|
@@ -11861,26 +11564,26 @@ class ConditionalExpression extends NodeBase {
|
|
|
11861
11564
|
}
|
|
11862
11565
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11863
11566
|
}
|
|
11864
|
-
|
|
11567
|
+
include(context, includeChildrenRecursively) {
|
|
11865
11568
|
this.included = true;
|
|
11866
11569
|
const usedBranch = this.getUsedBranch();
|
|
11867
11570
|
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
11868
|
-
this.test.
|
|
11869
|
-
this.consequent.
|
|
11870
|
-
this.alternate.
|
|
11571
|
+
this.test.include(context, includeChildrenRecursively);
|
|
11572
|
+
this.consequent.include(context, includeChildrenRecursively);
|
|
11573
|
+
this.alternate.include(context, includeChildrenRecursively);
|
|
11871
11574
|
}
|
|
11872
11575
|
else {
|
|
11873
|
-
usedBranch.
|
|
11576
|
+
usedBranch.include(context, includeChildrenRecursively);
|
|
11874
11577
|
}
|
|
11875
11578
|
}
|
|
11876
|
-
includeCallArguments(context,
|
|
11579
|
+
includeCallArguments(context, parameters) {
|
|
11877
11580
|
const usedBranch = this.getUsedBranch();
|
|
11878
11581
|
if (usedBranch) {
|
|
11879
|
-
usedBranch.includeCallArguments(context,
|
|
11582
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
11880
11583
|
}
|
|
11881
11584
|
else {
|
|
11882
|
-
this.consequent.includeCallArguments(context,
|
|
11883
|
-
this.alternate.includeCallArguments(context,
|
|
11585
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
11586
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
11884
11587
|
}
|
|
11885
11588
|
}
|
|
11886
11589
|
removeAnnotations(code) {
|
|
@@ -11941,10 +11644,10 @@ class ContinueStatement extends NodeBase {
|
|
|
11941
11644
|
context.brokenFlow = true;
|
|
11942
11645
|
return false;
|
|
11943
11646
|
}
|
|
11944
|
-
|
|
11647
|
+
include(context) {
|
|
11945
11648
|
this.included = true;
|
|
11946
11649
|
if (this.label) {
|
|
11947
|
-
this.label.
|
|
11650
|
+
this.label.include();
|
|
11948
11651
|
context.includedLabels.add(this.label.name);
|
|
11949
11652
|
}
|
|
11950
11653
|
else {
|
|
@@ -11987,7 +11690,7 @@ function includeLoopBody(context, body, includeChildrenRecursively) {
|
|
|
11987
11690
|
const { brokenFlow, hasBreak, hasContinue } = context;
|
|
11988
11691
|
context.hasBreak = false;
|
|
11989
11692
|
context.hasContinue = false;
|
|
11990
|
-
body.
|
|
11693
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
11991
11694
|
context.hasBreak = hasBreak;
|
|
11992
11695
|
context.hasContinue = hasContinue;
|
|
11993
11696
|
context.brokenFlow = brokenFlow;
|
|
@@ -11999,9 +11702,9 @@ class DoWhileStatement extends NodeBase {
|
|
|
11999
11702
|
return true;
|
|
12000
11703
|
return hasLoopBodyEffects(context, this.body);
|
|
12001
11704
|
}
|
|
12002
|
-
|
|
11705
|
+
include(context, includeChildrenRecursively) {
|
|
12003
11706
|
this.included = true;
|
|
12004
|
-
this.test.
|
|
11707
|
+
this.test.include(context, includeChildrenRecursively);
|
|
12005
11708
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12006
11709
|
}
|
|
12007
11710
|
}
|
|
@@ -12072,13 +11775,13 @@ class ForInStatement extends NodeBase {
|
|
|
12072
11775
|
return true;
|
|
12073
11776
|
return hasLoopBodyEffects(context, body);
|
|
12074
11777
|
}
|
|
12075
|
-
|
|
11778
|
+
include(context, includeChildrenRecursively) {
|
|
12076
11779
|
const { body, deoptimized, left, right } = this;
|
|
12077
11780
|
if (!deoptimized)
|
|
12078
11781
|
this.applyDeoptimizations();
|
|
12079
11782
|
this.included = true;
|
|
12080
11783
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12081
|
-
right.
|
|
11784
|
+
right.include(context, includeChildrenRecursively);
|
|
12082
11785
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12083
11786
|
}
|
|
12084
11787
|
initialise() {
|
|
@@ -12117,13 +11820,13 @@ class ForOfStatement extends NodeBase {
|
|
|
12117
11820
|
// Placeholder until proper Symbol.Iterator support
|
|
12118
11821
|
return true;
|
|
12119
11822
|
}
|
|
12120
|
-
|
|
11823
|
+
include(context, includeChildrenRecursively) {
|
|
12121
11824
|
const { body, deoptimized, left, right } = this;
|
|
12122
11825
|
if (!deoptimized)
|
|
12123
11826
|
this.applyDeoptimizations();
|
|
12124
11827
|
this.included = true;
|
|
12125
11828
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
12126
|
-
right.
|
|
11829
|
+
right.include(context, includeChildrenRecursively);
|
|
12127
11830
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
12128
11831
|
}
|
|
12129
11832
|
initialise() {
|
|
@@ -12159,13 +11862,11 @@ class ForStatement extends NodeBase {
|
|
|
12159
11862
|
}
|
|
12160
11863
|
return hasLoopBodyEffects(context, this.body);
|
|
12161
11864
|
}
|
|
12162
|
-
|
|
11865
|
+
include(context, includeChildrenRecursively) {
|
|
12163
11866
|
this.included = true;
|
|
12164
|
-
this.init?.
|
|
12165
|
-
|
|
12166
|
-
|
|
12167
|
-
this.test?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
12168
|
-
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);
|
|
12169
11870
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
12170
11871
|
}
|
|
12171
11872
|
render(code, options) {
|
|
@@ -12206,9 +11907,9 @@ class TrackingScope extends BlockScope {
|
|
|
12206
11907
|
super(...arguments);
|
|
12207
11908
|
this.hoistedDeclarations = [];
|
|
12208
11909
|
}
|
|
12209
|
-
addDeclaration(identifier, context, init,
|
|
11910
|
+
addDeclaration(identifier, context, init, kind) {
|
|
12210
11911
|
this.hoistedDeclarations.push(identifier);
|
|
12211
|
-
return super.addDeclaration(identifier, context, init,
|
|
11912
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
12212
11913
|
}
|
|
12213
11914
|
}
|
|
12214
11915
|
|
|
@@ -12241,7 +11942,7 @@ class IfStatement extends NodeBase {
|
|
|
12241
11942
|
}
|
|
12242
11943
|
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
12243
11944
|
}
|
|
12244
|
-
|
|
11945
|
+
include(context, includeChildrenRecursively) {
|
|
12245
11946
|
this.included = true;
|
|
12246
11947
|
if (includeChildrenRecursively) {
|
|
12247
11948
|
this.includeRecursively(includeChildrenRecursively, context);
|
|
@@ -12316,31 +12017,31 @@ class IfStatement extends NodeBase {
|
|
|
12316
12017
|
}
|
|
12317
12018
|
includeKnownTest(context, testValue) {
|
|
12318
12019
|
if (this.test.shouldBeIncluded(context)) {
|
|
12319
|
-
this.test.
|
|
12020
|
+
this.test.include(context, false);
|
|
12320
12021
|
}
|
|
12321
12022
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
12322
|
-
this.consequent.
|
|
12023
|
+
this.consequent.include(context, false, { asSingleStatement: true });
|
|
12323
12024
|
}
|
|
12324
12025
|
if (!testValue && this.alternate?.shouldBeIncluded(context)) {
|
|
12325
|
-
this.alternate.
|
|
12026
|
+
this.alternate.include(context, false, { asSingleStatement: true });
|
|
12326
12027
|
}
|
|
12327
12028
|
}
|
|
12328
12029
|
includeRecursively(includeChildrenRecursively, context) {
|
|
12329
|
-
this.test.
|
|
12330
|
-
this.consequent.
|
|
12331
|
-
this.alternate?.
|
|
12030
|
+
this.test.include(context, includeChildrenRecursively);
|
|
12031
|
+
this.consequent.include(context, includeChildrenRecursively);
|
|
12032
|
+
this.alternate?.include(context, includeChildrenRecursively);
|
|
12332
12033
|
}
|
|
12333
12034
|
includeUnknownTest(context) {
|
|
12334
|
-
this.test.
|
|
12035
|
+
this.test.include(context, false);
|
|
12335
12036
|
const { brokenFlow } = context;
|
|
12336
12037
|
let consequentBrokenFlow = false;
|
|
12337
12038
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
12338
|
-
this.consequent.
|
|
12039
|
+
this.consequent.include(context, false, { asSingleStatement: true });
|
|
12339
12040
|
consequentBrokenFlow = context.brokenFlow;
|
|
12340
12041
|
context.brokenFlow = brokenFlow;
|
|
12341
12042
|
}
|
|
12342
12043
|
if (this.alternate?.shouldBeIncluded(context)) {
|
|
12343
|
-
this.alternate.
|
|
12044
|
+
this.alternate.include(context, false, { asSingleStatement: true });
|
|
12344
12045
|
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
12345
12046
|
}
|
|
12346
12047
|
}
|
|
@@ -12408,7 +12109,7 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
12408
12109
|
class VariableDeclarator extends NodeBase {
|
|
12409
12110
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
12410
12111
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
12411
|
-
this.id.declare(kind,
|
|
12112
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
12412
12113
|
}
|
|
12413
12114
|
deoptimizePath(path) {
|
|
12414
12115
|
this.id.deoptimizePath(path);
|
|
@@ -12418,25 +12119,17 @@ class VariableDeclarator extends NodeBase {
|
|
|
12418
12119
|
this.applyDeoptimizations();
|
|
12419
12120
|
const initEffect = this.init?.hasEffects(context);
|
|
12420
12121
|
this.id.markDeclarationReached();
|
|
12421
|
-
return
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
(this.scope.context.options.treeshake
|
|
12425
|
-
.propertyReadSideEffects &&
|
|
12426
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
12427
|
-
}
|
|
12428
|
-
includePath(_path, context, includeChildrenRecursively) {
|
|
12122
|
+
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
12123
|
+
}
|
|
12124
|
+
include(context, includeChildrenRecursively) {
|
|
12429
12125
|
const { deoptimized, id, init } = this;
|
|
12430
12126
|
if (!deoptimized)
|
|
12431
12127
|
this.applyDeoptimizations();
|
|
12432
12128
|
this.included = true;
|
|
12433
|
-
init?.
|
|
12129
|
+
init?.include(context, includeChildrenRecursively);
|
|
12434
12130
|
id.markDeclarationReached();
|
|
12435
|
-
if (includeChildrenRecursively) {
|
|
12436
|
-
id.
|
|
12437
|
-
}
|
|
12438
|
-
else {
|
|
12439
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
12131
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
12132
|
+
id.include(context, includeChildrenRecursively);
|
|
12440
12133
|
}
|
|
12441
12134
|
}
|
|
12442
12135
|
removeAnnotations(code) {
|
|
@@ -12485,8 +12178,6 @@ class ImportExpression extends NodeBase {
|
|
|
12485
12178
|
constructor() {
|
|
12486
12179
|
super(...arguments);
|
|
12487
12180
|
this.inlineNamespace = null;
|
|
12488
|
-
this.hasUnknownAccessedKey = false;
|
|
12489
|
-
this.accessedPropKey = new Set();
|
|
12490
12181
|
this.attributes = null;
|
|
12491
12182
|
this.mechanism = null;
|
|
12492
12183
|
this.namespaceExportName = undefined;
|
|
@@ -12519,15 +12210,12 @@ class ImportExpression extends NodeBase {
|
|
|
12519
12210
|
if (parent2 instanceof ExpressionStatement) {
|
|
12520
12211
|
return EMPTY_ARRAY;
|
|
12521
12212
|
}
|
|
12522
|
-
// Case 1: const { foo }
|
|
12213
|
+
// Case 1: const { foo } = await import('bar')
|
|
12523
12214
|
if (parent2 instanceof VariableDeclarator) {
|
|
12524
12215
|
const declaration = parent2.id;
|
|
12525
|
-
|
|
12526
|
-
|
|
12527
|
-
|
|
12528
|
-
if (declaration instanceof ObjectPattern) {
|
|
12529
|
-
return getDeterministicObjectDestructure(declaration);
|
|
12530
|
-
}
|
|
12216
|
+
return declaration instanceof ObjectPattern
|
|
12217
|
+
? getDeterministicObjectDestructure(declaration)
|
|
12218
|
+
: undefined;
|
|
12531
12219
|
}
|
|
12532
12220
|
// Case 2: (await import('bar')).foo
|
|
12533
12221
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -12576,23 +12264,13 @@ class ImportExpression extends NodeBase {
|
|
|
12576
12264
|
hasEffects() {
|
|
12577
12265
|
return true;
|
|
12578
12266
|
}
|
|
12579
|
-
|
|
12267
|
+
include(context, includeChildrenRecursively) {
|
|
12580
12268
|
if (!this.included) {
|
|
12581
12269
|
this.included = true;
|
|
12582
12270
|
this.scope.context.includeDynamicImport(this);
|
|
12583
12271
|
this.scope.addAccessedDynamicImport(this);
|
|
12584
|
-
this.source.includePath(path, context, includeChildrenRecursively);
|
|
12585
|
-
}
|
|
12586
|
-
if (this.hasUnknownAccessedKey)
|
|
12587
|
-
return;
|
|
12588
|
-
if (path[0] === UnknownKey) {
|
|
12589
|
-
this.hasUnknownAccessedKey = true;
|
|
12590
|
-
this.scope.context.includeDynamicImport(this);
|
|
12591
|
-
}
|
|
12592
|
-
else if (typeof path[0] === 'string') {
|
|
12593
|
-
this.accessedPropKey.add(path[0]);
|
|
12594
|
-
this.scope.context.includeDynamicImport(this);
|
|
12595
12272
|
}
|
|
12273
|
+
this.source.include(context, includeChildrenRecursively);
|
|
12596
12274
|
}
|
|
12597
12275
|
initialise() {
|
|
12598
12276
|
super.initialise();
|
|
@@ -12920,7 +12598,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12920
12598
|
if (preserve) {
|
|
12921
12599
|
// This pretends we are accessing an included global variable of the same name
|
|
12922
12600
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
12923
|
-
globalVariable.
|
|
12601
|
+
globalVariable.include();
|
|
12924
12602
|
// This excludes this variable from renaming
|
|
12925
12603
|
factoryVariable.globalName = baseName;
|
|
12926
12604
|
}
|
|
@@ -12928,7 +12606,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
12928
12606
|
else {
|
|
12929
12607
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
12930
12608
|
}
|
|
12931
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
12609
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
12932
12610
|
if (factoryVariable instanceof LocalVariable) {
|
|
12933
12611
|
factoryVariable.consolidateInitializers();
|
|
12934
12612
|
factoryVariable.addUsedPlace(node);
|
|
@@ -12950,7 +12628,7 @@ class JSXElementBase extends NodeBase {
|
|
|
12950
12628
|
this.scope.context.addImportSource(importSource);
|
|
12951
12629
|
}
|
|
12952
12630
|
}
|
|
12953
|
-
|
|
12631
|
+
include(context, includeChildrenRecursively) {
|
|
12954
12632
|
if (!this.included) {
|
|
12955
12633
|
const { factory, importSource, mode } = this.jsxMode;
|
|
12956
12634
|
if (factory) {
|
|
@@ -12958,7 +12636,7 @@ class JSXElementBase extends NodeBase {
|
|
|
12958
12636
|
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
12959
12637
|
}
|
|
12960
12638
|
}
|
|
12961
|
-
super.
|
|
12639
|
+
super.include(context, includeChildrenRecursively);
|
|
12962
12640
|
}
|
|
12963
12641
|
applyDeoptimizations() { }
|
|
12964
12642
|
getRenderingMode() {
|
|
@@ -13220,7 +12898,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13220
12898
|
this.fragment = null;
|
|
13221
12899
|
this.fragmentVariable = null;
|
|
13222
12900
|
}
|
|
13223
|
-
|
|
12901
|
+
include(context, includeChildrenRecursively) {
|
|
13224
12902
|
if (!this.included) {
|
|
13225
12903
|
const jsx = this.scope.context.options.jsx;
|
|
13226
12904
|
if (jsx.mode === 'automatic') {
|
|
@@ -13235,7 +12913,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
13235
12913
|
}
|
|
13236
12914
|
}
|
|
13237
12915
|
}
|
|
13238
|
-
super.
|
|
12916
|
+
super.include(context, includeChildrenRecursively);
|
|
13239
12917
|
}
|
|
13240
12918
|
render(code, options) {
|
|
13241
12919
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -13292,13 +12970,13 @@ class LabeledStatement extends NodeBase {
|
|
|
13292
12970
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
13293
12971
|
return bodyHasEffects;
|
|
13294
12972
|
}
|
|
13295
|
-
|
|
12973
|
+
include(context, includeChildrenRecursively) {
|
|
13296
12974
|
this.included = true;
|
|
13297
12975
|
const { brokenFlow, includedLabels } = context;
|
|
13298
12976
|
context.includedLabels = new Set();
|
|
13299
|
-
this.body.
|
|
12977
|
+
this.body.include(context, includeChildrenRecursively);
|
|
13300
12978
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
13301
|
-
this.label.
|
|
12979
|
+
this.label.include();
|
|
13302
12980
|
context.includedLabels.delete(this.label.name);
|
|
13303
12981
|
context.brokenFlow = brokenFlow;
|
|
13304
12982
|
}
|
|
@@ -13395,17 +13073,17 @@ class LogicalExpression extends NodeBase {
|
|
|
13395
13073
|
}
|
|
13396
13074
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13397
13075
|
}
|
|
13398
|
-
|
|
13076
|
+
include(context, includeChildrenRecursively) {
|
|
13399
13077
|
this.included = true;
|
|
13400
13078
|
const usedBranch = this.getUsedBranch();
|
|
13401
13079
|
if (includeChildrenRecursively ||
|
|
13402
13080
|
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
13403
13081
|
!usedBranch) {
|
|
13404
|
-
this.left.
|
|
13405
|
-
this.right.
|
|
13082
|
+
this.left.include(context, includeChildrenRecursively);
|
|
13083
|
+
this.right.include(context, includeChildrenRecursively);
|
|
13406
13084
|
}
|
|
13407
13085
|
else {
|
|
13408
|
-
usedBranch.
|
|
13086
|
+
usedBranch.include(context, includeChildrenRecursively);
|
|
13409
13087
|
}
|
|
13410
13088
|
}
|
|
13411
13089
|
removeAnnotations(code) {
|
|
@@ -13477,17 +13155,17 @@ class NewExpression extends NodeBase {
|
|
|
13477
13155
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
13478
13156
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
13479
13157
|
}
|
|
13480
|
-
|
|
13158
|
+
include(context, includeChildrenRecursively) {
|
|
13481
13159
|
if (!this.deoptimized)
|
|
13482
13160
|
this.applyDeoptimizations();
|
|
13483
13161
|
if (includeChildrenRecursively) {
|
|
13484
|
-
super.
|
|
13162
|
+
super.include(context, includeChildrenRecursively);
|
|
13485
13163
|
}
|
|
13486
13164
|
else {
|
|
13487
13165
|
this.included = true;
|
|
13488
|
-
this.callee.
|
|
13166
|
+
this.callee.include(context, false);
|
|
13489
13167
|
}
|
|
13490
|
-
this.callee.includeCallArguments(context, this.
|
|
13168
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13491
13169
|
}
|
|
13492
13170
|
initialise() {
|
|
13493
13171
|
super.initialise();
|
|
@@ -13516,7 +13194,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13516
13194
|
constructor() {
|
|
13517
13195
|
super(...arguments);
|
|
13518
13196
|
this.objectEntity = null;
|
|
13519
|
-
this.protoProp = null;
|
|
13520
13197
|
}
|
|
13521
13198
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
13522
13199
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -13536,32 +13213,13 @@ class ObjectExpression extends NodeBase {
|
|
|
13536
13213
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13537
13214
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13538
13215
|
}
|
|
13539
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
13540
|
-
this.included = true;
|
|
13541
|
-
this.getObjectEntity().includePath(path, context, includeChildrenRecursively);
|
|
13542
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13543
|
-
}
|
|
13544
13216
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
13217
|
+
super.render(code, options);
|
|
13545
13218
|
if (renderedSurroundingElement === ExpressionStatement$1 ||
|
|
13546
13219
|
renderedSurroundingElement === ArrowFunctionExpression$1) {
|
|
13547
13220
|
code.appendRight(this.start, '(');
|
|
13548
13221
|
code.prependLeft(this.end, ')');
|
|
13549
13222
|
}
|
|
13550
|
-
if (this.properties.length > 0) {
|
|
13551
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
13552
|
-
let lastSeparatorPos = null;
|
|
13553
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
13554
|
-
if (!node.included) {
|
|
13555
|
-
treeshakeNode(node, code, start, end);
|
|
13556
|
-
continue;
|
|
13557
|
-
}
|
|
13558
|
-
lastSeparatorPos = separator;
|
|
13559
|
-
node.render(code, options);
|
|
13560
|
-
}
|
|
13561
|
-
if (lastSeparatorPos) {
|
|
13562
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
13563
|
-
}
|
|
13564
|
-
}
|
|
13565
13223
|
}
|
|
13566
13224
|
applyDeoptimizations() { }
|
|
13567
13225
|
getObjectEntity() {
|
|
@@ -13592,7 +13250,6 @@ class ObjectExpression extends NodeBase {
|
|
|
13592
13250
|
? property.key.name
|
|
13593
13251
|
: String(property.key.value);
|
|
13594
13252
|
if (key === '__proto__' && property.kind === 'init') {
|
|
13595
|
-
this.protoProp = property;
|
|
13596
13253
|
prototype =
|
|
13597
13254
|
property.value instanceof Literal && property.value.value === null
|
|
13598
13255
|
? null
|
|
@@ -13659,11 +13316,11 @@ class Program extends NodeBase {
|
|
|
13659
13316
|
}
|
|
13660
13317
|
return false;
|
|
13661
13318
|
}
|
|
13662
|
-
|
|
13319
|
+
include(context, includeChildrenRecursively) {
|
|
13663
13320
|
this.included = true;
|
|
13664
13321
|
for (const node of this.body) {
|
|
13665
13322
|
if (includeChildrenRecursively || node.shouldBeIncluded(context)) {
|
|
13666
|
-
node.
|
|
13323
|
+
node.include(context, includeChildrenRecursively);
|
|
13667
13324
|
}
|
|
13668
13325
|
}
|
|
13669
13326
|
}
|
|
@@ -13702,6 +13359,10 @@ class Program extends NodeBase {
|
|
|
13702
13359
|
}
|
|
13703
13360
|
|
|
13704
13361
|
class Property extends MethodBase {
|
|
13362
|
+
constructor() {
|
|
13363
|
+
super(...arguments);
|
|
13364
|
+
this.declarationInit = null;
|
|
13365
|
+
}
|
|
13705
13366
|
//declare method: boolean;
|
|
13706
13367
|
get method() {
|
|
13707
13368
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -13716,32 +13377,17 @@ class Property extends MethodBase {
|
|
|
13716
13377
|
set shorthand(value) {
|
|
13717
13378
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
13718
13379
|
}
|
|
13719
|
-
declare(kind,
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
13723
|
-
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
13380
|
+
declare(kind, init) {
|
|
13381
|
+
this.declarationInit = init;
|
|
13382
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
13724
13383
|
}
|
|
13725
13384
|
hasEffects(context) {
|
|
13726
13385
|
if (!this.deoptimized)
|
|
13727
13386
|
this.applyDeoptimizations();
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
}
|
|
13733
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
13734
|
-
let included = this.value.includeDestructuredIfNecessary(context, this.getPathInProperty(destructuredInitPath), init) || this.included;
|
|
13735
|
-
included ||= this.key.hasEffects(createHasEffectsContext());
|
|
13736
|
-
if (included) {
|
|
13737
|
-
this.key.includePath(EMPTY_PATH, context, false);
|
|
13738
|
-
}
|
|
13739
|
-
return (this.included = included);
|
|
13740
|
-
}
|
|
13741
|
-
includePath(path, context, includeChildrenRecursively) {
|
|
13742
|
-
this.included = true;
|
|
13743
|
-
this.key.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
13744
|
-
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));
|
|
13745
13391
|
}
|
|
13746
13392
|
markDeclarationReached() {
|
|
13747
13393
|
this.value.markDeclarationReached();
|
|
@@ -13752,17 +13398,12 @@ class Property extends MethodBase {
|
|
|
13752
13398
|
}
|
|
13753
13399
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
13754
13400
|
}
|
|
13755
|
-
applyDeoptimizations() {
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
this.computed
|
|
13762
|
-
? [...destructuredInitPath, UnknownKey]
|
|
13763
|
-
: this.key instanceof Identifier
|
|
13764
|
-
? [...destructuredInitPath, this.key.name]
|
|
13765
|
-
: [...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
|
+
}
|
|
13766
13407
|
}
|
|
13767
13408
|
}
|
|
13768
13409
|
|
|
@@ -13807,9 +13448,9 @@ class ReturnStatement extends NodeBase {
|
|
|
13807
13448
|
context.brokenFlow = true;
|
|
13808
13449
|
return false;
|
|
13809
13450
|
}
|
|
13810
|
-
|
|
13451
|
+
include(context, includeChildrenRecursively) {
|
|
13811
13452
|
this.included = true;
|
|
13812
|
-
this.argument?.
|
|
13453
|
+
this.argument?.include(context, includeChildrenRecursively);
|
|
13813
13454
|
context.brokenFlow = true;
|
|
13814
13455
|
}
|
|
13815
13456
|
initialise() {
|
|
@@ -13846,14 +13487,14 @@ class SequenceExpression extends NodeBase {
|
|
|
13846
13487
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
13847
13488
|
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13848
13489
|
}
|
|
13849
|
-
|
|
13490
|
+
include(context, includeChildrenRecursively) {
|
|
13850
13491
|
this.included = true;
|
|
13851
13492
|
const lastExpression = this.expressions[this.expressions.length - 1];
|
|
13852
13493
|
for (const expression of this.expressions) {
|
|
13853
13494
|
if (includeChildrenRecursively ||
|
|
13854
13495
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
13855
13496
|
expression.shouldBeIncluded(context))
|
|
13856
|
-
expression.
|
|
13497
|
+
expression.include(context, includeChildrenRecursively);
|
|
13857
13498
|
}
|
|
13858
13499
|
}
|
|
13859
13500
|
removeAnnotations(code) {
|
|
@@ -13901,13 +13542,10 @@ class Super extends NodeBase {
|
|
|
13901
13542
|
deoptimizePath(path) {
|
|
13902
13543
|
this.variable.deoptimizePath(path);
|
|
13903
13544
|
}
|
|
13904
|
-
|
|
13545
|
+
include() {
|
|
13905
13546
|
if (!this.included) {
|
|
13906
13547
|
this.included = true;
|
|
13907
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
13908
|
-
}
|
|
13909
|
-
else if (path.length > 0) {
|
|
13910
|
-
this.variable.includePath(path, context);
|
|
13548
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
13911
13549
|
}
|
|
13912
13550
|
}
|
|
13913
13551
|
}
|
|
@@ -13924,12 +13562,12 @@ class SwitchCase extends NodeBase {
|
|
|
13924
13562
|
}
|
|
13925
13563
|
return false;
|
|
13926
13564
|
}
|
|
13927
|
-
|
|
13565
|
+
include(context, includeChildrenRecursively) {
|
|
13928
13566
|
this.included = true;
|
|
13929
|
-
this.test?.
|
|
13567
|
+
this.test?.include(context, includeChildrenRecursively);
|
|
13930
13568
|
for (const node of this.consequent) {
|
|
13931
13569
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
13932
|
-
node.
|
|
13570
|
+
node.include(context, includeChildrenRecursively);
|
|
13933
13571
|
}
|
|
13934
13572
|
}
|
|
13935
13573
|
render(code, options, nodeRenderOptions) {
|
|
@@ -13977,9 +13615,9 @@ class SwitchStatement extends NodeBase {
|
|
|
13977
13615
|
context.hasBreak = hasBreak;
|
|
13978
13616
|
return false;
|
|
13979
13617
|
}
|
|
13980
|
-
|
|
13618
|
+
include(context, includeChildrenRecursively) {
|
|
13981
13619
|
this.included = true;
|
|
13982
|
-
this.discriminant.
|
|
13620
|
+
this.discriminant.include(context, includeChildrenRecursively);
|
|
13983
13621
|
const { brokenFlow, hasBreak } = context;
|
|
13984
13622
|
context.hasBreak = false;
|
|
13985
13623
|
let onlyHasBrokenFlow = true;
|
|
@@ -13996,7 +13634,7 @@ class SwitchStatement extends NodeBase {
|
|
|
13996
13634
|
isCaseIncluded = switchCase.hasEffects(hasEffectsContext);
|
|
13997
13635
|
}
|
|
13998
13636
|
if (isCaseIncluded) {
|
|
13999
|
-
switchCase.
|
|
13637
|
+
switchCase.include(context, includeChildrenRecursively);
|
|
14000
13638
|
onlyHasBrokenFlow &&= context.brokenFlow && !context.hasBreak;
|
|
14001
13639
|
context.hasBreak = false;
|
|
14002
13640
|
context.brokenFlow = brokenFlow;
|
|
@@ -14053,21 +13691,21 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
14053
13691
|
return (this.tag.hasEffects(context) ||
|
|
14054
13692
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
14055
13693
|
}
|
|
14056
|
-
|
|
13694
|
+
include(context, includeChildrenRecursively) {
|
|
14057
13695
|
if (!this.deoptimized)
|
|
14058
13696
|
this.applyDeoptimizations();
|
|
14059
13697
|
if (includeChildrenRecursively) {
|
|
14060
|
-
super.
|
|
13698
|
+
super.include(context, includeChildrenRecursively);
|
|
14061
13699
|
}
|
|
14062
13700
|
else {
|
|
14063
13701
|
this.included = true;
|
|
14064
|
-
this.tag.
|
|
14065
|
-
this.quasi.
|
|
13702
|
+
this.tag.include(context, includeChildrenRecursively);
|
|
13703
|
+
this.quasi.include(context, includeChildrenRecursively);
|
|
14066
13704
|
}
|
|
14067
|
-
this.tag.includeCallArguments(context, this.
|
|
13705
|
+
this.tag.includeCallArguments(context, this.args);
|
|
14068
13706
|
const [returnExpression] = this.getReturnExpression();
|
|
14069
13707
|
if (!returnExpression.included) {
|
|
14070
|
-
returnExpression.
|
|
13708
|
+
returnExpression.include(context, false);
|
|
14071
13709
|
}
|
|
14072
13710
|
}
|
|
14073
13711
|
initialise() {
|
|
@@ -14112,7 +13750,7 @@ class TemplateElement extends NodeBase {
|
|
|
14112
13750
|
hasEffects() {
|
|
14113
13751
|
return false;
|
|
14114
13752
|
}
|
|
14115
|
-
|
|
13753
|
+
include() {
|
|
14116
13754
|
this.included = true;
|
|
14117
13755
|
}
|
|
14118
13756
|
parseNode(esTreeNode) {
|
|
@@ -14154,13 +13792,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
14154
13792
|
class ModuleScope extends ChildScope {
|
|
14155
13793
|
constructor(parent, context) {
|
|
14156
13794
|
super(parent, context);
|
|
14157
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
13795
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
14158
13796
|
}
|
|
14159
|
-
addDeclaration(identifier, context, init,
|
|
13797
|
+
addDeclaration(identifier, context, init, kind) {
|
|
14160
13798
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
14161
13799
|
context.error(logRedeclarationError(identifier.name), identifier.start);
|
|
14162
13800
|
}
|
|
14163
|
-
return super.addDeclaration(identifier, context, init,
|
|
13801
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
14164
13802
|
}
|
|
14165
13803
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
14166
13804
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -14205,13 +13843,10 @@ class ThisExpression extends NodeBase {
|
|
|
14205
13843
|
}
|
|
14206
13844
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14207
13845
|
}
|
|
14208
|
-
|
|
13846
|
+
include() {
|
|
14209
13847
|
if (!this.included) {
|
|
14210
13848
|
this.included = true;
|
|
14211
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
14212
|
-
}
|
|
14213
|
-
else if (path.length > 0) {
|
|
14214
|
-
this.variable.includePath(path, context);
|
|
13849
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
14215
13850
|
}
|
|
14216
13851
|
}
|
|
14217
13852
|
initialise() {
|
|
@@ -14238,9 +13873,9 @@ class ThrowStatement extends NodeBase {
|
|
|
14238
13873
|
hasEffects() {
|
|
14239
13874
|
return true;
|
|
14240
13875
|
}
|
|
14241
|
-
|
|
13876
|
+
include(context, includeChildrenRecursively) {
|
|
14242
13877
|
this.included = true;
|
|
14243
|
-
this.argument.
|
|
13878
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
14244
13879
|
context.brokenFlow = true;
|
|
14245
13880
|
}
|
|
14246
13881
|
render(code, options) {
|
|
@@ -14262,13 +13897,13 @@ class TryStatement extends NodeBase {
|
|
|
14262
13897
|
? this.block.body.length > 0
|
|
14263
13898
|
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
14264
13899
|
}
|
|
14265
|
-
|
|
13900
|
+
include(context, includeChildrenRecursively) {
|
|
14266
13901
|
const tryCatchDeoptimization = this.scope.context.options.treeshake?.tryCatchDeoptimization;
|
|
14267
13902
|
const { brokenFlow, includedLabels } = context;
|
|
14268
13903
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
14269
13904
|
this.included = true;
|
|
14270
13905
|
this.directlyIncluded = true;
|
|
14271
|
-
this.block.
|
|
13906
|
+
this.block.include(context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
|
|
14272
13907
|
if (includedLabels.size > 0) {
|
|
14273
13908
|
this.includedLabelsAfterBlock = [...includedLabels];
|
|
14274
13909
|
}
|
|
@@ -14280,10 +13915,10 @@ class TryStatement extends NodeBase {
|
|
|
14280
13915
|
}
|
|
14281
13916
|
}
|
|
14282
13917
|
if (this.handler !== null) {
|
|
14283
|
-
this.handler.
|
|
13918
|
+
this.handler.include(context, includeChildrenRecursively);
|
|
14284
13919
|
context.brokenFlow = brokenFlow;
|
|
14285
13920
|
}
|
|
14286
|
-
this.finalizer?.
|
|
13921
|
+
this.finalizer?.include(context, includeChildrenRecursively);
|
|
14287
13922
|
}
|
|
14288
13923
|
}
|
|
14289
13924
|
|
|
@@ -14341,7 +13976,7 @@ class UpdateExpression extends NodeBase {
|
|
|
14341
13976
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
14342
13977
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
14343
13978
|
}
|
|
14344
|
-
|
|
13979
|
+
include(context, includeChildrenRecursively) {
|
|
14345
13980
|
if (!this.deoptimized)
|
|
14346
13981
|
this.applyDeoptimizations();
|
|
14347
13982
|
this.included = true;
|
|
@@ -14410,20 +14045,20 @@ class VariableDeclaration extends NodeBase {
|
|
|
14410
14045
|
hasEffectsOnInteractionAtPath() {
|
|
14411
14046
|
return false;
|
|
14412
14047
|
}
|
|
14413
|
-
|
|
14048
|
+
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
14414
14049
|
this.included = true;
|
|
14415
14050
|
for (const declarator of this.declarations) {
|
|
14416
14051
|
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
14417
|
-
declarator.
|
|
14052
|
+
declarator.include(context, includeChildrenRecursively);
|
|
14418
14053
|
const { id, init } = declarator;
|
|
14419
14054
|
if (asSingleStatement) {
|
|
14420
|
-
id.
|
|
14055
|
+
id.include(context, includeChildrenRecursively);
|
|
14421
14056
|
}
|
|
14422
14057
|
if (init &&
|
|
14423
14058
|
id.included &&
|
|
14424
14059
|
!init.included &&
|
|
14425
14060
|
(id instanceof ObjectPattern || id instanceof ArrayPattern)) {
|
|
14426
|
-
init.
|
|
14061
|
+
init.include(context, includeChildrenRecursively);
|
|
14427
14062
|
}
|
|
14428
14063
|
}
|
|
14429
14064
|
}
|
|
@@ -14495,7 +14130,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
14495
14130
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
14496
14131
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
14497
14132
|
if (!node.included) {
|
|
14498
|
-
|
|
14133
|
+
code.remove(start, end);
|
|
14134
|
+
node.removeAnnotations(code);
|
|
14499
14135
|
continue;
|
|
14500
14136
|
}
|
|
14501
14137
|
node.render(code, options);
|
|
@@ -14572,9 +14208,9 @@ class WhileStatement extends NodeBase {
|
|
|
14572
14208
|
return true;
|
|
14573
14209
|
return hasLoopBodyEffects(context, this.body);
|
|
14574
14210
|
}
|
|
14575
|
-
|
|
14211
|
+
include(context, includeChildrenRecursively) {
|
|
14576
14212
|
this.included = true;
|
|
14577
|
-
this.test.
|
|
14213
|
+
this.test.include(context, includeChildrenRecursively);
|
|
14578
14214
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
14579
14215
|
}
|
|
14580
14216
|
}
|
|
@@ -14818,7 +14454,7 @@ const bufferParsers = [
|
|
|
14818
14454
|
const annotations = (node.annotations = convertAnnotations(buffer[position + 1], buffer));
|
|
14819
14455
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
14820
14456
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
14821
|
-
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);
|
|
14822
14458
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
14823
14459
|
},
|
|
14824
14460
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -14864,7 +14500,7 @@ const bufferParsers = [
|
|
|
14864
14500
|
const parameterPosition = buffer[position];
|
|
14865
14501
|
const parameter = (node.param =
|
|
14866
14502
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
14867
|
-
parameter?.declare('parameter',
|
|
14503
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
14868
14504
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
14869
14505
|
},
|
|
14870
14506
|
function chainExpression(node, position, buffer) {
|
|
@@ -15002,7 +14638,7 @@ const bufferParsers = [
|
|
|
15002
14638
|
node.id =
|
|
15003
14639
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
15004
14640
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15005
|
-
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);
|
|
15006
14642
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15007
14643
|
},
|
|
15008
14644
|
function functionExpression(node, position, buffer) {
|
|
@@ -15015,7 +14651,7 @@ const bufferParsers = [
|
|
|
15015
14651
|
const idPosition = buffer[position + 2];
|
|
15016
14652
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
15017
14653
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
15018
|
-
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);
|
|
15019
14655
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
15020
14656
|
},
|
|
15021
14657
|
function identifier(node, position, buffer) {
|
|
@@ -15374,8 +15010,8 @@ class UnknownNode extends NodeBase {
|
|
|
15374
15010
|
hasEffects() {
|
|
15375
15011
|
return true;
|
|
15376
15012
|
}
|
|
15377
|
-
|
|
15378
|
-
super.
|
|
15013
|
+
include(context) {
|
|
15014
|
+
super.include(context, true);
|
|
15379
15015
|
}
|
|
15380
15016
|
}
|
|
15381
15017
|
|
|
@@ -15479,8 +15115,8 @@ class ExportShimVariable extends Variable {
|
|
|
15479
15115
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
15480
15116
|
this.module = module;
|
|
15481
15117
|
}
|
|
15482
|
-
|
|
15483
|
-
super.
|
|
15118
|
+
include() {
|
|
15119
|
+
super.include();
|
|
15484
15120
|
this.module.needsExportShim = true;
|
|
15485
15121
|
}
|
|
15486
15122
|
}
|
|
@@ -16171,7 +15807,7 @@ class Module {
|
|
|
16171
15807
|
include() {
|
|
16172
15808
|
const context = createInclusionContext();
|
|
16173
15809
|
if (this.ast.shouldBeIncluded(context))
|
|
16174
|
-
this.ast.
|
|
15810
|
+
this.ast.include(context, false);
|
|
16175
15811
|
}
|
|
16176
15812
|
includeAllExports(includeNamespaceMembers) {
|
|
16177
15813
|
if (!this.isExecuted) {
|
|
@@ -16185,7 +15821,9 @@ class Module {
|
|
|
16185
15821
|
return error(logMissingEntryExport(exportName, this.id));
|
|
16186
15822
|
}
|
|
16187
15823
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16188
|
-
|
|
15824
|
+
if (!variable.included) {
|
|
15825
|
+
this.includeVariable(variable);
|
|
15826
|
+
}
|
|
16189
15827
|
}
|
|
16190
15828
|
}
|
|
16191
15829
|
for (const name of this.getReexports()) {
|
|
@@ -16193,7 +15831,7 @@ class Module {
|
|
|
16193
15831
|
if (variable) {
|
|
16194
15832
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16195
15833
|
if (!variable.included) {
|
|
16196
|
-
this.includeVariable(variable
|
|
15834
|
+
this.includeVariable(variable);
|
|
16197
15835
|
}
|
|
16198
15836
|
if (variable instanceof ExternalVariable) {
|
|
16199
15837
|
variable.module.reexported = true;
|
|
@@ -16205,7 +15843,7 @@ class Module {
|
|
|
16205
15843
|
}
|
|
16206
15844
|
}
|
|
16207
15845
|
includeAllInBundle() {
|
|
16208
|
-
this.ast.
|
|
15846
|
+
this.ast.include(createInclusionContext(), true);
|
|
16209
15847
|
this.includeAllExports(false);
|
|
16210
15848
|
}
|
|
16211
15849
|
includeExportsByNames(names) {
|
|
@@ -16219,7 +15857,7 @@ class Module {
|
|
|
16219
15857
|
if (variable) {
|
|
16220
15858
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
16221
15859
|
if (!variable.included) {
|
|
16222
|
-
this.includeVariable(variable
|
|
15860
|
+
this.includeVariable(variable);
|
|
16223
15861
|
}
|
|
16224
15862
|
}
|
|
16225
15863
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
@@ -16661,13 +16299,13 @@ class Module {
|
|
|
16661
16299
|
for (const module of [this, ...this.exportAllModules]) {
|
|
16662
16300
|
if (module instanceof ExternalModule) {
|
|
16663
16301
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
16664
|
-
externalVariable.
|
|
16302
|
+
externalVariable.include();
|
|
16665
16303
|
this.includedImports.add(externalVariable);
|
|
16666
16304
|
externalNamespaces.add(externalVariable);
|
|
16667
16305
|
}
|
|
16668
16306
|
else if (module.info.syntheticNamedExports) {
|
|
16669
16307
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
16670
|
-
syntheticNamespace.
|
|
16308
|
+
syntheticNamespace.include();
|
|
16671
16309
|
this.includedImports.add(syntheticNamespace);
|
|
16672
16310
|
syntheticNamespaces.add(syntheticNamespace);
|
|
16673
16311
|
}
|
|
@@ -16677,9 +16315,7 @@ class Module {
|
|
|
16677
16315
|
includeDynamicImport(node) {
|
|
16678
16316
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
16679
16317
|
if (resolution instanceof Module) {
|
|
16680
|
-
|
|
16681
|
-
resolution.includedDynamicImporters.push(this);
|
|
16682
|
-
}
|
|
16318
|
+
resolution.includedDynamicImporters.push(this);
|
|
16683
16319
|
const importedNames = this.options.treeshake
|
|
16684
16320
|
? node.getDeterministicImportedNames()
|
|
16685
16321
|
: undefined;
|
|
@@ -16691,7 +16327,7 @@ class Module {
|
|
|
16691
16327
|
}
|
|
16692
16328
|
}
|
|
16693
16329
|
}
|
|
16694
|
-
includeVariable(variable
|
|
16330
|
+
includeVariable(variable) {
|
|
16695
16331
|
const variableModule = variable.module;
|
|
16696
16332
|
if (variable.included) {
|
|
16697
16333
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
@@ -16699,6 +16335,7 @@ class Module {
|
|
|
16699
16335
|
}
|
|
16700
16336
|
}
|
|
16701
16337
|
else {
|
|
16338
|
+
variable.include();
|
|
16702
16339
|
this.graph.needsTreeshakingPass = true;
|
|
16703
16340
|
if (variableModule instanceof Module) {
|
|
16704
16341
|
if (!variableModule.isExecuted) {
|
|
@@ -16714,10 +16351,9 @@ class Module {
|
|
|
16714
16351
|
}
|
|
16715
16352
|
}
|
|
16716
16353
|
}
|
|
16717
|
-
variable.includePath(path, createInclusionContext());
|
|
16718
16354
|
}
|
|
16719
|
-
includeVariableInModule(variable
|
|
16720
|
-
this.includeVariable(variable
|
|
16355
|
+
includeVariableInModule(variable) {
|
|
16356
|
+
this.includeVariable(variable);
|
|
16721
16357
|
const variableModule = variable.module;
|
|
16722
16358
|
if (variableModule && variableModule !== this) {
|
|
16723
16359
|
this.includedImports.add(variable);
|
|
@@ -21314,7 +20950,7 @@ class Graph {
|
|
|
21314
20950
|
this.options = options;
|
|
21315
20951
|
this.astLru = flru(5);
|
|
21316
20952
|
this.cachedModules = new Map();
|
|
21317
|
-
this.deoptimizationTracker = new
|
|
20953
|
+
this.deoptimizationTracker = new PathTracker();
|
|
21318
20954
|
this.entryModules = [];
|
|
21319
20955
|
this.modulesById = new Map();
|
|
21320
20956
|
this.needsTreeshakingPass = false;
|
|
@@ -22314,7 +21950,7 @@ createColors();
|
|
|
22314
21950
|
|
|
22315
21951
|
// @see https://no-color.org
|
|
22316
21952
|
// @see https://www.npmjs.com/package/chalk
|
|
22317
|
-
const { bold, cyan, dim, red} = createColors({
|
|
21953
|
+
const { bold, cyan, dim, gray, green, red, underline, yellow } = createColors({
|
|
22318
21954
|
useColor: env$1.FORCE_COLOR !== '0' && !env$1.NO_COLOR
|
|
22319
21955
|
});
|
|
22320
21956
|
|