@danielx/civet 0.9.4 → 0.9.5
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 +6 -1
- package/dist/browser.js +351 -212
- package/dist/main.js +424 -223
- package/dist/main.mjs +424 -223
- package/package.json +2 -2
package/dist/main.mjs
CHANGED
|
@@ -1631,6 +1631,15 @@ function gatherRecursiveAll(node, predicate) {
|
|
|
1631
1631
|
}
|
|
1632
1632
|
|
|
1633
1633
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
|
|
1634
|
+
var range = (start, end) => {
|
|
1635
|
+
const length = end - start;
|
|
1636
|
+
if (length <= 0) return [];
|
|
1637
|
+
const arr = Array(length);
|
|
1638
|
+
for (let i = 0; i < length; ++i) {
|
|
1639
|
+
arr[i] = i + start;
|
|
1640
|
+
}
|
|
1641
|
+
return arr;
|
|
1642
|
+
};
|
|
1634
1643
|
function makeRef(base = "ref", id = base) {
|
|
1635
1644
|
return {
|
|
1636
1645
|
type: "Ref",
|
|
@@ -1643,7 +1652,7 @@ function needsRef(expression, base = "ref") {
|
|
|
1643
1652
|
return;
|
|
1644
1653
|
}
|
|
1645
1654
|
if (Array.isArray(expression)) {
|
|
1646
|
-
const nonempty = (
|
|
1655
|
+
const nonempty = range(0, expression.length).filter((i) => !isWhitespaceOrEmpty(expression[i]));
|
|
1647
1656
|
if (nonempty.length === 1) {
|
|
1648
1657
|
let ref1;
|
|
1649
1658
|
if (ref1 = needsRef(expression[nonempty[0]], base)) {
|
|
@@ -1659,8 +1668,9 @@ function needsRef(expression, base = "ref") {
|
|
|
1659
1668
|
case "Ref":
|
|
1660
1669
|
case "Identifier":
|
|
1661
1670
|
case "Literal":
|
|
1662
|
-
case "Placeholder":
|
|
1671
|
+
case "Placeholder": {
|
|
1663
1672
|
return;
|
|
1673
|
+
}
|
|
1664
1674
|
}
|
|
1665
1675
|
return makeRef(base);
|
|
1666
1676
|
}
|
|
@@ -1690,10 +1700,34 @@ function maybeRefAssignment(exp, base = "ref") {
|
|
|
1690
1700
|
return { ref, ...makeRefAssignment(ref, exp) };
|
|
1691
1701
|
}
|
|
1692
1702
|
}
|
|
1703
|
+
function populateRefs(statements) {
|
|
1704
|
+
const refNodes = gatherRecursive(statements, ($) => $.type === "Ref");
|
|
1705
|
+
if (!refNodes.length) {
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
const ids = gatherRecursive(statements, ($1) => $1.type === "Identifier");
|
|
1709
|
+
const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
1710
|
+
for (let i1 = 0, len3 = refNodes.length; i1 < len3; i1++) {
|
|
1711
|
+
const ref = refNodes[i1];
|
|
1712
|
+
if (!(ref.type === "Ref")) {
|
|
1713
|
+
continue;
|
|
1714
|
+
}
|
|
1715
|
+
const { base } = ref;
|
|
1716
|
+
ref.type = "Identifier";
|
|
1717
|
+
let n = 0;
|
|
1718
|
+
let name = base;
|
|
1719
|
+
while (names.has(name)) {
|
|
1720
|
+
n++;
|
|
1721
|
+
name = `${base}${n}`;
|
|
1722
|
+
}
|
|
1723
|
+
names.add(name);
|
|
1724
|
+
ref.children = ref.names = [name];
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1693
1727
|
|
|
1694
1728
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
|
|
1695
1729
|
function adjustAtBindings(statements, asThis = false) {
|
|
1696
|
-
for (let ref1 = gatherRecursiveAll(statements, ($) =>
|
|
1730
|
+
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
1697
1731
|
const binding = ref1[i1];
|
|
1698
1732
|
const { ref } = binding;
|
|
1699
1733
|
if (asThis) {
|
|
@@ -1711,7 +1745,7 @@ function adjustAtBindings(statements, asThis = false) {
|
|
|
1711
1745
|
}
|
|
1712
1746
|
}
|
|
1713
1747
|
function adjustBindingElements(elements) {
|
|
1714
|
-
const names = elements.flatMap(($
|
|
1748
|
+
const names = elements.flatMap(($2) => $2.names || []);
|
|
1715
1749
|
const { length } = elements;
|
|
1716
1750
|
let blockPrefix, restIndex = -1, restCount = 0;
|
|
1717
1751
|
for (let i2 = 0, len1 = elements.length; i2 < len1; i2++) {
|
|
@@ -1769,16 +1803,40 @@ function adjustBindingElements(elements) {
|
|
|
1769
1803
|
length
|
|
1770
1804
|
};
|
|
1771
1805
|
}
|
|
1806
|
+
function gatherSubbindings(node, subbindings = []) {
|
|
1807
|
+
for (let ref2 = gatherRecursiveAll(node, ($) => $.subbinding != null), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
1808
|
+
const p = ref2[i3];
|
|
1809
|
+
const { subbinding } = p;
|
|
1810
|
+
subbindings.push(", ", subbinding);
|
|
1811
|
+
gatherSubbindings(subbinding, subbindings);
|
|
1812
|
+
}
|
|
1813
|
+
return subbindings;
|
|
1814
|
+
}
|
|
1815
|
+
function simplifyBindingProperties(node) {
|
|
1816
|
+
const results = [];
|
|
1817
|
+
for (let ref3 = gatherRecursiveAll(node, ($3) => $3.type === "BindingProperty"), i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
|
|
1818
|
+
const p = ref3[i4];
|
|
1819
|
+
const { name, value } = p;
|
|
1820
|
+
if (value?.type === "NamedBindingPattern" && value.binding === name) {
|
|
1821
|
+
const [ws] = p.children;
|
|
1822
|
+
results.push(p.children = [ws, name, p.delim]);
|
|
1823
|
+
} else {
|
|
1824
|
+
results.push(void 0);
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
;
|
|
1828
|
+
return results;
|
|
1829
|
+
}
|
|
1772
1830
|
function gatherBindingCode(statements, opts) {
|
|
1773
1831
|
const thisAssignments = [];
|
|
1774
1832
|
const splices = [];
|
|
1775
1833
|
function insertRestSplices(s, p, thisAssignments2) {
|
|
1776
1834
|
let m;
|
|
1777
|
-
for (let
|
|
1835
|
+
for (let ref4 = gatherRecursiveAll(
|
|
1778
1836
|
s,
|
|
1779
1837
|
(n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding" || opts?.assignPins && (m = n.type, m === "PinPattern" || m === "PinProperty")
|
|
1780
|
-
),
|
|
1781
|
-
let n =
|
|
1838
|
+
), i5 = 0, len4 = ref4.length; i5 < len4; i5++) {
|
|
1839
|
+
let n = ref4[i5];
|
|
1782
1840
|
if (n.type === "AtBinding") {
|
|
1783
1841
|
const { ref } = n;
|
|
1784
1842
|
const { id } = ref;
|
|
@@ -1787,7 +1845,7 @@ function gatherBindingCode(statements, opts) {
|
|
|
1787
1845
|
}
|
|
1788
1846
|
if (opts?.assignPins) {
|
|
1789
1847
|
if (n.type === "PinProperty") {
|
|
1790
|
-
n.children = n.children.flatMap(($
|
|
1848
|
+
n.children = n.children.flatMap(($4) => $4 === n.name ? [n.name, ": ", n.value] : $4);
|
|
1791
1849
|
updateParentPointers(n);
|
|
1792
1850
|
n = n.value;
|
|
1793
1851
|
}
|
|
@@ -1809,8 +1867,8 @@ function gatherBindingCode(statements, opts) {
|
|
|
1809
1867
|
}
|
|
1810
1868
|
}
|
|
1811
1869
|
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
1812
|
-
for (let
|
|
1813
|
-
const id =
|
|
1870
|
+
for (let ref5 = n.names, i6 = 0, len5 = ref5.length; i6 < len5; i6++) {
|
|
1871
|
+
const id = ref5[i6];
|
|
1814
1872
|
thisAssignments2.push({
|
|
1815
1873
|
type: "AssignmentExpression",
|
|
1816
1874
|
children: [`this.${id} = `, id],
|
|
@@ -1828,8 +1886,8 @@ function gatherBindingCode(statements, opts) {
|
|
|
1828
1886
|
return [splices, thisAssignments];
|
|
1829
1887
|
}
|
|
1830
1888
|
function arrayElementHasTrailingComma(elementNode) {
|
|
1831
|
-
let
|
|
1832
|
-
const lastChild = (
|
|
1889
|
+
let ref6;
|
|
1890
|
+
const lastChild = (ref6 = elementNode.children)[ref6.length - 1];
|
|
1833
1891
|
return lastChild && lastChild[lastChild.length - 1]?.token === ",";
|
|
1834
1892
|
}
|
|
1835
1893
|
function gatherBindingPatternTypeSuffix(pattern) {
|
|
@@ -1840,9 +1898,9 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1840
1898
|
switch (pattern.type) {
|
|
1841
1899
|
case "ArrayBindingPattern": {
|
|
1842
1900
|
{
|
|
1843
|
-
const
|
|
1844
|
-
for (let
|
|
1845
|
-
const elem =
|
|
1901
|
+
const results1 = [];
|
|
1902
|
+
for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
|
|
1903
|
+
const elem = ref7[i7];
|
|
1846
1904
|
let { typeSuffix } = elem;
|
|
1847
1905
|
typeSuffix ??= elem.binding?.typeSuffix;
|
|
1848
1906
|
if (typeSuffix) {
|
|
@@ -1859,10 +1917,10 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1859
1917
|
} else {
|
|
1860
1918
|
typeElement[0] ??= "unknown";
|
|
1861
1919
|
}
|
|
1862
|
-
|
|
1920
|
+
results1.push(typeElement);
|
|
1863
1921
|
}
|
|
1864
1922
|
;
|
|
1865
|
-
const types =
|
|
1923
|
+
const types = results1;
|
|
1866
1924
|
if (count) {
|
|
1867
1925
|
const t = [": [", types, "]"];
|
|
1868
1926
|
pattern.typeSuffix = {
|
|
@@ -1879,9 +1937,9 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1879
1937
|
case "ObjectBindingPattern": {
|
|
1880
1938
|
{
|
|
1881
1939
|
let restType;
|
|
1882
|
-
const
|
|
1883
|
-
for (let
|
|
1884
|
-
const prop =
|
|
1940
|
+
const results2 = [];
|
|
1941
|
+
for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
|
|
1942
|
+
const prop = ref8[i8];
|
|
1885
1943
|
let { typeSuffix } = prop;
|
|
1886
1944
|
typeSuffix ??= prop.value?.typeSuffix;
|
|
1887
1945
|
if (typeSuffix) {
|
|
@@ -1895,12 +1953,12 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1895
1953
|
switch (prop.type) {
|
|
1896
1954
|
case "BindingProperty": {
|
|
1897
1955
|
const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
|
|
1898
|
-
|
|
1956
|
+
results2.push([...ws, prop.name, typeSuffix, prop.delim]);
|
|
1899
1957
|
break;
|
|
1900
1958
|
}
|
|
1901
1959
|
case "AtBindingProperty": {
|
|
1902
1960
|
const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
|
|
1903
|
-
|
|
1961
|
+
results2.push([...ws, prop.ref.id.replace(/^#/, ""), typeSuffix, prop.delim]);
|
|
1904
1962
|
break;
|
|
1905
1963
|
}
|
|
1906
1964
|
case "BindingRestProperty": {
|
|
@@ -1910,7 +1968,7 @@ function gatherBindingPatternTypeSuffix(pattern) {
|
|
|
1910
1968
|
}
|
|
1911
1969
|
}
|
|
1912
1970
|
;
|
|
1913
|
-
const types =
|
|
1971
|
+
const types = results2;
|
|
1914
1972
|
if (count) {
|
|
1915
1973
|
const t = ["{", types, "}"];
|
|
1916
1974
|
if (restType != null) {
|
|
@@ -3638,7 +3696,8 @@ function processParams(f) {
|
|
|
3638
3696
|
parameters.names.push(...rest.names || []);
|
|
3639
3697
|
rest.children.pop();
|
|
3640
3698
|
if (after.length) {
|
|
3641
|
-
|
|
3699
|
+
let m4;
|
|
3700
|
+
if (m4 = rest.binding.type, m4 === "ArrayBindingPattern" || m4 === "ObjectBindingPattern" || m4 === "NamedBindingPattern") {
|
|
3642
3701
|
parameters.parameters.push({
|
|
3643
3702
|
type: "Error",
|
|
3644
3703
|
message: "Non-end rest parameter cannot be binding pattern"
|
|
@@ -3770,6 +3829,9 @@ function processParams(f) {
|
|
|
3770
3829
|
injectParamProps: isConstructor,
|
|
3771
3830
|
assignPins: true
|
|
3772
3831
|
});
|
|
3832
|
+
const subbindings = gatherSubbindings(parameters.parameters);
|
|
3833
|
+
simplifyBindingProperties(parameters.parameters);
|
|
3834
|
+
simplifyBindingProperties(subbindings);
|
|
3773
3835
|
if (isConstructor) {
|
|
3774
3836
|
const { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
|
|
3775
3837
|
if (ancestor != null) {
|
|
@@ -3777,8 +3839,8 @@ function processParams(f) {
|
|
|
3777
3839
|
const classExpressions = ancestor.body.expressions;
|
|
3778
3840
|
let index2 = findChildIndex(classExpressions, f);
|
|
3779
3841
|
assert.notEqual(index2, -1, "Could not find constructor in class");
|
|
3780
|
-
let
|
|
3781
|
-
while (
|
|
3842
|
+
let m5;
|
|
3843
|
+
while (m5 = classExpressions[index2 - 1]?.[1], typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "MethodDefinition" && "name" in m5 && m5.name === "constructor") {
|
|
3782
3844
|
index2--;
|
|
3783
3845
|
}
|
|
3784
3846
|
const fStatement = classExpressions[index2];
|
|
@@ -3818,6 +3880,15 @@ function processParams(f) {
|
|
|
3818
3880
|
children: [";"]
|
|
3819
3881
|
};
|
|
3820
3882
|
let prefix = [];
|
|
3883
|
+
if (subbindings.length) {
|
|
3884
|
+
prefix.push(makeNode({
|
|
3885
|
+
type: "Declaration",
|
|
3886
|
+
children: ["const ", subbindings.slice(1)],
|
|
3887
|
+
names: subbindings.flatMap(($16) => $16.names ?? []),
|
|
3888
|
+
bindings: [],
|
|
3889
|
+
decl: "const"
|
|
3890
|
+
}));
|
|
3891
|
+
}
|
|
3821
3892
|
for (let ref20 = splices, i11 = 0, len10 = ref20.length; i11 < len10; i11++) {
|
|
3822
3893
|
const binding = ref20[i11];
|
|
3823
3894
|
assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding");
|
|
@@ -3871,7 +3942,7 @@ function processSignature(f) {
|
|
|
3871
3942
|
f.async.push("async ");
|
|
3872
3943
|
signature.modifier.async = true;
|
|
3873
3944
|
} else {
|
|
3874
|
-
for (let ref21 = gatherRecursiveWithinFunction(block, ($
|
|
3945
|
+
for (let ref21 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
|
|
3875
3946
|
const a = ref21[i12];
|
|
3876
3947
|
const i = findChildIndex(a.parent, a);
|
|
3877
3948
|
a.parent.children.splice(i + 1, 0, {
|
|
@@ -3886,9 +3957,9 @@ function processSignature(f) {
|
|
|
3886
3957
|
f.generator.push("*");
|
|
3887
3958
|
signature.modifier.generator = true;
|
|
3888
3959
|
} else {
|
|
3889
|
-
for (let ref22 = gatherRecursiveWithinFunction(block, ($
|
|
3960
|
+
for (let ref22 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
|
|
3890
3961
|
const y = ref22[i13];
|
|
3891
|
-
const i = y.children.findIndex(($
|
|
3962
|
+
const i = y.children.findIndex(($19) => $19.type === "Yield");
|
|
3892
3963
|
y.children.splice(i + 1, 0, {
|
|
3893
3964
|
type: "Error",
|
|
3894
3965
|
message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
|
|
@@ -3901,7 +3972,7 @@ function processSignature(f) {
|
|
|
3901
3972
|
}
|
|
3902
3973
|
}
|
|
3903
3974
|
function processFunctions(statements, config2) {
|
|
3904
|
-
for (let ref23 = gatherRecursiveAll(statements, ($
|
|
3975
|
+
for (let ref23 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
|
|
3905
3976
|
const f = ref23[i14];
|
|
3906
3977
|
if (f.type === "FunctionExpression" || f.type === "MethodDefinition") {
|
|
3907
3978
|
implicitFunctionBlock(f);
|
|
@@ -3971,7 +4042,7 @@ function expressionizeIteration(exp) {
|
|
|
3971
4042
|
}
|
|
3972
4043
|
}
|
|
3973
4044
|
function processIterationExpressions(statements) {
|
|
3974
|
-
for (let ref25 = gatherRecursiveAll(statements, ($
|
|
4045
|
+
for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
|
|
3975
4046
|
const s = ref25[i15];
|
|
3976
4047
|
expressionizeIteration(s);
|
|
3977
4048
|
}
|
|
@@ -4021,12 +4092,12 @@ function processCoffeeDo(ws, expression) {
|
|
|
4021
4092
|
const newParameters = {
|
|
4022
4093
|
...parameters,
|
|
4023
4094
|
parameters: newParameterList,
|
|
4024
|
-
children: parameters.children.map(($
|
|
4095
|
+
children: parameters.children.map(($22) => $22 === parameterList ? newParameterList : $22)
|
|
4025
4096
|
};
|
|
4026
4097
|
expression = {
|
|
4027
4098
|
...expression,
|
|
4028
4099
|
parameters: newParameters,
|
|
4029
|
-
children: expression.children.map(($
|
|
4100
|
+
children: expression.children.map(($23) => $23 === parameters ? newParameters : $23)
|
|
4030
4101
|
};
|
|
4031
4102
|
}
|
|
4032
4103
|
return {
|
|
@@ -4048,7 +4119,7 @@ function makeAmpersandFunction(rhs) {
|
|
|
4048
4119
|
ref = makeRef("$");
|
|
4049
4120
|
inplacePrepend(ref, body);
|
|
4050
4121
|
}
|
|
4051
|
-
if (startsWithPredicate(body, ($
|
|
4122
|
+
if (startsWithPredicate(body, ($24) => $24.type === "ObjectExpression")) {
|
|
4052
4123
|
body = makeLeftHandSideExpression(body);
|
|
4053
4124
|
}
|
|
4054
4125
|
const parameterList = [
|
|
@@ -4844,17 +4915,15 @@ function getPatternConditions(pattern, ref, conditions = []) {
|
|
|
4844
4915
|
break;
|
|
4845
4916
|
}
|
|
4846
4917
|
case "ConditionFragment": {
|
|
4847
|
-
let {
|
|
4848
|
-
if (
|
|
4849
|
-
let [first, ...rest] =
|
|
4918
|
+
let { rhs } = pattern;
|
|
4919
|
+
if (rhs.length) {
|
|
4920
|
+
let [first, ...rest] = rhs;
|
|
4850
4921
|
let [ws, ...op] = first;
|
|
4851
4922
|
ws = [" "].concat(ws);
|
|
4852
4923
|
first = [ws, ...op];
|
|
4853
|
-
|
|
4924
|
+
rhs = [first, ...rest];
|
|
4854
4925
|
}
|
|
4855
|
-
conditions.push(
|
|
4856
|
-
processBinaryOpExpression([ref, children])
|
|
4857
|
-
);
|
|
4926
|
+
conditions.push(processBinaryOpExpression([ref, rhs]));
|
|
4858
4927
|
break;
|
|
4859
4928
|
}
|
|
4860
4929
|
case "RegularExpressionLiteral": {
|
|
@@ -4872,6 +4941,10 @@ function getPatternConditions(pattern, ref, conditions = []) {
|
|
|
4872
4941
|
]);
|
|
4873
4942
|
break;
|
|
4874
4943
|
}
|
|
4944
|
+
case "NamedBindingPattern": {
|
|
4945
|
+
getPatternConditions(pattern.pattern, ref, conditions);
|
|
4946
|
+
break;
|
|
4947
|
+
}
|
|
4875
4948
|
case "Literal": {
|
|
4876
4949
|
conditions.push([
|
|
4877
4950
|
ref,
|
|
@@ -4901,43 +4974,60 @@ function getPatternBlockPrefix(pattern, ref, decl = "const ", typeSuffix) {
|
|
|
4901
4974
|
}
|
|
4902
4975
|
case "Literal":
|
|
4903
4976
|
case "RegularExpressionLiteral":
|
|
4904
|
-
case "PinPattern":
|
|
4905
|
-
case "ConditionFragment": {
|
|
4977
|
+
case "PinPattern": {
|
|
4906
4978
|
return;
|
|
4907
4979
|
}
|
|
4980
|
+
case "ConditionFragment": {
|
|
4981
|
+
if (!pattern.binding) {
|
|
4982
|
+
return;
|
|
4983
|
+
}
|
|
4984
|
+
;
|
|
4985
|
+
break;
|
|
4986
|
+
}
|
|
4908
4987
|
}
|
|
4909
4988
|
let [splices, thisAssignments] = gatherBindingCode(pattern);
|
|
4910
4989
|
const patternBindings2 = nonMatcherBindings(pattern);
|
|
4911
|
-
const
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
;
|
|
4917
|
-
const
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4990
|
+
const subbindings = gatherSubbindings(patternBindings2);
|
|
4991
|
+
simplifyBindingProperties(patternBindings2);
|
|
4992
|
+
simplifyBindingProperties(subbindings);
|
|
4993
|
+
splices = splices.flatMap((s) => [", ", nonMatcherBindings(s)]);
|
|
4994
|
+
thisAssignments = thisAssignments.map(($7) => ["", $7, ";"]);
|
|
4995
|
+
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices, subbindings]);
|
|
4996
|
+
const blockPrefix = [];
|
|
4997
|
+
if (ref || subbindings.length || splices.length) {
|
|
4998
|
+
const children = [decl];
|
|
4999
|
+
if (ref) {
|
|
5000
|
+
children.push(patternBindings2, typeSuffix, " = ", ref);
|
|
5001
|
+
}
|
|
5002
|
+
children.push(...subbindings);
|
|
5003
|
+
children.push(...splices);
|
|
5004
|
+
if (!ref) {
|
|
5005
|
+
children.splice(1, 1);
|
|
5006
|
+
}
|
|
5007
|
+
blockPrefix.push(["", {
|
|
4923
5008
|
type: "Declaration",
|
|
4924
|
-
children
|
|
5009
|
+
children,
|
|
5010
|
+
decl,
|
|
4925
5011
|
names: [],
|
|
4926
5012
|
bindings: []
|
|
4927
5013
|
// avoid implicit return of any bindings
|
|
4928
|
-
}, ";"]
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
];
|
|
5014
|
+
}, ";"]);
|
|
5015
|
+
}
|
|
5016
|
+
blockPrefix.push(...thisAssignments);
|
|
5017
|
+
blockPrefix.push(...duplicateDeclarations.map(($8) => ["", $8, ";"]));
|
|
5018
|
+
if (!blockPrefix.length) {
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
return blockPrefix;
|
|
4932
5022
|
}
|
|
4933
5023
|
function elideMatchersFromArrayBindings(elements) {
|
|
4934
|
-
const
|
|
4935
|
-
for (let
|
|
4936
|
-
const element = elements[
|
|
5024
|
+
const results = [];
|
|
5025
|
+
for (let i5 = 0, len4 = elements.length; i5 < len4; i5++) {
|
|
5026
|
+
const element = elements[i5];
|
|
4937
5027
|
switch (element.type) {
|
|
4938
5028
|
case "BindingRestElement":
|
|
4939
5029
|
case "ElisionElement": {
|
|
4940
|
-
|
|
5030
|
+
results.push(element);
|
|
4941
5031
|
break;
|
|
4942
5032
|
}
|
|
4943
5033
|
case "BindingElement": {
|
|
@@ -4946,12 +5036,12 @@ function elideMatchersFromArrayBindings(elements) {
|
|
|
4946
5036
|
case "RegularExpressionLiteral":
|
|
4947
5037
|
case "StringLiteral":
|
|
4948
5038
|
case "PinPattern": {
|
|
4949
|
-
|
|
5039
|
+
results.push(element.delim);
|
|
4950
5040
|
break;
|
|
4951
5041
|
}
|
|
4952
5042
|
default: {
|
|
4953
5043
|
const binding = nonMatcherBindings(element.binding);
|
|
4954
|
-
|
|
5044
|
+
results.push(makeNode({
|
|
4955
5045
|
...element,
|
|
4956
5046
|
binding,
|
|
4957
5047
|
children: element.children.map((c) => {
|
|
@@ -4966,29 +5056,23 @@ function elideMatchersFromArrayBindings(elements) {
|
|
|
4966
5056
|
}
|
|
4967
5057
|
}
|
|
4968
5058
|
;
|
|
4969
|
-
return
|
|
5059
|
+
return results;
|
|
4970
5060
|
}
|
|
4971
5061
|
function elideMatchersFromPropertyBindings(properties) {
|
|
4972
|
-
const
|
|
4973
|
-
for (let
|
|
4974
|
-
const p = properties[
|
|
5062
|
+
const results1 = [];
|
|
5063
|
+
for (let i6 = 0, len5 = properties.length; i6 < len5; i6++) {
|
|
5064
|
+
const p = properties[i6];
|
|
4975
5065
|
switch (p.type) {
|
|
4976
5066
|
case "BindingProperty":
|
|
4977
5067
|
case "PinProperty": {
|
|
4978
|
-
const { children, name, value
|
|
5068
|
+
const { children, name, value } = p;
|
|
4979
5069
|
const [ws] = children;
|
|
4980
5070
|
const shouldElide = name.type === "NumericLiteral" && !value?.name || name.type === "ComputedPropertyName" && value?.subtype === "NumericLiteral";
|
|
4981
5071
|
if (shouldElide) {
|
|
4982
|
-
|
|
4983
|
-
results2.push({
|
|
4984
|
-
type: "Error",
|
|
4985
|
-
message: `Cannot bind ${name.type}`
|
|
4986
|
-
});
|
|
4987
|
-
} else {
|
|
4988
|
-
continue;
|
|
4989
|
-
}
|
|
5072
|
+
continue;
|
|
4990
5073
|
} else {
|
|
4991
5074
|
let contents;
|
|
5075
|
+
let m1;
|
|
4992
5076
|
switch (value?.type) {
|
|
4993
5077
|
case "ArrayBindingPattern":
|
|
4994
5078
|
case "ObjectBindingPattern": {
|
|
@@ -5005,22 +5089,28 @@ function elideMatchersFromPropertyBindings(properties) {
|
|
|
5005
5089
|
contents = p;
|
|
5006
5090
|
break;
|
|
5007
5091
|
}
|
|
5092
|
+
case "NamedBindingPattern": {
|
|
5093
|
+
const bindings = nonMatcherBindings(value.pattern);
|
|
5094
|
+
contents = {
|
|
5095
|
+
...p,
|
|
5096
|
+
subbinding: (m1 = bindings?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern" || m1 === "Identifier") ? [
|
|
5097
|
+
bindings,
|
|
5098
|
+
" = ",
|
|
5099
|
+
name
|
|
5100
|
+
] : void 0
|
|
5101
|
+
};
|
|
5102
|
+
if (p.name === value.binding) {
|
|
5103
|
+
contents.children = [ws, name, p.delim];
|
|
5104
|
+
}
|
|
5105
|
+
;
|
|
5106
|
+
break;
|
|
5107
|
+
}
|
|
5008
5108
|
default: {
|
|
5009
5109
|
contents = void 0;
|
|
5010
5110
|
}
|
|
5011
5111
|
}
|
|
5012
|
-
if (
|
|
5013
|
-
|
|
5014
|
-
...p,
|
|
5015
|
-
children: [ws, name, p.delim],
|
|
5016
|
-
subbinding: contents?.value ? [
|
|
5017
|
-
contents.value,
|
|
5018
|
-
" = ",
|
|
5019
|
-
name
|
|
5020
|
-
] : void 0
|
|
5021
|
-
});
|
|
5022
|
-
} else if (contents) {
|
|
5023
|
-
results2.push(contents);
|
|
5112
|
+
if (contents) {
|
|
5113
|
+
results1.push(contents);
|
|
5024
5114
|
} else {
|
|
5025
5115
|
continue;
|
|
5026
5116
|
}
|
|
@@ -5029,14 +5119,15 @@ function elideMatchersFromPropertyBindings(properties) {
|
|
|
5029
5119
|
break;
|
|
5030
5120
|
}
|
|
5031
5121
|
default: {
|
|
5032
|
-
|
|
5122
|
+
results1.push(p);
|
|
5033
5123
|
}
|
|
5034
5124
|
}
|
|
5035
5125
|
}
|
|
5036
5126
|
;
|
|
5037
|
-
return
|
|
5127
|
+
return results1;
|
|
5038
5128
|
}
|
|
5039
5129
|
function nonMatcherBindings(pattern) {
|
|
5130
|
+
let m2;
|
|
5040
5131
|
switch (pattern.type) {
|
|
5041
5132
|
case "ArrayBindingPattern":
|
|
5042
5133
|
case "PostRestBindingElements": {
|
|
@@ -5044,7 +5135,7 @@ function nonMatcherBindings(pattern) {
|
|
|
5044
5135
|
return makeNode({
|
|
5045
5136
|
...pattern,
|
|
5046
5137
|
elements,
|
|
5047
|
-
children: pattern.children.map(($
|
|
5138
|
+
children: pattern.children.map(($9) => $9 === pattern.elements ? elements : $9)
|
|
5048
5139
|
});
|
|
5049
5140
|
}
|
|
5050
5141
|
case "ObjectBindingPattern": {
|
|
@@ -5052,9 +5143,19 @@ function nonMatcherBindings(pattern) {
|
|
|
5052
5143
|
return makeNode({
|
|
5053
5144
|
...pattern,
|
|
5054
5145
|
properties,
|
|
5055
|
-
children: pattern.children.map(($
|
|
5146
|
+
children: pattern.children.map(($10) => $10 === pattern.properties ? properties : $10)
|
|
5056
5147
|
});
|
|
5057
5148
|
}
|
|
5149
|
+
case "NamedBindingPattern": {
|
|
5150
|
+
const bindings = nonMatcherBindings(pattern.pattern);
|
|
5151
|
+
return makeNode({
|
|
5152
|
+
...pattern,
|
|
5153
|
+
subbinding: (m2 = bindings?.type, m2 === "ArrayBindingPattern" || m2 === "ObjectBindingPattern" || m2 === "Identifier") ? [bindings, " = ", pattern.binding] : void 0
|
|
5154
|
+
});
|
|
5155
|
+
}
|
|
5156
|
+
case "ConditionFragment": {
|
|
5157
|
+
return pattern.binding;
|
|
5158
|
+
}
|
|
5058
5159
|
default: {
|
|
5059
5160
|
return pattern;
|
|
5060
5161
|
}
|
|
@@ -5070,11 +5171,11 @@ function aggregateDuplicateBindings(bindings) {
|
|
|
5070
5171
|
);
|
|
5071
5172
|
const declarations = [];
|
|
5072
5173
|
const propsGroupedByName = /* @__PURE__ */ new Map();
|
|
5073
|
-
for (let
|
|
5074
|
-
const p = props[
|
|
5174
|
+
for (let i7 = 0, len6 = props.length; i7 < len6; i7++) {
|
|
5175
|
+
const p = props[i7];
|
|
5075
5176
|
const { name, value } = p;
|
|
5076
|
-
let
|
|
5077
|
-
if (
|
|
5177
|
+
let m3;
|
|
5178
|
+
if (m3 = value?.type, m3 === "ArrayBindingPattern" || m3 === "ObjectBindingPattern") {
|
|
5078
5179
|
continue;
|
|
5079
5180
|
}
|
|
5080
5181
|
const key = value?.name || name?.name || name;
|
|
@@ -5096,8 +5197,8 @@ function aggregateDuplicateBindings(bindings) {
|
|
|
5096
5197
|
pos: 0,
|
|
5097
5198
|
input: key
|
|
5098
5199
|
})) {
|
|
5099
|
-
for (let
|
|
5100
|
-
const p = shared[
|
|
5200
|
+
for (let i8 = 0, len7 = shared.length; i8 < len7; i8++) {
|
|
5201
|
+
const p = shared[i8];
|
|
5101
5202
|
aliasBinding(p, makeRef(`_${key}`, key));
|
|
5102
5203
|
}
|
|
5103
5204
|
return;
|
|
@@ -5189,8 +5290,18 @@ function processDeclarations(statements) {
|
|
|
5189
5290
|
if (!(bindings != null)) {
|
|
5190
5291
|
continue;
|
|
5191
5292
|
}
|
|
5192
|
-
for (let i2 =
|
|
5193
|
-
const
|
|
5293
|
+
for (let i2 = bindings.length + -1; i2 >= 0; --i2) {
|
|
5294
|
+
const i = i2;
|
|
5295
|
+
const binding = bindings[i];
|
|
5296
|
+
const subbindings = gatherSubbindings(binding);
|
|
5297
|
+
if (subbindings.length) {
|
|
5298
|
+
simplifyBindingProperties(binding);
|
|
5299
|
+
simplifyBindingProperties(subbindings);
|
|
5300
|
+
spliceChild(declaration, binding, 1, binding, subbindings);
|
|
5301
|
+
}
|
|
5302
|
+
}
|
|
5303
|
+
for (let i3 = 0, len22 = bindings.length; i3 < len22; i3++) {
|
|
5304
|
+
const binding = bindings[i3];
|
|
5194
5305
|
let { typeSuffix, initializer } = binding;
|
|
5195
5306
|
if (typeSuffix && typeSuffix.optional) {
|
|
5196
5307
|
if (initializer && !typeSuffix.t) {
|
|
@@ -5228,6 +5339,25 @@ function processDeclarations(statements) {
|
|
|
5228
5339
|
}
|
|
5229
5340
|
}
|
|
5230
5341
|
}
|
|
5342
|
+
for (let ref2 = gatherRecursiveAll(statements, ($1) => $1.type === "ForStatement"), i4 = 0, len3 = ref2.length; i4 < len3; i4++) {
|
|
5343
|
+
const statement = ref2[i4];
|
|
5344
|
+
const { declaration } = statement;
|
|
5345
|
+
if (!(declaration?.type === "ForDeclaration")) {
|
|
5346
|
+
continue;
|
|
5347
|
+
}
|
|
5348
|
+
const { binding } = declaration;
|
|
5349
|
+
const blockPrefix = getPatternBlockPrefix(
|
|
5350
|
+
binding.pattern,
|
|
5351
|
+
void 0,
|
|
5352
|
+
append(declaration.decl, " "),
|
|
5353
|
+
binding.typeSuffix
|
|
5354
|
+
);
|
|
5355
|
+
simplifyBindingProperties(binding);
|
|
5356
|
+
if (blockPrefix != null) {
|
|
5357
|
+
statement.block.expressions.unshift(...blockPrefix);
|
|
5358
|
+
braceBlock(statement.block);
|
|
5359
|
+
}
|
|
5360
|
+
}
|
|
5231
5361
|
}
|
|
5232
5362
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
5233
5363
|
let { expression: exp } = initializer;
|
|
@@ -5371,8 +5501,7 @@ function processDeclarationConditionStatement(s) {
|
|
|
5371
5501
|
}
|
|
5372
5502
|
let { expression } = condition;
|
|
5373
5503
|
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]) {
|
|
5374
|
-
const {
|
|
5375
|
-
const type = [type1, type2];
|
|
5504
|
+
const { children: [[], { expression: expression2 }] } = expression;
|
|
5376
5505
|
expression = expression2;
|
|
5377
5506
|
}
|
|
5378
5507
|
processDeclarationCondition(expression, condition.expression, s);
|
|
@@ -5397,8 +5526,8 @@ function processDeclarationConditionStatement(s) {
|
|
|
5397
5526
|
({ children } = condition.expression.children[1]);
|
|
5398
5527
|
}
|
|
5399
5528
|
children.unshift("(");
|
|
5400
|
-
for (let
|
|
5401
|
-
const c = conditions[
|
|
5529
|
+
for (let i5 = 0, len4 = conditions.length; i5 < len4; i5++) {
|
|
5530
|
+
const c = conditions[i5];
|
|
5402
5531
|
children.push(" && ", c);
|
|
5403
5532
|
}
|
|
5404
5533
|
children.push(")");
|
|
@@ -5420,11 +5549,11 @@ function processDeclarationConditionStatement(s) {
|
|
|
5420
5549
|
ancestor.expressions.splice(index + 1, 0, ...blockPrefix);
|
|
5421
5550
|
updateParentPointers(ancestor);
|
|
5422
5551
|
braceBlock(ancestor);
|
|
5423
|
-
let
|
|
5552
|
+
let ref3;
|
|
5424
5553
|
switch (s.type) {
|
|
5425
5554
|
case "IfStatement": {
|
|
5426
|
-
if (
|
|
5427
|
-
const elseBlock =
|
|
5555
|
+
if (ref3 = s.else?.block) {
|
|
5556
|
+
const elseBlock = ref3;
|
|
5428
5557
|
if (elseBlock.bare && !elseBlock.semicolon) {
|
|
5429
5558
|
elseBlock.children.push(elseBlock.semicolon = ";");
|
|
5430
5559
|
}
|
|
@@ -5448,13 +5577,13 @@ function processDeclarationConditionStatement(s) {
|
|
|
5448
5577
|
if (s.negated) {
|
|
5449
5578
|
if (e != null) {
|
|
5450
5579
|
const block = blockWithPrefix(blockPrefix, e.block);
|
|
5451
|
-
e.children = e.children.map(($
|
|
5580
|
+
e.children = e.children.map(($2) => $2 === e.block ? block : $2);
|
|
5452
5581
|
e.block = block;
|
|
5453
5582
|
updateParentPointers(e);
|
|
5454
5583
|
}
|
|
5455
5584
|
} else {
|
|
5456
5585
|
const block = blockWithPrefix(blockPrefix, s.then);
|
|
5457
|
-
s.children = s.children.map(($
|
|
5586
|
+
s.children = s.children.map(($3) => $3 === s.then ? block : $3);
|
|
5458
5587
|
s.then = block;
|
|
5459
5588
|
updateParentPointers(s);
|
|
5460
5589
|
}
|
|
@@ -5467,7 +5596,7 @@ function processDeclarationConditionStatement(s) {
|
|
|
5467
5596
|
}
|
|
5468
5597
|
const { children, block } = s;
|
|
5469
5598
|
const newBlock = blockWithPrefix(blockPrefix, block);
|
|
5470
|
-
s.children = children.map(($
|
|
5599
|
+
s.children = children.map(($4) => $4 === block ? newBlock : $4);
|
|
5471
5600
|
updateParentPointers(s);
|
|
5472
5601
|
break;
|
|
5473
5602
|
}
|
|
@@ -5495,7 +5624,7 @@ function processDeclarationConditionStatement(s) {
|
|
|
5495
5624
|
const block = makeEmptyBlock();
|
|
5496
5625
|
replaceBlockExpression(s.parent, s, block);
|
|
5497
5626
|
block.expressions.push(["", s]);
|
|
5498
|
-
s.children.splice(s.children.findIndex(($
|
|
5627
|
+
s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix);
|
|
5499
5628
|
s.parent = block;
|
|
5500
5629
|
} else {
|
|
5501
5630
|
const block = blockWithPrefix([["", [{
|
|
@@ -5515,12 +5644,12 @@ function processDeclarationConditionStatement(s) {
|
|
|
5515
5644
|
function dynamizeFromClause(from) {
|
|
5516
5645
|
from = from.slice(1);
|
|
5517
5646
|
from = trimFirstSpace(from);
|
|
5518
|
-
let
|
|
5519
|
-
if (
|
|
5520
|
-
const assert2 =
|
|
5521
|
-
let
|
|
5522
|
-
|
|
5523
|
-
|
|
5647
|
+
let ref4;
|
|
5648
|
+
if (ref4 = from[from.length - 1]?.assertion) {
|
|
5649
|
+
const assert2 = ref4;
|
|
5650
|
+
let ref5;
|
|
5651
|
+
ref5 = from[from.length - 1];
|
|
5652
|
+
ref5.children = ref5.children.filter((a2) => a2 !== assert2);
|
|
5524
5653
|
from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
5525
5654
|
}
|
|
5526
5655
|
return ["(", ...from, ")"];
|
|
@@ -5529,20 +5658,20 @@ function dynamizeImportDeclaration(decl) {
|
|
|
5529
5658
|
const { imports } = decl;
|
|
5530
5659
|
let { star, binding, specifiers } = imports;
|
|
5531
5660
|
const justDefault = binding && !specifiers && !star;
|
|
5532
|
-
let
|
|
5661
|
+
let ref6;
|
|
5533
5662
|
{
|
|
5534
5663
|
if (binding) {
|
|
5535
5664
|
if (specifiers) {
|
|
5536
|
-
|
|
5665
|
+
ref6 = makeRef();
|
|
5537
5666
|
} else {
|
|
5538
|
-
|
|
5667
|
+
ref6 = binding;
|
|
5539
5668
|
}
|
|
5540
5669
|
} else {
|
|
5541
|
-
|
|
5670
|
+
ref6 = convertNamedImportsToObject(imports, true);
|
|
5542
5671
|
}
|
|
5543
5672
|
}
|
|
5544
5673
|
;
|
|
5545
|
-
const pattern =
|
|
5674
|
+
const pattern = ref6;
|
|
5546
5675
|
const c = "const";
|
|
5547
5676
|
const expression = [
|
|
5548
5677
|
justDefault ? "(" : void 0,
|
|
@@ -5807,7 +5936,7 @@ function processUnaryNestedExpression(pre, args, post) {
|
|
|
5807
5936
|
children: args.children.map(
|
|
5808
5937
|
(arg) => {
|
|
5809
5938
|
if (typeof arg === "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
|
|
5810
|
-
const {
|
|
5939
|
+
const { expression: exp, children } = arg;
|
|
5811
5940
|
let expression = processUnaryExpression([last], trimFirstSpace(exp));
|
|
5812
5941
|
expression = prepend(getTrimmingSpace(exp), expression);
|
|
5813
5942
|
return {
|
|
@@ -6053,12 +6182,12 @@ function processPipelineExpressions(statements) {
|
|
|
6053
6182
|
}
|
|
6054
6183
|
|
|
6055
6184
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
|
|
6056
|
-
function processRangeExpression(start, ws1,
|
|
6057
|
-
ws1 = [ws1,
|
|
6058
|
-
const ws2 =
|
|
6059
|
-
const comma = { $loc:
|
|
6185
|
+
function processRangeExpression(start, ws1, range2, end) {
|
|
6186
|
+
ws1 = [ws1, range2.children[0]];
|
|
6187
|
+
const ws2 = range2.children[1];
|
|
6188
|
+
const comma = { $loc: range2.$loc, token: "," };
|
|
6060
6189
|
let ref;
|
|
6061
|
-
switch (
|
|
6190
|
+
switch (range2.increasing) {
|
|
6062
6191
|
case true: {
|
|
6063
6192
|
ref = ($) => $;
|
|
6064
6193
|
break;
|
|
@@ -6073,7 +6202,7 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6073
6202
|
}
|
|
6074
6203
|
;
|
|
6075
6204
|
const abs = ref;
|
|
6076
|
-
const lengthAdjust = 1 - Number(!
|
|
6205
|
+
const lengthAdjust = 1 - Number(!range2.left.inclusive) - Number(!range2.right.inclusive);
|
|
6077
6206
|
let children;
|
|
6078
6207
|
if (typeof start === "object" && start != null && "type" in start && start.type === "Literal" && (typeof end === "object" && end != null && "type" in end && end.type === "Literal")) {
|
|
6079
6208
|
let startValue = literalValue(start);
|
|
@@ -6086,7 +6215,7 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6086
6215
|
let endCode = endValue.charCodeAt(0);
|
|
6087
6216
|
const step = startCode <= endCode ? 1 : -1;
|
|
6088
6217
|
const length = abs(endCode - startCode) + lengthAdjust;
|
|
6089
|
-
if (!
|
|
6218
|
+
if (!range2.left.inclusive) {
|
|
6090
6219
|
startCode += step;
|
|
6091
6220
|
}
|
|
6092
6221
|
if (length <= 26) {
|
|
@@ -6107,13 +6236,13 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6107
6236
|
")"
|
|
6108
6237
|
];
|
|
6109
6238
|
}
|
|
6110
|
-
if (
|
|
6111
|
-
children.unshift(
|
|
6239
|
+
if (range2.error != null) {
|
|
6240
|
+
children.unshift(range2.error);
|
|
6112
6241
|
}
|
|
6113
6242
|
} else if (typeof startValue === "number" && typeof endValue === "number") {
|
|
6114
6243
|
const step = startValue <= endValue ? 1 : -1;
|
|
6115
6244
|
const length = abs(endValue - startValue) + lengthAdjust;
|
|
6116
|
-
if (!
|
|
6245
|
+
if (!range2.left.inclusive) {
|
|
6117
6246
|
startValue += step;
|
|
6118
6247
|
}
|
|
6119
6248
|
if (length <= 20) {
|
|
@@ -6122,22 +6251,22 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6122
6251
|
Array.from({ length }, (_2, i) => startValue + i * step).join(", "),
|
|
6123
6252
|
"]"
|
|
6124
6253
|
];
|
|
6125
|
-
if (
|
|
6126
|
-
children.unshift(
|
|
6254
|
+
if (range2.error != null) {
|
|
6255
|
+
children.unshift(range2.error);
|
|
6127
6256
|
}
|
|
6128
6257
|
}
|
|
6129
6258
|
}
|
|
6130
6259
|
}
|
|
6131
6260
|
if (!(children != null)) {
|
|
6132
|
-
if (
|
|
6133
|
-
const sign =
|
|
6261
|
+
if (range2.increasing != null) {
|
|
6262
|
+
const sign = range2.increasing ? "+" : "-";
|
|
6134
6263
|
end = makeLeftHandSideExpression(end);
|
|
6135
6264
|
children = [
|
|
6136
|
-
getHelperRef(
|
|
6265
|
+
getHelperRef(range2.increasing ? "range" : "revRange"),
|
|
6137
6266
|
"(",
|
|
6138
|
-
|
|
6267
|
+
range2.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
|
|
6139
6268
|
",",
|
|
6140
|
-
|
|
6269
|
+
range2.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
|
|
6141
6270
|
...ws1,
|
|
6142
6271
|
")"
|
|
6143
6272
|
];
|
|
@@ -6146,11 +6275,11 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6146
6275
|
"((s, e) => s > e ? ",
|
|
6147
6276
|
getHelperRef("revRange"),
|
|
6148
6277
|
"(s, e",
|
|
6149
|
-
|
|
6278
|
+
range2.right.inclusive ? " - 1" : void 0,
|
|
6150
6279
|
") : ",
|
|
6151
6280
|
getHelperRef("range"),
|
|
6152
6281
|
"(s, e",
|
|
6153
|
-
|
|
6282
|
+
range2.right.inclusive ? " + 1" : void 0,
|
|
6154
6283
|
"))",
|
|
6155
6284
|
"(",
|
|
6156
6285
|
start,
|
|
@@ -6167,14 +6296,14 @@ function processRangeExpression(start, ws1, range, end) {
|
|
|
6167
6296
|
children,
|
|
6168
6297
|
start,
|
|
6169
6298
|
end,
|
|
6170
|
-
error:
|
|
6171
|
-
left:
|
|
6172
|
-
right:
|
|
6173
|
-
increasing:
|
|
6299
|
+
error: range2.error,
|
|
6300
|
+
left: range2.left,
|
|
6301
|
+
right: range2.right,
|
|
6302
|
+
increasing: range2.increasing
|
|
6174
6303
|
};
|
|
6175
6304
|
}
|
|
6176
|
-
function forRange(open, forDeclaration,
|
|
6177
|
-
let { start, end, left, right, increasing } =
|
|
6305
|
+
function forRange(open, forDeclaration, range2, stepExp, close) {
|
|
6306
|
+
let { start, end, left, right, increasing } = range2;
|
|
6178
6307
|
const counterRef = makeRef("i");
|
|
6179
6308
|
const infinite = typeof end === "object" && end != null && "type" in end && end.type === "Identifier" && "name" in end && end.name === "Infinity";
|
|
6180
6309
|
let stepRef, asc;
|
|
@@ -6273,7 +6402,7 @@ function forRange(open, forDeclaration, range, stepExp, close) {
|
|
|
6273
6402
|
// This declaration doesn't always appear in the output,
|
|
6274
6403
|
// but it's still helpful for determining the primary loop variable
|
|
6275
6404
|
declaration: forDeclaration,
|
|
6276
|
-
children: [
|
|
6405
|
+
children: [range2.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
|
|
6277
6406
|
blockPrefix
|
|
6278
6407
|
};
|
|
6279
6408
|
}
|
|
@@ -6333,6 +6462,7 @@ function processForInOf($0) {
|
|
|
6333
6462
|
declaration = {
|
|
6334
6463
|
type: "Declaration",
|
|
6335
6464
|
children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", trimFirstSpace(expRef2), ".length"],
|
|
6465
|
+
decl: "let",
|
|
6336
6466
|
names: []
|
|
6337
6467
|
};
|
|
6338
6468
|
const condition = [counterRef, " < ", lenRef, "; "];
|
|
@@ -6356,6 +6486,9 @@ function processForInOf($0) {
|
|
|
6356
6486
|
}
|
|
6357
6487
|
const { binding } = declaration;
|
|
6358
6488
|
let pattern = binding?.pattern;
|
|
6489
|
+
if (pattern?.type === "NamedBindingPattern") {
|
|
6490
|
+
pattern = pattern.binding;
|
|
6491
|
+
}
|
|
6359
6492
|
if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
|
|
6360
6493
|
const itemRef = makeRef(inOf.token === "in" ? "key" : "item");
|
|
6361
6494
|
blockPrefix.push(["", {
|
|
@@ -6394,12 +6527,14 @@ function processForInOf($0) {
|
|
|
6394
6527
|
hoistDec = {
|
|
6395
6528
|
type: "Declaration",
|
|
6396
6529
|
children: ["let ", counterRef, " = 0"],
|
|
6530
|
+
decl: "let",
|
|
6397
6531
|
names: []
|
|
6398
6532
|
};
|
|
6399
6533
|
blockPrefix.push(["", {
|
|
6400
6534
|
type: "Declaration",
|
|
6401
6535
|
children: [trimFirstSpace(ws2), decl2, " = ", counterRef, "++"],
|
|
6402
|
-
names: decl2.names
|
|
6536
|
+
names: decl2.names,
|
|
6537
|
+
decl: decl2.decl
|
|
6403
6538
|
}, ";"]);
|
|
6404
6539
|
break;
|
|
6405
6540
|
}
|
|
@@ -6409,7 +6544,8 @@ function processForInOf($0) {
|
|
|
6409
6544
|
hoistDec = {
|
|
6410
6545
|
type: "Declaration",
|
|
6411
6546
|
children: ["let ", expRef2],
|
|
6412
|
-
names: []
|
|
6547
|
+
names: [],
|
|
6548
|
+
decl: "let"
|
|
6413
6549
|
};
|
|
6414
6550
|
exp = {
|
|
6415
6551
|
type: "AssignmentExpression",
|
|
@@ -6421,20 +6557,58 @@ function processForInOf($0) {
|
|
|
6421
6557
|
blockPrefix.push(["", ["if (!", hasPropRef, "(", trimFirstSpace(expRef2), ", ", trimFirstSpace(pattern), ")) continue"], ";"]);
|
|
6422
6558
|
}
|
|
6423
6559
|
if (decl2) {
|
|
6424
|
-
|
|
6425
|
-
|
|
6560
|
+
const trimmedPattern = trimFirstSpace(pattern);
|
|
6561
|
+
const expression = makeNode({
|
|
6562
|
+
type: "MemberExpression",
|
|
6426
6563
|
children: [
|
|
6427
|
-
trimFirstSpace(ws2),
|
|
6428
|
-
decl2,
|
|
6429
|
-
" = ",
|
|
6430
6564
|
trimFirstSpace(expRef2),
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
}
|
|
6565
|
+
makeNode({
|
|
6566
|
+
type: "Index",
|
|
6567
|
+
expression: trimmedPattern,
|
|
6568
|
+
children: ["[", trimmedPattern, "]"]
|
|
6569
|
+
})
|
|
6570
|
+
]
|
|
6571
|
+
});
|
|
6572
|
+
blockPrefix.push([
|
|
6573
|
+
"",
|
|
6574
|
+
(() => {
|
|
6575
|
+
if (decl2.type === "ForDeclaration") {
|
|
6576
|
+
const { binding: binding2, children } = decl2;
|
|
6577
|
+
binding2.children.push(binding2.initializer = makeNode({
|
|
6578
|
+
type: "Initializer",
|
|
6579
|
+
expression,
|
|
6580
|
+
children: [" = ", expression]
|
|
6581
|
+
}));
|
|
6582
|
+
return makeNode({
|
|
6583
|
+
type: "Declaration",
|
|
6584
|
+
children: [
|
|
6585
|
+
trimFirstSpace(ws2),
|
|
6586
|
+
...children
|
|
6587
|
+
],
|
|
6588
|
+
bindings: [decl2.binding],
|
|
6589
|
+
decl: decl2.decl,
|
|
6590
|
+
names: decl2.names
|
|
6591
|
+
});
|
|
6592
|
+
} else {
|
|
6593
|
+
return makeNode({
|
|
6594
|
+
type: "AssignmentExpression",
|
|
6595
|
+
children: [
|
|
6596
|
+
trimFirstSpace(ws2),
|
|
6597
|
+
decl2,
|
|
6598
|
+
" = ",
|
|
6599
|
+
trimFirstSpace(expRef2),
|
|
6600
|
+
"[",
|
|
6601
|
+
trimFirstSpace(pattern),
|
|
6602
|
+
"]"
|
|
6603
|
+
],
|
|
6604
|
+
names: decl2.names,
|
|
6605
|
+
lhs: decl2,
|
|
6606
|
+
assigned: decl2
|
|
6607
|
+
});
|
|
6608
|
+
}
|
|
6609
|
+
})(),
|
|
6610
|
+
";"
|
|
6611
|
+
]);
|
|
6438
6612
|
}
|
|
6439
6613
|
;
|
|
6440
6614
|
break;
|
|
@@ -6964,7 +7138,7 @@ function processTryBlock($0) {
|
|
|
6964
7138
|
const clauses = cs.map((clause) => {
|
|
6965
7139
|
let ref1;
|
|
6966
7140
|
if ((ref1 = clause.binding?.parameter) && typeof ref1 === "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
|
|
6967
|
-
const {
|
|
7141
|
+
const { patterns } = ref1;
|
|
6968
7142
|
return {
|
|
6969
7143
|
type: "PatternClause",
|
|
6970
7144
|
patterns,
|
|
@@ -7568,7 +7742,14 @@ function makeGetterMethod(name, ws, value, returnType, block, kind = { token: "g
|
|
|
7568
7742
|
function processBindingPatternLHS(lhs, tail) {
|
|
7569
7743
|
adjustAtBindings(lhs, true);
|
|
7570
7744
|
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
7571
|
-
|
|
7745
|
+
const subbindings = gatherSubbindings(lhs);
|
|
7746
|
+
simplifyBindingProperties(lhs);
|
|
7747
|
+
simplifyBindingProperties(subbindings);
|
|
7748
|
+
tail.push(
|
|
7749
|
+
...splices.map((s) => [", ", s]),
|
|
7750
|
+
...thisAssignments.map((a) => [", ", a]),
|
|
7751
|
+
...subbindings
|
|
7752
|
+
);
|
|
7572
7753
|
}
|
|
7573
7754
|
function processAssignments(statements) {
|
|
7574
7755
|
for (let ref7 = gatherRecursiveAll(statements, ($4) => $4.type === "AssignmentExpression" || $4.type === "UpdateExpression"), i5 = 0, len3 = ref7.length; i5 < len3; i5++) {
|
|
@@ -7737,7 +7918,7 @@ function processAssignments(statements) {
|
|
|
7737
7918
|
message: "Slice range cannot be decreasing in assignment"
|
|
7738
7919
|
});
|
|
7739
7920
|
break;
|
|
7740
|
-
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") {
|
|
7921
|
+
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") {
|
|
7741
7922
|
processBindingPatternLHS(lhs, tail);
|
|
7742
7923
|
gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
|
|
7743
7924
|
}
|
|
@@ -7886,7 +8067,7 @@ function processTypes(node) {
|
|
|
7886
8067
|
while (suffixIndex >= 0) {
|
|
7887
8068
|
const suffix = unary.suffix[suffixIndex];
|
|
7888
8069
|
if (typeof suffix === "object" && suffix != null && "token" in suffix && suffix.token === "?") {
|
|
7889
|
-
const {
|
|
8070
|
+
const {} = suffix;
|
|
7890
8071
|
let count = 0;
|
|
7891
8072
|
let m4;
|
|
7892
8073
|
while (m4 = unary.suffix[suffixIndex], typeof m4 === "object" && m4 != null && "token" in m4 && m4.token === "?") {
|
|
@@ -7944,7 +8125,7 @@ function processTypes(node) {
|
|
|
7944
8125
|
}
|
|
7945
8126
|
results2.push(replaceNode(unary, replace, parent));
|
|
7946
8127
|
} else if (typeof suffix === "object" && suffix != null && "type" in suffix && suffix.type === "NonNullAssertion") {
|
|
7947
|
-
const {
|
|
8128
|
+
const {} = suffix;
|
|
7948
8129
|
let m6;
|
|
7949
8130
|
while (m6 = unary.suffix[suffixIndex], typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "NonNullAssertion") {
|
|
7950
8131
|
unary.suffix.splice(suffixIndex--, 1);
|
|
@@ -8342,30 +8523,10 @@ function processRepl(root, rootIIFE) {
|
|
|
8342
8523
|
}
|
|
8343
8524
|
}
|
|
8344
8525
|
}
|
|
8345
|
-
function populateRefs(statements) {
|
|
8346
|
-
const refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
|
|
8347
|
-
if (refNodes.length) {
|
|
8348
|
-
const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
|
|
8349
|
-
const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
8350
|
-
refNodes.forEach((ref) => {
|
|
8351
|
-
const { type, base } = ref;
|
|
8352
|
-
if (type !== "Ref") return;
|
|
8353
|
-
ref.type = "Identifier";
|
|
8354
|
-
let n = 0;
|
|
8355
|
-
let name = base;
|
|
8356
|
-
while (names.has(name)) {
|
|
8357
|
-
n++;
|
|
8358
|
-
name = `${base}${n}`;
|
|
8359
|
-
}
|
|
8360
|
-
names.add(name);
|
|
8361
|
-
return ref.children = ref.names = [name];
|
|
8362
|
-
});
|
|
8363
|
-
}
|
|
8364
|
-
}
|
|
8365
8526
|
function processPlaceholders(statements) {
|
|
8366
8527
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
8367
8528
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
8368
|
-
for (let ref25 = gatherRecursiveAll(statements, ($
|
|
8529
|
+
for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref25.length; i17 < len14; i17++) {
|
|
8369
8530
|
const exp = ref25[i17];
|
|
8370
8531
|
let ancestor;
|
|
8371
8532
|
if (exp.subtype === ".") {
|
|
@@ -8808,6 +8969,7 @@ var grammar = {
|
|
|
8808
8969
|
NWBindingIdentifier,
|
|
8809
8970
|
AtIdentifierRef,
|
|
8810
8971
|
PinPattern,
|
|
8972
|
+
NamedBindingPattern,
|
|
8811
8973
|
BindingPattern,
|
|
8812
8974
|
ObjectBindingPattern,
|
|
8813
8975
|
ObjectBindingPatternContent,
|
|
@@ -11357,8 +11519,9 @@ var LeftHandSideExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impo
|
|
|
11357
11519
|
expression
|
|
11358
11520
|
};
|
|
11359
11521
|
});
|
|
11360
|
-
var LeftHandSideExpression$1 =
|
|
11361
|
-
var LeftHandSideExpression
|
|
11522
|
+
var LeftHandSideExpression$1 = NamedBindingPattern;
|
|
11523
|
+
var LeftHandSideExpression$2 = CallExpression;
|
|
11524
|
+
var LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
|
|
11362
11525
|
function LeftHandSideExpression(ctx, state2) {
|
|
11363
11526
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
|
|
11364
11527
|
}
|
|
@@ -11981,7 +12144,7 @@ var FunctionRestParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, impor
|
|
|
11981
12144
|
function FunctionRestParameter(ctx, state2) {
|
|
11982
12145
|
return (0, import_lib2.$EVENT)(ctx, state2, "FunctionRestParameter", FunctionRestParameter$0);
|
|
11983
12146
|
}
|
|
11984
|
-
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)(
|
|
12147
|
+
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) {
|
|
11985
12148
|
var accessModifier = $2;
|
|
11986
12149
|
var binding = $4;
|
|
11987
12150
|
var typeSuffix = $5;
|
|
@@ -12094,12 +12257,31 @@ var PinPattern$$ = [PinPattern$0, PinPattern$1, PinPattern$2, PinPattern$3];
|
|
|
12094
12257
|
function PinPattern(ctx, state2) {
|
|
12095
12258
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
|
|
12096
12259
|
}
|
|
12260
|
+
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) {
|
|
12261
|
+
var binding = $1;
|
|
12262
|
+
var ws = $3;
|
|
12263
|
+
var pattern = $4;
|
|
12264
|
+
pattern = prepend(ws, pattern);
|
|
12265
|
+
return {
|
|
12266
|
+
type: "NamedBindingPattern",
|
|
12267
|
+
// NOTE: children just has binding, not pattern, for easy destructuring
|
|
12268
|
+
children: [binding],
|
|
12269
|
+
binding,
|
|
12270
|
+
pattern,
|
|
12271
|
+
subbinding: [pattern, " = ", binding],
|
|
12272
|
+
typeSuffix: pattern.typeSuffix
|
|
12273
|
+
};
|
|
12274
|
+
});
|
|
12275
|
+
function NamedBindingPattern(ctx, state2) {
|
|
12276
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "NamedBindingPattern", NamedBindingPattern$0);
|
|
12277
|
+
}
|
|
12097
12278
|
var BindingPattern$0 = ObjectBindingPattern;
|
|
12098
12279
|
var BindingPattern$1 = ArrayBindingPattern;
|
|
12099
12280
|
var BindingPattern$2 = PinPattern;
|
|
12100
12281
|
var BindingPattern$3 = Literal;
|
|
12101
12282
|
var BindingPattern$4 = RegularExpressionLiteral;
|
|
12102
|
-
var BindingPattern
|
|
12283
|
+
var BindingPattern$5 = NamedBindingPattern;
|
|
12284
|
+
var BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4, BindingPattern$5];
|
|
12103
12285
|
function BindingPattern(ctx, state2) {
|
|
12104
12286
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingPattern", BindingPattern$$);
|
|
12105
12287
|
}
|
|
@@ -12223,7 +12405,7 @@ function NestedBindingPropertyList(ctx, state2) {
|
|
|
12223
12405
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingPropertyList", NestedBindingPropertyList$0);
|
|
12224
12406
|
}
|
|
12225
12407
|
var BindingProperty$0 = BindingRestProperty;
|
|
12226
|
-
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)(
|
|
12408
|
+
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) {
|
|
12227
12409
|
var ws1 = $1;
|
|
12228
12410
|
var name = $2;
|
|
12229
12411
|
var bind = $3;
|
|
@@ -12233,6 +12415,19 @@ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
12233
12415
|
var value = $7;
|
|
12234
12416
|
var typeSuffix = $8;
|
|
12235
12417
|
var initializer = $9;
|
|
12418
|
+
if (bind) {
|
|
12419
|
+
const binding = name, pattern = value;
|
|
12420
|
+
value = {
|
|
12421
|
+
type: "NamedBindingPattern",
|
|
12422
|
+
// NOTE: children just has binding, not pattern, for easy destructuring
|
|
12423
|
+
children: [binding],
|
|
12424
|
+
binding,
|
|
12425
|
+
pattern,
|
|
12426
|
+
subbinding: [pattern, " = ", binding],
|
|
12427
|
+
typeSuffix: pattern.typeSuffix,
|
|
12428
|
+
names: value.names
|
|
12429
|
+
};
|
|
12430
|
+
}
|
|
12236
12431
|
return {
|
|
12237
12432
|
type: "BindingProperty",
|
|
12238
12433
|
children: [ws1, name, ws2, colon, ws3, value, initializer],
|
|
@@ -12241,8 +12436,7 @@ var BindingProperty$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
12241
12436
|
value,
|
|
12242
12437
|
typeSuffix,
|
|
12243
12438
|
initializer,
|
|
12244
|
-
names: value.names
|
|
12245
|
-
bind: !!bind
|
|
12439
|
+
names: value.names
|
|
12246
12440
|
};
|
|
12247
12441
|
});
|
|
12248
12442
|
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) {
|
|
@@ -12307,8 +12501,7 @@ var BindingProperty$3 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2
|
|
|
12307
12501
|
typeSuffix,
|
|
12308
12502
|
initializer,
|
|
12309
12503
|
names: binding.names,
|
|
12310
|
-
identifier: binding
|
|
12311
|
-
bind: !!bind
|
|
12504
|
+
identifier: binding
|
|
12312
12505
|
};
|
|
12313
12506
|
});
|
|
12314
12507
|
var BindingProperty$$ = [BindingProperty$0, BindingProperty$1, BindingProperty$2, BindingProperty$3];
|
|
@@ -12366,7 +12559,7 @@ function NestedBindingElements(ctx, state2) {
|
|
|
12366
12559
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingElements", NestedBindingElements$0);
|
|
12367
12560
|
}
|
|
12368
12561
|
var BindingElement$0 = BindingRestElement;
|
|
12369
|
-
var BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
12562
|
+
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) {
|
|
12370
12563
|
var ws = $1;
|
|
12371
12564
|
var binding = $2;
|
|
12372
12565
|
var typeSuffix = $3;
|
|
@@ -12391,7 +12584,7 @@ var BindingElement$$ = [BindingElement$0, BindingElement$1, BindingElement$2];
|
|
|
12391
12584
|
function BindingElement(ctx, state2) {
|
|
12392
12585
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingElement", BindingElement$$);
|
|
12393
12586
|
}
|
|
12394
|
-
var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(
|
|
12587
|
+
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) {
|
|
12395
12588
|
var ws = $1;
|
|
12396
12589
|
var dots = $2;
|
|
12397
12590
|
var binding = $3;
|
|
@@ -12407,7 +12600,7 @@ var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_l
|
|
|
12407
12600
|
rest: true
|
|
12408
12601
|
};
|
|
12409
12602
|
});
|
|
12410
|
-
var BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
12603
|
+
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) {
|
|
12411
12604
|
var ws = $1;
|
|
12412
12605
|
var binding = $2;
|
|
12413
12606
|
var dots = $3;
|
|
@@ -13416,9 +13609,9 @@ function RangeEnd(ctx, state2) {
|
|
|
13416
13609
|
var RangeExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, RangeDots, Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
13417
13610
|
var start = $1;
|
|
13418
13611
|
var ws = $2;
|
|
13419
|
-
var
|
|
13612
|
+
var range2 = $3;
|
|
13420
13613
|
var end = $4;
|
|
13421
|
-
return processRangeExpression(start, ws,
|
|
13614
|
+
return processRangeExpression(start, ws, range2, end);
|
|
13422
13615
|
});
|
|
13423
13616
|
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) {
|
|
13424
13617
|
var s = $1;
|
|
@@ -15556,10 +15749,13 @@ var ForDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(LetOrConstOrVar,
|
|
|
15556
15749
|
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) {
|
|
15557
15750
|
var c = $1;
|
|
15558
15751
|
var binding = $3;
|
|
15752
|
+
if (gatherRecursive(binding, ($) => $.type === "PinPattern").length) {
|
|
15753
|
+
return $skip;
|
|
15754
|
+
}
|
|
15559
15755
|
return {
|
|
15560
15756
|
type: "ForDeclaration",
|
|
15561
15757
|
children: [c, binding],
|
|
15562
|
-
decl: c.token,
|
|
15758
|
+
decl: c.token.trimEnd(),
|
|
15563
15759
|
binding,
|
|
15564
15760
|
names: binding.names
|
|
15565
15761
|
};
|
|
@@ -15729,12 +15925,17 @@ function PatternExpressionList(ctx, state2) {
|
|
|
15729
15925
|
return (0, import_lib2.$EVENT)(ctx, state2, "PatternExpressionList", PatternExpressionList$0);
|
|
15730
15926
|
}
|
|
15731
15927
|
var PatternExpression$0 = BindingPattern;
|
|
15732
|
-
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) {
|
|
15733
|
-
var
|
|
15734
|
-
if (!
|
|
15928
|
+
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) {
|
|
15929
|
+
var body = $2;
|
|
15930
|
+
if (!body) return $skip;
|
|
15931
|
+
const [named, rhs] = body;
|
|
15932
|
+
let binding;
|
|
15933
|
+
if (named) [binding] = named;
|
|
15735
15934
|
return {
|
|
15736
15935
|
type: "ConditionFragment",
|
|
15737
|
-
children:
|
|
15936
|
+
children: [binding, rhs],
|
|
15937
|
+
binding,
|
|
15938
|
+
rhs
|
|
15738
15939
|
};
|
|
15739
15940
|
});
|
|
15740
15941
|
var PatternExpression$$ = [PatternExpression$0, PatternExpression$1];
|
|
@@ -15846,31 +16047,31 @@ var FinallyClause$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Finally, (0, impo
|
|
|
15846
16047
|
function FinallyClause(ctx, state2) {
|
|
15847
16048
|
return (0, import_lib2.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
|
|
15848
16049
|
}
|
|
15849
|
-
var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
16050
|
+
var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
|
|
15850
16051
|
var binding = $1;
|
|
15851
16052
|
var typeSuffix = $2;
|
|
15852
16053
|
return {
|
|
15853
16054
|
type: "CatchParameter",
|
|
15854
16055
|
binding,
|
|
15855
16056
|
typeSuffix,
|
|
15856
|
-
children:
|
|
16057
|
+
children: [binding, typeSuffix]
|
|
16058
|
+
};
|
|
16059
|
+
});
|
|
16060
|
+
var CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
|
|
16061
|
+
return {
|
|
16062
|
+
type: "CatchPattern",
|
|
16063
|
+
children: $0,
|
|
16064
|
+
patterns: $1
|
|
15857
16065
|
};
|
|
15858
16066
|
});
|
|
15859
|
-
var CatchParameter$
|
|
16067
|
+
var CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
|
|
15860
16068
|
var binding = $1;
|
|
15861
16069
|
var typeSuffix = $2;
|
|
15862
16070
|
return {
|
|
15863
16071
|
type: "CatchParameter",
|
|
15864
16072
|
binding,
|
|
15865
16073
|
typeSuffix,
|
|
15866
|
-
children:
|
|
15867
|
-
};
|
|
15868
|
-
});
|
|
15869
|
-
var CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
|
|
15870
|
-
return {
|
|
15871
|
-
type: "CatchPattern",
|
|
15872
|
-
children: $0,
|
|
15873
|
-
patterns: $1
|
|
16074
|
+
children: $0
|
|
15874
16075
|
};
|
|
15875
16076
|
});
|
|
15876
16077
|
var CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
|
|
@@ -17486,7 +17687,7 @@ var By$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L1
|
|
|
17486
17687
|
function By(ctx, state2) {
|
|
17487
17688
|
return (0, import_lib2.$EVENT)(ctx, state2, "By", By$0);
|
|
17488
17689
|
}
|
|
17489
|
-
var Caret$0 = (0, import_lib2.$
|
|
17690
|
+
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) {
|
|
17490
17691
|
return { $loc, token: $1 };
|
|
17491
17692
|
});
|
|
17492
17693
|
function Caret(ctx, state2) {
|