rollup 2.75.4 → 2.75.7
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 +42 -0
- package/dist/bin/rollup +2 -2
- package/dist/es/rollup.browser.js +3 -3
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/rollup.js +1406 -1582
- package/dist/es/shared/watch.js +5 -5
- package/dist/loadConfigFile.js +2 -2
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.browser.js.map +1 -1
- package/dist/rollup.js +2 -2
- package/dist/shared/index.js +4 -4
- package/dist/shared/loadConfigFile.js +6 -7
- package/dist/shared/mergeOptions.js +2 -2
- package/dist/shared/rollup.js +1406 -1582
- package/dist/shared/watch-cli.js +2 -2
- package/dist/shared/watch.js +2 -2
- package/package.json +14 -14
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v2.75.
|
|
4
|
-
|
|
3
|
+
Rollup.js v2.75.7
|
|
4
|
+
Mon, 20 Jun 2022 07:24:02 GMT - commit 057171c2d3bc2092b7f543fc05ead01f12595f12
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -27,7 +27,7 @@ function _interopNamespaceDefault(e) {
|
|
|
27
27
|
return n;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
var version$1 = "2.75.
|
|
30
|
+
var version$1 = "2.75.7";
|
|
31
31
|
|
|
32
32
|
function ensureArray$1(items) {
|
|
33
33
|
if (Array.isArray(items)) {
|
|
@@ -2227,10 +2227,9 @@ class ExpressionEntity {
|
|
|
2227
2227
|
constructor() {
|
|
2228
2228
|
this.included = false;
|
|
2229
2229
|
}
|
|
2230
|
-
deoptimizeCallParameters() { }
|
|
2231
2230
|
deoptimizePath(_path) { }
|
|
2232
|
-
|
|
2233
|
-
|
|
2231
|
+
deoptimizeThisOnInteractionAtPath({ thisArg }, _path, _recursionTracker) {
|
|
2232
|
+
thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
2234
2233
|
}
|
|
2235
2234
|
/**
|
|
2236
2235
|
* If possible it returns a stringifyable literal value for this node that can be used
|
|
@@ -2240,16 +2239,10 @@ class ExpressionEntity {
|
|
|
2240
2239
|
getLiteralValueAtPath(_path, _recursionTracker, _origin) {
|
|
2241
2240
|
return UnknownValue;
|
|
2242
2241
|
}
|
|
2243
|
-
getReturnExpressionWhenCalledAtPath(_path,
|
|
2242
|
+
getReturnExpressionWhenCalledAtPath(_path, _interaction, _recursionTracker, _origin) {
|
|
2244
2243
|
return UNKNOWN_EXPRESSION;
|
|
2245
2244
|
}
|
|
2246
|
-
|
|
2247
|
-
return true;
|
|
2248
|
-
}
|
|
2249
|
-
hasEffectsWhenAssignedAtPath(_path, _context) {
|
|
2250
|
-
return true;
|
|
2251
|
-
}
|
|
2252
|
-
hasEffectsWhenCalledAtPath(_path, _callOptions, _context) {
|
|
2245
|
+
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
2253
2246
|
return true;
|
|
2254
2247
|
}
|
|
2255
2248
|
include(_context, _includeChildrenRecursively, _options) {
|
|
@@ -2267,6 +2260,30 @@ class ExpressionEntity {
|
|
|
2267
2260
|
const UNKNOWN_EXPRESSION = new (class UnknownExpression extends ExpressionEntity {
|
|
2268
2261
|
})();
|
|
2269
2262
|
|
|
2263
|
+
const INTERACTION_ACCESSED = 0;
|
|
2264
|
+
const INTERACTION_ASSIGNED = 1;
|
|
2265
|
+
const INTERACTION_CALLED = 2;
|
|
2266
|
+
const NODE_INTERACTION_UNKNOWN_ACCESS = {
|
|
2267
|
+
thisArg: null,
|
|
2268
|
+
type: INTERACTION_ACCESSED
|
|
2269
|
+
};
|
|
2270
|
+
const UNKNOWN_ARG = [UNKNOWN_EXPRESSION];
|
|
2271
|
+
const NODE_INTERACTION_UNKNOWN_ASSIGNMENT = {
|
|
2272
|
+
args: UNKNOWN_ARG,
|
|
2273
|
+
thisArg: null,
|
|
2274
|
+
type: INTERACTION_ASSIGNED
|
|
2275
|
+
};
|
|
2276
|
+
const NO_ARGS = [];
|
|
2277
|
+
// While this is technically a call without arguments, we can compare against
|
|
2278
|
+
// this reference in places where precise values or thisArg would make a
|
|
2279
|
+
// difference
|
|
2280
|
+
const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
2281
|
+
args: NO_ARGS,
|
|
2282
|
+
thisArg: null,
|
|
2283
|
+
type: INTERACTION_CALLED,
|
|
2284
|
+
withNew: false
|
|
2285
|
+
};
|
|
2286
|
+
|
|
2270
2287
|
class Variable extends ExpressionEntity {
|
|
2271
2288
|
constructor(name) {
|
|
2272
2289
|
super();
|
|
@@ -2291,8 +2308,8 @@ class Variable extends ExpressionEntity {
|
|
|
2291
2308
|
const name = this.renderName || this.name;
|
|
2292
2309
|
return this.renderBaseName ? `${this.renderBaseName}${getPropertyAccess(name)}` : name;
|
|
2293
2310
|
}
|
|
2294
|
-
|
|
2295
|
-
return path.length > 0;
|
|
2311
|
+
hasEffectsOnInteractionAtPath(path, { type }, _context) {
|
|
2312
|
+
return type !== INTERACTION_ACCESSED || path.length > 0;
|
|
2296
2313
|
}
|
|
2297
2314
|
/**
|
|
2298
2315
|
* Marks this variable as being part of the bundle, which is usually the case when one of
|
|
@@ -2323,8 +2340,8 @@ class ExternalVariable extends Variable {
|
|
|
2323
2340
|
this.module.suggestName(identifier.name);
|
|
2324
2341
|
}
|
|
2325
2342
|
}
|
|
2326
|
-
|
|
2327
|
-
return path.length > (this.isNamespace ? 1 : 0);
|
|
2343
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
2344
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
2328
2345
|
}
|
|
2329
2346
|
include() {
|
|
2330
2347
|
if (!this.included) {
|
|
@@ -4711,8 +4728,6 @@ function createHasEffectsContext() {
|
|
|
4711
4728
|
};
|
|
4712
4729
|
}
|
|
4713
4730
|
|
|
4714
|
-
const NO_ARGS = [];
|
|
4715
|
-
|
|
4716
4731
|
function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions = null) {
|
|
4717
4732
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
4718
4733
|
}
|
|
@@ -4734,12 +4749,12 @@ const UNKNOWN_LITERAL_BOOLEAN = new (class UnknownBoolean extends ExpressionEnti
|
|
|
4734
4749
|
}
|
|
4735
4750
|
return UNKNOWN_EXPRESSION;
|
|
4736
4751
|
}
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
if (path.length === 1) {
|
|
4742
|
-
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0],
|
|
4752
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4753
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4754
|
+
return path.length > 1;
|
|
4755
|
+
}
|
|
4756
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4757
|
+
return hasMemberEffectWhenCalled(literalBooleanMembers, path[0], interaction, context);
|
|
4743
4758
|
}
|
|
4744
4759
|
return true;
|
|
4745
4760
|
}
|
|
@@ -4757,12 +4772,12 @@ const UNKNOWN_LITERAL_NUMBER = new (class UnknownNumber extends ExpressionEntity
|
|
|
4757
4772
|
}
|
|
4758
4773
|
return UNKNOWN_EXPRESSION;
|
|
4759
4774
|
}
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
if (path.length === 1) {
|
|
4765
|
-
return hasMemberEffectWhenCalled(literalNumberMembers, path[0],
|
|
4775
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4776
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4777
|
+
return path.length > 1;
|
|
4778
|
+
}
|
|
4779
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4780
|
+
return hasMemberEffectWhenCalled(literalNumberMembers, path[0], interaction, context);
|
|
4766
4781
|
}
|
|
4767
4782
|
return true;
|
|
4768
4783
|
}
|
|
@@ -4780,12 +4795,12 @@ const UNKNOWN_LITERAL_STRING = new (class UnknownString extends ExpressionEntity
|
|
|
4780
4795
|
}
|
|
4781
4796
|
return UNKNOWN_EXPRESSION;
|
|
4782
4797
|
}
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
if (path.length === 1) {
|
|
4788
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0],
|
|
4798
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
4799
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
4800
|
+
return path.length > 1;
|
|
4801
|
+
}
|
|
4802
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
4803
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
4789
4804
|
}
|
|
4790
4805
|
return true;
|
|
4791
4806
|
}
|
|
@@ -4798,17 +4813,13 @@ const returnsString = {
|
|
|
4798
4813
|
};
|
|
4799
4814
|
const stringReplace = {
|
|
4800
4815
|
value: {
|
|
4801
|
-
hasEffectsWhenCalled(
|
|
4802
|
-
const arg1 =
|
|
4803
|
-
return (
|
|
4816
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
4817
|
+
const arg1 = args[1];
|
|
4818
|
+
return (args.length < 2 ||
|
|
4804
4819
|
(typeof arg1.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, {
|
|
4805
4820
|
deoptimizeCache() { }
|
|
4806
4821
|
}) === 'symbol' &&
|
|
4807
|
-
arg1.
|
|
4808
|
-
args: NO_ARGS,
|
|
4809
|
-
thisParam: null,
|
|
4810
|
-
withNew: false
|
|
4811
|
-
}, context)));
|
|
4822
|
+
arg1.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)));
|
|
4812
4823
|
},
|
|
4813
4824
|
returns: UNKNOWN_LITERAL_STRING
|
|
4814
4825
|
}
|
|
@@ -4892,12 +4903,12 @@ function getLiteralMembersForValue(value) {
|
|
|
4892
4903
|
}
|
|
4893
4904
|
return Object.create(null);
|
|
4894
4905
|
}
|
|
4895
|
-
function hasMemberEffectWhenCalled(members, memberName,
|
|
4906
|
+
function hasMemberEffectWhenCalled(members, memberName, interaction, context) {
|
|
4896
4907
|
var _a, _b;
|
|
4897
4908
|
if (typeof memberName !== 'string' || !members[memberName]) {
|
|
4898
4909
|
return true;
|
|
4899
4910
|
}
|
|
4900
|
-
return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a,
|
|
4911
|
+
return ((_b = (_a = members[memberName]).hasEffectsWhenCalled) === null || _b === void 0 ? void 0 : _b.call(_a, interaction, context)) || false;
|
|
4901
4912
|
}
|
|
4902
4913
|
function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
4903
4914
|
if (typeof memberName !== 'string' || !members[memberName])
|
|
@@ -5336,10 +5347,12 @@ const INCLUDE_PARAMETERS = 'variables';
|
|
|
5336
5347
|
class NodeBase extends ExpressionEntity {
|
|
5337
5348
|
constructor(esTreeNode, parent, parentScope) {
|
|
5338
5349
|
super();
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5350
|
+
/**
|
|
5351
|
+
* Nodes can apply custom deoptimizations once they become part of the
|
|
5352
|
+
* executed code. To do this, they must initialize this as false, implement
|
|
5353
|
+
* applyDeoptimizations and call this from include and hasEffects if they have
|
|
5354
|
+
* custom handlers
|
|
5355
|
+
*/
|
|
5343
5356
|
this.deoptimized = false;
|
|
5344
5357
|
this.esTreeNode = esTreeNode;
|
|
5345
5358
|
this.keys = keys[esTreeNode.type] || getAndCreateKeys(esTreeNode);
|
|
@@ -5395,6 +5408,10 @@ class NodeBase extends ExpressionEntity {
|
|
|
5395
5408
|
}
|
|
5396
5409
|
return false;
|
|
5397
5410
|
}
|
|
5411
|
+
hasEffectsAsAssignmentTarget(context, _checkAccess) {
|
|
5412
|
+
return (this.hasEffects(context) ||
|
|
5413
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
5414
|
+
}
|
|
5398
5415
|
include(context, includeChildrenRecursively, _options) {
|
|
5399
5416
|
if (!this.deoptimized)
|
|
5400
5417
|
this.applyDeoptimizations();
|
|
@@ -5413,6 +5430,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5413
5430
|
}
|
|
5414
5431
|
}
|
|
5415
5432
|
}
|
|
5433
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, _deoptimizeAccess) {
|
|
5434
|
+
this.include(context, includeChildrenRecursively);
|
|
5435
|
+
}
|
|
5416
5436
|
/**
|
|
5417
5437
|
* Override to perform special initialisation steps after the scope is initialised
|
|
5418
5438
|
*/
|
|
@@ -5467,6 +5487,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5467
5487
|
}
|
|
5468
5488
|
}
|
|
5469
5489
|
}
|
|
5490
|
+
setAssignedValue(value) {
|
|
5491
|
+
this.assignmentInteraction = { args: [value], thisArg: null, type: INTERACTION_ASSIGNED };
|
|
5492
|
+
}
|
|
5470
5493
|
shouldBeIncluded(context) {
|
|
5471
5494
|
return this.included || (!context.brokenFlow && this.hasEffects(createHasEffectsContext()));
|
|
5472
5495
|
}
|
|
@@ -5495,9 +5518,9 @@ class NodeBase extends ExpressionEntity {
|
|
|
5495
5518
|
}
|
|
5496
5519
|
|
|
5497
5520
|
class SpreadElement extends NodeBase {
|
|
5498
|
-
|
|
5521
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5499
5522
|
if (path.length > 0) {
|
|
5500
|
-
this.argument.
|
|
5523
|
+
this.argument.deoptimizeThisOnInteractionAtPath(interaction, [UnknownKey, ...path], recursionTracker);
|
|
5501
5524
|
}
|
|
5502
5525
|
}
|
|
5503
5526
|
hasEffects(context) {
|
|
@@ -5508,7 +5531,7 @@ class SpreadElement extends NodeBase {
|
|
|
5508
5531
|
return (this.argument.hasEffects(context) ||
|
|
5509
5532
|
(propertyReadSideEffects &&
|
|
5510
5533
|
(propertyReadSideEffects === 'always' ||
|
|
5511
|
-
this.argument.
|
|
5534
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
5512
5535
|
}
|
|
5513
5536
|
applyDeoptimizations() {
|
|
5514
5537
|
this.deoptimized = true;
|
|
@@ -5519,53 +5542,43 @@ class SpreadElement extends NodeBase {
|
|
|
5519
5542
|
}
|
|
5520
5543
|
}
|
|
5521
5544
|
|
|
5522
|
-
const EVENT_ACCESSED = 0;
|
|
5523
|
-
const EVENT_ASSIGNED = 1;
|
|
5524
|
-
const EVENT_CALLED = 2;
|
|
5525
|
-
|
|
5526
5545
|
class Method extends ExpressionEntity {
|
|
5527
5546
|
constructor(description) {
|
|
5528
5547
|
super();
|
|
5529
5548
|
this.description = description;
|
|
5530
5549
|
}
|
|
5531
|
-
|
|
5532
|
-
if (
|
|
5533
|
-
|
|
5550
|
+
deoptimizeThisOnInteractionAtPath({ type, thisArg }, path) {
|
|
5551
|
+
if (type === INTERACTION_CALLED && path.length === 0 && this.description.mutatesSelfAsArray) {
|
|
5552
|
+
thisArg.deoptimizePath(UNKNOWN_INTEGER_PATH);
|
|
5534
5553
|
}
|
|
5535
5554
|
}
|
|
5536
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
5555
|
+
getReturnExpressionWhenCalledAtPath(path, { thisArg }) {
|
|
5537
5556
|
if (path.length > 0) {
|
|
5538
5557
|
return UNKNOWN_EXPRESSION;
|
|
5539
5558
|
}
|
|
5540
5559
|
return (this.description.returnsPrimitive ||
|
|
5541
5560
|
(this.description.returns === 'self'
|
|
5542
|
-
?
|
|
5561
|
+
? thisArg || UNKNOWN_EXPRESSION
|
|
5543
5562
|
: this.description.returns()));
|
|
5544
5563
|
}
|
|
5545
|
-
|
|
5546
|
-
return path.length > 1;
|
|
5547
|
-
}
|
|
5548
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
5549
|
-
return path.length > 0;
|
|
5550
|
-
}
|
|
5551
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
5564
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5552
5565
|
var _a, _b;
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
((_a = callOptions.thisParam) === null || _a === void 0 ? void 0 : _a.hasEffectsWhenAssignedAtPath(UNKNOWN_INTEGER_PATH, context)))) {
|
|
5566
|
+
const { type } = interaction;
|
|
5567
|
+
if (path.length > (type === INTERACTION_ACCESSED ? 1 : 0)) {
|
|
5556
5568
|
return true;
|
|
5557
5569
|
}
|
|
5558
|
-
if (
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
for (const argIndex of this.description.callsArgs) {
|
|
5562
|
-
if ((_b = callOptions.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsWhenCalledAtPath(EMPTY_PATH, {
|
|
5563
|
-
args: NO_ARGS,
|
|
5564
|
-
thisParam: null,
|
|
5565
|
-
withNew: false
|
|
5566
|
-
}, context)) {
|
|
5570
|
+
if (type === INTERACTION_CALLED) {
|
|
5571
|
+
if (this.description.mutatesSelfAsArray === true &&
|
|
5572
|
+
((_a = interaction.thisArg) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(UNKNOWN_INTEGER_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context))) {
|
|
5567
5573
|
return true;
|
|
5568
5574
|
}
|
|
5575
|
+
if (this.description.callsArgs) {
|
|
5576
|
+
for (const argIndex of this.description.callsArgs) {
|
|
5577
|
+
if ((_b = interaction.args[argIndex]) === null || _b === void 0 ? void 0 : _b.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context)) {
|
|
5578
|
+
return true;
|
|
5579
|
+
}
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5569
5582
|
}
|
|
5570
5583
|
return false;
|
|
5571
5584
|
}
|
|
@@ -5707,24 +5720,24 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5707
5720
|
}
|
|
5708
5721
|
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path.length === 1 ? [...path, UnknownKey] : path);
|
|
5709
5722
|
}
|
|
5710
|
-
|
|
5723
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5711
5724
|
var _a;
|
|
5712
5725
|
const [key, ...subPath] = path;
|
|
5713
5726
|
if (this.hasLostTrack ||
|
|
5714
5727
|
// single paths that are deoptimized will not become getters or setters
|
|
5715
|
-
((
|
|
5728
|
+
((interaction.type === INTERACTION_CALLED || path.length > 1) &&
|
|
5716
5729
|
(this.hasUnknownDeoptimizedProperty ||
|
|
5717
5730
|
(typeof key === 'string' && this.deoptimizedPaths[key])))) {
|
|
5718
|
-
|
|
5731
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
5719
5732
|
return;
|
|
5720
5733
|
}
|
|
5721
|
-
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] =
|
|
5734
|
+
const [propertiesForExactMatchByKey, relevantPropertiesByKey, relevantUnmatchableProperties] = interaction.type === INTERACTION_CALLED || path.length > 1
|
|
5722
5735
|
? [
|
|
5723
5736
|
this.propertiesAndGettersByKey,
|
|
5724
5737
|
this.propertiesAndGettersByKey,
|
|
5725
5738
|
this.unmatchablePropertiesAndGetters
|
|
5726
5739
|
]
|
|
5727
|
-
:
|
|
5740
|
+
: interaction.type === INTERACTION_ACCESSED
|
|
5728
5741
|
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
5729
5742
|
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
5730
5743
|
if (typeof key === 'string') {
|
|
@@ -5732,20 +5745,20 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5732
5745
|
const properties = relevantPropertiesByKey[key];
|
|
5733
5746
|
if (properties) {
|
|
5734
5747
|
for (const property of properties) {
|
|
5735
|
-
property.
|
|
5748
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5736
5749
|
}
|
|
5737
5750
|
}
|
|
5738
5751
|
if (!this.immutable) {
|
|
5739
|
-
this.thisParametersToBeDeoptimized.add(
|
|
5752
|
+
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5740
5753
|
}
|
|
5741
5754
|
return;
|
|
5742
5755
|
}
|
|
5743
5756
|
for (const property of relevantUnmatchableProperties) {
|
|
5744
|
-
property.
|
|
5757
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5745
5758
|
}
|
|
5746
5759
|
if (INTEGER_REG_EXP.test(key)) {
|
|
5747
5760
|
for (const property of this.unknownIntegerProps) {
|
|
5748
|
-
property.
|
|
5761
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5749
5762
|
}
|
|
5750
5763
|
}
|
|
5751
5764
|
}
|
|
@@ -5754,17 +5767,17 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5754
5767
|
relevantUnmatchableProperties
|
|
5755
5768
|
])) {
|
|
5756
5769
|
for (const property of properties) {
|
|
5757
|
-
property.
|
|
5770
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5758
5771
|
}
|
|
5759
5772
|
}
|
|
5760
5773
|
for (const property of this.unknownIntegerProps) {
|
|
5761
|
-
property.
|
|
5774
|
+
property.deoptimizeThisOnInteractionAtPath(interaction, subPath, recursionTracker);
|
|
5762
5775
|
}
|
|
5763
5776
|
}
|
|
5764
5777
|
if (!this.immutable) {
|
|
5765
|
-
this.thisParametersToBeDeoptimized.add(
|
|
5778
|
+
this.thisParametersToBeDeoptimized.add(interaction.thisArg);
|
|
5766
5779
|
}
|
|
5767
|
-
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.
|
|
5780
|
+
(_a = this.prototypeExpression) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
5768
5781
|
}
|
|
5769
5782
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
5770
5783
|
if (path.length === 0) {
|
|
@@ -5783,79 +5796,29 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5783
5796
|
}
|
|
5784
5797
|
return UnknownValue;
|
|
5785
5798
|
}
|
|
5786
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
5799
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
5787
5800
|
if (path.length === 0) {
|
|
5788
5801
|
return UNKNOWN_EXPRESSION;
|
|
5789
5802
|
}
|
|
5790
|
-
const key = path
|
|
5803
|
+
const [key, ...subPath] = path;
|
|
5791
5804
|
const expressionAtPath = this.getMemberExpressionAndTrackDeopt(key, origin);
|
|
5792
5805
|
if (expressionAtPath) {
|
|
5793
|
-
return expressionAtPath.getReturnExpressionWhenCalledAtPath(
|
|
5806
|
+
return expressionAtPath.getReturnExpressionWhenCalledAtPath(subPath, interaction, recursionTracker, origin);
|
|
5794
5807
|
}
|
|
5795
5808
|
if (this.prototypeExpression) {
|
|
5796
|
-
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path,
|
|
5809
|
+
return this.prototypeExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
5797
5810
|
}
|
|
5798
5811
|
return UNKNOWN_EXPRESSION;
|
|
5799
5812
|
}
|
|
5800
|
-
|
|
5801
|
-
const [key, ...subPath] = path;
|
|
5802
|
-
if (path.length > 1) {
|
|
5803
|
-
if (typeof key !== 'string') {
|
|
5804
|
-
return true;
|
|
5805
|
-
}
|
|
5806
|
-
const expressionAtPath = this.getMemberExpression(key);
|
|
5807
|
-
if (expressionAtPath) {
|
|
5808
|
-
return expressionAtPath.hasEffectsWhenAccessedAtPath(subPath, context);
|
|
5809
|
-
}
|
|
5810
|
-
if (this.prototypeExpression) {
|
|
5811
|
-
return this.prototypeExpression.hasEffectsWhenAccessedAtPath(path, context);
|
|
5812
|
-
}
|
|
5813
|
-
return true;
|
|
5814
|
-
}
|
|
5815
|
-
if (this.hasLostTrack)
|
|
5816
|
-
return true;
|
|
5817
|
-
if (typeof key === 'string') {
|
|
5818
|
-
if (this.propertiesAndGettersByKey[key]) {
|
|
5819
|
-
const getters = this.gettersByKey[key];
|
|
5820
|
-
if (getters) {
|
|
5821
|
-
for (const getter of getters) {
|
|
5822
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
5823
|
-
return true;
|
|
5824
|
-
}
|
|
5825
|
-
}
|
|
5826
|
-
return false;
|
|
5827
|
-
}
|
|
5828
|
-
for (const getter of this.unmatchableGetters) {
|
|
5829
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context)) {
|
|
5830
|
-
return true;
|
|
5831
|
-
}
|
|
5832
|
-
}
|
|
5833
|
-
}
|
|
5834
|
-
else {
|
|
5835
|
-
for (const getters of Object.values(this.gettersByKey).concat([this.unmatchableGetters])) {
|
|
5836
|
-
for (const getter of getters) {
|
|
5837
|
-
if (getter.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
5838
|
-
return true;
|
|
5839
|
-
}
|
|
5840
|
-
}
|
|
5841
|
-
}
|
|
5842
|
-
if (this.prototypeExpression) {
|
|
5843
|
-
return this.prototypeExpression.hasEffectsWhenAccessedAtPath(path, context);
|
|
5844
|
-
}
|
|
5845
|
-
return false;
|
|
5846
|
-
}
|
|
5847
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
5813
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5848
5814
|
const [key, ...subPath] = path;
|
|
5849
|
-
if (
|
|
5850
|
-
if (typeof key !== 'string') {
|
|
5851
|
-
return true;
|
|
5852
|
-
}
|
|
5815
|
+
if (subPath.length || interaction.type === INTERACTION_CALLED) {
|
|
5853
5816
|
const expressionAtPath = this.getMemberExpression(key);
|
|
5854
5817
|
if (expressionAtPath) {
|
|
5855
|
-
return expressionAtPath.
|
|
5818
|
+
return expressionAtPath.hasEffectsOnInteractionAtPath(subPath, interaction, context);
|
|
5856
5819
|
}
|
|
5857
5820
|
if (this.prototypeExpression) {
|
|
5858
|
-
return this.prototypeExpression.
|
|
5821
|
+
return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5859
5822
|
}
|
|
5860
5823
|
return true;
|
|
5861
5824
|
}
|
|
@@ -5863,47 +5826,39 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
5863
5826
|
return false;
|
|
5864
5827
|
if (this.hasLostTrack)
|
|
5865
5828
|
return true;
|
|
5829
|
+
const [propertiesAndAccessorsByKey, accessorsByKey, unmatchableAccessors] = interaction.type === INTERACTION_ACCESSED
|
|
5830
|
+
? [this.propertiesAndGettersByKey, this.gettersByKey, this.unmatchableGetters]
|
|
5831
|
+
: [this.propertiesAndSettersByKey, this.settersByKey, this.unmatchableSetters];
|
|
5866
5832
|
if (typeof key === 'string') {
|
|
5867
|
-
if (
|
|
5868
|
-
const
|
|
5869
|
-
if (
|
|
5870
|
-
for (const
|
|
5871
|
-
if (
|
|
5833
|
+
if (propertiesAndAccessorsByKey[key]) {
|
|
5834
|
+
const accessors = accessorsByKey[key];
|
|
5835
|
+
if (accessors) {
|
|
5836
|
+
for (const accessor of accessors) {
|
|
5837
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
5872
5838
|
return true;
|
|
5873
5839
|
}
|
|
5874
5840
|
}
|
|
5875
5841
|
return false;
|
|
5876
5842
|
}
|
|
5877
|
-
for (const
|
|
5878
|
-
if (
|
|
5843
|
+
for (const accessor of unmatchableAccessors) {
|
|
5844
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context)) {
|
|
5879
5845
|
return true;
|
|
5880
5846
|
}
|
|
5881
5847
|
}
|
|
5882
5848
|
}
|
|
5883
5849
|
else {
|
|
5884
|
-
for (const
|
|
5885
|
-
for (const
|
|
5886
|
-
if (
|
|
5850
|
+
for (const accessors of Object.values(accessorsByKey).concat([unmatchableAccessors])) {
|
|
5851
|
+
for (const accessor of accessors) {
|
|
5852
|
+
if (accessor.hasEffectsOnInteractionAtPath(subPath, interaction, context))
|
|
5887
5853
|
return true;
|
|
5888
5854
|
}
|
|
5889
5855
|
}
|
|
5890
5856
|
}
|
|
5891
5857
|
if (this.prototypeExpression) {
|
|
5892
|
-
return this.prototypeExpression.
|
|
5858
|
+
return this.prototypeExpression.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5893
5859
|
}
|
|
5894
5860
|
return false;
|
|
5895
5861
|
}
|
|
5896
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
5897
|
-
const key = path[0];
|
|
5898
|
-
const expressionAtPath = this.getMemberExpression(key);
|
|
5899
|
-
if (expressionAtPath) {
|
|
5900
|
-
return expressionAtPath.hasEffectsWhenCalledAtPath(path.slice(1), callOptions, context);
|
|
5901
|
-
}
|
|
5902
|
-
if (this.prototypeExpression) {
|
|
5903
|
-
return this.prototypeExpression.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
5904
|
-
}
|
|
5905
|
-
return true;
|
|
5906
|
-
}
|
|
5907
5862
|
buildPropertyMaps(properties) {
|
|
5908
5863
|
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
5909
5864
|
const unmatchablePropertiesAndSetters = [];
|
|
@@ -6009,9 +5964,9 @@ const isInteger = (prop) => typeof prop === 'string' && /^\d+$/.test(prop);
|
|
|
6009
5964
|
// properties as we do not expect new builtin properties to be numbers, this
|
|
6010
5965
|
// will improve tree-shaking for out-of-bounds array properties
|
|
6011
5966
|
const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression extends ExpressionEntity {
|
|
6012
|
-
|
|
6013
|
-
if (
|
|
6014
|
-
|
|
5967
|
+
deoptimizeThisOnInteractionAtPath({ type, thisArg }, path) {
|
|
5968
|
+
if (type === INTERACTION_CALLED && path.length === 1 && !isInteger(path[0])) {
|
|
5969
|
+
thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
6015
5970
|
}
|
|
6016
5971
|
}
|
|
6017
5972
|
getLiteralValueAtPath(path) {
|
|
@@ -6020,11 +5975,8 @@ const OBJECT_PROTOTYPE_FALLBACK = new (class ObjectPrototypeFallbackExpression e
|
|
|
6020
5975
|
// "undefined"
|
|
6021
5976
|
return path.length === 1 && isInteger(path[0]) ? undefined : UnknownValue;
|
|
6022
5977
|
}
|
|
6023
|
-
|
|
6024
|
-
return path.length > 1;
|
|
6025
|
-
}
|
|
6026
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
6027
|
-
return path.length > 1;
|
|
5978
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
5979
|
+
return path.length > 1 || type === INTERACTION_CALLED;
|
|
6028
5980
|
}
|
|
6029
5981
|
})();
|
|
6030
5982
|
const OBJECT_PROTOTYPE = new ObjectEntity({
|
|
@@ -6146,8 +6098,8 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
6146
6098
|
flat: METHOD_DEOPTS_SELF_RETURNS_NEW_ARRAY,
|
|
6147
6099
|
flatMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_NEW_ARRAY,
|
|
6148
6100
|
forEach: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
|
|
6149
|
-
|
|
6150
|
-
|
|
6101
|
+
group: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
|
|
6102
|
+
groupToMap: METHOD_CALLS_ARG_DEOPTS_SELF_RETURNS_UNKNOWN,
|
|
6151
6103
|
includes: METHOD_RETURNS_BOOLEAN,
|
|
6152
6104
|
indexOf: METHOD_RETURNS_NUMBER,
|
|
6153
6105
|
join: METHOD_RETURNS_STRING,
|
|
@@ -6178,23 +6130,17 @@ class ArrayExpression extends NodeBase {
|
|
|
6178
6130
|
deoptimizePath(path) {
|
|
6179
6131
|
this.getObjectEntity().deoptimizePath(path);
|
|
6180
6132
|
}
|
|
6181
|
-
|
|
6182
|
-
this.getObjectEntity().
|
|
6133
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6134
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
6183
6135
|
}
|
|
6184
6136
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6185
6137
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6186
6138
|
}
|
|
6187
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
6188
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
6139
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6140
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6189
6141
|
}
|
|
6190
|
-
|
|
6191
|
-
return this.getObjectEntity().
|
|
6192
|
-
}
|
|
6193
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6194
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
6195
|
-
}
|
|
6196
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
6197
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
6142
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6143
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
6198
6144
|
}
|
|
6199
6145
|
applyDeoptimizations() {
|
|
6200
6146
|
this.deoptimized = true;
|
|
@@ -6204,13 +6150,8 @@ class ArrayExpression extends NodeBase {
|
|
|
6204
6150
|
if (element) {
|
|
6205
6151
|
if (hasSpread || element instanceof SpreadElement) {
|
|
6206
6152
|
hasSpread = true;
|
|
6207
|
-
// This also deoptimizes parameter defaults
|
|
6208
6153
|
element.deoptimizePath(UNKNOWN_PATH);
|
|
6209
6154
|
}
|
|
6210
|
-
else {
|
|
6211
|
-
// We do not track parameter defaults in arrays
|
|
6212
|
-
element.deoptimizeCallParameters();
|
|
6213
|
-
}
|
|
6214
6155
|
}
|
|
6215
6156
|
}
|
|
6216
6157
|
this.context.requestTreeshakingPass();
|
|
@@ -6264,9 +6205,9 @@ class ArrayPattern extends NodeBase {
|
|
|
6264
6205
|
}
|
|
6265
6206
|
}
|
|
6266
6207
|
// Patterns are only checked at the emtpy path at the moment
|
|
6267
|
-
|
|
6208
|
+
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
6268
6209
|
for (const element of this.elements) {
|
|
6269
|
-
if (element === null || element === void 0 ? void 0 : element.
|
|
6210
|
+
if (element === null || element === void 0 ? void 0 : element.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
6270
6211
|
return true;
|
|
6271
6212
|
}
|
|
6272
6213
|
return false;
|
|
@@ -6304,10 +6245,6 @@ class LocalVariable extends Variable {
|
|
|
6304
6245
|
this.additionalInitializers = null;
|
|
6305
6246
|
}
|
|
6306
6247
|
}
|
|
6307
|
-
deoptimizeCallParameters() {
|
|
6308
|
-
var _a;
|
|
6309
|
-
(_a = this.init) === null || _a === void 0 ? void 0 : _a.deoptimizeCallParameters();
|
|
6310
|
-
}
|
|
6311
6248
|
deoptimizePath(path) {
|
|
6312
6249
|
var _a, _b;
|
|
6313
6250
|
if (this.isReassigned ||
|
|
@@ -6329,11 +6266,11 @@ class LocalVariable extends Variable {
|
|
|
6329
6266
|
(_b = this.init) === null || _b === void 0 ? void 0 : _b.deoptimizePath(path);
|
|
6330
6267
|
}
|
|
6331
6268
|
}
|
|
6332
|
-
|
|
6269
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6333
6270
|
if (this.isReassigned || !this.init) {
|
|
6334
|
-
return
|
|
6271
|
+
return interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
6335
6272
|
}
|
|
6336
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.
|
|
6273
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
6337
6274
|
}
|
|
6338
6275
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6339
6276
|
if (this.isReassigned || !this.init) {
|
|
@@ -6344,39 +6281,40 @@ class LocalVariable extends Variable {
|
|
|
6344
6281
|
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6345
6282
|
}, UnknownValue);
|
|
6346
6283
|
}
|
|
6347
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
6284
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6348
6285
|
if (this.isReassigned || !this.init) {
|
|
6349
6286
|
return UNKNOWN_EXPRESSION;
|
|
6350
6287
|
}
|
|
6351
6288
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6352
6289
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6353
|
-
return this.init.getReturnExpressionWhenCalledAtPath(path,
|
|
6290
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6354
6291
|
}, UNKNOWN_EXPRESSION);
|
|
6355
6292
|
}
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6293
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6294
|
+
switch (interaction.type) {
|
|
6295
|
+
case INTERACTION_ACCESSED:
|
|
6296
|
+
if (this.isReassigned)
|
|
6297
|
+
return true;
|
|
6298
|
+
return (this.init &&
|
|
6299
|
+
!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6300
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6301
|
+
case INTERACTION_ASSIGNED:
|
|
6302
|
+
if (this.included)
|
|
6303
|
+
return true;
|
|
6304
|
+
if (path.length === 0)
|
|
6305
|
+
return false;
|
|
6306
|
+
if (this.isReassigned)
|
|
6307
|
+
return true;
|
|
6308
|
+
return (this.init &&
|
|
6309
|
+
!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6310
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6311
|
+
case INTERACTION_CALLED:
|
|
6312
|
+
if (this.isReassigned)
|
|
6313
|
+
return true;
|
|
6314
|
+
return (this.init &&
|
|
6315
|
+
!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
6316
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6317
|
+
}
|
|
6380
6318
|
}
|
|
6381
6319
|
include() {
|
|
6382
6320
|
if (!this.included) {
|
|
@@ -6653,641 +6591,87 @@ class ReturnValueScope extends ParameterScope {
|
|
|
6653
6591
|
}
|
|
6654
6592
|
}
|
|
6655
6593
|
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
deoptimizePath(path) {
|
|
6664
|
-
path.length === 0 && this.left.deoptimizePath(path);
|
|
6665
|
-
}
|
|
6666
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6667
|
-
return path.length > 0 || this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
|
|
6668
|
-
}
|
|
6669
|
-
// Note that FunctionBase may directly include .left and .right without
|
|
6670
|
-
// including the pattern itself. This is how default parameter tree-shaking
|
|
6671
|
-
// works at the moment.
|
|
6672
|
-
include(context, includeChildrenRecursively) {
|
|
6673
|
-
this.included = true;
|
|
6674
|
-
this.left.include(context, includeChildrenRecursively);
|
|
6675
|
-
this.right.include(context, includeChildrenRecursively);
|
|
6676
|
-
}
|
|
6677
|
-
markDeclarationReached() {
|
|
6678
|
-
this.left.markDeclarationReached();
|
|
6679
|
-
}
|
|
6680
|
-
render(code, options, { isShorthandProperty } = BLANK) {
|
|
6681
|
-
this.left.render(code, options, { isShorthandProperty });
|
|
6682
|
-
if (this.right.included) {
|
|
6683
|
-
this.right.render(code, options);
|
|
6684
|
-
}
|
|
6685
|
-
else {
|
|
6686
|
-
code.remove(this.left.end, this.end);
|
|
6687
|
-
}
|
|
6688
|
-
}
|
|
6689
|
-
applyDeoptimizations() {
|
|
6690
|
-
this.deoptimized = true;
|
|
6691
|
-
this.left.deoptimizePath(EMPTY_PATH);
|
|
6692
|
-
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
6693
|
-
this.context.requestTreeshakingPass();
|
|
6694
|
-
}
|
|
6695
|
-
}
|
|
6594
|
+
//@ts-check
|
|
6595
|
+
/** @typedef { import('estree').Node} Node */
|
|
6596
|
+
/** @typedef {Node | {
|
|
6597
|
+
* type: 'PropertyDefinition';
|
|
6598
|
+
* computed: boolean;
|
|
6599
|
+
* value: Node
|
|
6600
|
+
* }} NodeWithPropertyDefinition */
|
|
6696
6601
|
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6602
|
+
/**
|
|
6603
|
+
*
|
|
6604
|
+
* @param {NodeWithPropertyDefinition} node
|
|
6605
|
+
* @param {NodeWithPropertyDefinition} parent
|
|
6606
|
+
* @returns boolean
|
|
6607
|
+
*/
|
|
6608
|
+
function is_reference (node, parent) {
|
|
6609
|
+
if (node.type === 'MemberExpression') {
|
|
6610
|
+
return !node.computed && is_reference(node.object, node);
|
|
6611
|
+
}
|
|
6612
|
+
|
|
6613
|
+
if (node.type === 'Identifier') {
|
|
6614
|
+
if (!parent) return true;
|
|
6615
|
+
|
|
6616
|
+
switch (parent.type) {
|
|
6617
|
+
// disregard `bar` in `foo.bar`
|
|
6618
|
+
case 'MemberExpression': return parent.computed || node === parent.object;
|
|
6619
|
+
|
|
6620
|
+
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
6621
|
+
case 'MethodDefinition': return parent.computed;
|
|
6622
|
+
|
|
6623
|
+
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
6624
|
+
case 'PropertyDefinition': return parent.computed || node === parent.value;
|
|
6625
|
+
|
|
6626
|
+
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
6627
|
+
case 'Property': return parent.computed || node === parent.value;
|
|
6628
|
+
|
|
6629
|
+
// disregard the `bar` in `export { foo as bar }` or
|
|
6630
|
+
// the foo in `import { foo as bar }`
|
|
6631
|
+
case 'ExportSpecifier':
|
|
6632
|
+
case 'ImportSpecifier': return node === parent.local;
|
|
6633
|
+
|
|
6634
|
+
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
6635
|
+
case 'LabeledStatement':
|
|
6636
|
+
case 'BreakStatement':
|
|
6637
|
+
case 'ContinueStatement': return false;
|
|
6638
|
+
default: return true;
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6641
|
+
|
|
6642
|
+
return false;
|
|
6709
6643
|
}
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6644
|
+
|
|
6645
|
+
/* eslint sort-keys: "off" */
|
|
6646
|
+
const ValueProperties = Symbol('Value Properties');
|
|
6647
|
+
const PURE = {
|
|
6648
|
+
hasEffectsWhenCalled() {
|
|
6649
|
+
return false;
|
|
6713
6650
|
}
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6651
|
+
};
|
|
6652
|
+
const IMPURE = {
|
|
6653
|
+
hasEffectsWhenCalled() {
|
|
6654
|
+
return true;
|
|
6718
6655
|
}
|
|
6719
|
-
}
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
|
|
6736
|
-
|
|
6737
|
-
|
|
6738
|
-
searchPos = code.indexOf(searchString, start);
|
|
6739
|
-
}
|
|
6740
|
-
}
|
|
6741
|
-
}
|
|
6742
|
-
const NON_WHITESPACE = /\S/g;
|
|
6743
|
-
function findNonWhiteSpace(code, index) {
|
|
6744
|
-
NON_WHITESPACE.lastIndex = index;
|
|
6745
|
-
const result = NON_WHITESPACE.exec(code);
|
|
6746
|
-
return result.index;
|
|
6747
|
-
}
|
|
6748
|
-
// This assumes "code" only contains white-space and comments
|
|
6749
|
-
// Returns position of line-comment if applicable
|
|
6750
|
-
function findFirstLineBreakOutsideComment(code) {
|
|
6751
|
-
let lineBreakPos, charCodeAfterSlash, start = 0;
|
|
6752
|
-
lineBreakPos = code.indexOf('\n', start);
|
|
6753
|
-
while (true) {
|
|
6754
|
-
start = code.indexOf('/', start);
|
|
6755
|
-
if (start === -1 || start > lineBreakPos)
|
|
6756
|
-
return [lineBreakPos, lineBreakPos + 1];
|
|
6757
|
-
// With our assumption, '/' always starts a comment. Determine comment type:
|
|
6758
|
-
charCodeAfterSlash = code.charCodeAt(start + 1);
|
|
6759
|
-
if (charCodeAfterSlash === 47 /*"/"*/)
|
|
6760
|
-
return [start, lineBreakPos + 1];
|
|
6761
|
-
start = code.indexOf('*/', start + 3) + 2;
|
|
6762
|
-
if (start > lineBreakPos) {
|
|
6763
|
-
lineBreakPos = code.indexOf('\n', start);
|
|
6764
|
-
}
|
|
6765
|
-
}
|
|
6766
|
-
}
|
|
6767
|
-
function renderStatementList(statements, code, start, end, options) {
|
|
6768
|
-
let currentNode, currentNodeStart, currentNodeNeedsBoundaries, nextNodeStart;
|
|
6769
|
-
let nextNode = statements[0];
|
|
6770
|
-
let nextNodeNeedsBoundaries = !nextNode.included || nextNode.needsBoundaries;
|
|
6771
|
-
if (nextNodeNeedsBoundaries) {
|
|
6772
|
-
nextNodeStart =
|
|
6773
|
-
start + findFirstLineBreakOutsideComment(code.original.slice(start, nextNode.start))[1];
|
|
6774
|
-
}
|
|
6775
|
-
for (let nextIndex = 1; nextIndex <= statements.length; nextIndex++) {
|
|
6776
|
-
currentNode = nextNode;
|
|
6777
|
-
currentNodeStart = nextNodeStart;
|
|
6778
|
-
currentNodeNeedsBoundaries = nextNodeNeedsBoundaries;
|
|
6779
|
-
nextNode = statements[nextIndex];
|
|
6780
|
-
nextNodeNeedsBoundaries =
|
|
6781
|
-
nextNode === undefined ? false : !nextNode.included || nextNode.needsBoundaries;
|
|
6782
|
-
if (currentNodeNeedsBoundaries || nextNodeNeedsBoundaries) {
|
|
6783
|
-
nextNodeStart =
|
|
6784
|
-
currentNode.end +
|
|
6785
|
-
findFirstLineBreakOutsideComment(code.original.slice(currentNode.end, nextNode === undefined ? end : nextNode.start))[1];
|
|
6786
|
-
if (currentNode.included) {
|
|
6787
|
-
currentNodeNeedsBoundaries
|
|
6788
|
-
? currentNode.render(code, options, {
|
|
6789
|
-
end: nextNodeStart,
|
|
6790
|
-
start: currentNodeStart
|
|
6791
|
-
})
|
|
6792
|
-
: currentNode.render(code, options);
|
|
6793
|
-
}
|
|
6794
|
-
else {
|
|
6795
|
-
treeshakeNode(currentNode, code, currentNodeStart, nextNodeStart);
|
|
6796
|
-
}
|
|
6797
|
-
}
|
|
6798
|
-
else {
|
|
6799
|
-
currentNode.render(code, options);
|
|
6800
|
-
}
|
|
6801
|
-
}
|
|
6802
|
-
}
|
|
6803
|
-
// This assumes that the first character is not part of the first node
|
|
6804
|
-
function getCommaSeparatedNodesWithBoundaries(nodes, code, start, end) {
|
|
6805
|
-
const splitUpNodes = [];
|
|
6806
|
-
let node, nextNode, nextNodeStart, contentEnd, char;
|
|
6807
|
-
let separator = start - 1;
|
|
6808
|
-
for (let nextIndex = 0; nextIndex < nodes.length; nextIndex++) {
|
|
6809
|
-
nextNode = nodes[nextIndex];
|
|
6810
|
-
if (node !== undefined) {
|
|
6811
|
-
separator =
|
|
6812
|
-
node.end +
|
|
6813
|
-
findFirstOccurrenceOutsideComment(code.original.slice(node.end, nextNode.start), ',');
|
|
6814
|
-
}
|
|
6815
|
-
nextNodeStart = contentEnd =
|
|
6816
|
-
separator +
|
|
6817
|
-
1 +
|
|
6818
|
-
findFirstLineBreakOutsideComment(code.original.slice(separator + 1, nextNode.start))[1];
|
|
6819
|
-
while (((char = code.original.charCodeAt(nextNodeStart)),
|
|
6820
|
-
char === 32 /*" "*/ || char === 9 /*"\t"*/ || char === 10 /*"\n"*/ || char === 13) /*"\r"*/)
|
|
6821
|
-
nextNodeStart++;
|
|
6822
|
-
if (node !== undefined) {
|
|
6823
|
-
splitUpNodes.push({
|
|
6824
|
-
contentEnd,
|
|
6825
|
-
end: nextNodeStart,
|
|
6826
|
-
node,
|
|
6827
|
-
separator,
|
|
6828
|
-
start
|
|
6829
|
-
});
|
|
6830
|
-
}
|
|
6831
|
-
node = nextNode;
|
|
6832
|
-
start = nextNodeStart;
|
|
6833
|
-
}
|
|
6834
|
-
splitUpNodes.push({
|
|
6835
|
-
contentEnd: end,
|
|
6836
|
-
end,
|
|
6837
|
-
node: node,
|
|
6838
|
-
separator: null,
|
|
6839
|
-
start
|
|
6840
|
-
});
|
|
6841
|
-
return splitUpNodes;
|
|
6842
|
-
}
|
|
6843
|
-
// This assumes there are only white-space and comments between start and end
|
|
6844
|
-
function removeLineBreaks(code, start, end) {
|
|
6845
|
-
while (true) {
|
|
6846
|
-
const [removeStart, removeEnd] = findFirstLineBreakOutsideComment(code.original.slice(start, end));
|
|
6847
|
-
if (removeStart === -1) {
|
|
6848
|
-
break;
|
|
6849
|
-
}
|
|
6850
|
-
code.remove(start + removeStart, (start += removeEnd));
|
|
6851
|
-
}
|
|
6852
|
-
}
|
|
6853
|
-
|
|
6854
|
-
class BlockScope extends ChildScope {
|
|
6855
|
-
addDeclaration(identifier, context, init, isHoisted) {
|
|
6856
|
-
if (isHoisted) {
|
|
6857
|
-
const variable = this.parent.addDeclaration(identifier, context, init, isHoisted);
|
|
6858
|
-
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
6859
|
-
// We cannot call deoptimizePath here.
|
|
6860
|
-
variable.markInitializersForDeoptimization();
|
|
6861
|
-
return variable;
|
|
6862
|
-
}
|
|
6863
|
-
else {
|
|
6864
|
-
return super.addDeclaration(identifier, context, init, false);
|
|
6865
|
-
}
|
|
6866
|
-
}
|
|
6867
|
-
}
|
|
6868
|
-
|
|
6869
|
-
class ExpressionStatement extends NodeBase {
|
|
6870
|
-
initialise() {
|
|
6871
|
-
if (this.directive &&
|
|
6872
|
-
this.directive !== 'use strict' &&
|
|
6873
|
-
this.parent.type === Program$1) {
|
|
6874
|
-
this.context.warn(
|
|
6875
|
-
// This is necessary, because either way (deleting or not) can lead to errors.
|
|
6876
|
-
{
|
|
6877
|
-
code: 'MODULE_LEVEL_DIRECTIVE',
|
|
6878
|
-
message: `Module level directives cause errors when bundled, '${this.directive}' was ignored.`
|
|
6879
|
-
}, this.start);
|
|
6880
|
-
}
|
|
6881
|
-
}
|
|
6882
|
-
render(code, options) {
|
|
6883
|
-
super.render(code, options);
|
|
6884
|
-
if (this.included)
|
|
6885
|
-
this.insertSemicolon(code);
|
|
6886
|
-
}
|
|
6887
|
-
shouldBeIncluded(context) {
|
|
6888
|
-
if (this.directive && this.directive !== 'use strict')
|
|
6889
|
-
return this.parent.type !== Program$1;
|
|
6890
|
-
return super.shouldBeIncluded(context);
|
|
6891
|
-
}
|
|
6892
|
-
applyDeoptimizations() { }
|
|
6893
|
-
}
|
|
6894
|
-
|
|
6895
|
-
class BlockStatement extends NodeBase {
|
|
6896
|
-
constructor() {
|
|
6897
|
-
super(...arguments);
|
|
6898
|
-
this.directlyIncluded = false;
|
|
6899
|
-
}
|
|
6900
|
-
addImplicitReturnExpressionToScope() {
|
|
6901
|
-
const lastStatement = this.body[this.body.length - 1];
|
|
6902
|
-
if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
|
|
6903
|
-
this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
|
|
6904
|
-
}
|
|
6905
|
-
}
|
|
6906
|
-
createScope(parentScope) {
|
|
6907
|
-
this.scope = this.parent.preventChildBlockScope
|
|
6908
|
-
? parentScope
|
|
6909
|
-
: new BlockScope(parentScope);
|
|
6910
|
-
}
|
|
6911
|
-
hasEffects(context) {
|
|
6912
|
-
if (this.deoptimizeBody)
|
|
6913
|
-
return true;
|
|
6914
|
-
for (const node of this.body) {
|
|
6915
|
-
if (context.brokenFlow)
|
|
6916
|
-
break;
|
|
6917
|
-
if (node.hasEffects(context))
|
|
6918
|
-
return true;
|
|
6919
|
-
}
|
|
6920
|
-
return false;
|
|
6921
|
-
}
|
|
6922
|
-
include(context, includeChildrenRecursively) {
|
|
6923
|
-
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
6924
|
-
this.included = true;
|
|
6925
|
-
this.directlyIncluded = true;
|
|
6926
|
-
if (this.deoptimizeBody)
|
|
6927
|
-
includeChildrenRecursively = true;
|
|
6928
|
-
for (const node of this.body) {
|
|
6929
|
-
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
6930
|
-
node.include(context, includeChildrenRecursively);
|
|
6931
|
-
}
|
|
6932
|
-
}
|
|
6933
|
-
}
|
|
6934
|
-
initialise() {
|
|
6935
|
-
const firstBodyStatement = this.body[0];
|
|
6936
|
-
this.deoptimizeBody =
|
|
6937
|
-
firstBodyStatement instanceof ExpressionStatement &&
|
|
6938
|
-
firstBodyStatement.directive === 'use asm';
|
|
6939
|
-
}
|
|
6940
|
-
render(code, options) {
|
|
6941
|
-
if (this.body.length) {
|
|
6942
|
-
renderStatementList(this.body, code, this.start + 1, this.end - 1, options);
|
|
6943
|
-
}
|
|
6944
|
-
else {
|
|
6945
|
-
super.render(code, options);
|
|
6946
|
-
}
|
|
6947
|
-
}
|
|
6948
|
-
}
|
|
6949
|
-
|
|
6950
|
-
class RestElement extends NodeBase {
|
|
6951
|
-
constructor() {
|
|
6952
|
-
super(...arguments);
|
|
6953
|
-
this.declarationInit = null;
|
|
6954
|
-
}
|
|
6955
|
-
addExportedVariables(variables, exportNamesByVariable) {
|
|
6956
|
-
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
6957
|
-
}
|
|
6958
|
-
declare(kind, init) {
|
|
6959
|
-
this.declarationInit = init;
|
|
6960
|
-
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
6961
|
-
}
|
|
6962
|
-
deoptimizePath(path) {
|
|
6963
|
-
path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH);
|
|
6964
|
-
}
|
|
6965
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6966
|
-
return path.length > 0 || this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context);
|
|
6967
|
-
}
|
|
6968
|
-
markDeclarationReached() {
|
|
6969
|
-
this.argument.markDeclarationReached();
|
|
6970
|
-
}
|
|
6971
|
-
applyDeoptimizations() {
|
|
6972
|
-
this.deoptimized = true;
|
|
6973
|
-
if (this.declarationInit !== null) {
|
|
6974
|
-
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
6975
|
-
this.context.requestTreeshakingPass();
|
|
6976
|
-
}
|
|
6977
|
-
}
|
|
6978
|
-
}
|
|
6979
|
-
|
|
6980
|
-
class FunctionBase extends NodeBase {
|
|
6981
|
-
constructor() {
|
|
6982
|
-
super(...arguments);
|
|
6983
|
-
this.objectEntity = null;
|
|
6984
|
-
this.deoptimizedReturn = false;
|
|
6985
|
-
this.forceIncludeParameters = false;
|
|
6986
|
-
}
|
|
6987
|
-
deoptimizeCache() {
|
|
6988
|
-
this.forceIncludeParameters = true;
|
|
6989
|
-
}
|
|
6990
|
-
deoptimizeCallParameters() {
|
|
6991
|
-
this.forceIncludeParameters = true;
|
|
6992
|
-
}
|
|
6993
|
-
deoptimizePath(path) {
|
|
6994
|
-
this.getObjectEntity().deoptimizePath(path);
|
|
6995
|
-
if (path.length === 1 && path[0] === UnknownKey) {
|
|
6996
|
-
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
6997
|
-
// which means the return expression needs to be reassigned
|
|
6998
|
-
this.forceIncludeParameters = true;
|
|
6999
|
-
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
7000
|
-
}
|
|
7001
|
-
}
|
|
7002
|
-
deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
|
|
7003
|
-
if (path.length > 0) {
|
|
7004
|
-
this.getObjectEntity().deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
|
|
7005
|
-
}
|
|
7006
|
-
}
|
|
7007
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7008
|
-
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7009
|
-
}
|
|
7010
|
-
getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
|
|
7011
|
-
if (path.length > 0) {
|
|
7012
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin);
|
|
7013
|
-
}
|
|
7014
|
-
if (this.async) {
|
|
7015
|
-
if (!this.deoptimizedReturn) {
|
|
7016
|
-
this.deoptimizedReturn = true;
|
|
7017
|
-
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
7018
|
-
this.context.requestTreeshakingPass();
|
|
7019
|
-
}
|
|
7020
|
-
return UNKNOWN_EXPRESSION;
|
|
7021
|
-
}
|
|
7022
|
-
return this.scope.getReturnExpression();
|
|
7023
|
-
}
|
|
7024
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
7025
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
7026
|
-
}
|
|
7027
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
7028
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
7029
|
-
}
|
|
7030
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7031
|
-
var _a;
|
|
7032
|
-
if (path.length > 0) {
|
|
7033
|
-
return this.getObjectEntity().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
7034
|
-
}
|
|
7035
|
-
if (this.async) {
|
|
7036
|
-
const { propertyReadSideEffects } = this.context.options
|
|
7037
|
-
.treeshake;
|
|
7038
|
-
const returnExpression = this.scope.getReturnExpression();
|
|
7039
|
-
if (returnExpression.hasEffectsWhenCalledAtPath(['then'], { args: NO_ARGS, thisParam: null, withNew: false }, context) ||
|
|
7040
|
-
(propertyReadSideEffects &&
|
|
7041
|
-
(propertyReadSideEffects === 'always' ||
|
|
7042
|
-
returnExpression.hasEffectsWhenAccessedAtPath(['then'], context)))) {
|
|
7043
|
-
return true;
|
|
7044
|
-
}
|
|
7045
|
-
}
|
|
7046
|
-
for (let position = 0; position < this.params.length; position++) {
|
|
7047
|
-
const parameter = this.params[position];
|
|
7048
|
-
if (parameter instanceof AssignmentPattern) {
|
|
7049
|
-
if (parameter.left.hasEffects(context)) {
|
|
7050
|
-
return true;
|
|
7051
|
-
}
|
|
7052
|
-
const argumentValue = (_a = callOptions.args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7053
|
-
if ((argumentValue === undefined || argumentValue === UnknownValue) &&
|
|
7054
|
-
parameter.right.hasEffects(context)) {
|
|
7055
|
-
return true;
|
|
7056
|
-
}
|
|
7057
|
-
}
|
|
7058
|
-
else if (parameter.hasEffects(context)) {
|
|
7059
|
-
return true;
|
|
7060
|
-
}
|
|
7061
|
-
}
|
|
7062
|
-
return false;
|
|
7063
|
-
}
|
|
7064
|
-
include(context, includeChildrenRecursively, { includeWithoutParameterDefaults } = BLANK) {
|
|
7065
|
-
if (!this.deoptimized)
|
|
7066
|
-
this.applyDeoptimizations();
|
|
7067
|
-
this.included = true;
|
|
7068
|
-
const { brokenFlow } = context;
|
|
7069
|
-
context.brokenFlow = BROKEN_FLOW_NONE;
|
|
7070
|
-
this.body.include(context, includeChildrenRecursively);
|
|
7071
|
-
context.brokenFlow = brokenFlow;
|
|
7072
|
-
if (!includeWithoutParameterDefaults ||
|
|
7073
|
-
includeChildrenRecursively ||
|
|
7074
|
-
this.forceIncludeParameters) {
|
|
7075
|
-
for (const param of this.params) {
|
|
7076
|
-
param.include(context, includeChildrenRecursively);
|
|
7077
|
-
}
|
|
7078
|
-
}
|
|
7079
|
-
}
|
|
7080
|
-
includeCallArguments(context, args) {
|
|
7081
|
-
var _a;
|
|
7082
|
-
for (let position = 0; position < this.params.length; position++) {
|
|
7083
|
-
const parameter = this.params[position];
|
|
7084
|
-
if (parameter instanceof AssignmentPattern) {
|
|
7085
|
-
if (parameter.left.shouldBeIncluded(context)) {
|
|
7086
|
-
parameter.left.include(context, false);
|
|
7087
|
-
}
|
|
7088
|
-
const argumentValue = (_a = args[position]) === null || _a === void 0 ? void 0 : _a.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7089
|
-
// If argumentValue === UnknownTruthyValue, then we do not need to
|
|
7090
|
-
// include the default
|
|
7091
|
-
if ((argumentValue === undefined || argumentValue === UnknownValue) &&
|
|
7092
|
-
(this.parameterVariables[position].some(variable => variable.included) ||
|
|
7093
|
-
parameter.right.shouldBeIncluded(context))) {
|
|
7094
|
-
parameter.right.include(context, false);
|
|
7095
|
-
}
|
|
7096
|
-
}
|
|
7097
|
-
else if (parameter.shouldBeIncluded(context)) {
|
|
7098
|
-
parameter.include(context, false);
|
|
7099
|
-
}
|
|
7100
|
-
}
|
|
7101
|
-
this.scope.includeCallArguments(context, args);
|
|
7102
|
-
}
|
|
7103
|
-
initialise() {
|
|
7104
|
-
this.parameterVariables = this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION));
|
|
7105
|
-
this.scope.addParameterVariables(this.parameterVariables, this.params[this.params.length - 1] instanceof RestElement);
|
|
7106
|
-
if (this.body instanceof BlockStatement) {
|
|
7107
|
-
this.body.addImplicitReturnExpressionToScope();
|
|
7108
|
-
}
|
|
7109
|
-
else {
|
|
7110
|
-
this.scope.addReturnExpression(this.body);
|
|
7111
|
-
}
|
|
7112
|
-
}
|
|
7113
|
-
parseNode(esTreeNode) {
|
|
7114
|
-
if (esTreeNode.body.type === BlockStatement$1) {
|
|
7115
|
-
this.body = new BlockStatement(esTreeNode.body, this, this.scope.hoistedBodyVarScope);
|
|
7116
|
-
}
|
|
7117
|
-
super.parseNode(esTreeNode);
|
|
7118
|
-
}
|
|
7119
|
-
applyDeoptimizations() {
|
|
7120
|
-
// We currently do not track deoptimizations of default values, deoptimize them
|
|
7121
|
-
// just as we deoptimize call arguments
|
|
7122
|
-
for (const param of this.params) {
|
|
7123
|
-
if (param instanceof AssignmentPattern) {
|
|
7124
|
-
param.right.deoptimizePath(UNKNOWN_PATH);
|
|
7125
|
-
}
|
|
7126
|
-
}
|
|
7127
|
-
}
|
|
7128
|
-
}
|
|
7129
|
-
FunctionBase.prototype.preventChildBlockScope = true;
|
|
7130
|
-
|
|
7131
|
-
class ArrowFunctionExpression extends FunctionBase {
|
|
7132
|
-
constructor() {
|
|
7133
|
-
super(...arguments);
|
|
7134
|
-
this.objectEntity = null;
|
|
7135
|
-
}
|
|
7136
|
-
createScope(parentScope) {
|
|
7137
|
-
this.scope = new ReturnValueScope(parentScope, this.context);
|
|
7138
|
-
}
|
|
7139
|
-
hasEffects() {
|
|
7140
|
-
if (!this.deoptimized)
|
|
7141
|
-
this.applyDeoptimizations();
|
|
7142
|
-
return false;
|
|
7143
|
-
}
|
|
7144
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7145
|
-
if (super.hasEffectsWhenCalledAtPath(path, callOptions, context))
|
|
7146
|
-
return true;
|
|
7147
|
-
const { ignore, brokenFlow } = context;
|
|
7148
|
-
context.ignore = {
|
|
7149
|
-
breaks: false,
|
|
7150
|
-
continues: false,
|
|
7151
|
-
labels: new Set(),
|
|
7152
|
-
returnYield: true
|
|
7153
|
-
};
|
|
7154
|
-
if (this.body.hasEffects(context))
|
|
7155
|
-
return true;
|
|
7156
|
-
context.ignore = ignore;
|
|
7157
|
-
context.brokenFlow = brokenFlow;
|
|
7158
|
-
return false;
|
|
7159
|
-
}
|
|
7160
|
-
getObjectEntity() {
|
|
7161
|
-
if (this.objectEntity !== null) {
|
|
7162
|
-
return this.objectEntity;
|
|
7163
|
-
}
|
|
7164
|
-
return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE));
|
|
7165
|
-
}
|
|
7166
|
-
}
|
|
7167
|
-
|
|
7168
|
-
function getSystemExportStatement(exportedVariables, { exportNamesByVariable, snippets: { _, getObject, getPropertyAccess } }, modifier = '') {
|
|
7169
|
-
if (exportedVariables.length === 1 &&
|
|
7170
|
-
exportNamesByVariable.get(exportedVariables[0]).length === 1) {
|
|
7171
|
-
const variable = exportedVariables[0];
|
|
7172
|
-
return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName(getPropertyAccess)}${modifier})`;
|
|
7173
|
-
}
|
|
7174
|
-
else {
|
|
7175
|
-
const fields = [];
|
|
7176
|
-
for (const variable of exportedVariables) {
|
|
7177
|
-
for (const exportName of exportNamesByVariable.get(variable)) {
|
|
7178
|
-
fields.push([exportName, variable.getName(getPropertyAccess) + modifier]);
|
|
7179
|
-
}
|
|
7180
|
-
}
|
|
7181
|
-
return `exports(${getObject(fields, { lineBreakIndent: null })})`;
|
|
7182
|
-
}
|
|
7183
|
-
}
|
|
7184
|
-
function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
|
|
7185
|
-
code.prependRight(expressionStart, `exports('${exportNamesByVariable.get(exportedVariable)}',${_}`);
|
|
7186
|
-
code.appendLeft(expressionEnd, ')');
|
|
7187
|
-
}
|
|
7188
|
-
function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
|
|
7189
|
-
const { _, getDirectReturnIifeLeft } = options.snippets;
|
|
7190
|
-
code.prependRight(expressionStart, getDirectReturnIifeLeft(['v'], `${getSystemExportStatement(exportedVariables, options)},${_}v`, { needsArrowReturnParens: true, needsWrappedFunction: needsParens }));
|
|
7191
|
-
code.appendLeft(expressionEnd, ')');
|
|
7192
|
-
}
|
|
7193
|
-
function renderSystemExportSequenceAfterExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options) {
|
|
7194
|
-
const { _, getPropertyAccess } = options.snippets;
|
|
7195
|
-
code.appendLeft(expressionEnd, `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName(getPropertyAccess)}`);
|
|
7196
|
-
if (needsParens) {
|
|
7197
|
-
code.prependRight(expressionStart, '(');
|
|
7198
|
-
code.appendLeft(expressionEnd, ')');
|
|
7199
|
-
}
|
|
7200
|
-
}
|
|
7201
|
-
function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
|
|
7202
|
-
const { _ } = options.snippets;
|
|
7203
|
-
code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
|
|
7204
|
-
if (needsParens) {
|
|
7205
|
-
code.prependRight(expressionStart, '(');
|
|
7206
|
-
code.appendLeft(expressionEnd, ')');
|
|
7207
|
-
}
|
|
7208
|
-
}
|
|
7209
|
-
|
|
7210
|
-
//@ts-check
|
|
7211
|
-
/** @typedef { import('estree').Node} Node */
|
|
7212
|
-
/** @typedef {Node | {
|
|
7213
|
-
* type: 'PropertyDefinition';
|
|
7214
|
-
* computed: boolean;
|
|
7215
|
-
* value: Node
|
|
7216
|
-
* }} NodeWithPropertyDefinition */
|
|
7217
|
-
|
|
7218
|
-
/**
|
|
7219
|
-
*
|
|
7220
|
-
* @param {NodeWithPropertyDefinition} node
|
|
7221
|
-
* @param {NodeWithPropertyDefinition} parent
|
|
7222
|
-
* @returns boolean
|
|
7223
|
-
*/
|
|
7224
|
-
function is_reference (node, parent) {
|
|
7225
|
-
if (node.type === 'MemberExpression') {
|
|
7226
|
-
return !node.computed && is_reference(node.object, node);
|
|
7227
|
-
}
|
|
7228
|
-
|
|
7229
|
-
if (node.type === 'Identifier') {
|
|
7230
|
-
if (!parent) return true;
|
|
7231
|
-
|
|
7232
|
-
switch (parent.type) {
|
|
7233
|
-
// disregard `bar` in `foo.bar`
|
|
7234
|
-
case 'MemberExpression': return parent.computed || node === parent.object;
|
|
7235
|
-
|
|
7236
|
-
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
7237
|
-
case 'MethodDefinition': return parent.computed;
|
|
7238
|
-
|
|
7239
|
-
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
7240
|
-
case 'PropertyDefinition': return parent.computed || node === parent.value;
|
|
7241
|
-
|
|
7242
|
-
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
7243
|
-
case 'Property': return parent.computed || node === parent.value;
|
|
7244
|
-
|
|
7245
|
-
// disregard the `bar` in `export { foo as bar }` or
|
|
7246
|
-
// the foo in `import { foo as bar }`
|
|
7247
|
-
case 'ExportSpecifier':
|
|
7248
|
-
case 'ImportSpecifier': return node === parent.local;
|
|
7249
|
-
|
|
7250
|
-
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
7251
|
-
case 'LabeledStatement':
|
|
7252
|
-
case 'BreakStatement':
|
|
7253
|
-
case 'ContinueStatement': return false;
|
|
7254
|
-
default: return true;
|
|
7255
|
-
}
|
|
7256
|
-
}
|
|
7257
|
-
|
|
7258
|
-
return false;
|
|
7259
|
-
}
|
|
7260
|
-
|
|
7261
|
-
/* eslint sort-keys: "off" */
|
|
7262
|
-
const ValueProperties = Symbol('Value Properties');
|
|
7263
|
-
const PURE = {
|
|
7264
|
-
hasEffectsWhenCalled() {
|
|
7265
|
-
return false;
|
|
7266
|
-
}
|
|
7267
|
-
};
|
|
7268
|
-
const IMPURE = {
|
|
7269
|
-
hasEffectsWhenCalled() {
|
|
7270
|
-
return true;
|
|
7271
|
-
}
|
|
7272
|
-
};
|
|
7273
|
-
// We use shortened variables to reduce file size here
|
|
7274
|
-
/* OBJECT */
|
|
7275
|
-
const O = {
|
|
7276
|
-
__proto__: null,
|
|
7277
|
-
[ValueProperties]: IMPURE
|
|
7278
|
-
};
|
|
7279
|
-
/* PURE FUNCTION */
|
|
7280
|
-
const PF = {
|
|
7281
|
-
__proto__: null,
|
|
7282
|
-
[ValueProperties]: PURE
|
|
7283
|
-
};
|
|
7284
|
-
/* FUNCTION THAT MUTATES FIRST ARG WITHOUT TRIGGERING ACCESSORS */
|
|
7285
|
-
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
7286
|
-
__proto__: null,
|
|
7287
|
-
[ValueProperties]: {
|
|
7288
|
-
hasEffectsWhenCalled(callOptions, context) {
|
|
7289
|
-
return (!callOptions.args.length ||
|
|
7290
|
-
callOptions.args[0].hasEffectsWhenAssignedAtPath(UNKNOWN_NON_ACCESSOR_PATH, context));
|
|
6656
|
+
};
|
|
6657
|
+
// We use shortened variables to reduce file size here
|
|
6658
|
+
/* OBJECT */
|
|
6659
|
+
const O = {
|
|
6660
|
+
__proto__: null,
|
|
6661
|
+
[ValueProperties]: IMPURE
|
|
6662
|
+
};
|
|
6663
|
+
/* PURE FUNCTION */
|
|
6664
|
+
const PF = {
|
|
6665
|
+
__proto__: null,
|
|
6666
|
+
[ValueProperties]: PURE
|
|
6667
|
+
};
|
|
6668
|
+
/* FUNCTION THAT MUTATES FIRST ARG WITHOUT TRIGGERING ACCESSORS */
|
|
6669
|
+
const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
6670
|
+
__proto__: null,
|
|
6671
|
+
[ValueProperties]: {
|
|
6672
|
+
hasEffectsWhenCalled({ args }, context) {
|
|
6673
|
+
return (!args.length ||
|
|
6674
|
+
args[0].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
7291
6675
|
}
|
|
7292
6676
|
}
|
|
7293
6677
|
};
|
|
@@ -8104,227 +7488,691 @@ const knownGlobals = {
|
|
|
8104
7488
|
for (const global of ['window', 'global', 'self', 'globalThis']) {
|
|
8105
7489
|
knownGlobals[global] = knownGlobals;
|
|
8106
7490
|
}
|
|
8107
|
-
function getGlobalAtPath(path) {
|
|
8108
|
-
let currentGlobal = knownGlobals;
|
|
8109
|
-
for (const pathSegment of path) {
|
|
8110
|
-
if (typeof pathSegment !== 'string') {
|
|
8111
|
-
return null;
|
|
7491
|
+
function getGlobalAtPath(path) {
|
|
7492
|
+
let currentGlobal = knownGlobals;
|
|
7493
|
+
for (const pathSegment of path) {
|
|
7494
|
+
if (typeof pathSegment !== 'string') {
|
|
7495
|
+
return null;
|
|
7496
|
+
}
|
|
7497
|
+
currentGlobal = currentGlobal[pathSegment];
|
|
7498
|
+
if (!currentGlobal) {
|
|
7499
|
+
return null;
|
|
7500
|
+
}
|
|
7501
|
+
}
|
|
7502
|
+
return currentGlobal[ValueProperties];
|
|
7503
|
+
}
|
|
7504
|
+
|
|
7505
|
+
class GlobalVariable extends Variable {
|
|
7506
|
+
constructor() {
|
|
7507
|
+
super(...arguments);
|
|
7508
|
+
// Ensure we use live-bindings for globals as we do not know if they have
|
|
7509
|
+
// been reassigned
|
|
7510
|
+
this.isReassigned = true;
|
|
7511
|
+
}
|
|
7512
|
+
getLiteralValueAtPath(path, _recursionTracker, _origin) {
|
|
7513
|
+
return getGlobalAtPath([this.name, ...path]) ? UnknownTruthyValue : UnknownValue;
|
|
7514
|
+
}
|
|
7515
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7516
|
+
switch (interaction.type) {
|
|
7517
|
+
case INTERACTION_ACCESSED:
|
|
7518
|
+
if (path.length === 0) {
|
|
7519
|
+
// Technically, "undefined" is a global variable of sorts
|
|
7520
|
+
return this.name !== 'undefined' && !getGlobalAtPath([this.name]);
|
|
7521
|
+
}
|
|
7522
|
+
return !getGlobalAtPath([this.name, ...path].slice(0, -1));
|
|
7523
|
+
case INTERACTION_ASSIGNED:
|
|
7524
|
+
return true;
|
|
7525
|
+
case INTERACTION_CALLED: {
|
|
7526
|
+
const globalAtPath = getGlobalAtPath([this.name, ...path]);
|
|
7527
|
+
return !globalAtPath || globalAtPath.hasEffectsWhenCalled(interaction, context);
|
|
7528
|
+
}
|
|
7529
|
+
}
|
|
7530
|
+
}
|
|
7531
|
+
}
|
|
7532
|
+
|
|
7533
|
+
const tdzVariableKinds = {
|
|
7534
|
+
__proto__: null,
|
|
7535
|
+
class: true,
|
|
7536
|
+
const: true,
|
|
7537
|
+
let: true,
|
|
7538
|
+
var: true
|
|
7539
|
+
};
|
|
7540
|
+
class Identifier extends NodeBase {
|
|
7541
|
+
constructor() {
|
|
7542
|
+
super(...arguments);
|
|
7543
|
+
this.variable = null;
|
|
7544
|
+
this.isTDZAccess = null;
|
|
7545
|
+
}
|
|
7546
|
+
addExportedVariables(variables, exportNamesByVariable) {
|
|
7547
|
+
if (exportNamesByVariable.has(this.variable)) {
|
|
7548
|
+
variables.push(this.variable);
|
|
7549
|
+
}
|
|
7550
|
+
}
|
|
7551
|
+
bind() {
|
|
7552
|
+
if (!this.variable && is_reference(this, this.parent)) {
|
|
7553
|
+
this.variable = this.scope.findVariable(this.name);
|
|
7554
|
+
this.variable.addReference(this);
|
|
7555
|
+
}
|
|
7556
|
+
}
|
|
7557
|
+
declare(kind, init) {
|
|
7558
|
+
let variable;
|
|
7559
|
+
const { treeshake } = this.context.options;
|
|
7560
|
+
switch (kind) {
|
|
7561
|
+
case 'var':
|
|
7562
|
+
variable = this.scope.addDeclaration(this, this.context, init, true);
|
|
7563
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
7564
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
7565
|
+
variable.markInitializersForDeoptimization();
|
|
7566
|
+
}
|
|
7567
|
+
break;
|
|
7568
|
+
case 'function':
|
|
7569
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
7570
|
+
variable = this.scope.addDeclaration(this, this.context, init, false);
|
|
7571
|
+
break;
|
|
7572
|
+
case 'let':
|
|
7573
|
+
case 'const':
|
|
7574
|
+
case 'class':
|
|
7575
|
+
variable = this.scope.addDeclaration(this, this.context, init, false);
|
|
7576
|
+
break;
|
|
7577
|
+
case 'parameter':
|
|
7578
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
7579
|
+
break;
|
|
7580
|
+
/* istanbul ignore next */
|
|
7581
|
+
default:
|
|
7582
|
+
/* istanbul ignore next */
|
|
7583
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
7584
|
+
}
|
|
7585
|
+
variable.kind = kind;
|
|
7586
|
+
return [(this.variable = variable)];
|
|
7587
|
+
}
|
|
7588
|
+
deoptimizePath(path) {
|
|
7589
|
+
var _a;
|
|
7590
|
+
if (path.length === 0 && !this.scope.contains(this.name)) {
|
|
7591
|
+
this.disallowImportReassignment();
|
|
7592
|
+
}
|
|
7593
|
+
// We keep conditional chaining because an unknown Node could have an
|
|
7594
|
+
// Identifier as property that might be deoptimized by default
|
|
7595
|
+
(_a = this.variable) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
7596
|
+
}
|
|
7597
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7598
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
7599
|
+
}
|
|
7600
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7601
|
+
return this.getVariableRespectingTDZ().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7602
|
+
}
|
|
7603
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7604
|
+
return this.getVariableRespectingTDZ().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
7605
|
+
}
|
|
7606
|
+
hasEffects(context) {
|
|
7607
|
+
if (!this.deoptimized)
|
|
7608
|
+
this.applyDeoptimizations();
|
|
7609
|
+
if (this.isPossibleTDZ() && this.variable.kind !== 'var') {
|
|
7610
|
+
return true;
|
|
7611
|
+
}
|
|
7612
|
+
return (this.context.options.treeshake.unknownGlobalSideEffects &&
|
|
7613
|
+
this.variable instanceof GlobalVariable &&
|
|
7614
|
+
this.variable.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
7615
|
+
}
|
|
7616
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7617
|
+
switch (interaction.type) {
|
|
7618
|
+
case INTERACTION_ACCESSED:
|
|
7619
|
+
return (this.variable !== null &&
|
|
7620
|
+
this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
7621
|
+
case INTERACTION_ASSIGNED:
|
|
7622
|
+
return (path.length > 0 ? this.getVariableRespectingTDZ() : this.variable).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7623
|
+
case INTERACTION_CALLED:
|
|
7624
|
+
return this.getVariableRespectingTDZ().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7625
|
+
}
|
|
7626
|
+
}
|
|
7627
|
+
include() {
|
|
7628
|
+
if (!this.deoptimized)
|
|
7629
|
+
this.applyDeoptimizations();
|
|
7630
|
+
if (!this.included) {
|
|
7631
|
+
this.included = true;
|
|
7632
|
+
if (this.variable !== null) {
|
|
7633
|
+
this.context.includeVariableInModule(this.variable);
|
|
7634
|
+
}
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7637
|
+
includeCallArguments(context, args) {
|
|
7638
|
+
this.variable.includeCallArguments(context, args);
|
|
7639
|
+
}
|
|
7640
|
+
isPossibleTDZ() {
|
|
7641
|
+
// return cached value to avoid issues with the next tree-shaking pass
|
|
7642
|
+
if (this.isTDZAccess !== null)
|
|
7643
|
+
return this.isTDZAccess;
|
|
7644
|
+
if (!(this.variable instanceof LocalVariable) ||
|
|
7645
|
+
!this.variable.kind ||
|
|
7646
|
+
!(this.variable.kind in tdzVariableKinds)) {
|
|
7647
|
+
return (this.isTDZAccess = false);
|
|
7648
|
+
}
|
|
7649
|
+
let decl_id;
|
|
7650
|
+
if (this.variable.declarations &&
|
|
7651
|
+
this.variable.declarations.length === 1 &&
|
|
7652
|
+
(decl_id = this.variable.declarations[0]) &&
|
|
7653
|
+
this.start < decl_id.start &&
|
|
7654
|
+
closestParentFunctionOrProgram(this) === closestParentFunctionOrProgram(decl_id)) {
|
|
7655
|
+
// a variable accessed before its declaration
|
|
7656
|
+
// in the same function or at top level of module
|
|
7657
|
+
return (this.isTDZAccess = true);
|
|
7658
|
+
}
|
|
7659
|
+
if (!this.variable.initReached) {
|
|
7660
|
+
// Either a const/let TDZ violation or
|
|
7661
|
+
// var use before declaration was encountered.
|
|
7662
|
+
return (this.isTDZAccess = true);
|
|
7663
|
+
}
|
|
7664
|
+
return (this.isTDZAccess = false);
|
|
7665
|
+
}
|
|
7666
|
+
markDeclarationReached() {
|
|
7667
|
+
this.variable.initReached = true;
|
|
7668
|
+
}
|
|
7669
|
+
render(code, { snippets: { getPropertyAccess } }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = BLANK) {
|
|
7670
|
+
if (this.variable) {
|
|
7671
|
+
const name = this.variable.getName(getPropertyAccess);
|
|
7672
|
+
if (name !== this.name) {
|
|
7673
|
+
code.overwrite(this.start, this.end, name, {
|
|
7674
|
+
contentOnly: true,
|
|
7675
|
+
storeName: true
|
|
7676
|
+
});
|
|
7677
|
+
if (isShorthandProperty) {
|
|
7678
|
+
code.prependRight(this.start, `${this.name}: `);
|
|
7679
|
+
}
|
|
7680
|
+
}
|
|
7681
|
+
// In strict mode, any variable named "eval" must be the actual "eval" function
|
|
7682
|
+
if (name === 'eval' &&
|
|
7683
|
+
renderedParentType === CallExpression$1 &&
|
|
7684
|
+
isCalleeOfRenderedParent) {
|
|
7685
|
+
code.appendRight(this.start, '0, ');
|
|
7686
|
+
}
|
|
7687
|
+
}
|
|
7688
|
+
}
|
|
7689
|
+
applyDeoptimizations() {
|
|
7690
|
+
this.deoptimized = true;
|
|
7691
|
+
if (this.variable instanceof LocalVariable) {
|
|
7692
|
+
this.variable.consolidateInitializers();
|
|
7693
|
+
this.context.requestTreeshakingPass();
|
|
7694
|
+
}
|
|
7695
|
+
}
|
|
7696
|
+
disallowImportReassignment() {
|
|
7697
|
+
return this.context.error({
|
|
7698
|
+
code: 'ILLEGAL_REASSIGNMENT',
|
|
7699
|
+
message: `Illegal reassignment to import '${this.name}'`
|
|
7700
|
+
}, this.start);
|
|
7701
|
+
}
|
|
7702
|
+
getVariableRespectingTDZ() {
|
|
7703
|
+
if (this.isPossibleTDZ()) {
|
|
7704
|
+
return UNKNOWN_EXPRESSION;
|
|
7705
|
+
}
|
|
7706
|
+
return this.variable;
|
|
7707
|
+
}
|
|
7708
|
+
}
|
|
7709
|
+
function closestParentFunctionOrProgram(node) {
|
|
7710
|
+
while (node && !/^Program|Function/.test(node.type)) {
|
|
7711
|
+
node = node.parent;
|
|
7712
|
+
}
|
|
7713
|
+
// one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program
|
|
7714
|
+
return node;
|
|
7715
|
+
}
|
|
7716
|
+
|
|
7717
|
+
function treeshakeNode(node, code, start, end) {
|
|
7718
|
+
code.remove(start, end);
|
|
7719
|
+
if (node.annotations) {
|
|
7720
|
+
for (const annotation of node.annotations) {
|
|
7721
|
+
if (annotation.start < start) {
|
|
7722
|
+
code.remove(annotation.start, annotation.end);
|
|
7723
|
+
}
|
|
7724
|
+
else {
|
|
7725
|
+
return;
|
|
7726
|
+
}
|
|
7727
|
+
}
|
|
7728
|
+
}
|
|
7729
|
+
}
|
|
7730
|
+
function removeAnnotations(node, code) {
|
|
7731
|
+
if (!node.annotations && node.parent.type === ExpressionStatement$1) {
|
|
7732
|
+
node = node.parent;
|
|
7733
|
+
}
|
|
7734
|
+
if (node.annotations) {
|
|
7735
|
+
for (const annotation of node.annotations) {
|
|
7736
|
+
code.remove(annotation.start, annotation.end);
|
|
7737
|
+
}
|
|
7738
|
+
}
|
|
7739
|
+
}
|
|
7740
|
+
|
|
7741
|
+
const NO_SEMICOLON = { isNoStatement: true };
|
|
7742
|
+
// This assumes there are only white-space and comments between start and the string we are looking for
|
|
7743
|
+
function findFirstOccurrenceOutsideComment(code, searchString, start = 0) {
|
|
7744
|
+
let searchPos, charCodeAfterSlash;
|
|
7745
|
+
searchPos = code.indexOf(searchString, start);
|
|
7746
|
+
while (true) {
|
|
7747
|
+
start = code.indexOf('/', start);
|
|
7748
|
+
if (start === -1 || start >= searchPos)
|
|
7749
|
+
return searchPos;
|
|
7750
|
+
charCodeAfterSlash = code.charCodeAt(++start);
|
|
7751
|
+
++start;
|
|
7752
|
+
// With our assumption, '/' always starts a comment. Determine comment type:
|
|
7753
|
+
start =
|
|
7754
|
+
charCodeAfterSlash === 47 /*"/"*/
|
|
7755
|
+
? code.indexOf('\n', start) + 1
|
|
7756
|
+
: code.indexOf('*/', start) + 2;
|
|
7757
|
+
if (start > searchPos) {
|
|
7758
|
+
searchPos = code.indexOf(searchString, start);
|
|
7759
|
+
}
|
|
7760
|
+
}
|
|
7761
|
+
}
|
|
7762
|
+
const NON_WHITESPACE = /\S/g;
|
|
7763
|
+
function findNonWhiteSpace(code, index) {
|
|
7764
|
+
NON_WHITESPACE.lastIndex = index;
|
|
7765
|
+
const result = NON_WHITESPACE.exec(code);
|
|
7766
|
+
return result.index;
|
|
7767
|
+
}
|
|
7768
|
+
// This assumes "code" only contains white-space and comments
|
|
7769
|
+
// Returns position of line-comment if applicable
|
|
7770
|
+
function findFirstLineBreakOutsideComment(code) {
|
|
7771
|
+
let lineBreakPos, charCodeAfterSlash, start = 0;
|
|
7772
|
+
lineBreakPos = code.indexOf('\n', start);
|
|
7773
|
+
while (true) {
|
|
7774
|
+
start = code.indexOf('/', start);
|
|
7775
|
+
if (start === -1 || start > lineBreakPos)
|
|
7776
|
+
return [lineBreakPos, lineBreakPos + 1];
|
|
7777
|
+
// With our assumption, '/' always starts a comment. Determine comment type:
|
|
7778
|
+
charCodeAfterSlash = code.charCodeAt(start + 1);
|
|
7779
|
+
if (charCodeAfterSlash === 47 /*"/"*/)
|
|
7780
|
+
return [start, lineBreakPos + 1];
|
|
7781
|
+
start = code.indexOf('*/', start + 3) + 2;
|
|
7782
|
+
if (start > lineBreakPos) {
|
|
7783
|
+
lineBreakPos = code.indexOf('\n', start);
|
|
7784
|
+
}
|
|
7785
|
+
}
|
|
7786
|
+
}
|
|
7787
|
+
function renderStatementList(statements, code, start, end, options) {
|
|
7788
|
+
let currentNode, currentNodeStart, currentNodeNeedsBoundaries, nextNodeStart;
|
|
7789
|
+
let nextNode = statements[0];
|
|
7790
|
+
let nextNodeNeedsBoundaries = !nextNode.included || nextNode.needsBoundaries;
|
|
7791
|
+
if (nextNodeNeedsBoundaries) {
|
|
7792
|
+
nextNodeStart =
|
|
7793
|
+
start + findFirstLineBreakOutsideComment(code.original.slice(start, nextNode.start))[1];
|
|
7794
|
+
}
|
|
7795
|
+
for (let nextIndex = 1; nextIndex <= statements.length; nextIndex++) {
|
|
7796
|
+
currentNode = nextNode;
|
|
7797
|
+
currentNodeStart = nextNodeStart;
|
|
7798
|
+
currentNodeNeedsBoundaries = nextNodeNeedsBoundaries;
|
|
7799
|
+
nextNode = statements[nextIndex];
|
|
7800
|
+
nextNodeNeedsBoundaries =
|
|
7801
|
+
nextNode === undefined ? false : !nextNode.included || nextNode.needsBoundaries;
|
|
7802
|
+
if (currentNodeNeedsBoundaries || nextNodeNeedsBoundaries) {
|
|
7803
|
+
nextNodeStart =
|
|
7804
|
+
currentNode.end +
|
|
7805
|
+
findFirstLineBreakOutsideComment(code.original.slice(currentNode.end, nextNode === undefined ? end : nextNode.start))[1];
|
|
7806
|
+
if (currentNode.included) {
|
|
7807
|
+
currentNodeNeedsBoundaries
|
|
7808
|
+
? currentNode.render(code, options, {
|
|
7809
|
+
end: nextNodeStart,
|
|
7810
|
+
start: currentNodeStart
|
|
7811
|
+
})
|
|
7812
|
+
: currentNode.render(code, options);
|
|
7813
|
+
}
|
|
7814
|
+
else {
|
|
7815
|
+
treeshakeNode(currentNode, code, currentNodeStart, nextNodeStart);
|
|
7816
|
+
}
|
|
7817
|
+
}
|
|
7818
|
+
else {
|
|
7819
|
+
currentNode.render(code, options);
|
|
7820
|
+
}
|
|
7821
|
+
}
|
|
7822
|
+
}
|
|
7823
|
+
// This assumes that the first character is not part of the first node
|
|
7824
|
+
function getCommaSeparatedNodesWithBoundaries(nodes, code, start, end) {
|
|
7825
|
+
const splitUpNodes = [];
|
|
7826
|
+
let node, nextNode, nextNodeStart, contentEnd, char;
|
|
7827
|
+
let separator = start - 1;
|
|
7828
|
+
for (let nextIndex = 0; nextIndex < nodes.length; nextIndex++) {
|
|
7829
|
+
nextNode = nodes[nextIndex];
|
|
7830
|
+
if (node !== undefined) {
|
|
7831
|
+
separator =
|
|
7832
|
+
node.end +
|
|
7833
|
+
findFirstOccurrenceOutsideComment(code.original.slice(node.end, nextNode.start), ',');
|
|
7834
|
+
}
|
|
7835
|
+
nextNodeStart = contentEnd =
|
|
7836
|
+
separator +
|
|
7837
|
+
1 +
|
|
7838
|
+
findFirstLineBreakOutsideComment(code.original.slice(separator + 1, nextNode.start))[1];
|
|
7839
|
+
while (((char = code.original.charCodeAt(nextNodeStart)),
|
|
7840
|
+
char === 32 /*" "*/ || char === 9 /*"\t"*/ || char === 10 /*"\n"*/ || char === 13) /*"\r"*/)
|
|
7841
|
+
nextNodeStart++;
|
|
7842
|
+
if (node !== undefined) {
|
|
7843
|
+
splitUpNodes.push({
|
|
7844
|
+
contentEnd,
|
|
7845
|
+
end: nextNodeStart,
|
|
7846
|
+
node,
|
|
7847
|
+
separator,
|
|
7848
|
+
start
|
|
7849
|
+
});
|
|
7850
|
+
}
|
|
7851
|
+
node = nextNode;
|
|
7852
|
+
start = nextNodeStart;
|
|
7853
|
+
}
|
|
7854
|
+
splitUpNodes.push({
|
|
7855
|
+
contentEnd: end,
|
|
7856
|
+
end,
|
|
7857
|
+
node: node,
|
|
7858
|
+
separator: null,
|
|
7859
|
+
start
|
|
7860
|
+
});
|
|
7861
|
+
return splitUpNodes;
|
|
7862
|
+
}
|
|
7863
|
+
// This assumes there are only white-space and comments between start and end
|
|
7864
|
+
function removeLineBreaks(code, start, end) {
|
|
7865
|
+
while (true) {
|
|
7866
|
+
const [removeStart, removeEnd] = findFirstLineBreakOutsideComment(code.original.slice(start, end));
|
|
7867
|
+
if (removeStart === -1) {
|
|
7868
|
+
break;
|
|
7869
|
+
}
|
|
7870
|
+
code.remove(start + removeStart, (start += removeEnd));
|
|
7871
|
+
}
|
|
7872
|
+
}
|
|
7873
|
+
|
|
7874
|
+
class BlockScope extends ChildScope {
|
|
7875
|
+
addDeclaration(identifier, context, init, isHoisted) {
|
|
7876
|
+
if (isHoisted) {
|
|
7877
|
+
const variable = this.parent.addDeclaration(identifier, context, init, isHoisted);
|
|
7878
|
+
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
7879
|
+
// We cannot call deoptimizePath here.
|
|
7880
|
+
variable.markInitializersForDeoptimization();
|
|
7881
|
+
return variable;
|
|
8112
7882
|
}
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
return null;
|
|
7883
|
+
else {
|
|
7884
|
+
return super.addDeclaration(identifier, context, init, false);
|
|
8116
7885
|
}
|
|
8117
7886
|
}
|
|
8118
|
-
return currentGlobal[ValueProperties];
|
|
8119
7887
|
}
|
|
8120
7888
|
|
|
8121
|
-
class
|
|
7889
|
+
class ExpressionStatement extends NodeBase {
|
|
7890
|
+
initialise() {
|
|
7891
|
+
if (this.directive &&
|
|
7892
|
+
this.directive !== 'use strict' &&
|
|
7893
|
+
this.parent.type === Program$1) {
|
|
7894
|
+
this.context.warn(
|
|
7895
|
+
// This is necessary, because either way (deleting or not) can lead to errors.
|
|
7896
|
+
{
|
|
7897
|
+
code: 'MODULE_LEVEL_DIRECTIVE',
|
|
7898
|
+
message: `Module level directives cause errors when bundled, '${this.directive}' was ignored.`
|
|
7899
|
+
}, this.start);
|
|
7900
|
+
}
|
|
7901
|
+
}
|
|
7902
|
+
render(code, options) {
|
|
7903
|
+
super.render(code, options);
|
|
7904
|
+
if (this.included)
|
|
7905
|
+
this.insertSemicolon(code);
|
|
7906
|
+
}
|
|
7907
|
+
shouldBeIncluded(context) {
|
|
7908
|
+
if (this.directive && this.directive !== 'use strict')
|
|
7909
|
+
return this.parent.type !== Program$1;
|
|
7910
|
+
return super.shouldBeIncluded(context);
|
|
7911
|
+
}
|
|
7912
|
+
applyDeoptimizations() { }
|
|
7913
|
+
}
|
|
7914
|
+
|
|
7915
|
+
class BlockStatement extends NodeBase {
|
|
8122
7916
|
constructor() {
|
|
8123
7917
|
super(...arguments);
|
|
8124
|
-
|
|
8125
|
-
// been reassigned
|
|
8126
|
-
this.isReassigned = true;
|
|
7918
|
+
this.directlyIncluded = false;
|
|
8127
7919
|
}
|
|
8128
|
-
|
|
8129
|
-
|
|
7920
|
+
addImplicitReturnExpressionToScope() {
|
|
7921
|
+
const lastStatement = this.body[this.body.length - 1];
|
|
7922
|
+
if (!lastStatement || lastStatement.type !== ReturnStatement$1) {
|
|
7923
|
+
this.scope.addReturnExpression(UNKNOWN_EXPRESSION);
|
|
7924
|
+
}
|
|
8130
7925
|
}
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
7926
|
+
createScope(parentScope) {
|
|
7927
|
+
this.scope = this.parent.preventChildBlockScope
|
|
7928
|
+
? parentScope
|
|
7929
|
+
: new BlockScope(parentScope);
|
|
7930
|
+
}
|
|
7931
|
+
hasEffects(context) {
|
|
7932
|
+
if (this.deoptimizeBody)
|
|
7933
|
+
return true;
|
|
7934
|
+
for (const node of this.body) {
|
|
7935
|
+
if (context.brokenFlow)
|
|
7936
|
+
break;
|
|
7937
|
+
if (node.hasEffects(context))
|
|
7938
|
+
return true;
|
|
7939
|
+
}
|
|
7940
|
+
return false;
|
|
7941
|
+
}
|
|
7942
|
+
include(context, includeChildrenRecursively) {
|
|
7943
|
+
if (!(this.deoptimizeBody && this.directlyIncluded)) {
|
|
7944
|
+
this.included = true;
|
|
7945
|
+
this.directlyIncluded = true;
|
|
7946
|
+
if (this.deoptimizeBody)
|
|
7947
|
+
includeChildrenRecursively = true;
|
|
7948
|
+
for (const node of this.body) {
|
|
7949
|
+
if (includeChildrenRecursively || node.shouldBeIncluded(context))
|
|
7950
|
+
node.include(context, includeChildrenRecursively);
|
|
7951
|
+
}
|
|
8135
7952
|
}
|
|
8136
|
-
return !getGlobalAtPath([this.name, ...path].slice(0, -1));
|
|
8137
7953
|
}
|
|
8138
|
-
|
|
8139
|
-
const
|
|
8140
|
-
|
|
7954
|
+
initialise() {
|
|
7955
|
+
const firstBodyStatement = this.body[0];
|
|
7956
|
+
this.deoptimizeBody =
|
|
7957
|
+
firstBodyStatement instanceof ExpressionStatement &&
|
|
7958
|
+
firstBodyStatement.directive === 'use asm';
|
|
7959
|
+
}
|
|
7960
|
+
render(code, options) {
|
|
7961
|
+
if (this.body.length) {
|
|
7962
|
+
renderStatementList(this.body, code, this.start + 1, this.end - 1, options);
|
|
7963
|
+
}
|
|
7964
|
+
else {
|
|
7965
|
+
super.render(code, options);
|
|
7966
|
+
}
|
|
8141
7967
|
}
|
|
8142
7968
|
}
|
|
8143
7969
|
|
|
8144
|
-
|
|
8145
|
-
__proto__: null,
|
|
8146
|
-
class: true,
|
|
8147
|
-
const: true,
|
|
8148
|
-
let: true,
|
|
8149
|
-
var: true
|
|
8150
|
-
};
|
|
8151
|
-
class Identifier extends NodeBase {
|
|
7970
|
+
class RestElement extends NodeBase {
|
|
8152
7971
|
constructor() {
|
|
8153
7972
|
super(...arguments);
|
|
8154
|
-
this.
|
|
8155
|
-
this.isTDZAccess = null;
|
|
7973
|
+
this.declarationInit = null;
|
|
8156
7974
|
}
|
|
8157
7975
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
8158
|
-
|
|
8159
|
-
variables.push(this.variable);
|
|
8160
|
-
}
|
|
8161
|
-
}
|
|
8162
|
-
bind() {
|
|
8163
|
-
if (!this.variable && is_reference(this, this.parent)) {
|
|
8164
|
-
this.variable = this.scope.findVariable(this.name);
|
|
8165
|
-
this.variable.addReference(this);
|
|
8166
|
-
}
|
|
7976
|
+
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
8167
7977
|
}
|
|
8168
7978
|
declare(kind, init) {
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
break;
|
|
8188
|
-
case 'parameter':
|
|
8189
|
-
variable = this.scope.addParameterDeclaration(this);
|
|
8190
|
-
break;
|
|
8191
|
-
/* istanbul ignore next */
|
|
8192
|
-
default:
|
|
8193
|
-
/* istanbul ignore next */
|
|
8194
|
-
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
7979
|
+
this.declarationInit = init;
|
|
7980
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
7981
|
+
}
|
|
7982
|
+
deoptimizePath(path) {
|
|
7983
|
+
path.length === 0 && this.argument.deoptimizePath(EMPTY_PATH);
|
|
7984
|
+
}
|
|
7985
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7986
|
+
return (path.length > 0 ||
|
|
7987
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
7988
|
+
}
|
|
7989
|
+
markDeclarationReached() {
|
|
7990
|
+
this.argument.markDeclarationReached();
|
|
7991
|
+
}
|
|
7992
|
+
applyDeoptimizations() {
|
|
7993
|
+
this.deoptimized = true;
|
|
7994
|
+
if (this.declarationInit !== null) {
|
|
7995
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
7996
|
+
this.context.requestTreeshakingPass();
|
|
8195
7997
|
}
|
|
8196
|
-
variable.kind = kind;
|
|
8197
|
-
return [(this.variable = variable)];
|
|
8198
7998
|
}
|
|
8199
|
-
|
|
8200
|
-
|
|
7999
|
+
}
|
|
8000
|
+
|
|
8001
|
+
class FunctionBase extends NodeBase {
|
|
8002
|
+
constructor() {
|
|
8003
|
+
super(...arguments);
|
|
8004
|
+
this.objectEntity = null;
|
|
8005
|
+
this.deoptimizedReturn = false;
|
|
8201
8006
|
}
|
|
8202
8007
|
deoptimizePath(path) {
|
|
8203
|
-
|
|
8204
|
-
if (path.length ===
|
|
8205
|
-
|
|
8008
|
+
this.getObjectEntity().deoptimizePath(path);
|
|
8009
|
+
if (path.length === 1 && path[0] === UnknownKey) {
|
|
8010
|
+
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
8011
|
+
// which means the return expression needs to be reassigned
|
|
8012
|
+
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8206
8013
|
}
|
|
8207
|
-
// We keep conditional chaining because an unknown Node could have an
|
|
8208
|
-
// Identifier as property that might be deoptimized by default
|
|
8209
|
-
(_a = this.variable) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
8210
8014
|
}
|
|
8211
|
-
|
|
8212
|
-
|
|
8015
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8016
|
+
if (path.length > 0) {
|
|
8017
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8018
|
+
}
|
|
8213
8019
|
}
|
|
8214
8020
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8215
|
-
return this.
|
|
8021
|
+
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8216
8022
|
}
|
|
8217
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
8218
|
-
|
|
8023
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8024
|
+
if (path.length > 0) {
|
|
8025
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8026
|
+
}
|
|
8027
|
+
if (this.async) {
|
|
8028
|
+
if (!this.deoptimizedReturn) {
|
|
8029
|
+
this.deoptimizedReturn = true;
|
|
8030
|
+
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8031
|
+
this.context.requestTreeshakingPass();
|
|
8032
|
+
}
|
|
8033
|
+
return UNKNOWN_EXPRESSION;
|
|
8034
|
+
}
|
|
8035
|
+
return this.scope.getReturnExpression();
|
|
8219
8036
|
}
|
|
8220
|
-
|
|
8037
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8038
|
+
if (path.length > 0 || interaction.type !== INTERACTION_CALLED) {
|
|
8039
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8040
|
+
}
|
|
8041
|
+
if (this.async) {
|
|
8042
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8043
|
+
.treeshake;
|
|
8044
|
+
const returnExpression = this.scope.getReturnExpression();
|
|
8045
|
+
if (returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_CALL, context) ||
|
|
8046
|
+
(propertyReadSideEffects &&
|
|
8047
|
+
(propertyReadSideEffects === 'always' ||
|
|
8048
|
+
returnExpression.hasEffectsOnInteractionAtPath(['then'], NODE_INTERACTION_UNKNOWN_ACCESS, context)))) {
|
|
8049
|
+
return true;
|
|
8050
|
+
}
|
|
8051
|
+
}
|
|
8052
|
+
for (const param of this.params) {
|
|
8053
|
+
if (param.hasEffects(context))
|
|
8054
|
+
return true;
|
|
8055
|
+
}
|
|
8056
|
+
return false;
|
|
8057
|
+
}
|
|
8058
|
+
include(context, includeChildrenRecursively) {
|
|
8221
8059
|
if (!this.deoptimized)
|
|
8222
8060
|
this.applyDeoptimizations();
|
|
8223
|
-
|
|
8224
|
-
|
|
8061
|
+
this.included = true;
|
|
8062
|
+
const { brokenFlow } = context;
|
|
8063
|
+
context.brokenFlow = BROKEN_FLOW_NONE;
|
|
8064
|
+
this.body.include(context, includeChildrenRecursively);
|
|
8065
|
+
context.brokenFlow = brokenFlow;
|
|
8066
|
+
}
|
|
8067
|
+
includeCallArguments(context, args) {
|
|
8068
|
+
this.scope.includeCallArguments(context, args);
|
|
8069
|
+
}
|
|
8070
|
+
initialise() {
|
|
8071
|
+
this.scope.addParameterVariables(this.params.map(param => param.declare('parameter', UNKNOWN_EXPRESSION)), this.params[this.params.length - 1] instanceof RestElement);
|
|
8072
|
+
if (this.body instanceof BlockStatement) {
|
|
8073
|
+
this.body.addImplicitReturnExpressionToScope();
|
|
8074
|
+
}
|
|
8075
|
+
else {
|
|
8076
|
+
this.scope.addReturnExpression(this.body);
|
|
8225
8077
|
}
|
|
8226
|
-
return (this.context.options.treeshake.unknownGlobalSideEffects &&
|
|
8227
|
-
this.variable instanceof GlobalVariable &&
|
|
8228
|
-
this.variable.hasEffectsWhenAccessedAtPath(EMPTY_PATH));
|
|
8229
8078
|
}
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
this.
|
|
8079
|
+
parseNode(esTreeNode) {
|
|
8080
|
+
if (esTreeNode.body.type === BlockStatement$1) {
|
|
8081
|
+
this.body = new BlockStatement(esTreeNode.body, this, this.scope.hoistedBodyVarScope);
|
|
8082
|
+
}
|
|
8083
|
+
super.parseNode(esTreeNode);
|
|
8233
8084
|
}
|
|
8234
|
-
|
|
8235
|
-
|
|
8085
|
+
applyDeoptimizations() { }
|
|
8086
|
+
}
|
|
8087
|
+
FunctionBase.prototype.preventChildBlockScope = true;
|
|
8088
|
+
|
|
8089
|
+
class ArrowFunctionExpression extends FunctionBase {
|
|
8090
|
+
constructor() {
|
|
8091
|
+
super(...arguments);
|
|
8092
|
+
this.objectEntity = null;
|
|
8236
8093
|
}
|
|
8237
|
-
|
|
8238
|
-
|
|
8094
|
+
createScope(parentScope) {
|
|
8095
|
+
this.scope = new ReturnValueScope(parentScope, this.context);
|
|
8239
8096
|
}
|
|
8240
|
-
|
|
8097
|
+
hasEffects() {
|
|
8241
8098
|
if (!this.deoptimized)
|
|
8242
8099
|
this.applyDeoptimizations();
|
|
8243
|
-
|
|
8244
|
-
this.included = true;
|
|
8245
|
-
if (this.variable !== null) {
|
|
8246
|
-
this.context.includeVariableInModule(this.variable);
|
|
8247
|
-
}
|
|
8248
|
-
}
|
|
8249
|
-
}
|
|
8250
|
-
includeCallArguments(context, args) {
|
|
8251
|
-
this.variable.includeCallArguments(context, args);
|
|
8100
|
+
return false;
|
|
8252
8101
|
}
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
this.
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
// a variable accessed before its declaration
|
|
8269
|
-
// in the same function or at top level of module
|
|
8270
|
-
return (this.isTDZAccess = true);
|
|
8271
|
-
}
|
|
8272
|
-
if (!this.variable.initReached) {
|
|
8273
|
-
// Either a const/let TDZ violation or
|
|
8274
|
-
// var use before declaration was encountered.
|
|
8275
|
-
return (this.isTDZAccess = true);
|
|
8102
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8103
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8104
|
+
return true;
|
|
8105
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
8106
|
+
const { ignore, brokenFlow } = context;
|
|
8107
|
+
context.ignore = {
|
|
8108
|
+
breaks: false,
|
|
8109
|
+
continues: false,
|
|
8110
|
+
labels: new Set(),
|
|
8111
|
+
returnYield: true
|
|
8112
|
+
};
|
|
8113
|
+
if (this.body.hasEffects(context))
|
|
8114
|
+
return true;
|
|
8115
|
+
context.ignore = ignore;
|
|
8116
|
+
context.brokenFlow = brokenFlow;
|
|
8276
8117
|
}
|
|
8277
|
-
return
|
|
8278
|
-
}
|
|
8279
|
-
markDeclarationReached() {
|
|
8280
|
-
this.variable.initReached = true;
|
|
8118
|
+
return false;
|
|
8281
8119
|
}
|
|
8282
|
-
|
|
8283
|
-
|
|
8284
|
-
|
|
8285
|
-
if (
|
|
8286
|
-
|
|
8287
|
-
contentOnly: true,
|
|
8288
|
-
storeName: true
|
|
8289
|
-
});
|
|
8290
|
-
if (isShorthandProperty) {
|
|
8291
|
-
code.prependRight(this.start, `${this.name}: `);
|
|
8292
|
-
}
|
|
8293
|
-
}
|
|
8294
|
-
// In strict mode, any variable named "eval" must be the actual "eval" function
|
|
8295
|
-
if (name === 'eval' &&
|
|
8296
|
-
renderedParentType === CallExpression$1 &&
|
|
8297
|
-
isCalleeOfRenderedParent) {
|
|
8298
|
-
code.appendRight(this.start, '0, ');
|
|
8120
|
+
include(context, includeChildrenRecursively) {
|
|
8121
|
+
super.include(context, includeChildrenRecursively);
|
|
8122
|
+
for (const param of this.params) {
|
|
8123
|
+
if (!(param instanceof Identifier)) {
|
|
8124
|
+
param.include(context, includeChildrenRecursively);
|
|
8299
8125
|
}
|
|
8300
8126
|
}
|
|
8301
8127
|
}
|
|
8302
|
-
|
|
8303
|
-
this.
|
|
8304
|
-
|
|
8305
|
-
this.variable.consolidateInitializers();
|
|
8306
|
-
this.context.requestTreeshakingPass();
|
|
8128
|
+
getObjectEntity() {
|
|
8129
|
+
if (this.objectEntity !== null) {
|
|
8130
|
+
return this.objectEntity;
|
|
8307
8131
|
}
|
|
8132
|
+
return (this.objectEntity = new ObjectEntity([], OBJECT_PROTOTYPE));
|
|
8308
8133
|
}
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8134
|
+
}
|
|
8135
|
+
|
|
8136
|
+
function getSystemExportStatement(exportedVariables, { exportNamesByVariable, snippets: { _, getObject, getPropertyAccess } }, modifier = '') {
|
|
8137
|
+
if (exportedVariables.length === 1 &&
|
|
8138
|
+
exportNamesByVariable.get(exportedVariables[0]).length === 1) {
|
|
8139
|
+
const variable = exportedVariables[0];
|
|
8140
|
+
return `exports('${exportNamesByVariable.get(variable)}',${_}${variable.getName(getPropertyAccess)}${modifier})`;
|
|
8314
8141
|
}
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8142
|
+
else {
|
|
8143
|
+
const fields = [];
|
|
8144
|
+
for (const variable of exportedVariables) {
|
|
8145
|
+
for (const exportName of exportNamesByVariable.get(variable)) {
|
|
8146
|
+
fields.push([exportName, variable.getName(getPropertyAccess) + modifier]);
|
|
8147
|
+
}
|
|
8318
8148
|
}
|
|
8319
|
-
return
|
|
8149
|
+
return `exports(${getObject(fields, { lineBreakIndent: null })})`;
|
|
8320
8150
|
}
|
|
8321
8151
|
}
|
|
8322
|
-
function
|
|
8323
|
-
|
|
8324
|
-
|
|
8152
|
+
function renderSystemExportExpression(exportedVariable, expressionStart, expressionEnd, code, { exportNamesByVariable, snippets: { _ } }) {
|
|
8153
|
+
code.prependRight(expressionStart, `exports('${exportNamesByVariable.get(exportedVariable)}',${_}`);
|
|
8154
|
+
code.appendLeft(expressionEnd, ')');
|
|
8155
|
+
}
|
|
8156
|
+
function renderSystemExportFunction(exportedVariables, expressionStart, expressionEnd, needsParens, code, options) {
|
|
8157
|
+
const { _, getDirectReturnIifeLeft } = options.snippets;
|
|
8158
|
+
code.prependRight(expressionStart, getDirectReturnIifeLeft(['v'], `${getSystemExportStatement(exportedVariables, options)},${_}v`, { needsArrowReturnParens: true, needsWrappedFunction: needsParens }));
|
|
8159
|
+
code.appendLeft(expressionEnd, ')');
|
|
8160
|
+
}
|
|
8161
|
+
function renderSystemExportSequenceAfterExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options) {
|
|
8162
|
+
const { _, getPropertyAccess } = options.snippets;
|
|
8163
|
+
code.appendLeft(expressionEnd, `,${_}${getSystemExportStatement([exportedVariable], options)},${_}${exportedVariable.getName(getPropertyAccess)}`);
|
|
8164
|
+
if (needsParens) {
|
|
8165
|
+
code.prependRight(expressionStart, '(');
|
|
8166
|
+
code.appendLeft(expressionEnd, ')');
|
|
8167
|
+
}
|
|
8168
|
+
}
|
|
8169
|
+
function renderSystemExportSequenceBeforeExpression(exportedVariable, expressionStart, expressionEnd, needsParens, code, options, modifier) {
|
|
8170
|
+
const { _ } = options.snippets;
|
|
8171
|
+
code.prependRight(expressionStart, `${getSystemExportStatement([exportedVariable], options, modifier)},${_}`);
|
|
8172
|
+
if (needsParens) {
|
|
8173
|
+
code.prependRight(expressionStart, '(');
|
|
8174
|
+
code.appendLeft(expressionEnd, ')');
|
|
8325
8175
|
}
|
|
8326
|
-
// one of: ArrowFunctionExpression, FunctionDeclaration, FunctionExpression or Program
|
|
8327
|
-
return node;
|
|
8328
8176
|
}
|
|
8329
8177
|
|
|
8330
8178
|
class ObjectPattern extends NodeBase {
|
|
@@ -8352,11 +8200,12 @@ class ObjectPattern extends NodeBase {
|
|
|
8352
8200
|
}
|
|
8353
8201
|
}
|
|
8354
8202
|
}
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8203
|
+
hasEffectsOnInteractionAtPath(
|
|
8204
|
+
// At the moment, this is only triggered for assignment left-hand sides,
|
|
8205
|
+
// where the path is empty
|
|
8206
|
+
_path, interaction, context) {
|
|
8358
8207
|
for (const property of this.properties) {
|
|
8359
|
-
if (property.
|
|
8208
|
+
if (property.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context))
|
|
8360
8209
|
return true;
|
|
8361
8210
|
}
|
|
8362
8211
|
return false;
|
|
@@ -8370,75 +8219,78 @@ class ObjectPattern extends NodeBase {
|
|
|
8370
8219
|
|
|
8371
8220
|
class AssignmentExpression extends NodeBase {
|
|
8372
8221
|
hasEffects(context) {
|
|
8373
|
-
|
|
8222
|
+
const { deoptimized, left, right } = this;
|
|
8223
|
+
if (!deoptimized)
|
|
8374
8224
|
this.applyDeoptimizations();
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8225
|
+
// MemberExpressions do not access the property before assignments if the
|
|
8226
|
+
// operator is '='.
|
|
8227
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, this.operator !== '='));
|
|
8378
8228
|
}
|
|
8379
|
-
|
|
8380
|
-
return
|
|
8229
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8230
|
+
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8381
8231
|
}
|
|
8382
8232
|
include(context, includeChildrenRecursively) {
|
|
8383
|
-
|
|
8233
|
+
const { deoptimized, left, right, operator } = this;
|
|
8234
|
+
if (!deoptimized)
|
|
8384
8235
|
this.applyDeoptimizations();
|
|
8385
8236
|
this.included = true;
|
|
8386
|
-
let hasEffectsContext;
|
|
8387
8237
|
if (includeChildrenRecursively ||
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
(
|
|
8391
|
-
|
|
8392
|
-
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, hasEffectsContext))) {
|
|
8393
|
-
this.left.include(context, includeChildrenRecursively);
|
|
8238
|
+
operator !== '=' ||
|
|
8239
|
+
left.included ||
|
|
8240
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
8241
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
8394
8242
|
}
|
|
8395
|
-
|
|
8243
|
+
right.include(context, includeChildrenRecursively);
|
|
8244
|
+
}
|
|
8245
|
+
initialise() {
|
|
8246
|
+
this.left.setAssignedValue(this.right);
|
|
8396
8247
|
}
|
|
8397
8248
|
render(code, options, { preventASI, renderedParentType, renderedSurroundingElement } = BLANK) {
|
|
8398
|
-
|
|
8399
|
-
|
|
8400
|
-
|
|
8249
|
+
const { left, right, start, end, parent } = this;
|
|
8250
|
+
if (left.included) {
|
|
8251
|
+
left.render(code, options);
|
|
8252
|
+
right.render(code, options);
|
|
8401
8253
|
}
|
|
8402
8254
|
else {
|
|
8403
|
-
const inclusionStart = findNonWhiteSpace(code.original, findFirstOccurrenceOutsideComment(code.original, '=',
|
|
8404
|
-
code.remove(
|
|
8255
|
+
const inclusionStart = findNonWhiteSpace(code.original, findFirstOccurrenceOutsideComment(code.original, '=', left.end) + 1);
|
|
8256
|
+
code.remove(start, inclusionStart);
|
|
8405
8257
|
if (preventASI) {
|
|
8406
|
-
removeLineBreaks(code, inclusionStart,
|
|
8258
|
+
removeLineBreaks(code, inclusionStart, right.start);
|
|
8407
8259
|
}
|
|
8408
|
-
|
|
8409
|
-
renderedParentType: renderedParentType ||
|
|
8410
|
-
renderedSurroundingElement: renderedSurroundingElement ||
|
|
8260
|
+
right.render(code, options, {
|
|
8261
|
+
renderedParentType: renderedParentType || parent.type,
|
|
8262
|
+
renderedSurroundingElement: renderedSurroundingElement || parent.type
|
|
8411
8263
|
});
|
|
8412
8264
|
}
|
|
8413
8265
|
if (options.format === 'system') {
|
|
8414
|
-
if (
|
|
8415
|
-
const variable =
|
|
8266
|
+
if (left instanceof Identifier) {
|
|
8267
|
+
const variable = left.variable;
|
|
8416
8268
|
const exportNames = options.exportNamesByVariable.get(variable);
|
|
8417
8269
|
if (exportNames) {
|
|
8418
8270
|
if (exportNames.length === 1) {
|
|
8419
|
-
renderSystemExportExpression(variable,
|
|
8271
|
+
renderSystemExportExpression(variable, start, end, code, options);
|
|
8420
8272
|
}
|
|
8421
8273
|
else {
|
|
8422
|
-
renderSystemExportSequenceAfterExpression(variable,
|
|
8274
|
+
renderSystemExportSequenceAfterExpression(variable, start, end, parent.type !== ExpressionStatement$1, code, options);
|
|
8423
8275
|
}
|
|
8424
8276
|
return;
|
|
8425
8277
|
}
|
|
8426
8278
|
}
|
|
8427
8279
|
else {
|
|
8428
8280
|
const systemPatternExports = [];
|
|
8429
|
-
|
|
8281
|
+
left.addExportedVariables(systemPatternExports, options.exportNamesByVariable);
|
|
8430
8282
|
if (systemPatternExports.length > 0) {
|
|
8431
|
-
renderSystemExportFunction(systemPatternExports,
|
|
8283
|
+
renderSystemExportFunction(systemPatternExports, start, end, renderedSurroundingElement === ExpressionStatement$1, code, options);
|
|
8432
8284
|
return;
|
|
8433
8285
|
}
|
|
8434
8286
|
}
|
|
8435
8287
|
}
|
|
8436
|
-
if (
|
|
8437
|
-
|
|
8288
|
+
if (left.included &&
|
|
8289
|
+
left instanceof ObjectPattern &&
|
|
8438
8290
|
(renderedSurroundingElement === ExpressionStatement$1 ||
|
|
8439
8291
|
renderedSurroundingElement === ArrowFunctionExpression$1)) {
|
|
8440
|
-
code.appendRight(
|
|
8441
|
-
code.prependLeft(
|
|
8292
|
+
code.appendRight(start, '(');
|
|
8293
|
+
code.prependLeft(end, ')');
|
|
8442
8294
|
}
|
|
8443
8295
|
}
|
|
8444
8296
|
applyDeoptimizations() {
|
|
@@ -8449,18 +8301,40 @@ class AssignmentExpression extends NodeBase {
|
|
|
8449
8301
|
}
|
|
8450
8302
|
}
|
|
8451
8303
|
|
|
8304
|
+
class AssignmentPattern extends NodeBase {
|
|
8305
|
+
addExportedVariables(variables, exportNamesByVariable) {
|
|
8306
|
+
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
8307
|
+
}
|
|
8308
|
+
declare(kind, init) {
|
|
8309
|
+
return this.left.declare(kind, init);
|
|
8310
|
+
}
|
|
8311
|
+
deoptimizePath(path) {
|
|
8312
|
+
path.length === 0 && this.left.deoptimizePath(path);
|
|
8313
|
+
}
|
|
8314
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8315
|
+
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
8316
|
+
}
|
|
8317
|
+
markDeclarationReached() {
|
|
8318
|
+
this.left.markDeclarationReached();
|
|
8319
|
+
}
|
|
8320
|
+
render(code, options, { isShorthandProperty } = BLANK) {
|
|
8321
|
+
this.left.render(code, options, { isShorthandProperty });
|
|
8322
|
+
this.right.render(code, options);
|
|
8323
|
+
}
|
|
8324
|
+
applyDeoptimizations() {
|
|
8325
|
+
this.deoptimized = true;
|
|
8326
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
8327
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
8328
|
+
this.context.requestTreeshakingPass();
|
|
8329
|
+
}
|
|
8330
|
+
}
|
|
8331
|
+
|
|
8452
8332
|
class ArgumentsVariable extends LocalVariable {
|
|
8453
8333
|
constructor(context) {
|
|
8454
8334
|
super('arguments', null, UNKNOWN_EXPRESSION, context);
|
|
8455
8335
|
}
|
|
8456
|
-
|
|
8457
|
-
return path.length > 1;
|
|
8458
|
-
}
|
|
8459
|
-
hasEffectsWhenAssignedAtPath() {
|
|
8460
|
-
return true;
|
|
8461
|
-
}
|
|
8462
|
-
hasEffectsWhenCalledAtPath() {
|
|
8463
|
-
return true;
|
|
8336
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8337
|
+
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8464
8338
|
}
|
|
8465
8339
|
}
|
|
8466
8340
|
|
|
@@ -8476,8 +8350,8 @@ class ThisVariable extends LocalVariable {
|
|
|
8476
8350
|
for (const path of this.deoptimizedPaths) {
|
|
8477
8351
|
entity.deoptimizePath(path);
|
|
8478
8352
|
}
|
|
8479
|
-
for (const
|
|
8480
|
-
|
|
8353
|
+
for (const { interaction, path } of this.thisDeoptimizationList) {
|
|
8354
|
+
entity.deoptimizeThisOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
8481
8355
|
}
|
|
8482
8356
|
this.entitiesToBeDeoptimized.add(entity);
|
|
8483
8357
|
}
|
|
@@ -8491,29 +8365,21 @@ class ThisVariable extends LocalVariable {
|
|
|
8491
8365
|
entity.deoptimizePath(path);
|
|
8492
8366
|
}
|
|
8493
8367
|
}
|
|
8494
|
-
|
|
8368
|
+
deoptimizeThisOnInteractionAtPath(interaction, path) {
|
|
8495
8369
|
const thisDeoptimization = {
|
|
8496
|
-
|
|
8497
|
-
path
|
|
8498
|
-
thisParameter
|
|
8370
|
+
interaction,
|
|
8371
|
+
path
|
|
8499
8372
|
};
|
|
8500
|
-
if (!this.thisDeoptimizations.trackEntityAtPathAndGetIfTracked(path,
|
|
8373
|
+
if (!this.thisDeoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.type, interaction.thisArg)) {
|
|
8501
8374
|
for (const entity of this.entitiesToBeDeoptimized) {
|
|
8502
|
-
|
|
8375
|
+
entity.deoptimizeThisOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
8503
8376
|
}
|
|
8504
8377
|
this.thisDeoptimizationList.push(thisDeoptimization);
|
|
8505
8378
|
}
|
|
8506
8379
|
}
|
|
8507
|
-
|
|
8508
|
-
return (this.getInit(context).
|
|
8509
|
-
super.
|
|
8510
|
-
}
|
|
8511
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8512
|
-
return (this.getInit(context).hasEffectsWhenAssignedAtPath(path, context) ||
|
|
8513
|
-
super.hasEffectsWhenAssignedAtPath(path, context));
|
|
8514
|
-
}
|
|
8515
|
-
applyThisDeoptimizationEvent(entity, { event, path, thisParameter }) {
|
|
8516
|
-
entity.deoptimizeThisOnEventAtPath(event, path, thisParameter === this ? entity : thisParameter, SHARED_RECURSION_TRACKER);
|
|
8380
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8381
|
+
return (this.getInit(context).hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
8382
|
+
super.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
8517
8383
|
}
|
|
8518
8384
|
getInit(context) {
|
|
8519
8385
|
return context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION;
|
|
@@ -8549,50 +8415,56 @@ class FunctionNode extends FunctionBase {
|
|
|
8549
8415
|
createScope(parentScope) {
|
|
8550
8416
|
this.scope = new FunctionScope(parentScope, this.context);
|
|
8551
8417
|
}
|
|
8552
|
-
|
|
8553
|
-
super.
|
|
8554
|
-
if (
|
|
8555
|
-
this.scope.thisVariable.addEntityToBeDeoptimized(
|
|
8418
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8419
|
+
super.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8420
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
8421
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.thisArg);
|
|
8556
8422
|
}
|
|
8557
8423
|
}
|
|
8558
|
-
hasEffects() {
|
|
8424
|
+
hasEffects(context) {
|
|
8559
8425
|
var _a;
|
|
8560
8426
|
if (!this.deoptimized)
|
|
8561
8427
|
this.applyDeoptimizations();
|
|
8562
|
-
return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects());
|
|
8428
|
+
return !!((_a = this.id) === null || _a === void 0 ? void 0 : _a.hasEffects(context));
|
|
8563
8429
|
}
|
|
8564
|
-
|
|
8565
|
-
if (super.
|
|
8566
|
-
return true;
|
|
8567
|
-
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
8568
|
-
context.replacedVariableInits.set(this.scope.thisVariable, callOptions.withNew
|
|
8569
|
-
? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
|
|
8570
|
-
: UNKNOWN_EXPRESSION);
|
|
8571
|
-
const { brokenFlow, ignore } = context;
|
|
8572
|
-
context.ignore = {
|
|
8573
|
-
breaks: false,
|
|
8574
|
-
continues: false,
|
|
8575
|
-
labels: new Set(),
|
|
8576
|
-
returnYield: true
|
|
8577
|
-
};
|
|
8578
|
-
if (this.body.hasEffects(context))
|
|
8430
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8431
|
+
if (super.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
8579
8432
|
return true;
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
context.replacedVariableInits.set(this.scope.thisVariable,
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
context
|
|
8433
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
8434
|
+
const thisInit = context.replacedVariableInits.get(this.scope.thisVariable);
|
|
8435
|
+
context.replacedVariableInits.set(this.scope.thisVariable, interaction.withNew
|
|
8436
|
+
? new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE)
|
|
8437
|
+
: UNKNOWN_EXPRESSION);
|
|
8438
|
+
const { brokenFlow, ignore } = context;
|
|
8439
|
+
context.ignore = {
|
|
8440
|
+
breaks: false,
|
|
8441
|
+
continues: false,
|
|
8442
|
+
labels: new Set(),
|
|
8443
|
+
returnYield: true
|
|
8444
|
+
};
|
|
8445
|
+
if (this.body.hasEffects(context))
|
|
8446
|
+
return true;
|
|
8447
|
+
context.brokenFlow = brokenFlow;
|
|
8448
|
+
if (thisInit) {
|
|
8449
|
+
context.replacedVariableInits.set(this.scope.thisVariable, thisInit);
|
|
8450
|
+
}
|
|
8451
|
+
else {
|
|
8452
|
+
context.replacedVariableInits.delete(this.scope.thisVariable);
|
|
8453
|
+
}
|
|
8454
|
+
context.ignore = ignore;
|
|
8586
8455
|
}
|
|
8587
|
-
context.ignore = ignore;
|
|
8588
8456
|
return false;
|
|
8589
8457
|
}
|
|
8590
|
-
include(context, includeChildrenRecursively
|
|
8458
|
+
include(context, includeChildrenRecursively) {
|
|
8591
8459
|
var _a;
|
|
8460
|
+
super.include(context, includeChildrenRecursively);
|
|
8592
8461
|
(_a = this.id) === null || _a === void 0 ? void 0 : _a.include();
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
|
|
8462
|
+
const hasArguments = this.scope.argumentsVariable.included;
|
|
8463
|
+
for (const param of this.params) {
|
|
8464
|
+
if (!(param instanceof Identifier) || hasArguments) {
|
|
8465
|
+
param.include(context, includeChildrenRecursively);
|
|
8466
|
+
}
|
|
8467
|
+
}
|
|
8596
8468
|
}
|
|
8597
8469
|
initialise() {
|
|
8598
8470
|
var _a;
|
|
@@ -8683,12 +8555,13 @@ class BinaryExpression extends NodeBase {
|
|
|
8683
8555
|
// support some implicit type coercion runtime errors
|
|
8684
8556
|
if (this.operator === '+' &&
|
|
8685
8557
|
this.parent instanceof ExpressionStatement &&
|
|
8686
|
-
this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) === '')
|
|
8558
|
+
this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) === '') {
|
|
8687
8559
|
return true;
|
|
8560
|
+
}
|
|
8688
8561
|
return super.hasEffects(context);
|
|
8689
8562
|
}
|
|
8690
|
-
|
|
8691
|
-
return path.length > 1;
|
|
8563
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
8564
|
+
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
8692
8565
|
}
|
|
8693
8566
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
8694
8567
|
this.left.render(code, options, { renderedSurroundingElement });
|
|
@@ -8721,8 +8594,33 @@ class BreakStatement extends NodeBase {
|
|
|
8721
8594
|
}
|
|
8722
8595
|
}
|
|
8723
8596
|
|
|
8597
|
+
function renderCallArguments(code, options, node) {
|
|
8598
|
+
if (node.arguments.length > 0) {
|
|
8599
|
+
if (node.arguments[node.arguments.length - 1].included) {
|
|
8600
|
+
for (const arg of node.arguments) {
|
|
8601
|
+
arg.render(code, options);
|
|
8602
|
+
}
|
|
8603
|
+
}
|
|
8604
|
+
else {
|
|
8605
|
+
let lastIncludedIndex = node.arguments.length - 2;
|
|
8606
|
+
while (lastIncludedIndex >= 0 && !node.arguments[lastIncludedIndex].included) {
|
|
8607
|
+
lastIncludedIndex--;
|
|
8608
|
+
}
|
|
8609
|
+
if (lastIncludedIndex >= 0) {
|
|
8610
|
+
for (let index = 0; index <= lastIncludedIndex; index++) {
|
|
8611
|
+
node.arguments[index].render(code, options);
|
|
8612
|
+
}
|
|
8613
|
+
code.remove(findFirstOccurrenceOutsideComment(code.original, ',', node.arguments[lastIncludedIndex].end), node.end - 1);
|
|
8614
|
+
}
|
|
8615
|
+
else {
|
|
8616
|
+
code.remove(findFirstOccurrenceOutsideComment(code.original, '(', node.callee.end) + 1, node.end - 1);
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
}
|
|
8620
|
+
}
|
|
8621
|
+
|
|
8724
8622
|
class Literal extends NodeBase {
|
|
8725
|
-
|
|
8623
|
+
deoptimizeThisOnInteractionAtPath() { }
|
|
8726
8624
|
getLiteralValueAtPath(path) {
|
|
8727
8625
|
if (path.length > 0 ||
|
|
8728
8626
|
// unknown literals can also be null but do not start with an "n"
|
|
@@ -8739,17 +8637,16 @@ class Literal extends NodeBase {
|
|
|
8739
8637
|
return UNKNOWN_EXPRESSION;
|
|
8740
8638
|
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
8741
8639
|
}
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8640
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8641
|
+
switch (interaction.type) {
|
|
8642
|
+
case INTERACTION_ACCESSED:
|
|
8643
|
+
return path.length > (this.value === null ? 0 : 1);
|
|
8644
|
+
case INTERACTION_ASSIGNED:
|
|
8645
|
+
return true;
|
|
8646
|
+
case INTERACTION_CALLED:
|
|
8647
|
+
return (path.length !== 1 ||
|
|
8648
|
+
hasMemberEffectWhenCalled(this.members, path[0], interaction, context));
|
|
8751
8649
|
}
|
|
8752
|
-
return true;
|
|
8753
8650
|
}
|
|
8754
8651
|
initialise() {
|
|
8755
8652
|
this.members = getLiteralMembersForValue(this.value);
|
|
@@ -8807,6 +8704,7 @@ class MemberExpression extends NodeBase {
|
|
|
8807
8704
|
constructor() {
|
|
8808
8705
|
super(...arguments);
|
|
8809
8706
|
this.variable = null;
|
|
8707
|
+
this.assignmentDeoptimized = false;
|
|
8810
8708
|
this.bound = false;
|
|
8811
8709
|
this.expressionsToBeDeoptimized = [];
|
|
8812
8710
|
this.replacement = null;
|
|
@@ -8816,7 +8714,7 @@ class MemberExpression extends NodeBase {
|
|
|
8816
8714
|
const path = getPathIfNotComputed(this);
|
|
8817
8715
|
const baseVariable = path && this.scope.findVariable(path[0].key);
|
|
8818
8716
|
if (baseVariable && baseVariable.isNamespace) {
|
|
8819
|
-
const resolvedVariable =
|
|
8717
|
+
const resolvedVariable = resolveNamespaceVariables(baseVariable, path.slice(1), this.context);
|
|
8820
8718
|
if (!resolvedVariable) {
|
|
8821
8719
|
super.bind();
|
|
8822
8720
|
}
|
|
@@ -8857,21 +8755,21 @@ class MemberExpression extends NodeBase {
|
|
|
8857
8755
|
}
|
|
8858
8756
|
}
|
|
8859
8757
|
}
|
|
8860
|
-
|
|
8758
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8861
8759
|
if (this.variable) {
|
|
8862
|
-
this.variable.
|
|
8760
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8863
8761
|
}
|
|
8864
8762
|
else if (!this.replacement) {
|
|
8865
8763
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8866
|
-
this.object.
|
|
8764
|
+
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
8867
8765
|
}
|
|
8868
8766
|
else {
|
|
8869
|
-
|
|
8767
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
8870
8768
|
}
|
|
8871
8769
|
}
|
|
8872
8770
|
}
|
|
8873
8771
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8874
|
-
if (this.variable
|
|
8772
|
+
if (this.variable) {
|
|
8875
8773
|
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8876
8774
|
}
|
|
8877
8775
|
if (this.replacement) {
|
|
@@ -8883,81 +8781,62 @@ class MemberExpression extends NodeBase {
|
|
|
8883
8781
|
}
|
|
8884
8782
|
return UnknownValue;
|
|
8885
8783
|
}
|
|
8886
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
8887
|
-
if (this.variable
|
|
8888
|
-
return this.variable.getReturnExpressionWhenCalledAtPath(path,
|
|
8784
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
8785
|
+
if (this.variable) {
|
|
8786
|
+
return this.variable.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
8889
8787
|
}
|
|
8890
8788
|
if (this.replacement) {
|
|
8891
8789
|
return UNKNOWN_EXPRESSION;
|
|
8892
8790
|
}
|
|
8893
8791
|
this.expressionsToBeDeoptimized.push(origin);
|
|
8894
8792
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8895
|
-
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path],
|
|
8793
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
8896
8794
|
}
|
|
8897
8795
|
return UNKNOWN_EXPRESSION;
|
|
8898
8796
|
}
|
|
8899
8797
|
hasEffects(context) {
|
|
8900
8798
|
if (!this.deoptimized)
|
|
8901
8799
|
this.applyDeoptimizations();
|
|
8902
|
-
const { propertyReadSideEffects } = this.context.options
|
|
8903
|
-
.treeshake;
|
|
8904
8800
|
return (this.property.hasEffects(context) ||
|
|
8905
8801
|
this.object.hasEffects(context) ||
|
|
8906
|
-
|
|
8907
|
-
(!(this.variable ||
|
|
8908
|
-
this.replacement ||
|
|
8909
|
-
(this.parent instanceof AssignmentExpression && this.parent.operator === '=')) &&
|
|
8910
|
-
propertyReadSideEffects &&
|
|
8911
|
-
(propertyReadSideEffects === 'always' ||
|
|
8912
|
-
this.object.hasEffectsWhenAccessedAtPath([this.getPropertyKey()], context))));
|
|
8913
|
-
}
|
|
8914
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
8915
|
-
if (this.variable !== null) {
|
|
8916
|
-
return this.variable.hasEffectsWhenAccessedAtPath(path, context);
|
|
8917
|
-
}
|
|
8918
|
-
if (this.replacement) {
|
|
8919
|
-
return true;
|
|
8920
|
-
}
|
|
8921
|
-
if (path.length < MAX_PATH_DEPTH) {
|
|
8922
|
-
return this.object.hasEffectsWhenAccessedAtPath([this.getPropertyKey(), ...path], context);
|
|
8923
|
-
}
|
|
8924
|
-
return true;
|
|
8802
|
+
this.hasAccessEffect(context));
|
|
8925
8803
|
}
|
|
8926
|
-
|
|
8927
|
-
if (this.
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
}
|
|
8936
|
-
return true;
|
|
8804
|
+
hasEffectsAsAssignmentTarget(context, checkAccess) {
|
|
8805
|
+
if (checkAccess && !this.deoptimized)
|
|
8806
|
+
this.applyDeoptimizations();
|
|
8807
|
+
if (!this.assignmentDeoptimized)
|
|
8808
|
+
this.applyAssignmentDeoptimization();
|
|
8809
|
+
return (this.property.hasEffects(context) ||
|
|
8810
|
+
this.object.hasEffects(context) ||
|
|
8811
|
+
(checkAccess && this.hasAccessEffect(context)) ||
|
|
8812
|
+
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
8937
8813
|
}
|
|
8938
|
-
|
|
8939
|
-
if (this.variable
|
|
8940
|
-
return this.variable.
|
|
8814
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
8815
|
+
if (this.variable) {
|
|
8816
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
8941
8817
|
}
|
|
8942
8818
|
if (this.replacement) {
|
|
8943
8819
|
return true;
|
|
8944
8820
|
}
|
|
8945
8821
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8946
|
-
return this.object.
|
|
8822
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
8947
8823
|
}
|
|
8948
8824
|
return true;
|
|
8949
8825
|
}
|
|
8950
8826
|
include(context, includeChildrenRecursively) {
|
|
8951
8827
|
if (!this.deoptimized)
|
|
8952
8828
|
this.applyDeoptimizations();
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8829
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8830
|
+
}
|
|
8831
|
+
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
8832
|
+
if (!this.assignmentDeoptimized)
|
|
8833
|
+
this.applyAssignmentDeoptimization();
|
|
8834
|
+
if (deoptimizeAccess) {
|
|
8835
|
+
this.include(context, includeChildrenRecursively);
|
|
8836
|
+
}
|
|
8837
|
+
else {
|
|
8838
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8958
8839
|
}
|
|
8959
|
-
this.object.include(context, includeChildrenRecursively);
|
|
8960
|
-
this.property.include(context, includeChildrenRecursively);
|
|
8961
8840
|
}
|
|
8962
8841
|
includeCallArguments(context, args) {
|
|
8963
8842
|
if (this.variable) {
|
|
@@ -8969,6 +8848,7 @@ class MemberExpression extends NodeBase {
|
|
|
8969
8848
|
}
|
|
8970
8849
|
initialise() {
|
|
8971
8850
|
this.propertyKey = getResolvablePropertyKey(this);
|
|
8851
|
+
this.accessInteraction = { thisArg: this.object, type: INTERACTION_ACCESSED };
|
|
8972
8852
|
}
|
|
8973
8853
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = BLANK) {
|
|
8974
8854
|
if (this.variable || this.replacement) {
|
|
@@ -8989,8 +8869,29 @@ class MemberExpression extends NodeBase {
|
|
|
8989
8869
|
this.property.render(code, options);
|
|
8990
8870
|
}
|
|
8991
8871
|
}
|
|
8992
|
-
|
|
8993
|
-
this.
|
|
8872
|
+
setAssignedValue(value) {
|
|
8873
|
+
this.assignmentInteraction = {
|
|
8874
|
+
args: [value],
|
|
8875
|
+
thisArg: this.object,
|
|
8876
|
+
type: INTERACTION_ASSIGNED
|
|
8877
|
+
};
|
|
8878
|
+
}
|
|
8879
|
+
applyDeoptimizations() {
|
|
8880
|
+
this.deoptimized = true;
|
|
8881
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8882
|
+
.treeshake;
|
|
8883
|
+
if (
|
|
8884
|
+
// Namespaces are not bound and should not be deoptimized
|
|
8885
|
+
this.bound &&
|
|
8886
|
+
propertyReadSideEffects &&
|
|
8887
|
+
!(this.variable || this.replacement)) {
|
|
8888
|
+
const propertyKey = this.getPropertyKey();
|
|
8889
|
+
this.object.deoptimizeThisOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
8890
|
+
this.context.requestTreeshakingPass();
|
|
8891
|
+
}
|
|
8892
|
+
}
|
|
8893
|
+
applyAssignmentDeoptimization() {
|
|
8894
|
+
this.assignmentDeoptimized = true;
|
|
8994
8895
|
const { propertyReadSideEffects } = this.context.options
|
|
8995
8896
|
.treeshake;
|
|
8996
8897
|
if (
|
|
@@ -8998,13 +8899,7 @@ class MemberExpression extends NodeBase {
|
|
|
8998
8899
|
this.bound &&
|
|
8999
8900
|
propertyReadSideEffects &&
|
|
9000
8901
|
!(this.variable || this.replacement)) {
|
|
9001
|
-
|
|
9002
|
-
if (!(this.parent instanceof AssignmentExpression && this.parent.operator === '=')) {
|
|
9003
|
-
this.object.deoptimizeThisOnEventAtPath(EVENT_ACCESSED, [this.propertyKey], this.object, SHARED_RECURSION_TRACKER);
|
|
9004
|
-
}
|
|
9005
|
-
if (this.parent instanceof AssignmentExpression) {
|
|
9006
|
-
this.object.deoptimizeThisOnEventAtPath(EVENT_ASSIGNED, [this.propertyKey], this.object, SHARED_RECURSION_TRACKER);
|
|
9007
|
-
}
|
|
8902
|
+
this.object.deoptimizeThisOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
9008
8903
|
this.context.requestTreeshakingPass();
|
|
9009
8904
|
}
|
|
9010
8905
|
}
|
|
@@ -9030,28 +8925,46 @@ class MemberExpression extends NodeBase {
|
|
|
9030
8925
|
}
|
|
9031
8926
|
return this.propertyKey;
|
|
9032
8927
|
}
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
missing: exportName,
|
|
9048
|
-
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
9049
|
-
}, path[0].pos);
|
|
9050
|
-
return 'undefined';
|
|
8928
|
+
hasAccessEffect(context) {
|
|
8929
|
+
const { propertyReadSideEffects } = this.context.options
|
|
8930
|
+
.treeshake;
|
|
8931
|
+
return (!(this.variable || this.replacement) &&
|
|
8932
|
+
propertyReadSideEffects &&
|
|
8933
|
+
(propertyReadSideEffects === 'always' ||
|
|
8934
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
8935
|
+
}
|
|
8936
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
8937
|
+
if (!this.included) {
|
|
8938
|
+
this.included = true;
|
|
8939
|
+
if (this.variable) {
|
|
8940
|
+
this.context.includeVariableInModule(this.variable);
|
|
8941
|
+
}
|
|
9051
8942
|
}
|
|
9052
|
-
|
|
8943
|
+
this.object.include(context, includeChildrenRecursively);
|
|
8944
|
+
this.property.include(context, includeChildrenRecursively);
|
|
9053
8945
|
}
|
|
9054
8946
|
}
|
|
8947
|
+
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
8948
|
+
if (path.length === 0)
|
|
8949
|
+
return baseVariable;
|
|
8950
|
+
if (!baseVariable.isNamespace || baseVariable instanceof ExternalVariable)
|
|
8951
|
+
return null;
|
|
8952
|
+
const exportName = path[0].key;
|
|
8953
|
+
const variable = baseVariable.context.traceExport(exportName);
|
|
8954
|
+
if (!variable) {
|
|
8955
|
+
const fileName = baseVariable.context.fileName;
|
|
8956
|
+
astContext.warn({
|
|
8957
|
+
code: 'MISSING_EXPORT',
|
|
8958
|
+
exporter: relativeId(fileName),
|
|
8959
|
+
importer: relativeId(astContext.fileName),
|
|
8960
|
+
message: `'${exportName}' is not exported by '${relativeId(fileName)}'`,
|
|
8961
|
+
missing: exportName,
|
|
8962
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
8963
|
+
}, path[0].pos);
|
|
8964
|
+
return 'undefined';
|
|
8965
|
+
}
|
|
8966
|
+
return resolveNamespaceVariables(variable, path.slice(1), astContext);
|
|
8967
|
+
}
|
|
9055
8968
|
|
|
9056
8969
|
class CallExpressionBase extends NodeBase {
|
|
9057
8970
|
constructor() {
|
|
@@ -9081,15 +8994,15 @@ class CallExpressionBase extends NodeBase {
|
|
|
9081
8994
|
returnExpression.deoptimizePath(path);
|
|
9082
8995
|
}
|
|
9083
8996
|
}
|
|
9084
|
-
|
|
8997
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9085
8998
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9086
8999
|
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
9087
|
-
|
|
9000
|
+
interaction.thisArg.deoptimizePath(UNKNOWN_PATH);
|
|
9088
9001
|
}
|
|
9089
9002
|
else {
|
|
9090
9003
|
recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9091
|
-
this.expressionsToBeDeoptimized.add(
|
|
9092
|
-
returnExpression.
|
|
9004
|
+
this.expressionsToBeDeoptimized.add(interaction.thisArg);
|
|
9005
|
+
returnExpression.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9093
9006
|
}, undefined);
|
|
9094
9007
|
}
|
|
9095
9008
|
}
|
|
@@ -9103,27 +9016,31 @@ class CallExpressionBase extends NodeBase {
|
|
|
9103
9016
|
return returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9104
9017
|
}, UnknownValue);
|
|
9105
9018
|
}
|
|
9106
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9019
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9107
9020
|
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
9108
9021
|
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
9109
9022
|
return UNKNOWN_EXPRESSION;
|
|
9110
9023
|
}
|
|
9111
9024
|
return recursionTracker.withTrackedEntityAtPath(path, returnExpression, () => {
|
|
9112
9025
|
this.deoptimizableDependentExpressions.push(origin);
|
|
9113
|
-
return returnExpression.getReturnExpressionWhenCalledAtPath(path,
|
|
9026
|
+
return returnExpression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9114
9027
|
}, UNKNOWN_EXPRESSION);
|
|
9115
9028
|
}
|
|
9116
|
-
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9029
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9030
|
+
const { type } = interaction;
|
|
9031
|
+
if (type === INTERACTION_CALLED) {
|
|
9032
|
+
if ((interaction.withNew
|
|
9033
|
+
? context.instantiated
|
|
9034
|
+
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)) {
|
|
9035
|
+
return false;
|
|
9036
|
+
}
|
|
9037
|
+
}
|
|
9038
|
+
else if ((type === INTERACTION_ASSIGNED
|
|
9039
|
+
? context.assigned
|
|
9040
|
+
: context.accessed).trackEntityAtPathAndGetIfTracked(path, this)) {
|
|
9041
|
+
return false;
|
|
9042
|
+
}
|
|
9043
|
+
return this.getReturnExpression().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9127
9044
|
}
|
|
9128
9045
|
}
|
|
9129
9046
|
|
|
@@ -9146,11 +9063,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
9146
9063
|
}, this.start);
|
|
9147
9064
|
}
|
|
9148
9065
|
}
|
|
9149
|
-
this.
|
|
9066
|
+
this.interaction = {
|
|
9150
9067
|
args: this.arguments,
|
|
9151
|
-
|
|
9068
|
+
thisArg: this.callee instanceof MemberExpression && !this.callee.variable
|
|
9152
9069
|
? this.callee.object
|
|
9153
9070
|
: null,
|
|
9071
|
+
type: INTERACTION_CALLED,
|
|
9154
9072
|
withNew: false
|
|
9155
9073
|
};
|
|
9156
9074
|
}
|
|
@@ -9164,7 +9082,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9164
9082
|
this.annotations)
|
|
9165
9083
|
return false;
|
|
9166
9084
|
return (this.callee.hasEffects(context) ||
|
|
9167
|
-
this.callee.
|
|
9085
|
+
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
9168
9086
|
}
|
|
9169
9087
|
finally {
|
|
9170
9088
|
if (!this.deoptimized)
|
|
@@ -9184,7 +9102,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9184
9102
|
}
|
|
9185
9103
|
else {
|
|
9186
9104
|
this.included = true;
|
|
9187
|
-
this.callee.include(context, false
|
|
9105
|
+
this.callee.include(context, false);
|
|
9188
9106
|
}
|
|
9189
9107
|
this.callee.includeCallArguments(context, this.arguments);
|
|
9190
9108
|
const returnExpression = this.getReturnExpression();
|
|
@@ -9197,34 +9115,12 @@ class CallExpression extends CallExpressionBase {
|
|
|
9197
9115
|
isCalleeOfRenderedParent: true,
|
|
9198
9116
|
renderedSurroundingElement
|
|
9199
9117
|
});
|
|
9200
|
-
|
|
9201
|
-
if (this.arguments[this.arguments.length - 1].included) {
|
|
9202
|
-
for (const arg of this.arguments) {
|
|
9203
|
-
arg.render(code, options);
|
|
9204
|
-
}
|
|
9205
|
-
}
|
|
9206
|
-
else {
|
|
9207
|
-
let lastIncludedIndex = this.arguments.length - 2;
|
|
9208
|
-
while (lastIncludedIndex >= 0 && !this.arguments[lastIncludedIndex].included) {
|
|
9209
|
-
lastIncludedIndex--;
|
|
9210
|
-
}
|
|
9211
|
-
if (lastIncludedIndex >= 0) {
|
|
9212
|
-
for (let index = 0; index <= lastIncludedIndex; index++) {
|
|
9213
|
-
this.arguments[index].render(code, options);
|
|
9214
|
-
}
|
|
9215
|
-
code.remove(findFirstOccurrenceOutsideComment(code.original, ',', this.arguments[lastIncludedIndex].end), this.end - 1);
|
|
9216
|
-
}
|
|
9217
|
-
else {
|
|
9218
|
-
code.remove(findFirstOccurrenceOutsideComment(code.original, '(', this.callee.end) + 1, this.end - 1);
|
|
9219
|
-
}
|
|
9220
|
-
}
|
|
9221
|
-
}
|
|
9118
|
+
renderCallArguments(code, options, this);
|
|
9222
9119
|
}
|
|
9223
9120
|
applyDeoptimizations() {
|
|
9224
9121
|
this.deoptimized = true;
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
this.callee.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
|
|
9122
|
+
if (this.interaction.thisArg) {
|
|
9123
|
+
this.callee.deoptimizeThisOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
9228
9124
|
}
|
|
9229
9125
|
for (const argument of this.arguments) {
|
|
9230
9126
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -9235,7 +9131,7 @@ class CallExpression extends CallExpressionBase {
|
|
|
9235
9131
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
9236
9132
|
if (this.returnExpression === null) {
|
|
9237
9133
|
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
9238
|
-
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.
|
|
9134
|
+
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
9239
9135
|
}
|
|
9240
9136
|
return this.returnExpression;
|
|
9241
9137
|
}
|
|
@@ -9313,11 +9209,6 @@ class MethodBase extends NodeBase {
|
|
|
9313
9209
|
constructor() {
|
|
9314
9210
|
super(...arguments);
|
|
9315
9211
|
this.accessedValue = null;
|
|
9316
|
-
this.accessorCallOptions = {
|
|
9317
|
-
args: NO_ARGS,
|
|
9318
|
-
thisParam: null,
|
|
9319
|
-
withNew: false
|
|
9320
|
-
};
|
|
9321
9212
|
}
|
|
9322
9213
|
// As getter properties directly receive their values from fixed function
|
|
9323
9214
|
// expressions, there is no known situation where a getter is deoptimized.
|
|
@@ -9325,45 +9216,60 @@ class MethodBase extends NodeBase {
|
|
|
9325
9216
|
deoptimizePath(path) {
|
|
9326
9217
|
this.getAccessedValue().deoptimizePath(path);
|
|
9327
9218
|
}
|
|
9328
|
-
|
|
9329
|
-
if (
|
|
9330
|
-
return this.value.
|
|
9219
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9220
|
+
if (interaction.type === INTERACTION_ACCESSED && this.kind === 'get' && path.length === 0) {
|
|
9221
|
+
return this.value.deoptimizeThisOnInteractionAtPath({
|
|
9222
|
+
args: NO_ARGS,
|
|
9223
|
+
thisArg: interaction.thisArg,
|
|
9224
|
+
type: INTERACTION_CALLED,
|
|
9225
|
+
withNew: false
|
|
9226
|
+
}, EMPTY_PATH, recursionTracker);
|
|
9331
9227
|
}
|
|
9332
|
-
if (
|
|
9333
|
-
return this.value.
|
|
9228
|
+
if (interaction.type === INTERACTION_ASSIGNED && this.kind === 'set' && path.length === 0) {
|
|
9229
|
+
return this.value.deoptimizeThisOnInteractionAtPath({
|
|
9230
|
+
args: interaction.args,
|
|
9231
|
+
thisArg: interaction.thisArg,
|
|
9232
|
+
type: INTERACTION_CALLED,
|
|
9233
|
+
withNew: false
|
|
9234
|
+
}, EMPTY_PATH, recursionTracker);
|
|
9334
9235
|
}
|
|
9335
|
-
this.getAccessedValue().
|
|
9236
|
+
this.getAccessedValue().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9336
9237
|
}
|
|
9337
9238
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9338
9239
|
return this.getAccessedValue().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9339
9240
|
}
|
|
9340
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9341
|
-
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path,
|
|
9241
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9242
|
+
return this.getAccessedValue().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9342
9243
|
}
|
|
9343
9244
|
hasEffects(context) {
|
|
9344
9245
|
return this.key.hasEffects(context);
|
|
9345
9246
|
}
|
|
9346
|
-
|
|
9347
|
-
if (this.kind === 'get' && path.length === 0) {
|
|
9348
|
-
return this.value.
|
|
9349
|
-
|
|
9350
|
-
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
|
|
9354
|
-
|
|
9247
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9248
|
+
if (this.kind === 'get' && interaction.type === INTERACTION_ACCESSED && path.length === 0) {
|
|
9249
|
+
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9250
|
+
args: NO_ARGS,
|
|
9251
|
+
thisArg: interaction.thisArg,
|
|
9252
|
+
type: INTERACTION_CALLED,
|
|
9253
|
+
withNew: false
|
|
9254
|
+
}, context);
|
|
9255
|
+
}
|
|
9256
|
+
// setters are only called for empty paths
|
|
9257
|
+
if (this.kind === 'set' && interaction.type === INTERACTION_ASSIGNED) {
|
|
9258
|
+
return this.value.hasEffectsOnInteractionAtPath(EMPTY_PATH, {
|
|
9259
|
+
args: interaction.args,
|
|
9260
|
+
thisArg: interaction.thisArg,
|
|
9261
|
+
type: INTERACTION_CALLED,
|
|
9262
|
+
withNew: false
|
|
9263
|
+
}, context);
|
|
9355
9264
|
}
|
|
9356
|
-
return this.getAccessedValue().
|
|
9357
|
-
}
|
|
9358
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9359
|
-
return this.getAccessedValue().hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
9265
|
+
return this.getAccessedValue().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9360
9266
|
}
|
|
9361
9267
|
applyDeoptimizations() { }
|
|
9362
9268
|
getAccessedValue() {
|
|
9363
9269
|
if (this.accessedValue === null) {
|
|
9364
9270
|
if (this.kind === 'get') {
|
|
9365
9271
|
this.accessedValue = UNKNOWN_EXPRESSION;
|
|
9366
|
-
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH,
|
|
9272
|
+
return (this.accessedValue = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, SHARED_RECURSION_TRACKER, this));
|
|
9367
9273
|
}
|
|
9368
9274
|
else {
|
|
9369
9275
|
return (this.accessedValue = this.value);
|
|
@@ -9377,41 +9283,6 @@ class MethodDefinition extends MethodBase {
|
|
|
9377
9283
|
applyDeoptimizations() { }
|
|
9378
9284
|
}
|
|
9379
9285
|
|
|
9380
|
-
class PropertyDefinition extends NodeBase {
|
|
9381
|
-
deoptimizePath(path) {
|
|
9382
|
-
var _a;
|
|
9383
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
9384
|
-
}
|
|
9385
|
-
deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker) {
|
|
9386
|
-
var _a;
|
|
9387
|
-
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
|
|
9388
|
-
}
|
|
9389
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9390
|
-
return this.value
|
|
9391
|
-
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
|
|
9392
|
-
: UnknownValue;
|
|
9393
|
-
}
|
|
9394
|
-
getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin) {
|
|
9395
|
-
return this.value
|
|
9396
|
-
? this.value.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin)
|
|
9397
|
-
: UNKNOWN_EXPRESSION;
|
|
9398
|
-
}
|
|
9399
|
-
hasEffects(context) {
|
|
9400
|
-
var _a;
|
|
9401
|
-
return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
9402
|
-
}
|
|
9403
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
9404
|
-
return !this.value || this.value.hasEffectsWhenAccessedAtPath(path, context);
|
|
9405
|
-
}
|
|
9406
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9407
|
-
return !this.value || this.value.hasEffectsWhenAssignedAtPath(path, context);
|
|
9408
|
-
}
|
|
9409
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9410
|
-
return !this.value || this.value.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
9411
|
-
}
|
|
9412
|
-
applyDeoptimizations() { }
|
|
9413
|
-
}
|
|
9414
|
-
|
|
9415
9286
|
class ObjectMember extends ExpressionEntity {
|
|
9416
9287
|
constructor(object, key) {
|
|
9417
9288
|
super();
|
|
@@ -9421,23 +9292,17 @@ class ObjectMember extends ExpressionEntity {
|
|
|
9421
9292
|
deoptimizePath(path) {
|
|
9422
9293
|
this.object.deoptimizePath([this.key, ...path]);
|
|
9423
9294
|
}
|
|
9424
|
-
|
|
9425
|
-
this.object.
|
|
9295
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9296
|
+
this.object.deoptimizeThisOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
9426
9297
|
}
|
|
9427
9298
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9428
9299
|
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
9429
9300
|
}
|
|
9430
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9431
|
-
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path],
|
|
9301
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9302
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
9432
9303
|
}
|
|
9433
|
-
|
|
9434
|
-
return this.object.
|
|
9435
|
-
}
|
|
9436
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9437
|
-
return this.object.hasEffectsWhenAssignedAtPath([this.key, ...path], context);
|
|
9438
|
-
}
|
|
9439
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9440
|
-
return this.object.hasEffectsWhenCalledAtPath([this.key, ...path], callOptions, context);
|
|
9304
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9305
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
9441
9306
|
}
|
|
9442
9307
|
}
|
|
9443
9308
|
|
|
@@ -9453,23 +9318,16 @@ class ClassNode extends NodeBase {
|
|
|
9453
9318
|
this.getObjectEntity().deoptimizeAllProperties();
|
|
9454
9319
|
}
|
|
9455
9320
|
deoptimizePath(path) {
|
|
9456
|
-
var _a, _b;
|
|
9457
9321
|
this.getObjectEntity().deoptimizePath(path);
|
|
9458
|
-
if (path.length === 1 && path[0] === UnknownKey) {
|
|
9459
|
-
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
9460
|
-
// which means the constructor needs to be reassigned
|
|
9461
|
-
(_a = this.classConstructor) === null || _a === void 0 ? void 0 : _a.deoptimizePath(UNKNOWN_PATH);
|
|
9462
|
-
(_b = this.superClass) === null || _b === void 0 ? void 0 : _b.deoptimizePath(UNKNOWN_PATH);
|
|
9463
|
-
}
|
|
9464
9322
|
}
|
|
9465
|
-
|
|
9466
|
-
this.getObjectEntity().
|
|
9323
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9324
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9467
9325
|
}
|
|
9468
9326
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9469
9327
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9470
9328
|
}
|
|
9471
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9472
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
9329
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9330
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9473
9331
|
}
|
|
9474
9332
|
hasEffects(context) {
|
|
9475
9333
|
var _a, _b;
|
|
@@ -9479,23 +9337,17 @@ class ClassNode extends NodeBase {
|
|
|
9479
9337
|
(_b = this.id) === null || _b === void 0 ? void 0 : _b.markDeclarationReached();
|
|
9480
9338
|
return initEffect || super.hasEffects(context);
|
|
9481
9339
|
}
|
|
9482
|
-
|
|
9483
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
9484
|
-
}
|
|
9485
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9486
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
9487
|
-
}
|
|
9488
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9340
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9489
9341
|
var _a;
|
|
9490
|
-
if (path.length === 0) {
|
|
9491
|
-
return (!
|
|
9342
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 0) {
|
|
9343
|
+
return (!interaction.withNew ||
|
|
9492
9344
|
(this.classConstructor !== null
|
|
9493
|
-
? this.classConstructor.
|
|
9494
|
-
: (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.
|
|
9345
|
+
? this.classConstructor.hasEffectsOnInteractionAtPath(path, interaction, context)
|
|
9346
|
+
: (_a = this.superClass) === null || _a === void 0 ? void 0 : _a.hasEffectsOnInteractionAtPath(path, interaction, context)) ||
|
|
9495
9347
|
false);
|
|
9496
9348
|
}
|
|
9497
9349
|
else {
|
|
9498
|
-
return this.getObjectEntity().
|
|
9350
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9499
9351
|
}
|
|
9500
9352
|
}
|
|
9501
9353
|
include(context, includeChildrenRecursively) {
|
|
@@ -9522,7 +9374,6 @@ class ClassNode extends NodeBase {
|
|
|
9522
9374
|
this.classConstructor = null;
|
|
9523
9375
|
}
|
|
9524
9376
|
applyDeoptimizations() {
|
|
9525
|
-
var _a, _b;
|
|
9526
9377
|
this.deoptimized = true;
|
|
9527
9378
|
for (const definition of this.body.body) {
|
|
9528
9379
|
if (!(definition.static ||
|
|
@@ -9530,11 +9381,7 @@ class ClassNode extends NodeBase {
|
|
|
9530
9381
|
// Calls to methods are not tracked, ensure that the return value is deoptimized
|
|
9531
9382
|
definition.deoptimizePath(UNKNOWN_PATH);
|
|
9532
9383
|
}
|
|
9533
|
-
else if (definition instanceof PropertyDefinition) {
|
|
9534
|
-
(_a = definition.value) === null || _a === void 0 ? void 0 : _a.deoptimizeCallParameters();
|
|
9535
|
-
}
|
|
9536
9384
|
}
|
|
9537
|
-
(_b = this.superClass) === null || _b === void 0 ? void 0 : _b.deoptimizeCallParameters();
|
|
9538
9385
|
this.context.requestTreeshakingPass();
|
|
9539
9386
|
}
|
|
9540
9387
|
getObjectEntity() {
|
|
@@ -9621,26 +9468,12 @@ class MultiExpression extends ExpressionEntity {
|
|
|
9621
9468
|
expression.deoptimizePath(path);
|
|
9622
9469
|
}
|
|
9623
9470
|
}
|
|
9624
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9625
|
-
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path,
|
|
9626
|
-
}
|
|
9627
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
9628
|
-
for (const expression of this.expressions) {
|
|
9629
|
-
if (expression.hasEffectsWhenAccessedAtPath(path, context))
|
|
9630
|
-
return true;
|
|
9631
|
-
}
|
|
9632
|
-
return false;
|
|
9633
|
-
}
|
|
9634
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9635
|
-
for (const expression of this.expressions) {
|
|
9636
|
-
if (expression.hasEffectsWhenAssignedAtPath(path, context))
|
|
9637
|
-
return true;
|
|
9638
|
-
}
|
|
9639
|
-
return false;
|
|
9471
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9472
|
+
return new MultiExpression(this.expressions.map(expression => expression.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)));
|
|
9640
9473
|
}
|
|
9641
|
-
|
|
9474
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9642
9475
|
for (const expression of this.expressions) {
|
|
9643
|
-
if (expression.
|
|
9476
|
+
if (expression.hasEffectsOnInteractionAtPath(path, interaction, context))
|
|
9644
9477
|
return true;
|
|
9645
9478
|
}
|
|
9646
9479
|
return false;
|
|
@@ -9683,9 +9516,9 @@ class ConditionalExpression extends NodeBase {
|
|
|
9683
9516
|
usedBranch.deoptimizePath(path);
|
|
9684
9517
|
}
|
|
9685
9518
|
}
|
|
9686
|
-
|
|
9687
|
-
this.consequent.
|
|
9688
|
-
this.alternate.
|
|
9519
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
9520
|
+
this.consequent.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9521
|
+
this.alternate.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
9689
9522
|
}
|
|
9690
9523
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
9691
9524
|
const usedBranch = this.getUsedBranch();
|
|
@@ -9694,15 +9527,15 @@ class ConditionalExpression extends NodeBase {
|
|
|
9694
9527
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9695
9528
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
9696
9529
|
}
|
|
9697
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
9530
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
9698
9531
|
const usedBranch = this.getUsedBranch();
|
|
9699
9532
|
if (!usedBranch)
|
|
9700
9533
|
return new MultiExpression([
|
|
9701
|
-
this.consequent.getReturnExpressionWhenCalledAtPath(path,
|
|
9702
|
-
this.alternate.getReturnExpressionWhenCalledAtPath(path,
|
|
9534
|
+
this.consequent.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
9535
|
+
this.alternate.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
9703
9536
|
]);
|
|
9704
9537
|
this.expressionsToBeDeoptimized.push(origin);
|
|
9705
|
-
return usedBranch.getReturnExpressionWhenCalledAtPath(path,
|
|
9538
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
9706
9539
|
}
|
|
9707
9540
|
hasEffects(context) {
|
|
9708
9541
|
if (this.test.hasEffects(context))
|
|
@@ -9713,29 +9546,13 @@ class ConditionalExpression extends NodeBase {
|
|
|
9713
9546
|
}
|
|
9714
9547
|
return usedBranch.hasEffects(context);
|
|
9715
9548
|
}
|
|
9716
|
-
|
|
9717
|
-
const usedBranch = this.getUsedBranch();
|
|
9718
|
-
if (!usedBranch) {
|
|
9719
|
-
return (this.consequent.hasEffectsWhenAccessedAtPath(path, context) ||
|
|
9720
|
-
this.alternate.hasEffectsWhenAccessedAtPath(path, context));
|
|
9721
|
-
}
|
|
9722
|
-
return usedBranch.hasEffectsWhenAccessedAtPath(path, context);
|
|
9723
|
-
}
|
|
9724
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
9725
|
-
const usedBranch = this.getUsedBranch();
|
|
9726
|
-
if (!usedBranch) {
|
|
9727
|
-
return (this.consequent.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
9728
|
-
this.alternate.hasEffectsWhenAssignedAtPath(path, context));
|
|
9729
|
-
}
|
|
9730
|
-
return usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
9731
|
-
}
|
|
9732
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
9549
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
9733
9550
|
const usedBranch = this.getUsedBranch();
|
|
9734
9551
|
if (!usedBranch) {
|
|
9735
|
-
return (this.consequent.
|
|
9736
|
-
this.alternate.
|
|
9552
|
+
return (this.consequent.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
9553
|
+
this.alternate.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
9737
9554
|
}
|
|
9738
|
-
return usedBranch.
|
|
9555
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
9739
9556
|
}
|
|
9740
9557
|
include(context, includeChildrenRecursively) {
|
|
9741
9558
|
this.included = true;
|
|
@@ -9868,9 +9685,6 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
9868
9685
|
ExportAllDeclaration.prototype.needsBoundaries = true;
|
|
9869
9686
|
|
|
9870
9687
|
class FunctionDeclaration extends FunctionNode {
|
|
9871
|
-
include(context, includeChildrenRecursively) {
|
|
9872
|
-
super.include(context, includeChildrenRecursively, { includeWithoutParameterDefaults: true });
|
|
9873
|
-
}
|
|
9874
9688
|
initialise() {
|
|
9875
9689
|
super.initialise();
|
|
9876
9690
|
if (this.id !== null) {
|
|
@@ -10009,12 +9823,10 @@ class ForInStatement extends NodeBase {
|
|
|
10009
9823
|
this.scope = new BlockScope(parentScope);
|
|
10010
9824
|
}
|
|
10011
9825
|
hasEffects(context) {
|
|
10012
|
-
|
|
9826
|
+
const { deoptimized, left, right } = this;
|
|
9827
|
+
if (!deoptimized)
|
|
10013
9828
|
this.applyDeoptimizations();
|
|
10014
|
-
if ((
|
|
10015
|
-
(this.left.hasEffects(context) ||
|
|
10016
|
-
this.left.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context))) ||
|
|
10017
|
-
(this.right && this.right.hasEffects(context)))
|
|
9829
|
+
if (left.hasEffectsAsAssignmentTarget(context, false) || right.hasEffects(context))
|
|
10018
9830
|
return true;
|
|
10019
9831
|
const { brokenFlow, ignore: { breaks, continues } } = context;
|
|
10020
9832
|
context.ignore.breaks = true;
|
|
@@ -10027,15 +9839,19 @@ class ForInStatement extends NodeBase {
|
|
|
10027
9839
|
return false;
|
|
10028
9840
|
}
|
|
10029
9841
|
include(context, includeChildrenRecursively) {
|
|
10030
|
-
|
|
9842
|
+
const { body, deoptimized, left, right } = this;
|
|
9843
|
+
if (!deoptimized)
|
|
10031
9844
|
this.applyDeoptimizations();
|
|
10032
9845
|
this.included = true;
|
|
10033
|
-
|
|
10034
|
-
|
|
9846
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
9847
|
+
right.include(context, includeChildrenRecursively);
|
|
10035
9848
|
const { brokenFlow } = context;
|
|
10036
|
-
|
|
9849
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10037
9850
|
context.brokenFlow = brokenFlow;
|
|
10038
9851
|
}
|
|
9852
|
+
initialise() {
|
|
9853
|
+
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9854
|
+
}
|
|
10039
9855
|
render(code, options) {
|
|
10040
9856
|
this.left.render(code, options, NO_SEMICOLON);
|
|
10041
9857
|
this.right.render(code, options, NO_SEMICOLON);
|
|
@@ -10063,15 +9879,19 @@ class ForOfStatement extends NodeBase {
|
|
|
10063
9879
|
return true;
|
|
10064
9880
|
}
|
|
10065
9881
|
include(context, includeChildrenRecursively) {
|
|
10066
|
-
|
|
9882
|
+
const { body, deoptimized, left, right } = this;
|
|
9883
|
+
if (!deoptimized)
|
|
10067
9884
|
this.applyDeoptimizations();
|
|
10068
9885
|
this.included = true;
|
|
10069
|
-
|
|
10070
|
-
|
|
9886
|
+
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
9887
|
+
right.include(context, includeChildrenRecursively);
|
|
10071
9888
|
const { brokenFlow } = context;
|
|
10072
|
-
|
|
9889
|
+
body.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
10073
9890
|
context.brokenFlow = brokenFlow;
|
|
10074
9891
|
}
|
|
9892
|
+
initialise() {
|
|
9893
|
+
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
9894
|
+
}
|
|
10075
9895
|
render(code, options) {
|
|
10076
9896
|
this.left.render(code, options, NO_SEMICOLON);
|
|
10077
9897
|
this.right.render(code, options, NO_SEMICOLON);
|
|
@@ -10756,13 +10576,16 @@ class LogicalExpression extends NodeBase {
|
|
|
10756
10576
|
this.usedBranch = null;
|
|
10757
10577
|
}
|
|
10758
10578
|
deoptimizeCache() {
|
|
10759
|
-
if (this.usedBranch
|
|
10579
|
+
if (this.usedBranch) {
|
|
10760
10580
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
10761
10581
|
this.usedBranch = null;
|
|
10762
10582
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
10763
10583
|
for (const expression of this.expressionsToBeDeoptimized) {
|
|
10764
10584
|
expression.deoptimizeCache();
|
|
10765
10585
|
}
|
|
10586
|
+
// Request another pass because we need to ensure "include" runs again if
|
|
10587
|
+
// it is rendered
|
|
10588
|
+
this.context.requestTreeshakingPass();
|
|
10766
10589
|
}
|
|
10767
10590
|
}
|
|
10768
10591
|
deoptimizePath(path) {
|
|
@@ -10775,9 +10598,9 @@ class LogicalExpression extends NodeBase {
|
|
|
10775
10598
|
usedBranch.deoptimizePath(path);
|
|
10776
10599
|
}
|
|
10777
10600
|
}
|
|
10778
|
-
|
|
10779
|
-
this.left.
|
|
10780
|
-
this.right.
|
|
10601
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10602
|
+
this.left.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10603
|
+
this.right.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
10781
10604
|
}
|
|
10782
10605
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
10783
10606
|
const usedBranch = this.getUsedBranch();
|
|
@@ -10786,15 +10609,15 @@ class LogicalExpression extends NodeBase {
|
|
|
10786
10609
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10787
10610
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
10788
10611
|
}
|
|
10789
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
10612
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10790
10613
|
const usedBranch = this.getUsedBranch();
|
|
10791
10614
|
if (!usedBranch)
|
|
10792
10615
|
return new MultiExpression([
|
|
10793
|
-
this.left.getReturnExpressionWhenCalledAtPath(path,
|
|
10794
|
-
this.right.getReturnExpressionWhenCalledAtPath(path,
|
|
10616
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin),
|
|
10617
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
10795
10618
|
]);
|
|
10796
10619
|
this.expressionsToBeDeoptimized.push(origin);
|
|
10797
|
-
return usedBranch.getReturnExpressionWhenCalledAtPath(path,
|
|
10620
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
10798
10621
|
}
|
|
10799
10622
|
hasEffects(context) {
|
|
10800
10623
|
if (this.left.hasEffects(context)) {
|
|
@@ -10805,29 +10628,13 @@ class LogicalExpression extends NodeBase {
|
|
|
10805
10628
|
}
|
|
10806
10629
|
return false;
|
|
10807
10630
|
}
|
|
10808
|
-
|
|
10809
|
-
const usedBranch = this.getUsedBranch();
|
|
10810
|
-
if (!usedBranch) {
|
|
10811
|
-
return (this.left.hasEffectsWhenAccessedAtPath(path, context) ||
|
|
10812
|
-
this.right.hasEffectsWhenAccessedAtPath(path, context));
|
|
10813
|
-
}
|
|
10814
|
-
return usedBranch.hasEffectsWhenAccessedAtPath(path, context);
|
|
10815
|
-
}
|
|
10816
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
10817
|
-
const usedBranch = this.getUsedBranch();
|
|
10818
|
-
if (!usedBranch) {
|
|
10819
|
-
return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
10820
|
-
this.right.hasEffectsWhenAssignedAtPath(path, context));
|
|
10821
|
-
}
|
|
10822
|
-
return usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
10823
|
-
}
|
|
10824
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
10631
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10825
10632
|
const usedBranch = this.getUsedBranch();
|
|
10826
10633
|
if (!usedBranch) {
|
|
10827
|
-
return (this.left.
|
|
10828
|
-
this.right.
|
|
10634
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
10635
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
10829
10636
|
}
|
|
10830
|
-
return usedBranch.
|
|
10637
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
10831
10638
|
}
|
|
10832
10639
|
include(context, includeChildrenRecursively) {
|
|
10833
10640
|
this.included = true;
|
|
@@ -10917,8 +10724,8 @@ class MetaProperty extends NodeBase {
|
|
|
10917
10724
|
hasEffects() {
|
|
10918
10725
|
return false;
|
|
10919
10726
|
}
|
|
10920
|
-
|
|
10921
|
-
return path.length > 1;
|
|
10727
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
10728
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
10922
10729
|
}
|
|
10923
10730
|
include() {
|
|
10924
10731
|
if (!this.included) {
|
|
@@ -11063,18 +10870,19 @@ class NewExpression extends NodeBase {
|
|
|
11063
10870
|
return true;
|
|
11064
10871
|
}
|
|
11065
10872
|
if (this.context.options.treeshake.annotations &&
|
|
11066
|
-
this.annotations)
|
|
10873
|
+
this.annotations) {
|
|
11067
10874
|
return false;
|
|
10875
|
+
}
|
|
11068
10876
|
return (this.callee.hasEffects(context) ||
|
|
11069
|
-
this.callee.
|
|
10877
|
+
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
11070
10878
|
}
|
|
11071
10879
|
finally {
|
|
11072
10880
|
if (!this.deoptimized)
|
|
11073
10881
|
this.applyDeoptimizations();
|
|
11074
10882
|
}
|
|
11075
10883
|
}
|
|
11076
|
-
|
|
11077
|
-
return path.length > 0;
|
|
10884
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
10885
|
+
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
11078
10886
|
}
|
|
11079
10887
|
include(context, includeChildrenRecursively) {
|
|
11080
10888
|
if (!this.deoptimized)
|
|
@@ -11089,12 +10897,17 @@ class NewExpression extends NodeBase {
|
|
|
11089
10897
|
this.callee.includeCallArguments(context, this.arguments);
|
|
11090
10898
|
}
|
|
11091
10899
|
initialise() {
|
|
11092
|
-
this.
|
|
10900
|
+
this.interaction = {
|
|
11093
10901
|
args: this.arguments,
|
|
11094
|
-
|
|
10902
|
+
thisArg: null,
|
|
10903
|
+
type: INTERACTION_CALLED,
|
|
11095
10904
|
withNew: true
|
|
11096
10905
|
};
|
|
11097
10906
|
}
|
|
10907
|
+
render(code, options) {
|
|
10908
|
+
this.callee.render(code, options);
|
|
10909
|
+
renderCallArguments(code, options, this);
|
|
10910
|
+
}
|
|
11098
10911
|
applyDeoptimizations() {
|
|
11099
10912
|
this.deoptimized = true;
|
|
11100
10913
|
for (const argument of this.arguments) {
|
|
@@ -11105,42 +10918,6 @@ class NewExpression extends NodeBase {
|
|
|
11105
10918
|
}
|
|
11106
10919
|
}
|
|
11107
10920
|
|
|
11108
|
-
class Property extends MethodBase {
|
|
11109
|
-
constructor() {
|
|
11110
|
-
super(...arguments);
|
|
11111
|
-
this.declarationInit = null;
|
|
11112
|
-
}
|
|
11113
|
-
declare(kind, init) {
|
|
11114
|
-
this.declarationInit = init;
|
|
11115
|
-
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
11116
|
-
}
|
|
11117
|
-
hasEffects(context) {
|
|
11118
|
-
if (!this.deoptimized)
|
|
11119
|
-
this.applyDeoptimizations();
|
|
11120
|
-
const propertyReadSideEffects = this.context.options.treeshake
|
|
11121
|
-
.propertyReadSideEffects;
|
|
11122
|
-
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
11123
|
-
this.key.hasEffects(context) ||
|
|
11124
|
-
this.value.hasEffects(context));
|
|
11125
|
-
}
|
|
11126
|
-
markDeclarationReached() {
|
|
11127
|
-
this.value.markDeclarationReached();
|
|
11128
|
-
}
|
|
11129
|
-
render(code, options) {
|
|
11130
|
-
if (!this.shorthand) {
|
|
11131
|
-
this.key.render(code, options);
|
|
11132
|
-
}
|
|
11133
|
-
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
11134
|
-
}
|
|
11135
|
-
applyDeoptimizations() {
|
|
11136
|
-
this.deoptimized = true;
|
|
11137
|
-
if (this.declarationInit !== null) {
|
|
11138
|
-
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
11139
|
-
this.context.requestTreeshakingPass();
|
|
11140
|
-
}
|
|
11141
|
-
}
|
|
11142
|
-
}
|
|
11143
|
-
|
|
11144
10921
|
class ObjectExpression extends NodeBase {
|
|
11145
10922
|
constructor() {
|
|
11146
10923
|
super(...arguments);
|
|
@@ -11152,23 +10929,17 @@ class ObjectExpression extends NodeBase {
|
|
|
11152
10929
|
deoptimizePath(path) {
|
|
11153
10930
|
this.getObjectEntity().deoptimizePath(path);
|
|
11154
10931
|
}
|
|
11155
|
-
|
|
11156
|
-
this.getObjectEntity().
|
|
10932
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
10933
|
+
this.getObjectEntity().deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11157
10934
|
}
|
|
11158
10935
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11159
10936
|
return this.getObjectEntity().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
11160
10937
|
}
|
|
11161
|
-
getReturnExpressionWhenCalledAtPath(path,
|
|
11162
|
-
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path,
|
|
11163
|
-
}
|
|
11164
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
11165
|
-
return this.getObjectEntity().hasEffectsWhenAccessedAtPath(path, context);
|
|
11166
|
-
}
|
|
11167
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11168
|
-
return this.getObjectEntity().hasEffectsWhenAssignedAtPath(path, context);
|
|
10938
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
10939
|
+
return this.getObjectEntity().getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
11169
10940
|
}
|
|
11170
|
-
|
|
11171
|
-
return this.getObjectEntity().
|
|
10941
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
10942
|
+
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11172
10943
|
}
|
|
11173
10944
|
render(code, options, { renderedSurroundingElement } = BLANK) {
|
|
11174
10945
|
super.render(code, options);
|
|
@@ -11178,14 +10949,7 @@ class ObjectExpression extends NodeBase {
|
|
|
11178
10949
|
code.prependLeft(this.end, ')');
|
|
11179
10950
|
}
|
|
11180
10951
|
}
|
|
11181
|
-
applyDeoptimizations() {
|
|
11182
|
-
this.deoptimized = true;
|
|
11183
|
-
for (const property of this.properties) {
|
|
11184
|
-
if (property instanceof Property) {
|
|
11185
|
-
property.value.deoptimizeCallParameters();
|
|
11186
|
-
}
|
|
11187
|
-
}
|
|
11188
|
-
}
|
|
10952
|
+
applyDeoptimizations() { }
|
|
11189
10953
|
getObjectEntity() {
|
|
11190
10954
|
if (this.objectEntity !== null) {
|
|
11191
10955
|
return this.objectEntity;
|
|
@@ -11265,6 +11029,71 @@ class Program extends NodeBase {
|
|
|
11265
11029
|
applyDeoptimizations() { }
|
|
11266
11030
|
}
|
|
11267
11031
|
|
|
11032
|
+
class Property extends MethodBase {
|
|
11033
|
+
constructor() {
|
|
11034
|
+
super(...arguments);
|
|
11035
|
+
this.declarationInit = null;
|
|
11036
|
+
}
|
|
11037
|
+
declare(kind, init) {
|
|
11038
|
+
this.declarationInit = init;
|
|
11039
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
11040
|
+
}
|
|
11041
|
+
hasEffects(context) {
|
|
11042
|
+
if (!this.deoptimized)
|
|
11043
|
+
this.applyDeoptimizations();
|
|
11044
|
+
const propertyReadSideEffects = this.context.options.treeshake
|
|
11045
|
+
.propertyReadSideEffects;
|
|
11046
|
+
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
11047
|
+
this.key.hasEffects(context) ||
|
|
11048
|
+
this.value.hasEffects(context));
|
|
11049
|
+
}
|
|
11050
|
+
markDeclarationReached() {
|
|
11051
|
+
this.value.markDeclarationReached();
|
|
11052
|
+
}
|
|
11053
|
+
render(code, options) {
|
|
11054
|
+
if (!this.shorthand) {
|
|
11055
|
+
this.key.render(code, options);
|
|
11056
|
+
}
|
|
11057
|
+
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
11058
|
+
}
|
|
11059
|
+
applyDeoptimizations() {
|
|
11060
|
+
this.deoptimized = true;
|
|
11061
|
+
if (this.declarationInit !== null) {
|
|
11062
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
11063
|
+
this.context.requestTreeshakingPass();
|
|
11064
|
+
}
|
|
11065
|
+
}
|
|
11066
|
+
}
|
|
11067
|
+
|
|
11068
|
+
class PropertyDefinition extends NodeBase {
|
|
11069
|
+
deoptimizePath(path) {
|
|
11070
|
+
var _a;
|
|
11071
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizePath(path);
|
|
11072
|
+
}
|
|
11073
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11074
|
+
var _a;
|
|
11075
|
+
(_a = this.value) === null || _a === void 0 ? void 0 : _a.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11076
|
+
}
|
|
11077
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11078
|
+
return this.value
|
|
11079
|
+
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
|
|
11080
|
+
: UnknownValue;
|
|
11081
|
+
}
|
|
11082
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
11083
|
+
return this.value
|
|
11084
|
+
? this.value.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)
|
|
11085
|
+
: UNKNOWN_EXPRESSION;
|
|
11086
|
+
}
|
|
11087
|
+
hasEffects(context) {
|
|
11088
|
+
var _a;
|
|
11089
|
+
return this.key.hasEffects(context) || (this.static && !!((_a = this.value) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
11090
|
+
}
|
|
11091
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11092
|
+
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11093
|
+
}
|
|
11094
|
+
applyDeoptimizations() { }
|
|
11095
|
+
}
|
|
11096
|
+
|
|
11268
11097
|
class ReturnStatement extends NodeBase {
|
|
11269
11098
|
hasEffects(context) {
|
|
11270
11099
|
var _a;
|
|
@@ -11296,8 +11125,8 @@ class SequenceExpression extends NodeBase {
|
|
|
11296
11125
|
deoptimizePath(path) {
|
|
11297
11126
|
this.expressions[this.expressions.length - 1].deoptimizePath(path);
|
|
11298
11127
|
}
|
|
11299
|
-
|
|
11300
|
-
this.expressions[this.expressions.length - 1].
|
|
11128
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11129
|
+
this.expressions[this.expressions.length - 1].deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11301
11130
|
}
|
|
11302
11131
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
11303
11132
|
return this.expressions[this.expressions.length - 1].getLiteralValueAtPath(path, recursionTracker, origin);
|
|
@@ -11309,15 +11138,8 @@ class SequenceExpression extends NodeBase {
|
|
|
11309
11138
|
}
|
|
11310
11139
|
return false;
|
|
11311
11140
|
}
|
|
11312
|
-
|
|
11313
|
-
return
|
|
11314
|
-
this.expressions[this.expressions.length - 1].hasEffectsWhenAccessedAtPath(path, context));
|
|
11315
|
-
}
|
|
11316
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
11317
|
-
return this.expressions[this.expressions.length - 1].hasEffectsWhenAssignedAtPath(path, context);
|
|
11318
|
-
}
|
|
11319
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
11320
|
-
return this.expressions[this.expressions.length - 1].hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
11141
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11142
|
+
return this.expressions[this.expressions.length - 1].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11321
11143
|
}
|
|
11322
11144
|
include(context, includeChildrenRecursively) {
|
|
11323
11145
|
this.included = true;
|
|
@@ -11396,8 +11218,8 @@ class Super extends NodeBase {
|
|
|
11396
11218
|
deoptimizePath(path) {
|
|
11397
11219
|
this.variable.deoptimizePath(path);
|
|
11398
11220
|
}
|
|
11399
|
-
|
|
11400
|
-
this.variable.
|
|
11221
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11222
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker);
|
|
11401
11223
|
}
|
|
11402
11224
|
include() {
|
|
11403
11225
|
if (!this.included) {
|
|
@@ -11537,7 +11359,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11537
11359
|
return true;
|
|
11538
11360
|
}
|
|
11539
11361
|
return (this.tag.hasEffects(context) ||
|
|
11540
|
-
this.tag.
|
|
11362
|
+
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
11541
11363
|
}
|
|
11542
11364
|
finally {
|
|
11543
11365
|
if (!this.deoptimized)
|
|
@@ -11555,16 +11377,17 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11555
11377
|
this.tag.include(context, includeChildrenRecursively);
|
|
11556
11378
|
this.quasi.include(context, includeChildrenRecursively);
|
|
11557
11379
|
}
|
|
11558
|
-
this.tag.includeCallArguments(context, this.
|
|
11380
|
+
this.tag.includeCallArguments(context, this.interaction.args);
|
|
11559
11381
|
const returnExpression = this.getReturnExpression();
|
|
11560
11382
|
if (!returnExpression.included) {
|
|
11561
11383
|
returnExpression.include(context, false);
|
|
11562
11384
|
}
|
|
11563
11385
|
}
|
|
11564
11386
|
initialise() {
|
|
11565
|
-
this.
|
|
11387
|
+
this.interaction = {
|
|
11566
11388
|
args: [UNKNOWN_EXPRESSION, ...this.quasi.expressions],
|
|
11567
|
-
|
|
11389
|
+
thisArg: this.tag instanceof MemberExpression && !this.tag.variable ? this.tag.object : null,
|
|
11390
|
+
type: INTERACTION_CALLED,
|
|
11568
11391
|
withNew: false
|
|
11569
11392
|
};
|
|
11570
11393
|
}
|
|
@@ -11574,9 +11397,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11574
11397
|
}
|
|
11575
11398
|
applyDeoptimizations() {
|
|
11576
11399
|
this.deoptimized = true;
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
this.tag.deoptimizeThisOnEventAtPath(EVENT_CALLED, EMPTY_PATH, thisParam, SHARED_RECURSION_TRACKER);
|
|
11400
|
+
if (this.interaction.thisArg) {
|
|
11401
|
+
this.tag.deoptimizeThisOnInteractionAtPath(this.interaction, EMPTY_PATH, SHARED_RECURSION_TRACKER);
|
|
11580
11402
|
}
|
|
11581
11403
|
for (const argument of this.quasi.expressions) {
|
|
11582
11404
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -11587,7 +11409,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
11587
11409
|
getReturnExpression(recursionTracker = SHARED_RECURSION_TRACKER) {
|
|
11588
11410
|
if (this.returnExpression === null) {
|
|
11589
11411
|
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
11590
|
-
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.
|
|
11412
|
+
return (this.returnExpression = this.tag.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, this.interaction, recursionTracker, this));
|
|
11591
11413
|
}
|
|
11592
11414
|
return this.returnExpression;
|
|
11593
11415
|
}
|
|
@@ -11610,7 +11432,7 @@ class TemplateElement extends NodeBase {
|
|
|
11610
11432
|
}
|
|
11611
11433
|
|
|
11612
11434
|
class TemplateLiteral extends NodeBase {
|
|
11613
|
-
|
|
11435
|
+
deoptimizeThisOnInteractionAtPath() { }
|
|
11614
11436
|
getLiteralValueAtPath(path) {
|
|
11615
11437
|
if (path.length > 0 || this.quasis.length !== 1) {
|
|
11616
11438
|
return UnknownValue;
|
|
@@ -11623,12 +11445,12 @@ class TemplateLiteral extends NodeBase {
|
|
|
11623
11445
|
}
|
|
11624
11446
|
return getMemberReturnExpressionWhenCalled(literalStringMembers, path[0]);
|
|
11625
11447
|
}
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
if (path.length === 1) {
|
|
11631
|
-
return hasMemberEffectWhenCalled(literalStringMembers, path[0],
|
|
11448
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11449
|
+
if (interaction.type === INTERACTION_ACCESSED) {
|
|
11450
|
+
return path.length > 1;
|
|
11451
|
+
}
|
|
11452
|
+
if (interaction.type === INTERACTION_CALLED && path.length === 1) {
|
|
11453
|
+
return hasMemberEffectWhenCalled(literalStringMembers, path[0], interaction, context);
|
|
11632
11454
|
}
|
|
11633
11455
|
return true;
|
|
11634
11456
|
}
|
|
@@ -11756,16 +11578,15 @@ class ThisExpression extends NodeBase {
|
|
|
11756
11578
|
deoptimizePath(path) {
|
|
11757
11579
|
this.variable.deoptimizePath(path);
|
|
11758
11580
|
}
|
|
11759
|
-
|
|
11760
|
-
this.variable.deoptimizeThisOnEventAtPath(event, path,
|
|
11581
|
+
deoptimizeThisOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
11761
11582
|
// We rewrite the parameter so that a ThisVariable can detect self-mutations
|
|
11762
|
-
|
|
11763
|
-
}
|
|
11764
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
11765
|
-
return path.length > 0 && this.variable.hasEffectsWhenAccessedAtPath(path, context);
|
|
11583
|
+
this.variable.deoptimizeThisOnInteractionAtPath(interaction.thisArg === this ? { ...interaction, thisArg: this.variable } : interaction, path, recursionTracker);
|
|
11766
11584
|
}
|
|
11767
|
-
|
|
11768
|
-
|
|
11585
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
11586
|
+
if (path.length === 0) {
|
|
11587
|
+
return interaction.type !== INTERACTION_ACCESSED;
|
|
11588
|
+
}
|
|
11589
|
+
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
11769
11590
|
}
|
|
11770
11591
|
include() {
|
|
11771
11592
|
if (!this.included) {
|
|
@@ -11874,13 +11695,10 @@ class UnaryExpression extends NodeBase {
|
|
|
11874
11695
|
return false;
|
|
11875
11696
|
return (this.argument.hasEffects(context) ||
|
|
11876
11697
|
(this.operator === 'delete' &&
|
|
11877
|
-
this.argument.
|
|
11698
|
+
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context)));
|
|
11878
11699
|
}
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
return path.length > 0;
|
|
11882
|
-
}
|
|
11883
|
-
return path.length > 1;
|
|
11700
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11701
|
+
return type !== INTERACTION_ACCESSED || path.length > (this.operator === 'void' ? 0 : 1);
|
|
11884
11702
|
}
|
|
11885
11703
|
applyDeoptimizations() {
|
|
11886
11704
|
this.deoptimized = true;
|
|
@@ -11904,11 +11722,19 @@ class UpdateExpression extends NodeBase {
|
|
|
11904
11722
|
hasEffects(context) {
|
|
11905
11723
|
if (!this.deoptimized)
|
|
11906
11724
|
this.applyDeoptimizations();
|
|
11907
|
-
return
|
|
11908
|
-
this.argument.hasEffectsWhenAssignedAtPath(EMPTY_PATH, context));
|
|
11725
|
+
return this.argument.hasEffectsAsAssignmentTarget(context, true);
|
|
11909
11726
|
}
|
|
11910
|
-
|
|
11911
|
-
return path.length > 1;
|
|
11727
|
+
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
11728
|
+
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
11729
|
+
}
|
|
11730
|
+
include(context, includeChildrenRecursively) {
|
|
11731
|
+
if (!this.deoptimized)
|
|
11732
|
+
this.applyDeoptimizations();
|
|
11733
|
+
this.included = true;
|
|
11734
|
+
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
11735
|
+
}
|
|
11736
|
+
initialise() {
|
|
11737
|
+
this.argument.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
11912
11738
|
}
|
|
11913
11739
|
render(code, options) {
|
|
11914
11740
|
const { exportNamesByVariable, format, snippets: { _ } } = options;
|
|
@@ -11970,7 +11796,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
11970
11796
|
declarator.deoptimizePath(EMPTY_PATH);
|
|
11971
11797
|
}
|
|
11972
11798
|
}
|
|
11973
|
-
|
|
11799
|
+
hasEffectsOnInteractionAtPath() {
|
|
11974
11800
|
return false;
|
|
11975
11801
|
}
|
|
11976
11802
|
include(context, includeChildrenRecursively, { asSingleStatement } = BLANK) {
|
|
@@ -12133,9 +11959,7 @@ class VariableDeclarator extends NodeBase {
|
|
|
12133
11959
|
include(context, includeChildrenRecursively) {
|
|
12134
11960
|
var _a;
|
|
12135
11961
|
this.included = true;
|
|
12136
|
-
(_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively
|
|
12137
|
-
includeWithoutParameterDefaults: true
|
|
12138
|
-
});
|
|
11962
|
+
(_a = this.init) === null || _a === void 0 ? void 0 : _a.include(context, includeChildrenRecursively);
|
|
12139
11963
|
this.id.markDeclarationReached();
|
|
12140
11964
|
if (includeChildrenRecursively || this.id.shouldBeIncluded(context)) {
|
|
12141
11965
|
this.id.include(context, includeChildrenRecursively);
|
|
@@ -12190,7 +12014,7 @@ class YieldExpression extends NodeBase {
|
|
|
12190
12014
|
var _a;
|
|
12191
12015
|
if (!this.deoptimized)
|
|
12192
12016
|
this.applyDeoptimizations();
|
|
12193
|
-
return !context.ignore.returnYield
|
|
12017
|
+
return !(context.ignore.returnYield && !((_a = this.argument) === null || _a === void 0 ? void 0 : _a.hasEffects(context)));
|
|
12194
12018
|
}
|
|
12195
12019
|
render(code, options) {
|
|
12196
12020
|
if (this.argument) {
|