@rollup/wasm-node 4.24.2 → 4.25.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +598 -430
- 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 +595 -427
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +3 -3
- package/package.json +1 -1
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.25.0-0
|
|
4
|
+
Tue, 29 Oct 2024 06:14:37 GMT - commit b7fcaba12e863db516f39de74c1eacfe5329a5c3
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version = "4.
|
|
34
|
+
var version = "4.25.0-0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -3594,7 +3594,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
3594
3594
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
3595
3595
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
3596
3596
|
const EntitiesKey = Symbol('Entities');
|
|
3597
|
-
class
|
|
3597
|
+
class EntityPathTracker {
|
|
3598
3598
|
constructor() {
|
|
3599
3599
|
this.entityPaths = Object.create(null, {
|
|
3600
3600
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -3619,14 +3619,14 @@ class PathTracker {
|
|
|
3619
3619
|
getEntities(path) {
|
|
3620
3620
|
let currentPaths = this.entityPaths;
|
|
3621
3621
|
for (const pathSegment of path) {
|
|
3622
|
-
currentPaths = currentPaths[pathSegment]
|
|
3623
|
-
|
|
3624
|
-
|
|
3622
|
+
currentPaths = currentPaths[pathSegment] ||= Object.create(null, {
|
|
3623
|
+
[EntitiesKey]: { value: new Set() }
|
|
3624
|
+
});
|
|
3625
3625
|
}
|
|
3626
3626
|
return currentPaths[EntitiesKey];
|
|
3627
3627
|
}
|
|
3628
3628
|
}
|
|
3629
|
-
const SHARED_RECURSION_TRACKER = new
|
|
3629
|
+
const SHARED_RECURSION_TRACKER = new EntityPathTracker();
|
|
3630
3630
|
class DiscriminatedPathTracker {
|
|
3631
3631
|
constructor() {
|
|
3632
3632
|
this.entityPaths = Object.create(null, {
|
|
@@ -3636,9 +3636,9 @@ class DiscriminatedPathTracker {
|
|
|
3636
3636
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
3637
3637
|
let currentPaths = this.entityPaths;
|
|
3638
3638
|
for (const pathSegment of path) {
|
|
3639
|
-
currentPaths = currentPaths[pathSegment]
|
|
3640
|
-
|
|
3641
|
-
|
|
3639
|
+
currentPaths = currentPaths[pathSegment] ||= Object.create(null, {
|
|
3640
|
+
[EntitiesKey]: { value: new Map() }
|
|
3641
|
+
});
|
|
3642
3642
|
}
|
|
3643
3643
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
3644
3644
|
if (trackedEntities.has(entity))
|
|
@@ -3647,6 +3647,55 @@ class DiscriminatedPathTracker {
|
|
|
3647
3647
|
return false;
|
|
3648
3648
|
}
|
|
3649
3649
|
}
|
|
3650
|
+
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: parseAst_js.EMPTY_OBJECT });
|
|
3651
|
+
class IncludedPathTracker {
|
|
3652
|
+
constructor() {
|
|
3653
|
+
this.includedPaths = null;
|
|
3654
|
+
}
|
|
3655
|
+
includePathAndGetIfIncluded(path) {
|
|
3656
|
+
let included = true;
|
|
3657
|
+
let parent = this;
|
|
3658
|
+
let parentSegment = 'includedPaths';
|
|
3659
|
+
let currentPaths = (this.includedPaths ||=
|
|
3660
|
+
((included = false), Object.create(null)));
|
|
3661
|
+
for (const pathSegment of path) {
|
|
3662
|
+
// This means from here, all paths are included
|
|
3663
|
+
if (currentPaths[UnknownKey]) {
|
|
3664
|
+
return true;
|
|
3665
|
+
}
|
|
3666
|
+
// Including UnknownKey automatically includes all nested paths.
|
|
3667
|
+
// From above, we know that UnknownKey is not included yet.
|
|
3668
|
+
if (typeof pathSegment === 'symbol') {
|
|
3669
|
+
// Hopefully, this saves some memory over just setting
|
|
3670
|
+
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
3671
|
+
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
3672
|
+
return false;
|
|
3673
|
+
}
|
|
3674
|
+
parent = currentPaths;
|
|
3675
|
+
parentSegment = pathSegment;
|
|
3676
|
+
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
3677
|
+
}
|
|
3678
|
+
return included;
|
|
3679
|
+
}
|
|
3680
|
+
includeAllPaths(entity, context, basePath) {
|
|
3681
|
+
const { includedPaths } = this;
|
|
3682
|
+
if (includedPaths) {
|
|
3683
|
+
includeAllPaths(entity, context, basePath, includedPaths);
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
3688
|
+
if (currentPaths[UnknownKey]) {
|
|
3689
|
+
return entity.includePath([...basePath, UnknownKey], context, false);
|
|
3690
|
+
}
|
|
3691
|
+
const keys = Object.keys(currentPaths);
|
|
3692
|
+
if (keys.length === 0) {
|
|
3693
|
+
return entity.includePath(basePath, context, false);
|
|
3694
|
+
}
|
|
3695
|
+
for (const key of keys) {
|
|
3696
|
+
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3650
3699
|
|
|
3651
3700
|
function isFlagSet(flags, flag) {
|
|
3652
3701
|
return (flags & flag) !== 0;
|
|
@@ -3685,12 +3734,12 @@ class ExpressionEntity {
|
|
|
3685
3734
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
3686
3735
|
return true;
|
|
3687
3736
|
}
|
|
3688
|
-
|
|
3737
|
+
includePath(_path, _context, _includeChildrenRecursively, _options) {
|
|
3689
3738
|
this.included = true;
|
|
3690
3739
|
}
|
|
3691
|
-
includeCallArguments(context,
|
|
3692
|
-
for (const argument of
|
|
3693
|
-
argument
|
|
3740
|
+
includeCallArguments(context, interaction) {
|
|
3741
|
+
for (const argument of interaction.args) {
|
|
3742
|
+
argument?.includePath(UNKNOWN_PATH, context, false);
|
|
3694
3743
|
}
|
|
3695
3744
|
}
|
|
3696
3745
|
shouldBeIncluded(_context) {
|
|
@@ -3805,9 +3854,9 @@ class Variable extends ExpressionEntity {
|
|
|
3805
3854
|
* has not been included previously. Once a variable is included, it should
|
|
3806
3855
|
* take care all its declarations are included.
|
|
3807
3856
|
*/
|
|
3808
|
-
|
|
3857
|
+
includePath(path, context) {
|
|
3809
3858
|
this.included = true;
|
|
3810
|
-
this.renderedLikeHoisted?.
|
|
3859
|
+
this.renderedLikeHoisted?.includePath(path, context);
|
|
3811
3860
|
}
|
|
3812
3861
|
/**
|
|
3813
3862
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -3839,8 +3888,8 @@ class ExternalVariable extends Variable {
|
|
|
3839
3888
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
3840
3889
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
3841
3890
|
}
|
|
3842
|
-
|
|
3843
|
-
super.
|
|
3891
|
+
includePath(path, context) {
|
|
3892
|
+
super.includePath(path, context);
|
|
3844
3893
|
this.module.used = true;
|
|
3845
3894
|
}
|
|
3846
3895
|
}
|
|
@@ -4352,8 +4401,8 @@ function createInclusionContext() {
|
|
|
4352
4401
|
}
|
|
4353
4402
|
function createHasEffectsContext() {
|
|
4354
4403
|
return {
|
|
4355
|
-
accessed: new
|
|
4356
|
-
assigned: new
|
|
4404
|
+
accessed: new EntityPathTracker(),
|
|
4405
|
+
assigned: new EntityPathTracker(),
|
|
4357
4406
|
brokenFlow: false,
|
|
4358
4407
|
called: new DiscriminatedPathTracker(),
|
|
4359
4408
|
hasBreak: false,
|
|
@@ -4439,7 +4488,7 @@ class NodeBase extends ExpressionEntity {
|
|
|
4439
4488
|
return (this.hasEffects(context) ||
|
|
4440
4489
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
4441
4490
|
}
|
|
4442
|
-
|
|
4491
|
+
includePath(_path, context, includeChildrenRecursively, _options) {
|
|
4443
4492
|
if (!this.deoptimized)
|
|
4444
4493
|
this.applyDeoptimizations();
|
|
4445
4494
|
this.included = true;
|
|
@@ -4449,16 +4498,16 @@ class NodeBase extends ExpressionEntity {
|
|
|
4449
4498
|
continue;
|
|
4450
4499
|
if (Array.isArray(value)) {
|
|
4451
4500
|
for (const child of value) {
|
|
4452
|
-
child?.
|
|
4501
|
+
child?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
4453
4502
|
}
|
|
4454
4503
|
}
|
|
4455
4504
|
else {
|
|
4456
|
-
value.
|
|
4505
|
+
value.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
4457
4506
|
}
|
|
4458
4507
|
}
|
|
4459
4508
|
}
|
|
4460
4509
|
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
4461
|
-
this.
|
|
4510
|
+
this.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
4462
4511
|
}
|
|
4463
4512
|
/**
|
|
4464
4513
|
* Override to perform special initialisation steps after the scope is
|
|
@@ -4709,6 +4758,7 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
4709
4758
|
this.unknownIntegerProps = [];
|
|
4710
4759
|
this.unmatchableGetters = [];
|
|
4711
4760
|
this.unmatchablePropertiesAndGetters = [];
|
|
4761
|
+
this.unmatchablePropertiesAndSetters = [];
|
|
4712
4762
|
this.unmatchableSetters = [];
|
|
4713
4763
|
if (Array.isArray(properties)) {
|
|
4714
4764
|
this.buildPropertyMaps(properties);
|
|
@@ -4943,9 +4993,37 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
4943
4993
|
}
|
|
4944
4994
|
return false;
|
|
4945
4995
|
}
|
|
4996
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
4997
|
+
this.included = true;
|
|
4998
|
+
const [key, ...subPath] = path;
|
|
4999
|
+
if (key == null || includeChildrenRecursively) {
|
|
5000
|
+
for (const property of this.allProperties) {
|
|
5001
|
+
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
5002
|
+
property.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
5003
|
+
}
|
|
5004
|
+
}
|
|
5005
|
+
this.prototypeExpression?.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
5006
|
+
}
|
|
5007
|
+
else {
|
|
5008
|
+
const [includedMembers, includedPath] = typeof key === 'string'
|
|
5009
|
+
? [
|
|
5010
|
+
[
|
|
5011
|
+
...new Set([
|
|
5012
|
+
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
5013
|
+
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
5014
|
+
])
|
|
5015
|
+
],
|
|
5016
|
+
subPath
|
|
5017
|
+
]
|
|
5018
|
+
: [this.allProperties, UNKNOWN_PATH];
|
|
5019
|
+
for (const property of includedMembers) {
|
|
5020
|
+
property.includePath(includedPath, context, includeChildrenRecursively);
|
|
5021
|
+
}
|
|
5022
|
+
this.prototypeExpression?.includePath(path, context, includeChildrenRecursively);
|
|
5023
|
+
}
|
|
5024
|
+
}
|
|
4946
5025
|
buildPropertyMaps(properties) {
|
|
4947
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
4948
|
-
const unmatchablePropertiesAndSetters = [];
|
|
5026
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchablePropertiesAndSetters, unmatchableGetters, unmatchableSetters } = this;
|
|
4949
5027
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
4950
5028
|
const { key, kind, property } = properties[index];
|
|
4951
5029
|
allProperties.push(property);
|
|
@@ -6281,16 +6359,20 @@ class GlobalVariable extends Variable {
|
|
|
6281
6359
|
}
|
|
6282
6360
|
|
|
6283
6361
|
class LocalVariable extends Variable {
|
|
6284
|
-
constructor(name, declarator, init,
|
|
6362
|
+
constructor(name, declarator, init,
|
|
6363
|
+
/** if this is non-empty, the actual init is this path of this.init */
|
|
6364
|
+
initPath, context, kind) {
|
|
6285
6365
|
super(name);
|
|
6286
6366
|
this.init = init;
|
|
6367
|
+
this.initPath = initPath;
|
|
6368
|
+
this.kind = kind;
|
|
6287
6369
|
this.calledFromTryStatement = false;
|
|
6288
6370
|
this.additionalInitializers = null;
|
|
6371
|
+
this.includedPathTracker = new IncludedPathTracker();
|
|
6289
6372
|
this.expressionsToBeDeoptimized = [];
|
|
6290
6373
|
this.declarations = declarator ? [declarator] : [];
|
|
6291
6374
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
6292
6375
|
this.module = context.module;
|
|
6293
|
-
this.kind = kind;
|
|
6294
6376
|
}
|
|
6295
6377
|
addDeclaration(identifier, init) {
|
|
6296
6378
|
this.declarations.push(identifier);
|
|
@@ -6301,7 +6383,6 @@ class LocalVariable extends Variable {
|
|
|
6301
6383
|
for (const initializer of this.additionalInitializers) {
|
|
6302
6384
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
6303
6385
|
}
|
|
6304
|
-
this.additionalInitializers = null;
|
|
6305
6386
|
}
|
|
6306
6387
|
}
|
|
6307
6388
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -6309,7 +6390,7 @@ class LocalVariable extends Variable {
|
|
|
6309
6390
|
deoptimizeInteraction(interaction);
|
|
6310
6391
|
return;
|
|
6311
6392
|
}
|
|
6312
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
6393
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker), undefined);
|
|
6313
6394
|
}
|
|
6314
6395
|
deoptimizePath(path) {
|
|
6315
6396
|
if (this.isReassigned ||
|
|
@@ -6323,10 +6404,10 @@ class LocalVariable extends Variable {
|
|
|
6323
6404
|
for (const expression of expressionsToBeDeoptimized) {
|
|
6324
6405
|
expression.deoptimizeCache();
|
|
6325
6406
|
}
|
|
6326
|
-
this.init.deoptimizePath(
|
|
6407
|
+
this.init.deoptimizePath([...this.initPath, UnknownKey]);
|
|
6327
6408
|
}
|
|
6328
6409
|
else {
|
|
6329
|
-
this.init.deoptimizePath(path);
|
|
6410
|
+
this.init.deoptimizePath([...this.initPath, ...path]);
|
|
6330
6411
|
}
|
|
6331
6412
|
}
|
|
6332
6413
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -6335,7 +6416,7 @@ class LocalVariable extends Variable {
|
|
|
6335
6416
|
}
|
|
6336
6417
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6337
6418
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6338
|
-
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6419
|
+
return this.init.getLiteralValueAtPath([...this.initPath, ...path], recursionTracker, origin);
|
|
6339
6420
|
}, UnknownValue);
|
|
6340
6421
|
}
|
|
6341
6422
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
@@ -6344,7 +6425,7 @@ class LocalVariable extends Variable {
|
|
|
6344
6425
|
}
|
|
6345
6426
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6346
6427
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6347
|
-
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6428
|
+
return this.init.getReturnExpressionWhenCalledAtPath([...this.initPath, ...path], interaction, recursionTracker, origin);
|
|
6348
6429
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
6349
6430
|
}
|
|
6350
6431
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -6353,7 +6434,7 @@ class LocalVariable extends Variable {
|
|
|
6353
6434
|
if (this.isReassigned)
|
|
6354
6435
|
return true;
|
|
6355
6436
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6356
|
-
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6437
|
+
this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
6357
6438
|
}
|
|
6358
6439
|
case INTERACTION_ASSIGNED: {
|
|
6359
6440
|
if (this.included)
|
|
@@ -6363,23 +6444,23 @@ class LocalVariable extends Variable {
|
|
|
6363
6444
|
if (this.isReassigned)
|
|
6364
6445
|
return true;
|
|
6365
6446
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6366
|
-
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6447
|
+
this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
6367
6448
|
}
|
|
6368
6449
|
case INTERACTION_CALLED: {
|
|
6369
6450
|
if (this.isReassigned)
|
|
6370
6451
|
return true;
|
|
6371
6452
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
6372
|
-
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6453
|
+
this.init.hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
6373
6454
|
}
|
|
6374
6455
|
}
|
|
6375
6456
|
}
|
|
6376
|
-
|
|
6377
|
-
if (!this.
|
|
6378
|
-
super.
|
|
6457
|
+
includePath(path, context) {
|
|
6458
|
+
if (!this.includedPathTracker.includePathAndGetIfIncluded(path)) {
|
|
6459
|
+
super.includePath(path, context);
|
|
6379
6460
|
for (const declaration of this.declarations) {
|
|
6380
6461
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
6381
6462
|
if (!declaration.included)
|
|
6382
|
-
declaration.
|
|
6463
|
+
declaration.includePath(EMPTY_PATH, context, false);
|
|
6383
6464
|
let node = declaration.parent;
|
|
6384
6465
|
while (!node.included) {
|
|
6385
6466
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
@@ -6390,17 +6471,26 @@ class LocalVariable extends Variable {
|
|
|
6390
6471
|
node = node.parent;
|
|
6391
6472
|
}
|
|
6392
6473
|
}
|
|
6474
|
+
// We need to make sure we include the correct path of the init
|
|
6475
|
+
if (path.length > 0) {
|
|
6476
|
+
this.init.includePath([...this.initPath, ...path], context, false);
|
|
6477
|
+
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context, false));
|
|
6478
|
+
}
|
|
6393
6479
|
}
|
|
6394
6480
|
}
|
|
6395
|
-
includeCallArguments(context,
|
|
6396
|
-
if (this.isReassigned ||
|
|
6397
|
-
|
|
6398
|
-
|
|
6481
|
+
includeCallArguments(context, interaction) {
|
|
6482
|
+
if (this.isReassigned ||
|
|
6483
|
+
context.includedCallArguments.has(this.init) ||
|
|
6484
|
+
// This can be removed again once we can include arguments when called at
|
|
6485
|
+
// a specific path
|
|
6486
|
+
this.initPath.length > 0) {
|
|
6487
|
+
for (const argument of interaction.args) {
|
|
6488
|
+
argument?.includePath(UNKNOWN_PATH, context, false);
|
|
6399
6489
|
}
|
|
6400
6490
|
}
|
|
6401
6491
|
else {
|
|
6402
6492
|
context.includedCallArguments.add(this.init);
|
|
6403
|
-
this.init.includeCallArguments(context,
|
|
6493
|
+
this.init.includeCallArguments(context, interaction);
|
|
6404
6494
|
context.includedCallArguments.delete(this.init);
|
|
6405
6495
|
}
|
|
6406
6496
|
}
|
|
@@ -6480,18 +6570,21 @@ class IdentifierBase extends NodeBase {
|
|
|
6480
6570
|
}
|
|
6481
6571
|
}
|
|
6482
6572
|
}
|
|
6483
|
-
|
|
6573
|
+
includePath(path, context) {
|
|
6484
6574
|
if (!this.deoptimized)
|
|
6485
6575
|
this.applyDeoptimizations();
|
|
6486
6576
|
if (!this.included) {
|
|
6487
6577
|
this.included = true;
|
|
6488
6578
|
if (this.variable !== null) {
|
|
6489
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
6579
|
+
this.scope.context.includeVariableInModule(this.variable, path);
|
|
6490
6580
|
}
|
|
6491
6581
|
}
|
|
6582
|
+
else if (path.length > 0) {
|
|
6583
|
+
this.variable?.includePath(path, context);
|
|
6584
|
+
}
|
|
6492
6585
|
}
|
|
6493
|
-
includeCallArguments(context,
|
|
6494
|
-
this.variable.includeCallArguments(context,
|
|
6586
|
+
includeCallArguments(context, interaction) {
|
|
6587
|
+
this.variable.includeCallArguments(context, interaction);
|
|
6495
6588
|
}
|
|
6496
6589
|
isPossibleTDZ() {
|
|
6497
6590
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -6591,39 +6684,17 @@ class Identifier extends IdentifierBase {
|
|
|
6591
6684
|
this.isVariableReference = true;
|
|
6592
6685
|
}
|
|
6593
6686
|
}
|
|
6594
|
-
declare(kind, init) {
|
|
6687
|
+
declare(kind, includedInitPath, init) {
|
|
6595
6688
|
let variable;
|
|
6596
6689
|
const { treeshake } = this.scope.context.options;
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6605
|
-
}
|
|
6606
|
-
case 'function': {
|
|
6607
|
-
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
6608
|
-
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
6609
|
-
break;
|
|
6610
|
-
}
|
|
6611
|
-
case 'let':
|
|
6612
|
-
case 'const':
|
|
6613
|
-
case 'using':
|
|
6614
|
-
case 'await using':
|
|
6615
|
-
case 'class': {
|
|
6616
|
-
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
6617
|
-
break;
|
|
6618
|
-
}
|
|
6619
|
-
case 'parameter': {
|
|
6620
|
-
variable = this.scope.addParameterDeclaration(this);
|
|
6621
|
-
break;
|
|
6622
|
-
}
|
|
6623
|
-
/* istanbul ignore next */
|
|
6624
|
-
default: {
|
|
6625
|
-
/* istanbul ignore next */
|
|
6626
|
-
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
6690
|
+
if (kind === 'parameter') {
|
|
6691
|
+
variable = this.scope.addParameterDeclaration(this, includedInitPath);
|
|
6692
|
+
}
|
|
6693
|
+
else {
|
|
6694
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, includedInitPath, kind);
|
|
6695
|
+
if (kind === 'var' && treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
6696
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
6697
|
+
variable.markInitializersForDeoptimization();
|
|
6627
6698
|
}
|
|
6628
6699
|
}
|
|
6629
6700
|
return [(this.variable = variable)];
|
|
@@ -6680,18 +6751,17 @@ class Scope {
|
|
|
6680
6751
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
6681
6752
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
6682
6753
|
*/
|
|
6683
|
-
addDeclaration(identifier, context, init, kind) {
|
|
6754
|
+
addDeclaration(identifier, context, init, includedInitPath, kind) {
|
|
6684
6755
|
const name = identifier.name;
|
|
6685
6756
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6686
6757
|
if (existingVariable) {
|
|
6687
|
-
|
|
6688
|
-
if (kind === 'var' && existingKind === 'var') {
|
|
6758
|
+
if (kind === 'var' && existingVariable.kind === 'var') {
|
|
6689
6759
|
existingVariable.addDeclaration(identifier, init);
|
|
6690
6760
|
return existingVariable;
|
|
6691
6761
|
}
|
|
6692
6762
|
context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
6693
6763
|
}
|
|
6694
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6764
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, includedInitPath, context, kind);
|
|
6695
6765
|
this.variables.set(name, newVariable);
|
|
6696
6766
|
return newVariable;
|
|
6697
6767
|
}
|
|
@@ -6893,7 +6963,7 @@ class BlockScope extends ChildScope {
|
|
|
6893
6963
|
constructor(parent) {
|
|
6894
6964
|
super(parent, parent.context);
|
|
6895
6965
|
}
|
|
6896
|
-
addDeclaration(identifier, context, init, kind) {
|
|
6966
|
+
addDeclaration(identifier, context, init, includedInitPath, kind) {
|
|
6897
6967
|
if (kind === 'var') {
|
|
6898
6968
|
const name = identifier.name;
|
|
6899
6969
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -6905,7 +6975,7 @@ class BlockScope extends ChildScope {
|
|
|
6905
6975
|
}
|
|
6906
6976
|
return context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
6907
6977
|
}
|
|
6908
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
6978
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, includedInitPath, kind);
|
|
6909
6979
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
6910
6980
|
// We cannot call deoptimizePath here.
|
|
6911
6981
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -6913,7 +6983,7 @@ class BlockScope extends ChildScope {
|
|
|
6913
6983
|
this.addHoistedVariable(name, declaredVariable);
|
|
6914
6984
|
return declaredVariable;
|
|
6915
6985
|
}
|
|
6916
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
6986
|
+
return super.addDeclaration(identifier, context, init, includedInitPath, kind);
|
|
6917
6987
|
}
|
|
6918
6988
|
}
|
|
6919
6989
|
|
|
@@ -6928,11 +6998,11 @@ class StaticBlock extends NodeBase {
|
|
|
6928
6998
|
}
|
|
6929
6999
|
return false;
|
|
6930
7000
|
}
|
|
6931
|
-
|
|
7001
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
6932
7002
|
this.included = true;
|
|
6933
7003
|
for (const node of this.body) {
|
|
6934
7004
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
6935
|
-
node.
|
|
7005
|
+
node.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
6936
7006
|
}
|
|
6937
7007
|
}
|
|
6938
7008
|
render(code, options) {
|
|
@@ -7011,22 +7081,22 @@ class ClassNode extends NodeBase {
|
|
|
7011
7081
|
false
|
|
7012
7082
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7013
7083
|
}
|
|
7014
|
-
|
|
7084
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
7015
7085
|
if (!this.deoptimized)
|
|
7016
7086
|
this.applyDeoptimizations();
|
|
7017
7087
|
this.included = true;
|
|
7018
|
-
this.superClass?.
|
|
7019
|
-
this.body.
|
|
7088
|
+
this.superClass?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7089
|
+
this.body.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7020
7090
|
for (const decorator of this.decorators)
|
|
7021
|
-
decorator.
|
|
7091
|
+
decorator.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7022
7092
|
if (this.id) {
|
|
7023
7093
|
this.id.markDeclarationReached();
|
|
7024
|
-
this.id.
|
|
7094
|
+
this.id.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
7025
7095
|
}
|
|
7026
7096
|
}
|
|
7027
7097
|
initialise() {
|
|
7028
7098
|
super.initialise();
|
|
7029
|
-
this.id?.declare('class', this);
|
|
7099
|
+
this.id?.declare('class', EMPTY_PATH, this);
|
|
7030
7100
|
for (const method of this.body.body) {
|
|
7031
7101
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
7032
7102
|
this.classConstructor = method;
|
|
@@ -7141,7 +7211,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
7141
7211
|
|
|
7142
7212
|
class ArgumentsVariable extends LocalVariable {
|
|
7143
7213
|
constructor(context) {
|
|
7144
|
-
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
7214
|
+
super('arguments', null, UNKNOWN_EXPRESSION, EMPTY_PATH, context, 'other');
|
|
7145
7215
|
this.deoptimizedArguments = [];
|
|
7146
7216
|
}
|
|
7147
7217
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -7155,8 +7225,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
7155
7225
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
7156
7226
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
7157
7227
|
}
|
|
7158
|
-
|
|
7159
|
-
super.
|
|
7228
|
+
includePath(path, context) {
|
|
7229
|
+
super.includePath(path, context);
|
|
7160
7230
|
for (const argument of this.deoptimizedArguments) {
|
|
7161
7231
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7162
7232
|
}
|
|
@@ -7167,27 +7237,28 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
7167
7237
|
const MAX_TRACKED_INTERACTIONS = 20;
|
|
7168
7238
|
const NO_INTERACTIONS = parseAst_js.EMPTY_ARRAY;
|
|
7169
7239
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
7170
|
-
const EMPTY_PATH_TRACKER = new
|
|
7240
|
+
const EMPTY_PATH_TRACKER = new EntityPathTracker();
|
|
7171
7241
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
7172
7242
|
class ParameterVariable extends LocalVariable {
|
|
7173
|
-
constructor(name, declarator, context) {
|
|
7174
|
-
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
7243
|
+
constructor(name, declarator, argumentPath, context) {
|
|
7244
|
+
super(name, declarator, UNKNOWN_EXPRESSION, argumentPath, context, 'parameter');
|
|
7175
7245
|
this.deoptimizationInteractions = [];
|
|
7176
|
-
this.deoptimizations = new
|
|
7246
|
+
this.deoptimizations = new EntityPathTracker();
|
|
7177
7247
|
this.deoptimizedFields = new Set();
|
|
7178
|
-
this.
|
|
7179
|
-
this.
|
|
7248
|
+
this.argumentsToBeDeoptimized = new Set();
|
|
7249
|
+
this.expressionsDependingOnKnownValue = [];
|
|
7180
7250
|
this.knownValue = null;
|
|
7181
7251
|
this.knownValueLiteral = UnknownValue;
|
|
7182
7252
|
this.frozenValue = null;
|
|
7183
7253
|
}
|
|
7184
|
-
|
|
7254
|
+
addArgumentValue(entity) {
|
|
7255
|
+
this.updateKnownValue(entity);
|
|
7185
7256
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
7186
7257
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
7187
7258
|
// the interaction cache at this point provided we keep this optimization
|
|
7188
7259
|
// in mind when adding new interactions
|
|
7189
|
-
if (!this.
|
|
7190
|
-
this.
|
|
7260
|
+
if (!this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
7261
|
+
this.argumentsToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
7191
7262
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
7192
7263
|
deoptimizeInteraction(interaction);
|
|
7193
7264
|
}
|
|
@@ -7197,27 +7268,30 @@ class ParameterVariable extends LocalVariable {
|
|
|
7197
7268
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
7198
7269
|
// This means that we already deoptimized all interactions and no longer
|
|
7199
7270
|
// track them
|
|
7200
|
-
entity.deoptimizePath(
|
|
7271
|
+
entity.deoptimizePath([...this.initPath, UnknownKey]);
|
|
7201
7272
|
}
|
|
7202
|
-
else if (!this.
|
|
7203
|
-
this.
|
|
7273
|
+
else if (!this.argumentsToBeDeoptimized.has(entity)) {
|
|
7274
|
+
this.argumentsToBeDeoptimized.add(entity);
|
|
7204
7275
|
for (const field of this.deoptimizedFields) {
|
|
7205
|
-
entity.deoptimizePath([field]);
|
|
7276
|
+
entity.deoptimizePath([...this.initPath, field]);
|
|
7206
7277
|
}
|
|
7207
7278
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
7208
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
7279
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
7209
7280
|
}
|
|
7210
7281
|
}
|
|
7211
7282
|
}
|
|
7283
|
+
/** This says we should not make assumptions about the value of the parameter.
|
|
7284
|
+
* This is different from deoptimization that will also cause argument values
|
|
7285
|
+
* to be deoptimized. */
|
|
7212
7286
|
markReassigned() {
|
|
7213
7287
|
if (this.isReassigned) {
|
|
7214
7288
|
return;
|
|
7215
7289
|
}
|
|
7216
7290
|
super.markReassigned();
|
|
7217
|
-
for (const expression of this.
|
|
7291
|
+
for (const expression of this.expressionsDependingOnKnownValue) {
|
|
7218
7292
|
expression.deoptimizeCache();
|
|
7219
7293
|
}
|
|
7220
|
-
this.
|
|
7294
|
+
this.expressionsDependingOnKnownValue = parseAst_js.EMPTY_ARRAY;
|
|
7221
7295
|
}
|
|
7222
7296
|
deoptimizeCache() {
|
|
7223
7297
|
this.markReassigned();
|
|
@@ -7234,7 +7308,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
7234
7308
|
}
|
|
7235
7309
|
if (this.knownValue === null) {
|
|
7236
7310
|
this.knownValue = argument;
|
|
7237
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
7311
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(this.initPath, SHARED_RECURSION_TRACKER, this);
|
|
7238
7312
|
return;
|
|
7239
7313
|
}
|
|
7240
7314
|
// the same literal or identifier, do nothing
|
|
@@ -7250,7 +7324,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
7250
7324
|
return;
|
|
7251
7325
|
}
|
|
7252
7326
|
// add tracking for the new argument
|
|
7253
|
-
const newValue = argument.getLiteralValueAtPath(
|
|
7327
|
+
const newValue = argument.getLiteralValueAtPath(this.initPath, SHARED_RECURSION_TRACKER, this);
|
|
7254
7328
|
if (newValue !== oldValue) {
|
|
7255
7329
|
this.markReassigned();
|
|
7256
7330
|
}
|
|
@@ -7272,20 +7346,25 @@ class ParameterVariable extends LocalVariable {
|
|
|
7272
7346
|
return UnknownValue;
|
|
7273
7347
|
}
|
|
7274
7348
|
const knownValue = this.getKnownValue();
|
|
7275
|
-
this.
|
|
7276
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
7349
|
+
this.expressionsDependingOnKnownValue.push(origin);
|
|
7350
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath([...this.initPath, ...path], recursionTracker, origin), UnknownValue);
|
|
7277
7351
|
}
|
|
7278
7352
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7279
|
-
|
|
7353
|
+
const { type } = interaction;
|
|
7354
|
+
if (this.isReassigned || type === INTERACTION_ASSIGNED) {
|
|
7280
7355
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7281
7356
|
}
|
|
7282
|
-
|
|
7283
|
-
|
|
7357
|
+
return (!(type === INTERACTION_CALLED
|
|
7358
|
+
? (interaction.withNew
|
|
7359
|
+
? context.instantiated
|
|
7360
|
+
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
7361
|
+
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
7362
|
+
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
7284
7363
|
}
|
|
7285
7364
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
7286
7365
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
7287
7366
|
if (path.length >= 2 ||
|
|
7288
|
-
this.
|
|
7367
|
+
this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
7289
7368
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
7290
7369
|
(path.length === 1 &&
|
|
7291
7370
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
@@ -7294,10 +7373,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
7294
7373
|
return;
|
|
7295
7374
|
}
|
|
7296
7375
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
7297
|
-
for (const entity of this.
|
|
7298
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
7376
|
+
for (const entity of this.argumentsToBeDeoptimized) {
|
|
7377
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
7299
7378
|
}
|
|
7300
|
-
if (!this.
|
|
7379
|
+
if (!this.argumentsToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
7301
7380
|
this.deoptimizationInteractions.push({
|
|
7302
7381
|
interaction,
|
|
7303
7382
|
path
|
|
@@ -7318,17 +7397,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
7318
7397
|
return;
|
|
7319
7398
|
}
|
|
7320
7399
|
this.deoptimizedFields.add(key);
|
|
7321
|
-
for (const entity of this.
|
|
7400
|
+
for (const entity of this.argumentsToBeDeoptimized) {
|
|
7322
7401
|
// We do not need a recursion tracker here as we already track whether
|
|
7323
7402
|
// this field is deoptimized
|
|
7324
|
-
entity.deoptimizePath([key]);
|
|
7403
|
+
entity.deoptimizePath([...this.initPath, key]);
|
|
7325
7404
|
}
|
|
7326
7405
|
if (key === UnknownKey) {
|
|
7327
7406
|
// save some memory
|
|
7328
7407
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
7329
7408
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
7330
7409
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
7331
|
-
this.
|
|
7410
|
+
this.argumentsToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
7332
7411
|
}
|
|
7333
7412
|
}
|
|
7334
7413
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -7343,11 +7422,14 @@ class ParameterVariable extends LocalVariable {
|
|
|
7343
7422
|
}
|
|
7344
7423
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
7345
7424
|
}
|
|
7425
|
+
includeArgumentPaths(entity, context) {
|
|
7426
|
+
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
7427
|
+
}
|
|
7346
7428
|
}
|
|
7347
7429
|
|
|
7348
7430
|
class ThisVariable extends ParameterVariable {
|
|
7349
7431
|
constructor(context) {
|
|
7350
|
-
super('this', null, context);
|
|
7432
|
+
super('this', null, EMPTY_PATH, context);
|
|
7351
7433
|
}
|
|
7352
7434
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7353
7435
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -7359,7 +7441,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7359
7441
|
super(parent, parent.context);
|
|
7360
7442
|
this.parent = parent;
|
|
7361
7443
|
}
|
|
7362
|
-
addDeclaration(identifier, context, init, kind) {
|
|
7444
|
+
addDeclaration(identifier, context, init, includedInitPath, kind) {
|
|
7363
7445
|
if (kind === 'var') {
|
|
7364
7446
|
const name = identifier.name;
|
|
7365
7447
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -7372,7 +7454,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7372
7454
|
// the assignment actually goes to the parameter and the var is
|
|
7373
7455
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
7374
7456
|
// parameter
|
|
7375
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
7457
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, includedInitPath, kind);
|
|
7376
7458
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
7377
7459
|
// names. If we ever implement a logic that splits initialization and
|
|
7378
7460
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -7391,7 +7473,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7391
7473
|
return context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
7392
7474
|
}
|
|
7393
7475
|
// We only add parameters to parameter scopes
|
|
7394
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
7476
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, includedInitPath, kind);
|
|
7395
7477
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
7396
7478
|
// We cannot call deoptimizePath here.
|
|
7397
7479
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -7399,7 +7481,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7399
7481
|
this.addHoistedVariable(name, declaredVariable);
|
|
7400
7482
|
return declaredVariable;
|
|
7401
7483
|
}
|
|
7402
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
7484
|
+
return super.addDeclaration(identifier, context, init, includedInitPath, kind);
|
|
7403
7485
|
}
|
|
7404
7486
|
}
|
|
7405
7487
|
|
|
@@ -7409,7 +7491,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7409
7491
|
}
|
|
7410
7492
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
7411
7493
|
// be redeclared, functions and var can redeclare each other
|
|
7412
|
-
addDeclaration(identifier, context, init, kind) {
|
|
7494
|
+
addDeclaration(identifier, context, init, includedInitPath, kind) {
|
|
7413
7495
|
const name = identifier.name;
|
|
7414
7496
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
7415
7497
|
if (existingVariable) {
|
|
@@ -7421,7 +7503,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7421
7503
|
}
|
|
7422
7504
|
context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
7423
7505
|
}
|
|
7424
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
7506
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, includedInitPath, context, kind);
|
|
7425
7507
|
this.variables.set(name, newVariable);
|
|
7426
7508
|
return newVariable;
|
|
7427
7509
|
}
|
|
@@ -7430,21 +7512,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7430
7512
|
class ParameterScope extends ChildScope {
|
|
7431
7513
|
constructor(parent, isCatchScope) {
|
|
7432
7514
|
super(parent, parent.context);
|
|
7433
|
-
this.parameters = [];
|
|
7434
7515
|
this.hasRest = false;
|
|
7516
|
+
this.parameters = [];
|
|
7435
7517
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
7436
7518
|
}
|
|
7437
7519
|
/**
|
|
7438
7520
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
7439
7521
|
* order, i.e. from left to right.
|
|
7440
7522
|
*/
|
|
7441
|
-
addParameterDeclaration(identifier) {
|
|
7523
|
+
addParameterDeclaration(identifier, argumentPath) {
|
|
7442
7524
|
const { name, start } = identifier;
|
|
7443
7525
|
const existingParameter = this.variables.get(name);
|
|
7444
7526
|
if (existingParameter) {
|
|
7445
7527
|
return this.context.error(parseAst_js.logDuplicateArgumentNameError(name), start);
|
|
7446
7528
|
}
|
|
7447
|
-
const variable = new ParameterVariable(name, identifier, this.context);
|
|
7529
|
+
const variable = new ParameterVariable(name, identifier, argumentPath, this.context);
|
|
7448
7530
|
this.variables.set(name, variable);
|
|
7449
7531
|
// We also add it to the body scope to detect name conflicts with local
|
|
7450
7532
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -7462,43 +7544,54 @@ class ParameterScope extends ChildScope {
|
|
|
7462
7544
|
}
|
|
7463
7545
|
this.hasRest = hasRest;
|
|
7464
7546
|
}
|
|
7465
|
-
includeCallArguments(context,
|
|
7547
|
+
includeCallArguments(context, interaction) {
|
|
7466
7548
|
let calledFromTryStatement = false;
|
|
7467
7549
|
let argumentIncluded = false;
|
|
7468
7550
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7551
|
+
const { args } = interaction;
|
|
7552
|
+
let lastExplicitlyIncludedIndex = args.length - 1;
|
|
7553
|
+
// If there is a SpreadElement, we need to include all arguments after it
|
|
7554
|
+
// because we no longer know which argument corresponds to which parameter.
|
|
7555
|
+
for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) {
|
|
7556
|
+
if (args[argumentIndex] instanceof SpreadElement && !argumentIncluded) {
|
|
7557
|
+
argumentIncluded = true;
|
|
7558
|
+
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
7559
|
+
}
|
|
7560
|
+
if (argumentIncluded) {
|
|
7561
|
+
args[argumentIndex].includePath(UNKNOWN_PATH, context, false);
|
|
7475
7562
|
}
|
|
7476
7563
|
}
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7564
|
+
// Now we go backwards either starting from the last argument or before the
|
|
7565
|
+
// first SpreadElement to ensure all arguments before are included as needed
|
|
7566
|
+
for (let index = lastExplicitlyIncludedIndex; index >= 1; index--) {
|
|
7567
|
+
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
7568
|
+
const argument = args[index];
|
|
7480
7569
|
if (parameterVariables) {
|
|
7481
7570
|
calledFromTryStatement = false;
|
|
7482
7571
|
if (parameterVariables.length === 0) {
|
|
7483
|
-
// handle empty destructuring
|
|
7572
|
+
// handle empty destructuring to avoid destructuring undefined
|
|
7484
7573
|
argumentIncluded = true;
|
|
7485
7574
|
}
|
|
7486
7575
|
else {
|
|
7487
7576
|
for (const variable of parameterVariables) {
|
|
7488
|
-
if (variable.included) {
|
|
7489
|
-
argumentIncluded = true;
|
|
7490
|
-
}
|
|
7491
7577
|
if (variable.calledFromTryStatement) {
|
|
7492
7578
|
calledFromTryStatement = true;
|
|
7493
7579
|
}
|
|
7580
|
+
if (variable.included) {
|
|
7581
|
+
argumentIncluded = true;
|
|
7582
|
+
if (calledFromTryStatement) {
|
|
7583
|
+
argument.includePath(UNKNOWN_PATH, context, true);
|
|
7584
|
+
}
|
|
7585
|
+
else {
|
|
7586
|
+
variable.includeArgumentPaths(argument, context);
|
|
7587
|
+
}
|
|
7588
|
+
}
|
|
7494
7589
|
}
|
|
7495
7590
|
}
|
|
7496
7591
|
}
|
|
7497
|
-
if (!
|
|
7592
|
+
if (!argument.included && (argumentIncluded || argument.shouldBeIncluded(context))) {
|
|
7498
7593
|
argumentIncluded = true;
|
|
7499
|
-
|
|
7500
|
-
if (argumentIncluded) {
|
|
7501
|
-
argument.include(context, calledFromTryStatement);
|
|
7594
|
+
argument.includePath(EMPTY_PATH, context, calledFromTryStatement);
|
|
7502
7595
|
}
|
|
7503
7596
|
}
|
|
7504
7597
|
}
|
|
@@ -7513,11 +7606,61 @@ class ReturnValueScope extends ParameterScope {
|
|
|
7513
7606
|
addReturnExpression(expression) {
|
|
7514
7607
|
this.returnExpressions.push(expression);
|
|
7515
7608
|
}
|
|
7609
|
+
deoptimizeArgumentsOnCall(interaction) {
|
|
7610
|
+
const { parameters } = this;
|
|
7611
|
+
const { args } = interaction;
|
|
7612
|
+
let position = 0;
|
|
7613
|
+
for (; position < args.length - 1; position++) {
|
|
7614
|
+
// Only the "this" argument arg[0] can be null
|
|
7615
|
+
const argument = args[position + 1];
|
|
7616
|
+
if (argument instanceof SpreadElement) {
|
|
7617
|
+
// This deoptimizes the current and remaining parameters and arguments
|
|
7618
|
+
for (; position < parameters.length; position++) {
|
|
7619
|
+
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
7620
|
+
parameters[position].forEach(variable => variable.markReassigned());
|
|
7621
|
+
}
|
|
7622
|
+
break;
|
|
7623
|
+
}
|
|
7624
|
+
if (this.hasRest && position >= parameters.length - 1) {
|
|
7625
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7626
|
+
}
|
|
7627
|
+
else {
|
|
7628
|
+
const variables = parameters[position];
|
|
7629
|
+
if (variables) {
|
|
7630
|
+
for (const variable of variables) {
|
|
7631
|
+
variable.addArgumentValue(argument);
|
|
7632
|
+
}
|
|
7633
|
+
}
|
|
7634
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7637
|
+
for (; position < parameters.length; position++) {
|
|
7638
|
+
for (const variable of parameters[position]) {
|
|
7639
|
+
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
}
|
|
7516
7643
|
getReturnExpression() {
|
|
7517
7644
|
if (this.returnExpression === null)
|
|
7518
7645
|
this.updateReturnExpression();
|
|
7519
7646
|
return this.returnExpression;
|
|
7520
7647
|
}
|
|
7648
|
+
deoptimizeAllParameters() {
|
|
7649
|
+
for (const parameter of this.parameters) {
|
|
7650
|
+
for (const variable of parameter) {
|
|
7651
|
+
variable.deoptimizePath(UNKNOWN_PATH);
|
|
7652
|
+
variable.markReassigned();
|
|
7653
|
+
}
|
|
7654
|
+
}
|
|
7655
|
+
}
|
|
7656
|
+
reassignAllParameters() {
|
|
7657
|
+
for (const parameter of this.parameters) {
|
|
7658
|
+
for (const variable of parameter) {
|
|
7659
|
+
variable.markReassigned();
|
|
7660
|
+
}
|
|
7661
|
+
}
|
|
7662
|
+
}
|
|
7663
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
7521
7664
|
updateReturnExpression() {
|
|
7522
7665
|
if (this.returnExpressions.length === 1) {
|
|
7523
7666
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -7533,24 +7676,26 @@ class ReturnValueScope extends ParameterScope {
|
|
|
7533
7676
|
|
|
7534
7677
|
class FunctionScope extends ReturnValueScope {
|
|
7535
7678
|
constructor(parent) {
|
|
7536
|
-
const { context } = parent;
|
|
7537
7679
|
super(parent, false);
|
|
7680
|
+
const { context } = parent;
|
|
7538
7681
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
7539
7682
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
7540
7683
|
}
|
|
7541
7684
|
findLexicalBoundary() {
|
|
7542
7685
|
return this;
|
|
7543
7686
|
}
|
|
7544
|
-
includeCallArguments(context,
|
|
7545
|
-
super.includeCallArguments(context,
|
|
7687
|
+
includeCallArguments(context, interaction) {
|
|
7688
|
+
super.includeCallArguments(context, interaction);
|
|
7546
7689
|
if (this.argumentsVariable.included) {
|
|
7547
|
-
|
|
7548
|
-
|
|
7549
|
-
|
|
7550
|
-
}
|
|
7690
|
+
const { args } = interaction;
|
|
7691
|
+
for (let argumentIndex = 1; argumentIndex < args.length; argumentIndex++) {
|
|
7692
|
+
args[argumentIndex]?.includePath(UNKNOWN_PATH, context, false);
|
|
7551
7693
|
}
|
|
7552
7694
|
}
|
|
7553
7695
|
}
|
|
7696
|
+
addArgumentToBeDeoptimized(argument) {
|
|
7697
|
+
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
7698
|
+
}
|
|
7554
7699
|
}
|
|
7555
7700
|
|
|
7556
7701
|
class ExpressionStatement extends NodeBase {
|
|
@@ -7616,7 +7761,7 @@ class BlockStatement extends NodeBase {
|
|
|
7616
7761
|
}
|
|
7617
7762
|
return false;
|
|
7618
7763
|
}
|
|
7619
|
-
|
|
7764
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
7620
7765
|
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
7621
7766
|
this.included = true;
|
|
7622
7767
|
this.directlyIncluded = true;
|
|
@@ -7624,7 +7769,7 @@ class BlockStatement extends NodeBase {
|
|
|
7624
7769
|
includeChildrenRecursively = true;
|
|
7625
7770
|
for (const node of this.body) {
|
|
7626
7771
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
7627
|
-
node.
|
|
7772
|
+
node.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7628
7773
|
}
|
|
7629
7774
|
}
|
|
7630
7775
|
}
|
|
@@ -7653,9 +7798,9 @@ class RestElement extends NodeBase {
|
|
|
7653
7798
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
7654
7799
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
7655
7800
|
}
|
|
7656
|
-
declare(kind, init) {
|
|
7801
|
+
declare(kind, includedInitPath, init) {
|
|
7657
7802
|
this.declarationInit = init;
|
|
7658
|
-
return this.argument.declare(kind,
|
|
7803
|
+
return this.argument.declare(kind, includedInitPath.at(-1) === UnknownKey ? includedInitPath : [...includedInitPath, UnknownKey], init);
|
|
7659
7804
|
}
|
|
7660
7805
|
deoptimizePath(path) {
|
|
7661
7806
|
if (path.length === 0) {
|
|
@@ -7666,6 +7811,12 @@ class RestElement extends NodeBase {
|
|
|
7666
7811
|
return (path.length > 0 ||
|
|
7667
7812
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
7668
7813
|
}
|
|
7814
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
7815
|
+
this.included = true;
|
|
7816
|
+
// This should just include the identifier, its properties should be
|
|
7817
|
+
// included where the variable is used.
|
|
7818
|
+
this.argument.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
7819
|
+
}
|
|
7669
7820
|
markDeclarationReached() {
|
|
7670
7821
|
this.argument.markDeclarationReached();
|
|
7671
7822
|
}
|
|
@@ -7681,8 +7832,8 @@ class RestElement extends NodeBase {
|
|
|
7681
7832
|
class FunctionBase extends NodeBase {
|
|
7682
7833
|
constructor() {
|
|
7683
7834
|
super(...arguments);
|
|
7684
|
-
this.objectEntity = null;
|
|
7685
7835
|
this.parameterVariableValuesDeoptimized = false;
|
|
7836
|
+
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
7686
7837
|
}
|
|
7687
7838
|
get async() {
|
|
7688
7839
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -7702,53 +7853,9 @@ class FunctionBase extends NodeBase {
|
|
|
7702
7853
|
set generator(value) {
|
|
7703
7854
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
7704
7855
|
}
|
|
7705
|
-
updateParameterVariableValues(_arguments) {
|
|
7706
|
-
for (let position = 0; position < this.params.length; position++) {
|
|
7707
|
-
const parameter = this.params[position];
|
|
7708
|
-
if (!(parameter instanceof Identifier)) {
|
|
7709
|
-
continue;
|
|
7710
|
-
}
|
|
7711
|
-
const parameterVariable = parameter.variable;
|
|
7712
|
-
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
7713
|
-
parameterVariable.updateKnownValue(argument);
|
|
7714
|
-
}
|
|
7715
|
-
}
|
|
7716
|
-
deoptimizeParameterVariableValues() {
|
|
7717
|
-
for (const parameter of this.params) {
|
|
7718
|
-
if (parameter instanceof Identifier) {
|
|
7719
|
-
const parameterVariable = parameter.variable;
|
|
7720
|
-
parameterVariable.markReassigned();
|
|
7721
|
-
}
|
|
7722
|
-
}
|
|
7723
|
-
}
|
|
7724
7856
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7725
|
-
if (interaction.type === INTERACTION_CALLED) {
|
|
7726
|
-
|
|
7727
|
-
const { args } = interaction;
|
|
7728
|
-
let hasRest = false;
|
|
7729
|
-
for (let position = 0; position < args.length - 1; position++) {
|
|
7730
|
-
const parameter = this.params[position];
|
|
7731
|
-
// Only the "this" argument arg[0] can be null
|
|
7732
|
-
const argument = args[position + 1];
|
|
7733
|
-
if (argument instanceof SpreadElement) {
|
|
7734
|
-
this.deoptimizeParameterVariableValues();
|
|
7735
|
-
}
|
|
7736
|
-
if (hasRest || parameter instanceof RestElement) {
|
|
7737
|
-
hasRest = true;
|
|
7738
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7739
|
-
}
|
|
7740
|
-
else if (parameter instanceof Identifier) {
|
|
7741
|
-
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
7742
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
7743
|
-
}
|
|
7744
|
-
else if (parameter) {
|
|
7745
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7746
|
-
}
|
|
7747
|
-
else {
|
|
7748
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
7749
|
-
}
|
|
7750
|
-
}
|
|
7751
|
-
this.updateParameterVariableValues(args);
|
|
7857
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
7858
|
+
this.scope.deoptimizeArgumentsOnCall(interaction);
|
|
7752
7859
|
}
|
|
7753
7860
|
else {
|
|
7754
7861
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -7760,12 +7867,7 @@ class FunctionBase extends NodeBase {
|
|
|
7760
7867
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
7761
7868
|
// which means the return expression and parameters need to be reassigned
|
|
7762
7869
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
7763
|
-
|
|
7764
|
-
for (const parameter of parameterList) {
|
|
7765
|
-
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
7766
|
-
parameter.markReassigned();
|
|
7767
|
-
}
|
|
7768
|
-
}
|
|
7870
|
+
this.scope.deoptimizeAllParameters();
|
|
7769
7871
|
}
|
|
7770
7872
|
}
|
|
7771
7873
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -7822,22 +7924,19 @@ class FunctionBase extends NodeBase {
|
|
|
7822
7924
|
}
|
|
7823
7925
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
7824
7926
|
}
|
|
7825
|
-
|
|
7826
|
-
if (!this.parameterVariableValuesDeoptimized
|
|
7927
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
7928
|
+
if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) {
|
|
7827
7929
|
this.parameterVariableValuesDeoptimized = true;
|
|
7828
|
-
this.
|
|
7930
|
+
this.scope.reassignAllParameters();
|
|
7829
7931
|
}
|
|
7830
7932
|
if (!this.deoptimized)
|
|
7831
7933
|
this.applyDeoptimizations();
|
|
7832
7934
|
this.included = true;
|
|
7833
7935
|
const { brokenFlow } = context;
|
|
7834
7936
|
context.brokenFlow = false;
|
|
7835
|
-
this.body.
|
|
7937
|
+
this.body.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7836
7938
|
context.brokenFlow = brokenFlow;
|
|
7837
7939
|
}
|
|
7838
|
-
includeCallArguments(context, parameters) {
|
|
7839
|
-
this.scope.includeCallArguments(context, parameters);
|
|
7840
|
-
}
|
|
7841
7940
|
initialise() {
|
|
7842
7941
|
super.initialise();
|
|
7843
7942
|
if (this.body instanceof BlockStatement) {
|
|
@@ -7859,11 +7958,10 @@ class FunctionBase extends NodeBase {
|
|
|
7859
7958
|
// so that the scope already knows all parameters and can detect conflicts
|
|
7860
7959
|
// when parsing the body.
|
|
7861
7960
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
7862
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
7961
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
7863
7962
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
7864
7963
|
return super.parseNode(esTreeNode);
|
|
7865
7964
|
}
|
|
7866
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
7867
7965
|
applyDeoptimizations() { }
|
|
7868
7966
|
}
|
|
7869
7967
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
@@ -7878,13 +7976,13 @@ class FunctionNode extends FunctionBase {
|
|
|
7878
7976
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
7879
7977
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
7880
7978
|
// constructed entity.
|
|
7881
|
-
this.scope.thisVariable.
|
|
7979
|
+
this.scope.thisVariable.addArgumentValue(this.constructedEntity);
|
|
7882
7980
|
}
|
|
7883
7981
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7884
7982
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7885
7983
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
7886
7984
|
// args[0] is the "this" argument
|
|
7887
|
-
this.scope.thisVariable.
|
|
7985
|
+
this.scope.thisVariable.addArgumentValue(interaction.args[0]);
|
|
7888
7986
|
}
|
|
7889
7987
|
}
|
|
7890
7988
|
hasEffects(context) {
|
|
@@ -7925,22 +8023,19 @@ class FunctionNode extends FunctionBase {
|
|
|
7925
8023
|
}
|
|
7926
8024
|
return false;
|
|
7927
8025
|
}
|
|
7928
|
-
|
|
7929
|
-
super.
|
|
7930
|
-
this.id?.
|
|
8026
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
8027
|
+
super.includePath(path, context, includeChildrenRecursively);
|
|
8028
|
+
this.id?.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
7931
8029
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
7932
8030
|
for (const parameter of this.params) {
|
|
7933
8031
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
7934
|
-
parameter.
|
|
8032
|
+
parameter.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
7935
8033
|
}
|
|
7936
8034
|
}
|
|
7937
8035
|
}
|
|
7938
8036
|
initialise() {
|
|
7939
8037
|
super.initialise();
|
|
7940
|
-
this.id?.declare('function', this);
|
|
7941
|
-
}
|
|
7942
|
-
addArgumentToBeDeoptimized(argument) {
|
|
7943
|
-
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
8038
|
+
this.id?.declare('function', EMPTY_PATH, this);
|
|
7944
8039
|
}
|
|
7945
8040
|
getObjectEntity() {
|
|
7946
8041
|
if (this.objectEntity !== null) {
|
|
@@ -7989,10 +8084,11 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
7989
8084
|
return declarationEnd + generatorStarPos + 1;
|
|
7990
8085
|
}
|
|
7991
8086
|
class ExportDefaultDeclaration extends NodeBase {
|
|
7992
|
-
|
|
7993
|
-
|
|
8087
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
8088
|
+
this.included = true;
|
|
8089
|
+
this.declaration.includePath(path, context, includeChildrenRecursively);
|
|
7994
8090
|
if (includeChildrenRecursively) {
|
|
7995
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
8091
|
+
this.scope.context.includeVariableInModule(this.variable, path);
|
|
7996
8092
|
}
|
|
7997
8093
|
}
|
|
7998
8094
|
initialise() {
|
|
@@ -8565,27 +8661,27 @@ class MemberExpression extends NodeBase {
|
|
|
8565
8661
|
}
|
|
8566
8662
|
return true;
|
|
8567
8663
|
}
|
|
8568
|
-
|
|
8664
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
8569
8665
|
if (!this.deoptimized)
|
|
8570
8666
|
this.applyDeoptimizations();
|
|
8571
|
-
this.includeProperties(context, includeChildrenRecursively);
|
|
8667
|
+
this.includeProperties(path, [this.getPropertyKey(), ...path], context, includeChildrenRecursively);
|
|
8572
8668
|
}
|
|
8573
8669
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
8574
8670
|
if (!this.assignmentDeoptimized)
|
|
8575
8671
|
this.applyAssignmentDeoptimization();
|
|
8576
8672
|
if (deoptimizeAccess) {
|
|
8577
|
-
this.
|
|
8673
|
+
this.includePath([this.getPropertyKey()], context, includeChildrenRecursively);
|
|
8578
8674
|
}
|
|
8579
8675
|
else {
|
|
8580
|
-
this.includeProperties(context, includeChildrenRecursively);
|
|
8676
|
+
this.includeProperties(EMPTY_PATH, [this.getPropertyKey()], context, includeChildrenRecursively);
|
|
8581
8677
|
}
|
|
8582
8678
|
}
|
|
8583
|
-
includeCallArguments(context,
|
|
8679
|
+
includeCallArguments(context, interaction) {
|
|
8584
8680
|
if (this.variable) {
|
|
8585
|
-
this.variable.includeCallArguments(context,
|
|
8681
|
+
this.variable.includeCallArguments(context, interaction);
|
|
8586
8682
|
}
|
|
8587
8683
|
else {
|
|
8588
|
-
super.includeCallArguments(context,
|
|
8684
|
+
super.includeCallArguments(context, interaction);
|
|
8589
8685
|
}
|
|
8590
8686
|
}
|
|
8591
8687
|
initialise() {
|
|
@@ -8654,7 +8750,7 @@ class MemberExpression extends NodeBase {
|
|
|
8654
8750
|
const variable = this.scope.findVariable(this.object.name);
|
|
8655
8751
|
if (variable.isNamespace) {
|
|
8656
8752
|
if (this.variable) {
|
|
8657
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
8753
|
+
this.scope.context.includeVariableInModule(this.variable, UNKNOWN_PATH);
|
|
8658
8754
|
}
|
|
8659
8755
|
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
8660
8756
|
}
|
|
@@ -8681,15 +8777,18 @@ class MemberExpression extends NodeBase {
|
|
|
8681
8777
|
(propertyReadSideEffects === 'always' ||
|
|
8682
8778
|
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
8683
8779
|
}
|
|
8684
|
-
includeProperties(context, includeChildrenRecursively) {
|
|
8780
|
+
includeProperties(includedPath, objectPath, context, includeChildrenRecursively) {
|
|
8685
8781
|
if (!this.included) {
|
|
8686
8782
|
this.included = true;
|
|
8687
8783
|
if (this.variable) {
|
|
8688
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
8784
|
+
this.scope.context.includeVariableInModule(this.variable, includedPath);
|
|
8689
8785
|
}
|
|
8690
8786
|
}
|
|
8691
|
-
|
|
8692
|
-
|
|
8787
|
+
else if (includedPath.length > 0) {
|
|
8788
|
+
this.variable?.includePath(includedPath, context);
|
|
8789
|
+
}
|
|
8790
|
+
this.object.includePath(objectPath, context, includeChildrenRecursively);
|
|
8791
|
+
this.property.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
8693
8792
|
}
|
|
8694
8793
|
}
|
|
8695
8794
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -8732,7 +8831,7 @@ class MetaProperty extends NodeBase {
|
|
|
8732
8831
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8733
8832
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
8734
8833
|
}
|
|
8735
|
-
|
|
8834
|
+
includePath() {
|
|
8736
8835
|
if (!this.included) {
|
|
8737
8836
|
this.included = true;
|
|
8738
8837
|
if (this.meta.name === IMPORT) {
|
|
@@ -8851,7 +8950,7 @@ class UndefinedVariable extends Variable {
|
|
|
8851
8950
|
|
|
8852
8951
|
class ExportDefaultVariable extends LocalVariable {
|
|
8853
8952
|
constructor(name, exportDefaultDeclaration, context) {
|
|
8854
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
8953
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, EMPTY_PATH, context, 'other');
|
|
8855
8954
|
this.hasId = false;
|
|
8856
8955
|
this.originalId = null;
|
|
8857
8956
|
this.originalVariable = null;
|
|
@@ -9000,8 +9099,8 @@ class NamespaceVariable extends Variable {
|
|
|
9000
9099
|
return (!memberVariable ||
|
|
9001
9100
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
9002
9101
|
}
|
|
9003
|
-
|
|
9004
|
-
super.
|
|
9102
|
+
includePath(path, context) {
|
|
9103
|
+
super.includePath(path, context);
|
|
9005
9104
|
this.context.includeAllExports();
|
|
9006
9105
|
}
|
|
9007
9106
|
prepare(accessedGlobalsByScope) {
|
|
@@ -9094,9 +9193,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
9094
9193
|
getName(getPropertyAccess) {
|
|
9095
9194
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
9096
9195
|
}
|
|
9097
|
-
|
|
9098
|
-
super.
|
|
9099
|
-
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
9196
|
+
includePath(path, context) {
|
|
9197
|
+
super.includePath(path, context);
|
|
9198
|
+
this.context.includeVariableInModule(this.syntheticNamespace, path);
|
|
9100
9199
|
}
|
|
9101
9200
|
setRenderNames(baseName, name) {
|
|
9102
9201
|
super.setRenderNames(baseName, name);
|
|
@@ -12293,11 +12392,14 @@ class ArrayPattern extends NodeBase {
|
|
|
12293
12392
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
12294
12393
|
}
|
|
12295
12394
|
}
|
|
12296
|
-
declare(kind) {
|
|
12395
|
+
declare(kind, includedInitPath, init) {
|
|
12297
12396
|
const variables = [];
|
|
12397
|
+
const includedPatternPath = includedInitPath.at(-1) === UnknownKey
|
|
12398
|
+
? includedInitPath
|
|
12399
|
+
: [...includedInitPath, UnknownInteger];
|
|
12298
12400
|
for (const element of this.elements) {
|
|
12299
12401
|
if (element !== null) {
|
|
12300
|
-
variables.push(...element.declare(kind,
|
|
12402
|
+
variables.push(...element.declare(kind, includedPatternPath, init));
|
|
12301
12403
|
}
|
|
12302
12404
|
}
|
|
12303
12405
|
return variables;
|
|
@@ -12370,11 +12472,11 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
12370
12472
|
this.parent.callee === this;
|
|
12371
12473
|
return isIIFE || super.onlyFunctionCallUsed();
|
|
12372
12474
|
}
|
|
12373
|
-
|
|
12374
|
-
super.
|
|
12475
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
12476
|
+
super.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
12375
12477
|
for (const parameter of this.params) {
|
|
12376
12478
|
if (!(parameter instanceof Identifier)) {
|
|
12377
|
-
parameter.
|
|
12479
|
+
parameter.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
12378
12480
|
}
|
|
12379
12481
|
}
|
|
12380
12482
|
}
|
|
@@ -12397,10 +12499,10 @@ class ObjectPattern extends NodeBase {
|
|
|
12397
12499
|
}
|
|
12398
12500
|
}
|
|
12399
12501
|
}
|
|
12400
|
-
declare(kind, init) {
|
|
12502
|
+
declare(kind, includedInitPath, init) {
|
|
12401
12503
|
const variables = [];
|
|
12402
12504
|
for (const property of this.properties) {
|
|
12403
|
-
variables.push(...property.declare(kind, init));
|
|
12505
|
+
variables.push(...property.declare(kind, includedInitPath, init));
|
|
12404
12506
|
}
|
|
12405
12507
|
return variables;
|
|
12406
12508
|
}
|
|
@@ -12421,11 +12523,22 @@ class ObjectPattern extends NodeBase {
|
|
|
12421
12523
|
}
|
|
12422
12524
|
return false;
|
|
12423
12525
|
}
|
|
12526
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
12527
|
+
this.included = true;
|
|
12528
|
+
for (const property of this.properties) {
|
|
12529
|
+
// Including a pattern should not deeply include its children as that
|
|
12530
|
+
// would include all children of nested variable references. Their paths
|
|
12531
|
+
// will be included via their usages instead, and we store the path in
|
|
12532
|
+
// the pattern when declaring the variables.
|
|
12533
|
+
property.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
12534
|
+
}
|
|
12535
|
+
}
|
|
12424
12536
|
markDeclarationReached() {
|
|
12425
12537
|
for (const property of this.properties) {
|
|
12426
12538
|
property.markDeclarationReached();
|
|
12427
12539
|
}
|
|
12428
12540
|
}
|
|
12541
|
+
applyDeoptimizations() { }
|
|
12429
12542
|
}
|
|
12430
12543
|
|
|
12431
12544
|
class AssignmentExpression extends NodeBase {
|
|
@@ -12440,7 +12553,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
12440
12553
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
12441
12554
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
12442
12555
|
}
|
|
12443
|
-
|
|
12556
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
12444
12557
|
const { deoptimized, left, right, operator } = this;
|
|
12445
12558
|
if (!deoptimized)
|
|
12446
12559
|
this.applyDeoptimizations();
|
|
@@ -12451,7 +12564,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
12451
12564
|
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
12452
12565
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
12453
12566
|
}
|
|
12454
|
-
right.
|
|
12567
|
+
right.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
12455
12568
|
}
|
|
12456
12569
|
initialise() {
|
|
12457
12570
|
super.initialise();
|
|
@@ -12523,8 +12636,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
12523
12636
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
12524
12637
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
12525
12638
|
}
|
|
12526
|
-
declare(kind, init) {
|
|
12527
|
-
return this.left.declare(kind, init);
|
|
12639
|
+
declare(kind, includedInitPath, init) {
|
|
12640
|
+
return this.left.declare(kind, includedInitPath, init);
|
|
12528
12641
|
}
|
|
12529
12642
|
deoptimizePath(path) {
|
|
12530
12643
|
if (path.length === 0) {
|
|
@@ -12555,7 +12668,7 @@ class AwaitExpression extends NodeBase {
|
|
|
12555
12668
|
this.applyDeoptimizations();
|
|
12556
12669
|
return true;
|
|
12557
12670
|
}
|
|
12558
|
-
|
|
12671
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
12559
12672
|
if (!this.deoptimized)
|
|
12560
12673
|
this.applyDeoptimizations();
|
|
12561
12674
|
if (!this.included) {
|
|
@@ -12569,7 +12682,7 @@ class AwaitExpression extends NodeBase {
|
|
|
12569
12682
|
this.scope.context.usesTopLevelAwait = true;
|
|
12570
12683
|
}
|
|
12571
12684
|
}
|
|
12572
|
-
this.argument.
|
|
12685
|
+
this.argument.includePath(path, context, includeChildrenRecursively);
|
|
12573
12686
|
}
|
|
12574
12687
|
}
|
|
12575
12688
|
|
|
@@ -12651,10 +12764,10 @@ class BreakStatement extends NodeBase {
|
|
|
12651
12764
|
context.brokenFlow = true;
|
|
12652
12765
|
return false;
|
|
12653
12766
|
}
|
|
12654
|
-
|
|
12767
|
+
includePath(_, context) {
|
|
12655
12768
|
this.included = true;
|
|
12656
12769
|
if (this.label) {
|
|
12657
|
-
this.label.
|
|
12770
|
+
this.label.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
12658
12771
|
context.includedLabels.add(this.label.name);
|
|
12659
12772
|
}
|
|
12660
12773
|
else {
|
|
@@ -12848,11 +12961,11 @@ class CallExpression extends CallExpressionBase {
|
|
|
12848
12961
|
(calleeHasEffects ||
|
|
12849
12962
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
12850
12963
|
}
|
|
12851
|
-
|
|
12964
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
12852
12965
|
if (!this.deoptimized)
|
|
12853
12966
|
this.applyDeoptimizations();
|
|
12854
12967
|
if (includeChildrenRecursively) {
|
|
12855
|
-
super.
|
|
12968
|
+
super.includePath(path, context, includeChildrenRecursively);
|
|
12856
12969
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
12857
12970
|
this.callee instanceof Identifier &&
|
|
12858
12971
|
this.callee.variable) {
|
|
@@ -12861,9 +12974,18 @@ class CallExpression extends CallExpressionBase {
|
|
|
12861
12974
|
}
|
|
12862
12975
|
else {
|
|
12863
12976
|
this.included = true;
|
|
12864
|
-
|
|
12977
|
+
// If the callee is a member expression and does not have a variable, its
|
|
12978
|
+
// object will already be included via the first argument of the
|
|
12979
|
+
// interaction in includeCallArguments. Including it again can lead to
|
|
12980
|
+
// severe performance problems.
|
|
12981
|
+
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
12982
|
+
this.callee.property.includePath(UNKNOWN_PATH, context, false);
|
|
12983
|
+
}
|
|
12984
|
+
else {
|
|
12985
|
+
this.callee.includePath(UNKNOWN_PATH, context, false);
|
|
12986
|
+
}
|
|
12987
|
+
this.callee.includeCallArguments(context, this.interaction);
|
|
12865
12988
|
}
|
|
12866
|
-
this.callee.includeCallArguments(context, this.arguments);
|
|
12867
12989
|
}
|
|
12868
12990
|
initialise() {
|
|
12869
12991
|
super.initialise();
|
|
@@ -12902,7 +13024,7 @@ class CatchClause extends NodeBase {
|
|
|
12902
13024
|
this.type = type;
|
|
12903
13025
|
if (param) {
|
|
12904
13026
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
12905
|
-
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
13027
|
+
this.param.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION);
|
|
12906
13028
|
}
|
|
12907
13029
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
12908
13030
|
return super.parseNode(esTreeNode);
|
|
@@ -12930,7 +13052,7 @@ class ClassBodyScope extends ChildScope {
|
|
|
12930
13052
|
constructor(parent, classNode) {
|
|
12931
13053
|
const { context } = parent;
|
|
12932
13054
|
super(parent, context);
|
|
12933
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
13055
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, EMPTY_PATH, context, 'other')));
|
|
12934
13056
|
this.instanceScope = new ChildScope(this, context);
|
|
12935
13057
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
12936
13058
|
}
|
|
@@ -12943,11 +13065,11 @@ class ClassBody extends NodeBase {
|
|
|
12943
13065
|
createScope(parentScope) {
|
|
12944
13066
|
this.scope = new ClassBodyScope(parentScope, this.parent);
|
|
12945
13067
|
}
|
|
12946
|
-
|
|
13068
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
12947
13069
|
this.included = true;
|
|
12948
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
13070
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable, UNKNOWN_PATH);
|
|
12949
13071
|
for (const definition of this.body) {
|
|
12950
|
-
definition.
|
|
13072
|
+
definition.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
12951
13073
|
}
|
|
12952
13074
|
}
|
|
12953
13075
|
parseNode(esTreeNode) {
|
|
@@ -13070,26 +13192,26 @@ class ConditionalExpression extends NodeBase {
|
|
|
13070
13192
|
}
|
|
13071
13193
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
13072
13194
|
}
|
|
13073
|
-
|
|
13195
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
13074
13196
|
this.included = true;
|
|
13075
13197
|
const usedBranch = this.getUsedBranch();
|
|
13076
13198
|
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
13077
|
-
this.test.
|
|
13078
|
-
this.consequent.
|
|
13079
|
-
this.alternate.
|
|
13199
|
+
this.test.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13200
|
+
this.consequent.includePath(path, context, includeChildrenRecursively);
|
|
13201
|
+
this.alternate.includePath(path, context, includeChildrenRecursively);
|
|
13080
13202
|
}
|
|
13081
13203
|
else {
|
|
13082
|
-
usedBranch.
|
|
13204
|
+
usedBranch.includePath(path, context, includeChildrenRecursively);
|
|
13083
13205
|
}
|
|
13084
13206
|
}
|
|
13085
|
-
includeCallArguments(context,
|
|
13207
|
+
includeCallArguments(context, interaction) {
|
|
13086
13208
|
const usedBranch = this.getUsedBranch();
|
|
13087
13209
|
if (usedBranch) {
|
|
13088
|
-
usedBranch.includeCallArguments(context,
|
|
13210
|
+
usedBranch.includeCallArguments(context, interaction);
|
|
13089
13211
|
}
|
|
13090
13212
|
else {
|
|
13091
|
-
this.consequent.includeCallArguments(context,
|
|
13092
|
-
this.alternate.includeCallArguments(context,
|
|
13213
|
+
this.consequent.includeCallArguments(context, interaction);
|
|
13214
|
+
this.alternate.includeCallArguments(context, interaction);
|
|
13093
13215
|
}
|
|
13094
13216
|
}
|
|
13095
13217
|
removeAnnotations(code) {
|
|
@@ -13150,10 +13272,10 @@ class ContinueStatement extends NodeBase {
|
|
|
13150
13272
|
context.brokenFlow = true;
|
|
13151
13273
|
return false;
|
|
13152
13274
|
}
|
|
13153
|
-
|
|
13275
|
+
includePath(_, context) {
|
|
13154
13276
|
this.included = true;
|
|
13155
13277
|
if (this.label) {
|
|
13156
|
-
this.label.
|
|
13278
|
+
this.label.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
13157
13279
|
context.includedLabels.add(this.label.name);
|
|
13158
13280
|
}
|
|
13159
13281
|
else {
|
|
@@ -13196,7 +13318,7 @@ function includeLoopBody(context, body, includeChildrenRecursively) {
|
|
|
13196
13318
|
const { brokenFlow, hasBreak, hasContinue } = context;
|
|
13197
13319
|
context.hasBreak = false;
|
|
13198
13320
|
context.hasContinue = false;
|
|
13199
|
-
body.
|
|
13321
|
+
body.includePath(UNKNOWN_PATH, context, includeChildrenRecursively, { asSingleStatement: true });
|
|
13200
13322
|
context.hasBreak = hasBreak;
|
|
13201
13323
|
context.hasContinue = hasContinue;
|
|
13202
13324
|
context.brokenFlow = brokenFlow;
|
|
@@ -13208,9 +13330,9 @@ class DoWhileStatement extends NodeBase {
|
|
|
13208
13330
|
return true;
|
|
13209
13331
|
return hasLoopBodyEffects(context, this.body);
|
|
13210
13332
|
}
|
|
13211
|
-
|
|
13333
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
13212
13334
|
this.included = true;
|
|
13213
|
-
this.test.
|
|
13335
|
+
this.test.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13214
13336
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
13215
13337
|
}
|
|
13216
13338
|
}
|
|
@@ -13281,13 +13403,13 @@ class ForInStatement extends NodeBase {
|
|
|
13281
13403
|
return true;
|
|
13282
13404
|
return hasLoopBodyEffects(context, body);
|
|
13283
13405
|
}
|
|
13284
|
-
|
|
13406
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
13285
13407
|
const { body, deoptimized, left, right } = this;
|
|
13286
13408
|
if (!deoptimized)
|
|
13287
13409
|
this.applyDeoptimizations();
|
|
13288
13410
|
this.included = true;
|
|
13289
13411
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
13290
|
-
right.
|
|
13412
|
+
right.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13291
13413
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
13292
13414
|
}
|
|
13293
13415
|
initialise() {
|
|
@@ -13326,13 +13448,13 @@ class ForOfStatement extends NodeBase {
|
|
|
13326
13448
|
// Placeholder until proper Symbol.Iterator support
|
|
13327
13449
|
return true;
|
|
13328
13450
|
}
|
|
13329
|
-
|
|
13451
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
13330
13452
|
const { body, deoptimized, left, right } = this;
|
|
13331
13453
|
if (!deoptimized)
|
|
13332
13454
|
this.applyDeoptimizations();
|
|
13333
13455
|
this.included = true;
|
|
13334
13456
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
13335
|
-
right.
|
|
13457
|
+
right.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13336
13458
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
13337
13459
|
}
|
|
13338
13460
|
initialise() {
|
|
@@ -13368,11 +13490,13 @@ class ForStatement extends NodeBase {
|
|
|
13368
13490
|
}
|
|
13369
13491
|
return hasLoopBodyEffects(context, this.body);
|
|
13370
13492
|
}
|
|
13371
|
-
|
|
13493
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
13372
13494
|
this.included = true;
|
|
13373
|
-
this.init?.
|
|
13374
|
-
|
|
13375
|
-
|
|
13495
|
+
this.init?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively, {
|
|
13496
|
+
asSingleStatement: true
|
|
13497
|
+
});
|
|
13498
|
+
this.test?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13499
|
+
this.update?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13376
13500
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
13377
13501
|
}
|
|
13378
13502
|
render(code, options) {
|
|
@@ -13413,9 +13537,9 @@ class TrackingScope extends BlockScope {
|
|
|
13413
13537
|
super(...arguments);
|
|
13414
13538
|
this.hoistedDeclarations = [];
|
|
13415
13539
|
}
|
|
13416
|
-
addDeclaration(identifier, context, init, kind) {
|
|
13540
|
+
addDeclaration(identifier, context, init, includedInitPath, kind) {
|
|
13417
13541
|
this.hoistedDeclarations.push(identifier);
|
|
13418
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
13542
|
+
return super.addDeclaration(identifier, context, init, includedInitPath, kind);
|
|
13419
13543
|
}
|
|
13420
13544
|
}
|
|
13421
13545
|
|
|
@@ -13448,7 +13572,7 @@ class IfStatement extends NodeBase {
|
|
|
13448
13572
|
}
|
|
13449
13573
|
return testValue ? this.consequent.hasEffects(context) : !!this.alternate?.hasEffects(context);
|
|
13450
13574
|
}
|
|
13451
|
-
|
|
13575
|
+
includePath(_, context, includeChildrenRecursively) {
|
|
13452
13576
|
this.included = true;
|
|
13453
13577
|
if (includeChildrenRecursively) {
|
|
13454
13578
|
this.includeRecursively(includeChildrenRecursively, context);
|
|
@@ -13523,31 +13647,31 @@ class IfStatement extends NodeBase {
|
|
|
13523
13647
|
}
|
|
13524
13648
|
includeKnownTest(context, testValue) {
|
|
13525
13649
|
if (this.test.shouldBeIncluded(context)) {
|
|
13526
|
-
this.test.
|
|
13650
|
+
this.test.includePath(UNKNOWN_PATH, context, false);
|
|
13527
13651
|
}
|
|
13528
13652
|
if (testValue && this.consequent.shouldBeIncluded(context)) {
|
|
13529
|
-
this.consequent.
|
|
13653
|
+
this.consequent.includePath(UNKNOWN_PATH, context, false, { asSingleStatement: true });
|
|
13530
13654
|
}
|
|
13531
13655
|
if (!testValue && this.alternate?.shouldBeIncluded(context)) {
|
|
13532
|
-
this.alternate.
|
|
13656
|
+
this.alternate.includePath(UNKNOWN_PATH, context, false, { asSingleStatement: true });
|
|
13533
13657
|
}
|
|
13534
13658
|
}
|
|
13535
13659
|
includeRecursively(includeChildrenRecursively, context) {
|
|
13536
|
-
this.test.
|
|
13537
|
-
this.consequent.
|
|
13538
|
-
this.alternate?.
|
|
13660
|
+
this.test.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13661
|
+
this.consequent.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13662
|
+
this.alternate?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
13539
13663
|
}
|
|
13540
13664
|
includeUnknownTest(context) {
|
|
13541
|
-
this.test.
|
|
13665
|
+
this.test.includePath(UNKNOWN_PATH, context, false);
|
|
13542
13666
|
const { brokenFlow } = context;
|
|
13543
13667
|
let consequentBrokenFlow = false;
|
|
13544
13668
|
if (this.consequent.shouldBeIncluded(context)) {
|
|
13545
|
-
this.consequent.
|
|
13669
|
+
this.consequent.includePath(UNKNOWN_PATH, context, false, { asSingleStatement: true });
|
|
13546
13670
|
consequentBrokenFlow = context.brokenFlow;
|
|
13547
13671
|
context.brokenFlow = brokenFlow;
|
|
13548
13672
|
}
|
|
13549
13673
|
if (this.alternate?.shouldBeIncluded(context)) {
|
|
13550
|
-
this.alternate.
|
|
13674
|
+
this.alternate.includePath(UNKNOWN_PATH, context, false, { asSingleStatement: true });
|
|
13551
13675
|
context.brokenFlow = context.brokenFlow && consequentBrokenFlow;
|
|
13552
13676
|
}
|
|
13553
13677
|
}
|
|
@@ -13615,7 +13739,7 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
13615
13739
|
class VariableDeclarator extends NodeBase {
|
|
13616
13740
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
13617
13741
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
13618
|
-
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
13742
|
+
this.id.declare(kind, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION);
|
|
13619
13743
|
}
|
|
13620
13744
|
deoptimizePath(path) {
|
|
13621
13745
|
this.id.deoptimizePath(path);
|
|
@@ -13627,15 +13751,15 @@ class VariableDeclarator extends NodeBase {
|
|
|
13627
13751
|
this.id.markDeclarationReached();
|
|
13628
13752
|
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
13629
13753
|
}
|
|
13630
|
-
|
|
13754
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
13631
13755
|
const { deoptimized, id, init } = this;
|
|
13632
13756
|
if (!deoptimized)
|
|
13633
13757
|
this.applyDeoptimizations();
|
|
13634
13758
|
this.included = true;
|
|
13635
|
-
init?.
|
|
13759
|
+
init?.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
13636
13760
|
id.markDeclarationReached();
|
|
13637
13761
|
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
13638
|
-
id.
|
|
13762
|
+
id.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
13639
13763
|
}
|
|
13640
13764
|
}
|
|
13641
13765
|
removeAnnotations(code) {
|
|
@@ -13684,6 +13808,8 @@ class ImportExpression extends NodeBase {
|
|
|
13684
13808
|
constructor() {
|
|
13685
13809
|
super(...arguments);
|
|
13686
13810
|
this.inlineNamespace = null;
|
|
13811
|
+
this.hasUnknownAccessedKey = false;
|
|
13812
|
+
this.accessedPropKey = new Set();
|
|
13687
13813
|
this.attributes = null;
|
|
13688
13814
|
this.mechanism = null;
|
|
13689
13815
|
this.namespaceExportName = undefined;
|
|
@@ -13716,12 +13842,15 @@ class ImportExpression extends NodeBase {
|
|
|
13716
13842
|
if (parent2 instanceof ExpressionStatement) {
|
|
13717
13843
|
return parseAst_js.EMPTY_ARRAY;
|
|
13718
13844
|
}
|
|
13719
|
-
// Case 1: const { foo } = await import('bar')
|
|
13845
|
+
// Case 1: const { foo } / module = await import('bar')
|
|
13720
13846
|
if (parent2 instanceof VariableDeclarator) {
|
|
13721
13847
|
const declaration = parent2.id;
|
|
13722
|
-
|
|
13723
|
-
?
|
|
13724
|
-
|
|
13848
|
+
if (declaration instanceof Identifier) {
|
|
13849
|
+
return this.hasUnknownAccessedKey ? undefined : [...this.accessedPropKey];
|
|
13850
|
+
}
|
|
13851
|
+
if (declaration instanceof ObjectPattern) {
|
|
13852
|
+
return getDeterministicObjectDestructure(declaration);
|
|
13853
|
+
}
|
|
13725
13854
|
}
|
|
13726
13855
|
// Case 2: (await import('bar')).foo
|
|
13727
13856
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -13770,13 +13899,23 @@ class ImportExpression extends NodeBase {
|
|
|
13770
13899
|
hasEffects() {
|
|
13771
13900
|
return true;
|
|
13772
13901
|
}
|
|
13773
|
-
|
|
13902
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
13774
13903
|
if (!this.included) {
|
|
13775
13904
|
this.included = true;
|
|
13776
13905
|
this.scope.context.includeDynamicImport(this);
|
|
13777
13906
|
this.scope.addAccessedDynamicImport(this);
|
|
13907
|
+
this.source.includePath(path, context, includeChildrenRecursively);
|
|
13908
|
+
}
|
|
13909
|
+
if (this.hasUnknownAccessedKey)
|
|
13910
|
+
return;
|
|
13911
|
+
if (path[0] === UnknownKey) {
|
|
13912
|
+
this.hasUnknownAccessedKey = true;
|
|
13913
|
+
this.scope.context.includeDynamicImport(this);
|
|
13914
|
+
}
|
|
13915
|
+
else if (typeof path[0] === 'string') {
|
|
13916
|
+
this.accessedPropKey.add(path[0]);
|
|
13917
|
+
this.scope.context.includeDynamicImport(this);
|
|
13778
13918
|
}
|
|
13779
|
-
this.source.include(context, includeChildrenRecursively);
|
|
13780
13919
|
}
|
|
13781
13920
|
initialise() {
|
|
13782
13921
|
super.initialise();
|
|
@@ -14104,7 +14243,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
14104
14243
|
if (preserve) {
|
|
14105
14244
|
// This pretends we are accessing an included global variable of the same name
|
|
14106
14245
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
14107
|
-
globalVariable.
|
|
14246
|
+
globalVariable.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
14108
14247
|
// This excludes this variable from renaming
|
|
14109
14248
|
factoryVariable.globalName = baseName;
|
|
14110
14249
|
}
|
|
@@ -14112,7 +14251,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
|
14112
14251
|
else {
|
|
14113
14252
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
14114
14253
|
}
|
|
14115
|
-
node.scope.context.includeVariableInModule(factoryVariable);
|
|
14254
|
+
node.scope.context.includeVariableInModule(factoryVariable, UNKNOWN_PATH);
|
|
14116
14255
|
if (factoryVariable instanceof LocalVariable) {
|
|
14117
14256
|
factoryVariable.consolidateInitializers();
|
|
14118
14257
|
factoryVariable.addUsedPlace(node);
|
|
@@ -14134,7 +14273,7 @@ class JSXElementBase extends NodeBase {
|
|
|
14134
14273
|
this.scope.context.addImportSource(importSource);
|
|
14135
14274
|
}
|
|
14136
14275
|
}
|
|
14137
|
-
|
|
14276
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
14138
14277
|
if (!this.included) {
|
|
14139
14278
|
const { factory, importSource, mode } = this.jsxMode;
|
|
14140
14279
|
if (factory) {
|
|
@@ -14142,7 +14281,7 @@ class JSXElementBase extends NodeBase {
|
|
|
14142
14281
|
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
14143
14282
|
}
|
|
14144
14283
|
}
|
|
14145
|
-
super.
|
|
14284
|
+
super.includePath(path, context, includeChildrenRecursively);
|
|
14146
14285
|
}
|
|
14147
14286
|
applyDeoptimizations() { }
|
|
14148
14287
|
getRenderingMode() {
|
|
@@ -14404,7 +14543,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
14404
14543
|
this.fragment = null;
|
|
14405
14544
|
this.fragmentVariable = null;
|
|
14406
14545
|
}
|
|
14407
|
-
|
|
14546
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
14408
14547
|
if (!this.included) {
|
|
14409
14548
|
const jsx = this.scope.context.options.jsx;
|
|
14410
14549
|
if (jsx.mode === 'automatic') {
|
|
@@ -14419,7 +14558,7 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
14419
14558
|
}
|
|
14420
14559
|
}
|
|
14421
14560
|
}
|
|
14422
|
-
super.
|
|
14561
|
+
super.includePath(path, context, includeChildrenRecursively);
|
|
14423
14562
|
}
|
|
14424
14563
|
render(code, options) {
|
|
14425
14564
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -14476,13 +14615,13 @@ class LabeledStatement extends NodeBase {
|
|
|
14476
14615
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
14477
14616
|
return bodyHasEffects;
|
|
14478
14617
|
}
|
|
14479
|
-
|
|
14618
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
14480
14619
|
this.included = true;
|
|
14481
14620
|
const { brokenFlow, includedLabels } = context;
|
|
14482
14621
|
context.includedLabels = new Set();
|
|
14483
|
-
this.body.
|
|
14622
|
+
this.body.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
14484
14623
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
14485
|
-
this.label.
|
|
14624
|
+
this.label.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
14486
14625
|
context.includedLabels.delete(this.label.name);
|
|
14487
14626
|
context.brokenFlow = brokenFlow;
|
|
14488
14627
|
}
|
|
@@ -14579,17 +14718,17 @@ class LogicalExpression extends NodeBase {
|
|
|
14579
14718
|
}
|
|
14580
14719
|
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14581
14720
|
}
|
|
14582
|
-
|
|
14721
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
14583
14722
|
this.included = true;
|
|
14584
14723
|
const usedBranch = this.getUsedBranch();
|
|
14585
14724
|
if (includeChildrenRecursively ||
|
|
14586
14725
|
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
14587
14726
|
!usedBranch) {
|
|
14588
|
-
this.left.
|
|
14589
|
-
this.right.
|
|
14727
|
+
this.left.includePath(path, context, includeChildrenRecursively);
|
|
14728
|
+
this.right.includePath(path, context, includeChildrenRecursively);
|
|
14590
14729
|
}
|
|
14591
14730
|
else {
|
|
14592
|
-
usedBranch.
|
|
14731
|
+
usedBranch.includePath(path, context, includeChildrenRecursively);
|
|
14593
14732
|
}
|
|
14594
14733
|
}
|
|
14595
14734
|
removeAnnotations(code) {
|
|
@@ -14661,17 +14800,17 @@ class NewExpression extends NodeBase {
|
|
|
14661
14800
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
14662
14801
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
14663
14802
|
}
|
|
14664
|
-
|
|
14803
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
14665
14804
|
if (!this.deoptimized)
|
|
14666
14805
|
this.applyDeoptimizations();
|
|
14667
14806
|
if (includeChildrenRecursively) {
|
|
14668
|
-
super.
|
|
14807
|
+
super.includePath(path, context, includeChildrenRecursively);
|
|
14669
14808
|
}
|
|
14670
14809
|
else {
|
|
14671
14810
|
this.included = true;
|
|
14672
|
-
this.callee.
|
|
14811
|
+
this.callee.includePath(UNKNOWN_PATH, context, false);
|
|
14673
14812
|
}
|
|
14674
|
-
this.callee.includeCallArguments(context, this.
|
|
14813
|
+
this.callee.includeCallArguments(context, this.interaction);
|
|
14675
14814
|
}
|
|
14676
14815
|
initialise() {
|
|
14677
14816
|
super.initialise();
|
|
@@ -14700,6 +14839,7 @@ class ObjectExpression extends NodeBase {
|
|
|
14700
14839
|
constructor() {
|
|
14701
14840
|
super(...arguments);
|
|
14702
14841
|
this.objectEntity = null;
|
|
14842
|
+
this.protoProp = null;
|
|
14703
14843
|
}
|
|
14704
14844
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
14705
14845
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -14719,13 +14859,32 @@ class ObjectExpression extends NodeBase {
|
|
|
14719
14859
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
14720
14860
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14721
14861
|
}
|
|
14862
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
14863
|
+
this.included = true;
|
|
14864
|
+
this.getObjectEntity().includePath(path, context, includeChildrenRecursively);
|
|
14865
|
+
this.protoProp?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
14866
|
+
}
|
|
14722
14867
|
render(code, options, { renderedSurroundingElement } = parseAst_js.BLANK) {
|
|
14723
|
-
super.render(code, options);
|
|
14724
14868
|
if (renderedSurroundingElement === parseAst_js.ExpressionStatement ||
|
|
14725
14869
|
renderedSurroundingElement === parseAst_js.ArrowFunctionExpression) {
|
|
14726
14870
|
code.appendRight(this.start, '(');
|
|
14727
14871
|
code.prependLeft(this.end, ')');
|
|
14728
14872
|
}
|
|
14873
|
+
if (this.properties.length > 0) {
|
|
14874
|
+
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
14875
|
+
let lastSeparatorPos = null;
|
|
14876
|
+
for (const { node, separator, start, end } of separatedNodes) {
|
|
14877
|
+
if (!node.included) {
|
|
14878
|
+
treeshakeNode(node, code, start, end);
|
|
14879
|
+
continue;
|
|
14880
|
+
}
|
|
14881
|
+
lastSeparatorPos = separator;
|
|
14882
|
+
node.render(code, options);
|
|
14883
|
+
}
|
|
14884
|
+
if (lastSeparatorPos) {
|
|
14885
|
+
code.remove(lastSeparatorPos, this.end - 1);
|
|
14886
|
+
}
|
|
14887
|
+
}
|
|
14729
14888
|
}
|
|
14730
14889
|
applyDeoptimizations() { }
|
|
14731
14890
|
getObjectEntity() {
|
|
@@ -14756,6 +14915,7 @@ class ObjectExpression extends NodeBase {
|
|
|
14756
14915
|
? property.key.name
|
|
14757
14916
|
: String(property.key.value);
|
|
14758
14917
|
if (key === '__proto__' && property.kind === 'init') {
|
|
14918
|
+
this.protoProp = property;
|
|
14759
14919
|
prototype =
|
|
14760
14920
|
property.value instanceof Literal && property.value.value === null
|
|
14761
14921
|
? null
|
|
@@ -14822,11 +14982,11 @@ class Program extends NodeBase {
|
|
|
14822
14982
|
}
|
|
14823
14983
|
return false;
|
|
14824
14984
|
}
|
|
14825
|
-
|
|
14985
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
14826
14986
|
this.included = true;
|
|
14827
14987
|
for (const node of this.body) {
|
|
14828
14988
|
if (includeChildrenRecursively || node.shouldBeIncluded(context)) {
|
|
14829
|
-
node.
|
|
14989
|
+
node.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
14830
14990
|
}
|
|
14831
14991
|
}
|
|
14832
14992
|
}
|
|
@@ -14865,10 +15025,6 @@ class Program extends NodeBase {
|
|
|
14865
15025
|
}
|
|
14866
15026
|
|
|
14867
15027
|
class Property extends MethodBase {
|
|
14868
|
-
constructor() {
|
|
14869
|
-
super(...arguments);
|
|
14870
|
-
this.declarationInit = null;
|
|
14871
|
-
}
|
|
14872
15028
|
//declare method: boolean;
|
|
14873
15029
|
get method() {
|
|
14874
15030
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -14883,9 +15039,17 @@ class Property extends MethodBase {
|
|
|
14883
15039
|
set shorthand(value) {
|
|
14884
15040
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
14885
15041
|
}
|
|
14886
|
-
declare(kind, init) {
|
|
14887
|
-
|
|
14888
|
-
|
|
15042
|
+
declare(kind, includedInitPath, init) {
|
|
15043
|
+
const pathInProperty = includedInitPath.at(-1) === UnknownKey
|
|
15044
|
+
? includedInitPath
|
|
15045
|
+
: // For now, we only consider static path as we do not know how to
|
|
15046
|
+
// deoptimize the path in the dynamic case.
|
|
15047
|
+
this.computed
|
|
15048
|
+
? [...includedInitPath, UnknownKey]
|
|
15049
|
+
: this.key instanceof Identifier
|
|
15050
|
+
? [...includedInitPath, this.key.name]
|
|
15051
|
+
: [...includedInitPath, String(this.key.value)];
|
|
15052
|
+
return this.value.declare(kind, pathInProperty, init);
|
|
14889
15053
|
}
|
|
14890
15054
|
hasEffects(context) {
|
|
14891
15055
|
if (!this.deoptimized)
|
|
@@ -14895,6 +15059,11 @@ class Property extends MethodBase {
|
|
|
14895
15059
|
this.key.hasEffects(context) ||
|
|
14896
15060
|
this.value.hasEffects(context));
|
|
14897
15061
|
}
|
|
15062
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
15063
|
+
this.included = true;
|
|
15064
|
+
this.key.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
15065
|
+
this.value.includePath(path, context, includeChildrenRecursively);
|
|
15066
|
+
}
|
|
14898
15067
|
markDeclarationReached() {
|
|
14899
15068
|
this.value.markDeclarationReached();
|
|
14900
15069
|
}
|
|
@@ -14904,13 +15073,7 @@ class Property extends MethodBase {
|
|
|
14904
15073
|
}
|
|
14905
15074
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
14906
15075
|
}
|
|
14907
|
-
applyDeoptimizations() {
|
|
14908
|
-
this.deoptimized = true;
|
|
14909
|
-
if (this.declarationInit !== null) {
|
|
14910
|
-
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
14911
|
-
this.scope.context.requestTreeshakingPass();
|
|
14912
|
-
}
|
|
14913
|
-
}
|
|
15076
|
+
applyDeoptimizations() { }
|
|
14914
15077
|
}
|
|
14915
15078
|
|
|
14916
15079
|
class PropertyDefinition extends NodeBase {
|
|
@@ -14954,9 +15117,9 @@ class ReturnStatement extends NodeBase {
|
|
|
14954
15117
|
context.brokenFlow = true;
|
|
14955
15118
|
return false;
|
|
14956
15119
|
}
|
|
14957
|
-
|
|
15120
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
14958
15121
|
this.included = true;
|
|
14959
|
-
this.argument?.
|
|
15122
|
+
this.argument?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
14960
15123
|
context.brokenFlow = true;
|
|
14961
15124
|
}
|
|
14962
15125
|
initialise() {
|
|
@@ -14993,14 +15156,14 @@ class SequenceExpression extends NodeBase {
|
|
|
14993
15156
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
14994
15157
|
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
14995
15158
|
}
|
|
14996
|
-
|
|
15159
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
14997
15160
|
this.included = true;
|
|
14998
15161
|
const lastExpression = this.expressions[this.expressions.length - 1];
|
|
14999
15162
|
for (const expression of this.expressions) {
|
|
15000
15163
|
if (includeChildrenRecursively ||
|
|
15001
15164
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
15002
15165
|
expression.shouldBeIncluded(context))
|
|
15003
|
-
expression.
|
|
15166
|
+
expression.includePath(path, context, includeChildrenRecursively);
|
|
15004
15167
|
}
|
|
15005
15168
|
}
|
|
15006
15169
|
removeAnnotations(code) {
|
|
@@ -15048,10 +15211,13 @@ class Super extends NodeBase {
|
|
|
15048
15211
|
deoptimizePath(path) {
|
|
15049
15212
|
this.variable.deoptimizePath(path);
|
|
15050
15213
|
}
|
|
15051
|
-
|
|
15214
|
+
includePath(path, context) {
|
|
15052
15215
|
if (!this.included) {
|
|
15053
15216
|
this.included = true;
|
|
15054
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
15217
|
+
this.scope.context.includeVariableInModule(this.variable, path);
|
|
15218
|
+
}
|
|
15219
|
+
else if (path.length > 0) {
|
|
15220
|
+
this.variable.includePath(path, context);
|
|
15055
15221
|
}
|
|
15056
15222
|
}
|
|
15057
15223
|
}
|
|
@@ -15068,12 +15234,12 @@ class SwitchCase extends NodeBase {
|
|
|
15068
15234
|
}
|
|
15069
15235
|
return false;
|
|
15070
15236
|
}
|
|
15071
|
-
|
|
15237
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
15072
15238
|
this.included = true;
|
|
15073
|
-
this.test?.
|
|
15239
|
+
this.test?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15074
15240
|
for (const node of this.consequent) {
|
|
15075
15241
|
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
15076
|
-
node.
|
|
15242
|
+
node.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15077
15243
|
}
|
|
15078
15244
|
}
|
|
15079
15245
|
render(code, options, nodeRenderOptions) {
|
|
@@ -15121,9 +15287,9 @@ class SwitchStatement extends NodeBase {
|
|
|
15121
15287
|
context.hasBreak = hasBreak;
|
|
15122
15288
|
return false;
|
|
15123
15289
|
}
|
|
15124
|
-
|
|
15290
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
15125
15291
|
this.included = true;
|
|
15126
|
-
this.discriminant.
|
|
15292
|
+
this.discriminant.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15127
15293
|
const { brokenFlow, hasBreak } = context;
|
|
15128
15294
|
context.hasBreak = false;
|
|
15129
15295
|
let onlyHasBrokenFlow = true;
|
|
@@ -15140,7 +15306,7 @@ class SwitchStatement extends NodeBase {
|
|
|
15140
15306
|
isCaseIncluded = switchCase.hasEffects(hasEffectsContext);
|
|
15141
15307
|
}
|
|
15142
15308
|
if (isCaseIncluded) {
|
|
15143
|
-
switchCase.
|
|
15309
|
+
switchCase.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15144
15310
|
onlyHasBrokenFlow &&= context.brokenFlow && !context.hasBreak;
|
|
15145
15311
|
context.hasBreak = false;
|
|
15146
15312
|
context.brokenFlow = brokenFlow;
|
|
@@ -15197,21 +15363,21 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
15197
15363
|
return (this.tag.hasEffects(context) ||
|
|
15198
15364
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
15199
15365
|
}
|
|
15200
|
-
|
|
15366
|
+
includePath(path, context, includeChildrenRecursively) {
|
|
15201
15367
|
if (!this.deoptimized)
|
|
15202
15368
|
this.applyDeoptimizations();
|
|
15203
15369
|
if (includeChildrenRecursively) {
|
|
15204
|
-
super.
|
|
15370
|
+
super.includePath(path, context, includeChildrenRecursively);
|
|
15205
15371
|
}
|
|
15206
15372
|
else {
|
|
15207
15373
|
this.included = true;
|
|
15208
|
-
this.tag.
|
|
15209
|
-
this.quasi.
|
|
15374
|
+
this.tag.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15375
|
+
this.quasi.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15210
15376
|
}
|
|
15211
|
-
this.tag.includeCallArguments(context, this.
|
|
15377
|
+
this.tag.includeCallArguments(context, this.interaction);
|
|
15212
15378
|
const [returnExpression] = this.getReturnExpression();
|
|
15213
15379
|
if (!returnExpression.included) {
|
|
15214
|
-
returnExpression.
|
|
15380
|
+
returnExpression.includePath(UNKNOWN_PATH, context, false);
|
|
15215
15381
|
}
|
|
15216
15382
|
}
|
|
15217
15383
|
initialise() {
|
|
@@ -15256,7 +15422,7 @@ class TemplateElement extends NodeBase {
|
|
|
15256
15422
|
hasEffects() {
|
|
15257
15423
|
return false;
|
|
15258
15424
|
}
|
|
15259
|
-
|
|
15425
|
+
includePath() {
|
|
15260
15426
|
this.included = true;
|
|
15261
15427
|
}
|
|
15262
15428
|
parseNode(esTreeNode) {
|
|
@@ -15298,13 +15464,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
15298
15464
|
class ModuleScope extends ChildScope {
|
|
15299
15465
|
constructor(parent, context) {
|
|
15300
15466
|
super(parent, context);
|
|
15301
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
15467
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, EMPTY_PATH, context, 'other'));
|
|
15302
15468
|
}
|
|
15303
|
-
addDeclaration(identifier, context, init, kind) {
|
|
15469
|
+
addDeclaration(identifier, context, init, includedInitPath, kind) {
|
|
15304
15470
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
15305
15471
|
context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
|
|
15306
15472
|
}
|
|
15307
|
-
return super.addDeclaration(identifier, context, init, kind);
|
|
15473
|
+
return super.addDeclaration(identifier, context, init, includedInitPath, kind);
|
|
15308
15474
|
}
|
|
15309
15475
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
15310
15476
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -15349,10 +15515,13 @@ class ThisExpression extends NodeBase {
|
|
|
15349
15515
|
}
|
|
15350
15516
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
15351
15517
|
}
|
|
15352
|
-
|
|
15518
|
+
includePath(path, context) {
|
|
15353
15519
|
if (!this.included) {
|
|
15354
15520
|
this.included = true;
|
|
15355
|
-
this.scope.context.includeVariableInModule(this.variable);
|
|
15521
|
+
this.scope.context.includeVariableInModule(this.variable, path);
|
|
15522
|
+
}
|
|
15523
|
+
else if (path.length > 0) {
|
|
15524
|
+
this.variable.includePath(path, context);
|
|
15356
15525
|
}
|
|
15357
15526
|
}
|
|
15358
15527
|
initialise() {
|
|
@@ -15379,9 +15548,9 @@ class ThrowStatement extends NodeBase {
|
|
|
15379
15548
|
hasEffects() {
|
|
15380
15549
|
return true;
|
|
15381
15550
|
}
|
|
15382
|
-
|
|
15551
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
15383
15552
|
this.included = true;
|
|
15384
|
-
this.argument.
|
|
15553
|
+
this.argument.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15385
15554
|
context.brokenFlow = true;
|
|
15386
15555
|
}
|
|
15387
15556
|
render(code, options) {
|
|
@@ -15403,13 +15572,13 @@ class TryStatement extends NodeBase {
|
|
|
15403
15572
|
? this.block.body.length > 0
|
|
15404
15573
|
: this.block.hasEffects(context)) || !!this.finalizer?.hasEffects(context));
|
|
15405
15574
|
}
|
|
15406
|
-
|
|
15575
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
15407
15576
|
const tryCatchDeoptimization = this.scope.context.options.treeshake?.tryCatchDeoptimization;
|
|
15408
15577
|
const { brokenFlow, includedLabels } = context;
|
|
15409
15578
|
if (!this.directlyIncluded || !tryCatchDeoptimization) {
|
|
15410
15579
|
this.included = true;
|
|
15411
15580
|
this.directlyIncluded = true;
|
|
15412
|
-
this.block.
|
|
15581
|
+
this.block.includePath(UNKNOWN_PATH, context, tryCatchDeoptimization ? INCLUDE_PARAMETERS : includeChildrenRecursively);
|
|
15413
15582
|
if (includedLabels.size > 0) {
|
|
15414
15583
|
this.includedLabelsAfterBlock = [...includedLabels];
|
|
15415
15584
|
}
|
|
@@ -15421,10 +15590,10 @@ class TryStatement extends NodeBase {
|
|
|
15421
15590
|
}
|
|
15422
15591
|
}
|
|
15423
15592
|
if (this.handler !== null) {
|
|
15424
|
-
this.handler.
|
|
15593
|
+
this.handler.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15425
15594
|
context.brokenFlow = brokenFlow;
|
|
15426
15595
|
}
|
|
15427
|
-
this.finalizer?.
|
|
15596
|
+
this.finalizer?.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15428
15597
|
}
|
|
15429
15598
|
}
|
|
15430
15599
|
|
|
@@ -15482,7 +15651,7 @@ class UpdateExpression extends NodeBase {
|
|
|
15482
15651
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
15483
15652
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
15484
15653
|
}
|
|
15485
|
-
|
|
15654
|
+
includePath(_, context, includeChildrenRecursively) {
|
|
15486
15655
|
if (!this.deoptimized)
|
|
15487
15656
|
this.applyDeoptimizations();
|
|
15488
15657
|
this.included = true;
|
|
@@ -15551,20 +15720,20 @@ class VariableDeclaration extends NodeBase {
|
|
|
15551
15720
|
hasEffectsOnInteractionAtPath() {
|
|
15552
15721
|
return false;
|
|
15553
15722
|
}
|
|
15554
|
-
|
|
15723
|
+
includePath(_path, context, includeChildrenRecursively, { asSingleStatement } = parseAst_js.BLANK) {
|
|
15555
15724
|
this.included = true;
|
|
15556
15725
|
for (const declarator of this.declarations) {
|
|
15557
15726
|
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
15558
|
-
declarator.
|
|
15727
|
+
declarator.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15559
15728
|
const { id, init } = declarator;
|
|
15560
15729
|
if (asSingleStatement) {
|
|
15561
|
-
id.
|
|
15730
|
+
id.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
15562
15731
|
}
|
|
15563
15732
|
if (init &&
|
|
15564
15733
|
id.included &&
|
|
15565
15734
|
!init.included &&
|
|
15566
15735
|
(id instanceof ObjectPattern || id instanceof ArrayPattern)) {
|
|
15567
|
-
init.
|
|
15736
|
+
init.includePath(EMPTY_PATH, context, includeChildrenRecursively);
|
|
15568
15737
|
}
|
|
15569
15738
|
}
|
|
15570
15739
|
}
|
|
@@ -15636,8 +15805,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
15636
15805
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
15637
15806
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
15638
15807
|
if (!node.included) {
|
|
15639
|
-
code
|
|
15640
|
-
node.removeAnnotations(code);
|
|
15808
|
+
treeshakeNode(node, code, start, end);
|
|
15641
15809
|
continue;
|
|
15642
15810
|
}
|
|
15643
15811
|
node.render(code, options);
|
|
@@ -15714,9 +15882,9 @@ class WhileStatement extends NodeBase {
|
|
|
15714
15882
|
return true;
|
|
15715
15883
|
return hasLoopBodyEffects(context, this.body);
|
|
15716
15884
|
}
|
|
15717
|
-
|
|
15885
|
+
includePath(_path, context, includeChildrenRecursively) {
|
|
15718
15886
|
this.included = true;
|
|
15719
|
-
this.test.
|
|
15887
|
+
this.test.includePath(UNKNOWN_PATH, context, includeChildrenRecursively);
|
|
15720
15888
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
15721
15889
|
}
|
|
15722
15890
|
}
|
|
@@ -15960,7 +16128,7 @@ const bufferParsers = [
|
|
|
15960
16128
|
const annotations = (node.annotations = parseAst_js.convertAnnotations(buffer[position + 1], buffer));
|
|
15961
16129
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
15962
16130
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
15963
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16131
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
15964
16132
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
15965
16133
|
},
|
|
15966
16134
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -16006,7 +16174,7 @@ const bufferParsers = [
|
|
|
16006
16174
|
const parameterPosition = buffer[position];
|
|
16007
16175
|
const parameter = (node.param =
|
|
16008
16176
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
16009
|
-
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
16177
|
+
parameter?.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION);
|
|
16010
16178
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
16011
16179
|
},
|
|
16012
16180
|
function chainExpression(node, position, buffer) {
|
|
@@ -16141,7 +16309,7 @@ const bufferParsers = [
|
|
|
16141
16309
|
node.id =
|
|
16142
16310
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
16143
16311
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
16144
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16312
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16145
16313
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
16146
16314
|
},
|
|
16147
16315
|
function functionExpression(node, position, buffer) {
|
|
@@ -16154,7 +16322,7 @@ const bufferParsers = [
|
|
|
16154
16322
|
const idPosition = buffer[position + 2];
|
|
16155
16323
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
16156
16324
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
16157
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16325
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', EMPTY_PATH, UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16158
16326
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
16159
16327
|
},
|
|
16160
16328
|
function identifier(node, position, buffer) {
|
|
@@ -16513,8 +16681,8 @@ class UnknownNode extends NodeBase {
|
|
|
16513
16681
|
hasEffects() {
|
|
16514
16682
|
return true;
|
|
16515
16683
|
}
|
|
16516
|
-
|
|
16517
|
-
super.
|
|
16684
|
+
includePath(path, context) {
|
|
16685
|
+
super.includePath(path, context, true);
|
|
16518
16686
|
}
|
|
16519
16687
|
}
|
|
16520
16688
|
|
|
@@ -16618,8 +16786,8 @@ class ExportShimVariable extends Variable {
|
|
|
16618
16786
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
16619
16787
|
this.module = module;
|
|
16620
16788
|
}
|
|
16621
|
-
|
|
16622
|
-
super.
|
|
16789
|
+
includePath(path, context) {
|
|
16790
|
+
super.includePath(path, context);
|
|
16623
16791
|
this.module.needsExportShim = true;
|
|
16624
16792
|
}
|
|
16625
16793
|
}
|
|
@@ -17303,7 +17471,7 @@ class Module {
|
|
|
17303
17471
|
include() {
|
|
17304
17472
|
const context = createInclusionContext();
|
|
17305
17473
|
if (this.ast.shouldBeIncluded(context))
|
|
17306
|
-
this.ast.
|
|
17474
|
+
this.ast.includePath(EMPTY_PATH, context, false);
|
|
17307
17475
|
}
|
|
17308
17476
|
includeAllExports(includeNamespaceMembers) {
|
|
17309
17477
|
if (!this.isExecuted) {
|
|
@@ -17317,9 +17485,7 @@ class Module {
|
|
|
17317
17485
|
return parseAst_js.error(parseAst_js.logMissingEntryExport(exportName, this.id));
|
|
17318
17486
|
}
|
|
17319
17487
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17320
|
-
|
|
17321
|
-
this.includeVariable(variable);
|
|
17322
|
-
}
|
|
17488
|
+
this.includeVariable(variable, UNKNOWN_PATH);
|
|
17323
17489
|
}
|
|
17324
17490
|
}
|
|
17325
17491
|
for (const name of this.getReexports()) {
|
|
@@ -17327,7 +17493,7 @@ class Module {
|
|
|
17327
17493
|
if (variable) {
|
|
17328
17494
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17329
17495
|
if (!variable.included) {
|
|
17330
|
-
this.includeVariable(variable);
|
|
17496
|
+
this.includeVariable(variable, UNKNOWN_PATH);
|
|
17331
17497
|
}
|
|
17332
17498
|
if (variable instanceof ExternalVariable) {
|
|
17333
17499
|
variable.module.reexported = true;
|
|
@@ -17339,7 +17505,7 @@ class Module {
|
|
|
17339
17505
|
}
|
|
17340
17506
|
}
|
|
17341
17507
|
includeAllInBundle() {
|
|
17342
|
-
this.ast.
|
|
17508
|
+
this.ast.includePath(UNKNOWN_PATH, createInclusionContext(), true);
|
|
17343
17509
|
this.includeAllExports(false);
|
|
17344
17510
|
}
|
|
17345
17511
|
includeExportsByNames(names) {
|
|
@@ -17353,7 +17519,7 @@ class Module {
|
|
|
17353
17519
|
if (variable) {
|
|
17354
17520
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17355
17521
|
if (!variable.included) {
|
|
17356
|
-
this.includeVariable(variable);
|
|
17522
|
+
this.includeVariable(variable, EMPTY_PATH);
|
|
17357
17523
|
}
|
|
17358
17524
|
}
|
|
17359
17525
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
@@ -17795,13 +17961,13 @@ class Module {
|
|
|
17795
17961
|
for (const module of [this, ...this.exportAllModules]) {
|
|
17796
17962
|
if (module instanceof ExternalModule) {
|
|
17797
17963
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
17798
|
-
externalVariable.
|
|
17964
|
+
externalVariable.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
17799
17965
|
this.includedImports.add(externalVariable);
|
|
17800
17966
|
externalNamespaces.add(externalVariable);
|
|
17801
17967
|
}
|
|
17802
17968
|
else if (module.info.syntheticNamedExports) {
|
|
17803
17969
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
17804
|
-
syntheticNamespace.
|
|
17970
|
+
syntheticNamespace.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
17805
17971
|
this.includedImports.add(syntheticNamespace);
|
|
17806
17972
|
syntheticNamespaces.add(syntheticNamespace);
|
|
17807
17973
|
}
|
|
@@ -17811,7 +17977,9 @@ class Module {
|
|
|
17811
17977
|
includeDynamicImport(node) {
|
|
17812
17978
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
17813
17979
|
if (resolution instanceof Module) {
|
|
17814
|
-
resolution.includedDynamicImporters.
|
|
17980
|
+
if (!resolution.includedDynamicImporters.includes(this)) {
|
|
17981
|
+
resolution.includedDynamicImporters.push(this);
|
|
17982
|
+
}
|
|
17815
17983
|
const importedNames = this.options.treeshake
|
|
17816
17984
|
? node.getDeterministicImportedNames()
|
|
17817
17985
|
: undefined;
|
|
@@ -17823,7 +17991,7 @@ class Module {
|
|
|
17823
17991
|
}
|
|
17824
17992
|
}
|
|
17825
17993
|
}
|
|
17826
|
-
includeVariable(variable) {
|
|
17994
|
+
includeVariable(variable, path) {
|
|
17827
17995
|
const variableModule = variable.module;
|
|
17828
17996
|
if (variable.included) {
|
|
17829
17997
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
@@ -17831,7 +17999,6 @@ class Module {
|
|
|
17831
17999
|
}
|
|
17832
18000
|
}
|
|
17833
18001
|
else {
|
|
17834
|
-
variable.include();
|
|
17835
18002
|
this.graph.needsTreeshakingPass = true;
|
|
17836
18003
|
if (variableModule instanceof Module) {
|
|
17837
18004
|
if (!variableModule.isExecuted) {
|
|
@@ -17847,9 +18014,10 @@ class Module {
|
|
|
17847
18014
|
}
|
|
17848
18015
|
}
|
|
17849
18016
|
}
|
|
18017
|
+
variable.includePath(path, createInclusionContext());
|
|
17850
18018
|
}
|
|
17851
|
-
includeVariableInModule(variable) {
|
|
17852
|
-
this.includeVariable(variable);
|
|
18019
|
+
includeVariableInModule(variable, path) {
|
|
18020
|
+
this.includeVariable(variable, path);
|
|
17853
18021
|
const variableModule = variable.module;
|
|
17854
18022
|
if (variableModule && variableModule !== this) {
|
|
17855
18023
|
this.includedImports.add(variable);
|
|
@@ -21328,7 +21496,7 @@ class Graph {
|
|
|
21328
21496
|
this.options = options;
|
|
21329
21497
|
this.astLru = flru(5);
|
|
21330
21498
|
this.cachedModules = new Map();
|
|
21331
|
-
this.deoptimizationTracker = new
|
|
21499
|
+
this.deoptimizationTracker = new EntityPathTracker();
|
|
21332
21500
|
this.entryModules = [];
|
|
21333
21501
|
this.modulesById = new Map();
|
|
21334
21502
|
this.needsTreeshakingPass = false;
|