@danielx/civet 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/browser.js +498 -330
- package/dist/main.js +600 -342
- package/dist/main.mjs +600 -342
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -555,6 +555,7 @@ __export(lib_civet_exports, {
|
|
|
555
555
|
maybeRefAssignment: () => maybeRefAssignment,
|
|
556
556
|
modifyString: () => modifyString,
|
|
557
557
|
negateCondition: () => negateCondition,
|
|
558
|
+
precedenceCustomDefault: () => precedenceCustomDefault,
|
|
558
559
|
precedenceStep: () => precedenceStep,
|
|
559
560
|
prepend: () => prepend,
|
|
560
561
|
processAssignmentDeclaration: () => processAssignmentDeclaration,
|
|
@@ -1650,6 +1651,15 @@ function gatherRecursiveAll(node, predicate) {
|
|
|
1650
1651
|
}
|
|
1651
1652
|
|
|
1652
1653
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
|
|
1654
|
+
var range = (start, end) => {
|
|
1655
|
+
const length = end - start;
|
|
1656
|
+
if (length <= 0) return [];
|
|
1657
|
+
const arr = Array(length);
|
|
1658
|
+
for (let i = 0; i < length; ++i) {
|
|
1659
|
+
arr[i] = i + start;
|
|
1660
|
+
}
|
|
1661
|
+
return arr;
|
|
1662
|
+
};
|
|
1653
1663
|
function makeRef(base = "ref", id = base) {
|
|
1654
1664
|
return {
|
|
1655
1665
|
type: "Ref",
|
|
@@ -1662,7 +1672,7 @@ function needsRef(expression, base = "ref") {
|
|
|
1662
1672
|
return;
|
|
1663
1673
|
}
|
|
1664
1674
|
if (Array.isArray(expression)) {
|
|
1665
|
-
const nonempty = (
|
|
1675
|
+
const nonempty = range(0, expression.length).filter((i) => !isWhitespaceOrEmpty(expression[i]));
|
|
1666
1676
|
if (nonempty.length === 1) {
|
|
1667
1677
|
let ref1;
|
|
1668
1678
|
if (ref1 = needsRef(expression[nonempty[0]], base)) {
|
|
@@ -1678,8 +1688,9 @@ function needsRef(expression, base = "ref") {
|
|
|
1678
1688
|
case "Ref":
|
|
1679
1689
|
case "Identifier":
|
|
1680
1690
|
case "Literal":
|
|
1681
|
-
case "Placeholder":
|
|
1691
|
+
case "Placeholder": {
|
|
1682
1692
|
return;
|
|
1693
|
+
}
|
|
1683
1694
|
}
|
|
1684
1695
|
return makeRef(base);
|
|
1685
1696
|
}
|
|
@@ -1709,10 +1720,34 @@ function maybeRefAssignment(exp, base = "ref") {
|
|
|
1709
1720
|
return { ref, ...makeRefAssignment(ref, exp) };
|
|
1710
1721
|
}
|
|
1711
1722
|
}
|
|
1723
|
+
function populateRefs(statements) {
|
|
1724
|
+
const refNodes = gatherRecursive(statements, ($) => $.type === "Ref");
|
|
1725
|
+
if (!refNodes.length) {
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
const ids = gatherRecursive(statements, ($1) => $1.type === "Identifier");
|
|
1729
|
+
const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
1730
|
+
for (let i1 = 0, len3 = refNodes.length; i1 < len3; i1++) {
|
|
1731
|
+
const ref = refNodes[i1];
|
|
1732
|
+
if (!(ref.type === "Ref")) {
|
|
1733
|
+
continue;
|
|
1734
|
+
}
|
|
1735
|
+
const { base } = ref;
|
|
1736
|
+
ref.type = "Identifier";
|
|
1737
|
+
let n = 0;
|
|
1738
|
+
let name = base;
|
|
1739
|
+
while (names.has(name)) {
|
|
1740
|
+
n++;
|
|
1741
|
+
name = `${base}${n}`;
|
|
1742
|
+
}
|
|
1743
|
+
names.add(name);
|
|
1744
|
+
ref.children = ref.names = [name];
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1712
1747
|
|
|
1713
1748
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
|
|
1714
1749
|
function adjustAtBindings(statements, asThis = false) {
|
|
1715
|
-
for (let ref1 = gatherRecursiveAll(statements, ($) =>
|
|
1750
|
+
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
1716
1751
|
const binding = ref1[i1];
|
|
1717
1752
|
const { ref } = binding;
|
|
1718
1753
|
if (asThis) {
|
|
@@ -1730,7 +1765,7 @@ function adjustAtBindings(statements, asThis = false) {
|
|
|
1730
1765
|
}
|
|
1731
1766
|
}
|
|
1732
1767
|
function adjustBindingElements(elements) {
|
|
1733
|
-
const names = elements.flatMap(($
|
|
1768
|
+
const names = elements.flatMap(($2) => $2.names || []);
|
|
1734
1769
|
const { length } = elements;
|
|
1735
1770
|
let blockPrefix, restIndex = -1, restCount = 0;
|
|
1736
1771
|
for (let i2 = 0, len1 = elements.length; i2 < len1; i2++) {
|
|
@@ -1788,16 +1823,40 @@ function adjustBindingElements(elements) {
|
|
|
1788
1823
|
length
|
|
1789
1824
|
};
|
|
1790
1825
|
}
|
|
1826
|
+
function gatherSubbindings(node, subbindings = []) {
|
|
1827
|
+
for (let ref2 = gatherRecursiveAll(node, ($) => $.subbinding != null), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
1828
|
+
const p = ref2[i3];
|
|
1829
|
+
const { subbinding } = p;
|
|
1830
|
+
subbindings.push(", ", subbinding);
|
|
1831
|
+
gatherSubbindings(subbinding, subbindings);
|
|
1832
|
+
}
|
|
1833
|
+
return subbindings;
|
|
1834
|
+
}
|
|
1835
|
+
function simplifyBindingProperties(node) {
|
|
1836
|
+
const results = [];
|
|
1837
|
+
for (let ref3 = gatherRecursiveAll(node, ($3) => $3.type === "BindingProperty"), i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
|
|
1838
|
+
const p = ref3[i4];
|
|
1839
|
+
const { name, value } = p;
|
|
1840
|
+
if (value?.type === "NamedBindingPattern" && value.binding === name) {
|
|
1841
|
+
const [ws] = p.children;
|
|
1842
|
+
results.push(p.children = [ws, name, p.delim]);
|
|
1843
|
+
} else {
|
|
1844
|
+
results.push(void 0);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
;
|
|
1848
|
+
return results;
|
|
1849
|
+
}
|
|
1791
1850
|
function gatherBindingCode(statements, opts) {
|
|
1792
1851
|
const thisAssignments = [];
|
|
1793
1852
|
const splices = [];
|
|
1794
1853
|
function insertRestSplices(s, p, thisAssignments2) {
|
|
1795
1854
|
let m;
|
|
1796
|
-
for (let
|
|
1855
|
+
for (let ref4 = gatherRecursiveAll(
|
|
1797
1856
|
s,
|
|
1798
1857
|
(n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding" || opts?.assignPins && (m = n.type, m === "PinPattern" || m === "PinProperty")
|
|
1799
|
-
),
|
|
1800
|
-
let n =
|
|
1858
|
+
), i5 = 0, len4 = ref4.length; i5 < len4; i5++) {
|
|
1859
|
+
let n = ref4[i5];
|
|
1801
1860
|
if (n.type === "AtBinding") {
|
|
1802
1861
|
const { ref } = n;
|
|
1803
1862
|
const { id } = ref;
|
|
@@ -1806,7 +1865,7 @@ function gatherBindingCode(statements, opts) {
|
|
|
1806
1865
|
}
|
|
1807
1866
|
if (opts?.assignPins) {
|
|
1808
1867
|
if (n.type === "PinProperty") {
|
|
1809
|
-
n.children = n.children.flatMap(($
|
|
1868
|
+
n.children = n.children.flatMap(($4) => $4 === n.name ? [n.name, ": ", n.value] : $4);
|
|
1810
1869
|
updateParentPointers(n);
|
|
1811
1870
|
n = n.value;
|
|
1812
1871
|
}
|
|
@@ -1828,8 +1887,8 @@ function gatherBindingCode(statements, opts) {
|
|
|
1828
1887
|
}
|
|
1829
1888
|
}
|
|
1830
1889
|
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
1831
|
-
for (let
|
|
1832
|
-
const id =
|
|
1890
|
+
for (let ref5 = n.names, i6 = 0, len5 = ref5.length; i6 < len5; i6++) {
|
|
1891
|
+
const id = ref5[i6];
|
|
1833
1892
|
thisAssignments2.push({
|
|
1834
1893
|
type: "AssignmentExpression",
|
|
1835
1894
|
children: [`this.${id} = `, id],
|
|
@@ -1847,8 +1906,8 @@ function gatherBindingCode(statements, opts) {
|
|
|
1847
1906
|
return [splices, thisAssignments];
|
|
1848
1907
|
}
|
|
1849
1908
|
function arrayElementHasTrailingComma(elementNode) {
|
|
1850
|
-
let
|
|
1851
|
-
const lastChild = (
|
|
1909
|
+
let ref6;
|
|
1910
|
+
const lastChild = (ref6 = elementNode.children)[ref6.length - 1];
|
|
1852
1911
|
return lastChild && lastChild[lastChild.length - 1]?.token === ",";
|
|
1853
1912
|
}
|
|
1854
1913
|
function gatherBindingPatternTypeSuffix(pattern) {
|
|
@@ -1859,9 +1918,9 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1859
1918
|
switch (pattern.type) {
|
|
1860
1919
|
case "ArrayBindingPattern": {
|
|
1861
1920
|
{
|
|
1862
|
-
const
|
|
1863
|
-
for (let
|
|
1864
|
-
const elem =
|
|
1921
|
+
const results1 = [];
|
|
1922
|
+
for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
|
|
1923
|
+
const elem = ref7[i7];
|
|
1865
1924
|
let { typeSuffix } = elem;
|
|
1866
1925
|
typeSuffix ??= elem.binding?.typeSuffix;
|
|
1867
1926
|
if (typeSuffix) {
|
|
@@ -1878,10 +1937,10 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1878
1937
|
} else {
|
|
1879
1938
|
typeElement[0] ??= "unknown";
|
|
1880
1939
|
}
|
|
1881
|
-
|
|
1940
|
+
results1.push(typeElement);
|
|
1882
1941
|
}
|
|
1883
1942
|
;
|
|
1884
|
-
const types =
|
|
1943
|
+
const types = results1;
|
|
1885
1944
|
if (count) {
|
|
1886
1945
|
const t = [": [", types, "]"];
|
|
1887
1946
|
pattern.typeSuffix = {
|
|
@@ -1898,9 +1957,9 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1898
1957
|
case "ObjectBindingPattern": {
|
|
1899
1958
|
{
|
|
1900
1959
|
let restType;
|
|
1901
|
-
const
|
|
1902
|
-
for (let
|
|
1903
|
-
const prop =
|
|
1960
|
+
const results2 = [];
|
|
1961
|
+
for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
|
|
1962
|
+
const prop = ref8[i8];
|
|
1904
1963
|
let { typeSuffix } = prop;
|
|
1905
1964
|
typeSuffix ??= prop.value?.typeSuffix;
|
|
1906
1965
|
if (typeSuffix) {
|
|
@@ -1914,12 +1973,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1914
1973
|
switch (prop.type) {
|
|
1915
1974
|
case "BindingProperty": {
|
|
1916
1975
|
const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
|
|
1917
|
-
|
|
1976
|
+
results2.push([...ws, prop.name, typeSuffix, prop.delim]);
|
|
1918
1977
|
break;
|
|
1919
1978
|
}
|
|
1920
1979
|
case "AtBindingProperty": {
|
|
1921
1980
|
const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
|
|
1922
|
-
|
|
1981
|
+
results2.push([...ws, prop.ref.id.replace(/^#/, ""), typeSuffix, prop.delim]);
|
|
1923
1982
|
break;
|
|
1924
1983
|
}
|
|
1925
1984
|
case "BindingRestProperty": {
|
|
@@ -1929,7 +1988,7 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1929
1988
|
}
|
|
1930
1989
|
}
|
|
1931
1990
|
;
|
|
1932
|
-
const types =
|
|
1991
|
+
const types = results2;
|
|
1933
1992
|
if (count) {
|
|
1934
1993
|
const t = ["{", types, "}"];
|
|
1935
1994
|
if (restType != null) {
|
|
@@ -3042,6 +3101,7 @@ function assignResults(node, collect) {
|
|
|
3042
3101
|
exp = exp.statement;
|
|
3043
3102
|
}
|
|
3044
3103
|
let ref6;
|
|
3104
|
+
let m1;
|
|
3045
3105
|
switch (exp.type) {
|
|
3046
3106
|
case "BreakStatement":
|
|
3047
3107
|
case "ContinueStatement":
|
|
@@ -3121,6 +3181,9 @@ function assignResults(node, collect) {
|
|
|
3121
3181
|
return;
|
|
3122
3182
|
}
|
|
3123
3183
|
case "PipelineExpression": {
|
|
3184
|
+
if (m1 = exp.children[1]?.type, m1 === "ReturnStatement" || m1 === "ThrowStatement") {
|
|
3185
|
+
return;
|
|
3186
|
+
}
|
|
3124
3187
|
const semi2 = exp.children.lastIndexOf(";");
|
|
3125
3188
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
3126
3189
|
exp.children.splice(semi2 + 1, 1 / 0, ...[collect(exp.children.slice(semi2 + 1))]);
|
|
@@ -3146,8 +3209,8 @@ function insertReturn(node) {
|
|
|
3146
3209
|
const last = node.expressions[node.expressions.length - 1];
|
|
3147
3210
|
insertReturn(last);
|
|
3148
3211
|
} else {
|
|
3149
|
-
let
|
|
3150
|
-
if (
|
|
3212
|
+
let m2;
|
|
3213
|
+
if (m2 = node.parent?.type, m2 === "CatchClause" || m2 === "WhenClause") {
|
|
3151
3214
|
node.expressions.push(["", wrapWithReturn(void 0, node)]);
|
|
3152
3215
|
}
|
|
3153
3216
|
}
|
|
@@ -3193,6 +3256,7 @@ function insertReturn(node) {
|
|
|
3193
3256
|
exp = exp.statement;
|
|
3194
3257
|
}
|
|
3195
3258
|
let ref11;
|
|
3259
|
+
let m3;
|
|
3196
3260
|
switch (exp.type) {
|
|
3197
3261
|
case "BreakStatement":
|
|
3198
3262
|
case "ContinueStatement":
|
|
@@ -3284,6 +3348,9 @@ function insertReturn(node) {
|
|
|
3284
3348
|
return;
|
|
3285
3349
|
}
|
|
3286
3350
|
case "PipelineExpression": {
|
|
3351
|
+
if (m3 = exp.children[1]?.type, m3 === "ReturnStatement" || m3 === "ThrowStatement") {
|
|
3352
|
+
return;
|
|
3353
|
+
}
|
|
3287
3354
|
const semi2 = exp.children.lastIndexOf(";");
|
|
3288
3355
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
3289
3356
|
exp.children.splice(semi2 + 1, 1 / 0, ...[wrapWithReturn(exp.children.slice(semi2 + 1))]);
|
|
@@ -3306,8 +3373,8 @@ function processBreakContinueWith(statement) {
|
|
|
3306
3373
|
)) {
|
|
3307
3374
|
if (control.with) {
|
|
3308
3375
|
if (control.label) {
|
|
3309
|
-
let
|
|
3310
|
-
if (!(
|
|
3376
|
+
let m4;
|
|
3377
|
+
if (!(m4 = statement.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "LabelledStatement" && "label" in m4 && typeof m4.label === "object" && m4.label != null && "name" in m4.label && m4.label.name === control.label.name)) {
|
|
3311
3378
|
continue;
|
|
3312
3379
|
}
|
|
3313
3380
|
} else {
|
|
@@ -3528,8 +3595,8 @@ function iterationDefaultBody(statement) {
|
|
|
3528
3595
|
const reduction = statement.type === "ForStatement" && statement.reduction;
|
|
3529
3596
|
function fillBlock(expression) {
|
|
3530
3597
|
let ref15;
|
|
3531
|
-
let
|
|
3532
|
-
if (
|
|
3598
|
+
let m5;
|
|
3599
|
+
if (m5 = (ref15 = block.expressions)[ref15.length - 1], Array.isArray(m5) && m5.length >= 2 && typeof m5[1] === "object" && m5[1] != null && "type" in m5[1] && m5[1].type === "EmptyStatement" && "implicit" in m5[1] && m5[1].implicit === true) {
|
|
3533
3600
|
block.expressions.pop();
|
|
3534
3601
|
}
|
|
3535
3602
|
block.expressions.push(expression);
|
|
@@ -3657,7 +3724,8 @@ function processParams(f) {
|
|
|
3657
3724
|
parameters.names.push(...rest.names || []);
|
|
3658
3725
|
rest.children.pop();
|
|
3659
3726
|
if (after.length) {
|
|
3660
|
-
|
|
3727
|
+
let m6;
|
|
3728
|
+
if (m6 = rest.binding.type, m6 === "ArrayBindingPattern" || m6 === "ObjectBindingPattern" || m6 === "NamedBindingPattern") {
|
|
3661
3729
|
parameters.parameters.push({
|
|
3662
3730
|
type: "Error",
|
|
3663
3731
|
message: "Non-end rest parameter cannot be binding pattern"
|
|
@@ -3789,6 +3857,9 @@ function processParams(f) {
|
|
|
3789
3857
|
injectParamProps: isConstructor,
|
|
3790
3858
|
assignPins: true
|
|
3791
3859
|
});
|
|
3860
|
+
const subbindings = gatherSubbindings(parameters.parameters);
|
|
3861
|
+
simplifyBindingProperties(parameters.parameters);
|
|
3862
|
+
simplifyBindingProperties(subbindings);
|
|
3792
3863
|
if (isConstructor) {
|
|
3793
3864
|
const { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
|
|
3794
3865
|
if (ancestor != null) {
|
|
@@ -3796,8 +3867,8 @@ function processParams(f) {
|
|
|
3796
3867
|
const classExpressions = ancestor.body.expressions;
|
|
3797
3868
|
let index2 = findChildIndex(classExpressions, f);
|
|
3798
3869
|
assert.notEqual(index2, -1, "Could not find constructor in class");
|
|
3799
|
-
let
|
|
3800
|
-
while (
|
|
3870
|
+
let m7;
|
|
3871
|
+
while (m7 = classExpressions[index2 - 1]?.[1], typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "MethodDefinition" && "name" in m7 && m7.name === "constructor") {
|
|
3801
3872
|
index2--;
|
|
3802
3873
|
}
|
|
3803
3874
|
const fStatement = classExpressions[index2];
|
|
@@ -3837,6 +3908,15 @@ function processParams(f) {
|
|
|
3837
3908
|
children: [";"]
|
|
3838
3909
|
};
|
|
3839
3910
|
let prefix = [];
|
|
3911
|
+
if (subbindings.length) {
|
|
3912
|
+
prefix.push(makeNode({
|
|
3913
|
+
type: "Declaration",
|
|
3914
|
+
children: ["const ", subbindings.slice(1)],
|
|
3915
|
+
names: subbindings.flatMap(($16) => $16.names ?? []),
|
|
3916
|
+
bindings: [],
|
|
3917
|
+
decl: "const"
|
|
3918
|
+
}));
|
|
3919
|
+
}
|
|
3840
3920
|
for (let ref20 = splices, i11 = 0, len10 = ref20.length; i11 < len10; i11++) {
|
|
3841
3921
|
const binding = ref20[i11];
|
|
3842
3922
|
assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
|
|
@@ -3890,7 +3970,7 @@ function processSignature(f) {
|
|
|
3890
3970
|
f.async.push("async ");
|
|
3891
3971
|
signature.modifier.async = true;
|
|
3892
3972
|
} else {
|
|
3893
|
-
for (let ref21 = gatherRecursiveWithinFunction(block, ($
|
|
3973
|
+
for (let ref21 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
|
|
3894
3974
|
const a = ref21[i12];
|
|
3895
3975
|
const i = findChildIndex(a.parent, a);
|
|
3896
3976
|
a.parent.children.splice(i + 1, 0, {
|
|
@@ -3905,9 +3985,9 @@ function processSignature(f) {
|
|
|
3905
3985
|
f.generator.push("*");
|
|
3906
3986
|
signature.modifier.generator = true;
|
|
3907
3987
|
} else {
|
|
3908
|
-
for (let ref22 = gatherRecursiveWithinFunction(block, ($
|
|
3988
|
+
for (let ref22 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
|
|
3909
3989
|
const y = ref22[i13];
|
|
3910
|
-
const i = y.children.findIndex(($
|
|
3990
|
+
const i = y.children.findIndex(($19) => $19.type === "Yield");
|
|
3911
3991
|
y.children.splice(i + 1, 0, {
|
|
3912
3992
|
type: "Error",
|
|
3913
3993
|
message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
|
|
@@ -3920,7 +4000,7 @@ function processSignature(f) {
|
|
|
3920
4000
|
}
|
|
3921
4001
|
}
|
|
3922
4002
|
function processFunctions(statements, config2) {
|
|
3923
|
-
for (let ref23 = gatherRecursiveAll(statements, ($
|
|
4003
|
+
for (let ref23 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
|
|
3924
4004
|
const f = ref23[i14];
|
|
3925
4005
|
if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
|
|
3926
4006
|
implicitFunctionBlock(f);
|
|
@@ -3990,7 +4070,7 @@ function expressionizeIteration(exp) {
|
|
|
3990
4070
|
}
|
|
3991
4071
|
}
|
|
3992
4072
|
function processIterationExpressions(statements) {
|
|
3993
|
-
for (let ref25 = gatherRecursiveAll(statements, ($
|
|
4073
|
+
for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
|
|
3994
4074
|
const s = ref25[i15];
|
|
3995
4075
|
expressionizeIteration(s);
|
|
3996
4076
|
}
|
|
@@ -4040,12 +4120,12 @@ function processCoffeeDo(ws, expression) {
|
|
|
4040
4120
|
const newParameters = {
|
|
4041
4121
|
...parameters,
|
|
4042
4122
|
parameters: newParameterList,
|
|
4043
|
-
children: parameters.children.map(($
|
|
4123
|
+
children: parameters.children.map(($22) => $22 === parameterList ? newParameterList : $22)
|
|
4044
4124
|
};
|
|
4045
4125
|
expression = {
|
|
4046
4126
|
...expression,
|
|
4047
4127
|
parameters: newParameters,
|
|
4048
|
-
children: expression.children.map(($
|
|
4128
|
+
children: expression.children.map(($23) => $23 === parameters ? newParameters : $23)
|
|
4049
4129
|
};
|
|
4050
4130
|
}
|
|
4051
4131
|
return {
|
|
@@ -4067,7 +4147,7 @@ function makeAmpersandFunction(rhs) {
|
|
|
4067
4147
|
ref = makeRef("$");
|
|
4068
4148
|
inplacePrepend(ref, body);
|
|
4069
4149
|
}
|
|
4070
|
-
if (startsWithPredicate(body, ($
|
|
4150
|
+
if (startsWithPredicate(body, ($24) => $24.type === "ObjectExpression")) {
|
|
4071
4151
|
body = makeLeftHandSideExpression(body);
|
|
4072
4152
|
}
|
|
4073
4153
|
const parameterList = [
|
|
@@ -4863,17 +4943,15 @@ function getPatternConditions(pattern, ref, conditions = []) {
|
|
|
4863
4943
|
break;
|
|
4864
4944
|
}
|
|
4865
4945
|
case "ConditionFragment": {
|
|
4866
|
-
let {
|
|
4867
|
-
if (
|
|
4868
|
-
let [first, ...rest] =
|
|
4946
|
+
let { rhs } = pattern;
|
|
4947
|
+
if (rhs.length) {
|
|
4948
|
+
let [first, ...rest] = rhs;
|
|
4869
4949
|
let [ws, ...op] = first;
|
|
4870
4950
|
ws = [" "].concat(ws);
|
|
4871
4951
|
first = [ws, ...op];
|
|
4872
|
-
|
|
4952
|
+
rhs = [first, ...rest];
|
|
4873
4953
|
}
|
|
4874
|
-
conditions.push(
|
|
4875
|
-
processBinaryOpExpression([ref, children])
|
|
4876
|
-
);
|
|
4954
|
+
conditions.push(processBinaryOpExpression([ref, rhs]));
|
|
4877
4955
|
break;
|
|
4878
4956
|
}
|
|
4879
4957
|
case "RegularExpressionLiteral": {
|
|
@@ -4891,6 +4969,10 @@ function getPatternConditions(pattern, ref, conditions = []) {
|
|
|
4891
4969
|
]);
|
|
4892
4970
|
break;
|
|
4893
4971
|
}
|
|
4972
|
+
case "NamedBindingPattern": {
|
|
4973
|
+
getPatternConditions(pattern.pattern, ref, conditions);
|
|
4974
|
+
break;
|
|
4975
|
+
}
|
|
4894
4976
|
case "Literal": {
|
|
4895
4977
|
conditions.push([
|
|
4896
4978
|
ref,
|
|
@@ -4920,43 +5002,60 @@ function getPatternBlockPrefix(pattern, ref, decl = "const ", typeSuffix) {
|
|
|
4920
5002
|
}
|
|
4921
5003
|
case "Literal":
|
|
4922
5004
|
case "RegularExpressionLiteral":
|
|
4923
|
-
case "PinPattern":
|
|
4924
|
-
case "ConditionFragment": {
|
|
5005
|
+
case "PinPattern": {
|
|
4925
5006
|
return;
|
|
4926
5007
|
}
|
|
5008
|
+
case "ConditionFragment": {
|
|
5009
|
+
if (!pattern.binding) {
|
|
5010
|
+
return;
|
|
5011
|
+
}
|
|
5012
|
+
;
|
|
5013
|
+
break;
|
|
5014
|
+
}
|
|
4927
5015
|
}
|
|
4928
5016
|
let [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
4929
5017
|
const patternBindings2 = nonMatcherBindings(pattern);
|
|
4930
|
-
const
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
;
|
|
4936
|
-
const
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
5018
|
+
const subbindings = gatherSubbindings(patternBindings2);
|
|
5019
|
+
simplifyBindingProperties(patternBindings2);
|
|
5020
|
+
simplifyBindingProperties(subbindings);
|
|
5021
|
+
splices = splices.flatMap((s) => [", ", nonMatcherBindings(s)]);
|
|
5022
|
+
thisAssignments = thisAssignments.map(($7) => ["", $7, ";"]);
|
|
5023
|
+
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices, subbindings]);
|
|
5024
|
+
const blockPrefix = [];
|
|
5025
|
+
if (ref || subbindings.length || splices.length) {
|
|
5026
|
+
const children = [decl];
|
|
5027
|
+
if (ref) {
|
|
5028
|
+
children.push(patternBindings2, typeSuffix, " = ", ref);
|
|
5029
|
+
}
|
|
5030
|
+
children.push(...subbindings);
|
|
5031
|
+
children.push(...splices);
|
|
5032
|
+
if (!ref) {
|
|
5033
|
+
children.splice(1, 1);
|
|
5034
|
+
}
|
|
5035
|
+
blockPrefix.push(["", {
|
|
4942
5036
|
type: "Declaration",
|
|
4943
|
-
children
|
|
5037
|
+
children,
|
|
5038
|
+
decl,
|
|
4944
5039
|
names: [],
|
|
4945
5040
|
bindings: []
|
|
4946
5041
|
// avoid implicit return of any bindings
|
|
4947
|
-
}, ";"]
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
];
|
|
5042
|
+
}, ";"]);
|
|
5043
|
+
}
|
|
5044
|
+
blockPrefix.push(...thisAssignments);
|
|
5045
|
+
blockPrefix.push(...duplicateDeclarations.map(($8) => ["", $8, ";"]));
|
|
5046
|
+
if (!blockPrefix.length) {
|
|
5047
|
+
return;
|
|
5048
|
+
}
|
|
5049
|
+
return blockPrefix;
|
|
4951
5050
|
}
|
|
4952
5051
|
function elideMatchersFromArrayBindings(elements) {
|
|
4953
|
-
const
|
|
4954
|
-
for (let
|
|
4955
|
-
const element = elements[
|
|
5052
|
+
const results = [];
|
|
5053
|
+
for (let i5 = 0, len4 = elements.length; i5 < len4; i5++) {
|
|
5054
|
+
const element = elements[i5];
|
|
4956
5055
|
switch (element.type) {
|
|
4957
5056
|
case "BindingRestElement":
|
|
4958
5057
|
case "ElisionElement": {
|
|
4959
|
-
|
|
5058
|
+
results.push(element);
|
|
4960
5059
|
break;
|
|
4961
5060
|
}
|
|
4962
5061
|
case "BindingElement": {
|
|
@@ -4965,12 +5064,12 @@ function elideMatchersFromArrayBindings(elements) {
|
|
|
4965
5064
|
case "RegularExpressionLiteral":
|
|
4966
5065
|
case "StringLiteral":
|
|
4967
5066
|
case "PinPattern": {
|
|
4968
|
-
|
|
5067
|
+
results.push(element.delim);
|
|
4969
5068
|
break;
|
|
4970
5069
|
}
|
|
4971
5070
|
default: {
|
|
4972
5071
|
const binding = nonMatcherBindings(element.binding);
|
|
4973
|
-
|
|
5072
|
+
results.push(makeNode({
|
|
4974
5073
|
...element,
|
|
4975
5074
|
binding,
|
|
4976
5075
|
children: element.children.map((c) => {
|
|
@@ -4985,29 +5084,23 @@ function elideMatchersFromArrayBindings(elements) {
|
|
|
4985
5084
|
}
|
|
4986
5085
|
}
|
|
4987
5086
|
;
|
|
4988
|
-
return
|
|
5087
|
+
return results;
|
|
4989
5088
|
}
|
|
4990
5089
|
function elideMatchersFromPropertyBindings(properties) {
|
|
4991
|
-
const
|
|
4992
|
-
for (let
|
|
4993
|
-
const p = properties[
|
|
5090
|
+
const results1 = [];
|
|
5091
|
+
for (let i6 = 0, len5 = properties.length; i6 < len5; i6++) {
|
|
5092
|
+
const p = properties[i6];
|
|
4994
5093
|
switch (p.type) {
|
|
4995
5094
|
case "BindingProperty":
|
|
4996
5095
|
case "PinProperty": {
|
|
4997
|
-
const { children, name, value
|
|
5096
|
+
const { children, name, value } = p;
|
|
4998
5097
|
const [ws] = children;
|
|
4999
5098
|
const shouldElide = name.type === "NumericLiteral" && !value?.name || name.type === "ComputedPropertyName" && value?.subtype === "NumericLiteral";
|
|
5000
5099
|
if (shouldElide) {
|
|
5001
|
-
|
|
5002
|
-
results2.push({
|
|
5003
|
-
type: "Error",
|
|
5004
|
-
message: `Cannot bind ${name.type}`
|
|
5005
|
-
});
|
|
5006
|
-
} else {
|
|
5007
|
-
continue;
|
|
5008
|
-
}
|
|
5100
|
+
continue;
|
|
5009
5101
|
} else {
|
|
5010
5102
|
let contents;
|
|
5103
|
+
let m1;
|
|
5011
5104
|
switch (value?.type) {
|
|
5012
5105
|
case "ArrayBindingPattern":
|
|
5013
5106
|
case "ObjectBindingPattern": {
|
|
@@ -5024,22 +5117,28 @@ function elideMatchersFromPropertyBindings(properties) {
|
|
|
5024
5117
|
contents = p;
|
|
5025
5118
|
break;
|
|
5026
5119
|
}
|
|
5120
|
+
case "NamedBindingPattern": {
|
|
5121
|
+
const bindings = nonMatcherBindings(value.pattern);
|
|
5122
|
+
contents = {
|
|
5123
|
+
...p,
|
|
5124
|
+
subbinding: (m1 = bindings?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern" || m1 === "Identifier") ? [
|
|
5125
|
+
bindings,
|
|
5126
|
+
" = ",
|
|
5127
|
+
name
|
|
5128
|
+
] : void 0
|
|
5129
|
+
};
|
|
5130
|
+
if (p.name === value.binding) {
|
|
5131
|
+
contents.children = [ws, name, p.delim];
|
|
5132
|
+
}
|
|
5133
|
+
;
|
|
5134
|
+
break;
|
|
5135
|
+
}
|
|
5027
5136
|
default: {
|
|
5028
5137
|
contents = void 0;
|
|
5029
5138
|
}
|
|
5030
5139
|
}
|
|
5031
|
-
if (
|
|
5032
|
-
|
|
5033
|
-
...p,
|
|
5034
|
-
children: [ws, name, p.delim],
|
|
5035
|
-
subbinding: contents?.value ? [
|
|
5036
|
-
contents.value,
|
|
5037
|
-
" = ",
|
|
5038
|
-
name
|
|
5039
|
-
] : void 0
|
|
5040
|
-
});
|
|
5041
|
-
} else if (contents) {
|
|
5042
|
-
results2.push(contents);
|
|
5140
|
+
if (contents) {
|
|
5141
|
+
results1.push(contents);
|
|
5043
5142
|
} else {
|
|
5044
5143
|
continue;
|
|
5045
5144
|
}
|
|
@@ -5048,14 +5147,15 @@ function elideMatchersFromPropertyBindings(properties) {
|
|
|
5048
5147
|
break;
|
|
5049
5148
|
}
|
|
5050
5149
|
default: {
|
|
5051
|
-
|
|
5150
|
+
results1.push(p);
|
|
5052
5151
|
}
|
|
5053
5152
|
}
|
|
5054
5153
|
}
|
|
5055
5154
|
;
|
|
5056
|
-
return
|
|
5155
|
+
return results1;
|
|
5057
5156
|
}
|
|
5058
5157
|
function nonMatcherBindings(pattern) {
|
|
5158
|
+
let m2;
|
|
5059
5159
|
switch (pattern.type) {
|
|
5060
5160
|
case "ArrayBindingPattern":
|
|
5061
5161
|
case "PostRestBindingElements": {
|
|
@@ -5063,7 +5163,7 @@ function nonMatcherBindings(pattern) {
|
|
|
5063
5163
|
return makeNode({
|
|
5064
5164
|
...pattern,
|
|
5065
5165
|
elements,
|
|
5066
|
-
children: pattern.children.map(($
|
|
5166
|
+
children: pattern.children.map(($9) => $9 === pattern.elements ? elements : $9)
|
|
5067
5167
|
});
|
|
5068
5168
|
}
|
|
5069
5169
|
case "ObjectBindingPattern": {
|
|
@@ -5071,9 +5171,19 @@ function nonMatcherBindings(pattern) {
|
|
|
5071
5171
|
return makeNode({
|
|
5072
5172
|
...pattern,
|
|
5073
5173
|
properties,
|
|
5074
|
-
children: pattern.children.map(($
|
|
5174
|
+
children: pattern.children.map(($10) => $10 === pattern.properties ? properties : $10)
|
|
5075
5175
|
});
|
|
5076
5176
|
}
|
|
5177
|
+
case "NamedBindingPattern": {
|
|
5178
|
+
const bindings = nonMatcherBindings(pattern.pattern);
|
|
5179
|
+
return makeNode({
|
|
5180
|
+
...pattern,
|
|
5181
|
+
subbinding: (m2 = bindings?.type, m2 === "ArrayBindingPattern" || m2 === "ObjectBindingPattern" || m2 === "Identifier") ? [bindings, " = ", pattern.binding] : void 0
|
|
5182
|
+
});
|
|
5183
|
+
}
|
|
5184
|
+
case "ConditionFragment": {
|
|
5185
|
+
return pattern.binding;
|
|
5186
|
+
}
|
|
5077
5187
|
default: {
|
|
5078
5188
|
return pattern;
|
|
5079
5189
|
}
|
|
@@ -5089,11 +5199,11 @@ function aggregateDuplicateBindings(bindings) {
|
|
|
5089
5199
|
);
|
|
5090
5200
|
const declarations = [];
|
|
5091
5201
|
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
5092
|
-
for (let
|
|
5093
|
-
const p = props[
|
|
5202
|
+
for (let i7 = 0, len6 = props.length; i7 < len6; i7++) {
|
|
5203
|
+
const p = props[i7];
|
|
5094
5204
|
const { name, value } = p;
|
|
5095
|
-
let
|
|
5096
|
-
if (
|
|
5205
|
+
let m3;
|
|
5206
|
+
if (m3 = value?.type, m3 === "ArrayBindingPattern" || m3 === "ObjectBindingPattern") {
|
|
5097
5207
|
continue;
|
|
5098
5208
|
}
|
|
5099
5209
|
const key = value?.name || name?.name || name;
|
|
@@ -5115,8 +5225,8 @@ function aggregateDuplicateBindings(bindings) {
|
|
|
5115
5225
|
pos: 0,
|
|
5116
5226
|
input: key
|
|
5117
5227
|
})) {
|
|
5118
|
-
for (let
|
|
5119
|
-
const p = shared[
|
|
5228
|
+
for (let i8 = 0, len7 = shared.length; i8 < len7; i8++) {
|
|
5229
|
+
const p = shared[i8];
|
|
5120
5230
|
aliasBinding(p, makeRef(`_${key}`, key));
|
|
5121
5231
|
}
|
|
5122
5232
|
return;
|
|
@@ -5208,8 +5318,18 @@ function processDeclarations(statements) {
|
|
|
5208
5318
|
if (!(bindings != null)) {
|
|
5209
5319
|
continue;
|
|
5210
5320
|
}
|
|
5211
|
-
for (let i2 =
|
|
5212
|
-
const
|
|
5321
|
+
for (let i2 = bindings.length + -1; i2 >= 0; --i2) {
|
|
5322
|
+
const i = i2;
|
|
5323
|
+
const binding = bindings[i];
|
|
5324
|
+
const subbindings = gatherSubbindings(binding);
|
|
5325
|
+
if (subbindings.length) {
|
|
5326
|
+
simplifyBindingProperties(binding);
|
|
5327
|
+
simplifyBindingProperties(subbindings);
|
|
5328
|
+
spliceChild(declaration, binding, 1, binding, subbindings);
|
|
5329
|
+
}
|
|
5330
|
+
}
|
|
5331
|
+
for (let i3 = 0, len22 = bindings.length; i3 < len22; i3++) {
|
|
5332
|
+
const binding = bindings[i3];
|
|
5213
5333
|
let { typeSuffix, initializer } = binding;
|
|
5214
5334
|
if (typeSuffix && typeSuffix.optional) {
|
|
5215
5335
|
if (initializer && !typeSuffix.t) {
|
|
@@ -5247,6 +5367,25 @@ function processDeclarations(statements) {
|
|
|
5247
5367
|
}
|
|
5248
5368
|
}
|
|
5249
5369
|
}
|
|
5370
|
+
for (let ref2 = gatherRecursiveAll(statements, ($1) => $1.type === "ForStatement"), i4 = 0, len3 = ref2.length; i4 < len3; i4++) {
|
|
5371
|
+
const statement = ref2[i4];
|
|
5372
|
+
const { declaration } = statement;
|
|
5373
|
+
if (!(declaration?.type === "ForDeclaration")) {
|
|
5374
|
+
continue;
|
|
5375
|
+
}
|
|
5376
|
+
const { binding } = declaration;
|
|
5377
|
+
const blockPrefix = getPatternBlockPrefix(
|
|
5378
|
+
binding.pattern,
|
|
5379
|
+
void 0,
|
|
5380
|
+
append(declaration.decl, " "),
|
|
5381
|
+
binding.typeSuffix
|
|
5382
|
+
);
|
|
5383
|
+
simplifyBindingProperties(binding);
|
|
5384
|
+
if (blockPrefix != null) {
|
|
5385
|
+
statement.block.expressions.unshift(...blockPrefix);
|
|
5386
|
+
braceBlock(statement.block);
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5250
5389
|
}
|
|
5251
5390
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
5252
5391
|
let { expression: exp } = initializer;
|
|
@@ -5390,8 +5529,7 @@ function processDeclarationConditionStatement(s) {
|
|
|
5390
5529
|
}
|
|
5391
5530
|
let { expression } = condition;
|
|
5392
5531
|
if (expression && typeof expression === "object" && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && len2(expression.children, 2) && Array.isArray(expression.children[0]) && len2(expression.children[0], 1) && expression.children[0][0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
|
|
5393
|
-
const {
|
|
5394
|
-
const type = [type1, type2];
|
|
5532
|
+
const { children: [[], { expression: expression2 }] } = expression;
|
|
5395
5533
|
expression = expression2;
|
|
5396
5534
|
}
|
|
5397
5535
|
processDeclarationCondition(expression, condition.expression, s);
|
|
@@ -5416,8 +5554,8 @@ function processDeclarationConditionStatement(s) {
|
|
|
5416
5554
|
({ children } = condition.expression.children[1]);
|
|
5417
5555
|
}
|
|
5418
5556
|
children.unshift("(");
|
|
5419
|
-
for (let
|
|
5420
|
-
const c = conditions[
|
|
5557
|
+
for (let i5 = 0, len4 = conditions.length; i5 < len4; i5++) {
|
|
5558
|
+
const c = conditions[i5];
|
|
5421
5559
|
children.push(" && ", c);
|
|
5422
5560
|
}
|
|
5423
5561
|
children.push(")");
|
|
@@ -5439,11 +5577,11 @@ function processDeclarationConditionStatement(s) {
|
|
|
5439
5577
|
ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
|
|
5440
5578
|
updateParentPointers(ancestor);
|
|
5441
5579
|
braceBlock(ancestor);
|
|
5442
|
-
let
|
|
5580
|
+
let ref3;
|
|
5443
5581
|
switch (s.type) {
|
|
5444
5582
|
case "IfStatement": {
|
|
5445
|
-
if (
|
|
5446
|
-
const elseBlock =
|
|
5583
|
+
if (ref3 = s.else?.block) {
|
|
5584
|
+
const elseBlock = ref3;
|
|
5447
5585
|
if (elseBlock.bare && !elseBlock.semicolon) {
|
|
5448
5586
|
elseBlock.children.push(elseBlock.semicolon = ";");
|
|
5449
5587
|
}
|
|
@@ -5467,13 +5605,13 @@ function processDeclarationConditionStatement(s) {
|
|
|
5467
5605
|
if (s.negated) {
|
|
5468
5606
|
if (e != null) {
|
|
5469
5607
|
const block = blockWithPrefix(blockPrefix, e.block);
|
|
5470
|
-
e.children = e.children.map(($
|
|
5608
|
+
e.children = e.children.map(($2) => $2 === e.block ? block : $2);
|
|
5471
5609
|
e.block = block;
|
|
5472
5610
|
updateParentPointers(e);
|
|
5473
5611
|
}
|
|
5474
5612
|
} else {
|
|
5475
5613
|
const block = blockWithPrefix(blockPrefix, s.then);
|
|
5476
|
-
s.children = s.children.map(($
|
|
5614
|
+
s.children = s.children.map(($3) => $3 === s.then ? block : $3);
|
|
5477
5615
|
s.then = block;
|
|
5478
5616
|
updateParentPointers(s);
|
|
5479
5617
|
}
|
|
@@ -5486,7 +5624,7 @@ function processDeclarationConditionStatement(s) {
|
|
|
5486
5624
|
}
|
|
5487
5625
|
const { children, block } = s;
|
|
5488
5626
|
const newBlock = blockWithPrefix(blockPrefix, block);
|
|
5489
|
-
s.children = children.map(($
|
|
5627
|
+
s.children = children.map(($4) => $4 === block ? newBlock : $4);
|
|
5490
5628
|
updateParentPointers(s);
|
|
5491
5629
|
break;
|
|
5492
5630
|
}
|
|
@@ -5514,7 +5652,7 @@ function processDeclarationConditionStatement(s) {
|
|
|
5514
5652
|
const block = makeEmptyBlock();
|
|
5515
5653
|
replaceBlockExpression(s.parent, s, block);
|
|
5516
5654
|
block.expressions.push(["", s]);
|
|
5517
|
-
s.children.splice(s.children.findIndex(($
|
|
5655
|
+
s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
|
|
5518
5656
|
s.parent = block;
|
|
5519
5657
|
} else {
|
|
5520
5658
|
const block = blockWithPrefix([["", [{
|
|
@@ -5534,12 +5672,12 @@ function processDeclarationConditionStatement(s) {
|
|
|
5534
5672
|
function dynamizeFromClause(from) {
|
|
5535
5673
|
from = from.slice(1);
|
|
5536
5674
|
from = trimFirstSpace(from);
|
|
5537
|
-
let
|
|
5538
|
-
if (
|
|
5539
|
-
const assert2 =
|
|
5540
|
-
let
|
|
5541
|
-
|
|
5542
|
-
|
|
5675
|
+
let ref4;
|
|
5676
|
+
if (ref4 = from[from.length - 1]?.assertion) {
|
|
5677
|
+
const assert2 = ref4;
|
|
5678
|
+
let ref5;
|
|
5679
|
+
ref5 = from[from.length - 1];
|
|
5680
|
+
ref5.children = ref5.children.filter((a2) => a2 !== assert2);
|
|
5543
5681
|
from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
5544
5682
|
}
|
|
5545
5683
|
return ["(", ...from, ")"];
|
|
@@ -5548,20 +5686,20 @@ function dynamizeImportDeclaration(decl) {
|
|
|
5548
5686
|
const { imports } = decl;
|
|
5549
5687
|
let { star, binding, specifiers } = imports;
|
|
5550
5688
|
const justDefault = binding && !specifiers && !star;
|
|
5551
|
-
let
|
|
5689
|
+
let ref6;
|
|
5552
5690
|
{
|
|
5553
5691
|
if (binding) {
|
|
5554
5692
|
if (specifiers) {
|
|
5555
|
-
|
|
5693
|
+
ref6 = makeRef();
|
|
5556
5694
|
} else {
|
|
5557
|
-
|
|
5695
|
+
ref6 = binding;
|
|
5558
5696
|
}
|
|
5559
5697
|
} else {
|
|
5560
|
-
|
|
5698
|
+
ref6 = convertNamedImportsToObject(imports, true);
|
|
5561
5699
|
}
|
|
5562
5700
|
}
|
|
5563
5701
|
;
|
|
5564
|
-
const pattern =
|
|
5702
|
+
const pattern = ref6;
|
|
5565
5703
|
const c = "const";
|
|
5566
5704
|
const expression = [
|
|
5567
5705
|
justDefault ? "(" : void 0,
|
|
@@ -5826,7 +5964,7 @@ function processUnaryNestedExpression(pre, args, post) {
|
|
|
5826
5964
|
children: args.children.map(
|
|
5827
5965
|
(arg) => {
|
|
5828
5966
|
if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
|
|
5829
|
-
const {
|
|
5967
|
+
const { expression: exp, children } = arg;
|
|
5830
5968
|
let expression = processUnaryExpression([last], trimFirstSpace(exp));
|
|
5831
5969
|
expression = prepend(getTrimmingSpace(exp), expression);
|
|
5832
5970
|
return {
|
|
@@ -5887,9 +6025,8 @@ function constructInvocation(fn, arg) {
|
|
|
5887
6025
|
if (lhs.type === "NewExpression") {
|
|
5888
6026
|
let { expression } = lhs;
|
|
5889
6027
|
expression = {
|
|
5890
|
-
...expression,
|
|
5891
6028
|
type: "CallExpression",
|
|
5892
|
-
children: [
|
|
6029
|
+
children: [expression, call]
|
|
5893
6030
|
};
|
|
5894
6031
|
return {
|
|
5895
6032
|
...lhs,
|
|
@@ -5942,23 +6079,22 @@ function constructPipeStep(fn, arg, returning) {
|
|
|
5942
6079
|
];
|
|
5943
6080
|
}
|
|
5944
6081
|
function processPipelineExpressions(statements) {
|
|
5945
|
-
gatherRecursiveAll(statements, (
|
|
6082
|
+
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "PipelineExpression"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
6083
|
+
const s = ref1[i1];
|
|
5946
6084
|
const [ws, , body] = s.children;
|
|
5947
6085
|
let [, arg] = s.children;
|
|
5948
|
-
let i = 0;
|
|
5949
|
-
const l = body.length;
|
|
5950
6086
|
const children = [ws];
|
|
5951
6087
|
const comma = blockContainingStatement(s) ? ";" : ",";
|
|
5952
6088
|
let usingRef = null;
|
|
5953
|
-
for (let
|
|
5954
|
-
const
|
|
5955
|
-
const step = body[
|
|
6089
|
+
for (let i2 = 0, len1 = body.length; i2 < len1; i2++) {
|
|
6090
|
+
const i = i2;
|
|
6091
|
+
const step = body[i2];
|
|
5956
6092
|
const [leadingComment, pipe, trailingComment, expr] = step;
|
|
5957
6093
|
const returns = pipe.token === "||>";
|
|
5958
6094
|
let ref, result, returning = returns ? arg : null;
|
|
5959
6095
|
if (pipe.token === "|>=") {
|
|
5960
6096
|
let initRef;
|
|
5961
|
-
if (
|
|
6097
|
+
if (i === 0) {
|
|
5962
6098
|
checkValidLHS(arg);
|
|
5963
6099
|
outer: switch (arg.type) {
|
|
5964
6100
|
case "MemberExpression": {
|
|
@@ -6007,7 +6143,7 @@ function processPipelineExpressions(statements) {
|
|
|
6007
6143
|
});
|
|
6008
6144
|
}
|
|
6009
6145
|
} else {
|
|
6010
|
-
if (
|
|
6146
|
+
if (i === 0) s.children = children;
|
|
6011
6147
|
}
|
|
6012
6148
|
if (returns && (ref = needsRef(arg))) {
|
|
6013
6149
|
usingRef = usingRef || ref;
|
|
@@ -6031,7 +6167,7 @@ function processPipelineExpressions(statements) {
|
|
|
6031
6167
|
returning
|
|
6032
6168
|
);
|
|
6033
6169
|
if (result.type === "ReturnStatement") {
|
|
6034
|
-
if (
|
|
6170
|
+
if (i < body.length - 1) {
|
|
6035
6171
|
result.children.push({
|
|
6036
6172
|
type: "Error",
|
|
6037
6173
|
message: "Can't continue a pipeline after returning"
|
|
@@ -6059,7 +6195,7 @@ function processPipelineExpressions(statements) {
|
|
|
6059
6195
|
};
|
|
6060
6196
|
}
|
|
6061
6197
|
children.push(arg);
|
|
6062
|
-
if (!children.some(($
|
|
6198
|
+
if (!children.some(($2) => $2?.type === "ReturnStatement") && children.some(($3) => $3 === ",")) {
|
|
6063
6199
|
const { parent } = s;
|
|
6064
6200
|
const parenthesizedExpression = makeLeftHandSideExpression({ ...s });
|
|
6065
6201
|
Object.assign(s, parenthesizedExpression, {
|
|
@@ -6067,17 +6203,17 @@ function processPipelineExpressions(statements) {
|
|
|
6067
6203
|
hoistDec: void 0
|
|
6068
6204
|
});
|
|
6069
6205
|
}
|
|
6070
|
-
|
|
6071
|
-
}
|
|
6206
|
+
addParentPointers(s, s.parent);
|
|
6207
|
+
}
|
|
6072
6208
|
}
|
|
6073
6209
|
|
|
6074
6210
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
|
|
6075
|
-
function processRangeExpression(start, ws1,
|
|
6076
|
-
ws1 = [ws1,
|
|
6077
|
-
const ws2 =
|
|
6078
|
-
const comma = { $loc:
|
|
6211
|
+
function processRangeExpression(start, ws1, range2, end) {
|
|
6212
|
+
ws1 = [ws1, range2.children[0]];
|
|
6213
|
+
const ws2 = range2.children[1];
|
|
6214
|
+
const comma = { $loc: range2.$loc, token: "," };
|
|
6079
6215
|
let ref;
|
|
6080
|
-
switch (
|
|
6216
|
+
switch (range2.increasing) {
|
|
6081
6217
|
case true: {
|
|
6082
6218
|
ref = ($) => $;
|
|
6083
6219
|
break;
|
|
@@ -6092,7 +6228,7 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6092
6228
|
}
|
|
6093
6229
|
;
|
|
6094
6230
|
const abs = ref;
|
|
6095
|
-
const lengthAdjust = 1 - Number(!
|
|
6231
|
+
const lengthAdjust = 1 - Number(!range2.left.inclusive) - Number(!range2.right.inclusive);
|
|
6096
6232
|
let children;
|
|
6097
6233
|
if (typeof start === "object" && start != null && "type" in start && start.type === "Literal" && (typeof end === "object" && end != null && "type" in end && end.type === "Literal")) {
|
|
6098
6234
|
let startValue = literalValue(start);
|
|
@@ -6105,7 +6241,7 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6105
6241
|
let endCode = endValue.charCodeAt(0);
|
|
6106
6242
|
const step = startCode <= endCode ? 1 : -1;
|
|
6107
6243
|
const length = abs(endCode - startCode) + lengthAdjust;
|
|
6108
|
-
if (!
|
|
6244
|
+
if (!range2.left.inclusive) {
|
|
6109
6245
|
startCode += step;
|
|
6110
6246
|
}
|
|
6111
6247
|
if (length <= 26) {
|
|
@@ -6126,13 +6262,13 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6126
6262
|
")"
|
|
6127
6263
|
];
|
|
6128
6264
|
}
|
|
6129
|
-
if (
|
|
6130
|
-
children.unshift(
|
|
6265
|
+
if (range2.error != null) {
|
|
6266
|
+
children.unshift(range2.error);
|
|
6131
6267
|
}
|
|
6132
6268
|
} else if (typeof startValue === "number" && typeof endValue === "number") {
|
|
6133
6269
|
const step = startValue <= endValue ? 1 : -1;
|
|
6134
6270
|
const length = abs(endValue - startValue) + lengthAdjust;
|
|
6135
|
-
if (!
|
|
6271
|
+
if (!range2.left.inclusive) {
|
|
6136
6272
|
startValue += step;
|
|
6137
6273
|
}
|
|
6138
6274
|
if (length <= 20) {
|
|
@@ -6141,22 +6277,22 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6141
6277
|
Array.from({ length }, (_2, i) => startValue + i * step).join(", "),
|
|
6142
6278
|
"]"
|
|
6143
6279
|
];
|
|
6144
|
-
if (
|
|
6145
|
-
children.unshift(
|
|
6280
|
+
if (range2.error != null) {
|
|
6281
|
+
children.unshift(range2.error);
|
|
6146
6282
|
}
|
|
6147
6283
|
}
|
|
6148
6284
|
}
|
|
6149
6285
|
}
|
|
6150
6286
|
if (!(children != null)) {
|
|
6151
|
-
if (
|
|
6152
|
-
const sign =
|
|
6287
|
+
if (range2.increasing != null) {
|
|
6288
|
+
const sign = range2.increasing ? "+" : "-";
|
|
6153
6289
|
end = makeLeftHandSideExpression(end);
|
|
6154
6290
|
children = [
|
|
6155
|
-
getHelperRef(
|
|
6291
|
+
getHelperRef(range2.increasing ? "range" : "revRange"),
|
|
6156
6292
|
"(",
|
|
6157
|
-
|
|
6293
|
+
range2.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
|
|
6158
6294
|
",",
|
|
6159
|
-
|
|
6295
|
+
range2.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
|
|
6160
6296
|
...ws1,
|
|
6161
6297
|
")"
|
|
6162
6298
|
];
|
|
@@ -6165,11 +6301,11 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6165
6301
|
"((s, e) => s > e ? ",
|
|
6166
6302
|
getHelperRef("revRange"),
|
|
6167
6303
|
"(s, e",
|
|
6168
|
-
|
|
6304
|
+
range2.right.inclusive ? " - 1" : void 0,
|
|
6169
6305
|
") : ",
|
|
6170
6306
|
getHelperRef("range"),
|
|
6171
6307
|
"(s, e",
|
|
6172
|
-
|
|
6308
|
+
range2.right.inclusive ? " + 1" : void 0,
|
|
6173
6309
|
"))",
|
|
6174
6310
|
"(",
|
|
6175
6311
|
start,
|
|
@@ -6186,14 +6322,14 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6186
6322
|
children,
|
|
6187
6323
|
start,
|
|
6188
6324
|
end,
|
|
6189
|
-
error:
|
|
6190
|
-
left:
|
|
6191
|
-
right:
|
|
6192
|
-
increasing:
|
|
6325
|
+
error: range2.error,
|
|
6326
|
+
left: range2.left,
|
|
6327
|
+
right: range2.right,
|
|
6328
|
+
increasing: range2.increasing
|
|
6193
6329
|
};
|
|
6194
6330
|
}
|
|
6195
|
-
function forRange(open, forDeclaration,
|
|
6196
|
-
let { start, end, left, right, increasing } =
|
|
6331
|
+
function forRange(open, forDeclaration, range2, stepExp, close) {
|
|
6332
|
+
let { start, end, left, right, increasing } = range2;
|
|
6197
6333
|
const counterRef = makeRef("i");
|
|
6198
6334
|
const infinite = typeof end === "object" && end != null && "type" in end && end.type === "Identifier" && "name" in end && end.name === "Infinity";
|
|
6199
6335
|
let stepRef, asc;
|
|
@@ -6292,7 +6428,7 @@ function forRange(open, forDeclaration, range, stepExp, close) {
|
|
|
6292
6428
|
// This declaration doesn't always appear in the output,
|
|
6293
6429
|
// but it's still helpful for determining the primary loop variable
|
|
6294
6430
|
declaration: forDeclaration,
|
|
6295
|
-
children: [
|
|
6431
|
+
children: [range2.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
|
|
6296
6432
|
blockPrefix
|
|
6297
6433
|
};
|
|
6298
6434
|
}
|
|
@@ -6352,6 +6488,7 @@ function processForInOf($0) {
|
|
|
6352
6488
|
declaration = {
|
|
6353
6489
|
type: "Declaration",
|
|
6354
6490
|
children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", trimFirstSpace(expRef2), ".length"],
|
|
6491
|
+
decl: "let",
|
|
6355
6492
|
names: []
|
|
6356
6493
|
};
|
|
6357
6494
|
const condition = [counterRef, " < ", lenRef, "; "];
|
|
@@ -6375,6 +6512,9 @@ function processForInOf($0) {
|
|
|
6375
6512
|
}
|
|
6376
6513
|
const { binding } = declaration;
|
|
6377
6514
|
let pattern = binding?.pattern;
|
|
6515
|
+
if (pattern?.type === "NamedBindingPattern") {
|
|
6516
|
+
pattern = pattern.binding;
|
|
6517
|
+
}
|
|
6378
6518
|
if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
|
|
6379
6519
|
const itemRef = makeRef(inOf.token === "in" ? "key" : "item");
|
|
6380
6520
|
blockPrefix.push(["", {
|
|
@@ -6413,12 +6553,14 @@ function processForInOf($0) {
|
|
|
6413
6553
|
hoistDec = {
|
|
6414
6554
|
type: "Declaration",
|
|
6415
6555
|
children: ["let ", counterRef, " = 0"],
|
|
6556
|
+
decl: "let",
|
|
6416
6557
|
names: []
|
|
6417
6558
|
};
|
|
6418
6559
|
blockPrefix.push(["", {
|
|
6419
6560
|
type: "Declaration",
|
|
6420
6561
|
children: [trimFirstSpace(ws2), decl2, " = ", counterRef, "++"],
|
|
6421
|
-
names: decl2.names
|
|
6562
|
+
names: decl2.names,
|
|
6563
|
+
decl: decl2.decl
|
|
6422
6564
|
}, ";"]);
|
|
6423
6565
|
break;
|
|
6424
6566
|
}
|
|
@@ -6428,7 +6570,8 @@ function processForInOf($0) {
|
|
|
6428
6570
|
hoistDec = {
|
|
6429
6571
|
type: "Declaration",
|
|
6430
6572
|
children: ["let ", expRef2],
|
|
6431
|
-
names: []
|
|
6573
|
+
names: [],
|
|
6574
|
+
decl: "let"
|
|
6432
6575
|
};
|
|
6433
6576
|
exp = {
|
|
6434
6577
|
type: "AssignmentExpression",
|
|
@@ -6440,20 +6583,58 @@ function processForInOf($0) {
|
|
|
6440
6583
|
blockPrefix.push(["", ["if (!", hasPropRef, "(", trimFirstSpace(expRef2), ", ", trimFirstSpace(pattern), ")) continue"], ";"]);
|
|
6441
6584
|
}
|
|
6442
6585
|
if (decl2) {
|
|
6443
|
-
|
|
6444
|
-
|
|
6586
|
+
const trimmedPattern = trimFirstSpace(pattern);
|
|
6587
|
+
const expression = makeNode({
|
|
6588
|
+
type: "MemberExpression",
|
|
6445
6589
|
children: [
|
|
6446
|
-
trimFirstSpace(ws2),
|
|
6447
|
-
decl2,
|
|
6448
|
-
" = ",
|
|
6449
6590
|
trimFirstSpace(expRef2),
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
|
|
6456
|
-
}
|
|
6591
|
+
makeNode({
|
|
6592
|
+
type: "Index",
|
|
6593
|
+
expression: trimmedPattern,
|
|
6594
|
+
children: ["[", trimmedPattern, "]"]
|
|
6595
|
+
})
|
|
6596
|
+
]
|
|
6597
|
+
});
|
|
6598
|
+
blockPrefix.push([
|
|
6599
|
+
"",
|
|
6600
|
+
(() => {
|
|
6601
|
+
if (decl2.type === "ForDeclaration") {
|
|
6602
|
+
const { binding: binding2, children } = decl2;
|
|
6603
|
+
binding2.children.push(binding2.initializer = makeNode({
|
|
6604
|
+
type: "Initializer",
|
|
6605
|
+
expression,
|
|
6606
|
+
children: [" = ", expression]
|
|
6607
|
+
}));
|
|
6608
|
+
return makeNode({
|
|
6609
|
+
type: "Declaration",
|
|
6610
|
+
children: [
|
|
6611
|
+
trimFirstSpace(ws2),
|
|
6612
|
+
...children
|
|
6613
|
+
],
|
|
6614
|
+
bindings: [decl2.binding],
|
|
6615
|
+
decl: decl2.decl,
|
|
6616
|
+
names: decl2.names
|
|
6617
|
+
});
|
|
6618
|
+
} else {
|
|
6619
|
+
return makeNode({
|
|
6620
|
+
type: "AssignmentExpression",
|
|
6621
|
+
children: [
|
|
6622
|
+
trimFirstSpace(ws2),
|
|
6623
|
+
decl2,
|
|
6624
|
+
" = ",
|
|
6625
|
+
trimFirstSpace(expRef2),
|
|
6626
|
+
"[",
|
|
6627
|
+
trimFirstSpace(pattern),
|
|
6628
|
+
"]"
|
|
6629
|
+
],
|
|
6630
|
+
names: decl2.names,
|
|
6631
|
+
lhs: decl2,
|
|
6632
|
+
assigned: decl2
|
|
6633
|
+
});
|
|
6634
|
+
}
|
|
6635
|
+
})(),
|
|
6636
|
+
";"
|
|
6637
|
+
]);
|
|
6457
6638
|
}
|
|
6458
6639
|
;
|
|
6459
6640
|
break;
|
|
@@ -6983,7 +7164,7 @@ function processTryBlock($0) {
|
|
|
6983
7164
|
const clauses = cs.map((clause) => {
|
|
6984
7165
|
let ref1;
|
|
6985
7166
|
if ((ref1 = clause.binding?.parameter) && typeof ref1 === "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
|
|
6986
|
-
const {
|
|
7167
|
+
const { patterns } = ref1;
|
|
6987
7168
|
return {
|
|
6988
7169
|
type: "PatternClause",
|
|
6989
7170
|
patterns,
|
|
@@ -7174,14 +7355,21 @@ function processCallMemberExpression(node) {
|
|
|
7174
7355
|
}
|
|
7175
7356
|
}
|
|
7176
7357
|
if (args.length) {
|
|
7177
|
-
|
|
7178
|
-
0,
|
|
7179
|
-
2,
|
|
7180
|
-
commaCount ? {
|
|
7358
|
+
if (commaCount) {
|
|
7359
|
+
children.splice(0, 2, {
|
|
7181
7360
|
type: "ParenthesizedExpression",
|
|
7182
|
-
children: ["(",
|
|
7183
|
-
|
|
7184
|
-
|
|
7361
|
+
children: ["(", call.children, ")"],
|
|
7362
|
+
expression: call.children
|
|
7363
|
+
});
|
|
7364
|
+
} else {
|
|
7365
|
+
const middle = call.children.slice(0 + 1, -1);
|
|
7366
|
+
let ref2;
|
|
7367
|
+
children.splice(0, 2, {
|
|
7368
|
+
type: "ParenthesizedExpression",
|
|
7369
|
+
expression: middle,
|
|
7370
|
+
children: [call.children[0], middle, (ref2 = call.children)[ref2.length - 1]]
|
|
7371
|
+
});
|
|
7372
|
+
}
|
|
7185
7373
|
if (children.length === 1) {
|
|
7186
7374
|
return children[0];
|
|
7187
7375
|
}
|
|
@@ -7264,14 +7452,14 @@ function processCallMemberExpression(node) {
|
|
|
7264
7452
|
});
|
|
7265
7453
|
}
|
|
7266
7454
|
}
|
|
7267
|
-
let
|
|
7455
|
+
let ref3;
|
|
7268
7456
|
const object = {
|
|
7269
7457
|
type: "ObjectExpression",
|
|
7270
7458
|
children: [
|
|
7271
7459
|
glob.object.children[0],
|
|
7272
7460
|
// {
|
|
7273
7461
|
...parts,
|
|
7274
|
-
(
|
|
7462
|
+
(ref3 = glob.object.children)[ref3.length - 1]
|
|
7275
7463
|
// whitespace and }
|
|
7276
7464
|
],
|
|
7277
7465
|
properties: parts
|
|
@@ -7332,7 +7520,7 @@ function processCallMemberExpression(node) {
|
|
|
7332
7520
|
})
|
|
7333
7521
|
]
|
|
7334
7522
|
});
|
|
7335
|
-
let
|
|
7523
|
+
let ref4;
|
|
7336
7524
|
return processCallMemberExpression({
|
|
7337
7525
|
// in case there are more
|
|
7338
7526
|
...node,
|
|
@@ -7346,7 +7534,7 @@ function processCallMemberExpression(node) {
|
|
|
7346
7534
|
glob.children[0],
|
|
7347
7535
|
// "[" token
|
|
7348
7536
|
call,
|
|
7349
|
-
(
|
|
7537
|
+
(ref4 = glob.children)[ref4.length - 1]
|
|
7350
7538
|
// "]" token
|
|
7351
7539
|
]
|
|
7352
7540
|
}),
|
|
@@ -7359,7 +7547,7 @@ function processCallMemberExpression(node) {
|
|
|
7359
7547
|
{ ...glob.children[0], token: ", " },
|
|
7360
7548
|
...glob.children.slice(1, -1)
|
|
7361
7549
|
];
|
|
7362
|
-
let
|
|
7550
|
+
let ref5;
|
|
7363
7551
|
const rsliceCall = makeNode({
|
|
7364
7552
|
type: "CallExpression",
|
|
7365
7553
|
implicit: true,
|
|
@@ -7371,7 +7559,7 @@ function processCallMemberExpression(node) {
|
|
|
7371
7559
|
children: [
|
|
7372
7560
|
"(",
|
|
7373
7561
|
args,
|
|
7374
|
-
(
|
|
7562
|
+
(ref5 = glob.children)[ref5.length - 1]
|
|
7375
7563
|
]
|
|
7376
7564
|
})
|
|
7377
7565
|
]
|
|
@@ -7456,8 +7644,8 @@ function convertNamedImportsToObject(node, pattern) {
|
|
|
7456
7644
|
return { type: "Error", message: "cannot use `type` in dynamic import" };
|
|
7457
7645
|
} else {
|
|
7458
7646
|
const { source, binding } = specifier;
|
|
7459
|
-
let
|
|
7460
|
-
const delim = (
|
|
7647
|
+
let ref6;
|
|
7648
|
+
const delim = (ref6 = specifier.children)[ref6.length - 1];
|
|
7461
7649
|
return {
|
|
7462
7650
|
type: pattern ? "BindingProperty" : "Property",
|
|
7463
7651
|
name: source,
|
|
@@ -7467,7 +7655,7 @@ function convertNamedImportsToObject(node, pattern) {
|
|
|
7467
7655
|
};
|
|
7468
7656
|
}
|
|
7469
7657
|
});
|
|
7470
|
-
let
|
|
7658
|
+
let ref7;
|
|
7471
7659
|
return {
|
|
7472
7660
|
type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
|
|
7473
7661
|
names: node.names,
|
|
@@ -7476,7 +7664,7 @@ function convertNamedImportsToObject(node, pattern) {
|
|
|
7476
7664
|
node.children[0],
|
|
7477
7665
|
// {
|
|
7478
7666
|
properties,
|
|
7479
|
-
(
|
|
7667
|
+
(ref7 = node.children)[ref7.length - 1]
|
|
7480
7668
|
// }
|
|
7481
7669
|
]
|
|
7482
7670
|
};
|
|
@@ -7587,10 +7775,17 @@ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "g
|
|
|
7587
7775
|
function processBindingPatternLHS(lhs, tail) {
|
|
7588
7776
|
adjustAtBindings(lhs, true);
|
|
7589
7777
|
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
7590
|
-
|
|
7778
|
+
const subbindings = gatherSubbindings(lhs);
|
|
7779
|
+
simplifyBindingProperties(lhs);
|
|
7780
|
+
simplifyBindingProperties(subbindings);
|
|
7781
|
+
tail.push(
|
|
7782
|
+
...splices.map((s) => [", ", s]),
|
|
7783
|
+
...thisAssignments.map((a) => [", ", a]),
|
|
7784
|
+
...subbindings
|
|
7785
|
+
);
|
|
7591
7786
|
}
|
|
7592
7787
|
function processAssignments(statements) {
|
|
7593
|
-
for (let
|
|
7788
|
+
for (let ref8 = gatherRecursiveAll(statements, ($4) => $4.type === "AssignmentExpression" || $4.type === "UpdateExpression"), i5 = 0, len3 = ref8.length; i5 < len3; i5++) {
|
|
7594
7789
|
let extractAssignment = function(lhs) {
|
|
7595
7790
|
let expr = lhs;
|
|
7596
7791
|
while (expr.type === "ParenthesizedExpression") {
|
|
@@ -7610,20 +7805,20 @@ function processAssignments(statements) {
|
|
|
7610
7805
|
;
|
|
7611
7806
|
return;
|
|
7612
7807
|
};
|
|
7613
|
-
const exp =
|
|
7808
|
+
const exp = ref8[i5];
|
|
7614
7809
|
checkValidLHS(exp.assigned);
|
|
7615
7810
|
const pre = [], post = [];
|
|
7616
|
-
let
|
|
7811
|
+
let ref9;
|
|
7617
7812
|
switch (exp.type) {
|
|
7618
7813
|
case "AssignmentExpression": {
|
|
7619
7814
|
if (!exp.lhs) {
|
|
7620
7815
|
continue;
|
|
7621
7816
|
}
|
|
7622
|
-
for (let
|
|
7623
|
-
const lhsPart =
|
|
7624
|
-
let
|
|
7625
|
-
if (
|
|
7626
|
-
const newLhs =
|
|
7817
|
+
for (let ref10 = exp.lhs, i6 = 0, len4 = ref10.length; i6 < len4; i6++) {
|
|
7818
|
+
const lhsPart = ref10[i6];
|
|
7819
|
+
let ref11;
|
|
7820
|
+
if (ref11 = extractAssignment(lhsPart[1])) {
|
|
7821
|
+
const newLhs = ref11;
|
|
7627
7822
|
lhsPart[1] = newLhs;
|
|
7628
7823
|
}
|
|
7629
7824
|
}
|
|
@@ -7631,8 +7826,8 @@ function processAssignments(statements) {
|
|
|
7631
7826
|
break;
|
|
7632
7827
|
}
|
|
7633
7828
|
case "UpdateExpression": {
|
|
7634
|
-
if (
|
|
7635
|
-
const newLhs =
|
|
7829
|
+
if (ref9 = extractAssignment(exp.assigned)) {
|
|
7830
|
+
const newLhs = ref9;
|
|
7636
7831
|
const i = exp.children.indexOf(exp.assigned);
|
|
7637
7832
|
exp.assigned = exp.children[i] = newLhs;
|
|
7638
7833
|
}
|
|
@@ -7664,22 +7859,22 @@ function processAssignments(statements) {
|
|
|
7664
7859
|
}
|
|
7665
7860
|
}
|
|
7666
7861
|
}
|
|
7667
|
-
for (let
|
|
7668
|
-
const exp =
|
|
7862
|
+
for (let ref12 = gatherRecursiveAll(statements, ($6) => $6.type === "AssignmentExpression"), i7 = 0, len5 = ref12.length; i7 < len5; i7++) {
|
|
7863
|
+
const exp = ref12[i7];
|
|
7669
7864
|
if (!(exp.names === null)) {
|
|
7670
7865
|
continue;
|
|
7671
7866
|
}
|
|
7672
7867
|
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
7673
7868
|
let block;
|
|
7674
|
-
let
|
|
7675
|
-
if (blockContainingStatement(exp) && !(
|
|
7869
|
+
let ref13;
|
|
7870
|
+
if (blockContainingStatement(exp) && !(ref13 = $1[$1.length - 1])?.[ref13.length - 1]?.special) {
|
|
7676
7871
|
block = makeBlockFragment();
|
|
7677
|
-
let
|
|
7678
|
-
if (
|
|
7872
|
+
let ref14;
|
|
7873
|
+
if (ref14 = prependStatementExpressionBlock(
|
|
7679
7874
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
7680
7875
|
block
|
|
7681
7876
|
)) {
|
|
7682
|
-
const ref =
|
|
7877
|
+
const ref = ref14;
|
|
7683
7878
|
exp.children = exp.children.map(($7) => $7 === $2 ? ref : $7);
|
|
7684
7879
|
$2 = ref;
|
|
7685
7880
|
} else {
|
|
@@ -7756,7 +7951,7 @@ function processAssignments(statements) {
|
|
|
7756
7951
|
message: "Slice range cannot be decreasing in assignment"
|
|
7757
7952
|
});
|
|
7758
7953
|
break;
|
|
7759
|
-
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") {
|
|
7954
|
+
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
|
|
7760
7955
|
processBindingPatternLHS(lhs, tail);
|
|
7761
7956
|
gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
|
|
7762
7957
|
}
|
|
@@ -7860,9 +8055,9 @@ function unchainOptionalMemberExpression(exp, ref, innerExp) {
|
|
|
7860
8055
|
}
|
|
7861
8056
|
j++;
|
|
7862
8057
|
}
|
|
7863
|
-
let
|
|
7864
|
-
if (
|
|
7865
|
-
const l =
|
|
8058
|
+
let ref15;
|
|
8059
|
+
if (ref15 = conditions.length) {
|
|
8060
|
+
const l = ref15;
|
|
7866
8061
|
const cs = flatJoin(conditions, " && ");
|
|
7867
8062
|
return {
|
|
7868
8063
|
...exp,
|
|
@@ -7898,14 +8093,14 @@ function attachPostfixStatementAsExpression(exp, post) {
|
|
|
7898
8093
|
}
|
|
7899
8094
|
function processTypes(node) {
|
|
7900
8095
|
const results1 = [];
|
|
7901
|
-
for (let
|
|
7902
|
-
const unary =
|
|
8096
|
+
for (let ref16 = gatherRecursiveAll(node, ($11) => $11.type === "TypeUnary"), i8 = 0, len6 = ref16.length; i8 < len6; i8++) {
|
|
8097
|
+
const unary = ref16[i8];
|
|
7903
8098
|
let suffixIndex = unary.suffix.length - 1;
|
|
7904
8099
|
const results2 = [];
|
|
7905
8100
|
while (suffixIndex >= 0) {
|
|
7906
8101
|
const suffix = unary.suffix[suffixIndex];
|
|
7907
8102
|
if (typeof suffix === "object" && suffix != null && "token" in suffix && suffix.token === "?") {
|
|
7908
|
-
const {
|
|
8103
|
+
const {} = suffix;
|
|
7909
8104
|
let count = 0;
|
|
7910
8105
|
let m4;
|
|
7911
8106
|
while (m4 = unary.suffix[suffixIndex], typeof m4 === "object" && m4 != null && "token" in m4 && m4.token === "?") {
|
|
@@ -7963,7 +8158,7 @@ function processTypes(node) {
|
|
|
7963
8158
|
}
|
|
7964
8159
|
results2.push(replaceNode(unary, replace, parent));
|
|
7965
8160
|
} else if (typeof suffix === "object" && suffix != null && "type" in suffix && suffix.type === "NonNullAssertion") {
|
|
7966
|
-
const {
|
|
8161
|
+
const {} = suffix;
|
|
7967
8162
|
let m6;
|
|
7968
8163
|
while (m6 = unary.suffix[suffixIndex], typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "NonNullAssertion") {
|
|
7969
8164
|
unary.suffix.splice(suffixIndex--, 1);
|
|
@@ -7978,10 +8173,10 @@ function processTypes(node) {
|
|
|
7978
8173
|
const outer = unary.suffix.splice(suffixIndex + 1, Infinity);
|
|
7979
8174
|
const space = getTrimmingSpace(unary);
|
|
7980
8175
|
inplaceInsertTrimmingSpace(unary, "");
|
|
7981
|
-
let
|
|
7982
|
-
if (unary.suffix.length)
|
|
7983
|
-
else
|
|
7984
|
-
const t =
|
|
8176
|
+
let ref17;
|
|
8177
|
+
if (unary.suffix.length) ref17 = unary;
|
|
8178
|
+
else ref17 = unary.t;
|
|
8179
|
+
const t = ref17;
|
|
7985
8180
|
const arg = makeNode({
|
|
7986
8181
|
type: "TypeArgument",
|
|
7987
8182
|
ts: true,
|
|
@@ -8026,18 +8221,18 @@ function processTypes(node) {
|
|
|
8026
8221
|
return results1;
|
|
8027
8222
|
}
|
|
8028
8223
|
function processStatementExpressions(statements) {
|
|
8029
|
-
for (let
|
|
8030
|
-
const exp =
|
|
8224
|
+
for (let ref18 = gatherRecursiveAll(statements, ($12) => $12.type === "StatementExpression"), i9 = 0, len7 = ref18.length; i9 < len7; i9++) {
|
|
8225
|
+
const exp = ref18[i9];
|
|
8031
8226
|
const { maybe, statement } = exp;
|
|
8032
8227
|
if ((maybe || statement.type === "ThrowStatement") && blockContainingStatement(exp)) {
|
|
8033
8228
|
replaceNode(exp, statement);
|
|
8034
8229
|
continue;
|
|
8035
8230
|
}
|
|
8036
|
-
let
|
|
8231
|
+
let ref19;
|
|
8037
8232
|
switch (statement.type) {
|
|
8038
8233
|
case "IfStatement": {
|
|
8039
|
-
if (
|
|
8040
|
-
const expression =
|
|
8234
|
+
if (ref19 = expressionizeIfStatement(statement)) {
|
|
8235
|
+
const expression = ref19;
|
|
8041
8236
|
replaceNode(statement, expression, exp);
|
|
8042
8237
|
} else {
|
|
8043
8238
|
replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
@@ -8096,13 +8291,13 @@ function processNegativeIndexAccess(statements) {
|
|
|
8096
8291
|
});
|
|
8097
8292
|
}
|
|
8098
8293
|
function processFinallyClauses(statements) {
|
|
8099
|
-
for (let
|
|
8100
|
-
let f =
|
|
8101
|
-
let
|
|
8102
|
-
if (!((
|
|
8294
|
+
for (let ref20 = gatherRecursiveAll(statements, ($) => $.type === "FinallyClause" && $.parent?.type !== "TryStatement"), i10 = 0, len8 = ref20.length; i10 < len8; i10++) {
|
|
8295
|
+
let f = ref20[i10];
|
|
8296
|
+
let ref21;
|
|
8297
|
+
if (!((ref21 = blockContainingStatement(f)) && typeof ref21 === "object" && "block" in ref21 && "index" in ref21)) {
|
|
8103
8298
|
throw new Error("finally clause must be inside try statement or block");
|
|
8104
8299
|
}
|
|
8105
|
-
const { block, index } =
|
|
8300
|
+
const { block, index } = ref21;
|
|
8106
8301
|
const indent = block.expressions[index][0];
|
|
8107
8302
|
const expressions = block.expressions.slice(index + 1);
|
|
8108
8303
|
const t = makeNode({
|
|
@@ -8174,8 +8369,8 @@ function processBreaksContinues(statements) {
|
|
|
8174
8369
|
}
|
|
8175
8370
|
}
|
|
8176
8371
|
function processCoffeeClasses(statements) {
|
|
8177
|
-
for (let
|
|
8178
|
-
const ce =
|
|
8372
|
+
for (let ref22 = gatherRecursiveAll(statements, ($13) => $13.type === "ClassExpression"), i11 = 0, len9 = ref22.length; i11 < len9; i11++) {
|
|
8373
|
+
const ce = ref22[i11];
|
|
8179
8374
|
const { expressions } = ce.body;
|
|
8180
8375
|
const indent = expressions[0]?.[0] ?? "\n";
|
|
8181
8376
|
const autoBinds = expressions.filter(($14) => $14[1]?.autoBind);
|
|
@@ -8325,8 +8520,8 @@ async function processProgramAsync(root) {
|
|
|
8325
8520
|
function processRepl(root, rootIIFE) {
|
|
8326
8521
|
const topBlock = gatherRecursive(rootIIFE, ($17) => $17.type === "BlockStatement")[0];
|
|
8327
8522
|
let i = 0;
|
|
8328
|
-
for (let
|
|
8329
|
-
const decl =
|
|
8523
|
+
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($18) => $18.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
|
|
8524
|
+
const decl = ref23[i14];
|
|
8330
8525
|
if (!decl.names?.length) {
|
|
8331
8526
|
continue;
|
|
8332
8527
|
}
|
|
@@ -8339,8 +8534,8 @@ function processRepl(root, rootIIFE) {
|
|
|
8339
8534
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]);
|
|
8340
8535
|
}
|
|
8341
8536
|
}
|
|
8342
|
-
for (let
|
|
8343
|
-
const func =
|
|
8537
|
+
for (let ref24 = gatherRecursive(topBlock, ($19) => $19.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
|
|
8538
|
+
const func = ref24[i15];
|
|
8344
8539
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
8345
8540
|
if (func.parent === topBlock) {
|
|
8346
8541
|
replaceNode(func, void 0);
|
|
@@ -8352,8 +8547,8 @@ function processRepl(root, rootIIFE) {
|
|
|
8352
8547
|
}
|
|
8353
8548
|
}
|
|
8354
8549
|
}
|
|
8355
|
-
for (let
|
|
8356
|
-
const classExp =
|
|
8550
|
+
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($20) => $20.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
|
|
8551
|
+
const classExp = ref25[i16];
|
|
8357
8552
|
let m8;
|
|
8358
8553
|
if (classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 === "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) {
|
|
8359
8554
|
classExp.children.unshift(classExp.name, "=");
|
|
@@ -8361,31 +8556,11 @@ function processRepl(root, rootIIFE) {
|
|
|
8361
8556
|
}
|
|
8362
8557
|
}
|
|
8363
8558
|
}
|
|
8364
|
-
function populateRefs(statements) {
|
|
8365
|
-
const refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
|
|
8366
|
-
if (refNodes.length) {
|
|
8367
|
-
const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
|
|
8368
|
-
const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
8369
|
-
refNodes.forEach((ref) => {
|
|
8370
|
-
const { type, base } = ref;
|
|
8371
|
-
if (type !== "Ref") return;
|
|
8372
|
-
ref.type = "Identifier";
|
|
8373
|
-
let n = 0;
|
|
8374
|
-
let name = base;
|
|
8375
|
-
while (names.has(name)) {
|
|
8376
|
-
n++;
|
|
8377
|
-
name = `${base}${n}`;
|
|
8378
|
-
}
|
|
8379
|
-
names.add(name);
|
|
8380
|
-
return ref.children = ref.names = [name];
|
|
8381
|
-
});
|
|
8382
|
-
}
|
|
8383
|
-
}
|
|
8384
8559
|
function processPlaceholders(statements) {
|
|
8385
8560
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8386
8561
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8387
|
-
for (let
|
|
8388
|
-
const exp =
|
|
8562
|
+
for (let ref26 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
|
|
8563
|
+
const exp = ref26[i17];
|
|
8389
8564
|
let ancestor;
|
|
8390
8565
|
if (exp.subtype === ".") {
|
|
8391
8566
|
({ ancestor } = findAncestor(
|
|
@@ -8497,8 +8672,8 @@ function processPlaceholders(statements) {
|
|
|
8497
8672
|
for (let i18 = 0, len15 = placeholders.length; i18 < len15; i18++) {
|
|
8498
8673
|
const placeholder = placeholders[i18];
|
|
8499
8674
|
typeSuffix ??= placeholder.typeSuffix;
|
|
8500
|
-
let
|
|
8501
|
-
(
|
|
8675
|
+
let ref27;
|
|
8676
|
+
(ref27 = placeholder.children)[ref27.length - 1] = ref;
|
|
8502
8677
|
}
|
|
8503
8678
|
const { parent } = ancestor;
|
|
8504
8679
|
const body = maybeUnwrap(ancestor);
|
|
@@ -8519,16 +8694,16 @@ function processPlaceholders(statements) {
|
|
|
8519
8694
|
}
|
|
8520
8695
|
case "PipelineExpression": {
|
|
8521
8696
|
const i = findChildIndex(parent, ancestor);
|
|
8522
|
-
let
|
|
8697
|
+
let ref28;
|
|
8523
8698
|
if (i === 1) {
|
|
8524
|
-
|
|
8699
|
+
ref28 = ancestor === parent.children[i];
|
|
8525
8700
|
} else if (i === 2) {
|
|
8526
|
-
|
|
8701
|
+
ref28 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
|
|
8527
8702
|
} else {
|
|
8528
|
-
|
|
8703
|
+
ref28 = void 0;
|
|
8529
8704
|
}
|
|
8530
8705
|
;
|
|
8531
|
-
outer =
|
|
8706
|
+
outer = ref28;
|
|
8532
8707
|
break;
|
|
8533
8708
|
}
|
|
8534
8709
|
case "AssignmentExpression":
|
|
@@ -8543,9 +8718,12 @@ function processPlaceholders(statements) {
|
|
|
8543
8718
|
fnExp = makeLeftHandSideExpression(fnExp);
|
|
8544
8719
|
}
|
|
8545
8720
|
replaceNode(ancestor, fnExp, parent);
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8721
|
+
if (typeof parent === "object" && parent != null && "type" in parent && parent.type === "BlockStatement" && "parent" in parent && typeof parent.parent === "object" && parent.parent != null && "type" in parent.parent && parent.parent.type === "ArrowFunction" && "ampersandBlock" in parent.parent && parent.parent.ampersandBlock === true && "body" in parent.parent && parent.parent.body === body) {
|
|
8722
|
+
parent.parent.body = fnExp;
|
|
8723
|
+
}
|
|
8724
|
+
let ref29;
|
|
8725
|
+
if (ref29 = getTrimmingSpace(body)) {
|
|
8726
|
+
const ws = ref29;
|
|
8549
8727
|
inplaceInsertTrimmingSpace(body, "");
|
|
8550
8728
|
inplacePrepend(ws, fnExp);
|
|
8551
8729
|
}
|
|
@@ -8589,8 +8767,8 @@ function reorderBindingRestProperty(props) {
|
|
|
8589
8767
|
}
|
|
8590
8768
|
];
|
|
8591
8769
|
}
|
|
8592
|
-
let
|
|
8593
|
-
if (Array.isArray(rest.delim) && (
|
|
8770
|
+
let ref30;
|
|
8771
|
+
if (Array.isArray(rest.delim) && (ref30 = rest.delim)[ref30.length - 1]?.token === ",") {
|
|
8594
8772
|
rest.delim = rest.delim.slice(0, -1);
|
|
8595
8773
|
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
8596
8774
|
}
|
|
@@ -8827,6 +9005,7 @@ var grammar = {
|
|
|
8827
9005
|
NWBindingIdentifier,
|
|
8828
9006
|
AtIdentifierRef,
|
|
8829
9007
|
PinPattern,
|
|
9008
|
+
NamedBindingPattern,
|
|
8830
9009
|
BindingPattern,
|
|
8831
9010
|
ObjectBindingPattern,
|
|
8832
9011
|
ObjectBindingPatternContent,
|
|
@@ -10777,24 +10956,27 @@ var PipelineHeadItem$$ = [PipelineHeadItem$0, PipelineHeadItem$1];
|
|
|
10777
10956
|
function PipelineHeadItem(ctx, state2) {
|
|
10778
10957
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineHeadItem", PipelineHeadItem$$);
|
|
10779
10958
|
}
|
|
10780
|
-
var PipelineTailItem$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$C)(AwaitOp,
|
|
10959
|
+
var PipelineTailItem$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$C)(AwaitOp, Return, Throw), (0, import_lib2.$N)(AccessStart), (0, import_lib2.$N)(MaybeParenNestedExpression)), function(value) {
|
|
10781
10960
|
return value[0];
|
|
10782
10961
|
});
|
|
10783
|
-
var PipelineTailItem$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$
|
|
10962
|
+
var PipelineTailItem$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$S)(Yield, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)(_), Star)))), (0, import_lib2.$N)(AccessStart), (0, import_lib2.$N)(MaybeParenNestedExpression)), function($skip, $loc, $0, $1, $2, $3) {
|
|
10963
|
+
return { $loc, token: $1, type: "Yield" };
|
|
10964
|
+
});
|
|
10965
|
+
var PipelineTailItem$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L15, 'PipelineTailItem "import"'), (0, import_lib2.$N)(AccessStart)), function($skip, $loc, $0, $1, $2) {
|
|
10784
10966
|
return {
|
|
10785
10967
|
type: "Identifier",
|
|
10786
10968
|
children: [$1]
|
|
10787
10969
|
};
|
|
10788
10970
|
});
|
|
10789
|
-
var PipelineTailItem$
|
|
10971
|
+
var PipelineTailItem$3 = (0, import_lib2.$TS)((0, import_lib2.$S)(NWTypePostfix, (0, import_lib2.$Q)(TypePostfix)), function($skip, $loc, $0, $1, $2) {
|
|
10790
10972
|
return makeAmpersandFunction({
|
|
10791
10973
|
body: [" ", $1, ...$2]
|
|
10792
10974
|
});
|
|
10793
10975
|
});
|
|
10794
|
-
var PipelineTailItem$
|
|
10976
|
+
var PipelineTailItem$4 = (0, import_lib2.$T)((0, import_lib2.$S)(PipelineHeadItem), function(value) {
|
|
10795
10977
|
return value[0];
|
|
10796
10978
|
});
|
|
10797
|
-
var PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3];
|
|
10979
|
+
var PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3, PipelineTailItem$4];
|
|
10798
10980
|
function PipelineTailItem(ctx, state2) {
|
|
10799
10981
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineTailItem", PipelineTailItem$$);
|
|
10800
10982
|
}
|
|
@@ -11376,8 +11558,9 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
|
|
|
11376
11558
|
expression
|
|
11377
11559
|
};
|
|
11378
11560
|
});
|
|
11379
|
-
var LeftHandSideExpression$1 =
|
|
11380
|
-
var LeftHandSideExpression
|
|
11561
|
+
var LeftHandSideExpression$1 = NamedBindingPattern;
|
|
11562
|
+
var LeftHandSideExpression$2 = CallExpression;
|
|
11563
|
+
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
|
|
11381
11564
|
function LeftHandSideExpression(ctx, state2) {
|
|
11382
11565
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
|
|
11383
11566
|
}
|
|
@@ -12000,7 +12183,7 @@ var FunctionRestParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
12000
12183
|
function FunctionRestParameter(ctx, state2) {
|
|
12001
12184
|
return (0, import_lib2.$EVENT)(ctx, state2, "FunctionRestParameter", FunctionRestParameter$0);
|
|
12002
12185
|
}
|
|
12003
|
-
var ParameterElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
12186
|
+
var ParameterElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$E)(AccessModifier), (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, NWBindingIdentifier), (0, import_lib2.$E)(TypeSuffix), (0, import_lib2.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
12004
12187
|
var accessModifier = $2;
|
|
12005
12188
|
var binding = $4;
|
|
12006
12189
|
var typeSuffix = $5;
|
|
@@ -12113,12 +12296,31 @@ var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
|
|
|
12113
12296
|
function PinPattern(ctx, state2) {
|
|
12114
12297
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
|
|
12115
12298
|
}
|
|
12299
|
+
var NamedBindingPattern$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, Caret, (0, import_lib2.$E)(_), BindingPattern), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12300
|
+
var binding = $1;
|
|
12301
|
+
var ws = $3;
|
|
12302
|
+
var pattern = $4;
|
|
12303
|
+
pattern = prepend(ws, pattern);
|
|
12304
|
+
return {
|
|
12305
|
+
type: "NamedBindingPattern",
|
|
12306
|
+
// NOTE: children just has binding, not pattern, for easy destructuring
|
|
12307
|
+
children: [binding],
|
|
12308
|
+
binding,
|
|
12309
|
+
pattern,
|
|
12310
|
+
subbinding: [pattern, " = ", binding],
|
|
12311
|
+
typeSuffix: pattern.typeSuffix
|
|
12312
|
+
};
|
|
12313
|
+
});
|
|
12314
|
+
function NamedBindingPattern(ctx, state2) {
|
|
12315
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "NamedBindingPattern", NamedBindingPattern$0);
|
|
12316
|
+
}
|
|
12116
12317
|
var BindingPattern$0 = ObjectBindingPattern;
|
|
12117
12318
|
var BindingPattern$1 = ArrayBindingPattern;
|
|
12118
12319
|
var BindingPattern$2 = PinPattern;
|
|
12119
12320
|
var BindingPattern$3 = Literal;
|
|
12120
12321
|
var BindingPattern$4 = RegularExpressionLiteral;
|
|
12121
|
-
var BindingPattern
|
|
12322
|
+
var BindingPattern$5 = NamedBindingPattern;
|
|
12323
|
+
var BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4, BindingPattern$5];
|
|
12122
12324
|
function BindingPattern(ctx, state2) {
|
|
12123
12325
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingPattern", BindingPattern$$);
|
|
12124
12326
|
}
|
|
@@ -12242,7 +12444,7 @@ function NestedBindingPropertyList(ctx, state2) {
|
|
|
12242
12444
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingPropertyList", NestedBindingPropertyList$0);
|
|
12243
12445
|
}
|
|
12244
12446
|
var BindingProperty$0 = BindingRestProperty;
|
|
12245
|
-
var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PropertyName, (0, import_lib2.$E)(Caret), (0, import_lib2.$E)(_), Colon, (0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
12447
|
+
var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), PropertyName, (0, import_lib2.$E)(Caret), (0, import_lib2.$E)(_), Colon, (0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12246
12448
|
var ws1 = $1;
|
|
12247
12449
|
var name = $2;
|
|
12248
12450
|
var bind = $3;
|
|
@@ -12252,6 +12454,19 @@ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
12252
12454
|
var value = $7;
|
|
12253
12455
|
var typeSuffix = $8;
|
|
12254
12456
|
var initializer = $9;
|
|
12457
|
+
if (bind) {
|
|
12458
|
+
const binding = name, pattern = value;
|
|
12459
|
+
value = {
|
|
12460
|
+
type: "NamedBindingPattern",
|
|
12461
|
+
// NOTE: children just has binding, not pattern, for easy destructuring
|
|
12462
|
+
children: [binding],
|
|
12463
|
+
binding,
|
|
12464
|
+
pattern,
|
|
12465
|
+
subbinding: [pattern, " = ", binding],
|
|
12466
|
+
typeSuffix: pattern.typeSuffix,
|
|
12467
|
+
names: value.names
|
|
12468
|
+
};
|
|
12469
|
+
}
|
|
12255
12470
|
return {
|
|
12256
12471
|
type: "BindingProperty",
|
|
12257
12472
|
children: [ws1, name, ws2, colon, ws3, value, initializer],
|
|
@@ -12260,8 +12475,7 @@ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
12260
12475
|
value,
|
|
12261
12476
|
typeSuffix,
|
|
12262
12477
|
initializer,
|
|
12263
|
-
names: value.names
|
|
12264
|
-
bind: !!bind
|
|
12478
|
+
names: value.names
|
|
12265
12479
|
};
|
|
12266
12480
|
});
|
|
12267
12481
|
var BindingProperty$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), Caret, BindingIdentifier, (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
@@ -12326,8 +12540,7 @@ var BindingProperty$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
12326
12540
|
typeSuffix,
|
|
12327
12541
|
initializer,
|
|
12328
12542
|
names: binding.names,
|
|
12329
|
-
identifier: binding
|
|
12330
|
-
bind: !!bind
|
|
12543
|
+
identifier: binding
|
|
12331
12544
|
};
|
|
12332
12545
|
});
|
|
12333
12546
|
var BindingProperty$$ = [BindingProperty$0, BindingProperty$1, BindingProperty$2, BindingProperty$3];
|
|
@@ -12385,7 +12598,7 @@ function NestedBindingElements(ctx, state2) {
|
|
|
12385
12598
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingElements", NestedBindingElements$0);
|
|
12386
12599
|
}
|
|
12387
12600
|
var BindingElement$0 = BindingRestElement;
|
|
12388
|
-
var BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
12601
|
+
var BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), (0, import_lib2.$E)(BindingTypeSuffix), (0, import_lib2.$E)(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12389
12602
|
var ws = $1;
|
|
12390
12603
|
var binding = $2;
|
|
12391
12604
|
var typeSuffix = $3;
|
|
@@ -12410,7 +12623,7 @@ var BindingElement$$ = [BindingElement$0, BindingElement$1, BindingElement$2];
|
|
|
12410
12623
|
function BindingElement(ctx, state2) {
|
|
12411
12624
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingElement", BindingElement$$);
|
|
12412
12625
|
}
|
|
12413
|
-
var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(
|
|
12626
|
+
var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(BindingPattern, BindingIdentifier, EmptyBindingPattern), (0, import_lib2.$E)(BindingTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12414
12627
|
var ws = $1;
|
|
12415
12628
|
var dots = $2;
|
|
12416
12629
|
var binding = $3;
|
|
@@ -12426,7 +12639,7 @@ var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
|
|
|
12426
12639
|
rest: true
|
|
12427
12640
|
};
|
|
12428
12641
|
});
|
|
12429
|
-
var BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
12642
|
+
var BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(BindingPattern, BindingIdentifier), DotDotDot), function($skip, $loc, $0, $1, $2, $3) {
|
|
12430
12643
|
var ws = $1;
|
|
12431
12644
|
var binding = $2;
|
|
12432
12645
|
var dots = $3;
|
|
@@ -12514,13 +12727,17 @@ var FunctionExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(FunctionSign
|
|
|
12514
12727
|
block
|
|
12515
12728
|
};
|
|
12516
12729
|
});
|
|
12517
|
-
var FunctionExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(ArrowFunction), OpenParen, BinaryOp, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12730
|
+
var FunctionExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(ArrowFunction), OpenParen, __, BinaryOp, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
12518
12731
|
var open = $2;
|
|
12519
|
-
var
|
|
12520
|
-
var
|
|
12732
|
+
var ws1 = $3;
|
|
12733
|
+
var op = $4;
|
|
12734
|
+
var ws2 = $5;
|
|
12735
|
+
var close = $6;
|
|
12521
12736
|
if (op.special && op.call && !op.negated) return op.call;
|
|
12737
|
+
if (!ws1) ws1 = op.spaced ? [" "] : [];
|
|
12738
|
+
if (!ws2) ws2 = op.spaced ? [" "] : [];
|
|
12522
12739
|
const refA = makeRef("a"), refB = makeRef("b"), body = processBinaryOpExpression([refA, [
|
|
12523
|
-
[
|
|
12740
|
+
[ws1, op, ws2, refB]
|
|
12524
12741
|
// BinaryOpRHS
|
|
12525
12742
|
]]);
|
|
12526
12743
|
const parameterList = [[refA, ","], refB];
|
|
@@ -12552,6 +12769,8 @@ var FunctionExpression$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, N
|
|
|
12552
12769
|
var op = $4;
|
|
12553
12770
|
var ws2 = $5;
|
|
12554
12771
|
var close = $6;
|
|
12772
|
+
if (!ws1) ws1 = op.spaced ? [" "] : [];
|
|
12773
|
+
if (!ws2) ws2 = op.spaced ? [" "] : [];
|
|
12555
12774
|
const refB = makeRef("b");
|
|
12556
12775
|
const fn = makeAmpersandFunction({
|
|
12557
12776
|
ref: refB,
|
|
@@ -12618,6 +12837,8 @@ var FunctionExpression$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, _
|
|
|
12618
12837
|
var ws2 = $6;
|
|
12619
12838
|
var rhs = $7;
|
|
12620
12839
|
var close = $8;
|
|
12840
|
+
if (!ws1) ws1 = op.spaced ? [" "] : [];
|
|
12841
|
+
if (!ws2) ws2 = op.spaced ? [" "] : [];
|
|
12621
12842
|
const refA = makeRef("a");
|
|
12622
12843
|
const fn = makeAmpersandFunction({
|
|
12623
12844
|
ref: refA,
|
|
@@ -12642,10 +12863,9 @@ var OperatorDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, (
|
|
|
12642
12863
|
var w = $3;
|
|
12643
12864
|
var decl = $4;
|
|
12644
12865
|
decl.names.forEach((name) => state.operators.set(name, behavior));
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
};
|
|
12866
|
+
if (behavior?.error) decl = prepend(behavior.error, decl);
|
|
12867
|
+
decl = prepend(trimFirstSpace(w), decl);
|
|
12868
|
+
return decl;
|
|
12649
12869
|
});
|
|
12650
12870
|
var OperatorDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OperatorSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
12651
12871
|
var signature = $1;
|
|
@@ -12666,11 +12886,16 @@ var OperatorDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, _
|
|
|
12666
12886
|
var id = $3;
|
|
12667
12887
|
var behavior = $4;
|
|
12668
12888
|
var ids = $5;
|
|
12889
|
+
const children = [];
|
|
12669
12890
|
state.operators.set(id.name, behavior);
|
|
12670
|
-
|
|
12891
|
+
if (behavior?.error) children.push(behavior.error);
|
|
12892
|
+
ids.forEach(([, , id2, behavior2]) => {
|
|
12893
|
+
state.operators.set(id2.name, behavior2);
|
|
12894
|
+
if (behavior2?.error) children.push(behavior2.error);
|
|
12895
|
+
});
|
|
12671
12896
|
return {
|
|
12672
12897
|
id,
|
|
12673
|
-
children
|
|
12898
|
+
children
|
|
12674
12899
|
};
|
|
12675
12900
|
});
|
|
12676
12901
|
var OperatorDeclaration$$ = [OperatorDeclaration$0, OperatorDeclaration$1, OperatorDeclaration$2];
|
|
@@ -12708,7 +12933,7 @@ var OperatorSignature$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
12708
12933
|
generator: !!generator.length
|
|
12709
12934
|
},
|
|
12710
12935
|
block: null,
|
|
12711
|
-
children: [async, func, generator, w1, id, w2, parameters, returnType],
|
|
12936
|
+
children: [async, func, generator, w1, id, behavior?.error, w2, parameters, returnType],
|
|
12712
12937
|
behavior
|
|
12713
12938
|
};
|
|
12714
12939
|
});
|
|
@@ -12728,16 +12953,29 @@ function OperatorBehavior(ctx, state2) {
|
|
|
12728
12953
|
var OperatorPrecedence$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)((0, import_lib2.$EXPECT)($L27, 'OperatorPrecedence "tighter"'), (0, import_lib2.$EXPECT)($L28, 'OperatorPrecedence "looser"'), (0, import_lib2.$EXPECT)($L29, 'OperatorPrecedence "same"')), NonIdContinue, (0, import_lib2.$E)(_), (0, import_lib2.$C)(Identifier, (0, import_lib2.$S)(OpenParen, BinaryOp, CloseParen))), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
12729
12954
|
var mod = $2;
|
|
12730
12955
|
var op = $5;
|
|
12731
|
-
let prec
|
|
12956
|
+
let prec, error;
|
|
12957
|
+
if (op.type === "Identifier") {
|
|
12958
|
+
if (state.operators.has(op.name)) {
|
|
12959
|
+
prec = state.operators.get(op.name).prec;
|
|
12960
|
+
} else {
|
|
12961
|
+
prec = precedenceCustomDefault;
|
|
12962
|
+
error = {
|
|
12963
|
+
type: "Error",
|
|
12964
|
+
message: `Precedence refers to unknown operator ${op.name}`
|
|
12965
|
+
};
|
|
12966
|
+
}
|
|
12967
|
+
} else {
|
|
12968
|
+
prec = getPrecedence(op[1]);
|
|
12969
|
+
}
|
|
12732
12970
|
switch (mod) {
|
|
12733
12971
|
case "tighter":
|
|
12734
|
-
prec +=
|
|
12972
|
+
prec += precedenceStep;
|
|
12735
12973
|
break;
|
|
12736
12974
|
case "looser":
|
|
12737
|
-
prec -=
|
|
12975
|
+
prec -= precedenceStep;
|
|
12738
12976
|
break;
|
|
12739
12977
|
}
|
|
12740
|
-
return { prec };
|
|
12978
|
+
return { prec, error };
|
|
12741
12979
|
});
|
|
12742
12980
|
function OperatorPrecedence(ctx, state2) {
|
|
12743
12981
|
return (0, import_lib2.$EVENT)(ctx, state2, "OperatorPrecedence", OperatorPrecedence$0);
|
|
@@ -13435,9 +13673,9 @@ function RangeEnd(ctx, state2) {
|
|
|
13435
13673
|
var RangeExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, RangeDots, Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
13436
13674
|
var start = $1;
|
|
13437
13675
|
var ws = $2;
|
|
13438
|
-
var
|
|
13676
|
+
var range2 = $3;
|
|
13439
13677
|
var end = $4;
|
|
13440
|
-
return processRangeExpression(start, ws,
|
|
13678
|
+
return processRangeExpression(start, ws, range2, end);
|
|
13441
13679
|
});
|
|
13442
13680
|
var RangeExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, DotDot, (0, import_lib2.$Y)((0, import_lib2.$S)(__, CloseBracket))), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
13443
13681
|
var s = $1;
|
|
@@ -14575,6 +14813,7 @@ var BinaryOpSymbol$13 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L23, 'Bin
|
|
|
14575
14813
|
return {
|
|
14576
14814
|
$loc,
|
|
14577
14815
|
token: "instanceof",
|
|
14816
|
+
spaced: true,
|
|
14578
14817
|
relational: true,
|
|
14579
14818
|
special: true
|
|
14580
14819
|
};
|
|
@@ -14583,6 +14822,7 @@ var BinaryOpSymbol$14 = (0, import_lib2.$TV)((0, import_lib2.$EXPECT)($L84, 'Bin
|
|
|
14583
14822
|
return {
|
|
14584
14823
|
$loc,
|
|
14585
14824
|
token: "instanceof",
|
|
14825
|
+
spaced: true,
|
|
14586
14826
|
relational: true,
|
|
14587
14827
|
special: true,
|
|
14588
14828
|
negated: true
|
|
@@ -14658,6 +14898,7 @@ var BinaryOpSymbol$40 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
14658
14898
|
return {
|
|
14659
14899
|
$loc,
|
|
14660
14900
|
token: $1,
|
|
14901
|
+
spaced: true,
|
|
14661
14902
|
relational: true,
|
|
14662
14903
|
special: true
|
|
14663
14904
|
// for typeof shorthand
|
|
@@ -14760,6 +15001,7 @@ var CoffeeOfOp$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(OmittedNegation, __,
|
|
|
14760
15001
|
return {
|
|
14761
15002
|
$loc,
|
|
14762
15003
|
token: "in",
|
|
15004
|
+
spaced: true,
|
|
14763
15005
|
special: true,
|
|
14764
15006
|
negated: true
|
|
14765
15007
|
};
|
|
@@ -14781,6 +15023,7 @@ var NotOp$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)(
|
|
|
14781
15023
|
return {
|
|
14782
15024
|
$loc,
|
|
14783
15025
|
token: "instanceof",
|
|
15026
|
+
spaced: true,
|
|
14784
15027
|
relational: true,
|
|
14785
15028
|
special: true,
|
|
14786
15029
|
negated: true
|
|
@@ -14790,6 +15033,7 @@ var NotOp$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(In), function($skip, $loc
|
|
|
14790
15033
|
return {
|
|
14791
15034
|
$loc,
|
|
14792
15035
|
token: "in",
|
|
15036
|
+
spaced: true,
|
|
14793
15037
|
special: true,
|
|
14794
15038
|
negated: true
|
|
14795
15039
|
};
|
|
@@ -15575,10 +15819,13 @@ var ForDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(LetOrConstOrVar,
|
|
|
15575
15819
|
var ForDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertConst, (0, import_lib2.$N)(ActualMemberExpression), ForBinding), function($skip, $loc, $0, $1, $2, $3) {
|
|
15576
15820
|
var c = $1;
|
|
15577
15821
|
var binding = $3;
|
|
15822
|
+
if (gatherRecursive(binding, ($) => $.type === "PinPattern").length) {
|
|
15823
|
+
return $skip;
|
|
15824
|
+
}
|
|
15578
15825
|
return {
|
|
15579
15826
|
type: "ForDeclaration",
|
|
15580
15827
|
children: [c, binding],
|
|
15581
|
-
decl: c.token,
|
|
15828
|
+
decl: c.token.trimEnd(),
|
|
15582
15829
|
binding,
|
|
15583
15830
|
names: binding.names
|
|
15584
15831
|
};
|
|
@@ -15748,12 +15995,17 @@ function PatternExpressionList(ctx, state2) {
|
|
|
15748
15995
|
return (0, import_lib2.$EVENT)(ctx, state2, "PatternExpressionList", PatternExpressionList$0);
|
|
15749
15996
|
}
|
|
15750
15997
|
var PatternExpression$0 = BindingPattern;
|
|
15751
|
-
var PatternExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidIndentedApplication, (0, import_lib2.$E)((0, import_lib2.$P)(SingleLineBinaryOpRHS)), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
15752
|
-
var
|
|
15753
|
-
if (!
|
|
15998
|
+
var PatternExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(ForbidIndentedApplication, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(Caret))), (0, import_lib2.$P)(SingleLineBinaryOpRHS))), RestoreIndentedApplication), function($skip, $loc, $0, $1, $2, $3) {
|
|
15999
|
+
var body = $2;
|
|
16000
|
+
if (!body) return $skip;
|
|
16001
|
+
const [named, rhs] = body;
|
|
16002
|
+
let binding;
|
|
16003
|
+
if (named) [binding] = named;
|
|
15754
16004
|
return {
|
|
15755
16005
|
type: "ConditionFragment",
|
|
15756
|
-
children:
|
|
16006
|
+
children: [binding, rhs],
|
|
16007
|
+
binding,
|
|
16008
|
+
rhs
|
|
15757
16009
|
};
|
|
15758
16010
|
});
|
|
15759
16011
|
var PatternExpression$$ = [PatternExpression$0, PatternExpression$1];
|
|
@@ -15865,31 +16117,31 @@ var FinallyClause$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Finally, (0, impo
|
|
|
15865
16117
|
function FinallyClause(ctx, state2) {
|
|
15866
16118
|
return (0, import_lib2.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
|
|
15867
16119
|
}
|
|
15868
|
-
var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
16120
|
+
var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
|
|
15869
16121
|
var binding = $1;
|
|
15870
16122
|
var typeSuffix = $2;
|
|
15871
16123
|
return {
|
|
15872
16124
|
type: "CatchParameter",
|
|
15873
16125
|
binding,
|
|
15874
16126
|
typeSuffix,
|
|
15875
|
-
children:
|
|
16127
|
+
children: [binding, typeSuffix]
|
|
15876
16128
|
};
|
|
15877
16129
|
});
|
|
15878
|
-
var CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
16130
|
+
var CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
|
|
16131
|
+
return {
|
|
16132
|
+
type: "CatchPattern",
|
|
16133
|
+
children: $0,
|
|
16134
|
+
patterns: $1
|
|
16135
|
+
};
|
|
16136
|
+
});
|
|
16137
|
+
var CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
|
|
15879
16138
|
var binding = $1;
|
|
15880
16139
|
var typeSuffix = $2;
|
|
15881
16140
|
return {
|
|
15882
16141
|
type: "CatchParameter",
|
|
15883
16142
|
binding,
|
|
15884
16143
|
typeSuffix,
|
|
15885
|
-
children:
|
|
15886
|
-
};
|
|
15887
|
-
});
|
|
15888
|
-
var CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
|
|
15889
|
-
return {
|
|
15890
|
-
type: "CatchPattern",
|
|
15891
|
-
children: $0,
|
|
15892
|
-
patterns: $1
|
|
16144
|
+
children: $0
|
|
15893
16145
|
};
|
|
15894
16146
|
});
|
|
15895
16147
|
var CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
|
|
@@ -16383,12 +16635,15 @@ var ImportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_li
|
|
|
16383
16635
|
var imports = $5;
|
|
16384
16636
|
var ws2 = $6;
|
|
16385
16637
|
var from = $7;
|
|
16638
|
+
const errors = [];
|
|
16639
|
+
if (behavior?.error) errors.push(behavior.error);
|
|
16386
16640
|
imports.specifiers.forEach((spec) => {
|
|
16387
16641
|
state.operators.set(spec.binding.name, spec.behavior ?? behavior);
|
|
16642
|
+
if (spec.behavior?.error) errors.push(spec.behavior.error);
|
|
16388
16643
|
});
|
|
16389
16644
|
return {
|
|
16390
16645
|
type: "ImportDeclaration",
|
|
16391
|
-
children: [i, trimFirstSpace(ws1), imports, ws2, from],
|
|
16646
|
+
children: [i, ...errors, trimFirstSpace(ws1), imports, ws2, from],
|
|
16392
16647
|
// omit $2 = Operator and $3 = OperatorBehavior
|
|
16393
16648
|
imports,
|
|
16394
16649
|
from
|
|
@@ -16431,12 +16686,15 @@ var ImportDeclaration$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(ImpliedFromCl
|
|
|
16431
16686
|
var behavior = $6;
|
|
16432
16687
|
var ows = $7;
|
|
16433
16688
|
var imports = $8;
|
|
16689
|
+
const errors = [];
|
|
16690
|
+
if (behavior?.error) errors.push(behavior.error);
|
|
16434
16691
|
imports.specifiers.forEach((spec) => {
|
|
16435
16692
|
state.operators.set(spec.binding.name, spec.behavior ?? behavior);
|
|
16693
|
+
if (spec.behavior?.error) errors.push(spec.behavior.error);
|
|
16436
16694
|
});
|
|
16437
16695
|
return {
|
|
16438
16696
|
type: "ImportDeclaration",
|
|
16439
|
-
children: [i, iws, trimFirstSpace(ows), imports, fws, from],
|
|
16697
|
+
children: [i, iws, ...errors, trimFirstSpace(ows), imports, fws, from],
|
|
16440
16698
|
// omit Operator and OperatorBehavior
|
|
16441
16699
|
imports,
|
|
16442
16700
|
from
|
|
@@ -16618,7 +16876,7 @@ var OperatorImportSpecifier$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(__, Mod
|
|
|
16618
16876
|
return {
|
|
16619
16877
|
binding,
|
|
16620
16878
|
behavior,
|
|
16621
|
-
children: [$1, $2, $4, $5, $6, $7]
|
|
16879
|
+
children: [$1, $2, $3?.error, $4, $5, $6, $7]
|
|
16622
16880
|
};
|
|
16623
16881
|
});
|
|
16624
16882
|
var OperatorImportSpecifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(__, ImportedBinding, (0, import_lib2.$E)(OperatorBehavior), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
@@ -16627,7 +16885,7 @@ var OperatorImportSpecifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(__, Imp
|
|
|
16627
16885
|
return {
|
|
16628
16886
|
binding,
|
|
16629
16887
|
behavior,
|
|
16630
|
-
children: [$1, $2, $4]
|
|
16888
|
+
children: [$1, $2, $3?.error, $4]
|
|
16631
16889
|
};
|
|
16632
16890
|
});
|
|
16633
16891
|
var OperatorImportSpecifier$$ = [OperatorImportSpecifier$0, OperatorImportSpecifier$1];
|
|
@@ -17505,7 +17763,7 @@ var By$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L1
|
|
|
17505
17763
|
function By(ctx, state2) {
|
|
17506
17764
|
return (0, import_lib2.$EVENT)(ctx, state2, "By", By$0);
|
|
17507
17765
|
}
|
|
17508
|
-
var Caret$0 = (0, import_lib2.$
|
|
17766
|
+
var Caret$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'), (0, import_lib2.$N)((0, import_lib2.$EXPECT)($L22, 'Caret "^"'))), function($skip, $loc, $0, $1, $2) {
|
|
17509
17767
|
return { $loc, token: $1 };
|
|
17510
17768
|
});
|
|
17511
17769
|
function Caret(ctx, state2) {
|
|
@@ -17750,7 +18008,7 @@ function Import(ctx, state2) {
|
|
|
17750
18008
|
return (0, import_lib2.$EVENT)(ctx, state2, "Import", Import$0);
|
|
17751
18009
|
}
|
|
17752
18010
|
var In$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L180, 'In "in"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
17753
|
-
return { $loc, token: $1 };
|
|
18011
|
+
return { $loc, token: $1, spaced: true };
|
|
17754
18012
|
});
|
|
17755
18013
|
function In(ctx, state2) {
|
|
17756
18014
|
return (0, import_lib2.$EVENT)(ctx, state2, "In", In$0);
|