rollup 1.27.6 → 1.27.10
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 +39 -1
- package/README.md +3 -3
- package/dist/bin/rollup +7 -2
- package/dist/rollup.browser.es.js +3 -3
- package/dist/rollup.browser.js +3 -3
- package/dist/rollup.es.js +526 -510
- package/dist/rollup.js +525 -509
- package/dist/shared/index.js +3 -3
- package/package.json +11 -11
package/dist/rollup.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v1.27.
|
|
4
|
-
|
|
3
|
+
Rollup.js v1.27.10
|
|
4
|
+
Wed, 11 Dec 2019 08:12:01 GMT - commit a562ec571b1a9e6f12ddfb8b8ef6aef4d5212cf8
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
https://github.com/rollup/rollup
|
|
@@ -50,7 +50,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
var version = "1.27.
|
|
53
|
+
var version = "1.27.10";
|
|
54
54
|
|
|
55
55
|
var charToInteger = {};
|
|
56
56
|
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
@@ -1912,7 +1912,7 @@ class PathTracker {
|
|
|
1912
1912
|
return currentPaths[EntitiesKey];
|
|
1913
1913
|
}
|
|
1914
1914
|
}
|
|
1915
|
-
const
|
|
1915
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
1916
1916
|
|
|
1917
1917
|
const BROKEN_FLOW_NONE = 0;
|
|
1918
1918
|
const BROKEN_FLOW_BREAK_CONTINUE = 1;
|
|
@@ -6362,7 +6362,7 @@ class BinaryExpression extends NodeBase {
|
|
|
6362
6362
|
// support some implicit type coercion runtime errors
|
|
6363
6363
|
if (this.operator === '+' &&
|
|
6364
6364
|
this.parent instanceof ExpressionStatement$1 &&
|
|
6365
|
-
this.left.getLiteralValueAtPath(EMPTY_PATH,
|
|
6365
|
+
this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this) === '')
|
|
6366
6366
|
return true;
|
|
6367
6367
|
return super.hasEffects(context);
|
|
6368
6368
|
}
|
|
@@ -6396,12 +6396,282 @@ class BreakStatement extends NodeBase {
|
|
|
6396
6396
|
}
|
|
6397
6397
|
}
|
|
6398
6398
|
|
|
6399
|
+
class Literal extends NodeBase {
|
|
6400
|
+
getLiteralValueAtPath(path) {
|
|
6401
|
+
if (path.length > 0 ||
|
|
6402
|
+
// unknown literals can also be null but do not start with an "n"
|
|
6403
|
+
(this.value === null && this.context.code.charCodeAt(this.start) !== 110) ||
|
|
6404
|
+
typeof this.value === 'bigint' ||
|
|
6405
|
+
// to support shims for regular expressions
|
|
6406
|
+
this.context.code.charCodeAt(this.start) === 47) {
|
|
6407
|
+
return UnknownValue;
|
|
6408
|
+
}
|
|
6409
|
+
return this.value;
|
|
6410
|
+
}
|
|
6411
|
+
getReturnExpressionWhenCalledAtPath(path) {
|
|
6412
|
+
if (path.length !== 1)
|
|
6413
|
+
return UNKNOWN_EXPRESSION;
|
|
6414
|
+
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
6415
|
+
}
|
|
6416
|
+
hasEffectsWhenAccessedAtPath(path) {
|
|
6417
|
+
if (this.value === null) {
|
|
6418
|
+
return path.length > 0;
|
|
6419
|
+
}
|
|
6420
|
+
return path.length > 1;
|
|
6421
|
+
}
|
|
6422
|
+
hasEffectsWhenAssignedAtPath(path) {
|
|
6423
|
+
return path.length > 0;
|
|
6424
|
+
}
|
|
6425
|
+
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
6426
|
+
if (path.length === 1) {
|
|
6427
|
+
return hasMemberEffectWhenCalled(this.members, path[0], this.included, callOptions, context);
|
|
6428
|
+
}
|
|
6429
|
+
return true;
|
|
6430
|
+
}
|
|
6431
|
+
initialise() {
|
|
6432
|
+
this.members = getLiteralMembersForValue(this.value);
|
|
6433
|
+
}
|
|
6434
|
+
render(code) {
|
|
6435
|
+
if (typeof this.value === 'string') {
|
|
6436
|
+
code.indentExclusionRanges.push([this.start + 1, this.end - 1]);
|
|
6437
|
+
}
|
|
6438
|
+
}
|
|
6439
|
+
}
|
|
6440
|
+
|
|
6441
|
+
function getResolvablePropertyKey(memberExpression) {
|
|
6442
|
+
return memberExpression.computed
|
|
6443
|
+
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
6444
|
+
: memberExpression.property.name;
|
|
6445
|
+
}
|
|
6446
|
+
function getResolvableComputedPropertyKey(propertyKey) {
|
|
6447
|
+
if (propertyKey instanceof Literal) {
|
|
6448
|
+
return String(propertyKey.value);
|
|
6449
|
+
}
|
|
6450
|
+
return null;
|
|
6451
|
+
}
|
|
6452
|
+
function getPathIfNotComputed(memberExpression) {
|
|
6453
|
+
const nextPathKey = memberExpression.propertyKey;
|
|
6454
|
+
const object = memberExpression.object;
|
|
6455
|
+
if (typeof nextPathKey === 'string') {
|
|
6456
|
+
if (object instanceof Identifier$1) {
|
|
6457
|
+
return [
|
|
6458
|
+
{ key: object.name, pos: object.start },
|
|
6459
|
+
{ key: nextPathKey, pos: memberExpression.property.start }
|
|
6460
|
+
];
|
|
6461
|
+
}
|
|
6462
|
+
if (object instanceof MemberExpression) {
|
|
6463
|
+
const parentPath = getPathIfNotComputed(object);
|
|
6464
|
+
return (parentPath && [...parentPath, { key: nextPathKey, pos: memberExpression.property.start }]);
|
|
6465
|
+
}
|
|
6466
|
+
}
|
|
6467
|
+
return null;
|
|
6468
|
+
}
|
|
6469
|
+
function getStringFromPath(path) {
|
|
6470
|
+
let pathString = path[0].key;
|
|
6471
|
+
for (let index = 1; index < path.length; index++) {
|
|
6472
|
+
pathString += '.' + path[index].key;
|
|
6473
|
+
}
|
|
6474
|
+
return pathString;
|
|
6475
|
+
}
|
|
6476
|
+
class MemberExpression extends NodeBase {
|
|
6477
|
+
constructor() {
|
|
6478
|
+
super(...arguments);
|
|
6479
|
+
this.variable = null;
|
|
6480
|
+
this.bound = false;
|
|
6481
|
+
this.expressionsToBeDeoptimized = [];
|
|
6482
|
+
this.replacement = null;
|
|
6483
|
+
this.wasPathDeoptimizedWhileOptimized = false;
|
|
6484
|
+
}
|
|
6485
|
+
addExportedVariables() { }
|
|
6486
|
+
bind() {
|
|
6487
|
+
if (this.bound)
|
|
6488
|
+
return;
|
|
6489
|
+
this.bound = true;
|
|
6490
|
+
const path = getPathIfNotComputed(this);
|
|
6491
|
+
const baseVariable = path && this.scope.findVariable(path[0].key);
|
|
6492
|
+
if (baseVariable && baseVariable.isNamespace) {
|
|
6493
|
+
const resolvedVariable = this.resolveNamespaceVariables(baseVariable, path.slice(1));
|
|
6494
|
+
if (!resolvedVariable) {
|
|
6495
|
+
super.bind();
|
|
6496
|
+
}
|
|
6497
|
+
else if (typeof resolvedVariable === 'string') {
|
|
6498
|
+
this.replacement = resolvedVariable;
|
|
6499
|
+
}
|
|
6500
|
+
else {
|
|
6501
|
+
if (resolvedVariable instanceof ExternalVariable && resolvedVariable.module) {
|
|
6502
|
+
resolvedVariable.module.suggestName(path[0].key);
|
|
6503
|
+
}
|
|
6504
|
+
this.variable = resolvedVariable;
|
|
6505
|
+
this.scope.addNamespaceMemberAccess(getStringFromPath(path), resolvedVariable);
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6508
|
+
else {
|
|
6509
|
+
super.bind();
|
|
6510
|
+
// ensure the propertyKey is set for the tree-shaking passes
|
|
6511
|
+
this.getPropertyKey();
|
|
6512
|
+
}
|
|
6513
|
+
}
|
|
6514
|
+
deoptimizeCache() {
|
|
6515
|
+
this.propertyKey = UnknownKey;
|
|
6516
|
+
if (this.wasPathDeoptimizedWhileOptimized) {
|
|
6517
|
+
this.object.deoptimizePath(UNKNOWN_PATH);
|
|
6518
|
+
}
|
|
6519
|
+
for (const expression of this.expressionsToBeDeoptimized) {
|
|
6520
|
+
expression.deoptimizeCache();
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6523
|
+
deoptimizePath(path) {
|
|
6524
|
+
if (!this.bound)
|
|
6525
|
+
this.bind();
|
|
6526
|
+
if (path.length === 0)
|
|
6527
|
+
this.disallowNamespaceReassignment();
|
|
6528
|
+
if (this.variable) {
|
|
6529
|
+
this.variable.deoptimizePath(path);
|
|
6530
|
+
}
|
|
6531
|
+
else {
|
|
6532
|
+
const propertyKey = this.getPropertyKey();
|
|
6533
|
+
if (propertyKey === UnknownKey) {
|
|
6534
|
+
this.object.deoptimizePath(UNKNOWN_PATH);
|
|
6535
|
+
}
|
|
6536
|
+
else {
|
|
6537
|
+
this.wasPathDeoptimizedWhileOptimized = true;
|
|
6538
|
+
this.object.deoptimizePath([propertyKey, ...path]);
|
|
6539
|
+
}
|
|
6540
|
+
}
|
|
6541
|
+
}
|
|
6542
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6543
|
+
if (!this.bound)
|
|
6544
|
+
this.bind();
|
|
6545
|
+
if (this.variable !== null) {
|
|
6546
|
+
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6547
|
+
}
|
|
6548
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
6549
|
+
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
6550
|
+
}
|
|
6551
|
+
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
6552
|
+
if (!this.bound)
|
|
6553
|
+
this.bind();
|
|
6554
|
+
if (this.variable !== null) {
|
|
6555
|
+
return this.variable.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
6556
|
+
}
|
|
6557
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
6558
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
6559
|
+
}
|
|
6560
|
+
hasEffects(context) {
|
|
6561
|
+
return (this.property.hasEffects(context) ||
|
|
6562
|
+
this.object.hasEffects(context) ||
|
|
6563
|
+
(this.context.propertyReadSideEffects &&
|
|
6564
|
+
this.object.hasEffectsWhenAccessedAtPath([this.propertyKey], context)));
|
|
6565
|
+
}
|
|
6566
|
+
hasEffectsWhenAccessedAtPath(path, context) {
|
|
6567
|
+
if (path.length === 0)
|
|
6568
|
+
return false;
|
|
6569
|
+
if (this.variable !== null) {
|
|
6570
|
+
return this.variable.hasEffectsWhenAccessedAtPath(path, context);
|
|
6571
|
+
}
|
|
6572
|
+
return this.object.hasEffectsWhenAccessedAtPath([this.propertyKey, ...path], context);
|
|
6573
|
+
}
|
|
6574
|
+
hasEffectsWhenAssignedAtPath(path, context) {
|
|
6575
|
+
if (this.variable !== null) {
|
|
6576
|
+
return this.variable.hasEffectsWhenAssignedAtPath(path, context);
|
|
6577
|
+
}
|
|
6578
|
+
return this.object.hasEffectsWhenAssignedAtPath([this.propertyKey, ...path], context);
|
|
6579
|
+
}
|
|
6580
|
+
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
6581
|
+
if (this.variable !== null) {
|
|
6582
|
+
return this.variable.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
6583
|
+
}
|
|
6584
|
+
return this.object.hasEffectsWhenCalledAtPath([this.propertyKey, ...path], callOptions, context);
|
|
6585
|
+
}
|
|
6586
|
+
include(context, includeChildrenRecursively) {
|
|
6587
|
+
if (!this.included) {
|
|
6588
|
+
this.included = true;
|
|
6589
|
+
if (this.variable !== null) {
|
|
6590
|
+
this.context.includeVariable(context, this.variable);
|
|
6591
|
+
}
|
|
6592
|
+
}
|
|
6593
|
+
this.object.include(context, includeChildrenRecursively);
|
|
6594
|
+
this.property.include(context, includeChildrenRecursively);
|
|
6595
|
+
}
|
|
6596
|
+
includeCallArguments(context, args) {
|
|
6597
|
+
if (this.variable) {
|
|
6598
|
+
this.variable.includeCallArguments(context, args);
|
|
6599
|
+
}
|
|
6600
|
+
else {
|
|
6601
|
+
super.includeCallArguments(context, args);
|
|
6602
|
+
}
|
|
6603
|
+
}
|
|
6604
|
+
initialise() {
|
|
6605
|
+
this.propertyKey = getResolvablePropertyKey(this);
|
|
6606
|
+
}
|
|
6607
|
+
render(code, options, { renderedParentType, isCalleeOfRenderedParent } = BLANK) {
|
|
6608
|
+
const isCalleeOfDifferentParent = renderedParentType === CallExpression && isCalleeOfRenderedParent;
|
|
6609
|
+
if (this.variable || this.replacement) {
|
|
6610
|
+
let replacement = this.variable ? this.variable.getName() : this.replacement;
|
|
6611
|
+
if (isCalleeOfDifferentParent)
|
|
6612
|
+
replacement = '0, ' + replacement;
|
|
6613
|
+
code.overwrite(this.start, this.end, replacement, {
|
|
6614
|
+
contentOnly: true,
|
|
6615
|
+
storeName: true
|
|
6616
|
+
});
|
|
6617
|
+
}
|
|
6618
|
+
else {
|
|
6619
|
+
if (isCalleeOfDifferentParent) {
|
|
6620
|
+
code.appendRight(this.start, '0, ');
|
|
6621
|
+
}
|
|
6622
|
+
super.render(code, options);
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
disallowNamespaceReassignment() {
|
|
6626
|
+
if (this.object instanceof Identifier$1 &&
|
|
6627
|
+
this.scope.findVariable(this.object.name).isNamespace) {
|
|
6628
|
+
this.context.error({
|
|
6629
|
+
code: 'ILLEGAL_NAMESPACE_REASSIGNMENT',
|
|
6630
|
+
message: `Illegal reassignment to import '${this.object.name}'`
|
|
6631
|
+
}, this.start);
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
getPropertyKey() {
|
|
6635
|
+
if (this.propertyKey === null) {
|
|
6636
|
+
this.propertyKey = UnknownKey;
|
|
6637
|
+
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
6638
|
+
return (this.propertyKey = value === UnknownValue ? UnknownKey : String(value));
|
|
6639
|
+
}
|
|
6640
|
+
return this.propertyKey;
|
|
6641
|
+
}
|
|
6642
|
+
resolveNamespaceVariables(baseVariable, path) {
|
|
6643
|
+
if (path.length === 0)
|
|
6644
|
+
return baseVariable;
|
|
6645
|
+
if (!baseVariable.isNamespace)
|
|
6646
|
+
return null;
|
|
6647
|
+
const exportName = path[0].key;
|
|
6648
|
+
const variable = baseVariable instanceof ExternalVariable
|
|
6649
|
+
? baseVariable.module.getVariableForExportName(exportName)
|
|
6650
|
+
: baseVariable.context.traceExport(exportName);
|
|
6651
|
+
if (!variable) {
|
|
6652
|
+
const fileName = baseVariable instanceof ExternalVariable
|
|
6653
|
+
? baseVariable.module.id
|
|
6654
|
+
: baseVariable.context.fileName;
|
|
6655
|
+
this.context.warn({
|
|
6656
|
+
code: 'MISSING_EXPORT',
|
|
6657
|
+
exporter: relativeId(fileName),
|
|
6658
|
+
importer: relativeId(this.context.fileName),
|
|
6659
|
+
message: `'${exportName}' is not exported by '${relativeId(fileName)}'`,
|
|
6660
|
+
missing: exportName,
|
|
6661
|
+
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
6662
|
+
}, path[0].pos);
|
|
6663
|
+
return 'undefined';
|
|
6664
|
+
}
|
|
6665
|
+
return this.resolveNamespaceVariables(variable, path.slice(1));
|
|
6666
|
+
}
|
|
6667
|
+
}
|
|
6668
|
+
|
|
6399
6669
|
class CallExpression$1 extends NodeBase {
|
|
6400
6670
|
constructor() {
|
|
6401
6671
|
super(...arguments);
|
|
6402
|
-
// We collect deoptimization information if returnExpression !== UNKNOWN_EXPRESSION
|
|
6403
6672
|
this.expressionsToBeDeoptimized = [];
|
|
6404
6673
|
this.returnExpression = null;
|
|
6674
|
+
this.wasPathDeoptmizedWhileOptimized = false;
|
|
6405
6675
|
}
|
|
6406
6676
|
bind() {
|
|
6407
6677
|
super.bind();
|
|
@@ -6421,8 +6691,11 @@ class CallExpression$1 extends NodeBase {
|
|
|
6421
6691
|
}, this.start);
|
|
6422
6692
|
}
|
|
6423
6693
|
}
|
|
6424
|
-
|
|
6425
|
-
|
|
6694
|
+
// ensure the returnExpression is set for the tree-shaking passes
|
|
6695
|
+
this.getReturnExpression(SHARED_RECURSION_TRACKER);
|
|
6696
|
+
// This deoptimizes "this" for non-namespace calls until we have a better solution
|
|
6697
|
+
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
6698
|
+
this.callee.object.deoptimizePath(UNKNOWN_PATH);
|
|
6426
6699
|
}
|
|
6427
6700
|
for (const argument of this.arguments) {
|
|
6428
6701
|
// This will make sure all properties of parameters behave as "unknown"
|
|
@@ -6431,8 +6704,19 @@ class CallExpression$1 extends NodeBase {
|
|
|
6431
6704
|
}
|
|
6432
6705
|
deoptimizeCache() {
|
|
6433
6706
|
if (this.returnExpression !== UNKNOWN_EXPRESSION) {
|
|
6434
|
-
this.returnExpression =
|
|
6435
|
-
|
|
6707
|
+
this.returnExpression = null;
|
|
6708
|
+
const returnExpression = this.getReturnExpression(SHARED_RECURSION_TRACKER);
|
|
6709
|
+
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized;
|
|
6710
|
+
if (returnExpression !== UNKNOWN_EXPRESSION) {
|
|
6711
|
+
// We need to replace here because is possible new expressions are added
|
|
6712
|
+
// while we are deoptimizing the old ones
|
|
6713
|
+
this.expressionsToBeDeoptimized = [];
|
|
6714
|
+
if (this.wasPathDeoptmizedWhileOptimized) {
|
|
6715
|
+
returnExpression.deoptimizePath(UNKNOWN_PATH);
|
|
6716
|
+
this.wasPathDeoptmizedWhileOptimized = false;
|
|
6717
|
+
}
|
|
6718
|
+
}
|
|
6719
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
6436
6720
|
expression.deoptimizeCache();
|
|
6437
6721
|
}
|
|
6438
6722
|
}
|
|
@@ -6444,43 +6728,40 @@ class CallExpression$1 extends NodeBase {
|
|
|
6444
6728
|
if (trackedEntities.has(this))
|
|
6445
6729
|
return;
|
|
6446
6730
|
trackedEntities.add(this);
|
|
6447
|
-
|
|
6448
|
-
|
|
6731
|
+
const returnExpression = this.getReturnExpression(SHARED_RECURSION_TRACKER);
|
|
6732
|
+
if (returnExpression !== UNKNOWN_EXPRESSION) {
|
|
6733
|
+
this.wasPathDeoptmizedWhileOptimized = true;
|
|
6734
|
+
returnExpression.deoptimizePath(path);
|
|
6449
6735
|
}
|
|
6450
|
-
this.returnExpression.deoptimizePath(path);
|
|
6451
6736
|
}
|
|
6452
6737
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
}
|
|
6456
|
-
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
6738
|
+
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
6739
|
+
if (returnExpression === UNKNOWN_EXPRESSION) {
|
|
6457
6740
|
return UnknownValue;
|
|
6458
6741
|
}
|
|
6459
6742
|
const trackedEntities = recursionTracker.getEntities(path);
|
|
6460
|
-
if (trackedEntities.has(
|
|
6743
|
+
if (trackedEntities.has(returnExpression)) {
|
|
6461
6744
|
return UnknownValue;
|
|
6462
6745
|
}
|
|
6463
6746
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6464
|
-
trackedEntities.add(
|
|
6465
|
-
const value =
|
|
6466
|
-
trackedEntities.delete(
|
|
6747
|
+
trackedEntities.add(returnExpression);
|
|
6748
|
+
const value = returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6749
|
+
trackedEntities.delete(returnExpression);
|
|
6467
6750
|
return value;
|
|
6468
6751
|
}
|
|
6469
6752
|
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
6470
|
-
|
|
6471
|
-
this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, recursionTracker, this);
|
|
6472
|
-
}
|
|
6753
|
+
const returnExpression = this.getReturnExpression(recursionTracker);
|
|
6473
6754
|
if (this.returnExpression === UNKNOWN_EXPRESSION) {
|
|
6474
6755
|
return UNKNOWN_EXPRESSION;
|
|
6475
6756
|
}
|
|
6476
6757
|
const trackedEntities = recursionTracker.getEntities(path);
|
|
6477
|
-
if (trackedEntities.has(
|
|
6758
|
+
if (trackedEntities.has(returnExpression)) {
|
|
6478
6759
|
return UNKNOWN_EXPRESSION;
|
|
6479
6760
|
}
|
|
6480
6761
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6481
|
-
trackedEntities.add(
|
|
6482
|
-
const value =
|
|
6483
|
-
trackedEntities.delete(
|
|
6762
|
+
trackedEntities.add(returnExpression);
|
|
6763
|
+
const value = returnExpression.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
6764
|
+
trackedEntities.delete(returnExpression);
|
|
6484
6765
|
return value;
|
|
6485
6766
|
}
|
|
6486
6767
|
hasEffects(context) {
|
|
@@ -6574,6 +6855,13 @@ class CallExpression$1 extends NodeBase {
|
|
|
6574
6855
|
code.prependLeft(this.end, ')');
|
|
6575
6856
|
}
|
|
6576
6857
|
}
|
|
6858
|
+
getReturnExpression(recursionTracker) {
|
|
6859
|
+
if (this.returnExpression === null) {
|
|
6860
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
6861
|
+
return (this.returnExpression = this.callee.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, recursionTracker, this));
|
|
6862
|
+
}
|
|
6863
|
+
return this.returnExpression;
|
|
6864
|
+
}
|
|
6577
6865
|
}
|
|
6578
6866
|
|
|
6579
6867
|
class CatchScope extends ParameterScope {
|
|
@@ -6668,23 +6956,23 @@ class MultiExpression {
|
|
|
6668
6956
|
class ConditionalExpression extends NodeBase {
|
|
6669
6957
|
constructor() {
|
|
6670
6958
|
super(...arguments);
|
|
6671
|
-
// We collect deoptimization information if usedBranch !== null
|
|
6672
6959
|
this.expressionsToBeDeoptimized = [];
|
|
6673
6960
|
this.isBranchResolutionAnalysed = false;
|
|
6674
|
-
this.unusedBranch = null;
|
|
6675
6961
|
this.usedBranch = null;
|
|
6962
|
+
this.wasPathDeoptimizedWhileOptimized = false;
|
|
6676
6963
|
}
|
|
6677
6964
|
bind() {
|
|
6678
6965
|
super.bind();
|
|
6679
|
-
|
|
6680
|
-
|
|
6966
|
+
// ensure the usedBranch is set for the tree-shaking passes
|
|
6967
|
+
this.getUsedBranch();
|
|
6681
6968
|
}
|
|
6682
6969
|
deoptimizeCache() {
|
|
6683
6970
|
if (this.usedBranch !== null) {
|
|
6684
|
-
|
|
6685
|
-
// Also, the return value might need to be reassigned.
|
|
6971
|
+
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
6686
6972
|
this.usedBranch = null;
|
|
6687
|
-
this.
|
|
6973
|
+
if (this.wasPathDeoptimizedWhileOptimized) {
|
|
6974
|
+
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
6975
|
+
}
|
|
6688
6976
|
for (const expression of this.expressionsToBeDeoptimized) {
|
|
6689
6977
|
expression.deoptimizeCache();
|
|
6690
6978
|
}
|
|
@@ -6692,35 +6980,33 @@ class ConditionalExpression extends NodeBase {
|
|
|
6692
6980
|
}
|
|
6693
6981
|
deoptimizePath(path) {
|
|
6694
6982
|
if (path.length > 0) {
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
if (this.usedBranch === null) {
|
|
6983
|
+
const usedBranch = this.getUsedBranch();
|
|
6984
|
+
if (usedBranch === null) {
|
|
6698
6985
|
this.consequent.deoptimizePath(path);
|
|
6699
6986
|
this.alternate.deoptimizePath(path);
|
|
6700
6987
|
}
|
|
6701
6988
|
else {
|
|
6702
|
-
this.
|
|
6989
|
+
this.wasPathDeoptimizedWhileOptimized = true;
|
|
6990
|
+
usedBranch.deoptimizePath(path);
|
|
6703
6991
|
}
|
|
6704
6992
|
}
|
|
6705
6993
|
}
|
|
6706
6994
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
if (this.usedBranch === null)
|
|
6995
|
+
const usedBranch = this.getUsedBranch();
|
|
6996
|
+
if (usedBranch === null)
|
|
6710
6997
|
return UnknownValue;
|
|
6711
6998
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6712
|
-
return
|
|
6999
|
+
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6713
7000
|
}
|
|
6714
7001
|
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
if (this.usedBranch === null)
|
|
7002
|
+
const usedBranch = this.getUsedBranch();
|
|
7003
|
+
if (usedBranch === null)
|
|
6718
7004
|
return new MultiExpression([
|
|
6719
7005
|
this.consequent.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin),
|
|
6720
7006
|
this.alternate.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin)
|
|
6721
7007
|
]);
|
|
6722
7008
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6723
|
-
return
|
|
7009
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
6724
7010
|
}
|
|
6725
7011
|
hasEffects(context) {
|
|
6726
7012
|
if (this.test.hasEffects(context))
|
|
@@ -6793,19 +7079,15 @@ class ConditionalExpression extends NodeBase {
|
|
|
6793
7079
|
super.render(code, options);
|
|
6794
7080
|
}
|
|
6795
7081
|
}
|
|
6796
|
-
|
|
6797
|
-
this.isBranchResolutionAnalysed
|
|
6798
|
-
|
|
6799
|
-
if (testValue !== UnknownValue) {
|
|
6800
|
-
if (testValue) {
|
|
6801
|
-
this.usedBranch = this.consequent;
|
|
6802
|
-
this.unusedBranch = this.alternate;
|
|
6803
|
-
}
|
|
6804
|
-
else {
|
|
6805
|
-
this.usedBranch = this.alternate;
|
|
6806
|
-
this.unusedBranch = this.consequent;
|
|
6807
|
-
}
|
|
7082
|
+
getUsedBranch() {
|
|
7083
|
+
if (this.isBranchResolutionAnalysed) {
|
|
7084
|
+
return this.usedBranch;
|
|
6808
7085
|
}
|
|
7086
|
+
this.isBranchResolutionAnalysed = true;
|
|
7087
|
+
const testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7088
|
+
return testValue === UnknownValue
|
|
7089
|
+
? null
|
|
7090
|
+
: (this.usedBranch = testValue ? this.consequent : this.alternate);
|
|
6809
7091
|
}
|
|
6810
7092
|
}
|
|
6811
7093
|
|
|
@@ -7016,7 +7298,8 @@ class FunctionExpression$1 extends FunctionNode {
|
|
|
7016
7298
|
class IfStatement extends NodeBase {
|
|
7017
7299
|
bind() {
|
|
7018
7300
|
super.bind();
|
|
7019
|
-
|
|
7301
|
+
// ensure the testValue is set for the tree-shaking passes
|
|
7302
|
+
this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7020
7303
|
}
|
|
7021
7304
|
deoptimizeCache() {
|
|
7022
7305
|
this.testValue = UnknownValue;
|
|
@@ -7277,415 +7560,157 @@ class LabeledStatement extends NodeBase {
|
|
|
7277
7560
|
context.brokenFlow = brokenFlow;
|
|
7278
7561
|
}
|
|
7279
7562
|
}
|
|
7280
|
-
render(code, options) {
|
|
7281
|
-
if (this.label.included) {
|
|
7282
|
-
this.label.render(code, options);
|
|
7283
|
-
}
|
|
7284
|
-
else {
|
|
7285
|
-
code.remove(this.start, findFirstOccurrenceOutsideComment(code.original, ':', this.label.end) + 1);
|
|
7286
|
-
}
|
|
7287
|
-
this.body.render(code, options);
|
|
7288
|
-
}
|
|
7289
|
-
}
|
|
7290
|
-
|
|
7291
|
-
class Literal extends NodeBase {
|
|
7292
|
-
getLiteralValueAtPath(path) {
|
|
7293
|
-
if (path.length > 0 ||
|
|
7294
|
-
// unknown literals can also be null but do not start with an "n"
|
|
7295
|
-
(this.value === null && this.context.code.charCodeAt(this.start) !== 110) ||
|
|
7296
|
-
typeof this.value === 'bigint' ||
|
|
7297
|
-
// to support shims for regular expressions
|
|
7298
|
-
this.context.code.charCodeAt(this.start) === 47) {
|
|
7299
|
-
return UnknownValue;
|
|
7300
|
-
}
|
|
7301
|
-
return this.value;
|
|
7302
|
-
}
|
|
7303
|
-
getReturnExpressionWhenCalledAtPath(path) {
|
|
7304
|
-
if (path.length !== 1)
|
|
7305
|
-
return UNKNOWN_EXPRESSION;
|
|
7306
|
-
return getMemberReturnExpressionWhenCalled(this.members, path[0]);
|
|
7307
|
-
}
|
|
7308
|
-
hasEffectsWhenAccessedAtPath(path) {
|
|
7309
|
-
if (this.value === null) {
|
|
7310
|
-
return path.length > 0;
|
|
7311
|
-
}
|
|
7312
|
-
return path.length > 1;
|
|
7313
|
-
}
|
|
7314
|
-
hasEffectsWhenAssignedAtPath(path) {
|
|
7315
|
-
return path.length > 0;
|
|
7316
|
-
}
|
|
7317
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7318
|
-
if (path.length === 1) {
|
|
7319
|
-
return hasMemberEffectWhenCalled(this.members, path[0], this.included, callOptions, context);
|
|
7320
|
-
}
|
|
7321
|
-
return true;
|
|
7322
|
-
}
|
|
7323
|
-
initialise() {
|
|
7324
|
-
this.members = getLiteralMembersForValue(this.value);
|
|
7325
|
-
}
|
|
7326
|
-
render(code) {
|
|
7327
|
-
if (typeof this.value === 'string') {
|
|
7328
|
-
code.indentExclusionRanges.push([this.start + 1, this.end - 1]);
|
|
7329
|
-
}
|
|
7330
|
-
}
|
|
7331
|
-
}
|
|
7332
|
-
|
|
7333
|
-
class LogicalExpression extends NodeBase {
|
|
7334
|
-
constructor() {
|
|
7335
|
-
super(...arguments);
|
|
7336
|
-
// We collect deoptimization information if usedBranch !== null
|
|
7337
|
-
this.expressionsToBeDeoptimized = [];
|
|
7338
|
-
this.isBranchResolutionAnalysed = false;
|
|
7339
|
-
this.unusedBranch = null;
|
|
7340
|
-
this.usedBranch = null;
|
|
7341
|
-
}
|
|
7342
|
-
bind() {
|
|
7343
|
-
super.bind();
|
|
7344
|
-
if (!this.isBranchResolutionAnalysed)
|
|
7345
|
-
this.analyseBranchResolution();
|
|
7346
|
-
}
|
|
7347
|
-
deoptimizeCache() {
|
|
7348
|
-
if (this.usedBranch !== null) {
|
|
7349
|
-
// We did not track if there were reassignments to any of the branches.
|
|
7350
|
-
// Also, the return values might need reassignment.
|
|
7351
|
-
this.usedBranch = null;
|
|
7352
|
-
this.unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
7353
|
-
for (const expression of this.expressionsToBeDeoptimized) {
|
|
7354
|
-
expression.deoptimizeCache();
|
|
7355
|
-
}
|
|
7356
|
-
}
|
|
7357
|
-
}
|
|
7358
|
-
deoptimizePath(path) {
|
|
7359
|
-
if (path.length > 0) {
|
|
7360
|
-
if (!this.isBranchResolutionAnalysed)
|
|
7361
|
-
this.analyseBranchResolution();
|
|
7362
|
-
if (this.usedBranch === null) {
|
|
7363
|
-
this.left.deoptimizePath(path);
|
|
7364
|
-
this.right.deoptimizePath(path);
|
|
7365
|
-
}
|
|
7366
|
-
else {
|
|
7367
|
-
this.usedBranch.deoptimizePath(path);
|
|
7368
|
-
}
|
|
7369
|
-
}
|
|
7370
|
-
}
|
|
7371
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7372
|
-
if (!this.isBranchResolutionAnalysed)
|
|
7373
|
-
this.analyseBranchResolution();
|
|
7374
|
-
if (this.usedBranch === null)
|
|
7375
|
-
return UnknownValue;
|
|
7376
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7377
|
-
return this.usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7378
|
-
}
|
|
7379
|
-
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
7380
|
-
if (!this.isBranchResolutionAnalysed)
|
|
7381
|
-
this.analyseBranchResolution();
|
|
7382
|
-
if (this.usedBranch === null)
|
|
7383
|
-
return new MultiExpression([
|
|
7384
|
-
this.left.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin),
|
|
7385
|
-
this.right.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin)
|
|
7386
|
-
]);
|
|
7387
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
7388
|
-
return this.usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
7389
|
-
}
|
|
7390
|
-
hasEffects(context) {
|
|
7391
|
-
if (this.usedBranch === null) {
|
|
7392
|
-
return this.left.hasEffects(context) || this.right.hasEffects(context);
|
|
7393
|
-
}
|
|
7394
|
-
return this.usedBranch.hasEffects(context);
|
|
7395
|
-
}
|
|
7396
|
-
hasEffectsWhenAccessedAtPath(path, context) {
|
|
7397
|
-
if (path.length === 0)
|
|
7398
|
-
return false;
|
|
7399
|
-
if (this.usedBranch === null) {
|
|
7400
|
-
return (this.left.hasEffectsWhenAccessedAtPath(path, context) ||
|
|
7401
|
-
this.right.hasEffectsWhenAccessedAtPath(path, context));
|
|
7402
|
-
}
|
|
7403
|
-
return this.usedBranch.hasEffectsWhenAccessedAtPath(path, context);
|
|
7404
|
-
}
|
|
7405
|
-
hasEffectsWhenAssignedAtPath(path, context) {
|
|
7406
|
-
if (path.length === 0)
|
|
7407
|
-
return true;
|
|
7408
|
-
if (this.usedBranch === null) {
|
|
7409
|
-
return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
7410
|
-
this.right.hasEffectsWhenAssignedAtPath(path, context));
|
|
7411
|
-
}
|
|
7412
|
-
return this.usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
7413
|
-
}
|
|
7414
|
-
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7415
|
-
if (this.usedBranch === null) {
|
|
7416
|
-
return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
|
|
7417
|
-
this.right.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
7418
|
-
}
|
|
7419
|
-
return this.usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
7420
|
-
}
|
|
7421
|
-
include(context, includeChildrenRecursively) {
|
|
7422
|
-
this.included = true;
|
|
7423
|
-
if (includeChildrenRecursively ||
|
|
7424
|
-
this.usedBranch === null ||
|
|
7425
|
-
this.unusedBranch.shouldBeIncluded(context)) {
|
|
7426
|
-
this.left.include(context, includeChildrenRecursively);
|
|
7427
|
-
this.right.include(context, includeChildrenRecursively);
|
|
7428
|
-
}
|
|
7429
|
-
else {
|
|
7430
|
-
this.usedBranch.include(context, includeChildrenRecursively);
|
|
7431
|
-
}
|
|
7432
|
-
}
|
|
7433
|
-
render(code, options, { renderedParentType, isCalleeOfRenderedParent, preventASI } = BLANK) {
|
|
7434
|
-
if (!this.left.included || !this.right.included) {
|
|
7435
|
-
const operatorPos = findFirstOccurrenceOutsideComment(code.original, this.operator, this.left.end);
|
|
7436
|
-
if (this.right.included) {
|
|
7437
|
-
code.remove(this.start, operatorPos + 2);
|
|
7438
|
-
if (preventASI) {
|
|
7439
|
-
removeLineBreaks(code, operatorPos + 2, this.right.start);
|
|
7440
|
-
}
|
|
7441
|
-
}
|
|
7442
|
-
else {
|
|
7443
|
-
code.remove(operatorPos, this.end);
|
|
7444
|
-
}
|
|
7445
|
-
removeAnnotations(this, code);
|
|
7446
|
-
this.usedBranch.render(code, options, {
|
|
7447
|
-
isCalleeOfRenderedParent: renderedParentType
|
|
7448
|
-
? isCalleeOfRenderedParent
|
|
7449
|
-
: this.parent.callee === this,
|
|
7450
|
-
renderedParentType: renderedParentType || this.parent.type
|
|
7451
|
-
});
|
|
7452
|
-
}
|
|
7453
|
-
else {
|
|
7454
|
-
super.render(code, options);
|
|
7455
|
-
}
|
|
7456
|
-
}
|
|
7457
|
-
analyseBranchResolution() {
|
|
7458
|
-
this.isBranchResolutionAnalysed = true;
|
|
7459
|
-
const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, EMPTY_IMMUTABLE_TRACKER, this);
|
|
7460
|
-
if (leftValue !== UnknownValue) {
|
|
7461
|
-
if (this.operator === '||' ? leftValue : !leftValue) {
|
|
7462
|
-
this.usedBranch = this.left;
|
|
7463
|
-
this.unusedBranch = this.right;
|
|
7464
|
-
}
|
|
7465
|
-
else {
|
|
7466
|
-
this.usedBranch = this.right;
|
|
7467
|
-
this.unusedBranch = this.left;
|
|
7468
|
-
}
|
|
7469
|
-
}
|
|
7470
|
-
}
|
|
7471
|
-
}
|
|
7472
|
-
|
|
7473
|
-
function getResolvablePropertyKey(memberExpression) {
|
|
7474
|
-
return memberExpression.computed
|
|
7475
|
-
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
7476
|
-
: memberExpression.property.name;
|
|
7477
|
-
}
|
|
7478
|
-
function getResolvableComputedPropertyKey(propertyKey) {
|
|
7479
|
-
if (propertyKey instanceof Literal) {
|
|
7480
|
-
return String(propertyKey.value);
|
|
7481
|
-
}
|
|
7482
|
-
return null;
|
|
7483
|
-
}
|
|
7484
|
-
function getPathIfNotComputed(memberExpression) {
|
|
7485
|
-
const nextPathKey = memberExpression.propertyKey;
|
|
7486
|
-
const object = memberExpression.object;
|
|
7487
|
-
if (typeof nextPathKey === 'string') {
|
|
7488
|
-
if (object instanceof Identifier$1) {
|
|
7489
|
-
return [
|
|
7490
|
-
{ key: object.name, pos: object.start },
|
|
7491
|
-
{ key: nextPathKey, pos: memberExpression.property.start }
|
|
7492
|
-
];
|
|
7493
|
-
}
|
|
7494
|
-
if (object instanceof MemberExpression) {
|
|
7495
|
-
const parentPath = getPathIfNotComputed(object);
|
|
7496
|
-
return (parentPath && [...parentPath, { key: nextPathKey, pos: memberExpression.property.start }]);
|
|
7497
|
-
}
|
|
7498
|
-
}
|
|
7499
|
-
return null;
|
|
7500
|
-
}
|
|
7501
|
-
function getStringFromPath(path) {
|
|
7502
|
-
let pathString = path[0].key;
|
|
7503
|
-
for (let index = 1; index < path.length; index++) {
|
|
7504
|
-
pathString += '.' + path[index].key;
|
|
7563
|
+
render(code, options) {
|
|
7564
|
+
if (this.label.included) {
|
|
7565
|
+
this.label.render(code, options);
|
|
7566
|
+
}
|
|
7567
|
+
else {
|
|
7568
|
+
code.remove(this.start, findFirstOccurrenceOutsideComment(code.original, ':', this.label.end) + 1);
|
|
7569
|
+
}
|
|
7570
|
+
this.body.render(code, options);
|
|
7505
7571
|
}
|
|
7506
|
-
return pathString;
|
|
7507
7572
|
}
|
|
7508
|
-
|
|
7573
|
+
|
|
7574
|
+
class LogicalExpression extends NodeBase {
|
|
7509
7575
|
constructor() {
|
|
7510
7576
|
super(...arguments);
|
|
7511
|
-
|
|
7512
|
-
this.bound = false;
|
|
7577
|
+
// We collect deoptimization information if usedBranch !== null
|
|
7513
7578
|
this.expressionsToBeDeoptimized = [];
|
|
7514
|
-
this.
|
|
7579
|
+
this.isBranchResolutionAnalysed = false;
|
|
7580
|
+
this.unusedBranch = null;
|
|
7581
|
+
this.usedBranch = null;
|
|
7582
|
+
this.wasPathDeoptimizedWhileOptimized = false;
|
|
7515
7583
|
}
|
|
7516
|
-
addExportedVariables() { }
|
|
7517
7584
|
bind() {
|
|
7518
|
-
|
|
7519
|
-
|
|
7520
|
-
this.
|
|
7521
|
-
const path = getPathIfNotComputed(this);
|
|
7522
|
-
const baseVariable = path && this.scope.findVariable(path[0].key);
|
|
7523
|
-
if (baseVariable && baseVariable.isNamespace) {
|
|
7524
|
-
const resolvedVariable = this.resolveNamespaceVariables(baseVariable, path.slice(1));
|
|
7525
|
-
if (!resolvedVariable) {
|
|
7526
|
-
super.bind();
|
|
7527
|
-
}
|
|
7528
|
-
else if (typeof resolvedVariable === 'string') {
|
|
7529
|
-
this.replacement = resolvedVariable;
|
|
7530
|
-
}
|
|
7531
|
-
else {
|
|
7532
|
-
if (resolvedVariable instanceof ExternalVariable && resolvedVariable.module) {
|
|
7533
|
-
resolvedVariable.module.suggestName(path[0].key);
|
|
7534
|
-
}
|
|
7535
|
-
this.variable = resolvedVariable;
|
|
7536
|
-
this.scope.addNamespaceMemberAccess(getStringFromPath(path), resolvedVariable);
|
|
7537
|
-
}
|
|
7538
|
-
}
|
|
7539
|
-
else {
|
|
7540
|
-
super.bind();
|
|
7541
|
-
if (this.propertyKey === null)
|
|
7542
|
-
this.analysePropertyKey();
|
|
7543
|
-
}
|
|
7585
|
+
super.bind();
|
|
7586
|
+
// ensure the usedBranch is set for the tree-shaking passes
|
|
7587
|
+
this.getUsedBranch();
|
|
7544
7588
|
}
|
|
7545
7589
|
deoptimizeCache() {
|
|
7546
|
-
|
|
7547
|
-
|
|
7590
|
+
if (this.usedBranch !== null) {
|
|
7591
|
+
this.usedBranch = null;
|
|
7592
|
+
if (this.wasPathDeoptimizedWhileOptimized) {
|
|
7593
|
+
this.unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
7594
|
+
}
|
|
7595
|
+
for (const expression of this.expressionsToBeDeoptimized) {
|
|
7596
|
+
expression.deoptimizeCache();
|
|
7597
|
+
}
|
|
7548
7598
|
}
|
|
7549
7599
|
}
|
|
7550
7600
|
deoptimizePath(path) {
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
this.
|
|
7555
|
-
if (this.variable) {
|
|
7556
|
-
this.variable.deoptimizePath(path);
|
|
7601
|
+
const usedBranch = this.getUsedBranch();
|
|
7602
|
+
if (usedBranch === null) {
|
|
7603
|
+
this.left.deoptimizePath(path);
|
|
7604
|
+
this.right.deoptimizePath(path);
|
|
7557
7605
|
}
|
|
7558
7606
|
else {
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
this.object.deoptimizePath([this.propertyKey, ...path]);
|
|
7607
|
+
this.wasPathDeoptimizedWhileOptimized = true;
|
|
7608
|
+
usedBranch.deoptimizePath(path);
|
|
7562
7609
|
}
|
|
7563
7610
|
}
|
|
7564
7611
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
return this.variable.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7569
|
-
}
|
|
7570
|
-
if (this.propertyKey === null)
|
|
7571
|
-
this.analysePropertyKey();
|
|
7612
|
+
const usedBranch = this.getUsedBranch();
|
|
7613
|
+
if (usedBranch === null)
|
|
7614
|
+
return UnknownValue;
|
|
7572
7615
|
this.expressionsToBeDeoptimized.push(origin);
|
|
7573
|
-
return
|
|
7616
|
+
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
7574
7617
|
}
|
|
7575
7618
|
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
this.analysePropertyKey();
|
|
7619
|
+
const usedBranch = this.getUsedBranch();
|
|
7620
|
+
if (usedBranch === null)
|
|
7621
|
+
return new MultiExpression([
|
|
7622
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin),
|
|
7623
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin)
|
|
7624
|
+
]);
|
|
7583
7625
|
this.expressionsToBeDeoptimized.push(origin);
|
|
7584
|
-
return
|
|
7626
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
7585
7627
|
}
|
|
7586
7628
|
hasEffects(context) {
|
|
7587
|
-
|
|
7588
|
-
this.
|
|
7589
|
-
|
|
7590
|
-
|
|
7629
|
+
if (this.usedBranch === null) {
|
|
7630
|
+
return this.left.hasEffects(context) || this.right.hasEffects(context);
|
|
7631
|
+
}
|
|
7632
|
+
return this.usedBranch.hasEffects(context);
|
|
7591
7633
|
}
|
|
7592
7634
|
hasEffectsWhenAccessedAtPath(path, context) {
|
|
7593
7635
|
if (path.length === 0)
|
|
7594
7636
|
return false;
|
|
7595
|
-
if (this.
|
|
7596
|
-
return this.
|
|
7637
|
+
if (this.usedBranch === null) {
|
|
7638
|
+
return (this.left.hasEffectsWhenAccessedAtPath(path, context) ||
|
|
7639
|
+
this.right.hasEffectsWhenAccessedAtPath(path, context));
|
|
7597
7640
|
}
|
|
7598
|
-
return this.
|
|
7641
|
+
return this.usedBranch.hasEffectsWhenAccessedAtPath(path, context);
|
|
7599
7642
|
}
|
|
7600
7643
|
hasEffectsWhenAssignedAtPath(path, context) {
|
|
7601
|
-
if (
|
|
7602
|
-
return
|
|
7644
|
+
if (path.length === 0)
|
|
7645
|
+
return true;
|
|
7646
|
+
if (this.usedBranch === null) {
|
|
7647
|
+
return (this.left.hasEffectsWhenAssignedAtPath(path, context) ||
|
|
7648
|
+
this.right.hasEffectsWhenAssignedAtPath(path, context));
|
|
7603
7649
|
}
|
|
7604
|
-
return this.
|
|
7650
|
+
return this.usedBranch.hasEffectsWhenAssignedAtPath(path, context);
|
|
7605
7651
|
}
|
|
7606
7652
|
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
7607
|
-
if (this.
|
|
7608
|
-
return this.
|
|
7653
|
+
if (this.usedBranch === null) {
|
|
7654
|
+
return (this.left.hasEffectsWhenCalledAtPath(path, callOptions, context) ||
|
|
7655
|
+
this.right.hasEffectsWhenCalledAtPath(path, callOptions, context));
|
|
7609
7656
|
}
|
|
7610
|
-
return this.
|
|
7657
|
+
return this.usedBranch.hasEffectsWhenCalledAtPath(path, callOptions, context);
|
|
7611
7658
|
}
|
|
7612
7659
|
include(context, includeChildrenRecursively) {
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7617
|
-
|
|
7618
|
-
|
|
7619
|
-
this.object.include(context, includeChildrenRecursively);
|
|
7620
|
-
this.property.include(context, includeChildrenRecursively);
|
|
7621
|
-
}
|
|
7622
|
-
includeCallArguments(context, args) {
|
|
7623
|
-
if (this.variable) {
|
|
7624
|
-
this.variable.includeCallArguments(context, args);
|
|
7660
|
+
this.included = true;
|
|
7661
|
+
if (includeChildrenRecursively ||
|
|
7662
|
+
this.usedBranch === null ||
|
|
7663
|
+
this.unusedBranch.shouldBeIncluded(context)) {
|
|
7664
|
+
this.left.include(context, includeChildrenRecursively);
|
|
7665
|
+
this.right.include(context, includeChildrenRecursively);
|
|
7625
7666
|
}
|
|
7626
7667
|
else {
|
|
7627
|
-
|
|
7668
|
+
this.usedBranch.include(context, includeChildrenRecursively);
|
|
7628
7669
|
}
|
|
7629
7670
|
}
|
|
7630
|
-
|
|
7631
|
-
this.
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7638
|
-
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7671
|
+
render(code, options, { renderedParentType, isCalleeOfRenderedParent, preventASI } = BLANK) {
|
|
7672
|
+
if (!this.left.included || !this.right.included) {
|
|
7673
|
+
const operatorPos = findFirstOccurrenceOutsideComment(code.original, this.operator, this.left.end);
|
|
7674
|
+
if (this.right.included) {
|
|
7675
|
+
code.remove(this.start, operatorPos + 2);
|
|
7676
|
+
if (preventASI) {
|
|
7677
|
+
removeLineBreaks(code, operatorPos + 2, this.right.start);
|
|
7678
|
+
}
|
|
7679
|
+
}
|
|
7680
|
+
else {
|
|
7681
|
+
code.remove(operatorPos, this.end);
|
|
7682
|
+
}
|
|
7683
|
+
removeAnnotations(this, code);
|
|
7684
|
+
this.usedBranch.render(code, options, {
|
|
7685
|
+
isCalleeOfRenderedParent: renderedParentType
|
|
7686
|
+
? isCalleeOfRenderedParent
|
|
7687
|
+
: this.parent.callee === this,
|
|
7688
|
+
renderedParentType: renderedParentType || this.parent.type
|
|
7642
7689
|
});
|
|
7643
7690
|
}
|
|
7644
7691
|
else {
|
|
7645
|
-
if (isCalleeOfDifferentParent) {
|
|
7646
|
-
code.appendRight(this.start, '0, ');
|
|
7647
|
-
}
|
|
7648
7692
|
super.render(code, options);
|
|
7649
7693
|
}
|
|
7650
7694
|
}
|
|
7651
|
-
|
|
7652
|
-
this.
|
|
7653
|
-
|
|
7654
|
-
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
if (!baseVariable.isNamespace)
|
|
7669
|
-
return null;
|
|
7670
|
-
const exportName = path[0].key;
|
|
7671
|
-
const variable = baseVariable instanceof ExternalVariable
|
|
7672
|
-
? baseVariable.module.getVariableForExportName(exportName)
|
|
7673
|
-
: baseVariable.context.traceExport(exportName);
|
|
7674
|
-
if (!variable) {
|
|
7675
|
-
const fileName = baseVariable instanceof ExternalVariable
|
|
7676
|
-
? baseVariable.module.id
|
|
7677
|
-
: baseVariable.context.fileName;
|
|
7678
|
-
this.context.warn({
|
|
7679
|
-
code: 'MISSING_EXPORT',
|
|
7680
|
-
exporter: relativeId(fileName),
|
|
7681
|
-
importer: relativeId(this.context.fileName),
|
|
7682
|
-
message: `'${exportName}' is not exported by '${relativeId(fileName)}'`,
|
|
7683
|
-
missing: exportName,
|
|
7684
|
-
url: `https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module`
|
|
7685
|
-
}, path[0].pos);
|
|
7686
|
-
return 'undefined';
|
|
7695
|
+
getUsedBranch() {
|
|
7696
|
+
if (!this.isBranchResolutionAnalysed) {
|
|
7697
|
+
this.isBranchResolutionAnalysed = true;
|
|
7698
|
+
const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7699
|
+
if (leftValue === UnknownValue) {
|
|
7700
|
+
return null;
|
|
7701
|
+
}
|
|
7702
|
+
else {
|
|
7703
|
+
if (this.operator === '||' ? leftValue : !leftValue) {
|
|
7704
|
+
this.usedBranch = this.left;
|
|
7705
|
+
this.unusedBranch = this.right;
|
|
7706
|
+
}
|
|
7707
|
+
else {
|
|
7708
|
+
this.usedBranch = this.right;
|
|
7709
|
+
this.unusedBranch = this.left;
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7687
7712
|
}
|
|
7688
|
-
return this.
|
|
7713
|
+
return this.usedBranch;
|
|
7689
7714
|
}
|
|
7690
7715
|
}
|
|
7691
7716
|
|
|
@@ -7998,8 +8023,8 @@ class ObjectExpression extends NodeBase {
|
|
|
7998
8023
|
}
|
|
7999
8024
|
bind() {
|
|
8000
8025
|
super.bind();
|
|
8001
|
-
|
|
8002
|
-
|
|
8026
|
+
// ensure the propertyMap is set for the tree-shaking passes
|
|
8027
|
+
this.getPropertyMap();
|
|
8003
8028
|
}
|
|
8004
8029
|
// We could also track this per-property but this would quickly become much more complex
|
|
8005
8030
|
deoptimizeCache() {
|
|
@@ -8009,12 +8034,7 @@ class ObjectExpression extends NodeBase {
|
|
|
8009
8034
|
deoptimizePath(path) {
|
|
8010
8035
|
if (this.hasUnknownDeoptimizedProperty)
|
|
8011
8036
|
return;
|
|
8012
|
-
|
|
8013
|
-
this.buildPropertyMap();
|
|
8014
|
-
if (path.length === 0) {
|
|
8015
|
-
this.deoptimizeAllProperties();
|
|
8016
|
-
return;
|
|
8017
|
-
}
|
|
8037
|
+
const propertyMap = this.getPropertyMap();
|
|
8018
8038
|
const key = path[0];
|
|
8019
8039
|
if (path.length === 1) {
|
|
8020
8040
|
if (typeof key !== 'string') {
|
|
@@ -8035,16 +8055,15 @@ class ObjectExpression extends NodeBase {
|
|
|
8035
8055
|
}
|
|
8036
8056
|
const subPath = path.length === 1 ? UNKNOWN_PATH : path.slice(1);
|
|
8037
8057
|
for (const property of typeof key === 'string'
|
|
8038
|
-
?
|
|
8039
|
-
?
|
|
8058
|
+
? propertyMap[key]
|
|
8059
|
+
? propertyMap[key].propertiesRead
|
|
8040
8060
|
: []
|
|
8041
8061
|
: this.properties) {
|
|
8042
8062
|
property.deoptimizePath(subPath);
|
|
8043
8063
|
}
|
|
8044
8064
|
}
|
|
8045
8065
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8046
|
-
|
|
8047
|
-
this.buildPropertyMap();
|
|
8066
|
+
const propertyMap = this.getPropertyMap();
|
|
8048
8067
|
const key = path[0];
|
|
8049
8068
|
if (path.length === 0 ||
|
|
8050
8069
|
this.hasUnknownDeoptimizedProperty ||
|
|
@@ -8052,7 +8071,7 @@ class ObjectExpression extends NodeBase {
|
|
|
8052
8071
|
this.deoptimizedPaths.has(key))
|
|
8053
8072
|
return UnknownValue;
|
|
8054
8073
|
if (path.length === 1 &&
|
|
8055
|
-
!
|
|
8074
|
+
!propertyMap[key] &&
|
|
8056
8075
|
!objectMembers[key] &&
|
|
8057
8076
|
this.unmatchablePropertiesRead.length === 0) {
|
|
8058
8077
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized.get(key);
|
|
@@ -8064,9 +8083,9 @@ class ObjectExpression extends NodeBase {
|
|
|
8064
8083
|
}
|
|
8065
8084
|
return undefined;
|
|
8066
8085
|
}
|
|
8067
|
-
if (!
|
|
8068
|
-
|
|
8069
|
-
|
|
8086
|
+
if (!propertyMap[key] ||
|
|
8087
|
+
propertyMap[key].exactMatchRead === null ||
|
|
8088
|
+
propertyMap[key].propertiesRead.length > 1) {
|
|
8070
8089
|
return UnknownValue;
|
|
8071
8090
|
}
|
|
8072
8091
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized.get(key);
|
|
@@ -8076,12 +8095,10 @@ class ObjectExpression extends NodeBase {
|
|
|
8076
8095
|
else {
|
|
8077
8096
|
this.expressionsToBeDeoptimized.set(key, [origin]);
|
|
8078
8097
|
}
|
|
8079
|
-
return
|
|
8080
|
-
.exactMatchRead.getLiteralValueAtPath(path.slice(1), recursionTracker, origin);
|
|
8098
|
+
return propertyMap[key].exactMatchRead.getLiteralValueAtPath(path.slice(1), recursionTracker, origin);
|
|
8081
8099
|
}
|
|
8082
8100
|
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
8083
|
-
|
|
8084
|
-
this.buildPropertyMap();
|
|
8101
|
+
const propertyMap = this.getPropertyMap();
|
|
8085
8102
|
const key = path[0];
|
|
8086
8103
|
if (path.length === 0 ||
|
|
8087
8104
|
this.hasUnknownDeoptimizedProperty ||
|
|
@@ -8091,12 +8108,11 @@ class ObjectExpression extends NodeBase {
|
|
|
8091
8108
|
if (path.length === 1 &&
|
|
8092
8109
|
objectMembers[key] &&
|
|
8093
8110
|
this.unmatchablePropertiesRead.length === 0 &&
|
|
8094
|
-
(!
|
|
8095
|
-
this.propertyMap[key].exactMatchRead === null))
|
|
8111
|
+
(!propertyMap[key] || propertyMap[key].exactMatchRead === null))
|
|
8096
8112
|
return getMemberReturnExpressionWhenCalled(objectMembers, key);
|
|
8097
|
-
if (!
|
|
8098
|
-
|
|
8099
|
-
|
|
8113
|
+
if (!propertyMap[key] ||
|
|
8114
|
+
propertyMap[key].exactMatchRead === null ||
|
|
8115
|
+
propertyMap[key].propertiesRead.length > 1)
|
|
8100
8116
|
return UNKNOWN_EXPRESSION;
|
|
8101
8117
|
const expressionsToBeDeoptimized = this.expressionsToBeDeoptimized.get(key);
|
|
8102
8118
|
if (expressionsToBeDeoptimized) {
|
|
@@ -8105,25 +8121,25 @@ class ObjectExpression extends NodeBase {
|
|
|
8105
8121
|
else {
|
|
8106
8122
|
this.expressionsToBeDeoptimized.set(key, [origin]);
|
|
8107
8123
|
}
|
|
8108
|
-
return
|
|
8109
|
-
.exactMatchRead.getReturnExpressionWhenCalledAtPath(path.slice(1), recursionTracker, origin);
|
|
8124
|
+
return propertyMap[key].exactMatchRead.getReturnExpressionWhenCalledAtPath(path.slice(1), recursionTracker, origin);
|
|
8110
8125
|
}
|
|
8111
8126
|
hasEffectsWhenAccessedAtPath(path, context) {
|
|
8112
8127
|
if (path.length === 0)
|
|
8113
8128
|
return false;
|
|
8114
8129
|
const key = path[0];
|
|
8130
|
+
const propertyMap = this.propertyMap;
|
|
8115
8131
|
if (path.length > 1 &&
|
|
8116
8132
|
(this.hasUnknownDeoptimizedProperty ||
|
|
8117
8133
|
typeof key !== 'string' ||
|
|
8118
8134
|
this.deoptimizedPaths.has(key) ||
|
|
8119
|
-
!
|
|
8120
|
-
|
|
8135
|
+
!propertyMap[key] ||
|
|
8136
|
+
propertyMap[key].exactMatchRead === null))
|
|
8121
8137
|
return true;
|
|
8122
8138
|
const subPath = path.slice(1);
|
|
8123
8139
|
for (const property of typeof key !== 'string'
|
|
8124
8140
|
? this.properties
|
|
8125
|
-
:
|
|
8126
|
-
?
|
|
8141
|
+
: propertyMap[key]
|
|
8142
|
+
? propertyMap[key].propertiesRead
|
|
8127
8143
|
: []) {
|
|
8128
8144
|
if (property.hasEffectsWhenAccessedAtPath(subPath, context))
|
|
8129
8145
|
return true;
|
|
@@ -8131,23 +8147,22 @@ class ObjectExpression extends NodeBase {
|
|
|
8131
8147
|
return false;
|
|
8132
8148
|
}
|
|
8133
8149
|
hasEffectsWhenAssignedAtPath(path, context) {
|
|
8134
|
-
if (path.length === 0)
|
|
8135
|
-
return false;
|
|
8136
8150
|
const key = path[0];
|
|
8151
|
+
const propertyMap = this.propertyMap;
|
|
8137
8152
|
if (path.length > 1 &&
|
|
8138
8153
|
(this.hasUnknownDeoptimizedProperty ||
|
|
8139
|
-
typeof key !== 'string' ||
|
|
8140
8154
|
this.deoptimizedPaths.has(key) ||
|
|
8141
|
-
!
|
|
8142
|
-
|
|
8155
|
+
!propertyMap[key] ||
|
|
8156
|
+
propertyMap[key].exactMatchRead === null)) {
|
|
8143
8157
|
return true;
|
|
8158
|
+
}
|
|
8144
8159
|
const subPath = path.slice(1);
|
|
8145
8160
|
for (const property of typeof key !== 'string'
|
|
8146
8161
|
? this.properties
|
|
8147
8162
|
: path.length > 1
|
|
8148
|
-
?
|
|
8149
|
-
:
|
|
8150
|
-
?
|
|
8163
|
+
? propertyMap[key].propertiesRead
|
|
8164
|
+
: propertyMap[key]
|
|
8165
|
+
? propertyMap[key].propertiesWrite
|
|
8151
8166
|
: []) {
|
|
8152
8167
|
if (property.hasEffectsWhenAssignedAtPath(subPath, context))
|
|
8153
8168
|
return true;
|
|
@@ -8156,20 +8171,20 @@ class ObjectExpression extends NodeBase {
|
|
|
8156
8171
|
}
|
|
8157
8172
|
hasEffectsWhenCalledAtPath(path, callOptions, context) {
|
|
8158
8173
|
const key = path[0];
|
|
8159
|
-
if (
|
|
8174
|
+
if (typeof key !== 'string' ||
|
|
8160
8175
|
this.hasUnknownDeoptimizedProperty ||
|
|
8161
|
-
typeof key !== 'string' ||
|
|
8162
8176
|
this.deoptimizedPaths.has(key) ||
|
|
8163
8177
|
(this.propertyMap[key]
|
|
8164
8178
|
? !this.propertyMap[key].exactMatchRead
|
|
8165
|
-
: path.length > 1 || !objectMembers[key]))
|
|
8179
|
+
: path.length > 1 || !objectMembers[key])) {
|
|
8166
8180
|
return true;
|
|
8181
|
+
}
|
|
8167
8182
|
const subPath = path.slice(1);
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
|
|
8183
|
+
if (this.propertyMap[key]) {
|
|
8184
|
+
for (const property of this.propertyMap[key].propertiesRead) {
|
|
8185
|
+
if (property.hasEffectsWhenCalledAtPath(subPath, callOptions, context))
|
|
8186
|
+
return true;
|
|
8187
|
+
}
|
|
8173
8188
|
}
|
|
8174
8189
|
if (path.length === 1 && objectMembers[key])
|
|
8175
8190
|
return hasMemberEffectWhenCalled(objectMembers, key, this.included, callOptions, context);
|
|
@@ -8182,8 +8197,22 @@ class ObjectExpression extends NodeBase {
|
|
|
8182
8197
|
code.prependLeft(this.end, ')');
|
|
8183
8198
|
}
|
|
8184
8199
|
}
|
|
8185
|
-
|
|
8186
|
-
this.
|
|
8200
|
+
deoptimizeAllProperties() {
|
|
8201
|
+
this.hasUnknownDeoptimizedProperty = true;
|
|
8202
|
+
for (const property of this.properties) {
|
|
8203
|
+
property.deoptimizePath(UNKNOWN_PATH);
|
|
8204
|
+
}
|
|
8205
|
+
for (const expressionsToBeDeoptimized of this.expressionsToBeDeoptimized.values()) {
|
|
8206
|
+
for (const expression of expressionsToBeDeoptimized) {
|
|
8207
|
+
expression.deoptimizeCache();
|
|
8208
|
+
}
|
|
8209
|
+
}
|
|
8210
|
+
}
|
|
8211
|
+
getPropertyMap() {
|
|
8212
|
+
if (this.propertyMap !== null) {
|
|
8213
|
+
return this.propertyMap;
|
|
8214
|
+
}
|
|
8215
|
+
const propertyMap = (this.propertyMap = Object.create(null));
|
|
8187
8216
|
for (let index = this.properties.length - 1; index >= 0; index--) {
|
|
8188
8217
|
const property = this.properties[index];
|
|
8189
8218
|
if (property instanceof SpreadElement) {
|
|
@@ -8194,7 +8223,7 @@ class ObjectExpression extends NodeBase {
|
|
|
8194
8223
|
const isRead = property.kind !== 'set';
|
|
8195
8224
|
let key;
|
|
8196
8225
|
if (property.computed) {
|
|
8197
|
-
const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH,
|
|
8226
|
+
const keyValue = property.key.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
8198
8227
|
if (keyValue === UnknownValue) {
|
|
8199
8228
|
if (isRead) {
|
|
8200
8229
|
this.unmatchablePropertiesRead.push(property);
|
|
@@ -8212,13 +8241,13 @@ class ObjectExpression extends NodeBase {
|
|
|
8212
8241
|
else {
|
|
8213
8242
|
key = String(property.key.value);
|
|
8214
8243
|
}
|
|
8215
|
-
const propertyMapProperty =
|
|
8244
|
+
const propertyMapProperty = propertyMap[key];
|
|
8216
8245
|
if (!propertyMapProperty) {
|
|
8217
|
-
|
|
8246
|
+
propertyMap[key] = {
|
|
8218
8247
|
exactMatchRead: isRead ? property : null,
|
|
8219
8248
|
exactMatchWrite: isWrite ? property : null,
|
|
8220
8249
|
propertiesRead: isRead ? [property, ...this.unmatchablePropertiesRead] : [],
|
|
8221
|
-
|
|
8250
|
+
propertiesWrite: isWrite && !isRead ? [property, ...this.unmatchablePropertiesWrite] : []
|
|
8222
8251
|
};
|
|
8223
8252
|
continue;
|
|
8224
8253
|
}
|
|
@@ -8228,20 +8257,10 @@ class ObjectExpression extends NodeBase {
|
|
|
8228
8257
|
}
|
|
8229
8258
|
if (isWrite && !isRead && propertyMapProperty.exactMatchWrite === null) {
|
|
8230
8259
|
propertyMapProperty.exactMatchWrite = property;
|
|
8231
|
-
propertyMapProperty.
|
|
8232
|
-
}
|
|
8233
|
-
}
|
|
8234
|
-
}
|
|
8235
|
-
deoptimizeAllProperties() {
|
|
8236
|
-
this.hasUnknownDeoptimizedProperty = true;
|
|
8237
|
-
for (const property of this.properties) {
|
|
8238
|
-
property.deoptimizePath(UNKNOWN_PATH);
|
|
8239
|
-
}
|
|
8240
|
-
for (const expressionsToBeDeoptimized of this.expressionsToBeDeoptimized.values()) {
|
|
8241
|
-
for (const expression of expressionsToBeDeoptimized) {
|
|
8242
|
-
expression.deoptimizeCache();
|
|
8260
|
+
propertyMapProperty.propertiesWrite.push(property, ...this.unmatchablePropertiesWrite);
|
|
8243
8261
|
}
|
|
8244
8262
|
}
|
|
8263
|
+
return propertyMap;
|
|
8245
8264
|
}
|
|
8246
8265
|
}
|
|
8247
8266
|
|
|
@@ -8315,8 +8334,10 @@ class Property$1 extends NodeBase {
|
|
|
8315
8334
|
}
|
|
8316
8335
|
bind() {
|
|
8317
8336
|
super.bind();
|
|
8318
|
-
if (this.kind === 'get'
|
|
8319
|
-
|
|
8337
|
+
if (this.kind === 'get') {
|
|
8338
|
+
// ensure the returnExpression is set for the tree-shaking passes
|
|
8339
|
+
this.getReturnExpression();
|
|
8340
|
+
}
|
|
8320
8341
|
if (this.declarationInit !== null) {
|
|
8321
8342
|
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
8322
8343
|
}
|
|
@@ -8325,36 +8346,26 @@ class Property$1 extends NodeBase {
|
|
|
8325
8346
|
this.declarationInit = init;
|
|
8326
8347
|
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
8327
8348
|
}
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8331
|
-
throw new Error('Unexpected deoptimization');
|
|
8332
|
-
}
|
|
8349
|
+
// As getter properties directly receive their values from function expressions that always
|
|
8350
|
+
// have a fixed return value, there is no known situation where a getter is deoptimized.
|
|
8351
|
+
deoptimizeCache() { }
|
|
8333
8352
|
deoptimizePath(path) {
|
|
8334
8353
|
if (this.kind === 'get') {
|
|
8335
|
-
|
|
8336
|
-
if (this.returnExpression === null)
|
|
8337
|
-
this.updateReturnExpression();
|
|
8338
|
-
this.returnExpression.deoptimizePath(path);
|
|
8339
|
-
}
|
|
8354
|
+
this.getReturnExpression().deoptimizePath(path);
|
|
8340
8355
|
}
|
|
8341
|
-
else
|
|
8356
|
+
else {
|
|
8342
8357
|
this.value.deoptimizePath(path);
|
|
8343
8358
|
}
|
|
8344
8359
|
}
|
|
8345
8360
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
8346
8361
|
if (this.kind === 'get') {
|
|
8347
|
-
|
|
8348
|
-
this.updateReturnExpression();
|
|
8349
|
-
return this.returnExpression.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8362
|
+
return this.getReturnExpression().getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8350
8363
|
}
|
|
8351
8364
|
return this.value.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8352
8365
|
}
|
|
8353
8366
|
getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin) {
|
|
8354
8367
|
if (this.kind === 'get') {
|
|
8355
|
-
|
|
8356
|
-
this.updateReturnExpression();
|
|
8357
|
-
return this.returnExpression.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
8368
|
+
return this.getReturnExpression().getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
8358
8369
|
}
|
|
8359
8370
|
return this.value.getReturnExpressionWhenCalledAtPath(path, recursionTracker, origin);
|
|
8360
8371
|
}
|
|
@@ -8414,9 +8425,12 @@ class Property$1 extends NodeBase {
|
|
|
8414
8425
|
}
|
|
8415
8426
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
8416
8427
|
}
|
|
8417
|
-
|
|
8418
|
-
this.returnExpression
|
|
8419
|
-
|
|
8428
|
+
getReturnExpression() {
|
|
8429
|
+
if (this.returnExpression === null) {
|
|
8430
|
+
this.returnExpression = UNKNOWN_EXPRESSION;
|
|
8431
|
+
return (this.returnExpression = this.value.getReturnExpressionWhenCalledAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
8432
|
+
}
|
|
8433
|
+
return this.returnExpression;
|
|
8420
8434
|
}
|
|
8421
8435
|
}
|
|
8422
8436
|
|
|
@@ -9821,7 +9835,9 @@ class Module {
|
|
|
9821
9835
|
return { renderedExports, removedExports };
|
|
9822
9836
|
}
|
|
9823
9837
|
getTransitiveDependencies() {
|
|
9824
|
-
return this.dependencies.concat(this.getReexports()
|
|
9838
|
+
return this.dependencies.concat(this.getReexports()
|
|
9839
|
+
.concat(this.getExports())
|
|
9840
|
+
.map((exportName) => this.getVariableForExportName(exportName).module));
|
|
9825
9841
|
}
|
|
9826
9842
|
getVariableForExportName(name, isExportAllSearch) {
|
|
9827
9843
|
if (name[0] === '*') {
|