@rollup/wasm-node 4.29.0-2 → 4.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +738 -1490
- package/dist/es/shared/parseAst.js +3 -3
- package/dist/es/shared/watch.js +6 -6
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +6 -6
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +775 -1487
- package/dist/shared/watch-cli.js +20 -4
- package/dist/shared/watch.js +3 -3
- package/dist/wasm-node/bindings_wasm_bg.wasm +0 -0
- package/package.json +16 -16
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.29.0
|
|
4
|
-
Fri, 20 Dec 2024
|
|
3
|
+
Rollup.js v4.29.0
|
|
4
|
+
Fri, 20 Dec 2024 18:36:54 GMT - commit dadd4882c4984d7875af799ad56e506784d50e1c
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version = "4.29.0
|
|
34
|
+
var version = "4.29.0";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -1501,8 +1501,48 @@ const createColors = ({ useColor = isColorSupported } = {}) =>
|
|
|
1501
1501
|
);
|
|
1502
1502
|
|
|
1503
1503
|
const {
|
|
1504
|
+
reset,
|
|
1505
|
+
bold: bold$1,
|
|
1506
|
+
dim: dim$1,
|
|
1507
|
+
italic,
|
|
1508
|
+
underline: underline$1,
|
|
1509
|
+
inverse,
|
|
1510
|
+
hidden,
|
|
1511
|
+
strikethrough,
|
|
1512
|
+
black,
|
|
1513
|
+
red: red$1,
|
|
1514
|
+
green: green$1,
|
|
1515
|
+
yellow: yellow$1,
|
|
1504
1516
|
blue,
|
|
1505
|
-
|
|
1517
|
+
magenta,
|
|
1518
|
+
cyan: cyan$1,
|
|
1519
|
+
white,
|
|
1520
|
+
gray: gray$1,
|
|
1521
|
+
bgBlack,
|
|
1522
|
+
bgRed,
|
|
1523
|
+
bgGreen,
|
|
1524
|
+
bgYellow,
|
|
1525
|
+
bgBlue,
|
|
1526
|
+
bgMagenta,
|
|
1527
|
+
bgCyan,
|
|
1528
|
+
bgWhite,
|
|
1529
|
+
blackBright,
|
|
1530
|
+
redBright,
|
|
1531
|
+
greenBright,
|
|
1532
|
+
yellowBright,
|
|
1533
|
+
blueBright,
|
|
1534
|
+
magentaBright,
|
|
1535
|
+
cyanBright,
|
|
1536
|
+
whiteBright,
|
|
1537
|
+
bgBlackBright,
|
|
1538
|
+
bgRedBright,
|
|
1539
|
+
bgGreenBright,
|
|
1540
|
+
bgYellowBright,
|
|
1541
|
+
bgBlueBright,
|
|
1542
|
+
bgMagentaBright,
|
|
1543
|
+
bgCyanBright,
|
|
1544
|
+
bgWhiteBright,
|
|
1545
|
+
} = createColors();
|
|
1506
1546
|
|
|
1507
1547
|
// @see https://no-color.org
|
|
1508
1548
|
// @see https://www.npmjs.com/package/chalk
|
|
@@ -1862,7 +1902,7 @@ let Chunk$1 = class Chunk {
|
|
|
1862
1902
|
// ' test'.trim()
|
|
1863
1903
|
// split -> ' ' + 'test'
|
|
1864
1904
|
// ✔️ edit -> '' + 'test'
|
|
1865
|
-
// ✖️ edit -> 'test' + ''
|
|
1905
|
+
// ✖️ edit -> 'test' + ''
|
|
1866
1906
|
// TODO is this block necessary?...
|
|
1867
1907
|
newChunk.edit('', false);
|
|
1868
1908
|
this.content = '';
|
|
@@ -2109,6 +2149,7 @@ class Mappings {
|
|
|
2109
2149
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
|
2110
2150
|
this.generatedCodeColumn = 0;
|
|
2111
2151
|
first = true;
|
|
2152
|
+
charInHiresBoundary = false;
|
|
2112
2153
|
} else {
|
|
2113
2154
|
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
|
2114
2155
|
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
|
@@ -2186,6 +2227,7 @@ class MagicString {
|
|
|
2186
2227
|
storedNames: { writable: true, value: {} },
|
|
2187
2228
|
indentStr: { writable: true, value: undefined },
|
|
2188
2229
|
ignoreList: { writable: true, value: options.ignoreList },
|
|
2230
|
+
offset: { writable: true, value: options.offset || 0 },
|
|
2189
2231
|
});
|
|
2190
2232
|
|
|
2191
2233
|
this.byStart[0] = chunk;
|
|
@@ -2204,6 +2246,8 @@ class MagicString {
|
|
|
2204
2246
|
}
|
|
2205
2247
|
|
|
2206
2248
|
appendLeft(index, content) {
|
|
2249
|
+
index = index + this.offset;
|
|
2250
|
+
|
|
2207
2251
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
2208
2252
|
|
|
2209
2253
|
this._split(index);
|
|
@@ -2219,6 +2263,8 @@ class MagicString {
|
|
|
2219
2263
|
}
|
|
2220
2264
|
|
|
2221
2265
|
appendRight(index, content) {
|
|
2266
|
+
index = index + this.offset;
|
|
2267
|
+
|
|
2222
2268
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
2223
2269
|
|
|
2224
2270
|
this._split(index);
|
|
@@ -2234,7 +2280,7 @@ class MagicString {
|
|
|
2234
2280
|
}
|
|
2235
2281
|
|
|
2236
2282
|
clone() {
|
|
2237
|
-
const cloned = new MagicString(this.original, { filename: this.filename });
|
|
2283
|
+
const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
|
|
2238
2284
|
|
|
2239
2285
|
let originalChunk = this.firstChunk;
|
|
2240
2286
|
let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
|
|
@@ -2432,7 +2478,7 @@ class MagicString {
|
|
|
2432
2478
|
if (!warned.insertLeft) {
|
|
2433
2479
|
console.warn(
|
|
2434
2480
|
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
|
2435
|
-
);
|
|
2481
|
+
);
|
|
2436
2482
|
warned.insertLeft = true;
|
|
2437
2483
|
}
|
|
2438
2484
|
|
|
@@ -2443,7 +2489,7 @@ class MagicString {
|
|
|
2443
2489
|
if (!warned.insertRight) {
|
|
2444
2490
|
console.warn(
|
|
2445
2491
|
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
|
2446
|
-
);
|
|
2492
|
+
);
|
|
2447
2493
|
warned.insertRight = true;
|
|
2448
2494
|
}
|
|
2449
2495
|
|
|
@@ -2451,6 +2497,10 @@ class MagicString {
|
|
|
2451
2497
|
}
|
|
2452
2498
|
|
|
2453
2499
|
move(start, end, index) {
|
|
2500
|
+
start = start + this.offset;
|
|
2501
|
+
end = end + this.offset;
|
|
2502
|
+
index = index + this.offset;
|
|
2503
|
+
|
|
2454
2504
|
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
|
2455
2505
|
|
|
2456
2506
|
this._split(start);
|
|
@@ -2493,6 +2543,9 @@ class MagicString {
|
|
|
2493
2543
|
}
|
|
2494
2544
|
|
|
2495
2545
|
update(start, end, content, options) {
|
|
2546
|
+
start = start + this.offset;
|
|
2547
|
+
end = end + this.offset;
|
|
2548
|
+
|
|
2496
2549
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
|
2497
2550
|
|
|
2498
2551
|
if (this.original.length !== 0) {
|
|
@@ -2513,7 +2566,7 @@ class MagicString {
|
|
|
2513
2566
|
if (!warned.storeName) {
|
|
2514
2567
|
console.warn(
|
|
2515
2568
|
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
|
2516
|
-
);
|
|
2569
|
+
);
|
|
2517
2570
|
warned.storeName = true;
|
|
2518
2571
|
}
|
|
2519
2572
|
|
|
@@ -2564,6 +2617,8 @@ class MagicString {
|
|
|
2564
2617
|
}
|
|
2565
2618
|
|
|
2566
2619
|
prependLeft(index, content) {
|
|
2620
|
+
index = index + this.offset;
|
|
2621
|
+
|
|
2567
2622
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
2568
2623
|
|
|
2569
2624
|
this._split(index);
|
|
@@ -2579,6 +2634,8 @@ class MagicString {
|
|
|
2579
2634
|
}
|
|
2580
2635
|
|
|
2581
2636
|
prependRight(index, content) {
|
|
2637
|
+
index = index + this.offset;
|
|
2638
|
+
|
|
2582
2639
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
|
2583
2640
|
|
|
2584
2641
|
this._split(index);
|
|
@@ -2594,6 +2651,9 @@ class MagicString {
|
|
|
2594
2651
|
}
|
|
2595
2652
|
|
|
2596
2653
|
remove(start, end) {
|
|
2654
|
+
start = start + this.offset;
|
|
2655
|
+
end = end + this.offset;
|
|
2656
|
+
|
|
2597
2657
|
if (this.original.length !== 0) {
|
|
2598
2658
|
while (start < 0) start += this.original.length;
|
|
2599
2659
|
while (end < 0) end += this.original.length;
|
|
@@ -2620,6 +2680,9 @@ class MagicString {
|
|
|
2620
2680
|
}
|
|
2621
2681
|
|
|
2622
2682
|
reset(start, end) {
|
|
2683
|
+
start = start + this.offset;
|
|
2684
|
+
end = end + this.offset;
|
|
2685
|
+
|
|
2623
2686
|
if (this.original.length !== 0) {
|
|
2624
2687
|
while (start < 0) start += this.original.length;
|
|
2625
2688
|
while (end < 0) end += this.original.length;
|
|
@@ -2684,7 +2747,10 @@ class MagicString {
|
|
|
2684
2747
|
return this.intro + lineStr;
|
|
2685
2748
|
}
|
|
2686
2749
|
|
|
2687
|
-
slice(start = 0, end = this.original.length) {
|
|
2750
|
+
slice(start = 0, end = this.original.length - this.offset) {
|
|
2751
|
+
start = start + this.offset;
|
|
2752
|
+
end = end + this.offset;
|
|
2753
|
+
|
|
2688
2754
|
if (this.original.length !== 0) {
|
|
2689
2755
|
while (start < 0) start += this.original.length;
|
|
2690
2756
|
while (end < 0) end += this.original.length;
|
|
@@ -2920,11 +2986,7 @@ class MagicString {
|
|
|
2920
2986
|
if (match.index != null) {
|
|
2921
2987
|
const replacement = getReplacement(match, this.original);
|
|
2922
2988
|
if (replacement !== match[0]) {
|
|
2923
|
-
this.overwrite(
|
|
2924
|
-
match.index,
|
|
2925
|
-
match.index + match[0].length,
|
|
2926
|
-
replacement
|
|
2927
|
-
);
|
|
2989
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
2928
2990
|
}
|
|
2929
2991
|
}
|
|
2930
2992
|
});
|
|
@@ -2933,11 +2995,7 @@ class MagicString {
|
|
|
2933
2995
|
if (match && match.index != null) {
|
|
2934
2996
|
const replacement = getReplacement(match, this.original);
|
|
2935
2997
|
if (replacement !== match[0]) {
|
|
2936
|
-
this.overwrite(
|
|
2937
|
-
match.index,
|
|
2938
|
-
match.index + match[0].length,
|
|
2939
|
-
replacement
|
|
2940
|
-
);
|
|
2998
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
|
2941
2999
|
}
|
|
2942
3000
|
}
|
|
2943
3001
|
}
|
|
@@ -2972,8 +3030,7 @@ class MagicString {
|
|
|
2972
3030
|
index = original.indexOf(string, index + stringLength)
|
|
2973
3031
|
) {
|
|
2974
3032
|
const previous = original.slice(index, index + stringLength);
|
|
2975
|
-
if (previous !== replacement)
|
|
2976
|
-
this.overwrite(index, index + stringLength, replacement);
|
|
3033
|
+
if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
|
|
2977
3034
|
}
|
|
2978
3035
|
|
|
2979
3036
|
return this;
|
|
@@ -3482,6 +3539,71 @@ function renderSystemExportSequenceBeforeExpression(exportedVariable, expression
|
|
|
3482
3539
|
}
|
|
3483
3540
|
}
|
|
3484
3541
|
|
|
3542
|
+
/** @import { Node } from 'estree' */
|
|
3543
|
+
|
|
3544
|
+
/**
|
|
3545
|
+
* @param {Node} node
|
|
3546
|
+
* @param {Node} parent
|
|
3547
|
+
* @returns {boolean}
|
|
3548
|
+
*/
|
|
3549
|
+
function is_reference(node, parent) {
|
|
3550
|
+
if (node.type === 'MemberExpression') {
|
|
3551
|
+
return !node.computed && is_reference(node.object, node);
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
if (node.type !== 'Identifier') return false;
|
|
3555
|
+
|
|
3556
|
+
switch (parent?.type) {
|
|
3557
|
+
// disregard `bar` in `foo.bar`
|
|
3558
|
+
case 'MemberExpression':
|
|
3559
|
+
return parent.computed || node === parent.object;
|
|
3560
|
+
|
|
3561
|
+
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
3562
|
+
case 'MethodDefinition':
|
|
3563
|
+
return parent.computed;
|
|
3564
|
+
|
|
3565
|
+
// disregard the `meta` in `import.meta`
|
|
3566
|
+
case 'MetaProperty':
|
|
3567
|
+
return parent.meta === node;
|
|
3568
|
+
|
|
3569
|
+
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
3570
|
+
case 'PropertyDefinition':
|
|
3571
|
+
return parent.computed || node === parent.value;
|
|
3572
|
+
|
|
3573
|
+
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
3574
|
+
case 'Property':
|
|
3575
|
+
return parent.computed || node === parent.value;
|
|
3576
|
+
|
|
3577
|
+
// disregard the `bar` in `export { foo as bar }` or
|
|
3578
|
+
// the foo in `import { foo as bar }`
|
|
3579
|
+
case 'ExportSpecifier':
|
|
3580
|
+
case 'ImportSpecifier':
|
|
3581
|
+
return node === parent.local;
|
|
3582
|
+
|
|
3583
|
+
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
3584
|
+
case 'LabeledStatement':
|
|
3585
|
+
case 'BreakStatement':
|
|
3586
|
+
case 'ContinueStatement':
|
|
3587
|
+
return false;
|
|
3588
|
+
|
|
3589
|
+
default:
|
|
3590
|
+
return true;
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
const PureFunctionKey = Symbol('PureFunction');
|
|
3595
|
+
const getPureFunctions = ({ treeshake }) => {
|
|
3596
|
+
const pureFunctions = Object.create(null);
|
|
3597
|
+
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
3598
|
+
let currentFunctions = pureFunctions;
|
|
3599
|
+
for (const pathSegment of functionName.split('.')) {
|
|
3600
|
+
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
3601
|
+
}
|
|
3602
|
+
currentFunctions[PureFunctionKey] = true;
|
|
3603
|
+
}
|
|
3604
|
+
return pureFunctions;
|
|
3605
|
+
};
|
|
3606
|
+
|
|
3485
3607
|
const UnknownKey = Symbol('Unknown Key');
|
|
3486
3608
|
const UnknownNonAccessorKey = Symbol('Unknown Non-Accessor Key');
|
|
3487
3609
|
const UnknownInteger = Symbol('Unknown Integer');
|
|
@@ -3496,7 +3618,7 @@ const UNKNOWN_PATH = [UnknownKey];
|
|
|
3496
3618
|
const UNKNOWN_NON_ACCESSOR_PATH = [UnknownNonAccessorKey];
|
|
3497
3619
|
const UNKNOWN_INTEGER_PATH = [UnknownInteger];
|
|
3498
3620
|
const EntitiesKey = Symbol('Entities');
|
|
3499
|
-
class
|
|
3621
|
+
class PathTracker {
|
|
3500
3622
|
constructor() {
|
|
3501
3623
|
this.entityPaths = Object.create(null, {
|
|
3502
3624
|
[EntitiesKey]: { value: new Set() }
|
|
@@ -3521,14 +3643,14 @@ class EntityPathTracker {
|
|
|
3521
3643
|
getEntities(path) {
|
|
3522
3644
|
let currentPaths = this.entityPaths;
|
|
3523
3645
|
for (const pathSegment of path) {
|
|
3524
|
-
currentPaths = currentPaths[pathSegment]
|
|
3525
|
-
[
|
|
3526
|
-
|
|
3646
|
+
currentPaths = currentPaths[pathSegment] =
|
|
3647
|
+
currentPaths[pathSegment] ||
|
|
3648
|
+
Object.create(null, { [EntitiesKey]: { value: new Set() } });
|
|
3527
3649
|
}
|
|
3528
3650
|
return currentPaths[EntitiesKey];
|
|
3529
3651
|
}
|
|
3530
3652
|
}
|
|
3531
|
-
const SHARED_RECURSION_TRACKER = new
|
|
3653
|
+
const SHARED_RECURSION_TRACKER = new PathTracker();
|
|
3532
3654
|
class DiscriminatedPathTracker {
|
|
3533
3655
|
constructor() {
|
|
3534
3656
|
this.entityPaths = Object.create(null, {
|
|
@@ -3538,9 +3660,9 @@ class DiscriminatedPathTracker {
|
|
|
3538
3660
|
trackEntityAtPathAndGetIfTracked(path, discriminator, entity) {
|
|
3539
3661
|
let currentPaths = this.entityPaths;
|
|
3540
3662
|
for (const pathSegment of path) {
|
|
3541
|
-
currentPaths = currentPaths[pathSegment]
|
|
3542
|
-
[
|
|
3543
|
-
|
|
3663
|
+
currentPaths = currentPaths[pathSegment] =
|
|
3664
|
+
currentPaths[pathSegment] ||
|
|
3665
|
+
Object.create(null, { [EntitiesKey]: { value: new Map() } });
|
|
3544
3666
|
}
|
|
3545
3667
|
const trackedEntities = getOrCreate(currentPaths[EntitiesKey], discriminator, (getNewSet));
|
|
3546
3668
|
if (trackedEntities.has(entity))
|
|
@@ -3549,137 +3671,6 @@ class DiscriminatedPathTracker {
|
|
|
3549
3671
|
return false;
|
|
3550
3672
|
}
|
|
3551
3673
|
}
|
|
3552
|
-
const UNKNOWN_INCLUDED_PATH = Object.freeze({ [UnknownKey]: parseAst_js.EMPTY_OBJECT });
|
|
3553
|
-
class IncludedPathTracker {
|
|
3554
|
-
constructor() {
|
|
3555
|
-
this.includedPaths = null;
|
|
3556
|
-
}
|
|
3557
|
-
includePathAndGetIfIncluded(path) {
|
|
3558
|
-
let included = true;
|
|
3559
|
-
let parent = this;
|
|
3560
|
-
let parentSegment = 'includedPaths';
|
|
3561
|
-
let currentPaths = (this.includedPaths ||=
|
|
3562
|
-
((included = false), Object.create(null)));
|
|
3563
|
-
for (const pathSegment of path) {
|
|
3564
|
-
// This means from here, all paths are included
|
|
3565
|
-
if (currentPaths[UnknownKey]) {
|
|
3566
|
-
return true;
|
|
3567
|
-
}
|
|
3568
|
-
// Including UnknownKey automatically includes all nested paths.
|
|
3569
|
-
// From above, we know that UnknownKey is not included yet.
|
|
3570
|
-
if (typeof pathSegment === 'symbol') {
|
|
3571
|
-
// Hopefully, this saves some memory over just setting
|
|
3572
|
-
// currentPaths[UnknownKey] = EMPTY_OBJECT
|
|
3573
|
-
parent[parentSegment] = UNKNOWN_INCLUDED_PATH;
|
|
3574
|
-
return false;
|
|
3575
|
-
}
|
|
3576
|
-
parent = currentPaths;
|
|
3577
|
-
parentSegment = pathSegment;
|
|
3578
|
-
currentPaths = currentPaths[pathSegment] ||= ((included = false), Object.create(null));
|
|
3579
|
-
}
|
|
3580
|
-
return included;
|
|
3581
|
-
}
|
|
3582
|
-
includeAllPaths(entity, context, basePath) {
|
|
3583
|
-
const { includedPaths } = this;
|
|
3584
|
-
if (includedPaths) {
|
|
3585
|
-
includeAllPaths(entity, context, basePath, includedPaths);
|
|
3586
|
-
}
|
|
3587
|
-
}
|
|
3588
|
-
}
|
|
3589
|
-
function includeAllPaths(entity, context, basePath, currentPaths) {
|
|
3590
|
-
if (currentPaths[UnknownKey]) {
|
|
3591
|
-
return entity.includePath([...basePath, UnknownKey], context);
|
|
3592
|
-
}
|
|
3593
|
-
const keys = Object.keys(currentPaths);
|
|
3594
|
-
if (keys.length === 0) {
|
|
3595
|
-
return entity.includePath(basePath, context);
|
|
3596
|
-
}
|
|
3597
|
-
for (const key of keys) {
|
|
3598
|
-
includeAllPaths(entity, context, [...basePath, key], currentPaths[key]);
|
|
3599
|
-
}
|
|
3600
|
-
}
|
|
3601
|
-
|
|
3602
|
-
/** @import { Node } from 'estree' */
|
|
3603
|
-
|
|
3604
|
-
/**
|
|
3605
|
-
* @param {Node} node
|
|
3606
|
-
* @param {Node} parent
|
|
3607
|
-
* @returns {boolean}
|
|
3608
|
-
*/
|
|
3609
|
-
function is_reference(node, parent) {
|
|
3610
|
-
if (node.type === 'MemberExpression') {
|
|
3611
|
-
return !node.computed && is_reference(node.object, node);
|
|
3612
|
-
}
|
|
3613
|
-
|
|
3614
|
-
if (node.type !== 'Identifier') return false;
|
|
3615
|
-
|
|
3616
|
-
switch (parent?.type) {
|
|
3617
|
-
// disregard `bar` in `foo.bar`
|
|
3618
|
-
case 'MemberExpression':
|
|
3619
|
-
return parent.computed || node === parent.object;
|
|
3620
|
-
|
|
3621
|
-
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
|
|
3622
|
-
case 'MethodDefinition':
|
|
3623
|
-
return parent.computed;
|
|
3624
|
-
|
|
3625
|
-
// disregard the `meta` in `import.meta`
|
|
3626
|
-
case 'MetaProperty':
|
|
3627
|
-
return parent.meta === node;
|
|
3628
|
-
|
|
3629
|
-
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
|
|
3630
|
-
case 'PropertyDefinition':
|
|
3631
|
-
return parent.computed || node === parent.value;
|
|
3632
|
-
|
|
3633
|
-
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
|
|
3634
|
-
case 'Property':
|
|
3635
|
-
return parent.computed || node === parent.value;
|
|
3636
|
-
|
|
3637
|
-
// disregard the `bar` in `export { foo as bar }` or
|
|
3638
|
-
// the foo in `import { foo as bar }`
|
|
3639
|
-
case 'ExportSpecifier':
|
|
3640
|
-
case 'ImportSpecifier':
|
|
3641
|
-
return node === parent.local;
|
|
3642
|
-
|
|
3643
|
-
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
|
|
3644
|
-
case 'LabeledStatement':
|
|
3645
|
-
case 'BreakStatement':
|
|
3646
|
-
case 'ContinueStatement':
|
|
3647
|
-
return false;
|
|
3648
|
-
|
|
3649
|
-
default:
|
|
3650
|
-
return true;
|
|
3651
|
-
}
|
|
3652
|
-
}
|
|
3653
|
-
|
|
3654
|
-
function createInclusionContext() {
|
|
3655
|
-
return {
|
|
3656
|
-
brokenFlow: false,
|
|
3657
|
-
hasBreak: false,
|
|
3658
|
-
hasContinue: false,
|
|
3659
|
-
includedCallArguments: new Set(),
|
|
3660
|
-
includedLabels: new Set()
|
|
3661
|
-
};
|
|
3662
|
-
}
|
|
3663
|
-
function createHasEffectsContext() {
|
|
3664
|
-
return {
|
|
3665
|
-
accessed: new EntityPathTracker(),
|
|
3666
|
-
assigned: new EntityPathTracker(),
|
|
3667
|
-
brokenFlow: false,
|
|
3668
|
-
called: new DiscriminatedPathTracker(),
|
|
3669
|
-
hasBreak: false,
|
|
3670
|
-
hasContinue: false,
|
|
3671
|
-
ignore: {
|
|
3672
|
-
breaks: false,
|
|
3673
|
-
continues: false,
|
|
3674
|
-
labels: new Set(),
|
|
3675
|
-
returnYield: false,
|
|
3676
|
-
this: false
|
|
3677
|
-
},
|
|
3678
|
-
includedLabels: new Set(),
|
|
3679
|
-
instantiated: new DiscriminatedPathTracker(),
|
|
3680
|
-
replacedVariableInits: new Map()
|
|
3681
|
-
};
|
|
3682
|
-
}
|
|
3683
3674
|
|
|
3684
3675
|
function isFlagSet(flags, flag) {
|
|
3685
3676
|
return (flags & flag) !== 0;
|
|
@@ -3690,6 +3681,7 @@ function setFlag(flags, flag, value) {
|
|
|
3690
3681
|
|
|
3691
3682
|
const UnknownValue = Symbol('Unknown Value');
|
|
3692
3683
|
const UnknownTruthyValue = Symbol('Unknown Truthy Value');
|
|
3684
|
+
const UnknownFalsyValue = Symbol('Unknown Falsy Value');
|
|
3693
3685
|
class ExpressionEntity {
|
|
3694
3686
|
constructor() {
|
|
3695
3687
|
this.flags = 0;
|
|
@@ -3718,25 +3710,12 @@ class ExpressionEntity {
|
|
|
3718
3710
|
hasEffectsOnInteractionAtPath(_path, _interaction, _context) {
|
|
3719
3711
|
return true;
|
|
3720
3712
|
}
|
|
3721
|
-
include(
|
|
3722
|
-
if (!this.included)
|
|
3723
|
-
this.includeNode(context);
|
|
3724
|
-
}
|
|
3725
|
-
includeNode(_context) {
|
|
3713
|
+
include(_context, _includeChildrenRecursively, _options) {
|
|
3726
3714
|
this.included = true;
|
|
3727
3715
|
}
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
}
|
|
3732
|
-
/* We are both including and including an unknown path here as the former
|
|
3733
|
-
* ensures that nested nodes are included while the latter ensures that all
|
|
3734
|
-
* paths of the expression are included.
|
|
3735
|
-
* */
|
|
3736
|
-
includeCallArguments(context, interaction) {
|
|
3737
|
-
for (const argument of interaction.args) {
|
|
3738
|
-
argument?.includePath(UNKNOWN_PATH, context);
|
|
3739
|
-
argument?.include(context, false);
|
|
3716
|
+
includeCallArguments(context, parameters) {
|
|
3717
|
+
for (const argument of parameters) {
|
|
3718
|
+
argument.include(context, false);
|
|
3740
3719
|
}
|
|
3741
3720
|
}
|
|
3742
3721
|
shouldBeIncluded(_context) {
|
|
@@ -3775,19 +3754,6 @@ const NODE_INTERACTION_UNKNOWN_CALL = {
|
|
|
3775
3754
|
withNew: false
|
|
3776
3755
|
};
|
|
3777
3756
|
|
|
3778
|
-
const PureFunctionKey = Symbol('PureFunction');
|
|
3779
|
-
const getPureFunctions = ({ treeshake }) => {
|
|
3780
|
-
const pureFunctions = Object.create(null);
|
|
3781
|
-
for (const functionName of treeshake ? treeshake.manualPureFunctions : []) {
|
|
3782
|
-
let currentFunctions = pureFunctions;
|
|
3783
|
-
for (const pathSegment of functionName.split('.')) {
|
|
3784
|
-
currentFunctions = currentFunctions[pathSegment] ||= Object.create(null);
|
|
3785
|
-
}
|
|
3786
|
-
currentFunctions[PureFunctionKey] = true;
|
|
3787
|
-
}
|
|
3788
|
-
return pureFunctions;
|
|
3789
|
-
};
|
|
3790
|
-
|
|
3791
3757
|
class Variable extends ExpressionEntity {
|
|
3792
3758
|
markReassigned() {
|
|
3793
3759
|
this.isReassigned = true;
|
|
@@ -3864,9 +3830,9 @@ class Variable extends ExpressionEntity {
|
|
|
3864
3830
|
* has not been included previously. Once a variable is included, it should
|
|
3865
3831
|
* take care all its declarations are included.
|
|
3866
3832
|
*/
|
|
3867
|
-
|
|
3833
|
+
include() {
|
|
3868
3834
|
this.included = true;
|
|
3869
|
-
this.renderedLikeHoisted?.
|
|
3835
|
+
this.renderedLikeHoisted?.include();
|
|
3870
3836
|
}
|
|
3871
3837
|
/**
|
|
3872
3838
|
* Links the rendered name of this variable to another variable and includes
|
|
@@ -3898,8 +3864,8 @@ class ExternalVariable extends Variable {
|
|
|
3898
3864
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
3899
3865
|
return type !== INTERACTION_ACCESSED || path.length > (this.isNamespace ? 1 : 0);
|
|
3900
3866
|
}
|
|
3901
|
-
|
|
3902
|
-
super.
|
|
3867
|
+
include() {
|
|
3868
|
+
super.include();
|
|
3903
3869
|
this.module.used = true;
|
|
3904
3870
|
}
|
|
3905
3871
|
}
|
|
@@ -4198,6 +4164,36 @@ const childNodeKeys = {
|
|
|
4198
4164
|
YieldExpression: ['argument']
|
|
4199
4165
|
};
|
|
4200
4166
|
|
|
4167
|
+
function createInclusionContext() {
|
|
4168
|
+
return {
|
|
4169
|
+
brokenFlow: false,
|
|
4170
|
+
hasBreak: false,
|
|
4171
|
+
hasContinue: false,
|
|
4172
|
+
includedCallArguments: new Set(),
|
|
4173
|
+
includedLabels: new Set()
|
|
4174
|
+
};
|
|
4175
|
+
}
|
|
4176
|
+
function createHasEffectsContext() {
|
|
4177
|
+
return {
|
|
4178
|
+
accessed: new PathTracker(),
|
|
4179
|
+
assigned: new PathTracker(),
|
|
4180
|
+
brokenFlow: false,
|
|
4181
|
+
called: new DiscriminatedPathTracker(),
|
|
4182
|
+
hasBreak: false,
|
|
4183
|
+
hasContinue: false,
|
|
4184
|
+
ignore: {
|
|
4185
|
+
breaks: false,
|
|
4186
|
+
continues: false,
|
|
4187
|
+
labels: new Set(),
|
|
4188
|
+
returnYield: false,
|
|
4189
|
+
this: false
|
|
4190
|
+
},
|
|
4191
|
+
includedLabels: new Set(),
|
|
4192
|
+
instantiated: new DiscriminatedPathTracker(),
|
|
4193
|
+
replacedVariableInits: new Map()
|
|
4194
|
+
};
|
|
4195
|
+
}
|
|
4196
|
+
|
|
4201
4197
|
const INCLUDE_PARAMETERS = 'variables';
|
|
4202
4198
|
const IS_SKIPPED_CHAIN = Symbol('IS_SKIPPED_CHAIN');
|
|
4203
4199
|
class NodeBase extends ExpressionEntity {
|
|
@@ -4267,37 +4263,20 @@ class NodeBase extends ExpressionEntity {
|
|
|
4267
4263
|
this.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.assignmentInteraction, context));
|
|
4268
4264
|
}
|
|
4269
4265
|
include(context, includeChildrenRecursively, _options) {
|
|
4270
|
-
if (!this.included)
|
|
4271
|
-
this.includeNode(context);
|
|
4272
|
-
for (const key of childNodeKeys[this.type]) {
|
|
4273
|
-
const value = this[key];
|
|
4274
|
-
if (value === null)
|
|
4275
|
-
continue;
|
|
4276
|
-
if (Array.isArray(value)) {
|
|
4277
|
-
for (const child of value) {
|
|
4278
|
-
child?.include(context, includeChildrenRecursively);
|
|
4279
|
-
}
|
|
4280
|
-
}
|
|
4281
|
-
else {
|
|
4282
|
-
value.include(context, includeChildrenRecursively);
|
|
4283
|
-
}
|
|
4284
|
-
}
|
|
4285
|
-
}
|
|
4286
|
-
includeNode(context) {
|
|
4287
|
-
this.included = true;
|
|
4288
4266
|
if (!this.deoptimized)
|
|
4289
4267
|
this.applyDeoptimizations();
|
|
4268
|
+
this.included = true;
|
|
4290
4269
|
for (const key of childNodeKeys[this.type]) {
|
|
4291
4270
|
const value = this[key];
|
|
4292
4271
|
if (value === null)
|
|
4293
4272
|
continue;
|
|
4294
4273
|
if (Array.isArray(value)) {
|
|
4295
4274
|
for (const child of value) {
|
|
4296
|
-
child?.
|
|
4275
|
+
child?.include(context, includeChildrenRecursively);
|
|
4297
4276
|
}
|
|
4298
4277
|
}
|
|
4299
4278
|
else {
|
|
4300
|
-
value.
|
|
4279
|
+
value.include(context, includeChildrenRecursively);
|
|
4301
4280
|
}
|
|
4302
4281
|
}
|
|
4303
4282
|
}
|
|
@@ -4404,17 +4383,6 @@ class NodeBase extends ExpressionEntity {
|
|
|
4404
4383
|
function createChildNodeKeysForNode(esTreeNode) {
|
|
4405
4384
|
return Object.keys(esTreeNode).filter(key => typeof esTreeNode[key] === 'object' && key.charCodeAt(0) !== 95 /* _ */);
|
|
4406
4385
|
}
|
|
4407
|
-
function onlyIncludeSelf() {
|
|
4408
|
-
this.included = true;
|
|
4409
|
-
if (!this.deoptimized)
|
|
4410
|
-
this.applyDeoptimizations();
|
|
4411
|
-
}
|
|
4412
|
-
function onlyIncludeSelfNoDeoptimize() {
|
|
4413
|
-
this.included = true;
|
|
4414
|
-
}
|
|
4415
|
-
function doNotDeoptimize() {
|
|
4416
|
-
this.deoptimized = true;
|
|
4417
|
-
}
|
|
4418
4386
|
|
|
4419
4387
|
function isObjectExpressionNode(node) {
|
|
4420
4388
|
return node instanceof NodeBase && node.type === parseAst_js.ObjectExpression;
|
|
@@ -4427,8 +4395,8 @@ function assembleMemberDescriptions(memberDescriptions, inheritedDescriptions =
|
|
|
4427
4395
|
return Object.create(inheritedDescriptions, memberDescriptions);
|
|
4428
4396
|
}
|
|
4429
4397
|
const UNDEFINED_EXPRESSION = new (class UndefinedExpression extends ExpressionEntity {
|
|
4430
|
-
getLiteralValueAtPath(
|
|
4431
|
-
return
|
|
4398
|
+
getLiteralValueAtPath() {
|
|
4399
|
+
return undefined;
|
|
4432
4400
|
}
|
|
4433
4401
|
})();
|
|
4434
4402
|
const returnsUnknown = {
|
|
@@ -4625,6 +4593,31 @@ function getMemberReturnExpressionWhenCalled(members, memberName) {
|
|
|
4625
4593
|
return [members[memberName].returns, false];
|
|
4626
4594
|
}
|
|
4627
4595
|
|
|
4596
|
+
class SpreadElement extends NodeBase {
|
|
4597
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
4598
|
+
if (path.length > 0) {
|
|
4599
|
+
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
4600
|
+
}
|
|
4601
|
+
}
|
|
4602
|
+
hasEffects(context) {
|
|
4603
|
+
if (!this.deoptimized)
|
|
4604
|
+
this.applyDeoptimizations();
|
|
4605
|
+
const { propertyReadSideEffects } = this.scope.context.options
|
|
4606
|
+
.treeshake;
|
|
4607
|
+
return (this.argument.hasEffects(context) ||
|
|
4608
|
+
(propertyReadSideEffects &&
|
|
4609
|
+
(propertyReadSideEffects === 'always' ||
|
|
4610
|
+
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
4611
|
+
}
|
|
4612
|
+
applyDeoptimizations() {
|
|
4613
|
+
this.deoptimized = true;
|
|
4614
|
+
// Only properties of properties of the argument could become subject to reassignment
|
|
4615
|
+
// This will also reassign the return values of iterators
|
|
4616
|
+
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
4617
|
+
this.scope.context.requestTreeshakingPass();
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
|
|
4628
4621
|
class Method extends ExpressionEntity {
|
|
4629
4622
|
constructor(description) {
|
|
4630
4623
|
super();
|
|
@@ -4750,7 +4743,6 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
4750
4743
|
this.unknownIntegerProps = [];
|
|
4751
4744
|
this.unmatchableGetters = [];
|
|
4752
4745
|
this.unmatchablePropertiesAndGetters = [];
|
|
4753
|
-
this.unmatchablePropertiesAndSetters = [];
|
|
4754
4746
|
this.unmatchableSetters = [];
|
|
4755
4747
|
if (Array.isArray(properties)) {
|
|
4756
4748
|
this.buildPropertyMaps(properties);
|
|
@@ -4985,38 +4977,9 @@ class ObjectEntity extends ExpressionEntity {
|
|
|
4985
4977
|
}
|
|
4986
4978
|
return false;
|
|
4987
4979
|
}
|
|
4988
|
-
include(context, includeChildrenRecursively) {
|
|
4989
|
-
this.included = true;
|
|
4990
|
-
for (const property of this.allProperties) {
|
|
4991
|
-
if (includeChildrenRecursively || property.shouldBeIncluded(context)) {
|
|
4992
|
-
property.include(context, includeChildrenRecursively);
|
|
4993
|
-
}
|
|
4994
|
-
}
|
|
4995
|
-
this.prototypeExpression?.include(context, includeChildrenRecursively);
|
|
4996
|
-
}
|
|
4997
|
-
includePath(path, context) {
|
|
4998
|
-
this.included = true;
|
|
4999
|
-
if (path.length === 0)
|
|
5000
|
-
return;
|
|
5001
|
-
const [key, ...subPath] = path;
|
|
5002
|
-
const [includedMembers, includedPath] = typeof key === 'string'
|
|
5003
|
-
? [
|
|
5004
|
-
[
|
|
5005
|
-
...new Set([
|
|
5006
|
-
...(this.propertiesAndGettersByKey[key] || this.unmatchablePropertiesAndGetters),
|
|
5007
|
-
...(this.propertiesAndSettersByKey[key] || this.unmatchablePropertiesAndSetters)
|
|
5008
|
-
])
|
|
5009
|
-
],
|
|
5010
|
-
subPath
|
|
5011
|
-
]
|
|
5012
|
-
: [this.allProperties, UNKNOWN_PATH];
|
|
5013
|
-
for (const property of includedMembers) {
|
|
5014
|
-
property.includePath(includedPath, context);
|
|
5015
|
-
}
|
|
5016
|
-
this.prototypeExpression?.includePath(path, context);
|
|
5017
|
-
}
|
|
5018
4980
|
buildPropertyMaps(properties) {
|
|
5019
|
-
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters,
|
|
4981
|
+
const { allProperties, propertiesAndGettersByKey, propertiesAndSettersByKey, settersByKey, gettersByKey, unknownIntegerProps, unmatchablePropertiesAndGetters, unmatchableGetters, unmatchableSetters } = this;
|
|
4982
|
+
const unmatchablePropertiesAndSetters = [];
|
|
5020
4983
|
for (let index = properties.length - 1; index >= 0; index--) {
|
|
5021
4984
|
const { key, kind, property } = properties[index];
|
|
5022
4985
|
allProperties.push(property);
|
|
@@ -5286,37 +5249,6 @@ const ARRAY_PROTOTYPE = new ObjectEntity({
|
|
|
5286
5249
|
values: METHOD_DEOPTS_SELF_RETURNS_UNKNOWN
|
|
5287
5250
|
}, OBJECT_PROTOTYPE, true);
|
|
5288
5251
|
|
|
5289
|
-
class SpreadElement extends NodeBase {
|
|
5290
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
5291
|
-
if (path.length > 0) {
|
|
5292
|
-
this.argument.deoptimizeArgumentsOnInteractionAtPath(interaction, UNKNOWN_PATH, recursionTracker);
|
|
5293
|
-
}
|
|
5294
|
-
}
|
|
5295
|
-
hasEffects(context) {
|
|
5296
|
-
if (!this.deoptimized)
|
|
5297
|
-
this.applyDeoptimizations();
|
|
5298
|
-
const { propertyReadSideEffects } = this.scope.context.options
|
|
5299
|
-
.treeshake;
|
|
5300
|
-
return (this.argument.hasEffects(context) ||
|
|
5301
|
-
(propertyReadSideEffects &&
|
|
5302
|
-
(propertyReadSideEffects === 'always' ||
|
|
5303
|
-
this.argument.hasEffectsOnInteractionAtPath(UNKNOWN_PATH, NODE_INTERACTION_UNKNOWN_ACCESS, context))));
|
|
5304
|
-
}
|
|
5305
|
-
includeNode(context) {
|
|
5306
|
-
this.included = true;
|
|
5307
|
-
if (!this.deoptimized)
|
|
5308
|
-
this.applyDeoptimizations();
|
|
5309
|
-
this.argument.includePath(UNKNOWN_PATH, context);
|
|
5310
|
-
}
|
|
5311
|
-
applyDeoptimizations() {
|
|
5312
|
-
this.deoptimized = true;
|
|
5313
|
-
// Only properties of properties of the argument could become subject to reassignment
|
|
5314
|
-
// This will also reassign the return values of iterators
|
|
5315
|
-
this.argument.deoptimizePath([UnknownKey, UnknownKey]);
|
|
5316
|
-
this.scope.context.requestTreeshakingPass();
|
|
5317
|
-
}
|
|
5318
|
-
}
|
|
5319
|
-
|
|
5320
5252
|
class ArrayExpression extends NodeBase {
|
|
5321
5253
|
constructor() {
|
|
5322
5254
|
super(...arguments);
|
|
@@ -5337,16 +5269,6 @@ class ArrayExpression extends NodeBase {
|
|
|
5337
5269
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
5338
5270
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
5339
5271
|
}
|
|
5340
|
-
includeNode(context) {
|
|
5341
|
-
this.included = true;
|
|
5342
|
-
if (!this.deoptimized)
|
|
5343
|
-
this.applyDeoptimizations();
|
|
5344
|
-
for (const element of this.elements) {
|
|
5345
|
-
if (element) {
|
|
5346
|
-
element?.includePath(UNKNOWN_PATH, context);
|
|
5347
|
-
}
|
|
5348
|
-
}
|
|
5349
|
-
}
|
|
5350
5272
|
applyDeoptimizations() {
|
|
5351
5273
|
this.deoptimized = true;
|
|
5352
5274
|
let hasSpread = false;
|
|
@@ -5388,29 +5310,29 @@ class ArrayExpression extends NodeBase {
|
|
|
5388
5310
|
|
|
5389
5311
|
/* eslint sort-keys: "off" */
|
|
5390
5312
|
const ValueProperties = Symbol('Value Properties');
|
|
5391
|
-
const
|
|
5313
|
+
const getUnknownValue = () => UnknownValue;
|
|
5392
5314
|
const returnFalse = () => false;
|
|
5393
5315
|
const returnTrue = () => true;
|
|
5394
5316
|
const PURE = {
|
|
5395
5317
|
deoptimizeArgumentsOnCall: doNothing,
|
|
5396
|
-
getLiteralValue:
|
|
5318
|
+
getLiteralValue: getUnknownValue,
|
|
5397
5319
|
hasEffectsWhenCalled: returnFalse
|
|
5398
5320
|
};
|
|
5399
5321
|
const IMPURE = {
|
|
5400
5322
|
deoptimizeArgumentsOnCall: doNothing,
|
|
5401
|
-
getLiteralValue:
|
|
5323
|
+
getLiteralValue: getUnknownValue,
|
|
5402
5324
|
hasEffectsWhenCalled: returnTrue
|
|
5403
5325
|
};
|
|
5404
5326
|
const PURE_WITH_ARRAY = {
|
|
5405
5327
|
deoptimizeArgumentsOnCall: doNothing,
|
|
5406
|
-
getLiteralValue:
|
|
5328
|
+
getLiteralValue: getUnknownValue,
|
|
5407
5329
|
hasEffectsWhenCalled({ args }) {
|
|
5408
5330
|
return args.length > 1 && !(args[1] instanceof ArrayExpression);
|
|
5409
5331
|
}
|
|
5410
5332
|
};
|
|
5411
5333
|
const GETTER_ACCESS = {
|
|
5412
5334
|
deoptimizeArgumentsOnCall: doNothing,
|
|
5413
|
-
getLiteralValue:
|
|
5335
|
+
getLiteralValue: getUnknownValue,
|
|
5414
5336
|
hasEffectsWhenCalled({ args }, context) {
|
|
5415
5337
|
const [_thisArgument, firstArgument] = args;
|
|
5416
5338
|
return (!(firstArgument instanceof ExpressionEntity) ||
|
|
@@ -5440,7 +5362,7 @@ const MUTATES_ARG_WITHOUT_ACCESSOR = {
|
|
|
5440
5362
|
deoptimizeArgumentsOnCall({ args: [, firstArgument] }) {
|
|
5441
5363
|
firstArgument?.deoptimizePath(UNKNOWN_PATH);
|
|
5442
5364
|
},
|
|
5443
|
-
getLiteralValue:
|
|
5365
|
+
getLiteralValue: getUnknownValue,
|
|
5444
5366
|
hasEffectsWhenCalled({ args }, context) {
|
|
5445
5367
|
return (args.length <= 1 ||
|
|
5446
5368
|
args[1].hasEffectsOnInteractionAtPath(UNKNOWN_NON_ACCESSOR_PATH, NODE_INTERACTION_UNKNOWN_ASSIGNMENT, context));
|
|
@@ -5647,7 +5569,7 @@ const knownGlobals = {
|
|
|
5647
5569
|
}
|
|
5648
5570
|
target.deoptimizePath(UNKNOWN_PATH);
|
|
5649
5571
|
},
|
|
5650
|
-
getLiteralValue:
|
|
5572
|
+
getLiteralValue: getUnknownValue,
|
|
5651
5573
|
hasEffectsWhenCalled: returnTrue
|
|
5652
5574
|
}
|
|
5653
5575
|
},
|
|
@@ -5837,7 +5759,7 @@ const knownGlobals = {
|
|
|
5837
5759
|
deoptimizeArgumentsOnCall({ args }) {
|
|
5838
5760
|
args[2]?.deoptimizePath(['detail']);
|
|
5839
5761
|
},
|
|
5840
|
-
getLiteralValue:
|
|
5762
|
+
getLiteralValue: getUnknownValue,
|
|
5841
5763
|
hasEffectsWhenCalled: returnFalse
|
|
5842
5764
|
},
|
|
5843
5765
|
prototype: O
|
|
@@ -6414,37 +6336,17 @@ class GlobalVariable extends Variable {
|
|
|
6414
6336
|
}
|
|
6415
6337
|
}
|
|
6416
6338
|
|
|
6417
|
-
// To avoid infinite recursions
|
|
6418
|
-
const MAX_PATH_DEPTH = 6;
|
|
6419
|
-
// If a path is longer than MAX_PATH_DEPTH, it is truncated so that it is at
|
|
6420
|
-
// most MAX_PATH_DEPTH long. The last element is always UnknownKey
|
|
6421
|
-
const limitConcatenatedPathDepth = (path1, path2) => {
|
|
6422
|
-
const { length: length1 } = path1;
|
|
6423
|
-
const { length: length2 } = path2;
|
|
6424
|
-
return length1 === 0
|
|
6425
|
-
? path2
|
|
6426
|
-
: length2 === 0
|
|
6427
|
-
? path1
|
|
6428
|
-
: length1 + length2 > MAX_PATH_DEPTH
|
|
6429
|
-
? [...path1, ...path2.slice(0, MAX_PATH_DEPTH - 1 - path1.length), 'UnknownKey']
|
|
6430
|
-
: [...path1, ...path2];
|
|
6431
|
-
};
|
|
6432
|
-
|
|
6433
6339
|
class LocalVariable extends Variable {
|
|
6434
|
-
constructor(name, declarator, init,
|
|
6435
|
-
/** if this is non-empty, the actual init is this path of this.init */
|
|
6436
|
-
initPath, context, kind) {
|
|
6340
|
+
constructor(name, declarator, init, context, kind) {
|
|
6437
6341
|
super(name);
|
|
6438
6342
|
this.init = init;
|
|
6439
|
-
this.initPath = initPath;
|
|
6440
|
-
this.kind = kind;
|
|
6441
6343
|
this.calledFromTryStatement = false;
|
|
6442
6344
|
this.additionalInitializers = null;
|
|
6443
|
-
this.includedPathTracker = new IncludedPathTracker();
|
|
6444
6345
|
this.expressionsToBeDeoptimized = [];
|
|
6445
6346
|
this.declarations = declarator ? [declarator] : [];
|
|
6446
6347
|
this.deoptimizationTracker = context.deoptimizationTracker;
|
|
6447
6348
|
this.module = context.module;
|
|
6349
|
+
this.kind = kind;
|
|
6448
6350
|
}
|
|
6449
6351
|
addDeclaration(identifier, init) {
|
|
6450
6352
|
this.declarations.push(identifier);
|
|
@@ -6455,16 +6357,15 @@ class LocalVariable extends Variable {
|
|
|
6455
6357
|
for (const initializer of this.additionalInitializers) {
|
|
6456
6358
|
initializer.deoptimizePath(UNKNOWN_PATH);
|
|
6457
6359
|
}
|
|
6360
|
+
this.additionalInitializers = null;
|
|
6458
6361
|
}
|
|
6459
6362
|
}
|
|
6460
6363
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6461
|
-
if (this.isReassigned
|
|
6364
|
+
if (this.isReassigned) {
|
|
6462
6365
|
deoptimizeInteraction(interaction);
|
|
6463
6366
|
return;
|
|
6464
6367
|
}
|
|
6465
|
-
recursionTracker.withTrackedEntityAtPath(path, this.init, () =>
|
|
6466
|
-
this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], recursionTracker);
|
|
6467
|
-
}, undefined);
|
|
6368
|
+
recursionTracker.withTrackedEntityAtPath(path, this.init, () => this.init.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker), undefined);
|
|
6468
6369
|
}
|
|
6469
6370
|
deoptimizePath(path) {
|
|
6470
6371
|
if (this.isReassigned ||
|
|
@@ -6478,40 +6379,37 @@ class LocalVariable extends Variable {
|
|
|
6478
6379
|
for (const expression of expressionsToBeDeoptimized) {
|
|
6479
6380
|
expression.deoptimizeCache();
|
|
6480
6381
|
}
|
|
6481
|
-
this.init.deoptimizePath(
|
|
6382
|
+
this.init.deoptimizePath(UNKNOWN_PATH);
|
|
6482
6383
|
}
|
|
6483
6384
|
else {
|
|
6484
|
-
this.init.deoptimizePath(
|
|
6385
|
+
this.init.deoptimizePath(path);
|
|
6485
6386
|
}
|
|
6486
6387
|
}
|
|
6487
6388
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6488
|
-
if (this.isReassigned
|
|
6389
|
+
if (this.isReassigned) {
|
|
6489
6390
|
return UnknownValue;
|
|
6490
6391
|
}
|
|
6491
6392
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6492
6393
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6493
|
-
return this.init.getLiteralValueAtPath(
|
|
6394
|
+
return this.init.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
6494
6395
|
}, UnknownValue);
|
|
6495
6396
|
}
|
|
6496
6397
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6497
|
-
if (this.isReassigned
|
|
6398
|
+
if (this.isReassigned) {
|
|
6498
6399
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
6499
6400
|
}
|
|
6500
6401
|
return recursionTracker.withTrackedEntityAtPath(path, this.init, () => {
|
|
6501
6402
|
this.expressionsToBeDeoptimized.push(origin);
|
|
6502
|
-
return this.init.getReturnExpressionWhenCalledAtPath(
|
|
6403
|
+
return this.init.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
6503
6404
|
}, UNKNOWN_RETURN_EXPRESSION);
|
|
6504
6405
|
}
|
|
6505
6406
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6506
|
-
if (path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
6507
|
-
return true;
|
|
6508
|
-
}
|
|
6509
6407
|
switch (interaction.type) {
|
|
6510
6408
|
case INTERACTION_ACCESSED: {
|
|
6511
6409
|
if (this.isReassigned)
|
|
6512
6410
|
return true;
|
|
6513
6411
|
return (!context.accessed.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6514
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
6412
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6515
6413
|
}
|
|
6516
6414
|
case INTERACTION_ASSIGNED: {
|
|
6517
6415
|
if (this.included)
|
|
@@ -6521,63 +6419,44 @@ class LocalVariable extends Variable {
|
|
|
6521
6419
|
if (this.isReassigned)
|
|
6522
6420
|
return true;
|
|
6523
6421
|
return (!context.assigned.trackEntityAtPathAndGetIfTracked(path, this) &&
|
|
6524
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
6422
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6525
6423
|
}
|
|
6526
6424
|
case INTERACTION_CALLED: {
|
|
6527
6425
|
if (this.isReassigned)
|
|
6528
6426
|
return true;
|
|
6529
6427
|
return (!(interaction.withNew ? context.instantiated : context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this) &&
|
|
6530
|
-
this.init.hasEffectsOnInteractionAtPath(
|
|
6428
|
+
this.init.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
6531
6429
|
}
|
|
6532
6430
|
}
|
|
6533
6431
|
}
|
|
6534
|
-
|
|
6535
|
-
if (!this.
|
|
6536
|
-
|
|
6537
|
-
if (!this.included) {
|
|
6538
|
-
// This will reduce the number of tree-shaking passes by eagerly
|
|
6539
|
-
// including inits. By pushing this here instead of directly including
|
|
6540
|
-
// we avoid deep call stacks.
|
|
6541
|
-
this.module.scope.context.newlyIncludedVariableInits.add(this.init);
|
|
6542
|
-
}
|
|
6543
|
-
super.includePath(path, context);
|
|
6432
|
+
include() {
|
|
6433
|
+
if (!this.included) {
|
|
6434
|
+
super.include();
|
|
6544
6435
|
for (const declaration of this.declarations) {
|
|
6545
6436
|
// If node is a default export, it can save a tree-shaking run to include the full declaration now
|
|
6546
6437
|
if (!declaration.included)
|
|
6547
|
-
declaration.include(
|
|
6438
|
+
declaration.include(createInclusionContext(), false);
|
|
6548
6439
|
let node = declaration.parent;
|
|
6549
6440
|
while (!node.included) {
|
|
6550
6441
|
// We do not want to properly include parents in case they are part of a dead branch
|
|
6551
6442
|
// in which case .include() might pull in more dead code
|
|
6552
|
-
node.
|
|
6443
|
+
node.included = true;
|
|
6553
6444
|
if (node.type === parseAst_js.Program)
|
|
6554
6445
|
break;
|
|
6555
6446
|
node = node.parent;
|
|
6556
6447
|
}
|
|
6557
6448
|
}
|
|
6558
|
-
// We need to make sure we include the correct path of the init
|
|
6559
|
-
if (path.length > 0) {
|
|
6560
|
-
this.init.includePath(limitConcatenatedPathDepth(this.initPath, path), context);
|
|
6561
|
-
this.additionalInitializers?.forEach(initializer => initializer.includePath(UNKNOWN_PATH, context));
|
|
6562
|
-
}
|
|
6563
6449
|
}
|
|
6564
6450
|
}
|
|
6565
|
-
includeCallArguments(context,
|
|
6566
|
-
if (this.isReassigned ||
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
// a specific path
|
|
6570
|
-
this.initPath.length > 0) {
|
|
6571
|
-
for (const argument of interaction.args) {
|
|
6572
|
-
if (argument) {
|
|
6573
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
6574
|
-
argument.include(context, false);
|
|
6575
|
-
}
|
|
6451
|
+
includeCallArguments(context, parameters) {
|
|
6452
|
+
if (this.isReassigned || context.includedCallArguments.has(this.init)) {
|
|
6453
|
+
for (const argument of parameters) {
|
|
6454
|
+
argument.include(context, false);
|
|
6576
6455
|
}
|
|
6577
6456
|
}
|
|
6578
6457
|
else {
|
|
6579
6458
|
context.includedCallArguments.add(this.init);
|
|
6580
|
-
this.init.includeCallArguments(context,
|
|
6459
|
+
this.init.includeCallArguments(context, parameters);
|
|
6581
6460
|
context.includedCallArguments.delete(this.init);
|
|
6582
6461
|
}
|
|
6583
6462
|
}
|
|
@@ -6657,31 +6536,18 @@ class IdentifierBase extends NodeBase {
|
|
|
6657
6536
|
}
|
|
6658
6537
|
}
|
|
6659
6538
|
}
|
|
6660
|
-
include(
|
|
6661
|
-
if (!this.included)
|
|
6662
|
-
this.includeNode(context);
|
|
6663
|
-
}
|
|
6664
|
-
includeNode(context) {
|
|
6665
|
-
this.included = true;
|
|
6539
|
+
include() {
|
|
6666
6540
|
if (!this.deoptimized)
|
|
6667
6541
|
this.applyDeoptimizations();
|
|
6668
|
-
if (this.variable !== null) {
|
|
6669
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
6670
|
-
}
|
|
6671
|
-
}
|
|
6672
|
-
includePath(path, context) {
|
|
6673
6542
|
if (!this.included) {
|
|
6674
6543
|
this.included = true;
|
|
6675
6544
|
if (this.variable !== null) {
|
|
6676
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
6545
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
6677
6546
|
}
|
|
6678
6547
|
}
|
|
6679
|
-
else if (path.length > 0) {
|
|
6680
|
-
this.variable?.includePath(path, context);
|
|
6681
|
-
}
|
|
6682
6548
|
}
|
|
6683
|
-
includeCallArguments(context,
|
|
6684
|
-
this.variable.includeCallArguments(context,
|
|
6549
|
+
includeCallArguments(context, parameters) {
|
|
6550
|
+
this.variable.includeCallArguments(context, parameters);
|
|
6685
6551
|
}
|
|
6686
6552
|
isPossibleTDZ() {
|
|
6687
6553
|
// return cached value to avoid issues with the next tree-shaking pass
|
|
@@ -6764,40 +6630,11 @@ function closestParentFunctionOrProgram(node) {
|
|
|
6764
6630
|
return node;
|
|
6765
6631
|
}
|
|
6766
6632
|
|
|
6767
|
-
class ObjectMember extends ExpressionEntity {
|
|
6768
|
-
constructor(object, path) {
|
|
6769
|
-
super();
|
|
6770
|
-
this.object = object;
|
|
6771
|
-
this.path = path;
|
|
6772
|
-
}
|
|
6773
|
-
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
6774
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.path, ...path], recursionTracker);
|
|
6775
|
-
}
|
|
6776
|
-
deoptimizePath(path) {
|
|
6777
|
-
this.object.deoptimizePath([...this.path, ...path]);
|
|
6778
|
-
}
|
|
6779
|
-
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
6780
|
-
return this.object.getLiteralValueAtPath([...this.path, ...path], recursionTracker, origin);
|
|
6781
|
-
}
|
|
6782
|
-
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
6783
|
-
return this.object.getReturnExpressionWhenCalledAtPath([...this.path, ...path], interaction, recursionTracker, origin);
|
|
6784
|
-
}
|
|
6785
|
-
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
6786
|
-
return this.object.hasEffectsOnInteractionAtPath([...this.path, ...path], interaction, context);
|
|
6787
|
-
}
|
|
6788
|
-
}
|
|
6789
|
-
|
|
6790
6633
|
class Identifier extends IdentifierBase {
|
|
6791
6634
|
constructor() {
|
|
6792
6635
|
super(...arguments);
|
|
6793
6636
|
this.variable = null;
|
|
6794
6637
|
}
|
|
6795
|
-
get isDestructuringDeoptimized() {
|
|
6796
|
-
return isFlagSet(this.flags, 8388608 /* Flag.destructuringDeoptimized */);
|
|
6797
|
-
}
|
|
6798
|
-
set isDestructuringDeoptimized(value) {
|
|
6799
|
-
this.flags = setFlag(this.flags, 8388608 /* Flag.destructuringDeoptimized */, value);
|
|
6800
|
-
}
|
|
6801
6638
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
6802
6639
|
if (exportNamesByVariable.has(this.variable)) {
|
|
6803
6640
|
variables.push(this.variable);
|
|
@@ -6809,53 +6646,43 @@ class Identifier extends IdentifierBase {
|
|
|
6809
6646
|
this.variable.addReference(this);
|
|
6810
6647
|
this.isVariableReference = true;
|
|
6811
6648
|
}
|
|
6812
|
-
}
|
|
6813
|
-
declare(kind,
|
|
6814
|
-
let variable;
|
|
6815
|
-
const { treeshake } = this.scope.context.options;
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
}
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
if ((this.included ||=
|
|
6847
|
-
destructuredInitPath.length > 0 &&
|
|
6848
|
-
!context.brokenFlow &&
|
|
6849
|
-
propertyReadSideEffects &&
|
|
6850
|
-
(propertyReadSideEffects === 'always' ||
|
|
6851
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext())))) {
|
|
6852
|
-
if (this.variable && !this.variable.included) {
|
|
6853
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
6649
|
+
}
|
|
6650
|
+
declare(kind, init) {
|
|
6651
|
+
let variable;
|
|
6652
|
+
const { treeshake } = this.scope.context.options;
|
|
6653
|
+
switch (kind) {
|
|
6654
|
+
case 'var': {
|
|
6655
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
6656
|
+
if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
|
|
6657
|
+
// Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
|
|
6658
|
+
variable.markInitializersForDeoptimization();
|
|
6659
|
+
}
|
|
6660
|
+
break;
|
|
6661
|
+
}
|
|
6662
|
+
case 'function': {
|
|
6663
|
+
// in strict mode, functions are only hoisted within a scope but not across block scopes
|
|
6664
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
6665
|
+
break;
|
|
6666
|
+
}
|
|
6667
|
+
case 'let':
|
|
6668
|
+
case 'const':
|
|
6669
|
+
case 'using':
|
|
6670
|
+
case 'await using':
|
|
6671
|
+
case 'class': {
|
|
6672
|
+
variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
|
|
6673
|
+
break;
|
|
6674
|
+
}
|
|
6675
|
+
case 'parameter': {
|
|
6676
|
+
variable = this.scope.addParameterDeclaration(this);
|
|
6677
|
+
break;
|
|
6678
|
+
}
|
|
6679
|
+
/* istanbul ignore next */
|
|
6680
|
+
default: {
|
|
6681
|
+
/* istanbul ignore next */
|
|
6682
|
+
throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
|
|
6854
6683
|
}
|
|
6855
|
-
init.includePath(destructuredInitPath, context);
|
|
6856
|
-
return true;
|
|
6857
6684
|
}
|
|
6858
|
-
return
|
|
6685
|
+
return [(this.variable = variable)];
|
|
6859
6686
|
}
|
|
6860
6687
|
markDeclarationReached() {
|
|
6861
6688
|
this.variable.initReached = true;
|
|
@@ -6909,17 +6736,18 @@ class Scope {
|
|
|
6909
6736
|
- then the variable is still declared in the hoisted outer scope, but the initializer is assigned to the parameter
|
|
6910
6737
|
- const, let, class, and function except in the cases above cannot redeclare anything
|
|
6911
6738
|
*/
|
|
6912
|
-
addDeclaration(identifier, context, init,
|
|
6739
|
+
addDeclaration(identifier, context, init, kind) {
|
|
6913
6740
|
const name = identifier.name;
|
|
6914
6741
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
6915
6742
|
if (existingVariable) {
|
|
6916
|
-
|
|
6743
|
+
const existingKind = existingVariable.kind;
|
|
6744
|
+
if (kind === 'var' && existingKind === 'var') {
|
|
6917
6745
|
existingVariable.addDeclaration(identifier, init);
|
|
6918
6746
|
return existingVariable;
|
|
6919
6747
|
}
|
|
6920
6748
|
context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
6921
6749
|
}
|
|
6922
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
6750
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
6923
6751
|
this.variables.set(name, newVariable);
|
|
6924
6752
|
return newVariable;
|
|
6925
6753
|
}
|
|
@@ -7095,6 +6923,7 @@ class MethodBase extends NodeBase {
|
|
|
7095
6923
|
}
|
|
7096
6924
|
return this.getAccessedValue()[0].hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7097
6925
|
}
|
|
6926
|
+
applyDeoptimizations() { }
|
|
7098
6927
|
getAccessedValue() {
|
|
7099
6928
|
if (this.accessedValue === null) {
|
|
7100
6929
|
if (this.kind === 'get') {
|
|
@@ -7108,20 +6937,19 @@ class MethodBase extends NodeBase {
|
|
|
7108
6937
|
return this.accessedValue;
|
|
7109
6938
|
}
|
|
7110
6939
|
}
|
|
7111
|
-
MethodBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
7112
|
-
MethodBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
7113
6940
|
|
|
7114
6941
|
class MethodDefinition extends MethodBase {
|
|
7115
6942
|
hasEffects(context) {
|
|
7116
6943
|
return super.hasEffects(context) || checkEffectForNodes(this.decorators, context);
|
|
7117
6944
|
}
|
|
6945
|
+
applyDeoptimizations() { }
|
|
7118
6946
|
}
|
|
7119
6947
|
|
|
7120
6948
|
class BlockScope extends ChildScope {
|
|
7121
6949
|
constructor(parent) {
|
|
7122
6950
|
super(parent, parent.context);
|
|
7123
6951
|
}
|
|
7124
|
-
addDeclaration(identifier, context, init,
|
|
6952
|
+
addDeclaration(identifier, context, init, kind) {
|
|
7125
6953
|
if (kind === 'var') {
|
|
7126
6954
|
const name = identifier.name;
|
|
7127
6955
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -7133,7 +6961,7 @@ class BlockScope extends ChildScope {
|
|
|
7133
6961
|
}
|
|
7134
6962
|
return context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
7135
6963
|
}
|
|
7136
|
-
const declaredVariable = this.parent.addDeclaration(identifier, context, init,
|
|
6964
|
+
const declaredVariable = this.parent.addDeclaration(identifier, context, init, kind);
|
|
7137
6965
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
7138
6966
|
// We cannot call deoptimizePath here.
|
|
7139
6967
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -7141,7 +6969,7 @@ class BlockScope extends ChildScope {
|
|
|
7141
6969
|
this.addHoistedVariable(name, declaredVariable);
|
|
7142
6970
|
return declaredVariable;
|
|
7143
6971
|
}
|
|
7144
|
-
return super.addDeclaration(identifier, context, init,
|
|
6972
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
7145
6973
|
}
|
|
7146
6974
|
}
|
|
7147
6975
|
|
|
@@ -7173,12 +7001,33 @@ class StaticBlock extends NodeBase {
|
|
|
7173
7001
|
}
|
|
7174
7002
|
}
|
|
7175
7003
|
}
|
|
7176
|
-
StaticBlock.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
7177
|
-
StaticBlock.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
7178
7004
|
function isStaticBlock(statement) {
|
|
7179
7005
|
return statement.type === parseAst_js.StaticBlock;
|
|
7180
7006
|
}
|
|
7181
7007
|
|
|
7008
|
+
class ObjectMember extends ExpressionEntity {
|
|
7009
|
+
constructor(object, key) {
|
|
7010
|
+
super();
|
|
7011
|
+
this.object = object;
|
|
7012
|
+
this.key = key;
|
|
7013
|
+
}
|
|
7014
|
+
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
7015
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.key, ...path], recursionTracker);
|
|
7016
|
+
}
|
|
7017
|
+
deoptimizePath(path) {
|
|
7018
|
+
this.object.deoptimizePath([this.key, ...path]);
|
|
7019
|
+
}
|
|
7020
|
+
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7021
|
+
return this.object.getLiteralValueAtPath([this.key, ...path], recursionTracker, origin);
|
|
7022
|
+
}
|
|
7023
|
+
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
7024
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.key, ...path], interaction, recursionTracker, origin);
|
|
7025
|
+
}
|
|
7026
|
+
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7027
|
+
return this.object.hasEffectsOnInteractionAtPath([this.key, ...path], interaction, context);
|
|
7028
|
+
}
|
|
7029
|
+
}
|
|
7030
|
+
|
|
7182
7031
|
class ClassNode extends NodeBase {
|
|
7183
7032
|
constructor() {
|
|
7184
7033
|
super(...arguments);
|
|
@@ -7219,20 +7068,21 @@ class ClassNode extends NodeBase {
|
|
|
7219
7068
|
: this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7220
7069
|
}
|
|
7221
7070
|
include(context, includeChildrenRecursively) {
|
|
7222
|
-
if (!this.
|
|
7223
|
-
this.
|
|
7071
|
+
if (!this.deoptimized)
|
|
7072
|
+
this.applyDeoptimizations();
|
|
7073
|
+
this.included = true;
|
|
7224
7074
|
this.superClass?.include(context, includeChildrenRecursively);
|
|
7225
7075
|
this.body.include(context, includeChildrenRecursively);
|
|
7226
7076
|
for (const decorator of this.decorators)
|
|
7227
7077
|
decorator.include(context, includeChildrenRecursively);
|
|
7228
7078
|
if (this.id) {
|
|
7229
7079
|
this.id.markDeclarationReached();
|
|
7230
|
-
this.id.include(
|
|
7080
|
+
this.id.include();
|
|
7231
7081
|
}
|
|
7232
7082
|
}
|
|
7233
7083
|
initialise() {
|
|
7234
7084
|
super.initialise();
|
|
7235
|
-
this.id?.declare('class',
|
|
7085
|
+
this.id?.declare('class', this);
|
|
7236
7086
|
for (const method of this.body.body) {
|
|
7237
7087
|
if (method instanceof MethodDefinition && method.kind === 'constructor') {
|
|
7238
7088
|
this.classConstructor = method;
|
|
@@ -7290,12 +7140,11 @@ class ClassNode extends NodeBase {
|
|
|
7290
7140
|
staticProperties.unshift({
|
|
7291
7141
|
key: 'prototype',
|
|
7292
7142
|
kind: 'init',
|
|
7293
|
-
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass,
|
|
7143
|
+
property: new ObjectEntity(dynamicMethods, this.superClass ? new ObjectMember(this.superClass, 'prototype') : OBJECT_PROTOTYPE)
|
|
7294
7144
|
});
|
|
7295
7145
|
return (this.objectEntity = new ObjectEntity(staticProperties, this.superClass || OBJECT_PROTOTYPE));
|
|
7296
7146
|
}
|
|
7297
7147
|
}
|
|
7298
|
-
ClassNode.prototype.includeNode = onlyIncludeSelf;
|
|
7299
7148
|
|
|
7300
7149
|
class ClassDeclaration extends ClassNode {
|
|
7301
7150
|
initialise() {
|
|
@@ -7348,7 +7197,7 @@ class ClassDeclaration extends ClassNode {
|
|
|
7348
7197
|
|
|
7349
7198
|
class ArgumentsVariable extends LocalVariable {
|
|
7350
7199
|
constructor(context) {
|
|
7351
|
-
super('arguments', null, UNKNOWN_EXPRESSION,
|
|
7200
|
+
super('arguments', null, UNKNOWN_EXPRESSION, context, 'other');
|
|
7352
7201
|
this.deoptimizedArguments = [];
|
|
7353
7202
|
}
|
|
7354
7203
|
addArgumentToBeDeoptimized(argument) {
|
|
@@ -7362,8 +7211,8 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
7362
7211
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
7363
7212
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
7364
7213
|
}
|
|
7365
|
-
|
|
7366
|
-
super.
|
|
7214
|
+
include() {
|
|
7215
|
+
super.include();
|
|
7367
7216
|
for (const argument of this.deoptimizedArguments) {
|
|
7368
7217
|
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7369
7218
|
}
|
|
@@ -7374,28 +7223,27 @@ class ArgumentsVariable extends LocalVariable {
|
|
|
7374
7223
|
const MAX_TRACKED_INTERACTIONS = 20;
|
|
7375
7224
|
const NO_INTERACTIONS = parseAst_js.EMPTY_ARRAY;
|
|
7376
7225
|
const UNKNOWN_DEOPTIMIZED_FIELD = new Set([UnknownKey]);
|
|
7377
|
-
const EMPTY_PATH_TRACKER = new
|
|
7226
|
+
const EMPTY_PATH_TRACKER = new PathTracker();
|
|
7378
7227
|
const UNKNOWN_DEOPTIMIZED_ENTITY = new Set([UNKNOWN_EXPRESSION]);
|
|
7379
7228
|
class ParameterVariable extends LocalVariable {
|
|
7380
|
-
constructor(name, declarator,
|
|
7381
|
-
super(name, declarator, UNKNOWN_EXPRESSION,
|
|
7229
|
+
constructor(name, declarator, context) {
|
|
7230
|
+
super(name, declarator, UNKNOWN_EXPRESSION, context, 'parameter');
|
|
7382
7231
|
this.deoptimizationInteractions = [];
|
|
7383
|
-
this.deoptimizations = new
|
|
7232
|
+
this.deoptimizations = new PathTracker();
|
|
7384
7233
|
this.deoptimizedFields = new Set();
|
|
7385
|
-
this.
|
|
7386
|
-
this.
|
|
7234
|
+
this.entitiesToBeDeoptimized = new Set();
|
|
7235
|
+
this.expressionsUseTheKnownValue = [];
|
|
7387
7236
|
this.knownValue = null;
|
|
7388
7237
|
this.knownValueLiteral = UnknownValue;
|
|
7389
7238
|
this.frozenValue = null;
|
|
7390
7239
|
}
|
|
7391
|
-
|
|
7392
|
-
this.updateKnownValue(entity);
|
|
7240
|
+
addEntityToBeDeoptimized(entity) {
|
|
7393
7241
|
if (entity === UNKNOWN_EXPRESSION) {
|
|
7394
7242
|
// As unknown expressions fully deoptimize all interactions, we can clear
|
|
7395
7243
|
// the interaction cache at this point provided we keep this optimization
|
|
7396
7244
|
// in mind when adding new interactions
|
|
7397
|
-
if (!this.
|
|
7398
|
-
this.
|
|
7245
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
7246
|
+
this.entitiesToBeDeoptimized.add(UNKNOWN_EXPRESSION);
|
|
7399
7247
|
for (const { interaction } of this.deoptimizationInteractions) {
|
|
7400
7248
|
deoptimizeInteraction(interaction);
|
|
7401
7249
|
}
|
|
@@ -7405,34 +7253,27 @@ class ParameterVariable extends LocalVariable {
|
|
|
7405
7253
|
else if (this.deoptimizedFields.has(UnknownKey)) {
|
|
7406
7254
|
// This means that we already deoptimized all interactions and no longer
|
|
7407
7255
|
// track them
|
|
7408
|
-
entity.deoptimizePath(
|
|
7256
|
+
entity.deoptimizePath(UNKNOWN_PATH);
|
|
7409
7257
|
}
|
|
7410
|
-
else if (!this.
|
|
7411
|
-
this.
|
|
7258
|
+
else if (!this.entitiesToBeDeoptimized.has(entity)) {
|
|
7259
|
+
this.entitiesToBeDeoptimized.add(entity);
|
|
7412
7260
|
for (const field of this.deoptimizedFields) {
|
|
7413
|
-
entity.deoptimizePath([
|
|
7261
|
+
entity.deoptimizePath([field]);
|
|
7414
7262
|
}
|
|
7415
7263
|
for (const { interaction, path } of this.deoptimizationInteractions) {
|
|
7416
|
-
|
|
7417
|
-
deoptimizeInteraction(interaction);
|
|
7418
|
-
continue;
|
|
7419
|
-
}
|
|
7420
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, [...this.initPath, ...path], SHARED_RECURSION_TRACKER);
|
|
7264
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
7421
7265
|
}
|
|
7422
7266
|
}
|
|
7423
7267
|
}
|
|
7424
|
-
/** This says we should not make assumptions about the value of the parameter.
|
|
7425
|
-
* This is different from deoptimization that will also cause argument values
|
|
7426
|
-
* to be deoptimized. */
|
|
7427
7268
|
markReassigned() {
|
|
7428
7269
|
if (this.isReassigned) {
|
|
7429
7270
|
return;
|
|
7430
7271
|
}
|
|
7431
7272
|
super.markReassigned();
|
|
7432
|
-
for (const expression of this.
|
|
7273
|
+
for (const expression of this.expressionsUseTheKnownValue) {
|
|
7433
7274
|
expression.deoptimizeCache();
|
|
7434
7275
|
}
|
|
7435
|
-
this.
|
|
7276
|
+
this.expressionsUseTheKnownValue = parseAst_js.EMPTY_ARRAY;
|
|
7436
7277
|
}
|
|
7437
7278
|
deoptimizeCache() {
|
|
7438
7279
|
this.markReassigned();
|
|
@@ -7449,7 +7290,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
7449
7290
|
}
|
|
7450
7291
|
if (this.knownValue === null) {
|
|
7451
7292
|
this.knownValue = argument;
|
|
7452
|
-
this.knownValueLiteral = argument.getLiteralValueAtPath(
|
|
7293
|
+
this.knownValueLiteral = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7453
7294
|
return;
|
|
7454
7295
|
}
|
|
7455
7296
|
// the same literal or identifier, do nothing
|
|
@@ -7465,7 +7306,7 @@ class ParameterVariable extends LocalVariable {
|
|
|
7465
7306
|
return;
|
|
7466
7307
|
}
|
|
7467
7308
|
// add tracking for the new argument
|
|
7468
|
-
const newValue = argument.getLiteralValueAtPath(
|
|
7309
|
+
const newValue = argument.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
7469
7310
|
if (newValue !== oldValue) {
|
|
7470
7311
|
this.markReassigned();
|
|
7471
7312
|
}
|
|
@@ -7483,31 +7324,24 @@ class ParameterVariable extends LocalVariable {
|
|
|
7483
7324
|
return this.frozenValue;
|
|
7484
7325
|
}
|
|
7485
7326
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
7486
|
-
if (this.isReassigned
|
|
7327
|
+
if (this.isReassigned) {
|
|
7487
7328
|
return UnknownValue;
|
|
7488
7329
|
}
|
|
7489
7330
|
const knownValue = this.getKnownValue();
|
|
7490
|
-
this.
|
|
7491
|
-
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(
|
|
7331
|
+
this.expressionsUseTheKnownValue.push(origin);
|
|
7332
|
+
return recursionTracker.withTrackedEntityAtPath(path, knownValue, () => knownValue.getLiteralValueAtPath(path, recursionTracker, origin), UnknownValue);
|
|
7492
7333
|
}
|
|
7493
7334
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7494
|
-
|
|
7495
|
-
if (this.isReassigned ||
|
|
7496
|
-
type === INTERACTION_ASSIGNED ||
|
|
7497
|
-
path.length + this.initPath.length > MAX_PATH_DEPTH) {
|
|
7335
|
+
if (this.isReassigned || interaction.type === INTERACTION_ASSIGNED) {
|
|
7498
7336
|
return super.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7499
7337
|
}
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
? context.instantiated
|
|
7503
|
-
: context.called).trackEntityAtPathAndGetIfTracked(path, interaction.args, this)
|
|
7504
|
-
: context.accessed.trackEntityAtPathAndGetIfTracked(path, this)) &&
|
|
7505
|
-
this.getKnownValue().hasEffectsOnInteractionAtPath([...this.initPath, ...path], interaction, context));
|
|
7338
|
+
const knownValue = this.getKnownValue();
|
|
7339
|
+
return knownValue.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
7506
7340
|
}
|
|
7507
7341
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path) {
|
|
7508
7342
|
// For performance reasons, we fully deoptimize all deeper interactions
|
|
7509
7343
|
if (path.length >= 2 ||
|
|
7510
|
-
this.
|
|
7344
|
+
this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION) ||
|
|
7511
7345
|
this.deoptimizationInteractions.length >= MAX_TRACKED_INTERACTIONS ||
|
|
7512
7346
|
(path.length === 1 &&
|
|
7513
7347
|
(this.deoptimizedFields.has(UnknownKey) ||
|
|
@@ -7516,10 +7350,10 @@ class ParameterVariable extends LocalVariable {
|
|
|
7516
7350
|
return;
|
|
7517
7351
|
}
|
|
7518
7352
|
if (!this.deoptimizations.trackEntityAtPathAndGetIfTracked(path, interaction.args)) {
|
|
7519
|
-
for (const entity of this.
|
|
7520
|
-
entity.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
7353
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
7354
|
+
entity.deoptimizeArgumentsOnInteractionAtPath(interaction, path, SHARED_RECURSION_TRACKER);
|
|
7521
7355
|
}
|
|
7522
|
-
if (!this.
|
|
7356
|
+
if (!this.entitiesToBeDeoptimized.has(UNKNOWN_EXPRESSION)) {
|
|
7523
7357
|
this.deoptimizationInteractions.push({
|
|
7524
7358
|
interaction,
|
|
7525
7359
|
path
|
|
@@ -7540,17 +7374,17 @@ class ParameterVariable extends LocalVariable {
|
|
|
7540
7374
|
return;
|
|
7541
7375
|
}
|
|
7542
7376
|
this.deoptimizedFields.add(key);
|
|
7543
|
-
for (const entity of this.
|
|
7377
|
+
for (const entity of this.entitiesToBeDeoptimized) {
|
|
7544
7378
|
// We do not need a recursion tracker here as we already track whether
|
|
7545
7379
|
// this field is deoptimized
|
|
7546
|
-
entity.deoptimizePath([
|
|
7380
|
+
entity.deoptimizePath([key]);
|
|
7547
7381
|
}
|
|
7548
7382
|
if (key === UnknownKey) {
|
|
7549
7383
|
// save some memory
|
|
7550
7384
|
this.deoptimizationInteractions = NO_INTERACTIONS;
|
|
7551
7385
|
this.deoptimizations = EMPTY_PATH_TRACKER;
|
|
7552
7386
|
this.deoptimizedFields = UNKNOWN_DEOPTIMIZED_FIELD;
|
|
7553
|
-
this.
|
|
7387
|
+
this.entitiesToBeDeoptimized = UNKNOWN_DEOPTIMIZED_ENTITY;
|
|
7554
7388
|
}
|
|
7555
7389
|
}
|
|
7556
7390
|
getReturnExpressionWhenCalledAtPath(path) {
|
|
@@ -7565,14 +7399,11 @@ class ParameterVariable extends LocalVariable {
|
|
|
7565
7399
|
}
|
|
7566
7400
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
7567
7401
|
}
|
|
7568
|
-
includeArgumentPaths(entity, context) {
|
|
7569
|
-
this.includedPathTracker.includeAllPaths(entity, context, this.initPath);
|
|
7570
|
-
}
|
|
7571
7402
|
}
|
|
7572
7403
|
|
|
7573
7404
|
class ThisVariable extends ParameterVariable {
|
|
7574
7405
|
constructor(context) {
|
|
7575
|
-
super('this', null,
|
|
7406
|
+
super('this', null, context);
|
|
7576
7407
|
}
|
|
7577
7408
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
7578
7409
|
return (context.replacedVariableInits.get(this) || UNKNOWN_EXPRESSION).hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -7584,7 +7415,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7584
7415
|
super(parent, parent.context);
|
|
7585
7416
|
this.parent = parent;
|
|
7586
7417
|
}
|
|
7587
|
-
addDeclaration(identifier, context, init,
|
|
7418
|
+
addDeclaration(identifier, context, init, kind) {
|
|
7588
7419
|
if (kind === 'var') {
|
|
7589
7420
|
const name = identifier.name;
|
|
7590
7421
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
@@ -7597,7 +7428,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7597
7428
|
// the assignment actually goes to the parameter and the var is
|
|
7598
7429
|
// hoisted without assignment. Locally, it is shadowed by the
|
|
7599
7430
|
// parameter
|
|
7600
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION,
|
|
7431
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, UNDEFINED_EXPRESSION, kind);
|
|
7601
7432
|
// To avoid the need to rewrite the declaration, we link the variable
|
|
7602
7433
|
// names. If we ever implement a logic that splits initialization and
|
|
7603
7434
|
// assignment for hoisted vars, the "renderLikeHoisted" logic can be
|
|
@@ -7616,7 +7447,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7616
7447
|
return context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
7617
7448
|
}
|
|
7618
7449
|
// We only add parameters to parameter scopes
|
|
7619
|
-
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init,
|
|
7450
|
+
const declaredVariable = this.parent.parent.addDeclaration(identifier, context, init, kind);
|
|
7620
7451
|
// Necessary to make sure the init is deoptimized for conditional declarations.
|
|
7621
7452
|
// We cannot call deoptimizePath here.
|
|
7622
7453
|
declaredVariable.markInitializersForDeoptimization();
|
|
@@ -7624,7 +7455,7 @@ class CatchBodyScope extends ChildScope {
|
|
|
7624
7455
|
this.addHoistedVariable(name, declaredVariable);
|
|
7625
7456
|
return declaredVariable;
|
|
7626
7457
|
}
|
|
7627
|
-
return super.addDeclaration(identifier, context, init,
|
|
7458
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
7628
7459
|
}
|
|
7629
7460
|
}
|
|
7630
7461
|
|
|
@@ -7634,7 +7465,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7634
7465
|
}
|
|
7635
7466
|
// There is stuff that is only allowed in function scopes, i.e. functions can
|
|
7636
7467
|
// be redeclared, functions and var can redeclare each other
|
|
7637
|
-
addDeclaration(identifier, context, init,
|
|
7468
|
+
addDeclaration(identifier, context, init, kind) {
|
|
7638
7469
|
const name = identifier.name;
|
|
7639
7470
|
const existingVariable = this.hoistedVariables?.get(name) || this.variables.get(name);
|
|
7640
7471
|
if (existingVariable) {
|
|
@@ -7646,7 +7477,7 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7646
7477
|
}
|
|
7647
7478
|
context.error(parseAst_js.logRedeclarationError(name), identifier.start);
|
|
7648
7479
|
}
|
|
7649
|
-
const newVariable = new LocalVariable(identifier.name, identifier, init,
|
|
7480
|
+
const newVariable = new LocalVariable(identifier.name, identifier, init, context, kind);
|
|
7650
7481
|
this.variables.set(name, newVariable);
|
|
7651
7482
|
return newVariable;
|
|
7652
7483
|
}
|
|
@@ -7655,21 +7486,21 @@ class FunctionBodyScope extends ChildScope {
|
|
|
7655
7486
|
class ParameterScope extends ChildScope {
|
|
7656
7487
|
constructor(parent, isCatchScope) {
|
|
7657
7488
|
super(parent, parent.context);
|
|
7658
|
-
this.hasRest = false;
|
|
7659
7489
|
this.parameters = [];
|
|
7490
|
+
this.hasRest = false;
|
|
7660
7491
|
this.bodyScope = isCatchScope ? new CatchBodyScope(this) : new FunctionBodyScope(this);
|
|
7661
7492
|
}
|
|
7662
7493
|
/**
|
|
7663
7494
|
* Adds a parameter to this scope. Parameters must be added in the correct
|
|
7664
7495
|
* order, i.e. from left to right.
|
|
7665
7496
|
*/
|
|
7666
|
-
addParameterDeclaration(identifier
|
|
7497
|
+
addParameterDeclaration(identifier) {
|
|
7667
7498
|
const { name, start } = identifier;
|
|
7668
7499
|
const existingParameter = this.variables.get(name);
|
|
7669
7500
|
if (existingParameter) {
|
|
7670
7501
|
return this.context.error(parseAst_js.logDuplicateArgumentNameError(name), start);
|
|
7671
7502
|
}
|
|
7672
|
-
const variable = new ParameterVariable(name, identifier,
|
|
7503
|
+
const variable = new ParameterVariable(name, identifier, this.context);
|
|
7673
7504
|
this.variables.set(name, variable);
|
|
7674
7505
|
// We also add it to the body scope to detect name conflicts with local
|
|
7675
7506
|
// variables. We still need the intermediate scope, though, as parameter
|
|
@@ -7687,56 +7518,42 @@ class ParameterScope extends ChildScope {
|
|
|
7687
7518
|
}
|
|
7688
7519
|
this.hasRest = hasRest;
|
|
7689
7520
|
}
|
|
7690
|
-
includeCallArguments(context,
|
|
7521
|
+
includeCallArguments(context, parameters) {
|
|
7691
7522
|
let calledFromTryStatement = false;
|
|
7692
7523
|
let argumentIncluded = false;
|
|
7693
7524
|
const restParameter = this.hasRest && this.parameters[this.parameters.length - 1];
|
|
7694
|
-
const
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
7698
|
-
|
|
7699
|
-
|
|
7700
|
-
if (argument instanceof SpreadElement && !argumentIncluded) {
|
|
7701
|
-
argumentIncluded = true;
|
|
7702
|
-
lastExplicitlyIncludedIndex = argumentIndex - 1;
|
|
7703
|
-
}
|
|
7704
|
-
if (argumentIncluded) {
|
|
7705
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
7706
|
-
argument.include(context, false);
|
|
7525
|
+
for (const checkedArgument of parameters) {
|
|
7526
|
+
if (checkedArgument instanceof SpreadElement) {
|
|
7527
|
+
for (const argument of parameters) {
|
|
7528
|
+
argument.include(context, false);
|
|
7529
|
+
}
|
|
7530
|
+
break;
|
|
7707
7531
|
}
|
|
7708
7532
|
}
|
|
7709
|
-
|
|
7710
|
-
|
|
7711
|
-
|
|
7712
|
-
const parameterVariables = this.parameters[index - 1] || restParameter;
|
|
7713
|
-
const argument = args[index];
|
|
7533
|
+
for (let index = parameters.length - 1; index >= 0; index--) {
|
|
7534
|
+
const parameterVariables = this.parameters[index] || restParameter;
|
|
7535
|
+
const argument = parameters[index];
|
|
7714
7536
|
if (parameterVariables) {
|
|
7715
7537
|
calledFromTryStatement = false;
|
|
7716
7538
|
if (parameterVariables.length === 0) {
|
|
7717
|
-
// handle empty destructuring
|
|
7539
|
+
// handle empty destructuring
|
|
7718
7540
|
argumentIncluded = true;
|
|
7719
7541
|
}
|
|
7720
7542
|
else {
|
|
7721
7543
|
for (const variable of parameterVariables) {
|
|
7722
|
-
if (variable.calledFromTryStatement) {
|
|
7723
|
-
calledFromTryStatement = true;
|
|
7724
|
-
}
|
|
7725
7544
|
if (variable.included) {
|
|
7726
7545
|
argumentIncluded = true;
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
else {
|
|
7731
|
-
variable.includeArgumentPaths(argument, context);
|
|
7732
|
-
argument.include(context, false);
|
|
7733
|
-
}
|
|
7546
|
+
}
|
|
7547
|
+
if (variable.calledFromTryStatement) {
|
|
7548
|
+
calledFromTryStatement = true;
|
|
7734
7549
|
}
|
|
7735
7550
|
}
|
|
7736
7551
|
}
|
|
7737
7552
|
}
|
|
7738
|
-
if (!
|
|
7553
|
+
if (!argumentIncluded && argument.shouldBeIncluded(context)) {
|
|
7739
7554
|
argumentIncluded = true;
|
|
7555
|
+
}
|
|
7556
|
+
if (argumentIncluded) {
|
|
7740
7557
|
argument.include(context, calledFromTryStatement);
|
|
7741
7558
|
}
|
|
7742
7559
|
}
|
|
@@ -7752,62 +7569,11 @@ class ReturnValueScope extends ParameterScope {
|
|
|
7752
7569
|
addReturnExpression(expression) {
|
|
7753
7570
|
this.returnExpressions.push(expression);
|
|
7754
7571
|
}
|
|
7755
|
-
deoptimizeArgumentsOnCall(interaction) {
|
|
7756
|
-
const { parameters } = this;
|
|
7757
|
-
const { args } = interaction;
|
|
7758
|
-
let position = 0;
|
|
7759
|
-
for (; position < args.length - 1; position++) {
|
|
7760
|
-
// Only the "this" argument arg[0] can be null
|
|
7761
|
-
const argument = args[position + 1];
|
|
7762
|
-
if (argument instanceof SpreadElement) {
|
|
7763
|
-
// This deoptimizes the current and remaining parameters and arguments
|
|
7764
|
-
for (; position < parameters.length; position++) {
|
|
7765
|
-
args[position + 1]?.deoptimizePath(UNKNOWN_PATH);
|
|
7766
|
-
parameters[position].forEach(variable => variable.markReassigned());
|
|
7767
|
-
}
|
|
7768
|
-
break;
|
|
7769
|
-
}
|
|
7770
|
-
if (this.hasRest && position >= parameters.length - 1) {
|
|
7771
|
-
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7772
|
-
}
|
|
7773
|
-
else {
|
|
7774
|
-
const variables = parameters[position];
|
|
7775
|
-
if (variables) {
|
|
7776
|
-
for (const variable of variables) {
|
|
7777
|
-
variable.addArgumentValue(argument);
|
|
7778
|
-
}
|
|
7779
|
-
}
|
|
7780
|
-
this.addArgumentToBeDeoptimized(argument);
|
|
7781
|
-
}
|
|
7782
|
-
}
|
|
7783
|
-
const nonRestParameterLength = this.hasRest ? parameters.length - 1 : parameters.length;
|
|
7784
|
-
for (; position < nonRestParameterLength; position++) {
|
|
7785
|
-
for (const variable of parameters[position]) {
|
|
7786
|
-
variable.addArgumentValue(UNDEFINED_EXPRESSION);
|
|
7787
|
-
}
|
|
7788
|
-
}
|
|
7789
|
-
}
|
|
7790
7572
|
getReturnExpression() {
|
|
7791
7573
|
if (this.returnExpression === null)
|
|
7792
7574
|
this.updateReturnExpression();
|
|
7793
7575
|
return this.returnExpression;
|
|
7794
7576
|
}
|
|
7795
|
-
deoptimizeAllParameters() {
|
|
7796
|
-
for (const parameter of this.parameters) {
|
|
7797
|
-
for (const variable of parameter) {
|
|
7798
|
-
variable.deoptimizePath(UNKNOWN_PATH);
|
|
7799
|
-
variable.markReassigned();
|
|
7800
|
-
}
|
|
7801
|
-
}
|
|
7802
|
-
}
|
|
7803
|
-
reassignAllParameters() {
|
|
7804
|
-
for (const parameter of this.parameters) {
|
|
7805
|
-
for (const variable of parameter) {
|
|
7806
|
-
variable.markReassigned();
|
|
7807
|
-
}
|
|
7808
|
-
}
|
|
7809
|
-
}
|
|
7810
|
-
addArgumentToBeDeoptimized(_argument) { }
|
|
7811
7577
|
updateReturnExpression() {
|
|
7812
7578
|
if (this.returnExpressions.length === 1) {
|
|
7813
7579
|
this.returnExpression = this.returnExpressions[0];
|
|
@@ -7823,30 +7589,24 @@ class ReturnValueScope extends ParameterScope {
|
|
|
7823
7589
|
|
|
7824
7590
|
class FunctionScope extends ReturnValueScope {
|
|
7825
7591
|
constructor(parent) {
|
|
7826
|
-
super(parent, false);
|
|
7827
7592
|
const { context } = parent;
|
|
7593
|
+
super(parent, false);
|
|
7828
7594
|
this.variables.set('arguments', (this.argumentsVariable = new ArgumentsVariable(context)));
|
|
7829
7595
|
this.variables.set('this', (this.thisVariable = new ThisVariable(context)));
|
|
7830
7596
|
}
|
|
7831
7597
|
findLexicalBoundary() {
|
|
7832
7598
|
return this;
|
|
7833
7599
|
}
|
|
7834
|
-
includeCallArguments(context,
|
|
7835
|
-
super.includeCallArguments(context,
|
|
7600
|
+
includeCallArguments(context, parameters) {
|
|
7601
|
+
super.includeCallArguments(context, parameters);
|
|
7836
7602
|
if (this.argumentsVariable.included) {
|
|
7837
|
-
const
|
|
7838
|
-
|
|
7839
|
-
const argument = args[argumentIndex];
|
|
7840
|
-
if (argument) {
|
|
7841
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
7603
|
+
for (const argument of parameters) {
|
|
7604
|
+
if (!argument.included) {
|
|
7842
7605
|
argument.include(context, false);
|
|
7843
7606
|
}
|
|
7844
7607
|
}
|
|
7845
7608
|
}
|
|
7846
7609
|
}
|
|
7847
|
-
addArgumentToBeDeoptimized(argument) {
|
|
7848
|
-
this.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
7849
|
-
}
|
|
7850
7610
|
}
|
|
7851
7611
|
|
|
7852
7612
|
class ExpressionStatement extends NodeBase {
|
|
@@ -7874,9 +7634,8 @@ class ExpressionStatement extends NodeBase {
|
|
|
7874
7634
|
return this.parent.type !== parseAst_js.Program;
|
|
7875
7635
|
return super.shouldBeIncluded(context);
|
|
7876
7636
|
}
|
|
7637
|
+
applyDeoptimizations() { }
|
|
7877
7638
|
}
|
|
7878
|
-
ExpressionStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
7879
|
-
ExpressionStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
7880
7639
|
|
|
7881
7640
|
class BlockStatement extends NodeBase {
|
|
7882
7641
|
get deoptimizeBody() {
|
|
@@ -7941,8 +7700,6 @@ class BlockStatement extends NodeBase {
|
|
|
7941
7700
|
}
|
|
7942
7701
|
}
|
|
7943
7702
|
}
|
|
7944
|
-
BlockStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
7945
|
-
BlockStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
7946
7703
|
|
|
7947
7704
|
class RestElement extends NodeBase {
|
|
7948
7705
|
constructor() {
|
|
@@ -7952,12 +7709,9 @@ class RestElement extends NodeBase {
|
|
|
7952
7709
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
7953
7710
|
this.argument.addExportedVariables(variables, exportNamesByVariable);
|
|
7954
7711
|
}
|
|
7955
|
-
declare(kind,
|
|
7712
|
+
declare(kind, init) {
|
|
7956
7713
|
this.declarationInit = init;
|
|
7957
|
-
return this.argument.declare(kind,
|
|
7958
|
-
}
|
|
7959
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
7960
|
-
this.argument.deoptimizeAssignment(getIncludedPatternPath$1(destructuredInitPath), init);
|
|
7714
|
+
return this.argument.declare(kind, UNKNOWN_EXPRESSION);
|
|
7961
7715
|
}
|
|
7962
7716
|
deoptimizePath(path) {
|
|
7963
7717
|
if (path.length === 0) {
|
|
@@ -7968,20 +7722,6 @@ class RestElement extends NodeBase {
|
|
|
7968
7722
|
return (path.length > 0 ||
|
|
7969
7723
|
this.argument.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
7970
7724
|
}
|
|
7971
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
7972
|
-
return this.argument.hasEffectsWhenDestructuring(context, getIncludedPatternPath$1(destructuredInitPath), init);
|
|
7973
|
-
}
|
|
7974
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
7975
|
-
return (this.included =
|
|
7976
|
-
this.argument.includeDestructuredIfNecessary(context, getIncludedPatternPath$1(destructuredInitPath), init) || this.included);
|
|
7977
|
-
}
|
|
7978
|
-
include(context, includeChildrenRecursively) {
|
|
7979
|
-
if (!this.included)
|
|
7980
|
-
this.includeNode(context);
|
|
7981
|
-
// This should just include the identifier, its properties should be
|
|
7982
|
-
// included where the variable is used.
|
|
7983
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
7984
|
-
}
|
|
7985
7725
|
markDeclarationReached() {
|
|
7986
7726
|
this.argument.markDeclarationReached();
|
|
7987
7727
|
}
|
|
@@ -7993,16 +7733,12 @@ class RestElement extends NodeBase {
|
|
|
7993
7733
|
}
|
|
7994
7734
|
}
|
|
7995
7735
|
}
|
|
7996
|
-
RestElement.prototype.includeNode = onlyIncludeSelf;
|
|
7997
|
-
const getIncludedPatternPath$1 = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
7998
|
-
? destructuredInitPath
|
|
7999
|
-
: [...destructuredInitPath, UnknownKey];
|
|
8000
7736
|
|
|
8001
7737
|
class FunctionBase extends NodeBase {
|
|
8002
7738
|
constructor() {
|
|
8003
7739
|
super(...arguments);
|
|
7740
|
+
this.objectEntity = null;
|
|
8004
7741
|
this.parameterVariableValuesDeoptimized = false;
|
|
8005
|
-
this.includeCallArguments = this.scope.includeCallArguments.bind(this.scope);
|
|
8006
7742
|
}
|
|
8007
7743
|
get async() {
|
|
8008
7744
|
return isFlagSet(this.flags, 256 /* Flag.async */);
|
|
@@ -8022,9 +7758,53 @@ class FunctionBase extends NodeBase {
|
|
|
8022
7758
|
set generator(value) {
|
|
8023
7759
|
this.flags = setFlag(this.flags, 4194304 /* Flag.generator */, value);
|
|
8024
7760
|
}
|
|
7761
|
+
updateParameterVariableValues(_arguments) {
|
|
7762
|
+
for (let position = 0; position < this.params.length; position++) {
|
|
7763
|
+
const parameter = this.params[position];
|
|
7764
|
+
if (!(parameter instanceof Identifier)) {
|
|
7765
|
+
continue;
|
|
7766
|
+
}
|
|
7767
|
+
const parameterVariable = parameter.variable;
|
|
7768
|
+
const argument = _arguments[position + 1] ?? UNDEFINED_EXPRESSION;
|
|
7769
|
+
parameterVariable.updateKnownValue(argument);
|
|
7770
|
+
}
|
|
7771
|
+
}
|
|
7772
|
+
deoptimizeParameterVariableValues() {
|
|
7773
|
+
for (const parameter of this.params) {
|
|
7774
|
+
if (parameter instanceof Identifier) {
|
|
7775
|
+
const parameterVariable = parameter.variable;
|
|
7776
|
+
parameterVariable.markReassigned();
|
|
7777
|
+
}
|
|
7778
|
+
}
|
|
7779
|
+
}
|
|
8025
7780
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8026
|
-
if (interaction.type === INTERACTION_CALLED
|
|
8027
|
-
this.scope
|
|
7781
|
+
if (interaction.type === INTERACTION_CALLED) {
|
|
7782
|
+
const { parameters } = this.scope;
|
|
7783
|
+
const { args } = interaction;
|
|
7784
|
+
let hasRest = false;
|
|
7785
|
+
for (let position = 0; position < args.length - 1; position++) {
|
|
7786
|
+
const parameter = this.params[position];
|
|
7787
|
+
// Only the "this" argument arg[0] can be null
|
|
7788
|
+
const argument = args[position + 1];
|
|
7789
|
+
if (argument instanceof SpreadElement) {
|
|
7790
|
+
this.deoptimizeParameterVariableValues();
|
|
7791
|
+
}
|
|
7792
|
+
if (hasRest || parameter instanceof RestElement) {
|
|
7793
|
+
hasRest = true;
|
|
7794
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7795
|
+
}
|
|
7796
|
+
else if (parameter instanceof Identifier) {
|
|
7797
|
+
parameters[position][0].addEntityToBeDeoptimized(argument);
|
|
7798
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
7799
|
+
}
|
|
7800
|
+
else if (parameter) {
|
|
7801
|
+
argument.deoptimizePath(UNKNOWN_PATH);
|
|
7802
|
+
}
|
|
7803
|
+
else {
|
|
7804
|
+
this.addArgumentToBeDeoptimized(argument);
|
|
7805
|
+
}
|
|
7806
|
+
}
|
|
7807
|
+
this.updateParameterVariableValues(args);
|
|
8028
7808
|
}
|
|
8029
7809
|
else {
|
|
8030
7810
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -8036,7 +7816,12 @@ class FunctionBase extends NodeBase {
|
|
|
8036
7816
|
// A reassignment of UNKNOWN_PATH is considered equivalent to having lost track
|
|
8037
7817
|
// which means the return expression and parameters need to be reassigned
|
|
8038
7818
|
this.scope.getReturnExpression().deoptimizePath(UNKNOWN_PATH);
|
|
8039
|
-
this.scope.
|
|
7819
|
+
for (const parameterList of this.scope.parameters) {
|
|
7820
|
+
for (const parameter of parameterList) {
|
|
7821
|
+
parameter.deoptimizePath(UNKNOWN_PATH);
|
|
7822
|
+
parameter.markReassigned();
|
|
7823
|
+
}
|
|
7824
|
+
}
|
|
8040
7825
|
}
|
|
8041
7826
|
}
|
|
8042
7827
|
getLiteralValueAtPath(path, recursionTracker, origin) {
|
|
@@ -8074,13 +7859,8 @@ class FunctionBase extends NodeBase {
|
|
|
8074
7859
|
return true;
|
|
8075
7860
|
}
|
|
8076
7861
|
}
|
|
8077
|
-
const
|
|
8078
|
-
.
|
|
8079
|
-
for (let index = 0; index < this.params.length; index++) {
|
|
8080
|
-
const parameter = this.params[index];
|
|
8081
|
-
if (parameter.hasEffects(context) ||
|
|
8082
|
-
(propertyReadSideEffects &&
|
|
8083
|
-
parameter.hasEffectsWhenDestructuring(context, EMPTY_PATH, interaction.args[index + 1] || UNDEFINED_EXPRESSION)))
|
|
7862
|
+
for (const parameter of this.params) {
|
|
7863
|
+
if (parameter.hasEffects(context))
|
|
8084
7864
|
return true;
|
|
8085
7865
|
}
|
|
8086
7866
|
return false;
|
|
@@ -8099,17 +7879,21 @@ class FunctionBase extends NodeBase {
|
|
|
8099
7879
|
return variable?.getOnlyFunctionCallUsed() ?? false;
|
|
8100
7880
|
}
|
|
8101
7881
|
include(context, includeChildrenRecursively) {
|
|
8102
|
-
if (!this.
|
|
8103
|
-
this.includeNode(context);
|
|
8104
|
-
if (!(this.parameterVariableValuesDeoptimized || this.onlyFunctionCallUsed())) {
|
|
7882
|
+
if (!this.parameterVariableValuesDeoptimized && !this.onlyFunctionCallUsed()) {
|
|
8105
7883
|
this.parameterVariableValuesDeoptimized = true;
|
|
8106
|
-
this.
|
|
7884
|
+
this.deoptimizeParameterVariableValues();
|
|
8107
7885
|
}
|
|
7886
|
+
if (!this.deoptimized)
|
|
7887
|
+
this.applyDeoptimizations();
|
|
7888
|
+
this.included = true;
|
|
8108
7889
|
const { brokenFlow } = context;
|
|
8109
7890
|
context.brokenFlow = false;
|
|
8110
7891
|
this.body.include(context, includeChildrenRecursively);
|
|
8111
7892
|
context.brokenFlow = brokenFlow;
|
|
8112
7893
|
}
|
|
7894
|
+
includeCallArguments(context, parameters) {
|
|
7895
|
+
this.scope.includeCallArguments(context, parameters);
|
|
7896
|
+
}
|
|
8113
7897
|
initialise() {
|
|
8114
7898
|
super.initialise();
|
|
8115
7899
|
if (this.body instanceof BlockStatement) {
|
|
@@ -8131,14 +7915,14 @@ class FunctionBase extends NodeBase {
|
|
|
8131
7915
|
// so that the scope already knows all parameters and can detect conflicts
|
|
8132
7916
|
// when parsing the body.
|
|
8133
7917
|
const parameters = (this.params = params.map((parameter) => new (context.getNodeConstructor(parameter.type))(this, scope).parseNode(parameter)));
|
|
8134
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
7918
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
8135
7919
|
this.body = new (context.getNodeConstructor(body.type))(this, bodyScope).parseNode(body);
|
|
8136
7920
|
return super.parseNode(esTreeNode);
|
|
8137
7921
|
}
|
|
7922
|
+
addArgumentToBeDeoptimized(_argument) { }
|
|
7923
|
+
applyDeoptimizations() { }
|
|
8138
7924
|
}
|
|
8139
7925
|
FunctionBase.prototype.preventChildBlockScope = true;
|
|
8140
|
-
FunctionBase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
8141
|
-
FunctionBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
8142
7926
|
|
|
8143
7927
|
class FunctionNode extends FunctionBase {
|
|
8144
7928
|
constructor() {
|
|
@@ -8150,16 +7934,18 @@ class FunctionNode extends FunctionBase {
|
|
|
8150
7934
|
this.constructedEntity = new ObjectEntity(Object.create(null), OBJECT_PROTOTYPE);
|
|
8151
7935
|
// This makes sure that all deoptimizations of "this" are applied to the
|
|
8152
7936
|
// constructed entity.
|
|
8153
|
-
this.scope.thisVariable.
|
|
7937
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(this.constructedEntity);
|
|
8154
7938
|
}
|
|
8155
7939
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
8156
7940
|
super.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
8157
7941
|
if (interaction.type === INTERACTION_CALLED && path.length === 0 && interaction.args[0]) {
|
|
8158
7942
|
// args[0] is the "this" argument
|
|
8159
|
-
this.scope.thisVariable.
|
|
7943
|
+
this.scope.thisVariable.addEntityToBeDeoptimized(interaction.args[0]);
|
|
8160
7944
|
}
|
|
8161
7945
|
}
|
|
8162
7946
|
hasEffects(context) {
|
|
7947
|
+
if (!this.deoptimized)
|
|
7948
|
+
this.applyDeoptimizations();
|
|
8163
7949
|
if (this.annotationNoSideEffects) {
|
|
8164
7950
|
return false;
|
|
8165
7951
|
}
|
|
@@ -8197,7 +7983,7 @@ class FunctionNode extends FunctionBase {
|
|
|
8197
7983
|
}
|
|
8198
7984
|
include(context, includeChildrenRecursively) {
|
|
8199
7985
|
super.include(context, includeChildrenRecursively);
|
|
8200
|
-
this.id?.include(
|
|
7986
|
+
this.id?.include();
|
|
8201
7987
|
const hasArguments = this.scope.argumentsVariable.included;
|
|
8202
7988
|
for (const parameter of this.params) {
|
|
8203
7989
|
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
@@ -8205,18 +7991,12 @@ class FunctionNode extends FunctionBase {
|
|
|
8205
7991
|
}
|
|
8206
7992
|
}
|
|
8207
7993
|
}
|
|
8208
|
-
includeNode(context) {
|
|
8209
|
-
this.included = true;
|
|
8210
|
-
const hasArguments = this.scope.argumentsVariable.included;
|
|
8211
|
-
for (const parameter of this.params) {
|
|
8212
|
-
if (!(parameter instanceof Identifier) || hasArguments) {
|
|
8213
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
8214
|
-
}
|
|
8215
|
-
}
|
|
8216
|
-
}
|
|
8217
7994
|
initialise() {
|
|
8218
7995
|
super.initialise();
|
|
8219
|
-
this.id?.declare('function',
|
|
7996
|
+
this.id?.declare('function', this);
|
|
7997
|
+
}
|
|
7998
|
+
addArgumentToBeDeoptimized(argument) {
|
|
7999
|
+
this.scope.argumentsVariable.addArgumentToBeDeoptimized(argument);
|
|
8220
8000
|
}
|
|
8221
8001
|
getObjectEntity() {
|
|
8222
8002
|
if (this.objectEntity !== null) {
|
|
@@ -8266,16 +8046,11 @@ function getFunctionIdInsertPosition(code, start) {
|
|
|
8266
8046
|
}
|
|
8267
8047
|
class ExportDefaultDeclaration extends NodeBase {
|
|
8268
8048
|
include(context, includeChildrenRecursively) {
|
|
8269
|
-
|
|
8270
|
-
this.declaration.include(context, includeChildrenRecursively);
|
|
8049
|
+
super.include(context, includeChildrenRecursively);
|
|
8271
8050
|
if (includeChildrenRecursively) {
|
|
8272
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
8051
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
8273
8052
|
}
|
|
8274
8053
|
}
|
|
8275
|
-
includePath(path, context) {
|
|
8276
|
-
this.included = true;
|
|
8277
|
-
this.declaration.includePath(path, context);
|
|
8278
|
-
}
|
|
8279
8054
|
initialise() {
|
|
8280
8055
|
super.initialise();
|
|
8281
8056
|
const declaration = this.declaration;
|
|
@@ -8320,6 +8095,7 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
8320
8095
|
}
|
|
8321
8096
|
this.declaration.render(code, options);
|
|
8322
8097
|
}
|
|
8098
|
+
applyDeoptimizations() { }
|
|
8323
8099
|
renderNamedDeclaration(code, declarationStart, idInsertPosition, options) {
|
|
8324
8100
|
const { exportNamesByVariable, format, snippets: { getPropertyAccess } } = options;
|
|
8325
8101
|
const name = this.variable.getName(getPropertyAccess);
|
|
@@ -8350,8 +8126,6 @@ class ExportDefaultDeclaration extends NodeBase {
|
|
|
8350
8126
|
}
|
|
8351
8127
|
}
|
|
8352
8128
|
ExportDefaultDeclaration.prototype.needsBoundaries = true;
|
|
8353
|
-
ExportDefaultDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
8354
|
-
ExportDefaultDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
8355
8129
|
|
|
8356
8130
|
const needsEscapeRegEx = /[\n\r'\\\u2028\u2029]/;
|
|
8357
8131
|
const quoteNewlineRegEx = /([\n\r'\u2028\u2029])/g;
|
|
@@ -8621,7 +8395,6 @@ class Literal extends NodeBase {
|
|
|
8621
8395
|
}
|
|
8622
8396
|
}
|
|
8623
8397
|
}
|
|
8624
|
-
Literal.prototype.includeNode = onlyIncludeSelf;
|
|
8625
8398
|
|
|
8626
8399
|
function getChainElementLiteralValueAtPath(element, object, path, recursionTracker, origin) {
|
|
8627
8400
|
if ('getLiteralValueAtPathAsChainElement' in object) {
|
|
@@ -8637,6 +8410,8 @@ function getChainElementLiteralValueAtPath(element, object, path, recursionTrack
|
|
|
8637
8410
|
return element.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
8638
8411
|
}
|
|
8639
8412
|
|
|
8413
|
+
// To avoid infinite recursions
|
|
8414
|
+
const MAX_PATH_DEPTH = 7;
|
|
8640
8415
|
function getResolvablePropertyKey(memberExpression) {
|
|
8641
8416
|
return memberExpression.computed
|
|
8642
8417
|
? getResolvableComputedPropertyKey(memberExpression.property)
|
|
@@ -8735,27 +8510,18 @@ class MemberExpression extends NodeBase {
|
|
|
8735
8510
|
}
|
|
8736
8511
|
else if (!this.isUndefined) {
|
|
8737
8512
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8738
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction,
|
|
8513
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(interaction, [this.getPropertyKey(), ...path], recursionTracker);
|
|
8739
8514
|
}
|
|
8740
8515
|
else {
|
|
8741
8516
|
deoptimizeInteraction(interaction);
|
|
8742
8517
|
}
|
|
8743
8518
|
}
|
|
8744
8519
|
}
|
|
8745
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
8746
|
-
this.deoptimizePath(EMPTY_PATH);
|
|
8747
|
-
init.deoptimizePath([...destructuredInitPath, UnknownKey]);
|
|
8748
|
-
}
|
|
8749
8520
|
deoptimizeCache() {
|
|
8750
|
-
if (this.propertyKey === this.dynamicPropertyKey)
|
|
8751
|
-
return;
|
|
8752
8521
|
const { expressionsToBeDeoptimized, object } = this;
|
|
8753
8522
|
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
8754
|
-
this.
|
|
8523
|
+
this.propertyKey = UnknownKey;
|
|
8755
8524
|
object.deoptimizePath(UNKNOWN_PATH);
|
|
8756
|
-
if (this.included) {
|
|
8757
|
-
object.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
8758
|
-
}
|
|
8759
8525
|
for (const expression of expressionsToBeDeoptimized) {
|
|
8760
8526
|
expression.deoptimizeCache();
|
|
8761
8527
|
}
|
|
@@ -8766,13 +8532,11 @@ class MemberExpression extends NodeBase {
|
|
|
8766
8532
|
if (this.variable) {
|
|
8767
8533
|
this.variable.deoptimizePath(path);
|
|
8768
8534
|
}
|
|
8769
|
-
else if (!this.isUndefined) {
|
|
8770
|
-
const
|
|
8535
|
+
else if (!this.isUndefined && path.length < MAX_PATH_DEPTH) {
|
|
8536
|
+
const propertyKey = this.getPropertyKey();
|
|
8771
8537
|
this.object.deoptimizePath([
|
|
8772
8538
|
propertyKey === UnknownKey ? UnknownNonAccessorKey : propertyKey,
|
|
8773
|
-
...
|
|
8774
|
-
? path
|
|
8775
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
8539
|
+
...path
|
|
8776
8540
|
]);
|
|
8777
8541
|
}
|
|
8778
8542
|
}
|
|
@@ -8783,11 +8547,9 @@ class MemberExpression extends NodeBase {
|
|
|
8783
8547
|
if (this.isUndefined) {
|
|
8784
8548
|
return undefined;
|
|
8785
8549
|
}
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
8790
|
-
return this.object.getLiteralValueAtPath([propertyKey, ...path], recursionTracker, origin);
|
|
8550
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
8551
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
8552
|
+
return this.object.getLiteralValueAtPath([this.getPropertyKey(), ...path], recursionTracker, origin);
|
|
8791
8553
|
}
|
|
8792
8554
|
return UnknownValue;
|
|
8793
8555
|
}
|
|
@@ -8807,11 +8569,9 @@ class MemberExpression extends NodeBase {
|
|
|
8807
8569
|
if (this.isUndefined) {
|
|
8808
8570
|
return [UNDEFINED_EXPRESSION, false];
|
|
8809
8571
|
}
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
this.expressionsToBeDeoptimized.push(origin);
|
|
8814
|
-
return this.object.getReturnExpressionWhenCalledAtPath([propertyKey, ...path], interaction, recursionTracker, origin);
|
|
8572
|
+
if (this.propertyKey !== UnknownKey && path.length < MAX_PATH_DEPTH) {
|
|
8573
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
8574
|
+
return this.object.getReturnExpressionWhenCalledAtPath([this.getPropertyKey(), ...path], interaction, recursionTracker, origin);
|
|
8815
8575
|
}
|
|
8816
8576
|
return UNKNOWN_RETURN_EXPRESSION;
|
|
8817
8577
|
}
|
|
@@ -8857,45 +8617,14 @@ class MemberExpression extends NodeBase {
|
|
|
8857
8617
|
return true;
|
|
8858
8618
|
}
|
|
8859
8619
|
if (path.length < MAX_PATH_DEPTH) {
|
|
8860
|
-
return this.object.hasEffectsOnInteractionAtPath([this.
|
|
8620
|
+
return this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey(), ...path], interaction, context);
|
|
8861
8621
|
}
|
|
8862
8622
|
return true;
|
|
8863
8623
|
}
|
|
8864
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
8865
|
-
return (destructuredInitPath.length > 0 &&
|
|
8866
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, context));
|
|
8867
|
-
}
|
|
8868
8624
|
include(context, includeChildrenRecursively) {
|
|
8869
|
-
if (!this.included)
|
|
8870
|
-
this.includeNode(context);
|
|
8871
|
-
this.object.include(context, includeChildrenRecursively);
|
|
8872
|
-
this.property.include(context, includeChildrenRecursively);
|
|
8873
|
-
}
|
|
8874
|
-
includeNode(context) {
|
|
8875
|
-
this.included = true;
|
|
8876
8625
|
if (!this.deoptimized)
|
|
8877
8626
|
this.applyDeoptimizations();
|
|
8878
|
-
|
|
8879
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
8880
|
-
}
|
|
8881
|
-
else if (!this.isUndefined) {
|
|
8882
|
-
this.object.includePath([this.propertyKey], context);
|
|
8883
|
-
}
|
|
8884
|
-
}
|
|
8885
|
-
includePath(path, context) {
|
|
8886
|
-
if (!this.included)
|
|
8887
|
-
this.includeNode(context);
|
|
8888
|
-
if (this.variable) {
|
|
8889
|
-
this.variable?.includePath(path, context);
|
|
8890
|
-
}
|
|
8891
|
-
else if (!this.isUndefined) {
|
|
8892
|
-
this.object.includePath([
|
|
8893
|
-
this.propertyKey,
|
|
8894
|
-
...(path.length < MAX_PATH_DEPTH
|
|
8895
|
-
? path
|
|
8896
|
-
: [...path.slice(0, MAX_PATH_DEPTH), UnknownKey])
|
|
8897
|
-
], context);
|
|
8898
|
-
}
|
|
8627
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8899
8628
|
}
|
|
8900
8629
|
includeAsAssignmentTarget(context, includeChildrenRecursively, deoptimizeAccess) {
|
|
8901
8630
|
if (!this.assignmentDeoptimized)
|
|
@@ -8904,34 +8633,20 @@ class MemberExpression extends NodeBase {
|
|
|
8904
8633
|
this.include(context, includeChildrenRecursively);
|
|
8905
8634
|
}
|
|
8906
8635
|
else {
|
|
8907
|
-
|
|
8908
|
-
this.includeNode(context);
|
|
8909
|
-
this.object.include(context, includeChildrenRecursively);
|
|
8910
|
-
this.property.include(context, includeChildrenRecursively);
|
|
8636
|
+
this.includeProperties(context, includeChildrenRecursively);
|
|
8911
8637
|
}
|
|
8912
8638
|
}
|
|
8913
|
-
includeCallArguments(context,
|
|
8639
|
+
includeCallArguments(context, parameters) {
|
|
8914
8640
|
if (this.variable) {
|
|
8915
|
-
this.variable.includeCallArguments(context,
|
|
8641
|
+
this.variable.includeCallArguments(context, parameters);
|
|
8916
8642
|
}
|
|
8917
8643
|
else {
|
|
8918
|
-
super.includeCallArguments(context,
|
|
8919
|
-
}
|
|
8920
|
-
}
|
|
8921
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
8922
|
-
if ((this.included ||=
|
|
8923
|
-
destructuredInitPath.length > 0 &&
|
|
8924
|
-
!context.brokenFlow &&
|
|
8925
|
-
init.hasEffectsOnInteractionAtPath(destructuredInitPath, NODE_INTERACTION_UNKNOWN_ACCESS, createHasEffectsContext()))) {
|
|
8926
|
-
init.include(context, false);
|
|
8927
|
-
return true;
|
|
8644
|
+
super.includeCallArguments(context, parameters);
|
|
8928
8645
|
}
|
|
8929
|
-
return false;
|
|
8930
8646
|
}
|
|
8931
8647
|
initialise() {
|
|
8932
8648
|
super.initialise();
|
|
8933
|
-
this.
|
|
8934
|
-
this.propertyKey = this.dynamicPropertyKey === null ? UnknownKey : this.dynamicPropertyKey;
|
|
8649
|
+
this.propertyKey = getResolvablePropertyKey(this);
|
|
8935
8650
|
this.accessInteraction = { args: [this.object], type: INTERACTION_ACCESSED };
|
|
8936
8651
|
}
|
|
8937
8652
|
render(code, options, { renderedParentType, isCalleeOfRenderedParent, renderedSurroundingElement } = parseAst_js.BLANK) {
|
|
@@ -8968,7 +8683,8 @@ class MemberExpression extends NodeBase {
|
|
|
8968
8683
|
this.bound &&
|
|
8969
8684
|
propertyReadSideEffects &&
|
|
8970
8685
|
!(this.variable || this.isUndefined)) {
|
|
8971
|
-
this.
|
|
8686
|
+
const propertyKey = this.getPropertyKey();
|
|
8687
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.accessInteraction, [propertyKey], SHARED_RECURSION_TRACKER);
|
|
8972
8688
|
this.scope.context.requestTreeshakingPass();
|
|
8973
8689
|
}
|
|
8974
8690
|
if (this.variable) {
|
|
@@ -8985,7 +8701,7 @@ class MemberExpression extends NodeBase {
|
|
|
8985
8701
|
this.bound &&
|
|
8986
8702
|
propertyReadSideEffects &&
|
|
8987
8703
|
!(this.variable || this.isUndefined)) {
|
|
8988
|
-
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.
|
|
8704
|
+
this.object.deoptimizeArgumentsOnInteractionAtPath(this.assignmentInteraction, [this.getPropertyKey()], SHARED_RECURSION_TRACKER);
|
|
8989
8705
|
this.scope.context.requestTreeshakingPass();
|
|
8990
8706
|
}
|
|
8991
8707
|
}
|
|
@@ -8994,24 +8710,24 @@ class MemberExpression extends NodeBase {
|
|
|
8994
8710
|
const variable = this.scope.findVariable(this.object.name);
|
|
8995
8711
|
if (variable.isNamespace) {
|
|
8996
8712
|
if (this.variable) {
|
|
8997
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
8713
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
8998
8714
|
}
|
|
8999
8715
|
this.scope.context.log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logIllegalImportReassignment(this.object.name, this.scope.context.module.id), this.start);
|
|
9000
8716
|
}
|
|
9001
8717
|
}
|
|
9002
8718
|
}
|
|
9003
|
-
|
|
9004
|
-
if (this.
|
|
9005
|
-
this.
|
|
8719
|
+
getPropertyKey() {
|
|
8720
|
+
if (this.propertyKey === null) {
|
|
8721
|
+
this.propertyKey = UnknownKey;
|
|
9006
8722
|
const value = this.property.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
9007
|
-
return (this.
|
|
8723
|
+
return (this.propertyKey =
|
|
9008
8724
|
value === SymbolToStringTag
|
|
9009
8725
|
? value
|
|
9010
8726
|
: typeof value === 'symbol'
|
|
9011
8727
|
? UnknownKey
|
|
9012
8728
|
: String(value));
|
|
9013
8729
|
}
|
|
9014
|
-
return this.
|
|
8730
|
+
return this.propertyKey;
|
|
9015
8731
|
}
|
|
9016
8732
|
hasAccessEffect(context) {
|
|
9017
8733
|
const { propertyReadSideEffects } = this.scope.context.options
|
|
@@ -9019,7 +8735,17 @@ class MemberExpression extends NodeBase {
|
|
|
9019
8735
|
return (!(this.variable || this.isUndefined) &&
|
|
9020
8736
|
propertyReadSideEffects &&
|
|
9021
8737
|
(propertyReadSideEffects === 'always' ||
|
|
9022
|
-
this.object.hasEffectsOnInteractionAtPath([this.
|
|
8738
|
+
this.object.hasEffectsOnInteractionAtPath([this.getPropertyKey()], this.accessInteraction, context)));
|
|
8739
|
+
}
|
|
8740
|
+
includeProperties(context, includeChildrenRecursively) {
|
|
8741
|
+
if (!this.included) {
|
|
8742
|
+
this.included = true;
|
|
8743
|
+
if (this.variable) {
|
|
8744
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
8745
|
+
}
|
|
8746
|
+
}
|
|
8747
|
+
this.object.include(context, includeChildrenRecursively);
|
|
8748
|
+
this.property.include(context, includeChildrenRecursively);
|
|
9023
8749
|
}
|
|
9024
8750
|
}
|
|
9025
8751
|
function resolveNamespaceVariables(baseVariable, path, astContext) {
|
|
@@ -9063,20 +8789,18 @@ class MetaProperty extends NodeBase {
|
|
|
9063
8789
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
9064
8790
|
}
|
|
9065
8791
|
include() {
|
|
9066
|
-
if (!this.included)
|
|
9067
|
-
this.
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
9079
|
-
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
8792
|
+
if (!this.included) {
|
|
8793
|
+
this.included = true;
|
|
8794
|
+
if (this.meta.name === IMPORT) {
|
|
8795
|
+
this.scope.context.addImportMeta(this);
|
|
8796
|
+
const parent = this.parent;
|
|
8797
|
+
const metaProperty = (this.metaProperty =
|
|
8798
|
+
parent instanceof MemberExpression && typeof parent.propertyKey === 'string'
|
|
8799
|
+
? parent.propertyKey
|
|
8800
|
+
: null);
|
|
8801
|
+
if (metaProperty?.startsWith(FILE_PREFIX)) {
|
|
8802
|
+
this.referenceId = metaProperty.slice(FILE_PREFIX.length);
|
|
8803
|
+
}
|
|
9080
8804
|
}
|
|
9081
8805
|
}
|
|
9082
8806
|
}
|
|
@@ -9183,7 +8907,7 @@ class UndefinedVariable extends Variable {
|
|
|
9183
8907
|
|
|
9184
8908
|
class ExportDefaultVariable extends LocalVariable {
|
|
9185
8909
|
constructor(name, exportDefaultDeclaration, context) {
|
|
9186
|
-
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration,
|
|
8910
|
+
super(name, exportDefaultDeclaration, exportDefaultDeclaration.declaration, context, 'other');
|
|
9187
8911
|
this.hasId = false;
|
|
9188
8912
|
this.originalId = null;
|
|
9189
8913
|
this.originalVariable = null;
|
|
@@ -9332,8 +9056,8 @@ class NamespaceVariable extends Variable {
|
|
|
9332
9056
|
return (!memberVariable ||
|
|
9333
9057
|
memberVariable.hasEffectsOnInteractionAtPath(path.slice(1), interaction, context));
|
|
9334
9058
|
}
|
|
9335
|
-
|
|
9336
|
-
super.
|
|
9059
|
+
include() {
|
|
9060
|
+
super.include();
|
|
9337
9061
|
this.context.includeAllExports();
|
|
9338
9062
|
}
|
|
9339
9063
|
prepare(accessedGlobalsByScope) {
|
|
@@ -9426,9 +9150,9 @@ class SyntheticNamedExportVariable extends Variable {
|
|
|
9426
9150
|
getName(getPropertyAccess) {
|
|
9427
9151
|
return `${this.syntheticNamespace.getName(getPropertyAccess)}${getPropertyAccess(this.name)}`;
|
|
9428
9152
|
}
|
|
9429
|
-
|
|
9430
|
-
super.
|
|
9431
|
-
this.context.includeVariableInModule(this.syntheticNamespace
|
|
9153
|
+
include() {
|
|
9154
|
+
super.include();
|
|
9155
|
+
this.context.includeVariableInModule(this.syntheticNamespace);
|
|
9432
9156
|
}
|
|
9433
9157
|
setRenderNames(baseName, name) {
|
|
9434
9158
|
super.setRenderNames(baseName, name);
|
|
@@ -12604,11 +12328,17 @@ const createFilter = function createFilter(include, exclude, options) {
|
|
|
12604
12328
|
const pathId = normalizePath(id);
|
|
12605
12329
|
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
12606
12330
|
const matcher = excludeMatchers[i];
|
|
12331
|
+
if (matcher instanceof RegExp) {
|
|
12332
|
+
matcher.lastIndex = 0;
|
|
12333
|
+
}
|
|
12607
12334
|
if (matcher.test(pathId))
|
|
12608
12335
|
return false;
|
|
12609
12336
|
}
|
|
12610
12337
|
for (let i = 0; i < includeMatchers.length; ++i) {
|
|
12611
12338
|
const matcher = includeMatchers[i];
|
|
12339
|
+
if (matcher instanceof RegExp) {
|
|
12340
|
+
matcher.lastIndex = 0;
|
|
12341
|
+
}
|
|
12612
12342
|
if (matcher.test(pathId))
|
|
12613
12343
|
return true;
|
|
12614
12344
|
}
|
|
@@ -12627,37 +12357,21 @@ class ArrayPattern extends NodeBase {
|
|
|
12627
12357
|
element?.addExportedVariables(variables, exportNamesByVariable);
|
|
12628
12358
|
}
|
|
12629
12359
|
}
|
|
12630
|
-
declare(kind
|
|
12360
|
+
declare(kind) {
|
|
12631
12361
|
const variables = [];
|
|
12632
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12633
12362
|
for (const element of this.elements) {
|
|
12634
12363
|
if (element !== null) {
|
|
12635
|
-
variables.push(...element.declare(kind,
|
|
12364
|
+
variables.push(...element.declare(kind, UNKNOWN_EXPRESSION));
|
|
12636
12365
|
}
|
|
12637
12366
|
}
|
|
12638
12367
|
return variables;
|
|
12639
12368
|
}
|
|
12640
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
12641
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12642
|
-
for (const element of this.elements) {
|
|
12643
|
-
element?.deoptimizeAssignment(includedPatternPath, init);
|
|
12644
|
-
}
|
|
12645
|
-
}
|
|
12646
12369
|
// Patterns can only be deoptimized at the empty path at the moment
|
|
12647
12370
|
deoptimizePath() {
|
|
12648
12371
|
for (const element of this.elements) {
|
|
12649
12372
|
element?.deoptimizePath(EMPTY_PATH);
|
|
12650
12373
|
}
|
|
12651
12374
|
}
|
|
12652
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
12653
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12654
|
-
for (const element of this.elements) {
|
|
12655
|
-
if (element?.hasEffectsWhenDestructuring(context, includedPatternPath, init)) {
|
|
12656
|
-
return true;
|
|
12657
|
-
}
|
|
12658
|
-
}
|
|
12659
|
-
return false;
|
|
12660
|
-
}
|
|
12661
12375
|
// Patterns are only checked at the empty path at the moment
|
|
12662
12376
|
hasEffectsOnInteractionAtPath(_path, interaction, context) {
|
|
12663
12377
|
for (const element of this.elements) {
|
|
@@ -12666,38 +12380,12 @@ class ArrayPattern extends NodeBase {
|
|
|
12666
12380
|
}
|
|
12667
12381
|
return false;
|
|
12668
12382
|
}
|
|
12669
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
12670
|
-
let included = false;
|
|
12671
|
-
const includedPatternPath = getIncludedPatternPath(destructuredInitPath);
|
|
12672
|
-
for (const element of this.elements) {
|
|
12673
|
-
if (element) {
|
|
12674
|
-
element.included ||= included;
|
|
12675
|
-
included =
|
|
12676
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init) || included;
|
|
12677
|
-
}
|
|
12678
|
-
}
|
|
12679
|
-
if (included) {
|
|
12680
|
-
// This is necessary so that if any pattern element is included, all are
|
|
12681
|
-
// included for proper deconflicting
|
|
12682
|
-
for (const element of this.elements) {
|
|
12683
|
-
if (element && !element.included) {
|
|
12684
|
-
element.included = true;
|
|
12685
|
-
element.includeDestructuredIfNecessary(context, includedPatternPath, init);
|
|
12686
|
-
}
|
|
12687
|
-
}
|
|
12688
|
-
}
|
|
12689
|
-
return (this.included ||= included);
|
|
12690
|
-
}
|
|
12691
12383
|
markDeclarationReached() {
|
|
12692
12384
|
for (const element of this.elements) {
|
|
12693
12385
|
element?.markDeclarationReached();
|
|
12694
12386
|
}
|
|
12695
12387
|
}
|
|
12696
12388
|
}
|
|
12697
|
-
ArrayPattern.prototype.includeNode = onlyIncludeSelf;
|
|
12698
|
-
const getIncludedPatternPath = (destructuredInitPath) => destructuredInitPath.at(-1) === UnknownKey
|
|
12699
|
-
? destructuredInitPath
|
|
12700
|
-
: [...destructuredInitPath, UnknownInteger];
|
|
12701
12389
|
|
|
12702
12390
|
class ArrowFunctionExpression extends FunctionBase {
|
|
12703
12391
|
constructor() {
|
|
@@ -12714,6 +12402,8 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
12714
12402
|
this.scope = new ReturnValueScope(parentScope, false);
|
|
12715
12403
|
}
|
|
12716
12404
|
hasEffects() {
|
|
12405
|
+
if (!this.deoptimized)
|
|
12406
|
+
this.applyDeoptimizations();
|
|
12717
12407
|
return false;
|
|
12718
12408
|
}
|
|
12719
12409
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
@@ -12752,15 +12442,6 @@ class ArrowFunctionExpression extends FunctionBase {
|
|
|
12752
12442
|
}
|
|
12753
12443
|
}
|
|
12754
12444
|
}
|
|
12755
|
-
includeNode(context) {
|
|
12756
|
-
this.included = true;
|
|
12757
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
12758
|
-
for (const parameter of this.params) {
|
|
12759
|
-
if (!(parameter instanceof Identifier)) {
|
|
12760
|
-
parameter.includePath(UNKNOWN_PATH, context);
|
|
12761
|
-
}
|
|
12762
|
-
}
|
|
12763
|
-
}
|
|
12764
12445
|
getObjectEntity() {
|
|
12765
12446
|
if (this.objectEntity !== null) {
|
|
12766
12447
|
return this.objectEntity;
|
|
@@ -12780,18 +12461,13 @@ class ObjectPattern extends NodeBase {
|
|
|
12780
12461
|
}
|
|
12781
12462
|
}
|
|
12782
12463
|
}
|
|
12783
|
-
declare(kind,
|
|
12464
|
+
declare(kind, init) {
|
|
12784
12465
|
const variables = [];
|
|
12785
12466
|
for (const property of this.properties) {
|
|
12786
|
-
variables.push(...property.declare(kind,
|
|
12467
|
+
variables.push(...property.declare(kind, init));
|
|
12787
12468
|
}
|
|
12788
12469
|
return variables;
|
|
12789
12470
|
}
|
|
12790
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
12791
|
-
for (const property of this.properties) {
|
|
12792
|
-
property.deoptimizeAssignment(destructuredInitPath, init);
|
|
12793
|
-
}
|
|
12794
|
-
}
|
|
12795
12471
|
deoptimizePath(path) {
|
|
12796
12472
|
if (path.length === 0) {
|
|
12797
12473
|
for (const property of this.properties) {
|
|
@@ -12809,46 +12485,12 @@ class ObjectPattern extends NodeBase {
|
|
|
12809
12485
|
}
|
|
12810
12486
|
return false;
|
|
12811
12487
|
}
|
|
12812
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
12813
|
-
for (const property of this.properties) {
|
|
12814
|
-
if (property.hasEffectsWhenDestructuring(context, destructuredInitPath, init))
|
|
12815
|
-
return true;
|
|
12816
|
-
}
|
|
12817
|
-
return false;
|
|
12818
|
-
}
|
|
12819
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
12820
|
-
let included = false;
|
|
12821
|
-
for (const property of this.properties) {
|
|
12822
|
-
included =
|
|
12823
|
-
property.includeDestructuredIfNecessary(context, destructuredInitPath, init) || included;
|
|
12824
|
-
}
|
|
12825
|
-
return (this.included ||= included);
|
|
12826
|
-
}
|
|
12827
12488
|
markDeclarationReached() {
|
|
12828
12489
|
for (const property of this.properties) {
|
|
12829
12490
|
property.markDeclarationReached();
|
|
12830
12491
|
}
|
|
12831
12492
|
}
|
|
12832
|
-
render(code, options) {
|
|
12833
|
-
if (this.properties.length > 0) {
|
|
12834
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
12835
|
-
let lastSeparatorPos = null;
|
|
12836
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
12837
|
-
if (!node.included) {
|
|
12838
|
-
treeshakeNode(node, code, start, end);
|
|
12839
|
-
continue;
|
|
12840
|
-
}
|
|
12841
|
-
lastSeparatorPos = separator;
|
|
12842
|
-
node.render(code, options);
|
|
12843
|
-
}
|
|
12844
|
-
if (lastSeparatorPos) {
|
|
12845
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
12846
|
-
}
|
|
12847
|
-
}
|
|
12848
|
-
}
|
|
12849
12493
|
}
|
|
12850
|
-
ObjectPattern.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
12851
|
-
ObjectPattern.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
12852
12494
|
|
|
12853
12495
|
class AssignmentExpression extends NodeBase {
|
|
12854
12496
|
hasEffects(context) {
|
|
@@ -12857,9 +12499,7 @@ class AssignmentExpression extends NodeBase {
|
|
|
12857
12499
|
this.applyDeoptimizations();
|
|
12858
12500
|
// MemberExpressions do not access the property before assignments if the
|
|
12859
12501
|
// operator is '='.
|
|
12860
|
-
return (right.hasEffects(context) ||
|
|
12861
|
-
left.hasEffectsAsAssignmentTarget(context, operator !== '=') ||
|
|
12862
|
-
this.left.hasEffectsWhenDestructuring?.(context, EMPTY_PATH, right));
|
|
12502
|
+
return (right.hasEffects(context) || left.hasEffectsAsAssignmentTarget(context, operator !== '='));
|
|
12863
12503
|
}
|
|
12864
12504
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
12865
12505
|
return this.right.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
@@ -12868,24 +12508,15 @@ class AssignmentExpression extends NodeBase {
|
|
|
12868
12508
|
const { deoptimized, left, right, operator } = this;
|
|
12869
12509
|
if (!deoptimized)
|
|
12870
12510
|
this.applyDeoptimizations();
|
|
12871
|
-
|
|
12872
|
-
this.includeNode(context);
|
|
12873
|
-
const hasEffectsContext = createHasEffectsContext();
|
|
12511
|
+
this.included = true;
|
|
12874
12512
|
if (includeChildrenRecursively ||
|
|
12875
12513
|
operator !== '=' ||
|
|
12876
12514
|
left.included ||
|
|
12877
|
-
left.hasEffectsAsAssignmentTarget(
|
|
12878
|
-
left.hasEffectsWhenDestructuring?.(hasEffectsContext, EMPTY_PATH, right)) {
|
|
12515
|
+
left.hasEffectsAsAssignmentTarget(createHasEffectsContext(), false)) {
|
|
12879
12516
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively, operator !== '=');
|
|
12880
12517
|
}
|
|
12881
12518
|
right.include(context, includeChildrenRecursively);
|
|
12882
12519
|
}
|
|
12883
|
-
includeNode(context) {
|
|
12884
|
-
this.included = true;
|
|
12885
|
-
if (!this.deoptimized)
|
|
12886
|
-
this.applyDeoptimizations();
|
|
12887
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12888
|
-
}
|
|
12889
12520
|
initialise() {
|
|
12890
12521
|
super.initialise();
|
|
12891
12522
|
if (this.left instanceof Identifier) {
|
|
@@ -12946,7 +12577,8 @@ class AssignmentExpression extends NodeBase {
|
|
|
12946
12577
|
}
|
|
12947
12578
|
applyDeoptimizations() {
|
|
12948
12579
|
this.deoptimized = true;
|
|
12949
|
-
this.left.
|
|
12580
|
+
this.left.deoptimizePath(EMPTY_PATH);
|
|
12581
|
+
this.right.deoptimizePath(UNKNOWN_PATH);
|
|
12950
12582
|
this.scope.context.requestTreeshakingPass();
|
|
12951
12583
|
}
|
|
12952
12584
|
}
|
|
@@ -12955,11 +12587,8 @@ class AssignmentPattern extends NodeBase {
|
|
|
12955
12587
|
addExportedVariables(variables, exportNamesByVariable) {
|
|
12956
12588
|
this.left.addExportedVariables(variables, exportNamesByVariable);
|
|
12957
12589
|
}
|
|
12958
|
-
declare(kind,
|
|
12959
|
-
return this.left.declare(kind,
|
|
12960
|
-
}
|
|
12961
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
12962
|
-
this.left.deoptimizeAssignment(destructuredInitPath, init);
|
|
12590
|
+
declare(kind, init) {
|
|
12591
|
+
return this.left.declare(kind, init);
|
|
12963
12592
|
}
|
|
12964
12593
|
deoptimizePath(path) {
|
|
12965
12594
|
if (path.length === 0) {
|
|
@@ -12969,29 +12598,6 @@ class AssignmentPattern extends NodeBase {
|
|
|
12969
12598
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
12970
12599
|
return (path.length > 0 || this.left.hasEffectsOnInteractionAtPath(EMPTY_PATH, interaction, context));
|
|
12971
12600
|
}
|
|
12972
|
-
hasEffectsWhenDestructuring(context, destructuredInitPath, init) {
|
|
12973
|
-
return this.left.hasEffectsWhenDestructuring(context, destructuredInitPath, init);
|
|
12974
|
-
}
|
|
12975
|
-
includeDestructuredIfNecessary(context, destructuredInitPath, init) {
|
|
12976
|
-
let included = this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init) ||
|
|
12977
|
-
this.included;
|
|
12978
|
-
if ((included ||= this.right.shouldBeIncluded(context))) {
|
|
12979
|
-
this.right.include(context, false);
|
|
12980
|
-
if (!this.left.included) {
|
|
12981
|
-
this.left.included = true;
|
|
12982
|
-
// Unfortunately, we need to include the left side again now, so that
|
|
12983
|
-
// any declared variables are properly included.
|
|
12984
|
-
this.left.includeDestructuredIfNecessary(context, destructuredInitPath, init);
|
|
12985
|
-
}
|
|
12986
|
-
}
|
|
12987
|
-
return (this.included = included);
|
|
12988
|
-
}
|
|
12989
|
-
includeNode(context) {
|
|
12990
|
-
this.included = true;
|
|
12991
|
-
if (!this.deoptimized)
|
|
12992
|
-
this.applyDeoptimizations();
|
|
12993
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
12994
|
-
}
|
|
12995
12601
|
markDeclarationReached() {
|
|
12996
12602
|
this.left.markDeclarationReached();
|
|
12997
12603
|
}
|
|
@@ -13008,40 +12614,28 @@ class AssignmentPattern extends NodeBase {
|
|
|
13008
12614
|
}
|
|
13009
12615
|
|
|
13010
12616
|
class AwaitExpression extends NodeBase {
|
|
13011
|
-
hasEffects() {
|
|
13012
|
-
if (!this.deoptimized)
|
|
13013
|
-
this.applyDeoptimizations();
|
|
13014
|
-
return true;
|
|
13015
|
-
}
|
|
13016
|
-
include(context, includeChildrenRecursively) {
|
|
13017
|
-
if (!this.included)
|
|
13018
|
-
this.includeNode(context);
|
|
13019
|
-
this.argument.include(context, includeChildrenRecursively);
|
|
13020
|
-
}
|
|
13021
|
-
includeNode(context) {
|
|
13022
|
-
this.included = true;
|
|
12617
|
+
hasEffects() {
|
|
13023
12618
|
if (!this.deoptimized)
|
|
13024
12619
|
this.applyDeoptimizations();
|
|
13025
|
-
|
|
13026
|
-
let parent = this.parent;
|
|
13027
|
-
do {
|
|
13028
|
-
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
13029
|
-
break checkTopLevelAwait;
|
|
13030
|
-
} while ((parent = parent.parent));
|
|
13031
|
-
this.scope.context.usesTopLevelAwait = true;
|
|
13032
|
-
}
|
|
13033
|
-
// Thenables need to be included
|
|
13034
|
-
this.argument.includePath(THEN_PATH, context);
|
|
12620
|
+
return true;
|
|
13035
12621
|
}
|
|
13036
|
-
|
|
12622
|
+
include(context, includeChildrenRecursively) {
|
|
13037
12623
|
if (!this.deoptimized)
|
|
13038
12624
|
this.applyDeoptimizations();
|
|
13039
|
-
if (!this.included)
|
|
13040
|
-
this.
|
|
13041
|
-
|
|
12625
|
+
if (!this.included) {
|
|
12626
|
+
this.included = true;
|
|
12627
|
+
checkTopLevelAwait: if (!this.scope.context.usesTopLevelAwait) {
|
|
12628
|
+
let parent = this.parent;
|
|
12629
|
+
do {
|
|
12630
|
+
if (parent instanceof FunctionNode || parent instanceof ArrowFunctionExpression)
|
|
12631
|
+
break checkTopLevelAwait;
|
|
12632
|
+
} while ((parent = parent.parent));
|
|
12633
|
+
this.scope.context.usesTopLevelAwait = true;
|
|
12634
|
+
}
|
|
12635
|
+
}
|
|
12636
|
+
this.argument.include(context, includeChildrenRecursively);
|
|
13042
12637
|
}
|
|
13043
12638
|
}
|
|
13044
|
-
const THEN_PATH = ['then'];
|
|
13045
12639
|
|
|
13046
12640
|
const binaryOperators = {
|
|
13047
12641
|
'!=': (left, right) => left != right,
|
|
@@ -13097,12 +12691,6 @@ class BinaryExpression extends NodeBase {
|
|
|
13097
12691
|
hasEffectsOnInteractionAtPath(path, { type }) {
|
|
13098
12692
|
return type !== INTERACTION_ACCESSED || path.length > 1;
|
|
13099
12693
|
}
|
|
13100
|
-
includeNode(context) {
|
|
13101
|
-
this.included = true;
|
|
13102
|
-
if (this.operator === 'in') {
|
|
13103
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
13104
|
-
}
|
|
13105
|
-
}
|
|
13106
12694
|
removeAnnotations(code) {
|
|
13107
12695
|
this.left.removeAnnotations(code);
|
|
13108
12696
|
}
|
|
@@ -13111,7 +12699,6 @@ class BinaryExpression extends NodeBase {
|
|
|
13111
12699
|
this.right.render(code, options);
|
|
13112
12700
|
}
|
|
13113
12701
|
}
|
|
13114
|
-
BinaryExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13115
12702
|
|
|
13116
12703
|
class BreakStatement extends NodeBase {
|
|
13117
12704
|
hasEffects(context) {
|
|
@@ -13131,7 +12718,7 @@ class BreakStatement extends NodeBase {
|
|
|
13131
12718
|
include(context) {
|
|
13132
12719
|
this.included = true;
|
|
13133
12720
|
if (this.label) {
|
|
13134
|
-
this.label.include(
|
|
12721
|
+
this.label.include();
|
|
13135
12722
|
context.includedLabels.add(this.label.name);
|
|
13136
12723
|
}
|
|
13137
12724
|
else {
|
|
@@ -13140,8 +12727,6 @@ class BreakStatement extends NodeBase {
|
|
|
13140
12727
|
context.brokenFlow = true;
|
|
13141
12728
|
}
|
|
13142
12729
|
}
|
|
13143
|
-
BreakStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13144
|
-
BreakStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13145
12730
|
|
|
13146
12731
|
function renderCallArguments(code, options, node) {
|
|
13147
12732
|
if (node.arguments.length > 0) {
|
|
@@ -13328,14 +12913,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
13328
12913
|
this.callee.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context)));
|
|
13329
12914
|
}
|
|
13330
12915
|
include(context, includeChildrenRecursively) {
|
|
13331
|
-
if (!this.
|
|
13332
|
-
this.
|
|
12916
|
+
if (!this.deoptimized)
|
|
12917
|
+
this.applyDeoptimizations();
|
|
13333
12918
|
if (includeChildrenRecursively) {
|
|
13334
|
-
|
|
13335
|
-
for (const argument of this.arguments) {
|
|
13336
|
-
argument.includePath(UNKNOWN_PATH, context);
|
|
13337
|
-
argument.include(context, true);
|
|
13338
|
-
}
|
|
12919
|
+
super.include(context, includeChildrenRecursively);
|
|
13339
12920
|
if (includeChildrenRecursively === INCLUDE_PARAMETERS &&
|
|
13340
12921
|
this.callee instanceof Identifier &&
|
|
13341
12922
|
this.callee.variable) {
|
|
@@ -13343,24 +12924,10 @@ class CallExpression extends CallExpressionBase {
|
|
|
13343
12924
|
}
|
|
13344
12925
|
}
|
|
13345
12926
|
else {
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
// interaction in includeCallArguments. Including it again can lead to
|
|
13349
|
-
// severe performance problems.
|
|
13350
|
-
if (this.callee instanceof MemberExpression && !this.callee.variable) {
|
|
13351
|
-
this.callee.property.include(context, false);
|
|
13352
|
-
}
|
|
13353
|
-
else {
|
|
13354
|
-
this.callee.include(context, false);
|
|
13355
|
-
}
|
|
13356
|
-
this.callee.includeCallArguments(context, this.interaction);
|
|
12927
|
+
this.included = true;
|
|
12928
|
+
this.callee.include(context, false);
|
|
13357
12929
|
}
|
|
13358
|
-
|
|
13359
|
-
includeNode(context) {
|
|
13360
|
-
this.included = true;
|
|
13361
|
-
if (!this.deoptimized)
|
|
13362
|
-
this.applyDeoptimizations();
|
|
13363
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
12930
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
13364
12931
|
}
|
|
13365
12932
|
initialise() {
|
|
13366
12933
|
super.initialise();
|
|
@@ -13399,14 +12966,13 @@ class CatchClause extends NodeBase {
|
|
|
13399
12966
|
this.type = type;
|
|
13400
12967
|
if (param) {
|
|
13401
12968
|
this.param = new (this.scope.context.getNodeConstructor(param.type))(this, this.scope).parseNode(param);
|
|
13402
|
-
this.param.declare('parameter',
|
|
12969
|
+
this.param.declare('parameter', UNKNOWN_EXPRESSION);
|
|
13403
12970
|
}
|
|
13404
12971
|
this.body = new BlockStatement(this, this.scope.bodyScope).parseNode(body);
|
|
13405
12972
|
return super.parseNode(esTreeNode);
|
|
13406
12973
|
}
|
|
13407
12974
|
}
|
|
13408
12975
|
CatchClause.prototype.preventChildBlockScope = true;
|
|
13409
|
-
CatchClause.prototype.includeNode = onlyIncludeSelf;
|
|
13410
12976
|
|
|
13411
12977
|
class ChainExpression extends NodeBase {
|
|
13412
12978
|
// deoptimizations are not relevant as we are not caching values
|
|
@@ -13418,22 +12984,17 @@ class ChainExpression extends NodeBase {
|
|
|
13418
12984
|
hasEffects(context) {
|
|
13419
12985
|
return this.expression.hasEffectsAsChainElement(context) === true;
|
|
13420
12986
|
}
|
|
13421
|
-
includePath(path, context) {
|
|
13422
|
-
this.included = true;
|
|
13423
|
-
this.expression.includePath(path, context);
|
|
13424
|
-
}
|
|
13425
12987
|
removeAnnotations(code) {
|
|
13426
12988
|
this.expression.removeAnnotations(code);
|
|
13427
12989
|
}
|
|
12990
|
+
applyDeoptimizations() { }
|
|
13428
12991
|
}
|
|
13429
|
-
ChainExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13430
|
-
ChainExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13431
12992
|
|
|
13432
12993
|
class ClassBodyScope extends ChildScope {
|
|
13433
12994
|
constructor(parent, classNode) {
|
|
13434
12995
|
const { context } = parent;
|
|
13435
12996
|
super(parent, context);
|
|
13436
|
-
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode,
|
|
12997
|
+
this.variables.set('this', (this.thisVariable = new LocalVariable('this', null, classNode, context, 'other')));
|
|
13437
12998
|
this.instanceScope = new ChildScope(this, context);
|
|
13438
12999
|
this.instanceScope.variables.set('this', new ThisVariable(context));
|
|
13439
13000
|
}
|
|
@@ -13448,7 +13009,7 @@ class ClassBody extends NodeBase {
|
|
|
13448
13009
|
}
|
|
13449
13010
|
include(context, includeChildrenRecursively) {
|
|
13450
13011
|
this.included = true;
|
|
13451
|
-
this.scope.context.includeVariableInModule(this.scope.thisVariable
|
|
13012
|
+
this.scope.context.includeVariableInModule(this.scope.thisVariable);
|
|
13452
13013
|
for (const definition of this.body) {
|
|
13453
13014
|
definition.include(context, includeChildrenRecursively);
|
|
13454
13015
|
}
|
|
@@ -13461,9 +13022,8 @@ class ClassBody extends NodeBase {
|
|
|
13461
13022
|
}
|
|
13462
13023
|
return super.parseNode(esTreeNode);
|
|
13463
13024
|
}
|
|
13025
|
+
applyDeoptimizations() { }
|
|
13464
13026
|
}
|
|
13465
|
-
ClassBody.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13466
|
-
ClassBody.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13467
13027
|
|
|
13468
13028
|
class ClassExpression extends ClassNode {
|
|
13469
13029
|
render(code, options, { renderedSurroundingElement } = parseAst_js.BLANK) {
|
|
@@ -13475,6 +13035,19 @@ class ClassExpression extends ClassNode {
|
|
|
13475
13035
|
}
|
|
13476
13036
|
}
|
|
13477
13037
|
|
|
13038
|
+
function tryCastLiteralValueToBoolean(literalValue) {
|
|
13039
|
+
if (typeof literalValue === 'symbol') {
|
|
13040
|
+
if (literalValue === UnknownFalsyValue) {
|
|
13041
|
+
return false;
|
|
13042
|
+
}
|
|
13043
|
+
if (literalValue === UnknownTruthyValue) {
|
|
13044
|
+
return true;
|
|
13045
|
+
}
|
|
13046
|
+
return UnknownValue;
|
|
13047
|
+
}
|
|
13048
|
+
return !!literalValue;
|
|
13049
|
+
}
|
|
13050
|
+
|
|
13478
13051
|
class MultiExpression extends ExpressionEntity {
|
|
13479
13052
|
constructor(expressions) {
|
|
13480
13053
|
super();
|
|
@@ -13521,9 +13094,6 @@ class ConditionalExpression extends NodeBase {
|
|
|
13521
13094
|
const unusedBranch = this.usedBranch === this.consequent ? this.alternate : this.consequent;
|
|
13522
13095
|
this.usedBranch = null;
|
|
13523
13096
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
13524
|
-
if (this.included) {
|
|
13525
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
13526
|
-
}
|
|
13527
13097
|
const { expressionsToBeDeoptimized } = this;
|
|
13528
13098
|
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
13529
13099
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -13581,7 +13151,7 @@ class ConditionalExpression extends NodeBase {
|
|
|
13581
13151
|
include(context, includeChildrenRecursively) {
|
|
13582
13152
|
this.included = true;
|
|
13583
13153
|
const usedBranch = this.getUsedBranch();
|
|
13584
|
-
if (
|
|
13154
|
+
if (includeChildrenRecursively || this.test.shouldBeIncluded(context) || usedBranch === null) {
|
|
13585
13155
|
this.test.include(context, includeChildrenRecursively);
|
|
13586
13156
|
this.consequent.include(context, includeChildrenRecursively);
|
|
13587
13157
|
this.alternate.include(context, includeChildrenRecursively);
|
|
@@ -13590,38 +13160,27 @@ class ConditionalExpression extends NodeBase {
|
|
|
13590
13160
|
usedBranch.include(context, includeChildrenRecursively);
|
|
13591
13161
|
}
|
|
13592
13162
|
}
|
|
13593
|
-
|
|
13594
|
-
this.included = true;
|
|
13595
|
-
const usedBranch = this.getUsedBranch();
|
|
13596
|
-
if (usedBranch === null || this.test.shouldBeIncluded(context)) {
|
|
13597
|
-
this.consequent.includePath(path, context);
|
|
13598
|
-
this.alternate.includePath(path, context);
|
|
13599
|
-
}
|
|
13600
|
-
else {
|
|
13601
|
-
usedBranch.includePath(path, context);
|
|
13602
|
-
}
|
|
13603
|
-
}
|
|
13604
|
-
includeCallArguments(context, interaction) {
|
|
13163
|
+
includeCallArguments(context, parameters) {
|
|
13605
13164
|
const usedBranch = this.getUsedBranch();
|
|
13606
13165
|
if (usedBranch) {
|
|
13607
|
-
usedBranch.includeCallArguments(context,
|
|
13166
|
+
usedBranch.includeCallArguments(context, parameters);
|
|
13608
13167
|
}
|
|
13609
13168
|
else {
|
|
13610
|
-
this.consequent.includeCallArguments(context,
|
|
13611
|
-
this.alternate.includeCallArguments(context,
|
|
13169
|
+
this.consequent.includeCallArguments(context, parameters);
|
|
13170
|
+
this.alternate.includeCallArguments(context, parameters);
|
|
13612
13171
|
}
|
|
13613
13172
|
}
|
|
13614
13173
|
removeAnnotations(code) {
|
|
13615
13174
|
this.test.removeAnnotations(code);
|
|
13616
13175
|
}
|
|
13617
13176
|
render(code, options, { isCalleeOfRenderedParent, preventASI, renderedParentType, renderedSurroundingElement } = parseAst_js.BLANK) {
|
|
13177
|
+
const usedBranch = this.getUsedBranch();
|
|
13618
13178
|
if (this.test.included) {
|
|
13619
13179
|
this.test.render(code, options, { renderedSurroundingElement });
|
|
13620
13180
|
this.consequent.render(code, options);
|
|
13621
13181
|
this.alternate.render(code, options);
|
|
13622
13182
|
}
|
|
13623
13183
|
else {
|
|
13624
|
-
const usedBranch = this.getUsedBranch();
|
|
13625
13184
|
const colonPos = findFirstOccurrenceOutsideComment(code.original, ':', this.consequent.end);
|
|
13626
13185
|
const inclusionStart = findNonWhiteSpace(code.original, (this.consequent.included
|
|
13627
13186
|
? findFirstOccurrenceOutsideComment(code.original, '?', this.test.end)
|
|
@@ -13647,14 +13206,12 @@ class ConditionalExpression extends NodeBase {
|
|
|
13647
13206
|
return this.usedBranch;
|
|
13648
13207
|
}
|
|
13649
13208
|
this.isBranchResolutionAnalysed = true;
|
|
13650
|
-
const testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
13209
|
+
const testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
13651
13210
|
return typeof testValue === 'symbol'
|
|
13652
13211
|
? null
|
|
13653
13212
|
: (this.usedBranch = testValue ? this.consequent : this.alternate);
|
|
13654
13213
|
}
|
|
13655
13214
|
}
|
|
13656
|
-
ConditionalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13657
|
-
ConditionalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13658
13215
|
|
|
13659
13216
|
class ContinueStatement extends NodeBase {
|
|
13660
13217
|
hasEffects(context) {
|
|
@@ -13674,7 +13231,7 @@ class ContinueStatement extends NodeBase {
|
|
|
13674
13231
|
include(context) {
|
|
13675
13232
|
this.included = true;
|
|
13676
13233
|
if (this.label) {
|
|
13677
|
-
this.label.include(
|
|
13234
|
+
this.label.include();
|
|
13678
13235
|
context.includedLabels.add(this.label.name);
|
|
13679
13236
|
}
|
|
13680
13237
|
else {
|
|
@@ -13683,15 +13240,12 @@ class ContinueStatement extends NodeBase {
|
|
|
13683
13240
|
context.brokenFlow = true;
|
|
13684
13241
|
}
|
|
13685
13242
|
}
|
|
13686
|
-
ContinueStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13687
|
-
ContinueStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13688
13243
|
|
|
13689
13244
|
class DebuggerStatement extends NodeBase {
|
|
13690
13245
|
hasEffects() {
|
|
13691
13246
|
return true;
|
|
13692
13247
|
}
|
|
13693
13248
|
}
|
|
13694
|
-
DebuggerStatement.prototype.includeNode = onlyIncludeSelf;
|
|
13695
13249
|
|
|
13696
13250
|
class Decorator extends NodeBase {
|
|
13697
13251
|
hasEffects(context) {
|
|
@@ -13699,7 +13253,6 @@ class Decorator extends NodeBase {
|
|
|
13699
13253
|
this.expression.hasEffectsOnInteractionAtPath(EMPTY_PATH, NODE_INTERACTION_UNKNOWN_CALL, context));
|
|
13700
13254
|
}
|
|
13701
13255
|
}
|
|
13702
|
-
Decorator.prototype.includeNode = onlyIncludeSelf;
|
|
13703
13256
|
|
|
13704
13257
|
function hasLoopBodyEffects(context, body) {
|
|
13705
13258
|
const { brokenFlow, hasBreak, hasContinue, ignore } = context;
|
|
@@ -13739,15 +13292,12 @@ class DoWhileStatement extends NodeBase {
|
|
|
13739
13292
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
13740
13293
|
}
|
|
13741
13294
|
}
|
|
13742
|
-
DoWhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13743
|
-
DoWhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13744
13295
|
|
|
13745
13296
|
class EmptyStatement extends NodeBase {
|
|
13746
13297
|
hasEffects() {
|
|
13747
13298
|
return false;
|
|
13748
13299
|
}
|
|
13749
13300
|
}
|
|
13750
|
-
EmptyStatement.prototype.includeNode = onlyIncludeSelf;
|
|
13751
13301
|
|
|
13752
13302
|
class ExportAllDeclaration extends NodeBase {
|
|
13753
13303
|
hasEffects() {
|
|
@@ -13760,10 +13310,9 @@ class ExportAllDeclaration extends NodeBase {
|
|
|
13760
13310
|
render(code, _options, nodeRenderOptions) {
|
|
13761
13311
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
13762
13312
|
}
|
|
13313
|
+
applyDeoptimizations() { }
|
|
13763
13314
|
}
|
|
13764
13315
|
ExportAllDeclaration.prototype.needsBoundaries = true;
|
|
13765
|
-
ExportAllDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13766
|
-
ExportAllDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13767
13316
|
|
|
13768
13317
|
class ExportNamedDeclaration extends NodeBase {
|
|
13769
13318
|
bind() {
|
|
@@ -13790,15 +13339,13 @@ class ExportNamedDeclaration extends NodeBase {
|
|
|
13790
13339
|
this.declaration.render(code, options, { end, start });
|
|
13791
13340
|
}
|
|
13792
13341
|
}
|
|
13342
|
+
applyDeoptimizations() { }
|
|
13793
13343
|
}
|
|
13794
13344
|
ExportNamedDeclaration.prototype.needsBoundaries = true;
|
|
13795
|
-
ExportNamedDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13796
|
-
ExportNamedDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13797
13345
|
|
|
13798
13346
|
class ExportSpecifier extends NodeBase {
|
|
13347
|
+
applyDeoptimizations() { }
|
|
13799
13348
|
}
|
|
13800
|
-
ExportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13801
|
-
ExportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13802
13349
|
|
|
13803
13350
|
class ForInStatement extends NodeBase {
|
|
13804
13351
|
createScope(parentScope) {
|
|
@@ -13816,18 +13363,11 @@ class ForInStatement extends NodeBase {
|
|
|
13816
13363
|
const { body, deoptimized, left, right } = this;
|
|
13817
13364
|
if (!deoptimized)
|
|
13818
13365
|
this.applyDeoptimizations();
|
|
13819
|
-
|
|
13820
|
-
this.includeNode(context);
|
|
13366
|
+
this.included = true;
|
|
13821
13367
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
13822
13368
|
right.include(context, includeChildrenRecursively);
|
|
13823
13369
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
13824
13370
|
}
|
|
13825
|
-
includeNode(context) {
|
|
13826
|
-
this.included = true;
|
|
13827
|
-
if (!this.deoptimized)
|
|
13828
|
-
this.applyDeoptimizations();
|
|
13829
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
13830
|
-
}
|
|
13831
13371
|
initialise() {
|
|
13832
13372
|
super.initialise();
|
|
13833
13373
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -13868,18 +13408,11 @@ class ForOfStatement extends NodeBase {
|
|
|
13868
13408
|
const { body, deoptimized, left, right } = this;
|
|
13869
13409
|
if (!deoptimized)
|
|
13870
13410
|
this.applyDeoptimizations();
|
|
13871
|
-
|
|
13872
|
-
this.includeNode(context);
|
|
13411
|
+
this.included = true;
|
|
13873
13412
|
left.includeAsAssignmentTarget(context, includeChildrenRecursively || true, false);
|
|
13874
13413
|
right.include(context, includeChildrenRecursively);
|
|
13875
13414
|
includeLoopBody(context, body, includeChildrenRecursively);
|
|
13876
13415
|
}
|
|
13877
|
-
includeNode(context) {
|
|
13878
|
-
this.included = true;
|
|
13879
|
-
if (!this.deoptimized)
|
|
13880
|
-
this.applyDeoptimizations();
|
|
13881
|
-
this.right.includePath(UNKNOWN_PATH, context);
|
|
13882
|
-
}
|
|
13883
13416
|
initialise() {
|
|
13884
13417
|
super.initialise();
|
|
13885
13418
|
this.left.setAssignedValue(UNKNOWN_EXPRESSION);
|
|
@@ -13915,9 +13448,7 @@ class ForStatement extends NodeBase {
|
|
|
13915
13448
|
}
|
|
13916
13449
|
include(context, includeChildrenRecursively) {
|
|
13917
13450
|
this.included = true;
|
|
13918
|
-
this.init?.include(context, includeChildrenRecursively, {
|
|
13919
|
-
asSingleStatement: true
|
|
13920
|
-
});
|
|
13451
|
+
this.init?.include(context, includeChildrenRecursively, { asSingleStatement: true });
|
|
13921
13452
|
this.test?.include(context, includeChildrenRecursively);
|
|
13922
13453
|
this.update?.include(context, includeChildrenRecursively);
|
|
13923
13454
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
@@ -13929,8 +13460,6 @@ class ForStatement extends NodeBase {
|
|
|
13929
13460
|
this.body.render(code, options);
|
|
13930
13461
|
}
|
|
13931
13462
|
}
|
|
13932
|
-
ForStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
13933
|
-
ForStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
13934
13463
|
|
|
13935
13464
|
class FunctionExpression extends FunctionNode {
|
|
13936
13465
|
createScope(parentScope) {
|
|
@@ -13962,9 +13491,9 @@ class TrackingScope extends BlockScope {
|
|
|
13962
13491
|
super(...arguments);
|
|
13963
13492
|
this.hoistedDeclarations = [];
|
|
13964
13493
|
}
|
|
13965
|
-
addDeclaration(identifier, context, init,
|
|
13494
|
+
addDeclaration(identifier, context, init, kind) {
|
|
13966
13495
|
this.hoistedDeclarations.push(identifier);
|
|
13967
|
-
return super.addDeclaration(identifier, context, init,
|
|
13496
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
13968
13497
|
}
|
|
13969
13498
|
}
|
|
13970
13499
|
|
|
@@ -14063,9 +13592,10 @@ class IfStatement extends NodeBase {
|
|
|
14063
13592
|
}
|
|
14064
13593
|
this.renderHoistedDeclarations(hoistedDeclarations, code, getPropertyAccess);
|
|
14065
13594
|
}
|
|
13595
|
+
applyDeoptimizations() { }
|
|
14066
13596
|
getTestValue() {
|
|
14067
13597
|
if (this.testValue === unset) {
|
|
14068
|
-
return (this.testValue = this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this));
|
|
13598
|
+
return (this.testValue = tryCastLiteralValueToBoolean(this.test.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this)));
|
|
14069
13599
|
}
|
|
14070
13600
|
return this.testValue;
|
|
14071
13601
|
}
|
|
@@ -14131,8 +13661,6 @@ class IfStatement extends NodeBase {
|
|
|
14131
13661
|
return false;
|
|
14132
13662
|
}
|
|
14133
13663
|
}
|
|
14134
|
-
IfStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14135
|
-
IfStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14136
13664
|
|
|
14137
13665
|
class ImportAttribute extends NodeBase {
|
|
14138
13666
|
}
|
|
@@ -14150,15 +13678,13 @@ class ImportDeclaration extends NodeBase {
|
|
|
14150
13678
|
render(code, _options, nodeRenderOptions) {
|
|
14151
13679
|
code.remove(nodeRenderOptions.start, nodeRenderOptions.end);
|
|
14152
13680
|
}
|
|
13681
|
+
applyDeoptimizations() { }
|
|
14153
13682
|
}
|
|
14154
13683
|
ImportDeclaration.prototype.needsBoundaries = true;
|
|
14155
|
-
ImportDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14156
|
-
ImportDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14157
13684
|
|
|
14158
13685
|
class ImportDefaultSpecifier extends NodeBase {
|
|
13686
|
+
applyDeoptimizations() { }
|
|
14159
13687
|
}
|
|
14160
|
-
ImportDefaultSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14161
|
-
ImportDefaultSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14162
13688
|
|
|
14163
13689
|
function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
14164
13690
|
return (variable.renderBaseName !== null && exportNamesByVariable.has(variable) && variable.isReassigned);
|
|
@@ -14167,33 +13693,28 @@ function isReassignedExportsMember(variable, exportNamesByVariable) {
|
|
|
14167
13693
|
class VariableDeclarator extends NodeBase {
|
|
14168
13694
|
declareDeclarator(kind, isUsingDeclaration) {
|
|
14169
13695
|
this.isUsingDeclaration = isUsingDeclaration;
|
|
14170
|
-
this.id.declare(kind,
|
|
13696
|
+
this.id.declare(kind, this.init || UNDEFINED_EXPRESSION);
|
|
14171
13697
|
}
|
|
14172
13698
|
deoptimizePath(path) {
|
|
14173
13699
|
this.id.deoptimizePath(path);
|
|
14174
13700
|
}
|
|
14175
13701
|
hasEffects(context) {
|
|
13702
|
+
if (!this.deoptimized)
|
|
13703
|
+
this.applyDeoptimizations();
|
|
14176
13704
|
const initEffect = this.init?.hasEffects(context);
|
|
14177
13705
|
this.id.markDeclarationReached();
|
|
14178
|
-
return
|
|
14179
|
-
this.isUsingDeclaration ||
|
|
14180
|
-
this.id.hasEffects(context) ||
|
|
14181
|
-
(this.scope.context.options.treeshake
|
|
14182
|
-
.propertyReadSideEffects &&
|
|
14183
|
-
this.id.hasEffectsWhenDestructuring(context, EMPTY_PATH, this.init || UNDEFINED_EXPRESSION)));
|
|
13706
|
+
return initEffect || this.id.hasEffects(context) || this.isUsingDeclaration;
|
|
14184
13707
|
}
|
|
14185
13708
|
include(context, includeChildrenRecursively) {
|
|
14186
|
-
const { id, init } = this;
|
|
14187
|
-
if (!
|
|
14188
|
-
this.
|
|
13709
|
+
const { deoptimized, id, init } = this;
|
|
13710
|
+
if (!deoptimized)
|
|
13711
|
+
this.applyDeoptimizations();
|
|
13712
|
+
this.included = true;
|
|
14189
13713
|
init?.include(context, includeChildrenRecursively);
|
|
14190
13714
|
id.markDeclarationReached();
|
|
14191
|
-
if (includeChildrenRecursively) {
|
|
13715
|
+
if (includeChildrenRecursively || id.shouldBeIncluded(context)) {
|
|
14192
13716
|
id.include(context, includeChildrenRecursively);
|
|
14193
13717
|
}
|
|
14194
|
-
else {
|
|
14195
|
-
id.includeDestructuredIfNecessary(context, EMPTY_PATH, init || UNDEFINED_EXPRESSION);
|
|
14196
|
-
}
|
|
14197
13718
|
}
|
|
14198
13719
|
removeAnnotations(code) {
|
|
14199
13720
|
this.init?.removeAnnotations(code);
|
|
@@ -14223,8 +13744,8 @@ class VariableDeclarator extends NodeBase {
|
|
|
14223
13744
|
code.appendLeft(end, `${_}=${_}void 0`);
|
|
14224
13745
|
}
|
|
14225
13746
|
}
|
|
14226
|
-
|
|
14227
|
-
this.
|
|
13747
|
+
applyDeoptimizations() {
|
|
13748
|
+
this.deoptimized = true;
|
|
14228
13749
|
const { id, init } = this;
|
|
14229
13750
|
if (init && id instanceof Identifier && init instanceof ClassExpression && !init.id) {
|
|
14230
13751
|
const { name, variable } = id;
|
|
@@ -14236,14 +13757,11 @@ class VariableDeclarator extends NodeBase {
|
|
|
14236
13757
|
}
|
|
14237
13758
|
}
|
|
14238
13759
|
}
|
|
14239
|
-
VariableDeclarator.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14240
13760
|
|
|
14241
13761
|
class ImportExpression extends NodeBase {
|
|
14242
13762
|
constructor() {
|
|
14243
13763
|
super(...arguments);
|
|
14244
13764
|
this.inlineNamespace = null;
|
|
14245
|
-
this.hasUnknownAccessedKey = false;
|
|
14246
|
-
this.accessedPropKey = new Set();
|
|
14247
13765
|
this.attributes = null;
|
|
14248
13766
|
this.mechanism = null;
|
|
14249
13767
|
this.namespaceExportName = undefined;
|
|
@@ -14276,15 +13794,12 @@ class ImportExpression extends NodeBase {
|
|
|
14276
13794
|
if (parent2 instanceof ExpressionStatement) {
|
|
14277
13795
|
return parseAst_js.EMPTY_ARRAY;
|
|
14278
13796
|
}
|
|
14279
|
-
// Case 1: const { foo }
|
|
13797
|
+
// Case 1: const { foo } = await import('bar')
|
|
14280
13798
|
if (parent2 instanceof VariableDeclarator) {
|
|
14281
13799
|
const declaration = parent2.id;
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
if (declaration instanceof ObjectPattern) {
|
|
14286
|
-
return getDeterministicObjectDestructure(declaration);
|
|
14287
|
-
}
|
|
13800
|
+
return declaration instanceof ObjectPattern
|
|
13801
|
+
? getDeterministicObjectDestructure(declaration)
|
|
13802
|
+
: undefined;
|
|
14288
13803
|
}
|
|
14289
13804
|
// Case 2: (await import('bar')).foo
|
|
14290
13805
|
if (parent2 instanceof MemberExpression) {
|
|
@@ -14334,29 +13849,12 @@ class ImportExpression extends NodeBase {
|
|
|
14334
13849
|
return true;
|
|
14335
13850
|
}
|
|
14336
13851
|
include(context, includeChildrenRecursively) {
|
|
14337
|
-
if (!this.included)
|
|
14338
|
-
this.
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
includeNode() {
|
|
14342
|
-
this.included = true;
|
|
14343
|
-
this.scope.context.includeDynamicImport(this);
|
|
14344
|
-
this.scope.addAccessedDynamicImport(this);
|
|
14345
|
-
}
|
|
14346
|
-
includePath(path) {
|
|
14347
|
-
if (!this.included)
|
|
14348
|
-
this.includeNode();
|
|
14349
|
-
// Technically, this is not correct as dynamic imports return a Promise.
|
|
14350
|
-
if (this.hasUnknownAccessedKey)
|
|
14351
|
-
return;
|
|
14352
|
-
if (path[0] === UnknownKey) {
|
|
14353
|
-
this.hasUnknownAccessedKey = true;
|
|
14354
|
-
}
|
|
14355
|
-
else if (typeof path[0] === 'string') {
|
|
14356
|
-
this.accessedPropKey.add(path[0]);
|
|
13852
|
+
if (!this.included) {
|
|
13853
|
+
this.included = true;
|
|
13854
|
+
this.scope.context.includeDynamicImport(this);
|
|
13855
|
+
this.scope.addAccessedDynamicImport(this);
|
|
14357
13856
|
}
|
|
14358
|
-
|
|
14359
|
-
this.scope.context.includeDynamicImport(this);
|
|
13857
|
+
this.source.include(context, includeChildrenRecursively);
|
|
14360
13858
|
}
|
|
14361
13859
|
initialise() {
|
|
14362
13860
|
super.initialise();
|
|
@@ -14426,6 +13924,7 @@ class ImportExpression extends NodeBase {
|
|
|
14426
13924
|
setInternalResolution(inlineNamespace) {
|
|
14427
13925
|
this.inlineNamespace = inlineNamespace;
|
|
14428
13926
|
}
|
|
13927
|
+
applyDeoptimizations() { }
|
|
14429
13928
|
getDynamicImportMechanismAndHelper(resolution, exportMode, { compact, dynamicImportInCjs, format, generatedCode: { arrowFunctions }, interop }, { _, getDirectReturnFunction, getDirectReturnIifeLeft }, pluginDriver) {
|
|
14430
13929
|
const mechanism = pluginDriver.hookFirstSync('renderDynamicImport', [
|
|
14431
13930
|
{
|
|
@@ -14515,7 +14014,6 @@ class ImportExpression extends NodeBase {
|
|
|
14515
14014
|
return { helper: null, mechanism: null };
|
|
14516
14015
|
}
|
|
14517
14016
|
}
|
|
14518
|
-
ImportExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14519
14017
|
function getInteropHelper(resolution, exportMode, interop) {
|
|
14520
14018
|
return exportMode === 'external'
|
|
14521
14019
|
? namespaceInteropHelpersByInteropType[interop(resolution instanceof ExternalModule ? resolution.id : null)]
|
|
@@ -14539,14 +14037,12 @@ function getDeterministicObjectDestructure(objectPattern) {
|
|
|
14539
14037
|
}
|
|
14540
14038
|
|
|
14541
14039
|
class ImportNamespaceSpecifier extends NodeBase {
|
|
14040
|
+
applyDeoptimizations() { }
|
|
14542
14041
|
}
|
|
14543
|
-
ImportNamespaceSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14544
|
-
ImportNamespaceSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14545
14042
|
|
|
14546
14043
|
class ImportSpecifier extends NodeBase {
|
|
14044
|
+
applyDeoptimizations() { }
|
|
14547
14045
|
}
|
|
14548
|
-
ImportSpecifier.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
14549
|
-
ImportSpecifier.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14550
14046
|
|
|
14551
14047
|
class JSXIdentifier extends IdentifierBase {
|
|
14552
14048
|
constructor() {
|
|
@@ -14563,29 +14059,6 @@ class JSXIdentifier extends IdentifierBase {
|
|
|
14563
14059
|
this.isNativeElement = true;
|
|
14564
14060
|
}
|
|
14565
14061
|
}
|
|
14566
|
-
include(context) {
|
|
14567
|
-
if (!this.included)
|
|
14568
|
-
this.includeNode(context);
|
|
14569
|
-
}
|
|
14570
|
-
includeNode(context) {
|
|
14571
|
-
this.included = true;
|
|
14572
|
-
if (!this.deoptimized)
|
|
14573
|
-
this.applyDeoptimizations();
|
|
14574
|
-
if (this.variable !== null) {
|
|
14575
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
14576
|
-
}
|
|
14577
|
-
}
|
|
14578
|
-
includePath(path, context) {
|
|
14579
|
-
if (!this.included) {
|
|
14580
|
-
this.included = true;
|
|
14581
|
-
if (this.variable !== null) {
|
|
14582
|
-
this.scope.context.includeVariableInModule(this.variable, path, context);
|
|
14583
|
-
}
|
|
14584
|
-
}
|
|
14585
|
-
else if (path.length > 0) {
|
|
14586
|
-
this.variable?.includePath(path, context);
|
|
14587
|
-
}
|
|
14588
|
-
}
|
|
14589
14062
|
render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
|
|
14590
14063
|
if (this.variable) {
|
|
14591
14064
|
const name = this.variable.getName(getPropertyAccess, useOriginalName);
|
|
@@ -14647,7 +14120,6 @@ class JSXAttribute extends NodeBase {
|
|
|
14647
14120
|
}
|
|
14648
14121
|
}
|
|
14649
14122
|
}
|
|
14650
|
-
JSXAttribute.prototype.includeNode = onlyIncludeSelf;
|
|
14651
14123
|
|
|
14652
14124
|
class JSXClosingBase extends NodeBase {
|
|
14653
14125
|
render(code, options) {
|
|
@@ -14660,7 +14132,6 @@ class JSXClosingBase extends NodeBase {
|
|
|
14660
14132
|
}
|
|
14661
14133
|
}
|
|
14662
14134
|
}
|
|
14663
|
-
JSXClosingBase.prototype.includeNode = onlyIncludeSelf;
|
|
14664
14135
|
|
|
14665
14136
|
class JSXClosingElement extends JSXClosingBase {
|
|
14666
14137
|
}
|
|
@@ -14681,15 +14152,8 @@ class JSXSpreadAttribute extends NodeBase {
|
|
|
14681
14152
|
|
|
14682
14153
|
class JSXEmptyExpression extends NodeBase {
|
|
14683
14154
|
}
|
|
14684
|
-
JSXEmptyExpression.prototype.includeNode = onlyIncludeSelf;
|
|
14685
14155
|
|
|
14686
14156
|
class JSXExpressionContainer extends NodeBase {
|
|
14687
|
-
includeNode(context) {
|
|
14688
|
-
this.included = true;
|
|
14689
|
-
if (!this.deoptimized)
|
|
14690
|
-
this.applyDeoptimizations();
|
|
14691
|
-
this.expression.includePath(UNKNOWN_PATH, context);
|
|
14692
|
-
}
|
|
14693
14157
|
render(code, options) {
|
|
14694
14158
|
const { mode } = this.scope.context.options.jsx;
|
|
14695
14159
|
if (mode !== 'preserve') {
|
|
@@ -14710,7 +14174,7 @@ function getRenderedJsxChildren(children) {
|
|
|
14710
14174
|
return renderedChildren;
|
|
14711
14175
|
}
|
|
14712
14176
|
|
|
14713
|
-
function getAndIncludeFactoryVariable(factory, preserve, importSource, node
|
|
14177
|
+
function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
|
|
14714
14178
|
const [baseName, nestedName] = factory.split('.');
|
|
14715
14179
|
let factoryVariable;
|
|
14716
14180
|
if (importSource) {
|
|
@@ -14718,7 +14182,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
14718
14182
|
if (preserve) {
|
|
14719
14183
|
// This pretends we are accessing an included global variable of the same name
|
|
14720
14184
|
const globalVariable = node.scope.findGlobal(baseName);
|
|
14721
|
-
globalVariable.
|
|
14185
|
+
globalVariable.include();
|
|
14722
14186
|
// This excludes this variable from renaming
|
|
14723
14187
|
factoryVariable.globalName = baseName;
|
|
14724
14188
|
}
|
|
@@ -14726,7 +14190,7 @@ function getAndIncludeFactoryVariable(factory, preserve, importSource, node, con
|
|
|
14726
14190
|
else {
|
|
14727
14191
|
factoryVariable = node.scope.findGlobal(baseName);
|
|
14728
14192
|
}
|
|
14729
|
-
node.scope.context.includeVariableInModule(factoryVariable
|
|
14193
|
+
node.scope.context.includeVariableInModule(factoryVariable);
|
|
14730
14194
|
if (factoryVariable instanceof LocalVariable) {
|
|
14731
14195
|
factoryVariable.consolidateInitializers();
|
|
14732
14196
|
factoryVariable.addUsedPlace(node);
|
|
@@ -14749,20 +14213,16 @@ class JSXElementBase extends NodeBase {
|
|
|
14749
14213
|
}
|
|
14750
14214
|
}
|
|
14751
14215
|
include(context, includeChildrenRecursively) {
|
|
14752
|
-
if (!this.included)
|
|
14753
|
-
this.
|
|
14754
|
-
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
includeNode(context) {
|
|
14759
|
-
this.included = true;
|
|
14760
|
-
const { factory, importSource, mode } = this.jsxMode;
|
|
14761
|
-
if (factory) {
|
|
14762
|
-
this.factory = factory;
|
|
14763
|
-
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this, context);
|
|
14216
|
+
if (!this.included) {
|
|
14217
|
+
const { factory, importSource, mode } = this.jsxMode;
|
|
14218
|
+
if (factory) {
|
|
14219
|
+
this.factory = factory;
|
|
14220
|
+
this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
|
|
14221
|
+
}
|
|
14764
14222
|
}
|
|
14223
|
+
super.include(context, includeChildrenRecursively);
|
|
14765
14224
|
}
|
|
14225
|
+
applyDeoptimizations() { }
|
|
14766
14226
|
getRenderingMode() {
|
|
14767
14227
|
const jsx = this.scope.context.options.jsx;
|
|
14768
14228
|
const { mode, factory, importSource } = jsx;
|
|
@@ -14800,14 +14260,8 @@ class JSXElementBase extends NodeBase {
|
|
|
14800
14260
|
return { childrenEnd, firstChild, hasMultipleChildren };
|
|
14801
14261
|
}
|
|
14802
14262
|
}
|
|
14803
|
-
JSXElementBase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
14804
14263
|
|
|
14805
14264
|
class JSXElement extends JSXElementBase {
|
|
14806
|
-
include(context, includeChildrenRecursively) {
|
|
14807
|
-
super.include(context, includeChildrenRecursively);
|
|
14808
|
-
this.openingElement.include(context, includeChildrenRecursively);
|
|
14809
|
-
this.closingElement?.include(context, includeChildrenRecursively);
|
|
14810
|
-
}
|
|
14811
14265
|
render(code, options) {
|
|
14812
14266
|
switch (this.jsxMode.mode) {
|
|
14813
14267
|
case 'classic': {
|
|
@@ -14959,11 +14413,6 @@ class JSXElement extends JSXElementBase {
|
|
|
14959
14413
|
}
|
|
14960
14414
|
|
|
14961
14415
|
class JSXFragment extends JSXElementBase {
|
|
14962
|
-
include(context, includeChildrenRecursively) {
|
|
14963
|
-
super.include(context, includeChildrenRecursively);
|
|
14964
|
-
this.openingFragment.include(context, includeChildrenRecursively);
|
|
14965
|
-
this.closingFragment.include(context, includeChildrenRecursively);
|
|
14966
|
-
}
|
|
14967
14416
|
render(code, options) {
|
|
14968
14417
|
switch (this.jsxMode.mode) {
|
|
14969
14418
|
case 'classic': {
|
|
@@ -15013,22 +14462,10 @@ class JSXFragment extends JSXElementBase {
|
|
|
15013
14462
|
}
|
|
15014
14463
|
|
|
15015
14464
|
class JSXMemberExpression extends NodeBase {
|
|
15016
|
-
includeNode(context) {
|
|
15017
|
-
this.included = true;
|
|
15018
|
-
if (!this.deoptimized)
|
|
15019
|
-
this.applyDeoptimizations();
|
|
15020
|
-
this.object.includePath([this.property.name], context);
|
|
15021
|
-
}
|
|
15022
|
-
includePath(path, context) {
|
|
15023
|
-
if (!this.included)
|
|
15024
|
-
this.includeNode(context);
|
|
15025
|
-
this.object.includePath([this.property.name, ...path], context);
|
|
15026
|
-
}
|
|
15027
14465
|
}
|
|
15028
14466
|
|
|
15029
14467
|
class JSXNamespacedName extends NodeBase {
|
|
15030
14468
|
}
|
|
15031
|
-
JSXNamespacedName.prototype.includeNode = onlyIncludeSelf;
|
|
15032
14469
|
|
|
15033
14470
|
class JSXOpeningElement extends NodeBase {
|
|
15034
14471
|
render(code, options, { jsxMode = this.scope.context.options.jsx.mode } = {}) {
|
|
@@ -15038,7 +14475,6 @@ class JSXOpeningElement extends NodeBase {
|
|
|
15038
14475
|
}
|
|
15039
14476
|
}
|
|
15040
14477
|
}
|
|
15041
|
-
JSXOpeningElement.prototype.includeNode = onlyIncludeSelf;
|
|
15042
14478
|
|
|
15043
14479
|
class JSXOpeningFragment extends NodeBase {
|
|
15044
14480
|
constructor() {
|
|
@@ -15046,22 +14482,22 @@ class JSXOpeningFragment extends NodeBase {
|
|
|
15046
14482
|
this.fragment = null;
|
|
15047
14483
|
this.fragmentVariable = null;
|
|
15048
14484
|
}
|
|
15049
|
-
|
|
15050
|
-
this.included
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this, context);
|
|
14485
|
+
include(context, includeChildrenRecursively) {
|
|
14486
|
+
if (!this.included) {
|
|
14487
|
+
const jsx = this.scope.context.options.jsx;
|
|
14488
|
+
if (jsx.mode === 'automatic') {
|
|
14489
|
+
this.fragment = 'Fragment';
|
|
14490
|
+
this.fragmentVariable = getAndIncludeFactoryVariable('Fragment', false, jsx.jsxImportSource, this);
|
|
14491
|
+
}
|
|
14492
|
+
else {
|
|
14493
|
+
const { fragment, importSource, mode } = jsx;
|
|
14494
|
+
if (fragment != null) {
|
|
14495
|
+
this.fragment = fragment;
|
|
14496
|
+
this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this);
|
|
14497
|
+
}
|
|
15063
14498
|
}
|
|
15064
14499
|
}
|
|
14500
|
+
super.include(context, includeChildrenRecursively);
|
|
15065
14501
|
}
|
|
15066
14502
|
render(code, options) {
|
|
15067
14503
|
const { mode } = this.scope.context.options.jsx;
|
|
@@ -15098,7 +14534,6 @@ class JSXText extends NodeBase {
|
|
|
15098
14534
|
}
|
|
15099
14535
|
}
|
|
15100
14536
|
}
|
|
15101
|
-
JSXText.prototype.includeNode = onlyIncludeSelf;
|
|
15102
14537
|
|
|
15103
14538
|
class LabeledStatement extends NodeBase {
|
|
15104
14539
|
hasEffects(context) {
|
|
@@ -15120,22 +14555,17 @@ class LabeledStatement extends NodeBase {
|
|
|
15120
14555
|
return bodyHasEffects;
|
|
15121
14556
|
}
|
|
15122
14557
|
include(context, includeChildrenRecursively) {
|
|
15123
|
-
|
|
15124
|
-
this.includeNode(context);
|
|
14558
|
+
this.included = true;
|
|
15125
14559
|
const { brokenFlow, includedLabels } = context;
|
|
15126
14560
|
context.includedLabels = new Set();
|
|
15127
14561
|
this.body.include(context, includeChildrenRecursively);
|
|
15128
14562
|
if (includeChildrenRecursively || context.includedLabels.has(this.label.name)) {
|
|
15129
|
-
this.label.include(
|
|
14563
|
+
this.label.include();
|
|
15130
14564
|
context.includedLabels.delete(this.label.name);
|
|
15131
14565
|
context.brokenFlow = brokenFlow;
|
|
15132
14566
|
}
|
|
15133
14567
|
context.includedLabels = new Set([...includedLabels, ...context.includedLabels]);
|
|
15134
14568
|
}
|
|
15135
|
-
includeNode(context) {
|
|
15136
|
-
this.included = true;
|
|
15137
|
-
this.body.includePath(UNKNOWN_PATH, context);
|
|
15138
|
-
}
|
|
15139
14569
|
render(code, options) {
|
|
15140
14570
|
if (this.label.included) {
|
|
15141
14571
|
this.label.render(code, options);
|
|
@@ -15146,7 +14576,6 @@ class LabeledStatement extends NodeBase {
|
|
|
15146
14576
|
this.body.render(code, options);
|
|
15147
14577
|
}
|
|
15148
14578
|
}
|
|
15149
|
-
LabeledStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15150
14579
|
|
|
15151
14580
|
class LogicalExpression extends NodeBase {
|
|
15152
14581
|
constructor() {
|
|
@@ -15171,10 +14600,6 @@ class LogicalExpression extends NodeBase {
|
|
|
15171
14600
|
const unusedBranch = this.usedBranch === this.left ? this.right : this.left;
|
|
15172
14601
|
this.usedBranch = null;
|
|
15173
14602
|
unusedBranch.deoptimizePath(UNKNOWN_PATH);
|
|
15174
|
-
if (this.included) {
|
|
15175
|
-
// As we are not tracking inclusions, we just include everything
|
|
15176
|
-
unusedBranch.includePath(UNKNOWN_PATH, createInclusionContext());
|
|
15177
|
-
}
|
|
15178
14603
|
const { scope: { context }, expressionsToBeDeoptimized } = this;
|
|
15179
14604
|
this.expressionsToBeDeoptimized = parseAst_js.EMPTY_ARRAY;
|
|
15180
14605
|
for (const expression of expressionsToBeDeoptimized) {
|
|
@@ -15201,21 +14626,33 @@ class LogicalExpression extends NodeBase {
|
|
|
15201
14626
|
this.expressionsToBeDeoptimized.push(origin);
|
|
15202
14627
|
return usedBranch.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
15203
14628
|
}
|
|
14629
|
+
else {
|
|
14630
|
+
const rightValue = this.right.getLiteralValueAtPath(path, recursionTracker, origin);
|
|
14631
|
+
const booleanOrUnknown = tryCastLiteralValueToBoolean(rightValue);
|
|
14632
|
+
if (typeof booleanOrUnknown !== 'symbol') {
|
|
14633
|
+
if (!booleanOrUnknown && this.operator === '&&') {
|
|
14634
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
14635
|
+
return UnknownFalsyValue;
|
|
14636
|
+
}
|
|
14637
|
+
if (booleanOrUnknown && this.operator === '||') {
|
|
14638
|
+
return UnknownTruthyValue;
|
|
14639
|
+
}
|
|
14640
|
+
}
|
|
14641
|
+
}
|
|
15204
14642
|
return UnknownValue;
|
|
15205
14643
|
}
|
|
15206
14644
|
getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin) {
|
|
15207
14645
|
const usedBranch = this.getUsedBranch();
|
|
15208
|
-
if (usedBranch)
|
|
15209
|
-
|
|
15210
|
-
|
|
15211
|
-
|
|
15212
|
-
|
|
15213
|
-
|
|
15214
|
-
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
];
|
|
14646
|
+
if (!usedBranch)
|
|
14647
|
+
return [
|
|
14648
|
+
new MultiExpression([
|
|
14649
|
+
this.left.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0],
|
|
14650
|
+
this.right.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin)[0]
|
|
14651
|
+
]),
|
|
14652
|
+
false
|
|
14653
|
+
];
|
|
14654
|
+
this.expressionsToBeDeoptimized.push(origin);
|
|
14655
|
+
return usedBranch.getReturnExpressionWhenCalledAtPath(path, interaction, recursionTracker, origin);
|
|
15219
14656
|
}
|
|
15220
14657
|
hasEffects(context) {
|
|
15221
14658
|
if (this.left.hasEffects(context)) {
|
|
@@ -15228,18 +14665,18 @@ class LogicalExpression extends NodeBase {
|
|
|
15228
14665
|
}
|
|
15229
14666
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
15230
14667
|
const usedBranch = this.getUsedBranch();
|
|
15231
|
-
if (usedBranch) {
|
|
15232
|
-
return
|
|
14668
|
+
if (!usedBranch) {
|
|
14669
|
+
return (this.left.hasEffectsOnInteractionAtPath(path, interaction, context) ||
|
|
14670
|
+
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
15233
14671
|
}
|
|
15234
|
-
return
|
|
15235
|
-
this.right.hasEffectsOnInteractionAtPath(path, interaction, context));
|
|
14672
|
+
return usedBranch.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
15236
14673
|
}
|
|
15237
14674
|
include(context, includeChildrenRecursively) {
|
|
15238
14675
|
this.included = true;
|
|
15239
14676
|
const usedBranch = this.getUsedBranch();
|
|
15240
14677
|
if (includeChildrenRecursively ||
|
|
15241
|
-
|
|
15242
|
-
|
|
14678
|
+
(usedBranch === this.right && this.left.shouldBeIncluded(context)) ||
|
|
14679
|
+
!usedBranch) {
|
|
15243
14680
|
this.left.include(context, includeChildrenRecursively);
|
|
15244
14681
|
this.right.include(context, includeChildrenRecursively);
|
|
15245
14682
|
}
|
|
@@ -15247,17 +14684,6 @@ class LogicalExpression extends NodeBase {
|
|
|
15247
14684
|
usedBranch.include(context, includeChildrenRecursively);
|
|
15248
14685
|
}
|
|
15249
14686
|
}
|
|
15250
|
-
includePath(path, context) {
|
|
15251
|
-
this.included = true;
|
|
15252
|
-
const usedBranch = this.getUsedBranch();
|
|
15253
|
-
if (!usedBranch || (usedBranch === this.right && this.left.shouldBeIncluded(context))) {
|
|
15254
|
-
this.left.includePath(path, context);
|
|
15255
|
-
this.right.includePath(path, context);
|
|
15256
|
-
}
|
|
15257
|
-
else {
|
|
15258
|
-
usedBranch.includePath(path, context);
|
|
15259
|
-
}
|
|
15260
|
-
}
|
|
15261
14687
|
removeAnnotations(code) {
|
|
15262
14688
|
this.left.removeAnnotations(code);
|
|
15263
14689
|
}
|
|
@@ -15294,13 +14720,14 @@ class LogicalExpression extends NodeBase {
|
|
|
15294
14720
|
if (!this.isBranchResolutionAnalysed) {
|
|
15295
14721
|
this.isBranchResolutionAnalysed = true;
|
|
15296
14722
|
const leftValue = this.left.getLiteralValueAtPath(EMPTY_PATH, SHARED_RECURSION_TRACKER, this);
|
|
15297
|
-
|
|
14723
|
+
const booleanOrUnknown = tryCastLiteralValueToBoolean(leftValue);
|
|
14724
|
+
if (typeof booleanOrUnknown === 'symbol') {
|
|
15298
14725
|
return null;
|
|
15299
14726
|
}
|
|
15300
14727
|
else {
|
|
15301
14728
|
this.usedBranch =
|
|
15302
|
-
(this.operator === '||' &&
|
|
15303
|
-
(this.operator === '&&' && !
|
|
14729
|
+
(this.operator === '||' && booleanOrUnknown) ||
|
|
14730
|
+
(this.operator === '&&' && !booleanOrUnknown) ||
|
|
15304
14731
|
(this.operator === '??' && leftValue != null)
|
|
15305
14732
|
? this.left
|
|
15306
14733
|
: this.right;
|
|
@@ -15309,8 +14736,6 @@ class LogicalExpression extends NodeBase {
|
|
|
15309
14736
|
return this.usedBranch;
|
|
15310
14737
|
}
|
|
15311
14738
|
}
|
|
15312
|
-
LogicalExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15313
|
-
LogicalExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15314
14739
|
|
|
15315
14740
|
class NewExpression extends NodeBase {
|
|
15316
14741
|
hasEffects(context) {
|
|
@@ -15330,21 +14755,16 @@ class NewExpression extends NodeBase {
|
|
|
15330
14755
|
return path.length > 0 || type !== INTERACTION_ACCESSED;
|
|
15331
14756
|
}
|
|
15332
14757
|
include(context, includeChildrenRecursively) {
|
|
14758
|
+
if (!this.deoptimized)
|
|
14759
|
+
this.applyDeoptimizations();
|
|
15333
14760
|
if (includeChildrenRecursively) {
|
|
15334
14761
|
super.include(context, includeChildrenRecursively);
|
|
15335
14762
|
}
|
|
15336
14763
|
else {
|
|
15337
|
-
|
|
15338
|
-
this.includeNode(context);
|
|
14764
|
+
this.included = true;
|
|
15339
14765
|
this.callee.include(context, false);
|
|
15340
14766
|
}
|
|
15341
|
-
this.callee.includeCallArguments(context, this.
|
|
15342
|
-
}
|
|
15343
|
-
includeNode(context) {
|
|
15344
|
-
this.included = true;
|
|
15345
|
-
if (!this.deoptimized)
|
|
15346
|
-
this.applyDeoptimizations();
|
|
15347
|
-
this.callee.includePath(UNKNOWN_PATH, context);
|
|
14767
|
+
this.callee.includeCallArguments(context, this.arguments);
|
|
15348
14768
|
}
|
|
15349
14769
|
initialise() {
|
|
15350
14770
|
super.initialise();
|
|
@@ -15373,7 +14793,6 @@ class ObjectExpression extends NodeBase {
|
|
|
15373
14793
|
constructor() {
|
|
15374
14794
|
super(...arguments);
|
|
15375
14795
|
this.objectEntity = null;
|
|
15376
|
-
this.protoProp = null;
|
|
15377
14796
|
}
|
|
15378
14797
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
15379
14798
|
this.getObjectEntity().deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
|
|
@@ -15393,43 +14812,15 @@ class ObjectExpression extends NodeBase {
|
|
|
15393
14812
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
15394
14813
|
return this.getObjectEntity().hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
15395
14814
|
}
|
|
15396
|
-
include(context, includeChildrenRecursively) {
|
|
15397
|
-
if (!this.included)
|
|
15398
|
-
this.includeNode(context);
|
|
15399
|
-
this.getObjectEntity().include(context, includeChildrenRecursively);
|
|
15400
|
-
this.protoProp?.include(context, includeChildrenRecursively);
|
|
15401
|
-
}
|
|
15402
|
-
includeNode(context) {
|
|
15403
|
-
this.included = true;
|
|
15404
|
-
this.protoProp?.includePath(UNKNOWN_PATH, context);
|
|
15405
|
-
}
|
|
15406
|
-
includePath(path, context) {
|
|
15407
|
-
if (!this.included)
|
|
15408
|
-
this.includeNode(context);
|
|
15409
|
-
this.getObjectEntity().includePath(path, context);
|
|
15410
|
-
}
|
|
15411
14815
|
render(code, options, { renderedSurroundingElement } = parseAst_js.BLANK) {
|
|
14816
|
+
super.render(code, options);
|
|
15412
14817
|
if (renderedSurroundingElement === parseAst_js.ExpressionStatement ||
|
|
15413
14818
|
renderedSurroundingElement === parseAst_js.ArrowFunctionExpression) {
|
|
15414
14819
|
code.appendRight(this.start, '(');
|
|
15415
14820
|
code.prependLeft(this.end, ')');
|
|
15416
14821
|
}
|
|
15417
|
-
if (this.properties.length > 0) {
|
|
15418
|
-
const separatedNodes = getCommaSeparatedNodesWithBoundaries(this.properties, code, this.start + 1, this.end - 1);
|
|
15419
|
-
let lastSeparatorPos = null;
|
|
15420
|
-
for (const { node, separator, start, end } of separatedNodes) {
|
|
15421
|
-
if (!node.included) {
|
|
15422
|
-
treeshakeNode(node, code, start, end);
|
|
15423
|
-
continue;
|
|
15424
|
-
}
|
|
15425
|
-
lastSeparatorPos = separator;
|
|
15426
|
-
node.render(code, options);
|
|
15427
|
-
}
|
|
15428
|
-
if (lastSeparatorPos) {
|
|
15429
|
-
code.remove(lastSeparatorPos, this.end - 1);
|
|
15430
|
-
}
|
|
15431
|
-
}
|
|
15432
14822
|
}
|
|
14823
|
+
applyDeoptimizations() { }
|
|
15433
14824
|
getObjectEntity() {
|
|
15434
14825
|
if (this.objectEntity !== null) {
|
|
15435
14826
|
return this.objectEntity;
|
|
@@ -15458,7 +14849,6 @@ class ObjectExpression extends NodeBase {
|
|
|
15458
14849
|
? property.key.name
|
|
15459
14850
|
: String(property.key.value);
|
|
15460
14851
|
if (key === '__proto__' && property.kind === 'init') {
|
|
15461
|
-
this.protoProp = property;
|
|
15462
14852
|
prototype =
|
|
15463
14853
|
property.value instanceof Literal && property.value.value === null
|
|
15464
14854
|
? null
|
|
@@ -15471,7 +14861,6 @@ class ObjectExpression extends NodeBase {
|
|
|
15471
14861
|
return (this.objectEntity = new ObjectEntity(properties, prototype));
|
|
15472
14862
|
}
|
|
15473
14863
|
}
|
|
15474
|
-
ObjectExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15475
14864
|
|
|
15476
14865
|
class PanicError extends NodeBase {
|
|
15477
14866
|
initialise() {
|
|
@@ -15498,7 +14887,6 @@ class ParseError extends NodeBase {
|
|
|
15498
14887
|
|
|
15499
14888
|
class PrivateIdentifier extends NodeBase {
|
|
15500
14889
|
}
|
|
15501
|
-
PrivateIdentifier.prototype.includeNode = onlyIncludeSelf;
|
|
15502
14890
|
|
|
15503
14891
|
class Program extends NodeBase {
|
|
15504
14892
|
constructor() {
|
|
@@ -15566,11 +14954,14 @@ class Program extends NodeBase {
|
|
|
15566
14954
|
super.render(code, options);
|
|
15567
14955
|
}
|
|
15568
14956
|
}
|
|
14957
|
+
applyDeoptimizations() { }
|
|
15569
14958
|
}
|
|
15570
|
-
Program.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15571
|
-
Program.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15572
14959
|
|
|
15573
14960
|
class Property extends MethodBase {
|
|
14961
|
+
constructor() {
|
|
14962
|
+
super(...arguments);
|
|
14963
|
+
this.declarationInit = null;
|
|
14964
|
+
}
|
|
15574
14965
|
//declare method: boolean;
|
|
15575
14966
|
get method() {
|
|
15576
14967
|
return isFlagSet(this.flags, 262144 /* Flag.method */);
|
|
@@ -15585,41 +14976,17 @@ class Property extends MethodBase {
|
|
|
15585
14976
|
set shorthand(value) {
|
|
15586
14977
|
this.flags = setFlag(this.flags, 524288 /* Flag.shorthand */, value);
|
|
15587
14978
|
}
|
|
15588
|
-
declare(kind,
|
|
15589
|
-
|
|
15590
|
-
|
|
15591
|
-
deoptimizeAssignment(destructuredInitPath, init) {
|
|
15592
|
-
this.value.deoptimizeAssignment?.(this.getPathInProperty(destructuredInitPath), init);
|
|
14979
|
+
declare(kind, init) {
|
|
14980
|
+
this.declarationInit = init;
|
|
14981
|
+
return this.value.declare(kind, UNKNOWN_EXPRESSION);
|
|
15593
14982
|
}
|
|
15594
14983
|
hasEffects(context) {
|
|
15595
|
-
|
|
15596
|
-
|
|
15597
|
-
|
|
15598
|
-
return this.
|
|
15599
|
-
|
|
15600
|
-
|
|
15601
|
-
const path = this.getPathInProperty(destructuredInitPath);
|
|
15602
|
-
let included = this.value.includeDestructuredIfNecessary(context, path, init) ||
|
|
15603
|
-
this.included;
|
|
15604
|
-
if ((included ||= this.key.hasEffects(createHasEffectsContext()))) {
|
|
15605
|
-
this.key.include(context, false);
|
|
15606
|
-
if (!this.value.included) {
|
|
15607
|
-
this.value.included = true;
|
|
15608
|
-
// Unfortunately, we need to include the value again now, so that any
|
|
15609
|
-
// declared variables are properly included.
|
|
15610
|
-
this.value.includeDestructuredIfNecessary(context, path, init);
|
|
15611
|
-
}
|
|
15612
|
-
}
|
|
15613
|
-
return (this.included = included);
|
|
15614
|
-
}
|
|
15615
|
-
include(context, includeChildrenRecursively) {
|
|
15616
|
-
this.included = true;
|
|
15617
|
-
this.key.include(context, includeChildrenRecursively);
|
|
15618
|
-
this.value.include(context, includeChildrenRecursively);
|
|
15619
|
-
}
|
|
15620
|
-
includePath(path, context) {
|
|
15621
|
-
this.included = true;
|
|
15622
|
-
this.value.includePath(path, context);
|
|
14984
|
+
if (!this.deoptimized)
|
|
14985
|
+
this.applyDeoptimizations();
|
|
14986
|
+
const propertyReadSideEffects = this.scope.context.options.treeshake.propertyReadSideEffects;
|
|
14987
|
+
return ((this.parent.type === 'ObjectPattern' && propertyReadSideEffects === 'always') ||
|
|
14988
|
+
this.key.hasEffects(context) ||
|
|
14989
|
+
this.value.hasEffects(context));
|
|
15623
14990
|
}
|
|
15624
14991
|
markDeclarationReached() {
|
|
15625
14992
|
this.value.markDeclarationReached();
|
|
@@ -15630,20 +14997,14 @@ class Property extends MethodBase {
|
|
|
15630
14997
|
}
|
|
15631
14998
|
this.value.render(code, options, { isShorthandProperty: this.shorthand });
|
|
15632
14999
|
}
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
? [...destructuredInitPath, UnknownKey]
|
|
15640
|
-
: this.key instanceof Identifier
|
|
15641
|
-
? [...destructuredInitPath, this.key.name]
|
|
15642
|
-
: [...destructuredInitPath, String(this.key.value)];
|
|
15000
|
+
applyDeoptimizations() {
|
|
15001
|
+
this.deoptimized = true;
|
|
15002
|
+
if (this.declarationInit !== null) {
|
|
15003
|
+
this.declarationInit.deoptimizePath([UnknownKey, UnknownKey]);
|
|
15004
|
+
this.scope.context.requestTreeshakingPass();
|
|
15005
|
+
}
|
|
15643
15006
|
}
|
|
15644
15007
|
}
|
|
15645
|
-
Property.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15646
|
-
Property.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15647
15008
|
|
|
15648
15009
|
class PropertyDefinition extends NodeBase {
|
|
15649
15010
|
get computed() {
|
|
@@ -15676,15 +15037,8 @@ class PropertyDefinition extends NodeBase {
|
|
|
15676
15037
|
hasEffectsOnInteractionAtPath(path, interaction, context) {
|
|
15677
15038
|
return !this.value || this.value.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
15678
15039
|
}
|
|
15679
|
-
|
|
15680
|
-
this.included = true;
|
|
15681
|
-
this.value?.includePath(UNKNOWN_PATH, context);
|
|
15682
|
-
for (const decorator of this.decorators) {
|
|
15683
|
-
decorator.includePath(UNKNOWN_PATH, context);
|
|
15684
|
-
}
|
|
15685
|
-
}
|
|
15040
|
+
applyDeoptimizations() { }
|
|
15686
15041
|
}
|
|
15687
|
-
PropertyDefinition.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15688
15042
|
|
|
15689
15043
|
class ReturnStatement extends NodeBase {
|
|
15690
15044
|
hasEffects(context) {
|
|
@@ -15694,15 +15048,10 @@ class ReturnStatement extends NodeBase {
|
|
|
15694
15048
|
return false;
|
|
15695
15049
|
}
|
|
15696
15050
|
include(context, includeChildrenRecursively) {
|
|
15697
|
-
|
|
15698
|
-
this.includeNode(context);
|
|
15051
|
+
this.included = true;
|
|
15699
15052
|
this.argument?.include(context, includeChildrenRecursively);
|
|
15700
15053
|
context.brokenFlow = true;
|
|
15701
15054
|
}
|
|
15702
|
-
includeNode(context) {
|
|
15703
|
-
this.included = true;
|
|
15704
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
15705
|
-
}
|
|
15706
15055
|
initialise() {
|
|
15707
15056
|
super.initialise();
|
|
15708
15057
|
this.scope.addReturnExpression(this.argument || UNKNOWN_EXPRESSION);
|
|
@@ -15716,7 +15065,6 @@ class ReturnStatement extends NodeBase {
|
|
|
15716
15065
|
}
|
|
15717
15066
|
}
|
|
15718
15067
|
}
|
|
15719
|
-
ReturnStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15720
15068
|
|
|
15721
15069
|
class SequenceExpression extends NodeBase {
|
|
15722
15070
|
deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
|
|
@@ -15744,15 +15092,10 @@ class SequenceExpression extends NodeBase {
|
|
|
15744
15092
|
for (const expression of this.expressions) {
|
|
15745
15093
|
if (includeChildrenRecursively ||
|
|
15746
15094
|
(expression === lastExpression && !(this.parent instanceof ExpressionStatement)) ||
|
|
15747
|
-
expression.shouldBeIncluded(context))
|
|
15095
|
+
expression.shouldBeIncluded(context))
|
|
15748
15096
|
expression.include(context, includeChildrenRecursively);
|
|
15749
|
-
}
|
|
15750
15097
|
}
|
|
15751
15098
|
}
|
|
15752
|
-
includePath(path, context) {
|
|
15753
|
-
this.included = true;
|
|
15754
|
-
this.expressions[this.expressions.length - 1].includePath(path, context);
|
|
15755
|
-
}
|
|
15756
15099
|
removeAnnotations(code) {
|
|
15757
15100
|
this.expressions[0].removeAnnotations(code);
|
|
15758
15101
|
}
|
|
@@ -15787,8 +15130,6 @@ class SequenceExpression extends NodeBase {
|
|
|
15787
15130
|
}
|
|
15788
15131
|
}
|
|
15789
15132
|
}
|
|
15790
|
-
SequenceExpression.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15791
|
-
SequenceExpression.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15792
15133
|
|
|
15793
15134
|
class Super extends NodeBase {
|
|
15794
15135
|
bind() {
|
|
@@ -15800,15 +15141,11 @@ class Super extends NodeBase {
|
|
|
15800
15141
|
deoptimizePath(path) {
|
|
15801
15142
|
this.variable.deoptimizePath(path);
|
|
15802
15143
|
}
|
|
15803
|
-
include(
|
|
15804
|
-
if (!this.included)
|
|
15805
|
-
this.
|
|
15806
|
-
|
|
15807
|
-
|
|
15808
|
-
this.included = true;
|
|
15809
|
-
if (!this.deoptimized)
|
|
15810
|
-
this.applyDeoptimizations();
|
|
15811
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
15144
|
+
include() {
|
|
15145
|
+
if (!this.included) {
|
|
15146
|
+
this.included = true;
|
|
15147
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
15148
|
+
}
|
|
15812
15149
|
}
|
|
15813
15150
|
}
|
|
15814
15151
|
|
|
@@ -15849,8 +15186,6 @@ class SwitchCase extends NodeBase {
|
|
|
15849
15186
|
}
|
|
15850
15187
|
}
|
|
15851
15188
|
SwitchCase.prototype.needsBoundaries = true;
|
|
15852
|
-
SwitchCase.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15853
|
-
SwitchCase.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15854
15189
|
|
|
15855
15190
|
class SwitchStatement extends NodeBase {
|
|
15856
15191
|
createScope(parentScope) {
|
|
@@ -15933,8 +15268,6 @@ class SwitchStatement extends NodeBase {
|
|
|
15933
15268
|
}
|
|
15934
15269
|
}
|
|
15935
15270
|
}
|
|
15936
|
-
SwitchStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
15937
|
-
SwitchStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
15938
15271
|
|
|
15939
15272
|
class TaggedTemplateExpression extends CallExpressionBase {
|
|
15940
15273
|
bind() {
|
|
@@ -15958,8 +15291,8 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
15958
15291
|
this.tag.hasEffectsOnInteractionAtPath(EMPTY_PATH, this.interaction, context));
|
|
15959
15292
|
}
|
|
15960
15293
|
include(context, includeChildrenRecursively) {
|
|
15961
|
-
if (!this.
|
|
15962
|
-
this.
|
|
15294
|
+
if (!this.deoptimized)
|
|
15295
|
+
this.applyDeoptimizations();
|
|
15963
15296
|
if (includeChildrenRecursively) {
|
|
15964
15297
|
super.include(context, includeChildrenRecursively);
|
|
15965
15298
|
}
|
|
@@ -15968,7 +15301,7 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
15968
15301
|
this.tag.include(context, includeChildrenRecursively);
|
|
15969
15302
|
this.quasi.include(context, includeChildrenRecursively);
|
|
15970
15303
|
}
|
|
15971
|
-
this.tag.includeCallArguments(context, this.
|
|
15304
|
+
this.tag.includeCallArguments(context, this.args);
|
|
15972
15305
|
const [returnExpression] = this.getReturnExpression();
|
|
15973
15306
|
if (!returnExpression.included) {
|
|
15974
15307
|
returnExpression.include(context, false);
|
|
@@ -16003,7 +15336,6 @@ class TaggedTemplateExpression extends CallExpressionBase {
|
|
|
16003
15336
|
return this.returnExpression;
|
|
16004
15337
|
}
|
|
16005
15338
|
}
|
|
16006
|
-
TaggedTemplateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16007
15339
|
|
|
16008
15340
|
class TemplateElement extends NodeBase {
|
|
16009
15341
|
get tail() {
|
|
@@ -16017,13 +15349,15 @@ class TemplateElement extends NodeBase {
|
|
|
16017
15349
|
hasEffects() {
|
|
16018
15350
|
return false;
|
|
16019
15351
|
}
|
|
15352
|
+
include() {
|
|
15353
|
+
this.included = true;
|
|
15354
|
+
}
|
|
16020
15355
|
parseNode(esTreeNode) {
|
|
16021
15356
|
this.value = esTreeNode.value;
|
|
16022
15357
|
return super.parseNode(esTreeNode);
|
|
16023
15358
|
}
|
|
16024
15359
|
render() { }
|
|
16025
15360
|
}
|
|
16026
|
-
TemplateElement.prototype.includeNode = onlyIncludeSelf;
|
|
16027
15361
|
|
|
16028
15362
|
class TemplateLiteral extends NodeBase {
|
|
16029
15363
|
deoptimizeArgumentsOnInteractionAtPath() { }
|
|
@@ -16048,14 +15382,6 @@ class TemplateLiteral extends NodeBase {
|
|
|
16048
15382
|
}
|
|
16049
15383
|
return true;
|
|
16050
15384
|
}
|
|
16051
|
-
includeNode(context) {
|
|
16052
|
-
this.included = true;
|
|
16053
|
-
if (!this.deoptimized)
|
|
16054
|
-
this.applyDeoptimizations();
|
|
16055
|
-
for (const node of this.expressions) {
|
|
16056
|
-
node.includePath(UNKNOWN_PATH, context);
|
|
16057
|
-
}
|
|
16058
|
-
}
|
|
16059
15385
|
render(code, options) {
|
|
16060
15386
|
code.indentExclusionRanges.push([this.start, this.end]);
|
|
16061
15387
|
super.render(code, options);
|
|
@@ -16065,13 +15391,13 @@ class TemplateLiteral extends NodeBase {
|
|
|
16065
15391
|
class ModuleScope extends ChildScope {
|
|
16066
15392
|
constructor(parent, context) {
|
|
16067
15393
|
super(parent, context);
|
|
16068
|
-
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION,
|
|
15394
|
+
this.variables.set('this', new LocalVariable('this', null, UNDEFINED_EXPRESSION, context, 'other'));
|
|
16069
15395
|
}
|
|
16070
|
-
addDeclaration(identifier, context, init,
|
|
15396
|
+
addDeclaration(identifier, context, init, kind) {
|
|
16071
15397
|
if (this.context.module.importDescriptions.has(identifier.name)) {
|
|
16072
15398
|
context.error(parseAst_js.logRedeclarationError(identifier.name), identifier.start);
|
|
16073
15399
|
}
|
|
16074
|
-
return super.addDeclaration(identifier, context, init,
|
|
15400
|
+
return super.addDeclaration(identifier, context, init, kind);
|
|
16075
15401
|
}
|
|
16076
15402
|
addExportDefaultDeclaration(name, exportDefaultDeclaration, context) {
|
|
16077
15403
|
const variable = new ExportDefaultVariable(name, exportDefaultDeclaration, context);
|
|
@@ -16116,23 +15442,10 @@ class ThisExpression extends NodeBase {
|
|
|
16116
15442
|
}
|
|
16117
15443
|
return this.variable.hasEffectsOnInteractionAtPath(path, interaction, context);
|
|
16118
15444
|
}
|
|
16119
|
-
include(
|
|
16120
|
-
if (!this.included)
|
|
16121
|
-
this.includeNode(context);
|
|
16122
|
-
}
|
|
16123
|
-
includeNode(context) {
|
|
16124
|
-
this.included = true;
|
|
16125
|
-
if (!this.deoptimized)
|
|
16126
|
-
this.applyDeoptimizations();
|
|
16127
|
-
this.scope.context.includeVariableInModule(this.variable, EMPTY_PATH, context);
|
|
16128
|
-
}
|
|
16129
|
-
includePath(path, context) {
|
|
15445
|
+
include() {
|
|
16130
15446
|
if (!this.included) {
|
|
16131
15447
|
this.included = true;
|
|
16132
|
-
this.scope.context.includeVariableInModule(this.variable
|
|
16133
|
-
}
|
|
16134
|
-
else if (path.length > 0) {
|
|
16135
|
-
this.variable.includePath(path, context);
|
|
15448
|
+
this.scope.context.includeVariableInModule(this.variable);
|
|
16136
15449
|
}
|
|
16137
15450
|
}
|
|
16138
15451
|
initialise() {
|
|
@@ -16160,8 +15473,7 @@ class ThrowStatement extends NodeBase {
|
|
|
16160
15473
|
return true;
|
|
16161
15474
|
}
|
|
16162
15475
|
include(context, includeChildrenRecursively) {
|
|
16163
|
-
|
|
16164
|
-
this.includeNode(context);
|
|
15476
|
+
this.included = true;
|
|
16165
15477
|
this.argument.include(context, includeChildrenRecursively);
|
|
16166
15478
|
context.brokenFlow = true;
|
|
16167
15479
|
}
|
|
@@ -16172,7 +15484,6 @@ class ThrowStatement extends NodeBase {
|
|
|
16172
15484
|
}
|
|
16173
15485
|
}
|
|
16174
15486
|
}
|
|
16175
|
-
ThrowStatement.prototype.includeNode = onlyIncludeSelf;
|
|
16176
15487
|
|
|
16177
15488
|
class TryStatement extends NodeBase {
|
|
16178
15489
|
constructor() {
|
|
@@ -16209,8 +15520,6 @@ class TryStatement extends NodeBase {
|
|
|
16209
15520
|
this.finalizer?.include(context, includeChildrenRecursively);
|
|
16210
15521
|
}
|
|
16211
15522
|
}
|
|
16212
|
-
TryStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
16213
|
-
TryStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16214
15523
|
|
|
16215
15524
|
const unaryOperators = {
|
|
16216
15525
|
'!': value => !value,
|
|
@@ -16256,7 +15565,6 @@ class UnaryExpression extends NodeBase {
|
|
|
16256
15565
|
}
|
|
16257
15566
|
}
|
|
16258
15567
|
}
|
|
16259
|
-
UnaryExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16260
15568
|
|
|
16261
15569
|
class UpdateExpression extends NodeBase {
|
|
16262
15570
|
hasEffects(context) {
|
|
@@ -16268,8 +15576,9 @@ class UpdateExpression extends NodeBase {
|
|
|
16268
15576
|
return path.length > 1 || type !== INTERACTION_ACCESSED;
|
|
16269
15577
|
}
|
|
16270
15578
|
include(context, includeChildrenRecursively) {
|
|
16271
|
-
if (!this.
|
|
16272
|
-
this.
|
|
15579
|
+
if (!this.deoptimized)
|
|
15580
|
+
this.applyDeoptimizations();
|
|
15581
|
+
this.included = true;
|
|
16273
15582
|
this.argument.includeAsAssignmentTarget(context, includeChildrenRecursively, true);
|
|
16274
15583
|
}
|
|
16275
15584
|
initialise() {
|
|
@@ -16308,7 +15617,6 @@ class UpdateExpression extends NodeBase {
|
|
|
16308
15617
|
this.scope.context.requestTreeshakingPass();
|
|
16309
15618
|
}
|
|
16310
15619
|
}
|
|
16311
|
-
UpdateExpression.prototype.includeNode = onlyIncludeSelf;
|
|
16312
15620
|
|
|
16313
15621
|
function areAllDeclarationsIncludedAndNotExported(declarations, exportNamesByVariable) {
|
|
16314
15622
|
for (const declarator of declarations) {
|
|
@@ -16339,9 +15647,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
16339
15647
|
include(context, includeChildrenRecursively, { asSingleStatement } = parseAst_js.BLANK) {
|
|
16340
15648
|
this.included = true;
|
|
16341
15649
|
for (const declarator of this.declarations) {
|
|
16342
|
-
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
15650
|
+
if (includeChildrenRecursively || declarator.shouldBeIncluded(context))
|
|
16343
15651
|
declarator.include(context, includeChildrenRecursively);
|
|
16344
|
-
}
|
|
16345
15652
|
const { id, init } = declarator;
|
|
16346
15653
|
if (asSingleStatement) {
|
|
16347
15654
|
id.include(context, includeChildrenRecursively);
|
|
@@ -16379,6 +15686,7 @@ class VariableDeclaration extends NodeBase {
|
|
|
16379
15686
|
this.renderReplacedDeclarations(code, options);
|
|
16380
15687
|
}
|
|
16381
15688
|
}
|
|
15689
|
+
applyDeoptimizations() { }
|
|
16382
15690
|
renderDeclarationEnd(code, separatorString, lastSeparatorPos, actualContentEnd, renderedContentEnd, systemPatternExports, options) {
|
|
16383
15691
|
if (code.original.charCodeAt(this.end - 1) === 59 /*";"*/) {
|
|
16384
15692
|
code.remove(this.end - 1, this.end);
|
|
@@ -16421,7 +15729,8 @@ class VariableDeclaration extends NodeBase {
|
|
|
16421
15729
|
const singleSystemExport = gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregatedSystemExports);
|
|
16422
15730
|
for (const { node, start, separator, contentEnd, end } of separatedNodes) {
|
|
16423
15731
|
if (!node.included) {
|
|
16424
|
-
|
|
15732
|
+
code.remove(start, end);
|
|
15733
|
+
node.removeAnnotations(code);
|
|
16425
15734
|
continue;
|
|
16426
15735
|
}
|
|
16427
15736
|
node.render(code, options);
|
|
@@ -16491,8 +15800,6 @@ function gatherSystemExportsAndGetSingleExport(separatedNodes, options, aggregat
|
|
|
16491
15800
|
}
|
|
16492
15801
|
return singleSystemExport;
|
|
16493
15802
|
}
|
|
16494
|
-
VariableDeclaration.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
16495
|
-
VariableDeclaration.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16496
15803
|
|
|
16497
15804
|
class WhileStatement extends NodeBase {
|
|
16498
15805
|
hasEffects(context) {
|
|
@@ -16506,25 +15813,13 @@ class WhileStatement extends NodeBase {
|
|
|
16506
15813
|
includeLoopBody(context, this.body, includeChildrenRecursively);
|
|
16507
15814
|
}
|
|
16508
15815
|
}
|
|
16509
|
-
WhileStatement.prototype.includeNode = onlyIncludeSelfNoDeoptimize;
|
|
16510
|
-
WhileStatement.prototype.applyDeoptimizations = doNotDeoptimize;
|
|
16511
15816
|
|
|
16512
15817
|
class YieldExpression extends NodeBase {
|
|
16513
|
-
applyDeoptimizations() {
|
|
16514
|
-
this.deoptimized = true;
|
|
16515
|
-
this.argument?.deoptimizePath(UNKNOWN_PATH);
|
|
16516
|
-
}
|
|
16517
15818
|
hasEffects(context) {
|
|
16518
15819
|
if (!this.deoptimized)
|
|
16519
15820
|
this.applyDeoptimizations();
|
|
16520
15821
|
return !(context.ignore.returnYield && !this.argument?.hasEffects(context));
|
|
16521
15822
|
}
|
|
16522
|
-
includeNode(context) {
|
|
16523
|
-
this.included = true;
|
|
16524
|
-
if (!this.deoptimized)
|
|
16525
|
-
this.applyDeoptimizations();
|
|
16526
|
-
this.argument?.includePath(UNKNOWN_PATH, context);
|
|
16527
|
-
}
|
|
16528
15823
|
render(code, options) {
|
|
16529
15824
|
if (this.argument) {
|
|
16530
15825
|
this.argument.render(code, options, { preventASI: true });
|
|
@@ -16758,7 +16053,7 @@ const bufferParsers = [
|
|
|
16758
16053
|
const annotations = (node.annotations = parseAst_js.convertAnnotations(buffer[position + 1], buffer));
|
|
16759
16054
|
node.annotationNoSideEffects = annotations.some(comment => comment.type === 'noSideEffects');
|
|
16760
16055
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 2], buffer));
|
|
16761
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
16056
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16762
16057
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 3], buffer);
|
|
16763
16058
|
},
|
|
16764
16059
|
function assignmentExpression(node, position, buffer) {
|
|
@@ -16804,7 +16099,7 @@ const bufferParsers = [
|
|
|
16804
16099
|
const parameterPosition = buffer[position];
|
|
16805
16100
|
const parameter = (node.param =
|
|
16806
16101
|
parameterPosition === 0 ? null : convertNode(node, scope, parameterPosition, buffer));
|
|
16807
|
-
parameter?.declare('parameter',
|
|
16102
|
+
parameter?.declare('parameter', UNKNOWN_EXPRESSION);
|
|
16808
16103
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 1], buffer);
|
|
16809
16104
|
},
|
|
16810
16105
|
function chainExpression(node, position, buffer) {
|
|
@@ -16942,7 +16237,7 @@ const bufferParsers = [
|
|
|
16942
16237
|
node.id =
|
|
16943
16238
|
idPosition === 0 ? null : convertNode(node, scope.parent, idPosition, buffer);
|
|
16944
16239
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
16945
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
16240
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16946
16241
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
16947
16242
|
},
|
|
16948
16243
|
function functionExpression(node, position, buffer) {
|
|
@@ -16955,7 +16250,7 @@ const bufferParsers = [
|
|
|
16955
16250
|
const idPosition = buffer[position + 2];
|
|
16956
16251
|
node.id = idPosition === 0 ? null : convertNode(node, node.idScope, idPosition, buffer);
|
|
16957
16252
|
const parameters = (node.params = convertNodeList(node, scope, buffer[position + 3], buffer));
|
|
16958
|
-
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter',
|
|
16253
|
+
scope.addParameterVariables(parameters.map(parameter => parameter.declare('parameter', UNKNOWN_EXPRESSION)), parameters[parameters.length - 1] instanceof RestElement);
|
|
16959
16254
|
node.body = convertNode(node, scope.bodyScope, buffer[position + 4], buffer);
|
|
16960
16255
|
},
|
|
16961
16256
|
function identifier(node, position, buffer) {
|
|
@@ -17419,8 +16714,8 @@ class ExportShimVariable extends Variable {
|
|
|
17419
16714
|
super(MISSING_EXPORT_SHIM_VARIABLE);
|
|
17420
16715
|
this.module = module;
|
|
17421
16716
|
}
|
|
17422
|
-
|
|
17423
|
-
super.
|
|
16717
|
+
include() {
|
|
16718
|
+
super.include();
|
|
17424
16719
|
this.module.needsExportShim = true;
|
|
17425
16720
|
}
|
|
17426
16721
|
}
|
|
@@ -18111,15 +17406,16 @@ class Module {
|
|
|
18111
17406
|
markModuleAndImpureDependenciesAsExecuted(this);
|
|
18112
17407
|
this.graph.needsTreeshakingPass = true;
|
|
18113
17408
|
}
|
|
18114
|
-
const inclusionContext = createInclusionContext();
|
|
18115
17409
|
for (const exportName of this.exports.keys()) {
|
|
18116
17410
|
if (includeNamespaceMembers || exportName !== this.info.syntheticNamedExports) {
|
|
18117
17411
|
const variable = this.getVariableForExportName(exportName)[0];
|
|
18118
17412
|
if (!variable) {
|
|
18119
17413
|
return parseAst_js.error(parseAst_js.logMissingEntryExport(exportName, this.id));
|
|
18120
17414
|
}
|
|
18121
|
-
this.includeVariable(variable, UNKNOWN_PATH, inclusionContext);
|
|
18122
17415
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
17416
|
+
if (!variable.included) {
|
|
17417
|
+
this.includeVariable(variable);
|
|
17418
|
+
}
|
|
18123
17419
|
}
|
|
18124
17420
|
}
|
|
18125
17421
|
for (const name of this.getReexports()) {
|
|
@@ -18127,7 +17423,7 @@ class Module {
|
|
|
18127
17423
|
if (variable) {
|
|
18128
17424
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18129
17425
|
if (!variable.included) {
|
|
18130
|
-
this.includeVariable(variable
|
|
17426
|
+
this.includeVariable(variable);
|
|
18131
17427
|
}
|
|
18132
17428
|
if (variable instanceof ExternalVariable) {
|
|
18133
17429
|
variable.module.reexported = true;
|
|
@@ -18148,12 +17444,13 @@ class Module {
|
|
|
18148
17444
|
this.graph.needsTreeshakingPass = true;
|
|
18149
17445
|
}
|
|
18150
17446
|
let includeNamespaceMembers = false;
|
|
18151
|
-
const inclusionContext = createInclusionContext();
|
|
18152
17447
|
for (const name of names) {
|
|
18153
17448
|
const variable = this.getVariableForExportName(name)[0];
|
|
18154
17449
|
if (variable) {
|
|
18155
17450
|
variable.deoptimizePath(UNKNOWN_PATH);
|
|
18156
|
-
|
|
17451
|
+
if (!variable.included) {
|
|
17452
|
+
this.includeVariable(variable);
|
|
17453
|
+
}
|
|
18157
17454
|
}
|
|
18158
17455
|
if (!this.exports.has(name) && !this.reexportDescriptions.has(name)) {
|
|
18159
17456
|
includeNamespaceMembers = true;
|
|
@@ -18254,7 +17551,6 @@ class Module {
|
|
|
18254
17551
|
manualPureFunctions: this.graph.pureFunctions,
|
|
18255
17552
|
module: this,
|
|
18256
17553
|
moduleContext: this.context,
|
|
18257
|
-
newlyIncludedVariableInits: this.graph.newlyIncludedVariableInits,
|
|
18258
17554
|
options: this.options,
|
|
18259
17555
|
requestTreeshakingPass: () => (this.graph.needsTreeshakingPass = true),
|
|
18260
17556
|
traceExport: (name) => this.getVariableForExportName(name)[0],
|
|
@@ -18595,13 +17891,13 @@ class Module {
|
|
|
18595
17891
|
for (const module of [this, ...this.exportAllModules]) {
|
|
18596
17892
|
if (module instanceof ExternalModule) {
|
|
18597
17893
|
const [externalVariable] = module.getVariableForExportName('*');
|
|
18598
|
-
externalVariable.
|
|
17894
|
+
externalVariable.include();
|
|
18599
17895
|
this.includedImports.add(externalVariable);
|
|
18600
17896
|
externalNamespaces.add(externalVariable);
|
|
18601
17897
|
}
|
|
18602
17898
|
else if (module.info.syntheticNamedExports) {
|
|
18603
17899
|
const syntheticNamespace = module.getSyntheticNamespace();
|
|
18604
|
-
syntheticNamespace.
|
|
17900
|
+
syntheticNamespace.include();
|
|
18605
17901
|
this.includedImports.add(syntheticNamespace);
|
|
18606
17902
|
syntheticNamespaces.add(syntheticNamespace);
|
|
18607
17903
|
}
|
|
@@ -18611,9 +17907,7 @@ class Module {
|
|
|
18611
17907
|
includeDynamicImport(node) {
|
|
18612
17908
|
const resolution = this.dynamicImports.find(dynamicImport => dynamicImport.node === node).resolution;
|
|
18613
17909
|
if (resolution instanceof Module) {
|
|
18614
|
-
|
|
18615
|
-
resolution.includedDynamicImporters.push(this);
|
|
18616
|
-
}
|
|
17910
|
+
resolution.includedDynamicImporters.push(this);
|
|
18617
17911
|
const importedNames = this.options.treeshake
|
|
18618
17912
|
? node.getDeterministicImportedNames()
|
|
18619
17913
|
: undefined;
|
|
@@ -18625,15 +17919,15 @@ class Module {
|
|
|
18625
17919
|
}
|
|
18626
17920
|
}
|
|
18627
17921
|
}
|
|
18628
|
-
includeVariable(variable
|
|
18629
|
-
const
|
|
18630
|
-
variable.
|
|
18631
|
-
if (included) {
|
|
17922
|
+
includeVariable(variable) {
|
|
17923
|
+
const variableModule = variable.module;
|
|
17924
|
+
if (variable.included) {
|
|
18632
17925
|
if (variableModule instanceof Module && variableModule !== this) {
|
|
18633
17926
|
getAndExtendSideEffectModules(variable, this);
|
|
18634
17927
|
}
|
|
18635
17928
|
}
|
|
18636
17929
|
else {
|
|
17930
|
+
variable.include();
|
|
18637
17931
|
this.graph.needsTreeshakingPass = true;
|
|
18638
17932
|
if (variableModule instanceof Module) {
|
|
18639
17933
|
if (!variableModule.isExecuted) {
|
|
@@ -18650,8 +17944,8 @@ class Module {
|
|
|
18650
17944
|
}
|
|
18651
17945
|
}
|
|
18652
17946
|
}
|
|
18653
|
-
includeVariableInModule(variable
|
|
18654
|
-
this.includeVariable(variable
|
|
17947
|
+
includeVariableInModule(variable) {
|
|
17948
|
+
this.includeVariable(variable);
|
|
18655
17949
|
const variableModule = variable.module;
|
|
18656
17950
|
if (variableModule && variableModule !== this) {
|
|
18657
17951
|
this.includedImports.add(variable);
|
|
@@ -22154,11 +21448,10 @@ class Graph {
|
|
|
22154
21448
|
this.options = options;
|
|
22155
21449
|
this.astLru = flru(5);
|
|
22156
21450
|
this.cachedModules = new Map();
|
|
22157
|
-
this.deoptimizationTracker = new
|
|
21451
|
+
this.deoptimizationTracker = new PathTracker();
|
|
22158
21452
|
this.entryModules = [];
|
|
22159
21453
|
this.modulesById = new Map();
|
|
22160
21454
|
this.needsTreeshakingPass = false;
|
|
22161
|
-
this.newlyIncludedVariableInits = new Set();
|
|
22162
21455
|
this.phase = BuildPhase.LOAD_AND_PARSE;
|
|
22163
21456
|
this.scope = new GlobalScope();
|
|
22164
21457
|
this.watchFiles = Object.create(null);
|
|
@@ -22252,7 +21545,6 @@ class Graph {
|
|
|
22252
21545
|
}
|
|
22253
21546
|
if (this.options.treeshake) {
|
|
22254
21547
|
let treeshakingPass = 1;
|
|
22255
|
-
this.newlyIncludedVariableInits.clear();
|
|
22256
21548
|
do {
|
|
22257
21549
|
timeStart(`treeshaking pass ${treeshakingPass}`, 3);
|
|
22258
21550
|
this.needsTreeshakingPass = false;
|
|
@@ -22277,10 +21569,6 @@ class Graph {
|
|
|
22277
21569
|
}
|
|
22278
21570
|
}
|
|
22279
21571
|
}
|
|
22280
|
-
for (const entity of this.newlyIncludedVariableInits) {
|
|
22281
|
-
this.newlyIncludedVariableInits.delete(entity);
|
|
22282
|
-
entity.include(createInclusionContext(), false);
|
|
22283
|
-
}
|
|
22284
21572
|
timeEnd(`treeshaking pass ${treeshakingPass++}`, 3);
|
|
22285
21573
|
} while (this.needsTreeshakingPass);
|
|
22286
21574
|
}
|