rollup 2.75.5 → 2.76.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/CHANGELOG.md +52 -0
- package/dist/bin/rollup +18 -18
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +650 -730
- package/dist/es/shared/watch.js +3 -2
- package/dist/loadConfigFile.js +6 -6
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.d.ts +2 -0
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +2 -2
- package/dist/shared/loadConfigFile.js +20 -12
- package/dist/shared/mergeOptions.js +3 -2
- package/dist/shared/rollup.js +650 -730
- package/dist/shared/watch-cli.js +17 -17
- package/dist/shared/watch.js +2 -2
- package/package.json +19 -19
package/dist/es/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.76.0
|
|
4
|
+
Fri, 08 Jul 2022 08:35:58 GMT - commit 0eb042740eb41812b9e96e0e7b6ed8aa4cab04a7
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ import { createHash as createHash$1 } from 'crypto';
|
|
|
14
14
|
import { promises } from 'fs';
|
|
15
15
|
import { EventEmitter } from 'events';
|
|
16
16
|
|
|
17
|
-
var version$1 = "2.
|
|
17
|
+
var version$1 = "2.76.0";
|
|
18
18
|
|
|
19
19
|
var charToInteger = {};
|
|
20
20
|
var chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -1594,8 +1594,8 @@ class ExpressionEntity {
|
|
|
1594
1594
|
this.included = false;
|
|
1595
1595
|
}
|
|
1596
1596
|
deoptimizePath(_path) { }
|
|
1597
|
-
|
|
1598
|
-
|
|
1597
|
+
deoptimizeThisOnInteractionAtPath({ thisArg }, _path, _recursionTracker) {
|
|
1598
|
+
thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
1599
1599
|
}
|
|
1600
1600
|
/**
|
|
1601
1601
|
* If possible it returns a stringifyable literal value for this node that can be used
|
|
@@ -1605,16 +1605,10 @@ class ExpressionEntity {
|
|
|
1605
1605
|
getLiteralValueAtPath(_path, _recursionTracker, _origin) {
|
|
1606
1606
|
return UnknownValue;
|
|
1607
1607
|
}
|
|
1608
|
-
getReturnExpressionWhenCalledAtPath(_path,
|
|
1608
|
+
getReturnExpressionWhenCalledAtPath(_path, _interaction, _recursionTracker, _origin) {
|
|
1609
1609
|
return UNKNOWN_EXPRESSION;
|
|
1610
1610
|
}
|
|
1611
|
-
|
|
1612
|
-
return true;
|
|
1613
|
-
}
|
|
1614
|
-
hasEffectsWhenAssignedAtPath(_path, _context) {
|
|
1615
|
-
return true;
|
|
1616
|
-
}
|
|
1617
|
-
hasEffectsWhenCalledAtPath(_path, _callOptions, _context) {
|
|
1611
|
+
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
1618
1612
|
return true;
|
|
1619
1613
|
}
|
|
1620
1614
|
include(_context, _includeChildrenRecursively, _options) {
|
|
@@ -1632,6 +1626,30 @@ class ExpressionEntity {
|
|
|
1632
1626
|
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
1633
1627
|
})();
|
|
1634
1628
|
|
|
1629
|
+
const INTERACTION_ACCESSED = 0;
|
|
1630
|
+
const INTERACTION_ASSIGNED = 1;
|
|
1631
|
+
const INTERACTION_CALLED = 2;
|
|
1632
|
+
const NODE_INTERACTION_UNKNOWN_ACCESS = {
|
|
1633
|
+
thisArg: null,
|
|
1634
|
+
type: INTERACTION_ACCESSED
|
|
1635
|
+
};
|
|
1636
|
+
const UNKNOWN_ARG = [UNKNOWN_EXPRESSION];
|
|
1637
|
+
const NODE_INTERACTION_UNKNOWN_ASSIGNMENT = {
|
|
1638
|
+
args: UNKNOWN_ARG,
|
|
1639
|
+
thisArg: null,
|
|
1640
|
+
type: INTERACTION_ASSIGNED
|
|
1641
|
+
};
|
|
1642
|
+
const NO_ARGS = [];
|
|
1643
|
+
// While this is technically a call without arguments, we can compare against
|
|
1644
|
+
// this reference in places where precise values or thisArg would make a
|
|
1645
|
+
// difference
|
|
1646
|
+
const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
1647
|
+
args: NO_ARGS,
|
|
1648
|
+
thisArg: null,
|
|
1649
|
+
type: INTERACTION_CALLED,
|
|
1650
|
+
withNew: false
|
|
1651
|
+
};
|
|
1652
|
+
|
|
1635
1653
|
class Variable extends ExpressionEntity {
|
|
1636
1654
|
constructor(name) {
|
|
1637
1655
|
super();
|
|
@@ -1656,8 +1674,8 @@ class Variable extends ExpressionEntity {
|
|
|
1656
1674
|
const name = this.renderName || this.name;
|
|
1657
1675
|
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
1658
1676
|
}
|
|
1659
|
-
|
|
1660
|
-
return path.length > 0;
|
|
1677
|
+
hasEffectsOnInteractionAtPath(path, { type }, _context) {
|
|
1678
|
+
return type !== INTERACTION_ACCESSED || path.length > 0;
|
|
1661
1679
|
}
|
|
1662
1680
|
/**
|
|
1663
1681
|
* Marks this variable as being part of the bundle, which is usually the case when one of
|
|
@@ -1688,8 +1706,8 @@ class ExternalVariable extends Variable {
|
|
|
1688
1706
|
this.module.suggestName(identifier.name);
|
|
1689
1707
|
}
|
|
1690
1708
|
}
|
|
1691
|
-
|
|
1692
|
-
return path.length > (this.isNamespace ? 1 : 0);
|
|
1709
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
1710
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
1693
1711
|
}
|
|
1694
1712
|
include() {
|
|
1695
1713
|
if (!this.included) {
|
|
@@ -4579,8 +4597,6 @@ function createHasEffectsContext() {
|
|
|
4579
4597
|
};
|
|
4580
4598
|
}
|
|
4581
4599
|
|
|
4582
|
-
const NO_ARGS = [];
|
|
4583
|
-
|
|
4584
4600
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
4585
4601
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
4586
4602
|
}
|
|
@@ -4602,12 +4618,12 @@ const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEnti
|
|
|
4602
4618
|
}
|
|
4603
4619
|
return UNKNOWN_EXPRESSION;
|
|
4604
4620
|
}
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
if (path.length === 1) {
|
|
4610
|
-
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0],
|
|
4621
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4622
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4623
|
+
return path.length > 1;
|
|
4624
|
+
}
|
|
4625
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4626
|
+
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context);
|
|
4611
4627
|
}
|
|
4612
4628
|
return true;
|
|
4613
4629
|
}
|
|
@@ -4625,12 +4641,12 @@ const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity
|
|
|
4625
4641
|
}
|
|
4626
4642
|
return UNKNOWN_EXPRESSION;
|
|
4627
4643
|
}
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
if (path.length === 1) {
|
|
4633
|
-
return hasMemberEffectWhenCalled(literalNumberMembers, path[0],
|
|
4644
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4645
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4646
|
+
return path.length > 1;
|
|
4647
|
+
}
|
|
4648
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4649
|
+
return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context);
|
|
4634
4650
|
}
|
|
4635
4651
|
return true;
|
|
4636
4652
|
}
|
|
@@ -4648,12 +4664,12 @@ const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity
|
|
|
4648
4664
|
}
|
|
4649
4665
|
return UNKNOWN_EXPRESSION;
|
|
4650
4666
|
}
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
if (path.length === 1) {
|
|
4656
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0],
|
|
4667
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4668
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4669
|
+
return path.length > 1;
|
|
4670
|
+
}
|
|
4671
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4672
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
4657
4673
|
}
|
|
4658
4674
|
return true;
|
|
4659
4675
|
}
|
|
@@ -4666,17 +4682,13 @@ const returnsString = {
|
|
|
4666
4682
|
};
|
|
4667
4683
|
const stringReplace = {
|
|
4668
4684
|
value: {
|
|
4669
|
-
hasEffectsWhenCalled(
|
|
4670
|
-
const arg1 =
|
|
4671
|
-
return (
|
|
4685
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
4686
|
+
const arg1 = args[1];
|
|
4687
|
+
return (args.length < 2 ||
|
|
4672
4688
|
(typeof arg1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
4673
4689
|
deoptimizeCache() { }
|
|
4674
4690
|
}) === 'symbol' &&
|
|
4675
|
-
arg1.
|
|
4676
|
-
args: NO_ARGS,
|
|
4677
|
-
thisParam: null,
|
|
4678
|
-
withNew: false
|
|
4679
|
-
}, context)));
|
|
4691
|
+
arg1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
4680
4692
|
},
|
|
4681
4693
|
returns: UNKNOWN_LITERAL_STRING
|
|
4682
4694
|
}
|
|
@@ -4760,12 +4772,12 @@ function getLiteralMembersForValue(value) {
|
|
|
4760
4772
|
}
|
|
4761
4773
|
return Object.create(null);
|
|
4762
4774
|
}
|
|
4763
|
-
function hasMemberEffectWhenCalled(members, memberName,
|
|
4775
|
+
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
4764
4776
|
var _a, _b;
|
|
4765
4777
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
4766
4778
|
return true;
|
|
4767
4779
|
}
|
|
4768
|
-
return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a,
|
|
4780
|
+
return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a, interaction, context)) || false;
|
|
4769
4781
|
}
|
|
4770
4782
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
4771
4783
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
@@ -5204,10 +5216,12 @@ const INCLUDE_PARAMETERS = 'variables';
|
|
|
5204
5216
|
class NodeBase extends ExpressionEntity {
|
|
5205
5217
|
constructor(esTreeNode, parent, parentScope) {
|
|
5206
5218
|
super();
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5219
|
+
/**
|
|
5220
|
+
* Nodes can apply custom deoptimizations once they become part of the
|
|
5221
|
+
* executed code. To do this, they must initialize this as false, implement
|
|
5222
|
+
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
5223
|
+
* custom handlers
|
|
5224
|
+
*/
|
|
5211
5225
|
this.deoptimized = false;
|
|
5212
5226
|
this.esTreeNode = esTreeNode;
|
|
5213
5227
|
this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
|
|
@@ -5263,6 +5277,10 @@ class NodeBase extends ExpressionEntity {
|
|
|
5263
5277
|
}
|
|
5264
5278
|
return false;
|
|
5265
5279
|
}
|
|
5280
|
+
hasEffectsAsAssignmentTarget(context, _checkAccess) {
|
|
5281
|
+
return (this.hasEffects(context) ||
|
|
5282
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
5283
|
+
}
|
|
5266
5284
|
include(context, includeChildrenRecursively, _options) {
|
|
5267
5285
|
if (!this.deoptimized)
|
|
5268
5286
|
this.applyDeoptimizations();
|
|
@@ -5281,6 +5299,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5281
5299
|
}
|
|
5282
5300
|
}
|
|
5283
5301
|
}
|
|
5302
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
5303
|
+
this.include(context, includeChildrenRecursively);
|
|
5304
|
+
}
|
|
5284
5305
|
/**
|
|
5285
5306
|
* Override to perform special initialisation steps after the scope is initialised
|
|
5286
5307
|
*/
|
|
@@ -5335,6 +5356,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5335
5356
|
}
|
|
5336
5357
|
}
|
|
5337
5358
|
}
|
|
5359
|
+
setAssignedValue(value) {
|
|
5360
|
+
this.assignmentInteraction = { args: [value], thisArg: null, type: INTERACTION_ASSIGNED };
|
|
5361
|
+
}
|
|
5338
5362
|
shouldBeIncluded(context) {
|
|
5339
5363
|
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
5340
5364
|
}
|
|
@@ -5363,9 +5387,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5363
5387
|
}
|
|
5364
5388
|
|
|
5365
5389
|
class SpreadElement extends NodeBase {
|
|
5366
|
-
|
|
5390
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5367
5391
|
if (path.length > 0) {
|
|
5368
|
-
this.argument.
|
|
5392
|
+
this.argument.deoptimizeThisOnInteractionAtPath(interaction, [UnknownKey, ...path], recursionTracker);
|
|
5369
5393
|
}
|
|
5370
5394
|
}
|
|
5371
5395
|
hasEffects(context) {
|
|
@@ -5376,7 +5400,7 @@ class SpreadElement extends NodeBase {
|
|
|
5376
5400
|
return (this.argument.hasEffects(context) ||
|
|
5377
5401
|
(propertyReadSideEffects &&
|
|
5378
5402
|
(propertyReadSideEffects === 'always' ||
|
|
5379
|
-
this.argument.
|
|
5403
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
5380
5404
|
}
|
|
5381
5405
|
applyDeoptimizations() {
|
|
5382
5406
|
this.deoptimized = true;
|
|
@@ -5387,53 +5411,43 @@ class SpreadElement extends NodeBase {
|
|
|
5387
5411
|
}
|
|
5388
5412
|
}
|
|
5389
5413
|
|
|
5390
|
-
const EVENT_ACCESSED = 0;
|
|
5391
|
-
const EVENT_ASSIGNED = 1;
|
|
5392
|
-
const EVENT_CALLED = 2;
|
|
5393
|
-
|
|
5394
5414
|
class Method extends ExpressionEntity {
|
|
5395
5415
|
constructor(description) {
|
|
5396
5416
|
super();
|
|
5397
5417
|
this.description = description;
|
|
5398
5418
|
}
|
|
5399
|
-
|
|
5400
|
-
if (
|
|
5401
|
-
|
|
5419
|
+
deoptimizeThisOnInteractionAtPath({ type, thisArg }, path) {
|
|
5420
|
+
if (type === INTERACTION_CALLED && path.length === 0 && this.description.mutatesSelfAsArray) {
|
|
5421
|
+
thisArg.deoptimizePath(UNKNOWN_INTEGER_PATH);
|
|
5402
5422
|
}
|
|
5403
5423
|
}
|
|
5404
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
5424
|
+
getReturnExpressionWhenCalledAtPath(path, { thisArg }) {
|
|
5405
5425
|
if (path.length > 0) {
|
|
5406
5426
|
return UNKNOWN_EXPRESSION;
|
|
5407
5427
|
}
|
|
5408
5428
|
return (this.description.returnsPrimitive ||
|
|
5409
5429
|
(this.description.returns === 'self'
|
|
5410
|
-
?
|
|
5430
|
+
? thisArg || UNKNOWN_EXPRESSION
|
|
5411
5431
|
: this.description.returns()));
|
|
5412
5432
|
}
|
|
5413
|
-
|
|
5414
|
-
return path.length > 1;
|
|
5415
|
-
}
|
|
5416
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
5417
|
-
return path.length > 0;
|
|
5418
|
-
}
|
|
5419
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
5433
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5420
5434
|
var _a, _b;
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
((_a = callOptions.thisParam) === null || _a === void 0 ? void 0 : _a.hasEffectsWhenAssignedAtPath(UNKNOWN_INTEGER_PATH, context)))) {
|
|
5435
|
+
const { type } = interaction;
|
|
5436
|
+
if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) {
|
|
5424
5437
|
return true;
|
|
5425
5438
|
}
|
|
5426
|
-
if (
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
for (const argIndex of this.description.callsArgs) {
|
|
5430
|
-
if ((_b = callOptions.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsWhenCalledAtPath(EMPTY_PATH, {
|
|
5431
|
-
args: NO_ARGS,
|
|
5432
|
-
thisParam: null,
|
|
5433
|
-
withNew: false
|
|
5434
|
-
}, context)) {
|
|
5439
|
+
if (type === INTERACTION_CALLED) {
|
|
5440
|
+
if (this.description.mutatesSelfAsArray === true &&
|
|
5441
|
+
((_a = interaction.thisArg) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context))) {
|
|
5435
5442
|
return true;
|
|
5436
5443
|
}
|
|
5444
|
+
if (this.description.callsArgs) {
|
|
5445
|
+
for (const argIndex of this.description.callsArgs) {
|
|
5446
|
+
if ((_b = interaction.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5447
|
+
return true;
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5437
5451
|
}
|
|
5438
5452
|
return false;
|
|
5439
5453
|
}
|
|
@@ -5575,24 +5589,24 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5575
5589
|
}
|
|
5576
5590
|
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
|
|
5577
5591
|
}
|
|
5578
|
-
|
|
5592
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5579
5593
|
var _a;
|
|
5580
5594
|
const [key, ...subPath] = path;
|
|
5581
5595
|
if (this.hasLostTrack ||
|
|
5582
5596
|
// single paths that are deoptimized will not become getters or setters
|
|
5583
|
-
((
|
|
5597
|
+
((interaction.type === INTERACTION_CALLED || path.length > 1) &&
|
|
5584
5598
|
(this.hasUnknownDeoptimizedProperty ||
|
|
5585
5599
|
(typeof key === 'string' && this.deoptimizedPaths[key])))) {
|
|
5586
|
-
|
|
5600
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
5587
5601
|
return;
|
|
5588
5602
|
}
|
|
5589
|
-
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] =
|
|
5603
|
+
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] = interaction.type === INTERACTION_CALLED || path.length > 1
|
|
5590
5604
|
? [
|
|
5591
5605
|
this.propertiesAndGettersByKey,
|
|
5592
5606
|
this.propertiesAndGettersByKey,
|
|
5593
5607
|
this.unmatchablePropertiesAndGetters
|
|
5594
5608
|
]
|
|
5595
|
-
:
|
|
5609
|
+
: interaction.type === INTERACTION_ACCESSED
|
|
5596
5610
|
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
5597
5611
|
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
5598
5612
|
if (typeof key === 'string') {
|
|
@@ -5600,20 +5614,20 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5600
5614
|
const properties = relevantPropertiesByKey[key];
|
|
5601
5615
|
if (properties) {
|
|
5602
5616
|
for (const property of properties) {
|
|
5603
|
-
property.
|
|
5617
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5604
5618
|
}
|
|
5605
5619
|
}
|
|
5606
5620
|
if (!this.immutable) {
|
|
5607
|
-
this.thisParametersToBeDeoptimized.add(
|
|
5621
|
+
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5608
5622
|
}
|
|
5609
5623
|
return;
|
|
5610
5624
|
}
|
|
5611
5625
|
for (const property of relevantUnmatchableProperties) {
|
|
5612
|
-
property.
|
|
5626
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5613
5627
|
}
|
|
5614
5628
|
if (INTEGER_REG_EXP.test(key)) {
|
|
5615
5629
|
for (const property of this.unknownIntegerProps) {
|
|
5616
|
-
property.
|
|
5630
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5617
5631
|
}
|
|
5618
5632
|
}
|
|
5619
5633
|
}
|
|
@@ -5622,17 +5636,17 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5622
5636
|
relevantUnmatchableProperties
|
|
5623
5637
|
])) {
|
|
5624
5638
|
for (const property of properties) {
|
|
5625
|
-
property.
|
|
5639
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5626
5640
|
}
|
|
5627
5641
|
}
|
|
5628
5642
|
for (const property of this.unknownIntegerProps) {
|
|
5629
|
-
property.
|
|
5643
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5630
5644
|
}
|
|
5631
5645
|
}
|
|
5632
5646
|
if (!this.immutable) {
|
|
5633
|
-
this.thisParametersToBeDeoptimized.add(
|
|
5647
|
+
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5634
5648
|
}
|
|
5635
|
-
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.
|
|
5649
|
+
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
5636
5650
|
}
|
|
5637
5651
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5638
5652
|
if (path.length === 0) {
|
|
@@ -5651,79 +5665,29 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5651
5665
|
}
|
|
5652
5666
|
return UnknownValue;
|
|
5653
5667
|
}
|
|
5654
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
5668
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5655
5669
|
if (path.length === 0) {
|
|
5656
5670
|
return UNKNOWN_EXPRESSION;
|
|
5657
5671
|
}
|
|
5658
|
-
const key = path
|
|
5672
|
+
const [key, ...subPath] = path;
|
|
5659
5673
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
5660
5674
|
if (expressionAtPath) {
|
|
5661
|
-
return expressionAtPath.getReturnExpressionWhenCalledAtPath(
|
|
5675
|
+
return expressionAtPath.getReturnExpressionWhenCalledAtPath(subPath, interaction, recursionTracker, origin);
|
|
5662
5676
|
}
|
|
5663
5677
|
if (this.prototypeExpression) {
|
|
5664
|
-
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path,
|
|
5678
|
+
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
5665
5679
|
}
|
|
5666
5680
|
return UNKNOWN_EXPRESSION;
|
|
5667
5681
|
}
|
|
5668
|
-
|
|
5682
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5669
5683
|
const [key, ...subPath] = path;
|
|
5670
|
-
if (
|
|
5671
|
-
if (typeof key !== 'string') {
|
|
5672
|
-
return true;
|
|
5673
|
-
}
|
|
5684
|
+
if (subPath.length || interaction.type === INTERACTION_CALLED) {
|
|
5674
5685
|
const expressionAtPath = this.getMemberExpression(key);
|
|
5675
5686
|
if (expressionAtPath) {
|
|
5676
|
-
return expressionAtPath.
|
|
5687
|
+
return expressionAtPath.hasEffectsOnInteractionAtPath(subPath, interaction, context);
|
|
5677
5688
|
}
|
|
5678
5689
|
if (this.prototypeExpression) {
|
|
5679
|
-
return this.prototypeExpression.
|
|
5680
|
-
}
|
|
5681
|
-
return true;
|
|
5682
|
-
}
|
|
5683
|
-
if (this.hasLostTrack)
|
|
5684
|
-
return true;
|
|
5685
|
-
if (typeof key === 'string') {
|
|
5686
|
-
if (this.propertiesAndGettersByKey[key]) {
|
|
5687
|
-
const getters = this.gettersByKey[key];
|
|
5688
|
-
if (getters) {
|
|
5689
|
-
for (const getter of getters) {
|
|
5690
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
5691
|
-
return true;
|
|
5692
|
-
}
|
|
5693
|
-
}
|
|
5694
|
-
return false;
|
|
5695
|
-
}
|
|
5696
|
-
for (const getter of this.unmatchableGetters) {
|
|
5697
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context)) {
|
|
5698
|
-
return true;
|
|
5699
|
-
}
|
|
5700
|
-
}
|
|
5701
|
-
}
|
|
5702
|
-
else {
|
|
5703
|
-
for (const getters of Object.values(this.gettersByKey).concat([this.unmatchableGetters])) {
|
|
5704
|
-
for (const getter of getters) {
|
|
5705
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
5706
|
-
return true;
|
|
5707
|
-
}
|
|
5708
|
-
}
|
|
5709
|
-
}
|
|
5710
|
-
if (this.prototypeExpression) {
|
|
5711
|
-
return this.prototypeExpression.hasEffectsWhenAccessedAtPath(path, context);
|
|
5712
|
-
}
|
|
5713
|
-
return false;
|
|
5714
|
-
}
|
|
5715
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
5716
|
-
const [key, ...subPath] = path;
|
|
5717
|
-
if (path.length > 1) {
|
|
5718
|
-
if (typeof key !== 'string') {
|
|
5719
|
-
return true;
|
|
5720
|
-
}
|
|
5721
|
-
const expressionAtPath = this.getMemberExpression(key);
|
|
5722
|
-
if (expressionAtPath) {
|
|
5723
|
-
return expressionAtPath.hasEffectsWhenAssignedAtPath(subPath, context);
|
|
5724
|
-
}
|
|
5725
|
-
if (this.prototypeExpression) {
|
|
5726
|
-
return this.prototypeExpression.hasEffectsWhenAssignedAtPath(path, context);
|
|
5690
|
+
return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5727
5691
|
}
|
|
5728
5692
|
return true;
|
|
5729
5693
|
}
|
|
@@ -5731,47 +5695,39 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5731
5695
|
return false;
|
|
5732
5696
|
if (this.hasLostTrack)
|
|
5733
5697
|
return true;
|
|
5698
|
+
const [propertiesAndAccessorsByKey, accessorsByKey, unmatchableAccessors] = interaction.type === INTERACTION_ACCESSED
|
|
5699
|
+
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
5700
|
+
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
5734
5701
|
if (typeof key === 'string') {
|
|
5735
|
-
if (
|
|
5736
|
-
const
|
|
5737
|
-
if (
|
|
5738
|
-
for (const
|
|
5739
|
-
if (
|
|
5702
|
+
if (propertiesAndAccessorsByKey[key]) {
|
|
5703
|
+
const accessors = accessorsByKey[key];
|
|
5704
|
+
if (accessors) {
|
|
5705
|
+
for (const accessor of accessors) {
|
|
5706
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
5740
5707
|
return true;
|
|
5741
5708
|
}
|
|
5742
5709
|
}
|
|
5743
5710
|
return false;
|
|
5744
5711
|
}
|
|
5745
|
-
for (const
|
|
5746
|
-
if (
|
|
5712
|
+
for (const accessor of unmatchableAccessors) {
|
|
5713
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context)) {
|
|
5747
5714
|
return true;
|
|
5748
5715
|
}
|
|
5749
5716
|
}
|
|
5750
5717
|
}
|
|
5751
5718
|
else {
|
|
5752
|
-
for (const
|
|
5753
|
-
for (const
|
|
5754
|
-
if (
|
|
5719
|
+
for (const accessors of Object.values(accessorsByKey).concat([unmatchableAccessors])) {
|
|
5720
|
+
for (const accessor of accessors) {
|
|
5721
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
5755
5722
|
return true;
|
|
5756
5723
|
}
|
|
5757
5724
|
}
|
|
5758
5725
|
}
|
|
5759
5726
|
if (this.prototypeExpression) {
|
|
5760
|
-
return this.prototypeExpression.
|
|
5727
|
+
return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5761
5728
|
}
|
|
5762
5729
|
return false;
|
|
5763
5730
|
}
|
|
5764
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
5765
|
-
const key = path[0];
|
|
5766
|
-
const expressionAtPath = this.getMemberExpression(key);
|
|
5767
|
-
if (expressionAtPath) {
|
|
5768
|
-
return expressionAtPath.hasEffectsWhenCalledAtPath(path.slice(1), callOptions, context);
|
|
5769
|
-
}
|
|
5770
|
-
if (this.prototypeExpression) {
|
|
5771
|
-
return this.prototypeExpression.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
5772
|
-
}
|
|
5773
|
-
return true;
|
|
5774
|
-
}
|
|
5775
5731
|
buildPropertyMaps(properties) {
|
|
5776
5732
|
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
5777
5733
|
const unmatchablePropertiesAndSetters = [];
|
|
@@ -5877,9 +5833,9 @@ const isInteger = (prop) => typeof prop === 'string' && /^\d+$/.test(prop);
|
|
|
5877
5833
|
// properties as we do not expect new builtin properties to be numbers, this
|
|
5878
5834
|
// will improve tree-shaking for out-of-bounds array properties
|
|
5879
5835
|
const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression extends ExpressionEntity {
|
|
5880
|
-
|
|
5881
|
-
if (
|
|
5882
|
-
|
|
5836
|
+
deoptimizeThisOnInteractionAtPath({ type, thisArg }, path) {
|
|
5837
|
+
if (type === INTERACTION_CALLED && path.length === 1 && !isInteger(path[0])) {
|
|
5838
|
+
thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
5883
5839
|
}
|
|
5884
5840
|
}
|
|
5885
5841
|
getLiteralValueAtPath(path) {
|
|
@@ -5888,11 +5844,8 @@ const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression e
|
|
|
5888
5844
|
// "undefined"
|
|
5889
5845
|
return path.length === 1 && isInteger(path[0]) ? undefined : UnknownValue;
|
|
5890
5846
|
}
|
|
5891
|
-
|
|
5892
|
-
return path.length > 1;
|
|
5893
|
-
}
|
|
5894
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
5895
|
-
return path.length > 1;
|
|
5847
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5848
|
+
return path.length > 1 || type === INTERACTION_CALLED;
|
|
5896
5849
|
}
|
|
5897
5850
|
})();
|
|
5898
5851
|
const OBJECT_PROTOTYPE = new ObjectEntity({
|
|
@@ -6014,8 +5967,8 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
6014
5967
|
flat: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
|
|
6015
5968
|
flatMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
|
|
6016
5969
|
forEach: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
|
|
6017
|
-
|
|
6018
|
-
|
|
5970
|
+
group: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
|
|
5971
|
+
groupToMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
|
|
6019
5972
|
includes: METHOD_RETURNS_BOOLEAN,
|
|
6020
5973
|
indexOf: METHOD_RETURNS_NUMBER,
|
|
6021
5974
|
join: METHOD_RETURNS_STRING,
|
|
@@ -6046,23 +5999,17 @@ class ArrayExpression extends NodeBase {
|
|
|
6046
5999
|
deoptimizePath(path) {
|
|
6047
6000
|
this.getObjectEntity().deoptimizePath(path);
|
|
6048
6001
|
}
|
|
6049
|
-
|
|
6050
|
-
this.getObjectEntity().
|
|
6002
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6003
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6051
6004
|
}
|
|
6052
6005
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6053
6006
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6054
6007
|
}
|
|
6055
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
6056
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
6057
|
-
}
|
|
6058
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
6059
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
6008
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6009
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6060
6010
|
}
|
|
6061
|
-
|
|
6062
|
-
return this.getObjectEntity().
|
|
6063
|
-
}
|
|
6064
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
6065
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
6011
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6012
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6066
6013
|
}
|
|
6067
6014
|
applyDeoptimizations() {
|
|
6068
6015
|
this.deoptimized = true;
|
|
@@ -6127,9 +6074,9 @@ class ArrayPattern extends NodeBase {
|
|
|
6127
6074
|
}
|
|
6128
6075
|
}
|
|
6129
6076
|
// Patterns are only checked at the emtpy path at the moment
|
|
6130
|
-
|
|
6077
|
+
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
6131
6078
|
for (const element of this.elements) {
|
|
6132
|
-
if (element === null || element === void 0 ? void 0 : element.
|
|
6079
|
+
if (element === null || element === void 0 ? void 0 : element.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
6133
6080
|
return true;
|
|
6134
6081
|
}
|
|
6135
6082
|
return false;
|
|
@@ -6188,11 +6135,11 @@ class LocalVariable extends Variable {
|
|
|
6188
6135
|
(_b = this.init) === null || _b === void 0 ? void 0 : _b.deoptimizePath(path);
|
|
6189
6136
|
}
|
|
6190
6137
|
}
|
|
6191
|
-
|
|
6138
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6192
6139
|
if (this.isReassigned || !this.init) {
|
|
6193
|
-
return
|
|
6140
|
+
return interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
6194
6141
|
}
|
|
6195
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.
|
|
6142
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
6196
6143
|
}
|
|
6197
6144
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6198
6145
|
if (this.isReassigned || !this.init) {
|
|
@@ -6203,39 +6150,40 @@ class LocalVariable extends Variable {
|
|
|
6203
6150
|
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6204
6151
|
}, UnknownValue);
|
|
6205
6152
|
}
|
|
6206
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
6153
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6207
6154
|
if (this.isReassigned || !this.init) {
|
|
6208
6155
|
return UNKNOWN_EXPRESSION;
|
|
6209
6156
|
}
|
|
6210
6157
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6211
6158
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6212
|
-
return this.init.getReturnExpressionWhenCalledAtPath(path,
|
|
6159
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6213
6160
|
}, UNKNOWN_EXPRESSION);
|
|
6214
6161
|
}
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6162
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6163
|
+
switch (interaction.type) {
|
|
6164
|
+
case INTERACTION_ACCESSED:
|
|
6165
|
+
if (this.isReassigned)
|
|
6166
|
+
return true;
|
|
6167
|
+
return (this.init &&
|
|
6168
|
+
!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6169
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6170
|
+
case INTERACTION_ASSIGNED:
|
|
6171
|
+
if (this.included)
|
|
6172
|
+
return true;
|
|
6173
|
+
if (path.length === 0)
|
|
6174
|
+
return false;
|
|
6175
|
+
if (this.isReassigned)
|
|
6176
|
+
return true;
|
|
6177
|
+
return (this.init &&
|
|
6178
|
+
!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6179
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6180
|
+
case INTERACTION_CALLED:
|
|
6181
|
+
if (this.isReassigned)
|
|
6182
|
+
return true;
|
|
6183
|
+
return (this.init &&
|
|
6184
|
+
!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
6185
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6186
|
+
}
|
|
6239
6187
|
}
|
|
6240
6188
|
include() {
|
|
6241
6189
|
if (!this.included) {
|
|
@@ -6590,9 +6538,9 @@ const PF = {
|
|
|
6590
6538
|
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
6591
6539
|
__proto__: null,
|
|
6592
6540
|
[ValueProperties]: {
|
|
6593
|
-
hasEffectsWhenCalled(
|
|
6594
|
-
return (!
|
|
6595
|
-
|
|
6541
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
6542
|
+
return (!args.length ||
|
|
6543
|
+
args[0].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
6596
6544
|
}
|
|
6597
6545
|
}
|
|
6598
6546
|
};
|
|
@@ -7433,16 +7381,21 @@ class GlobalVariable extends Variable {
|
|
|
7433
7381
|
getLiteralValueAtPath(path, _recursionTracker, _origin) {
|
|
7434
7382
|
return getGlobalAtPath([this.name, ...path]) ? UnknownTruthyValue : UnknownValue;
|
|
7435
7383
|
}
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7384
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7385
|
+
switch (interaction.type) {
|
|
7386
|
+
case INTERACTION_ACCESSED:
|
|
7387
|
+
if (path.length === 0) {
|
|
7388
|
+
// Technically, "undefined" is a global variable of sorts
|
|
7389
|
+
return this.name !== 'undefined' && !getGlobalAtPath([this.name]);
|
|
7390
|
+
}
|
|
7391
|
+
return !getGlobalAtPath([this.name, ...path].slice(0, -1));
|
|
7392
|
+
case INTERACTION_ASSIGNED:
|
|
7393
|
+
return true;
|
|
7394
|
+
case INTERACTION_CALLED: {
|
|
7395
|
+
const globalAtPath = getGlobalAtPath([this.name, ...path]);
|
|
7396
|
+
return !globalAtPath || globalAtPath.hasEffectsWhenCalled(interaction, context);
|
|
7397
|
+
}
|
|
7440
7398
|
}
|
|
7441
|
-
return !getGlobalAtPath([this.name, ...path].slice(0, -1));
|
|
7442
|
-
}
|
|
7443
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7444
|
-
const globalAtPath = getGlobalAtPath([this.name, ...path]);
|
|
7445
|
-
return !globalAtPath || globalAtPath.hasEffectsWhenCalled(callOptions, context);
|
|
7446
7399
|
}
|
|
7447
7400
|
}
|
|
7448
7401
|
|
|
@@ -7510,16 +7463,16 @@ class Identifier extends NodeBase {
|
|
|
7510
7463
|
// Identifier as property that might be deoptimized by default
|
|
7511
7464
|
(_a = this.variable) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
7512
7465
|
}
|
|
7513
|
-
|
|
7514
|
-
this.variable.
|
|
7466
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7467
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7515
7468
|
}
|
|
7516
7469
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7517
7470
|
return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7518
7471
|
}
|
|
7519
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
7520
|
-
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path,
|
|
7472
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7473
|
+
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
7521
7474
|
}
|
|
7522
|
-
hasEffects() {
|
|
7475
|
+
hasEffects(context) {
|
|
7523
7476
|
if (!this.deoptimized)
|
|
7524
7477
|
this.applyDeoptimizations();
|
|
7525
7478
|
if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
|
|
@@ -7527,17 +7480,18 @@ class Identifier extends NodeBase {
|
|
|
7527
7480
|
}
|
|
7528
7481
|
return (this.context.options.treeshake.unknownGlobalSideEffects &&
|
|
7529
7482
|
this.variable instanceof GlobalVariable &&
|
|
7530
|
-
this.variable.
|
|
7483
|
+
this.variable.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7531
7484
|
}
|
|
7532
|
-
|
|
7533
|
-
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7485
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7486
|
+
switch (interaction.type) {
|
|
7487
|
+
case INTERACTION_ACCESSED:
|
|
7488
|
+
return (this.variable !== null &&
|
|
7489
|
+
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7490
|
+
case INTERACTION_ASSIGNED:
|
|
7491
|
+
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7492
|
+
case INTERACTION_CALLED:
|
|
7493
|
+
return this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7494
|
+
}
|
|
7541
7495
|
}
|
|
7542
7496
|
include() {
|
|
7543
7497
|
if (!this.deoptimized)
|
|
@@ -7897,8 +7851,9 @@ class RestElement extends NodeBase {
|
|
|
7897
7851
|
deoptimizePath(path) {
|
|
7898
7852
|
path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH);
|
|
7899
7853
|
}
|
|
7900
|
-
|
|
7901
|
-
return path.length > 0 ||
|
|
7854
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7855
|
+
return (path.length > 0 ||
|
|
7856
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
7902
7857
|
}
|
|
7903
7858
|
markDeclarationReached() {
|
|
7904
7859
|
this.argument.markDeclarationReached();
|
|
@@ -7926,17 +7881,17 @@ class FunctionBase extends NodeBase {
|
|
|
7926
7881
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
7927
7882
|
}
|
|
7928
7883
|
}
|
|
7929
|
-
|
|
7884
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7930
7885
|
if (path.length > 0) {
|
|
7931
|
-
this.getObjectEntity().
|
|
7886
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7932
7887
|
}
|
|
7933
7888
|
}
|
|
7934
7889
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7935
7890
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7936
7891
|
}
|
|
7937
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
7892
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7938
7893
|
if (path.length > 0) {
|
|
7939
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
7894
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
7940
7895
|
}
|
|
7941
7896
|
if (this.async) {
|
|
7942
7897
|
if (!this.deoptimizedReturn) {
|
|
@@ -7948,24 +7903,18 @@ class FunctionBase extends NodeBase {
|
|
|
7948
7903
|
}
|
|
7949
7904
|
return this.scope.getReturnExpression();
|
|
7950
7905
|
}
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7954
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
7955
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
7956
|
-
}
|
|
7957
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7958
|
-
if (path.length > 0) {
|
|
7959
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
7906
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7907
|
+
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
7908
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7960
7909
|
}
|
|
7961
7910
|
if (this.async) {
|
|
7962
7911
|
const { propertyReadSideEffects } = this.context.options
|
|
7963
7912
|
.treeshake;
|
|
7964
7913
|
const returnExpression = this.scope.getReturnExpression();
|
|
7965
|
-
if (returnExpression.
|
|
7914
|
+
if (returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_CALL, context) ||
|
|
7966
7915
|
(propertyReadSideEffects &&
|
|
7967
7916
|
(propertyReadSideEffects === 'always' ||
|
|
7968
|
-
returnExpression.
|
|
7917
|
+
returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_ACCESS, context)))) {
|
|
7969
7918
|
return true;
|
|
7970
7919
|
}
|
|
7971
7920
|
}
|
|
@@ -8019,20 +7968,22 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
8019
7968
|
this.applyDeoptimizations();
|
|
8020
7969
|
return false;
|
|
8021
7970
|
}
|
|
8022
|
-
|
|
8023
|
-
if (super.
|
|
8024
|
-
return true;
|
|
8025
|
-
const { ignore, brokenFlow } = context;
|
|
8026
|
-
context.ignore = {
|
|
8027
|
-
breaks: false,
|
|
8028
|
-
continues: false,
|
|
8029
|
-
labels: new Set(),
|
|
8030
|
-
returnYield: true
|
|
8031
|
-
};
|
|
8032
|
-
if (this.body.hasEffects(context))
|
|
7971
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7972
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8033
7973
|
return true;
|
|
8034
|
-
|
|
8035
|
-
|
|
7974
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
7975
|
+
const { ignore, brokenFlow } = context;
|
|
7976
|
+
context.ignore = {
|
|
7977
|
+
breaks: false,
|
|
7978
|
+
continues: false,
|
|
7979
|
+
labels: new Set(),
|
|
7980
|
+
returnYield: true
|
|
7981
|
+
};
|
|
7982
|
+
if (this.body.hasEffects(context))
|
|
7983
|
+
return true;
|
|
7984
|
+
context.ignore = ignore;
|
|
7985
|
+
context.brokenFlow = brokenFlow;
|
|
7986
|
+
}
|
|
8036
7987
|
return false;
|
|
8037
7988
|
}
|
|
8038
7989
|
include(context, includeChildrenRecursively) {
|
|
@@ -8118,11 +8069,12 @@ class ObjectPattern extends NodeBase {
|
|
|
8118
8069
|
}
|
|
8119
8070
|
}
|
|
8120
8071
|
}
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8072
|
+
hasEffectsOnInteractionAtPath(
|
|
8073
|
+
// At the moment, this is only triggered for assignment left-hand sides,
|
|
8074
|
+
// where the path is empty
|
|
8075
|
+
_path, interaction, context) {
|
|
8124
8076
|
for (const property of this.properties) {
|
|
8125
|
-
if (property.
|
|
8077
|
+
if (property.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
8126
8078
|
return true;
|
|
8127
8079
|
}
|
|
8128
8080
|
return false;
|
|
@@ -8136,75 +8088,78 @@ class ObjectPattern extends NodeBase {
|
|
|
8136
8088
|
|
|
8137
8089
|
class AssignmentExpression extends NodeBase {
|
|
8138
8090
|
hasEffects(context) {
|
|
8139
|
-
|
|
8091
|
+
const { deoptimized, left, right } = this;
|
|
8092
|
+
if (!deoptimized)
|
|
8140
8093
|
this.applyDeoptimizations();
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8094
|
+
// MemberExpressions do not access the property before assignments if the
|
|
8095
|
+
// operator is '='.
|
|
8096
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, this.operator !== '='));
|
|
8144
8097
|
}
|
|
8145
|
-
|
|
8146
|
-
return
|
|
8098
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8099
|
+
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8147
8100
|
}
|
|
8148
8101
|
include(context, includeChildrenRecursively) {
|
|
8149
|
-
|
|
8102
|
+
const { deoptimized, left, right, operator } = this;
|
|
8103
|
+
if (!deoptimized)
|
|
8150
8104
|
this.applyDeoptimizations();
|
|
8151
8105
|
this.included = true;
|
|
8152
|
-
let hasEffectsContext;
|
|
8153
8106
|
if (includeChildrenRecursively ||
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
(
|
|
8157
|
-
|
|
8158
|
-
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, hasEffectsContext))) {
|
|
8159
|
-
this.left.include(context, includeChildrenRecursively);
|
|
8107
|
+
operator !== '=' ||
|
|
8108
|
+
left.included ||
|
|
8109
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
8110
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
8160
8111
|
}
|
|
8161
|
-
|
|
8112
|
+
right.include(context, includeChildrenRecursively);
|
|
8113
|
+
}
|
|
8114
|
+
initialise() {
|
|
8115
|
+
this.left.setAssignedValue(this.right);
|
|
8162
8116
|
}
|
|
8163
8117
|
render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8118
|
+
const { left, right, start, end, parent } = this;
|
|
8119
|
+
if (left.included) {
|
|
8120
|
+
left.render(code, options);
|
|
8121
|
+
right.render(code, options);
|
|
8167
8122
|
}
|
|
8168
8123
|
else {
|
|
8169
|
-
const inclusionStart = findNonWhiteSpace(code.original, findFirstOccurrenceOutsideComment(code.original, '=',
|
|
8170
|
-
code.remove(
|
|
8124
|
+
const inclusionStart = findNonWhiteSpace(code.original, findFirstOccurrenceOutsideComment(code.original, '=', left.end) + 1);
|
|
8125
|
+
code.remove(start, inclusionStart);
|
|
8171
8126
|
if (preventASI) {
|
|
8172
|
-
removeLineBreaks(code, inclusionStart,
|
|
8127
|
+
removeLineBreaks(code, inclusionStart, right.start);
|
|
8173
8128
|
}
|
|
8174
|
-
|
|
8175
|
-
renderedParentType: renderedParentType ||
|
|
8176
|
-
renderedSurroundingElement: renderedSurroundingElement ||
|
|
8129
|
+
right.render(code, options, {
|
|
8130
|
+
renderedParentType: renderedParentType || parent.type,
|
|
8131
|
+
renderedSurroundingElement: renderedSurroundingElement || parent.type
|
|
8177
8132
|
});
|
|
8178
8133
|
}
|
|
8179
8134
|
if (options.format === 'system') {
|
|
8180
|
-
if (
|
|
8181
|
-
const variable =
|
|
8135
|
+
if (left instanceof Identifier) {
|
|
8136
|
+
const variable = left.variable;
|
|
8182
8137
|
const exportNames = options.exportNamesByVariable.get(variable);
|
|
8183
8138
|
if (exportNames) {
|
|
8184
8139
|
if (exportNames.length === 1) {
|
|
8185
|
-
renderSystemExportExpression(variable,
|
|
8140
|
+
renderSystemExportExpression(variable, start, end, code, options);
|
|
8186
8141
|
}
|
|
8187
8142
|
else {
|
|
8188
|
-
renderSystemExportSequenceAfterExpression(variable,
|
|
8143
|
+
renderSystemExportSequenceAfterExpression(variable, start, end, parent.type !== ExpressionStatement$1, code, options);
|
|
8189
8144
|
}
|
|
8190
8145
|
return;
|
|
8191
8146
|
}
|
|
8192
8147
|
}
|
|
8193
8148
|
else {
|
|
8194
8149
|
const systemPatternExports = [];
|
|
8195
|
-
|
|
8150
|
+
left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
8196
8151
|
if (systemPatternExports.length > 0) {
|
|
8197
|
-
renderSystemExportFunction(systemPatternExports,
|
|
8152
|
+
renderSystemExportFunction(systemPatternExports, start, end, renderedSurroundingElement === ExpressionStatement$1, code, options);
|
|
8198
8153
|
return;
|
|
8199
8154
|
}
|
|
8200
8155
|
}
|
|
8201
8156
|
}
|
|
8202
|
-
if (
|
|
8203
|
-
|
|
8157
|
+
if (left.included &&
|
|
8158
|
+
left instanceof ObjectPattern &&
|
|
8204
8159
|
(renderedSurroundingElement === ExpressionStatement$1 ||
|
|
8205
8160
|
renderedSurroundingElement === ArrowFunctionExpression$1)) {
|
|
8206
|
-
code.appendRight(
|
|
8207
|
-
code.prependLeft(
|
|
8161
|
+
code.appendRight(start, '(');
|
|
8162
|
+
code.prependLeft(end, ')');
|
|
8208
8163
|
}
|
|
8209
8164
|
}
|
|
8210
8165
|
applyDeoptimizations() {
|
|
@@ -8225,27 +8180,15 @@ class AssignmentPattern extends NodeBase {
|
|
|
8225
8180
|
deoptimizePath(path) {
|
|
8226
8181
|
path.length === 0 && this.left.deoptimizePath(path);
|
|
8227
8182
|
}
|
|
8228
|
-
|
|
8229
|
-
return path.length > 0 || this.left.
|
|
8230
|
-
}
|
|
8231
|
-
include(context, includeChildrenRecursively) {
|
|
8232
|
-
if (!this.deoptimized)
|
|
8233
|
-
this.applyDeoptimizations();
|
|
8234
|
-
this.included = true;
|
|
8235
|
-
this.left.include(context, includeChildrenRecursively);
|
|
8236
|
-
this.right.include(context, includeChildrenRecursively);
|
|
8183
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8184
|
+
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
8237
8185
|
}
|
|
8238
8186
|
markDeclarationReached() {
|
|
8239
8187
|
this.left.markDeclarationReached();
|
|
8240
8188
|
}
|
|
8241
8189
|
render(code, options, { isShorthandProperty } = BLANK) {
|
|
8242
8190
|
this.left.render(code, options, { isShorthandProperty });
|
|
8243
|
-
|
|
8244
|
-
this.right.render(code, options);
|
|
8245
|
-
}
|
|
8246
|
-
else {
|
|
8247
|
-
code.remove(this.left.end, this.end);
|
|
8248
|
-
}
|
|
8191
|
+
this.right.render(code, options);
|
|
8249
8192
|
}
|
|
8250
8193
|
applyDeoptimizations() {
|
|
8251
8194
|
this.deoptimized = true;
|
|
@@ -8259,14 +8202,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
8259
8202
|
constructor(context) {
|
|
8260
8203
|
super('arguments', null, UNKNOWN_EXPRESSION, context);
|
|
8261
8204
|
}
|
|
8262
|
-
|
|
8263
|
-
return path.length > 1;
|
|
8264
|
-
}
|
|
8265
|
-
hasEffectsWhenAssignedAtPath() {
|
|
8266
|
-
return true;
|
|
8267
|
-
}
|
|
8268
|
-
hasEffectsWhenCalledAtPath() {
|
|
8269
|
-
return true;
|
|
8205
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8206
|
+
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8270
8207
|
}
|
|
8271
8208
|
}
|
|
8272
8209
|
|
|
@@ -8282,8 +8219,8 @@ class ThisVariable extends LocalVariable {
|
|
|
8282
8219
|
for (const path of this.deoptimizedPaths) {
|
|
8283
8220
|
entity.deoptimizePath(path);
|
|
8284
8221
|
}
|
|
8285
|
-
for (const
|
|
8286
|
-
|
|
8222
|
+
for (const { interaction, path } of this.thisDeoptimizationList) {
|
|
8223
|
+
entity.deoptimizeThisOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
8287
8224
|
}
|
|
8288
8225
|
this.entitiesToBeDeoptimized.add(entity);
|
|
8289
8226
|
}
|
|
@@ -8297,29 +8234,21 @@ class ThisVariable extends LocalVariable {
|
|
|
8297
8234
|
entity.deoptimizePath(path);
|
|
8298
8235
|
}
|
|
8299
8236
|
}
|
|
8300
|
-
|
|
8237
|
+
deoptimizeThisOnInteractionAtPath(interaction, path) {
|
|
8301
8238
|
const thisDeoptimization = {
|
|
8302
|
-
|
|
8303
|
-
path
|
|
8304
|
-
thisParameter
|
|
8239
|
+
interaction,
|
|
8240
|
+
path
|
|
8305
8241
|
};
|
|
8306
|
-
if (!this.thisDeoptimizations.trackEntityAtPathAndGetIfTracked(path,
|
|
8242
|
+
if (!this.thisDeoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.type, interaction.thisArg)) {
|
|
8307
8243
|
for (const entity of this.entitiesToBeDeoptimized) {
|
|
8308
|
-
|
|
8244
|
+
entity.deoptimizeThisOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
8309
8245
|
}
|
|
8310
8246
|
this.thisDeoptimizationList.push(thisDeoptimization);
|
|
8311
8247
|
}
|
|
8312
8248
|
}
|
|
8313
|
-
|
|
8314
|
-
return (this.getInit(context).
|
|
8315
|
-
super.
|
|
8316
|
-
}
|
|
8317
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8318
|
-
return (this.getInit(context).hasEffectsWhenAssignedAtPath(path, context) ||
|
|
8319
|
-
super.hasEffectsWhenAssignedAtPath(path, context));
|
|
8320
|
-
}
|
|
8321
|
-
applyThisDeoptimizationEvent(entity, { event, path, thisParameter }) {
|
|
8322
|
-
entity.deoptimizeThisOnEventAtPath(event, path, thisParameter === this ? entity : thisParameter, SHARED_RECURSION_TRACKER);
|
|
8249
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8250
|
+
return (this.getInit(context).hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
8251
|
+
super.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8323
8252
|
}
|
|
8324
8253
|
getInit(context) {
|
|
8325
8254
|
return context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION;
|
|
@@ -8355,42 +8284,44 @@ class FunctionNode extends FunctionBase {
|
|
|
8355
8284
|
createScope(parentScope) {
|
|
8356
8285
|
this.scope = new FunctionScope(parentScope, this.context);
|
|
8357
8286
|
}
|
|
8358
|
-
|
|
8359
|
-
super.
|
|
8360
|
-
if (
|
|
8361
|
-
this.scope.thisVariable.addEntityToBeDeoptimized(
|
|
8287
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8288
|
+
super.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8289
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
8290
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.thisArg);
|
|
8362
8291
|
}
|
|
8363
8292
|
}
|
|
8364
|
-
hasEffects() {
|
|
8293
|
+
hasEffects(context) {
|
|
8365
8294
|
var _a;
|
|
8366
8295
|
if (!this.deoptimized)
|
|
8367
8296
|
this.applyDeoptimizations();
|
|
8368
|
-
return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects());
|
|
8297
|
+
return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
|
|
8369
8298
|
}
|
|
8370
|
-
|
|
8371
|
-
if (super.
|
|
8372
|
-
return true;
|
|
8373
|
-
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
8374
|
-
context.replacedVariableInits.set(this.scope.thisVariable, callOptions.withNew
|
|
8375
|
-
? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
|
|
8376
|
-
: UNKNOWN_EXPRESSION);
|
|
8377
|
-
const { brokenFlow, ignore } = context;
|
|
8378
|
-
context.ignore = {
|
|
8379
|
-
breaks: false,
|
|
8380
|
-
continues: false,
|
|
8381
|
-
labels: new Set(),
|
|
8382
|
-
returnYield: true
|
|
8383
|
-
};
|
|
8384
|
-
if (this.body.hasEffects(context))
|
|
8299
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8300
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8385
8301
|
return true;
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
context.replacedVariableInits.set(this.scope.thisVariable,
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
context
|
|
8302
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
8303
|
+
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
8304
|
+
context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew
|
|
8305
|
+
? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
|
|
8306
|
+
: UNKNOWN_EXPRESSION);
|
|
8307
|
+
const { brokenFlow, ignore } = context;
|
|
8308
|
+
context.ignore = {
|
|
8309
|
+
breaks: false,
|
|
8310
|
+
continues: false,
|
|
8311
|
+
labels: new Set(),
|
|
8312
|
+
returnYield: true
|
|
8313
|
+
};
|
|
8314
|
+
if (this.body.hasEffects(context))
|
|
8315
|
+
return true;
|
|
8316
|
+
context.brokenFlow = brokenFlow;
|
|
8317
|
+
if (thisInit) {
|
|
8318
|
+
context.replacedVariableInits.set(this.scope.thisVariable, thisInit);
|
|
8319
|
+
}
|
|
8320
|
+
else {
|
|
8321
|
+
context.replacedVariableInits.delete(this.scope.thisVariable);
|
|
8322
|
+
}
|
|
8323
|
+
context.ignore = ignore;
|
|
8392
8324
|
}
|
|
8393
|
-
context.ignore = ignore;
|
|
8394
8325
|
return false;
|
|
8395
8326
|
}
|
|
8396
8327
|
include(context, includeChildrenRecursively) {
|
|
@@ -8493,12 +8424,13 @@ class BinaryExpression extends NodeBase {
|
|
|
8493
8424
|
// support some implicit type coercion runtime errors
|
|
8494
8425
|
if (this.operator === '+' &&
|
|
8495
8426
|
this.parent instanceof ExpressionStatement &&
|
|
8496
|
-
this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) === '')
|
|
8427
|
+
this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) === '') {
|
|
8497
8428
|
return true;
|
|
8429
|
+
}
|
|
8498
8430
|
return super.hasEffects(context);
|
|
8499
8431
|
}
|
|
8500
|
-
|
|
8501
|
-
return path.length > 1;
|
|
8432
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8433
|
+
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8502
8434
|
}
|
|
8503
8435
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
8504
8436
|
this.left.render(code, options, { renderedSurroundingElement });
|
|
@@ -8557,7 +8489,7 @@ function renderCallArguments(code, options, node) {
|
|
|
8557
8489
|
}
|
|
8558
8490
|
|
|
8559
8491
|
class Literal extends NodeBase {
|
|
8560
|
-
|
|
8492
|
+
deoptimizeThisOnInteractionAtPath() { }
|
|
8561
8493
|
getLiteralValueAtPath(path) {
|
|
8562
8494
|
if (path.length > 0 ||
|
|
8563
8495
|
// unknown literals can also be null but do not start with an "n"
|
|
@@ -8574,17 +8506,16 @@ class Literal extends NodeBase {
|
|
|
8574
8506
|
return UNKNOWN_EXPRESSION;
|
|
8575
8507
|
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
8576
8508
|
}
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8509
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8510
|
+
switch (interaction.type) {
|
|
8511
|
+
case INTERACTION_ACCESSED:
|
|
8512
|
+
return path.length > (this.value === null ? 0 : 1);
|
|
8513
|
+
case INTERACTION_ASSIGNED:
|
|
8514
|
+
return true;
|
|
8515
|
+
case INTERACTION_CALLED:
|
|
8516
|
+
return (path.length !== 1 ||
|
|
8517
|
+
hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
|
|
8586
8518
|
}
|
|
8587
|
-
return true;
|
|
8588
8519
|
}
|
|
8589
8520
|
initialise() {
|
|
8590
8521
|
this.members = getLiteralMembersForValue(this.value);
|
|
@@ -8642,6 +8573,7 @@ class MemberExpression extends NodeBase {
|
|
|
8642
8573
|
constructor() {
|
|
8643
8574
|
super(...arguments);
|
|
8644
8575
|
this.variable = null;
|
|
8576
|
+
this.assignmentDeoptimized = false;
|
|
8645
8577
|
this.bound = false;
|
|
8646
8578
|
this.expressionsToBeDeoptimized = [];
|
|
8647
8579
|
this.replacement = null;
|
|
@@ -8651,7 +8583,7 @@ class MemberExpression extends NodeBase {
|
|
|
8651
8583
|
const path = getPathIfNotComputed(this);
|
|
8652
8584
|
const baseVariable = path && this.scope.findVariable(path[0].key);
|
|
8653
8585
|
if (baseVariable && baseVariable.isNamespace) {
|
|
8654
|
-
const resolvedVariable =
|
|
8586
|
+
const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.context);
|
|
8655
8587
|
if (!resolvedVariable) {
|
|
8656
8588
|
super.bind();
|
|
8657
8589
|
}
|
|
@@ -8692,21 +8624,21 @@ class MemberExpression extends NodeBase {
|
|
|
8692
8624
|
}
|
|
8693
8625
|
}
|
|
8694
8626
|
}
|
|
8695
|
-
|
|
8627
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8696
8628
|
if (this.variable) {
|
|
8697
|
-
this.variable.
|
|
8629
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8698
8630
|
}
|
|
8699
8631
|
else if (!this.replacement) {
|
|
8700
8632
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8701
|
-
this.object.
|
|
8633
|
+
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
8702
8634
|
}
|
|
8703
8635
|
else {
|
|
8704
|
-
|
|
8636
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
8705
8637
|
}
|
|
8706
8638
|
}
|
|
8707
8639
|
}
|
|
8708
8640
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8709
|
-
if (this.variable
|
|
8641
|
+
if (this.variable) {
|
|
8710
8642
|
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8711
8643
|
}
|
|
8712
8644
|
if (this.replacement) {
|
|
@@ -8718,81 +8650,62 @@ class MemberExpression extends NodeBase {
|
|
|
8718
8650
|
}
|
|
8719
8651
|
return UnknownValue;
|
|
8720
8652
|
}
|
|
8721
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
8722
|
-
if (this.variable
|
|
8723
|
-
return this.variable.getReturnExpressionWhenCalledAtPath(path,
|
|
8653
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8654
|
+
if (this.variable) {
|
|
8655
|
+
return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8724
8656
|
}
|
|
8725
8657
|
if (this.replacement) {
|
|
8726
8658
|
return UNKNOWN_EXPRESSION;
|
|
8727
8659
|
}
|
|
8728
8660
|
this.expressionsToBeDeoptimized.push(origin);
|
|
8729
8661
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8730
|
-
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path],
|
|
8662
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
8731
8663
|
}
|
|
8732
8664
|
return UNKNOWN_EXPRESSION;
|
|
8733
8665
|
}
|
|
8734
8666
|
hasEffects(context) {
|
|
8735
8667
|
if (!this.deoptimized)
|
|
8736
8668
|
this.applyDeoptimizations();
|
|
8737
|
-
const { propertyReadSideEffects } = this.context.options
|
|
8738
|
-
.treeshake;
|
|
8739
8669
|
return (this.property.hasEffects(context) ||
|
|
8740
8670
|
this.object.hasEffects(context) ||
|
|
8741
|
-
|
|
8742
|
-
(!(this.variable ||
|
|
8743
|
-
this.replacement ||
|
|
8744
|
-
(this.parent instanceof AssignmentExpression && this.parent.operator === '=')) &&
|
|
8745
|
-
propertyReadSideEffects &&
|
|
8746
|
-
(propertyReadSideEffects === 'always' ||
|
|
8747
|
-
this.object.hasEffectsWhenAccessedAtPath([this.getPropertyKey()], context))));
|
|
8748
|
-
}
|
|
8749
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
8750
|
-
if (this.variable !== null) {
|
|
8751
|
-
return this.variable.hasEffectsWhenAccessedAtPath(path, context);
|
|
8752
|
-
}
|
|
8753
|
-
if (this.replacement) {
|
|
8754
|
-
return true;
|
|
8755
|
-
}
|
|
8756
|
-
if (path.length < MAX_PATH_DEPTH) {
|
|
8757
|
-
return this.object.hasEffectsWhenAccessedAtPath([this.getPropertyKey(), ...path], context);
|
|
8758
|
-
}
|
|
8759
|
-
return true;
|
|
8671
|
+
this.hasAccessEffect(context));
|
|
8760
8672
|
}
|
|
8761
|
-
|
|
8762
|
-
if (this.
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
}
|
|
8771
|
-
return true;
|
|
8673
|
+
hasEffectsAsAssignmentTarget(context, checkAccess) {
|
|
8674
|
+
if (checkAccess && !this.deoptimized)
|
|
8675
|
+
this.applyDeoptimizations();
|
|
8676
|
+
if (!this.assignmentDeoptimized)
|
|
8677
|
+
this.applyAssignmentDeoptimization();
|
|
8678
|
+
return (this.property.hasEffects(context) ||
|
|
8679
|
+
this.object.hasEffects(context) ||
|
|
8680
|
+
(checkAccess && this.hasAccessEffect(context)) ||
|
|
8681
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
8772
8682
|
}
|
|
8773
|
-
|
|
8774
|
-
if (this.variable
|
|
8775
|
-
return this.variable.
|
|
8683
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8684
|
+
if (this.variable) {
|
|
8685
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8776
8686
|
}
|
|
8777
8687
|
if (this.replacement) {
|
|
8778
8688
|
return true;
|
|
8779
8689
|
}
|
|
8780
8690
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8781
|
-
return this.object.
|
|
8691
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
8782
8692
|
}
|
|
8783
8693
|
return true;
|
|
8784
8694
|
}
|
|
8785
8695
|
include(context, includeChildrenRecursively) {
|
|
8786
8696
|
if (!this.deoptimized)
|
|
8787
8697
|
this.applyDeoptimizations();
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8698
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8699
|
+
}
|
|
8700
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
8701
|
+
if (!this.assignmentDeoptimized)
|
|
8702
|
+
this.applyAssignmentDeoptimization();
|
|
8703
|
+
if (deoptimizeAccess) {
|
|
8704
|
+
this.include(context, includeChildrenRecursively);
|
|
8705
|
+
}
|
|
8706
|
+
else {
|
|
8707
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8793
8708
|
}
|
|
8794
|
-
this.object.include(context, includeChildrenRecursively);
|
|
8795
|
-
this.property.include(context, includeChildrenRecursively);
|
|
8796
8709
|
}
|
|
8797
8710
|
includeCallArguments(context, args) {
|
|
8798
8711
|
if (this.variable) {
|
|
@@ -8804,6 +8717,7 @@ class MemberExpression extends NodeBase {
|
|
|
8804
8717
|
}
|
|
8805
8718
|
initialise() {
|
|
8806
8719
|
this.propertyKey = getResolvablePropertyKey(this);
|
|
8720
|
+
this.accessInteraction = { thisArg: this.object, type: INTERACTION_ACCESSED };
|
|
8807
8721
|
}
|
|
8808
8722
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
8809
8723
|
if (this.variable || this.replacement) {
|
|
@@ -8824,6 +8738,13 @@ class MemberExpression extends NodeBase {
|
|
|
8824
8738
|
this.property.render(code, options);
|
|
8825
8739
|
}
|
|
8826
8740
|
}
|
|
8741
|
+
setAssignedValue(value) {
|
|
8742
|
+
this.assignmentInteraction = {
|
|
8743
|
+
args: [value],
|
|
8744
|
+
thisArg: this.object,
|
|
8745
|
+
type: INTERACTION_ASSIGNED
|
|
8746
|
+
};
|
|
8747
|
+
}
|
|
8827
8748
|
applyDeoptimizations() {
|
|
8828
8749
|
this.deoptimized = true;
|
|
8829
8750
|
const { propertyReadSideEffects } = this.context.options
|
|
@@ -8833,13 +8754,21 @@ class MemberExpression extends NodeBase {
|
|
|
8833
8754
|
this.bound &&
|
|
8834
8755
|
propertyReadSideEffects &&
|
|
8835
8756
|
!(this.variable || this.replacement)) {
|
|
8836
|
-
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8757
|
+
const propertyKey = this.getPropertyKey();
|
|
8758
|
+
this.object.deoptimizeThisOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
8759
|
+
this.context.requestTreeshakingPass();
|
|
8760
|
+
}
|
|
8761
|
+
}
|
|
8762
|
+
applyAssignmentDeoptimization() {
|
|
8763
|
+
this.assignmentDeoptimized = true;
|
|
8764
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8765
|
+
.treeshake;
|
|
8766
|
+
if (
|
|
8767
|
+
// Namespaces are not bound and should not be deoptimized
|
|
8768
|
+
this.bound &&
|
|
8769
|
+
propertyReadSideEffects &&
|
|
8770
|
+
!(this.variable || this.replacement)) {
|
|
8771
|
+
this.object.deoptimizeThisOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
8843
8772
|
this.context.requestTreeshakingPass();
|
|
8844
8773
|
}
|
|
8845
8774
|
}
|
|
@@ -8865,28 +8794,46 @@ class MemberExpression extends NodeBase {
|
|
|
8865
8794
|
}
|
|
8866
8795
|
return this.propertyKey;
|
|
8867
8796
|
}
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
missing: exportName,
|
|
8883
|
-
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
8884
|
-
}, path[0].pos);
|
|
8885
|
-
return 'undefined';
|
|
8797
|
+
hasAccessEffect(context) {
|
|
8798
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8799
|
+
.treeshake;
|
|
8800
|
+
return (!(this.variable || this.replacement) &&
|
|
8801
|
+
propertyReadSideEffects &&
|
|
8802
|
+
(propertyReadSideEffects === 'always' ||
|
|
8803
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
8804
|
+
}
|
|
8805
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
8806
|
+
if (!this.included) {
|
|
8807
|
+
this.included = true;
|
|
8808
|
+
if (this.variable) {
|
|
8809
|
+
this.context.includeVariableInModule(this.variable);
|
|
8810
|
+
}
|
|
8886
8811
|
}
|
|
8887
|
-
|
|
8812
|
+
this.object.include(context, includeChildrenRecursively);
|
|
8813
|
+
this.property.include(context, includeChildrenRecursively);
|
|
8888
8814
|
}
|
|
8889
8815
|
}
|
|
8816
|
+
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
8817
|
+
if (path.length === 0)
|
|
8818
|
+
return baseVariable;
|
|
8819
|
+
if (!baseVariable.isNamespace || baseVariable instanceof ExternalVariable)
|
|
8820
|
+
return null;
|
|
8821
|
+
const exportName = path[0].key;
|
|
8822
|
+
const variable = baseVariable.context.traceExport(exportName);
|
|
8823
|
+
if (!variable) {
|
|
8824
|
+
const fileName = baseVariable.context.fileName;
|
|
8825
|
+
astContext.warn({
|
|
8826
|
+
code: 'MISSING_EXPORT',
|
|
8827
|
+
exporter: relativeId(fileName),
|
|
8828
|
+
importer: relativeId(astContext.fileName),
|
|
8829
|
+
message: `'${exportName}' is not exported by '${relativeId(fileName)}'`,
|
|
8830
|
+
missing: exportName,
|
|
8831
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
8832
|
+
}, path[0].pos);
|
|
8833
|
+
return 'undefined';
|
|
8834
|
+
}
|
|
8835
|
+
return resolveNamespaceVariables(variable, path.slice(1), astContext);
|
|
8836
|
+
}
|
|
8890
8837
|
|
|
8891
8838
|
class CallExpressionBase extends NodeBase {
|
|
8892
8839
|
constructor() {
|
|
@@ -8916,15 +8863,15 @@ class CallExpressionBase extends NodeBase {
|
|
|
8916
8863
|
returnExpression.deoptimizePath(path);
|
|
8917
8864
|
}
|
|
8918
8865
|
}
|
|
8919
|
-
|
|
8866
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8920
8867
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
8921
8868
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
8922
|
-
|
|
8869
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
8923
8870
|
}
|
|
8924
8871
|
else {
|
|
8925
8872
|
recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
8926
|
-
this.expressionsToBeDeoptimized.add(
|
|
8927
|
-
returnExpression.
|
|
8873
|
+
this.expressionsToBeDeoptimized.add(interaction.thisArg);
|
|
8874
|
+
returnExpression.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8928
8875
|
}, undefined);
|
|
8929
8876
|
}
|
|
8930
8877
|
}
|
|
@@ -8938,27 +8885,31 @@ class CallExpressionBase extends NodeBase {
|
|
|
8938
8885
|
return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8939
8886
|
}, UnknownValue);
|
|
8940
8887
|
}
|
|
8941
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
8888
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8942
8889
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
8943
8890
|
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
8944
8891
|
return UNKNOWN_EXPRESSION;
|
|
8945
8892
|
}
|
|
8946
8893
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
8947
8894
|
this.deoptimizableDependentExpressions.push(origin);
|
|
8948
|
-
return returnExpression.getReturnExpressionWhenCalledAtPath(path,
|
|
8895
|
+
return returnExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8949
8896
|
}, UNKNOWN_EXPRESSION);
|
|
8950
8897
|
}
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8898
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8899
|
+
const { type } = interaction;
|
|
8900
|
+
if (type === INTERACTION_CALLED) {
|
|
8901
|
+
if ((interaction.withNew
|
|
8902
|
+
? context.instantiated
|
|
8903
|
+
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)) {
|
|
8904
|
+
return false;
|
|
8905
|
+
}
|
|
8906
|
+
}
|
|
8907
|
+
else if ((type === INTERACTION_ASSIGNED
|
|
8908
|
+
? context.assigned
|
|
8909
|
+
: context.accessed).trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
8910
|
+
return false;
|
|
8911
|
+
}
|
|
8912
|
+
return this.getReturnExpression().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8962
8913
|
}
|
|
8963
8914
|
}
|
|
8964
8915
|
|
|
@@ -8981,11 +8932,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
8981
8932
|
}, this.start);
|
|
8982
8933
|
}
|
|
8983
8934
|
}
|
|
8984
|
-
this.
|
|
8935
|
+
this.interaction = {
|
|
8985
8936
|
args: this.arguments,
|
|
8986
|
-
|
|
8937
|
+
thisArg: this.callee instanceof MemberExpression && !this.callee.variable
|
|
8987
8938
|
? this.callee.object
|
|
8988
8939
|
: null,
|
|
8940
|
+
type: INTERACTION_CALLED,
|
|
8989
8941
|
withNew: false
|
|
8990
8942
|
};
|
|
8991
8943
|
}
|
|
@@ -8999,7 +8951,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
8999
8951
|
this.annotations)
|
|
9000
8952
|
return false;
|
|
9001
8953
|
return (this.callee.hasEffects(context) ||
|
|
9002
|
-
this.callee.
|
|
8954
|
+
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
9003
8955
|
}
|
|
9004
8956
|
finally {
|
|
9005
8957
|
if (!this.deoptimized)
|
|
@@ -9036,9 +8988,8 @@ class CallExpression extends CallExpressionBase {
|
|
|
9036
8988
|
}
|
|
9037
8989
|
applyDeoptimizations() {
|
|
9038
8990
|
this.deoptimized = true;
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
this.callee.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
|
|
8991
|
+
if (this.interaction.thisArg) {
|
|
8992
|
+
this.callee.deoptimizeThisOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
9042
8993
|
}
|
|
9043
8994
|
for (const argument of this.arguments) {
|
|
9044
8995
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -9049,7 +9000,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9049
9000
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
9050
9001
|
if (this.returnExpression === null) {
|
|
9051
9002
|
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9052
|
-
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.
|
|
9003
|
+
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
9053
9004
|
}
|
|
9054
9005
|
return this.returnExpression;
|
|
9055
9006
|
}
|
|
@@ -9127,11 +9078,6 @@ class MethodBase extends NodeBase {
|
|
|
9127
9078
|
constructor() {
|
|
9128
9079
|
super(...arguments);
|
|
9129
9080
|
this.accessedValue = null;
|
|
9130
|
-
this.accessorCallOptions = {
|
|
9131
|
-
args: NO_ARGS,
|
|
9132
|
-
thisParam: null,
|
|
9133
|
-
withNew: false
|
|
9134
|
-
};
|
|
9135
9081
|
}
|
|
9136
9082
|
// As getter properties directly receive their values from fixed function
|
|
9137
9083
|
// expressions, there is no known situation where a getter is deoptimized.
|
|
@@ -9139,45 +9085,60 @@ class MethodBase extends NodeBase {
|
|
|
9139
9085
|
deoptimizePath(path) {
|
|
9140
9086
|
this.getAccessedValue().deoptimizePath(path);
|
|
9141
9087
|
}
|
|
9142
|
-
|
|
9143
|
-
if (
|
|
9144
|
-
return this.value.
|
|
9088
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9089
|
+
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
9090
|
+
return this.value.deoptimizeThisOnInteractionAtPath({
|
|
9091
|
+
args: NO_ARGS,
|
|
9092
|
+
thisArg: interaction.thisArg,
|
|
9093
|
+
type: INTERACTION_CALLED,
|
|
9094
|
+
withNew: false
|
|
9095
|
+
}, EMPTY_PATH, recursionTracker);
|
|
9145
9096
|
}
|
|
9146
|
-
if (
|
|
9147
|
-
return this.value.
|
|
9097
|
+
if (interaction.type === INTERACTION_ASSIGNED && this.kind === 'set' && path.length === 0) {
|
|
9098
|
+
return this.value.deoptimizeThisOnInteractionAtPath({
|
|
9099
|
+
args: interaction.args,
|
|
9100
|
+
thisArg: interaction.thisArg,
|
|
9101
|
+
type: INTERACTION_CALLED,
|
|
9102
|
+
withNew: false
|
|
9103
|
+
}, EMPTY_PATH, recursionTracker);
|
|
9148
9104
|
}
|
|
9149
|
-
this.getAccessedValue().
|
|
9105
|
+
this.getAccessedValue().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9150
9106
|
}
|
|
9151
9107
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9152
9108
|
return this.getAccessedValue().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9153
9109
|
}
|
|
9154
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9155
|
-
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path,
|
|
9110
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9111
|
+
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9156
9112
|
}
|
|
9157
9113
|
hasEffects(context) {
|
|
9158
9114
|
return this.key.hasEffects(context);
|
|
9159
9115
|
}
|
|
9160
|
-
|
|
9161
|
-
if (this.kind === 'get' && path.length === 0) {
|
|
9162
|
-
return this.value.
|
|
9163
|
-
|
|
9164
|
-
|
|
9165
|
-
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9116
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9117
|
+
if (this.kind === 'get' && interaction.type === INTERACTION_ACCESSED && path.length === 0) {
|
|
9118
|
+
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9119
|
+
args: NO_ARGS,
|
|
9120
|
+
thisArg: interaction.thisArg,
|
|
9121
|
+
type: INTERACTION_CALLED,
|
|
9122
|
+
withNew: false
|
|
9123
|
+
}, context);
|
|
9124
|
+
}
|
|
9125
|
+
// setters are only called for empty paths
|
|
9126
|
+
if (this.kind === 'set' && interaction.type === INTERACTION_ASSIGNED) {
|
|
9127
|
+
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9128
|
+
args: interaction.args,
|
|
9129
|
+
thisArg: interaction.thisArg,
|
|
9130
|
+
type: INTERACTION_CALLED,
|
|
9131
|
+
withNew: false
|
|
9132
|
+
}, context);
|
|
9169
9133
|
}
|
|
9170
|
-
return this.getAccessedValue().
|
|
9171
|
-
}
|
|
9172
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9173
|
-
return this.getAccessedValue().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
9134
|
+
return this.getAccessedValue().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9174
9135
|
}
|
|
9175
9136
|
applyDeoptimizations() { }
|
|
9176
9137
|
getAccessedValue() {
|
|
9177
9138
|
if (this.accessedValue === null) {
|
|
9178
9139
|
if (this.kind === 'get') {
|
|
9179
9140
|
this.accessedValue = UNKNOWN_EXPRESSION;
|
|
9180
|
-
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH,
|
|
9141
|
+
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, SHARED_RECURSION_TRACKER, this));
|
|
9181
9142
|
}
|
|
9182
9143
|
else {
|
|
9183
9144
|
return (this.accessedValue = this.value);
|
|
@@ -9200,23 +9161,17 @@ class ObjectMember extends ExpressionEntity {
|
|
|
9200
9161
|
deoptimizePath(path) {
|
|
9201
9162
|
this.object.deoptimizePath([this.key, ...path]);
|
|
9202
9163
|
}
|
|
9203
|
-
|
|
9204
|
-
this.object.
|
|
9164
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9165
|
+
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
9205
9166
|
}
|
|
9206
9167
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9207
9168
|
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
9208
9169
|
}
|
|
9209
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9210
|
-
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path],
|
|
9211
|
-
}
|
|
9212
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
9213
|
-
return this.object.hasEffectsWhenAccessedAtPath([this.key, ...path], context);
|
|
9214
|
-
}
|
|
9215
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9216
|
-
return this.object.hasEffectsWhenAssignedAtPath([this.key, ...path], context);
|
|
9170
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9171
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
9217
9172
|
}
|
|
9218
|
-
|
|
9219
|
-
return this.object.
|
|
9173
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9174
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
9220
9175
|
}
|
|
9221
9176
|
}
|
|
9222
9177
|
|
|
@@ -9234,14 +9189,14 @@ class ClassNode extends NodeBase {
|
|
|
9234
9189
|
deoptimizePath(path) {
|
|
9235
9190
|
this.getObjectEntity().deoptimizePath(path);
|
|
9236
9191
|
}
|
|
9237
|
-
|
|
9238
|
-
this.getObjectEntity().
|
|
9192
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9193
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9239
9194
|
}
|
|
9240
9195
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9241
9196
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9242
9197
|
}
|
|
9243
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9244
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
9198
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9199
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9245
9200
|
}
|
|
9246
9201
|
hasEffects(context) {
|
|
9247
9202
|
var _a, _b;
|
|
@@ -9251,23 +9206,17 @@ class ClassNode extends NodeBase {
|
|
|
9251
9206
|
(_b = this.id) === null || _b === void 0 ? void 0 : _b.markDeclarationReached();
|
|
9252
9207
|
return initEffect || super.hasEffects(context);
|
|
9253
9208
|
}
|
|
9254
|
-
|
|
9255
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
9256
|
-
}
|
|
9257
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9258
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
9259
|
-
}
|
|
9260
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9209
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9261
9210
|
var _a;
|
|
9262
|
-
if (path.length === 0) {
|
|
9263
|
-
return (!
|
|
9211
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
9212
|
+
return (!interaction.withNew ||
|
|
9264
9213
|
(this.classConstructor !== null
|
|
9265
|
-
? this.classConstructor.
|
|
9266
|
-
: (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.
|
|
9214
|
+
? this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
9215
|
+
: (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
|
|
9267
9216
|
false);
|
|
9268
9217
|
}
|
|
9269
9218
|
else {
|
|
9270
|
-
return this.getObjectEntity().
|
|
9219
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9271
9220
|
}
|
|
9272
9221
|
}
|
|
9273
9222
|
include(context, includeChildrenRecursively) {
|
|
@@ -9388,26 +9337,12 @@ class MultiExpression extends ExpressionEntity {
|
|
|
9388
9337
|
expression.deoptimizePath(path);
|
|
9389
9338
|
}
|
|
9390
9339
|
}
|
|
9391
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9392
|
-
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path,
|
|
9393
|
-
}
|
|
9394
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
9395
|
-
for (const expression of this.expressions) {
|
|
9396
|
-
if (expression.hasEffectsWhenAccessedAtPath(path, context))
|
|
9397
|
-
return true;
|
|
9398
|
-
}
|
|
9399
|
-
return false;
|
|
9340
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9341
|
+
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)));
|
|
9400
9342
|
}
|
|
9401
|
-
|
|
9343
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9402
9344
|
for (const expression of this.expressions) {
|
|
9403
|
-
if (expression.
|
|
9404
|
-
return true;
|
|
9405
|
-
}
|
|
9406
|
-
return false;
|
|
9407
|
-
}
|
|
9408
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9409
|
-
for (const expression of this.expressions) {
|
|
9410
|
-
if (expression.hasEffectsWhenCalledAtPath(path, callOptions, context))
|
|
9345
|
+
if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
9411
9346
|
return true;
|
|
9412
9347
|
}
|
|
9413
9348
|
return false;
|
|
@@ -9450,9 +9385,9 @@ class ConditionalExpression extends NodeBase {
|
|
|
9450
9385
|
usedBranch.deoptimizePath(path);
|
|
9451
9386
|
}
|
|
9452
9387
|
}
|
|
9453
|
-
|
|
9454
|
-
this.consequent.
|
|
9455
|
-
this.alternate.
|
|
9388
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9389
|
+
this.consequent.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9390
|
+
this.alternate.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9456
9391
|
}
|
|
9457
9392
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9458
9393
|
const usedBranch = this.getUsedBranch();
|
|
@@ -9461,15 +9396,15 @@ class ConditionalExpression extends NodeBase {
|
|
|
9461
9396
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9462
9397
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9463
9398
|
}
|
|
9464
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9399
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9465
9400
|
const usedBranch = this.getUsedBranch();
|
|
9466
9401
|
if (!usedBranch)
|
|
9467
9402
|
return new MultiExpression([
|
|
9468
|
-
this.consequent.getReturnExpressionWhenCalledAtPath(path,
|
|
9469
|
-
this.alternate.getReturnExpressionWhenCalledAtPath(path,
|
|
9403
|
+
this.consequent.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
9404
|
+
this.alternate.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
9470
9405
|
]);
|
|
9471
9406
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9472
|
-
return usedBranch.getReturnExpressionWhenCalledAtPath(path,
|
|
9407
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9473
9408
|
}
|
|
9474
9409
|
hasEffects(context) {
|
|
9475
9410
|
if (this.test.hasEffects(context))
|
|
@@ -9480,29 +9415,13 @@ class ConditionalExpression extends NodeBase {
|
|
|
9480
9415
|
}
|
|
9481
9416
|
return usedBranch.hasEffects(context);
|
|
9482
9417
|
}
|
|
9483
|
-
|
|
9484
|
-
const usedBranch = this.getUsedBranch();
|
|
9485
|
-
if (!usedBranch) {
|
|
9486
|
-
return (this.consequent.hasEffectsWhenAccessedAtPath(path, context) ||
|
|
9487
|
-
this.alternate.hasEffectsWhenAccessedAtPath(path, context));
|
|
9488
|
-
}
|
|
9489
|
-
return usedBranch.hasEffectsWhenAccessedAtPath(path, context);
|
|
9490
|
-
}
|
|
9491
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9492
|
-
const usedBranch = this.getUsedBranch();
|
|
9493
|
-
if (!usedBranch) {
|
|
9494
|
-
return (this.consequent.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
9495
|
-
this.alternate.hasEffectsWhenAssignedAtPath(path, context));
|
|
9496
|
-
}
|
|
9497
|
-
return usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
9498
|
-
}
|
|
9499
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9418
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9500
9419
|
const usedBranch = this.getUsedBranch();
|
|
9501
9420
|
if (!usedBranch) {
|
|
9502
|
-
return (this.consequent.
|
|
9503
|
-
this.alternate.
|
|
9421
|
+
return (this.consequent.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
9422
|
+
this.alternate.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
9504
9423
|
}
|
|
9505
|
-
return usedBranch.
|
|
9424
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9506
9425
|
}
|
|
9507
9426
|
include(context, includeChildrenRecursively) {
|
|
9508
9427
|
this.included = true;
|
|
@@ -9773,12 +9692,10 @@ class ForInStatement extends NodeBase {
|
|
|
9773
9692
|
this.scope = new BlockScope(parentScope);
|
|
9774
9693
|
}
|
|
9775
9694
|
hasEffects(context) {
|
|
9776
|
-
|
|
9695
|
+
const { deoptimized, left, right } = this;
|
|
9696
|
+
if (!deoptimized)
|
|
9777
9697
|
this.applyDeoptimizations();
|
|
9778
|
-
if ((
|
|
9779
|
-
(this.left.hasEffects(context) ||
|
|
9780
|
-
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))) ||
|
|
9781
|
-
(this.right && this.right.hasEffects(context)))
|
|
9698
|
+
if (left.hasEffectsAsAssignmentTarget(context, false) || right.hasEffects(context))
|
|
9782
9699
|
return true;
|
|
9783
9700
|
const { brokenFlow, ignore: { breaks, continues } } = context;
|
|
9784
9701
|
context.ignore.breaks = true;
|
|
@@ -9791,15 +9708,19 @@ class ForInStatement extends NodeBase {
|
|
|
9791
9708
|
return false;
|
|
9792
9709
|
}
|
|
9793
9710
|
include(context, includeChildrenRecursively) {
|
|
9794
|
-
|
|
9711
|
+
const { body, deoptimized, left, right } = this;
|
|
9712
|
+
if (!deoptimized)
|
|
9795
9713
|
this.applyDeoptimizations();
|
|
9796
9714
|
this.included = true;
|
|
9797
|
-
|
|
9798
|
-
|
|
9715
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
9716
|
+
right.include(context, includeChildrenRecursively);
|
|
9799
9717
|
const { brokenFlow } = context;
|
|
9800
|
-
|
|
9718
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
9801
9719
|
context.brokenFlow = brokenFlow;
|
|
9802
9720
|
}
|
|
9721
|
+
initialise() {
|
|
9722
|
+
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9723
|
+
}
|
|
9803
9724
|
render(code, options) {
|
|
9804
9725
|
this.left.render(code, options, NO_SEMICOLON);
|
|
9805
9726
|
this.right.render(code, options, NO_SEMICOLON);
|
|
@@ -9827,15 +9748,19 @@ class ForOfStatement extends NodeBase {
|
|
|
9827
9748
|
return true;
|
|
9828
9749
|
}
|
|
9829
9750
|
include(context, includeChildrenRecursively) {
|
|
9830
|
-
|
|
9751
|
+
const { body, deoptimized, left, right } = this;
|
|
9752
|
+
if (!deoptimized)
|
|
9831
9753
|
this.applyDeoptimizations();
|
|
9832
9754
|
this.included = true;
|
|
9833
|
-
|
|
9834
|
-
|
|
9755
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
9756
|
+
right.include(context, includeChildrenRecursively);
|
|
9835
9757
|
const { brokenFlow } = context;
|
|
9836
|
-
|
|
9758
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
9837
9759
|
context.brokenFlow = brokenFlow;
|
|
9838
9760
|
}
|
|
9761
|
+
initialise() {
|
|
9762
|
+
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9763
|
+
}
|
|
9839
9764
|
render(code, options) {
|
|
9840
9765
|
this.left.render(code, options, NO_SEMICOLON);
|
|
9841
9766
|
this.right.render(code, options, NO_SEMICOLON);
|
|
@@ -10542,9 +10467,9 @@ class LogicalExpression extends NodeBase {
|
|
|
10542
10467
|
usedBranch.deoptimizePath(path);
|
|
10543
10468
|
}
|
|
10544
10469
|
}
|
|
10545
|
-
|
|
10546
|
-
this.left.
|
|
10547
|
-
this.right.
|
|
10470
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10471
|
+
this.left.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10472
|
+
this.right.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10548
10473
|
}
|
|
10549
10474
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
10550
10475
|
const usedBranch = this.getUsedBranch();
|
|
@@ -10553,15 +10478,15 @@ class LogicalExpression extends NodeBase {
|
|
|
10553
10478
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10554
10479
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
10555
10480
|
}
|
|
10556
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
10481
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10557
10482
|
const usedBranch = this.getUsedBranch();
|
|
10558
10483
|
if (!usedBranch)
|
|
10559
10484
|
return new MultiExpression([
|
|
10560
|
-
this.left.getReturnExpressionWhenCalledAtPath(path,
|
|
10561
|
-
this.right.getReturnExpressionWhenCalledAtPath(path,
|
|
10485
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
10486
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
10562
10487
|
]);
|
|
10563
10488
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10564
|
-
return usedBranch.getReturnExpressionWhenCalledAtPath(path,
|
|
10489
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
10565
10490
|
}
|
|
10566
10491
|
hasEffects(context) {
|
|
10567
10492
|
if (this.left.hasEffects(context)) {
|
|
@@ -10572,29 +10497,13 @@ class LogicalExpression extends NodeBase {
|
|
|
10572
10497
|
}
|
|
10573
10498
|
return false;
|
|
10574
10499
|
}
|
|
10575
|
-
|
|
10500
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10576
10501
|
const usedBranch = this.getUsedBranch();
|
|
10577
10502
|
if (!usedBranch) {
|
|
10578
|
-
return (this.left.
|
|
10579
|
-
this.right.
|
|
10503
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
10504
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
10580
10505
|
}
|
|
10581
|
-
return usedBranch.
|
|
10582
|
-
}
|
|
10583
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
10584
|
-
const usedBranch = this.getUsedBranch();
|
|
10585
|
-
if (!usedBranch) {
|
|
10586
|
-
return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
10587
|
-
this.right.hasEffectsWhenAssignedAtPath(path, context));
|
|
10588
|
-
}
|
|
10589
|
-
return usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
10590
|
-
}
|
|
10591
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
10592
|
-
const usedBranch = this.getUsedBranch();
|
|
10593
|
-
if (!usedBranch) {
|
|
10594
|
-
return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
|
|
10595
|
-
this.right.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
10596
|
-
}
|
|
10597
|
-
return usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
10506
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10598
10507
|
}
|
|
10599
10508
|
include(context, includeChildrenRecursively) {
|
|
10600
10509
|
this.included = true;
|
|
@@ -10684,8 +10593,8 @@ class MetaProperty extends NodeBase {
|
|
|
10684
10593
|
hasEffects() {
|
|
10685
10594
|
return false;
|
|
10686
10595
|
}
|
|
10687
|
-
|
|
10688
|
-
return path.length > 1;
|
|
10596
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
10597
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
10689
10598
|
}
|
|
10690
10599
|
include() {
|
|
10691
10600
|
if (!this.included) {
|
|
@@ -10830,18 +10739,19 @@ class NewExpression extends NodeBase {
|
|
|
10830
10739
|
return true;
|
|
10831
10740
|
}
|
|
10832
10741
|
if (this.context.options.treeshake.annotations &&
|
|
10833
|
-
this.annotations)
|
|
10742
|
+
this.annotations) {
|
|
10834
10743
|
return false;
|
|
10744
|
+
}
|
|
10835
10745
|
return (this.callee.hasEffects(context) ||
|
|
10836
|
-
this.callee.
|
|
10746
|
+
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
10837
10747
|
}
|
|
10838
10748
|
finally {
|
|
10839
10749
|
if (!this.deoptimized)
|
|
10840
10750
|
this.applyDeoptimizations();
|
|
10841
10751
|
}
|
|
10842
10752
|
}
|
|
10843
|
-
|
|
10844
|
-
return path.length > 0;
|
|
10753
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
10754
|
+
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
10845
10755
|
}
|
|
10846
10756
|
include(context, includeChildrenRecursively) {
|
|
10847
10757
|
if (!this.deoptimized)
|
|
@@ -10856,9 +10766,10 @@ class NewExpression extends NodeBase {
|
|
|
10856
10766
|
this.callee.includeCallArguments(context, this.arguments);
|
|
10857
10767
|
}
|
|
10858
10768
|
initialise() {
|
|
10859
|
-
this.
|
|
10769
|
+
this.interaction = {
|
|
10860
10770
|
args: this.arguments,
|
|
10861
|
-
|
|
10771
|
+
thisArg: null,
|
|
10772
|
+
type: INTERACTION_CALLED,
|
|
10862
10773
|
withNew: true
|
|
10863
10774
|
};
|
|
10864
10775
|
}
|
|
@@ -10887,23 +10798,17 @@ class ObjectExpression extends NodeBase {
|
|
|
10887
10798
|
deoptimizePath(path) {
|
|
10888
10799
|
this.getObjectEntity().deoptimizePath(path);
|
|
10889
10800
|
}
|
|
10890
|
-
|
|
10891
|
-
this.getObjectEntity().
|
|
10801
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10802
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10892
10803
|
}
|
|
10893
10804
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
10894
10805
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
10895
10806
|
}
|
|
10896
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
10897
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
10898
|
-
}
|
|
10899
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
10900
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
10807
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10808
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
10901
10809
|
}
|
|
10902
|
-
|
|
10903
|
-
return this.getObjectEntity().
|
|
10904
|
-
}
|
|
10905
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
10906
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
10810
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10811
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10907
10812
|
}
|
|
10908
10813
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
10909
10814
|
super.render(code, options);
|
|
@@ -11034,32 +10939,26 @@ class PropertyDefinition extends NodeBase {
|
|
|
11034
10939
|
var _a;
|
|
11035
10940
|
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
11036
10941
|
}
|
|
11037
|
-
|
|
10942
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11038
10943
|
var _a;
|
|
11039
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.
|
|
10944
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11040
10945
|
}
|
|
11041
10946
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11042
10947
|
return this.value
|
|
11043
10948
|
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
|
|
11044
10949
|
: UnknownValue;
|
|
11045
10950
|
}
|
|
11046
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
10951
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
11047
10952
|
return this.value
|
|
11048
|
-
? this.value.getReturnExpressionWhenCalledAtPath(path,
|
|
10953
|
+
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
11049
10954
|
: UNKNOWN_EXPRESSION;
|
|
11050
10955
|
}
|
|
11051
10956
|
hasEffects(context) {
|
|
11052
10957
|
var _a;
|
|
11053
10958
|
return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
11054
10959
|
}
|
|
11055
|
-
|
|
11056
|
-
return !this.value || this.value.
|
|
11057
|
-
}
|
|
11058
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11059
|
-
return !this.value || this.value.hasEffectsWhenAssignedAtPath(path, context);
|
|
11060
|
-
}
|
|
11061
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
11062
|
-
return !this.value || this.value.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
10960
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10961
|
+
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11063
10962
|
}
|
|
11064
10963
|
applyDeoptimizations() { }
|
|
11065
10964
|
}
|
|
@@ -11095,8 +10994,8 @@ class SequenceExpression extends NodeBase {
|
|
|
11095
10994
|
deoptimizePath(path) {
|
|
11096
10995
|
this.expressions[this.expressions.length - 1].deoptimizePath(path);
|
|
11097
10996
|
}
|
|
11098
|
-
|
|
11099
|
-
this.expressions[this.expressions.length - 1].
|
|
10997
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10998
|
+
this.expressions[this.expressions.length - 1].deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11100
10999
|
}
|
|
11101
11000
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11102
11001
|
return this.expressions[this.expressions.length - 1].getLiteralValueAtPath(path, recursionTracker, origin);
|
|
@@ -11108,15 +11007,8 @@ class SequenceExpression extends NodeBase {
|
|
|
11108
11007
|
}
|
|
11109
11008
|
return false;
|
|
11110
11009
|
}
|
|
11111
|
-
|
|
11112
|
-
return
|
|
11113
|
-
this.expressions[this.expressions.length - 1].hasEffectsWhenAccessedAtPath(path, context));
|
|
11114
|
-
}
|
|
11115
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11116
|
-
return this.expressions[this.expressions.length - 1].hasEffectsWhenAssignedAtPath(path, context);
|
|
11117
|
-
}
|
|
11118
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
11119
|
-
return this.expressions[this.expressions.length - 1].hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
11010
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11011
|
+
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11120
11012
|
}
|
|
11121
11013
|
include(context, includeChildrenRecursively) {
|
|
11122
11014
|
this.included = true;
|
|
@@ -11195,8 +11087,8 @@ class Super extends NodeBase {
|
|
|
11195
11087
|
deoptimizePath(path) {
|
|
11196
11088
|
this.variable.deoptimizePath(path);
|
|
11197
11089
|
}
|
|
11198
|
-
|
|
11199
|
-
this.variable.
|
|
11090
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11091
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11200
11092
|
}
|
|
11201
11093
|
include() {
|
|
11202
11094
|
if (!this.included) {
|
|
@@ -11336,7 +11228,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11336
11228
|
return true;
|
|
11337
11229
|
}
|
|
11338
11230
|
return (this.tag.hasEffects(context) ||
|
|
11339
|
-
this.tag.
|
|
11231
|
+
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
11340
11232
|
}
|
|
11341
11233
|
finally {
|
|
11342
11234
|
if (!this.deoptimized)
|
|
@@ -11354,16 +11246,17 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11354
11246
|
this.tag.include(context, includeChildrenRecursively);
|
|
11355
11247
|
this.quasi.include(context, includeChildrenRecursively);
|
|
11356
11248
|
}
|
|
11357
|
-
this.tag.includeCallArguments(context, this.
|
|
11249
|
+
this.tag.includeCallArguments(context, this.interaction.args);
|
|
11358
11250
|
const returnExpression = this.getReturnExpression();
|
|
11359
11251
|
if (!returnExpression.included) {
|
|
11360
11252
|
returnExpression.include(context, false);
|
|
11361
11253
|
}
|
|
11362
11254
|
}
|
|
11363
11255
|
initialise() {
|
|
11364
|
-
this.
|
|
11256
|
+
this.interaction = {
|
|
11365
11257
|
args: [UNKNOWN_EXPRESSION, ...this.quasi.expressions],
|
|
11366
|
-
|
|
11258
|
+
thisArg: this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
|
|
11259
|
+
type: INTERACTION_CALLED,
|
|
11367
11260
|
withNew: false
|
|
11368
11261
|
};
|
|
11369
11262
|
}
|
|
@@ -11373,9 +11266,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11373
11266
|
}
|
|
11374
11267
|
applyDeoptimizations() {
|
|
11375
11268
|
this.deoptimized = true;
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
this.tag.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
|
|
11269
|
+
if (this.interaction.thisArg) {
|
|
11270
|
+
this.tag.deoptimizeThisOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
11379
11271
|
}
|
|
11380
11272
|
for (const argument of this.quasi.expressions) {
|
|
11381
11273
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -11386,7 +11278,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11386
11278
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
11387
11279
|
if (this.returnExpression === null) {
|
|
11388
11280
|
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
11389
|
-
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.
|
|
11281
|
+
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
11390
11282
|
}
|
|
11391
11283
|
return this.returnExpression;
|
|
11392
11284
|
}
|
|
@@ -11409,7 +11301,7 @@ class TemplateElement extends NodeBase {
|
|
|
11409
11301
|
}
|
|
11410
11302
|
|
|
11411
11303
|
class TemplateLiteral extends NodeBase {
|
|
11412
|
-
|
|
11304
|
+
deoptimizeThisOnInteractionAtPath() { }
|
|
11413
11305
|
getLiteralValueAtPath(path) {
|
|
11414
11306
|
if (path.length > 0 || this.quasis.length !== 1) {
|
|
11415
11307
|
return UnknownValue;
|
|
@@ -11422,12 +11314,12 @@ class TemplateLiteral extends NodeBase {
|
|
|
11422
11314
|
}
|
|
11423
11315
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
11424
11316
|
}
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
if (path.length === 1) {
|
|
11430
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0],
|
|
11317
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11318
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
11319
|
+
return path.length > 1;
|
|
11320
|
+
}
|
|
11321
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
11322
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
11431
11323
|
}
|
|
11432
11324
|
return true;
|
|
11433
11325
|
}
|
|
@@ -11555,16 +11447,15 @@ class ThisExpression extends NodeBase {
|
|
|
11555
11447
|
deoptimizePath(path) {
|
|
11556
11448
|
this.variable.deoptimizePath(path);
|
|
11557
11449
|
}
|
|
11558
|
-
|
|
11559
|
-
this.variable.deoptimizeThisOnEventAtPath(event, path,
|
|
11450
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11560
11451
|
// We rewrite the parameter so that a ThisVariable can detect self-mutations
|
|
11561
|
-
|
|
11452
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction.thisArg === this ? { ...interaction, thisArg: this.variable } : interaction, path, recursionTracker);
|
|
11562
11453
|
}
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
return this.variable.
|
|
11454
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11455
|
+
if (path.length === 0) {
|
|
11456
|
+
return interaction.type !== INTERACTION_ACCESSED;
|
|
11457
|
+
}
|
|
11458
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11568
11459
|
}
|
|
11569
11460
|
include() {
|
|
11570
11461
|
if (!this.included) {
|
|
@@ -11673,13 +11564,10 @@ class UnaryExpression extends NodeBase {
|
|
|
11673
11564
|
return false;
|
|
11674
11565
|
return (this.argument.hasEffects(context) ||
|
|
11675
11566
|
(this.operator === 'delete' &&
|
|
11676
|
-
this.argument.
|
|
11567
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)));
|
|
11677
11568
|
}
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
return path.length > 0;
|
|
11681
|
-
}
|
|
11682
|
-
return path.length > 1;
|
|
11569
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11570
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.operator === 'void' ? 0 : 1);
|
|
11683
11571
|
}
|
|
11684
11572
|
applyDeoptimizations() {
|
|
11685
11573
|
this.deoptimized = true;
|
|
@@ -11703,11 +11591,19 @@ class UpdateExpression extends NodeBase {
|
|
|
11703
11591
|
hasEffects(context) {
|
|
11704
11592
|
if (!this.deoptimized)
|
|
11705
11593
|
this.applyDeoptimizations();
|
|
11706
|
-
return
|
|
11707
|
-
|
|
11594
|
+
return this.argument.hasEffectsAsAssignmentTarget(context, true);
|
|
11595
|
+
}
|
|
11596
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11597
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
11598
|
+
}
|
|
11599
|
+
include(context, includeChildrenRecursively) {
|
|
11600
|
+
if (!this.deoptimized)
|
|
11601
|
+
this.applyDeoptimizations();
|
|
11602
|
+
this.included = true;
|
|
11603
|
+
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
11708
11604
|
}
|
|
11709
|
-
|
|
11710
|
-
|
|
11605
|
+
initialise() {
|
|
11606
|
+
this.argument.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
11711
11607
|
}
|
|
11712
11608
|
render(code, options) {
|
|
11713
11609
|
const { exportNamesByVariable, format, snippets: { _ } } = options;
|
|
@@ -11769,7 +11665,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
11769
11665
|
declarator.deoptimizePath(EMPTY_PATH);
|
|
11770
11666
|
}
|
|
11771
11667
|
}
|
|
11772
|
-
|
|
11668
|
+
hasEffectsOnInteractionAtPath() {
|
|
11773
11669
|
return false;
|
|
11774
11670
|
}
|
|
11775
11671
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
@@ -14438,7 +14334,7 @@ function renderChunk({ code, options, outputPluginDriver, renderChunk, sourcemap
|
|
|
14438
14334
|
|
|
14439
14335
|
function renderNamePattern(pattern, patternName, replacements) {
|
|
14440
14336
|
if (isPathFragment(pattern))
|
|
14441
|
-
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths.`));
|
|
14337
|
+
return error(errFailedValidation(`Invalid pattern "${pattern}" for "${patternName}", patterns can be neither absolute nor relative paths. If you want your files to be stored in a subdirectory, write its name without a leading slash like this: subdirectory/pattern.`));
|
|
14442
14338
|
return pattern.replace(/\[(\w+)\]/g, (_match, type) => {
|
|
14443
14339
|
if (!replacements.hasOwnProperty(type)) {
|
|
14444
14340
|
return error(errFailedValidation(`"[${type}]" is not a valid placeholder in "${patternName}" pattern.`));
|
|
@@ -23434,6 +23330,16 @@ function sanitizeFileName(name) {
|
|
|
23434
23330
|
return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_REGEX, '_');
|
|
23435
23331
|
}
|
|
23436
23332
|
|
|
23333
|
+
function isValidUrl(url) {
|
|
23334
|
+
try {
|
|
23335
|
+
new URL(url);
|
|
23336
|
+
}
|
|
23337
|
+
catch (_) {
|
|
23338
|
+
return false;
|
|
23339
|
+
}
|
|
23340
|
+
return true;
|
|
23341
|
+
}
|
|
23342
|
+
|
|
23437
23343
|
function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
23438
23344
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
23439
23345
|
// These are options that may trigger special warnings or behaviour later
|
|
@@ -23487,6 +23393,7 @@ function normalizeOutputOptions(config, inputOptions, unsetInputOptions) {
|
|
|
23487
23393
|
? id => id
|
|
23488
23394
|
: sanitizeFileName,
|
|
23489
23395
|
sourcemap: config.sourcemap || false,
|
|
23396
|
+
sourcemapBaseUrl: getSourcemapBaseUrl(config),
|
|
23490
23397
|
sourcemapExcludeSources: config.sourcemapExcludeSources || false,
|
|
23491
23398
|
sourcemapFile: config.sourcemapFile,
|
|
23492
23399
|
sourcemapPathTransform: config.sourcemapPathTransform,
|
|
@@ -23712,6 +23619,15 @@ const getNamespaceToStringTag = (config, generatedCode, inputOptions) => {
|
|
|
23712
23619
|
}
|
|
23713
23620
|
return generatedCode.symbols || false;
|
|
23714
23621
|
};
|
|
23622
|
+
const getSourcemapBaseUrl = (config) => {
|
|
23623
|
+
const { sourcemapBaseUrl } = config;
|
|
23624
|
+
if (sourcemapBaseUrl) {
|
|
23625
|
+
if (isValidUrl(sourcemapBaseUrl)) {
|
|
23626
|
+
return sourcemapBaseUrl;
|
|
23627
|
+
}
|
|
23628
|
+
return error(errInvalidOption('output.sourcemapBaseUrl', 'outputsourcemapbaseurl', `must be a valid URL, received ${JSON.stringify(sourcemapBaseUrl)}`));
|
|
23629
|
+
}
|
|
23630
|
+
};
|
|
23715
23631
|
|
|
23716
23632
|
function rollup(rawInputOptions) {
|
|
23717
23633
|
return rollupInternal(rawInputOptions, null);
|
|
@@ -23874,7 +23790,11 @@ async function writeOutputFile(outputFile, outputOptions) {
|
|
|
23874
23790
|
url = outputFile.map.toUrl();
|
|
23875
23791
|
}
|
|
23876
23792
|
else {
|
|
23877
|
-
|
|
23793
|
+
const { sourcemapBaseUrl } = outputOptions;
|
|
23794
|
+
const sourcemapFileName = `${basename(outputFile.fileName)}.map`;
|
|
23795
|
+
url = sourcemapBaseUrl
|
|
23796
|
+
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
23797
|
+
: sourcemapFileName;
|
|
23878
23798
|
writeSourceMapPromise = promises.writeFile(`${fileName}.map`, outputFile.map.toString());
|
|
23879
23799
|
}
|
|
23880
23800
|
if (outputOptions.sourcemap !== 'hidden') {
|