@danielx/civet 0.8.4 → 0.8.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 +5 -0
- package/dist/browser.js +475 -236
- package/dist/civet +5 -8
- package/dist/main.js +475 -236
- package/dist/main.mjs +475 -236
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -1067,6 +1067,9 @@ ${body}`;
|
|
|
1067
1067
|
expression = item;
|
|
1068
1068
|
}
|
|
1069
1069
|
if (isASTNodeObject(expression)) {
|
|
1070
|
+
if (expression.token) {
|
|
1071
|
+
return expression;
|
|
1072
|
+
}
|
|
1070
1073
|
if (expression.parenthesized) {
|
|
1071
1074
|
return expression;
|
|
1072
1075
|
}
|
|
@@ -1589,86 +1592,90 @@ ${body}`;
|
|
|
1589
1592
|
let count = 0;
|
|
1590
1593
|
switch (pattern.type) {
|
|
1591
1594
|
case "ArrayBindingPattern": {
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1595
|
+
{
|
|
1596
|
+
const results = [];
|
|
1597
|
+
for (let ref2 = pattern.elements, i2 = 0, len1 = ref2.length; i2 < len1; i2++) {
|
|
1598
|
+
const elem = ref2[i2];
|
|
1599
|
+
let { typeSuffix } = elem;
|
|
1600
|
+
typeSuffix ??= elem.binding?.typeSuffix;
|
|
1601
|
+
if (typeSuffix) {
|
|
1602
|
+
count++;
|
|
1603
|
+
}
|
|
1604
|
+
let typeElement = [typeSuffix?.t, elem.delim];
|
|
1605
|
+
if (typeSuffix?.optional) {
|
|
1606
|
+
typeElement[0] = parenthesizeType(typeElement[0]);
|
|
1607
|
+
typeElement.unshift("undefined |");
|
|
1608
|
+
}
|
|
1609
|
+
if (elem.type === "BindingRestElement") {
|
|
1610
|
+
typeElement[0] ??= "unknown[]";
|
|
1611
|
+
typeElement.unshift(elem.dots);
|
|
1612
|
+
} else {
|
|
1613
|
+
typeElement[0] ??= "unknown";
|
|
1614
|
+
}
|
|
1615
|
+
results.push(typeElement);
|
|
1604
1616
|
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1617
|
+
;
|
|
1618
|
+
const types = results;
|
|
1619
|
+
if (count) {
|
|
1620
|
+
const t = [": [", types, "]"];
|
|
1621
|
+
pattern.typeSuffix = {
|
|
1622
|
+
type: "TypeSuffix",
|
|
1623
|
+
ts: true,
|
|
1624
|
+
t,
|
|
1625
|
+
children: [t]
|
|
1626
|
+
};
|
|
1610
1627
|
}
|
|
1611
|
-
results.push(typeElement);
|
|
1612
|
-
}
|
|
1613
|
-
;
|
|
1614
|
-
const types = results;
|
|
1615
|
-
if (count) {
|
|
1616
|
-
const t = [": [", types, "]"];
|
|
1617
|
-
pattern.typeSuffix = {
|
|
1618
|
-
type: "TypeSuffix",
|
|
1619
|
-
ts: true,
|
|
1620
|
-
t,
|
|
1621
|
-
children: [t]
|
|
1622
|
-
};
|
|
1623
1628
|
}
|
|
1624
1629
|
;
|
|
1625
1630
|
break;
|
|
1626
1631
|
}
|
|
1627
1632
|
case "ObjectBindingPattern": {
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
typeSuffix ??= {
|
|
1638
|
-
type: "TypeSuffix",
|
|
1639
|
-
ts: true,
|
|
1640
|
-
children: [": unknown"]
|
|
1641
|
-
};
|
|
1642
|
-
switch (prop.type) {
|
|
1643
|
-
case "BindingProperty": {
|
|
1644
|
-
const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
|
|
1645
|
-
results1.push([...ws, prop.name, typeSuffix, prop.delim]);
|
|
1646
|
-
break;
|
|
1647
|
-
}
|
|
1648
|
-
case "AtBindingProperty": {
|
|
1649
|
-
const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
|
|
1650
|
-
results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
|
|
1651
|
-
break;
|
|
1633
|
+
{
|
|
1634
|
+
let restType;
|
|
1635
|
+
const results1 = [];
|
|
1636
|
+
for (let ref3 = pattern.properties, i3 = 0, len22 = ref3.length; i3 < len22; i3++) {
|
|
1637
|
+
const prop = ref3[i3];
|
|
1638
|
+
let { typeSuffix } = prop;
|
|
1639
|
+
typeSuffix ??= prop.value?.typeSuffix;
|
|
1640
|
+
if (typeSuffix) {
|
|
1641
|
+
count++;
|
|
1652
1642
|
}
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1643
|
+
typeSuffix ??= {
|
|
1644
|
+
type: "TypeSuffix",
|
|
1645
|
+
ts: true,
|
|
1646
|
+
children: [": unknown"]
|
|
1647
|
+
};
|
|
1648
|
+
switch (prop.type) {
|
|
1649
|
+
case "BindingProperty": {
|
|
1650
|
+
const ws = prop.children.slice(0, prop.children.indexOf(prop.name));
|
|
1651
|
+
results1.push([...ws, prop.name, typeSuffix, prop.delim]);
|
|
1652
|
+
break;
|
|
1653
|
+
}
|
|
1654
|
+
case "AtBindingProperty": {
|
|
1655
|
+
const ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
|
|
1656
|
+
results1.push([...ws, prop.ref.id, typeSuffix, prop.delim]);
|
|
1657
|
+
break;
|
|
1658
|
+
}
|
|
1659
|
+
case "BindingRestProperty": {
|
|
1660
|
+
restType = prop.typeSuffix?.t;
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1656
1663
|
}
|
|
1657
1664
|
}
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
+
;
|
|
1666
|
+
const types = results1;
|
|
1667
|
+
if (count) {
|
|
1668
|
+
const t = ["{", types, "}"];
|
|
1669
|
+
if (restType != null) {
|
|
1670
|
+
t.push(" & ", parenthesizeType(trimFirstSpace(restType)));
|
|
1671
|
+
}
|
|
1672
|
+
pattern.typeSuffix = {
|
|
1673
|
+
type: "TypeSuffix",
|
|
1674
|
+
ts: true,
|
|
1675
|
+
t,
|
|
1676
|
+
children: [": ", t]
|
|
1677
|
+
};
|
|
1665
1678
|
}
|
|
1666
|
-
pattern.typeSuffix = {
|
|
1667
|
-
type: "TypeSuffix",
|
|
1668
|
-
ts: true,
|
|
1669
|
-
t,
|
|
1670
|
-
children: [": ", t]
|
|
1671
|
-
};
|
|
1672
1679
|
}
|
|
1673
1680
|
;
|
|
1674
1681
|
break;
|
|
@@ -1753,6 +1760,34 @@ ${body}`;
|
|
|
1753
1760
|
"\n"
|
|
1754
1761
|
]]);
|
|
1755
1762
|
},
|
|
1763
|
+
rslice(rsliceRef) {
|
|
1764
|
+
const RSliceable = makeRef("RSliceable");
|
|
1765
|
+
state.prelude.push(["", [
|
|
1766
|
+
ts(["type ", RSliceable, "<R> = string | {length: number; slice(start: number, end: number): {reverse(): R}}\n"]),
|
|
1767
|
+
preludeVar,
|
|
1768
|
+
rsliceRef,
|
|
1769
|
+
ts([": <R, T extends string | ", RSliceable, "<R>>(a: T, start?: number, end?: number) => T extends string ? string : T extends ", RSliceable, "<infer R> ? R : never"]),
|
|
1770
|
+
" = ((a, start, end) => {\n",
|
|
1771
|
+
" const l = a.length\n",
|
|
1772
|
+
" start = ",
|
|
1773
|
+
getHelperRef("modulo"),
|
|
1774
|
+
"(start ?? -1, l)\n",
|
|
1775
|
+
" end = ",
|
|
1776
|
+
getHelperRef("modulo"),
|
|
1777
|
+
"((end ?? -1) + 1, l)\n",
|
|
1778
|
+
" if (typeof a === 'string') {\n",
|
|
1779
|
+
` let r = ""
|
|
1780
|
+
`,
|
|
1781
|
+
" for (let i = start; i >= end; --i) r += a[i]\n",
|
|
1782
|
+
" return r",
|
|
1783
|
+
asAny,
|
|
1784
|
+
"\n",
|
|
1785
|
+
" } else {\n",
|
|
1786
|
+
" return a.slice(end, start + 1).reverse()\n",
|
|
1787
|
+
" }\n",
|
|
1788
|
+
"});\n"
|
|
1789
|
+
]]);
|
|
1790
|
+
},
|
|
1756
1791
|
div(divRef) {
|
|
1757
1792
|
state.prelude.push(["", [
|
|
1758
1793
|
// [indent, statement]
|
|
@@ -1879,6 +1914,9 @@ ${body}`;
|
|
|
1879
1914
|
declareHelper[base](ref);
|
|
1880
1915
|
return state.helperRefs[base] = ref;
|
|
1881
1916
|
}
|
|
1917
|
+
function peekHelperRef(base) {
|
|
1918
|
+
return state.helperRefs[base];
|
|
1919
|
+
}
|
|
1882
1920
|
function extractPreludeFor(node) {
|
|
1883
1921
|
let helpers = new Set(Object.values(state.helperRefs));
|
|
1884
1922
|
helpers = new Set(gatherRecursive(node, helpers.has.bind(helpers)));
|
|
@@ -5825,7 +5863,131 @@ ${js}`
|
|
|
5825
5863
|
return [value, value.thisShorthand];
|
|
5826
5864
|
}
|
|
5827
5865
|
function processTryBlock($0) {
|
|
5828
|
-
let [t, , b,
|
|
5866
|
+
let [t, , b, cs, e, f] = $0;
|
|
5867
|
+
let c;
|
|
5868
|
+
let m;
|
|
5869
|
+
if (cs.some(($) => (m = $.binding?.parameter, typeof m === "object" && m != null && "type" in m && m.type === "CatchPattern"))) {
|
|
5870
|
+
const ref = makeRef("e");
|
|
5871
|
+
const binding = {
|
|
5872
|
+
type: "CatchBinding",
|
|
5873
|
+
children: ["(", ref, ")"],
|
|
5874
|
+
parameter: ref
|
|
5875
|
+
};
|
|
5876
|
+
const condition = {
|
|
5877
|
+
type: "ParenthesizedExpression",
|
|
5878
|
+
children: ["(", ref, ")"],
|
|
5879
|
+
expression: ref
|
|
5880
|
+
};
|
|
5881
|
+
let defaultClause = false;
|
|
5882
|
+
const clauses = cs.map((clause) => {
|
|
5883
|
+
let ref1;
|
|
5884
|
+
if ((ref1 = clause.binding?.parameter) && typeof ref1 === "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
|
|
5885
|
+
const { type, patterns } = ref1;
|
|
5886
|
+
return {
|
|
5887
|
+
type: "PatternClause",
|
|
5888
|
+
patterns,
|
|
5889
|
+
block: clause.block,
|
|
5890
|
+
children: [patterns, clause.block]
|
|
5891
|
+
};
|
|
5892
|
+
} else {
|
|
5893
|
+
defaultClause = true;
|
|
5894
|
+
const parameter = clause.binding?.parameter;
|
|
5895
|
+
if (parameter != null) {
|
|
5896
|
+
assert.equal(
|
|
5897
|
+
parameter.type,
|
|
5898
|
+
"CatchParameter",
|
|
5899
|
+
`Invalid catch parameter ${parameter.type}`
|
|
5900
|
+
);
|
|
5901
|
+
const { binding: pattern, typeSuffix } = parameter;
|
|
5902
|
+
const initializer = {
|
|
5903
|
+
type: "Initializer",
|
|
5904
|
+
expression: ref,
|
|
5905
|
+
children: ["", " = ", ref]
|
|
5906
|
+
};
|
|
5907
|
+
const bindings = [{
|
|
5908
|
+
type: "Binding",
|
|
5909
|
+
names: pattern.names,
|
|
5910
|
+
pattern,
|
|
5911
|
+
typeSuffix,
|
|
5912
|
+
initializer,
|
|
5913
|
+
children: [pattern, typeSuffix, initializer],
|
|
5914
|
+
splices: [],
|
|
5915
|
+
thisAssignments: []
|
|
5916
|
+
}];
|
|
5917
|
+
clause.block.expressions.unshift(["", {
|
|
5918
|
+
type: "Declaration",
|
|
5919
|
+
children: ["let", " ", bindings],
|
|
5920
|
+
bindings,
|
|
5921
|
+
names: bindings[0].names,
|
|
5922
|
+
decl: "let"
|
|
5923
|
+
}, ";"]);
|
|
5924
|
+
}
|
|
5925
|
+
return {
|
|
5926
|
+
type: "DefaultClause",
|
|
5927
|
+
block: clause.block,
|
|
5928
|
+
children: ["default: ", clause.block]
|
|
5929
|
+
};
|
|
5930
|
+
}
|
|
5931
|
+
});
|
|
5932
|
+
if (!defaultClause) {
|
|
5933
|
+
const expressions = [[
|
|
5934
|
+
"",
|
|
5935
|
+
{
|
|
5936
|
+
type: "ThrowStatement",
|
|
5937
|
+
children: ["throw", " ", ref]
|
|
5938
|
+
}
|
|
5939
|
+
]];
|
|
5940
|
+
const block2 = {
|
|
5941
|
+
type: "BlockStatement",
|
|
5942
|
+
expressions,
|
|
5943
|
+
children: [" {", expressions, "}"],
|
|
5944
|
+
bare: false
|
|
5945
|
+
};
|
|
5946
|
+
clauses.push({
|
|
5947
|
+
type: "DefaultClause",
|
|
5948
|
+
block: block2,
|
|
5949
|
+
children: ["default: ", block2]
|
|
5950
|
+
});
|
|
5951
|
+
}
|
|
5952
|
+
const caseBlock = {
|
|
5953
|
+
type: "CaseBlock",
|
|
5954
|
+
clauses,
|
|
5955
|
+
children: [" {", clauses, "}"]
|
|
5956
|
+
};
|
|
5957
|
+
const patternSwitch = {
|
|
5958
|
+
type: "SwitchStatement",
|
|
5959
|
+
condition,
|
|
5960
|
+
caseBlock,
|
|
5961
|
+
children: ["switch", condition, caseBlock]
|
|
5962
|
+
};
|
|
5963
|
+
const block = {
|
|
5964
|
+
type: "BlockStatement",
|
|
5965
|
+
bare: false,
|
|
5966
|
+
expressions: [["", patternSwitch]],
|
|
5967
|
+
children: [" {", patternSwitch, "}"]
|
|
5968
|
+
};
|
|
5969
|
+
c = makeNode({
|
|
5970
|
+
type: "CatchClause",
|
|
5971
|
+
children: [
|
|
5972
|
+
cs[0].children[0],
|
|
5973
|
+
// whitespace
|
|
5974
|
+
cs[0].children[1],
|
|
5975
|
+
// catch token
|
|
5976
|
+
binding,
|
|
5977
|
+
block
|
|
5978
|
+
],
|
|
5979
|
+
binding,
|
|
5980
|
+
block
|
|
5981
|
+
});
|
|
5982
|
+
} else {
|
|
5983
|
+
c = cs[0];
|
|
5984
|
+
if (cs.length > 1) {
|
|
5985
|
+
c = append(c, {
|
|
5986
|
+
type: "Error",
|
|
5987
|
+
message: "Only one catch clause allowed unless using pattern matching"
|
|
5988
|
+
});
|
|
5989
|
+
}
|
|
5990
|
+
}
|
|
5829
5991
|
if (!c && (e || !f)) {
|
|
5830
5992
|
const emptyCatchBlock = makeEmptyBlock();
|
|
5831
5993
|
c = {
|
|
@@ -5924,8 +6086,9 @@ ${js}`
|
|
|
5924
6086
|
}
|
|
5925
6087
|
}
|
|
5926
6088
|
}
|
|
5927
|
-
for (let
|
|
5928
|
-
const
|
|
6089
|
+
for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
|
|
6090
|
+
const i = i3;
|
|
6091
|
+
const glob = children[i3];
|
|
5929
6092
|
if (glob?.type === "PropertyGlob") {
|
|
5930
6093
|
let prefix = children.slice(0, i);
|
|
5931
6094
|
const parts = [];
|
|
@@ -5996,14 +6159,14 @@ ${js}`
|
|
|
5996
6159
|
});
|
|
5997
6160
|
}
|
|
5998
6161
|
}
|
|
5999
|
-
let
|
|
6162
|
+
let ref2;
|
|
6000
6163
|
let object = {
|
|
6001
6164
|
type: "ObjectExpression",
|
|
6002
6165
|
children: [
|
|
6003
6166
|
glob.object.children[0],
|
|
6004
6167
|
// {
|
|
6005
6168
|
...parts,
|
|
6006
|
-
(
|
|
6169
|
+
(ref2 = glob.object.children)[ref2.length - 1]
|
|
6007
6170
|
// whitespace and }
|
|
6008
6171
|
],
|
|
6009
6172
|
properties: parts,
|
|
@@ -6045,6 +6208,33 @@ ${js}`
|
|
|
6045
6208
|
...children.slice(i + 1)
|
|
6046
6209
|
]
|
|
6047
6210
|
});
|
|
6211
|
+
} else if (typeof glob === "object" && glob != null && "type" in glob && glob.type === "SliceExpression" && "reversed" in glob && glob.reversed === true) {
|
|
6212
|
+
const args = [
|
|
6213
|
+
{ ...node, children: node.children.slice(0, i) },
|
|
6214
|
+
{ ...glob.children[0], token: ", " },
|
|
6215
|
+
...glob.children.slice(1, -1)
|
|
6216
|
+
];
|
|
6217
|
+
let ref3;
|
|
6218
|
+
return makeNode({
|
|
6219
|
+
...node,
|
|
6220
|
+
children: [
|
|
6221
|
+
{
|
|
6222
|
+
type: "CallExpression",
|
|
6223
|
+
children: [
|
|
6224
|
+
getHelperRef("rslice"),
|
|
6225
|
+
makeNode({
|
|
6226
|
+
type: "Call",
|
|
6227
|
+
args,
|
|
6228
|
+
children: [
|
|
6229
|
+
"(",
|
|
6230
|
+
args,
|
|
6231
|
+
(ref3 = glob.children)[ref3.length - 1]
|
|
6232
|
+
]
|
|
6233
|
+
})
|
|
6234
|
+
]
|
|
6235
|
+
}
|
|
6236
|
+
]
|
|
6237
|
+
});
|
|
6048
6238
|
}
|
|
6049
6239
|
}
|
|
6050
6240
|
return node;
|
|
@@ -6055,9 +6245,9 @@ ${js}`
|
|
|
6055
6245
|
throw new Error("replaceNode failed: node has no parent");
|
|
6056
6246
|
}
|
|
6057
6247
|
function recurse(children) {
|
|
6058
|
-
for (let
|
|
6059
|
-
const i =
|
|
6060
|
-
const child = children[
|
|
6248
|
+
for (let i4 = 0, len3 = children.length; i4 < len3; i4++) {
|
|
6249
|
+
const i = i4;
|
|
6250
|
+
const child = children[i4];
|
|
6061
6251
|
if (child === node) {
|
|
6062
6252
|
children[i] = newNode;
|
|
6063
6253
|
return true;
|
|
@@ -6149,8 +6339,8 @@ ${js}`
|
|
|
6149
6339
|
return { type: "Error", message: "cannot use `type` in dynamic import" };
|
|
6150
6340
|
} else {
|
|
6151
6341
|
const { source, binding } = specifier;
|
|
6152
|
-
let
|
|
6153
|
-
const delim = (
|
|
6342
|
+
let ref4;
|
|
6343
|
+
const delim = (ref4 = specifier.children)[ref4.length - 1];
|
|
6154
6344
|
return {
|
|
6155
6345
|
type: pattern ? "BindingProperty" : "Property",
|
|
6156
6346
|
name: source,
|
|
@@ -6160,7 +6350,7 @@ ${js}`
|
|
|
6160
6350
|
};
|
|
6161
6351
|
}
|
|
6162
6352
|
});
|
|
6163
|
-
let
|
|
6353
|
+
let ref5;
|
|
6164
6354
|
return {
|
|
6165
6355
|
type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
|
|
6166
6356
|
names: node.names,
|
|
@@ -6169,7 +6359,7 @@ ${js}`
|
|
|
6169
6359
|
node.children[0],
|
|
6170
6360
|
// {
|
|
6171
6361
|
properties,
|
|
6172
|
-
(
|
|
6362
|
+
(ref5 = node.children)[ref5.length - 1]
|
|
6173
6363
|
// }
|
|
6174
6364
|
]
|
|
6175
6365
|
};
|
|
@@ -6275,8 +6465,8 @@ ${js}`
|
|
|
6275
6465
|
while (expr.type === "ParenthesizedExpression") {
|
|
6276
6466
|
expr = expr.expression;
|
|
6277
6467
|
}
|
|
6278
|
-
let
|
|
6279
|
-
if (
|
|
6468
|
+
let m1;
|
|
6469
|
+
if (m1 = expr.type, m1 === "AssignmentExpression" || m1 === "UpdateExpression") {
|
|
6280
6470
|
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
6281
6471
|
pre.push("(");
|
|
6282
6472
|
post.push([", ", lhs, ")"]);
|
|
@@ -6290,15 +6480,15 @@ ${js}`
|
|
|
6290
6480
|
return;
|
|
6291
6481
|
}
|
|
6292
6482
|
const pre = [], post = [];
|
|
6293
|
-
let
|
|
6483
|
+
let ref6;
|
|
6294
6484
|
switch (exp.type) {
|
|
6295
6485
|
case "AssignmentExpression": {
|
|
6296
6486
|
if (!exp.lhs)
|
|
6297
6487
|
return;
|
|
6298
6488
|
exp.lhs.forEach((lhsPart, i) => {
|
|
6299
|
-
let
|
|
6300
|
-
if (
|
|
6301
|
-
const newLhs =
|
|
6489
|
+
let ref7;
|
|
6490
|
+
if (ref7 = extractAssignment(lhsPart[1])) {
|
|
6491
|
+
const newLhs = ref7;
|
|
6302
6492
|
return lhsPart[1] = newLhs;
|
|
6303
6493
|
}
|
|
6304
6494
|
;
|
|
@@ -6307,8 +6497,8 @@ ${js}`
|
|
|
6307
6497
|
break;
|
|
6308
6498
|
}
|
|
6309
6499
|
case "UpdateExpression": {
|
|
6310
|
-
if (
|
|
6311
|
-
const newLhs =
|
|
6500
|
+
if (ref6 = extractAssignment(exp.assigned)) {
|
|
6501
|
+
const newLhs = ref6;
|
|
6312
6502
|
const i = exp.children.indexOf(exp.assigned);
|
|
6313
6503
|
exp.assigned = exp.children[i] = newLhs;
|
|
6314
6504
|
}
|
|
@@ -6324,7 +6514,7 @@ ${js}`
|
|
|
6324
6514
|
const { assigned } = exp;
|
|
6325
6515
|
const ref = makeRef();
|
|
6326
6516
|
const newMemberExp = unchainOptionalMemberExpression(assigned, ref, (children) => {
|
|
6327
|
-
return exp.children.map(($) => $ === assigned ? children : $);
|
|
6517
|
+
return exp.children.map(($3) => $3 === assigned ? children : $3);
|
|
6328
6518
|
});
|
|
6329
6519
|
if (newMemberExp !== assigned) {
|
|
6330
6520
|
if (newMemberExp.usesRef) {
|
|
@@ -6348,23 +6538,23 @@ ${js}`
|
|
|
6348
6538
|
(exp) => {
|
|
6349
6539
|
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
6350
6540
|
let block;
|
|
6351
|
-
let
|
|
6352
|
-
if (exp.parent?.type === "BlockStatement" && !(
|
|
6541
|
+
let ref8;
|
|
6542
|
+
if (exp.parent?.type === "BlockStatement" && !(ref8 = $1[$1.length - 1])?.[ref8.length - 1]?.special) {
|
|
6353
6543
|
block = makeBlockFragment();
|
|
6354
|
-
let
|
|
6355
|
-
if (
|
|
6544
|
+
let ref9;
|
|
6545
|
+
if (ref9 = prependStatementExpressionBlock(
|
|
6356
6546
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
6357
6547
|
block
|
|
6358
6548
|
)) {
|
|
6359
|
-
const ref =
|
|
6360
|
-
exp.children = exp.children.map(($
|
|
6549
|
+
const ref = ref9;
|
|
6550
|
+
exp.children = exp.children.map(($4) => $4 === $2 ? ref : $4);
|
|
6361
6551
|
$2 = ref;
|
|
6362
6552
|
} else {
|
|
6363
6553
|
block = void 0;
|
|
6364
6554
|
}
|
|
6365
6555
|
}
|
|
6366
|
-
let
|
|
6367
|
-
if ($1.some(($
|
|
6556
|
+
let ref10;
|
|
6557
|
+
if ($1.some(($5) => (ref10 = $5)[ref10.length - 1].special)) {
|
|
6368
6558
|
if ($1.length !== 1)
|
|
6369
6559
|
throw new Error("Only one assignment with id= is allowed");
|
|
6370
6560
|
const [, lhs, , op] = $1[0];
|
|
@@ -6389,8 +6579,8 @@ ${js}`
|
|
|
6389
6579
|
if (!(op.token === "=")) {
|
|
6390
6580
|
continue;
|
|
6391
6581
|
}
|
|
6392
|
-
let
|
|
6393
|
-
if (
|
|
6582
|
+
let m2;
|
|
6583
|
+
if (m2 = lhs.type, m2 === "ObjectExpression" || m2 === "ObjectBindingPattern") {
|
|
6394
6584
|
if (!wrapped) {
|
|
6395
6585
|
wrapped = true;
|
|
6396
6586
|
lhs.children.splice(0, 0, "(");
|
|
@@ -6404,10 +6594,17 @@ ${js}`
|
|
|
6404
6594
|
const lastAssignment = $1[i];
|
|
6405
6595
|
if (lastAssignment[3].token === "=") {
|
|
6406
6596
|
const lhs = lastAssignment[1];
|
|
6407
|
-
let
|
|
6597
|
+
let m3;
|
|
6408
6598
|
if (lhs.type === "MemberExpression") {
|
|
6409
6599
|
const members = lhs.children;
|
|
6410
6600
|
const lastMember = members[members.length - 1];
|
|
6601
|
+
if (typeof lastMember === "object" && lastMember != null && "type" in lastMember && lastMember.type === "CallExpression" && "children" in lastMember && Array.isArray(lastMember.children) && lastMember.children.length >= 1 && lastMember.children[0] === peekHelperRef("rslice")) {
|
|
6602
|
+
lastMember.children.push({
|
|
6603
|
+
type: "Error",
|
|
6604
|
+
message: "Slice range cannot be decreasing in assignment"
|
|
6605
|
+
});
|
|
6606
|
+
break;
|
|
6607
|
+
}
|
|
6411
6608
|
if (lastMember.type === "SliceExpression") {
|
|
6412
6609
|
const { start, end, children: c } = lastMember;
|
|
6413
6610
|
c[0].token = ".splice(";
|
|
@@ -6430,9 +6627,9 @@ ${js}`
|
|
|
6430
6627
|
exp.names = [];
|
|
6431
6628
|
break;
|
|
6432
6629
|
}
|
|
6433
|
-
} else if (
|
|
6630
|
+
} else if (m3 = lhs.type, m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") {
|
|
6434
6631
|
processBindingPatternLHS(lhs, tail);
|
|
6435
|
-
gatherRecursiveAll(lhs, ($
|
|
6632
|
+
gatherRecursiveAll(lhs, ($6) => $6.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare));
|
|
6436
6633
|
}
|
|
6437
6634
|
}
|
|
6438
6635
|
i--;
|
|
@@ -6465,7 +6662,7 @@ ${js}`
|
|
|
6465
6662
|
}
|
|
6466
6663
|
if (refsToDeclare.size) {
|
|
6467
6664
|
if (exp.hoistDec) {
|
|
6468
|
-
exp.hoistDec.children.push([...refsToDeclare].map(($
|
|
6665
|
+
exp.hoistDec.children.push([...refsToDeclare].map(($7) => [",", $7]));
|
|
6469
6666
|
} else {
|
|
6470
6667
|
exp.hoistDec = {
|
|
6471
6668
|
type: "Declaration",
|
|
@@ -6539,9 +6736,9 @@ ${js}`
|
|
|
6539
6736
|
}
|
|
6540
6737
|
j++;
|
|
6541
6738
|
}
|
|
6542
|
-
let
|
|
6543
|
-
if (
|
|
6544
|
-
const l =
|
|
6739
|
+
let ref11;
|
|
6740
|
+
if (ref11 = conditions.length) {
|
|
6741
|
+
const l = ref11;
|
|
6545
6742
|
const cs = flatJoin(conditions, " && ");
|
|
6546
6743
|
return {
|
|
6547
6744
|
...exp,
|
|
@@ -6580,27 +6777,27 @@ ${js}`
|
|
|
6580
6777
|
if (!unary.suffix.length) {
|
|
6581
6778
|
return;
|
|
6582
6779
|
}
|
|
6583
|
-
let
|
|
6584
|
-
let
|
|
6585
|
-
if (
|
|
6586
|
-
const { token } =
|
|
6780
|
+
let ref12;
|
|
6781
|
+
let m4;
|
|
6782
|
+
if (m4 = (ref12 = unary.suffix)[ref12.length - 1], typeof m4 === "object" && m4 != null && "token" in m4 && m4.token === "?") {
|
|
6783
|
+
const { token } = m4;
|
|
6587
6784
|
let last;
|
|
6588
6785
|
let count = 0;
|
|
6589
|
-
let
|
|
6590
|
-
while (unary.suffix.length && (
|
|
6786
|
+
let ref13;
|
|
6787
|
+
while (unary.suffix.length && (ref13 = unary.suffix)[ref13.length - 1]?.token === "?") {
|
|
6591
6788
|
last = unary.suffix.pop();
|
|
6592
6789
|
count++;
|
|
6593
6790
|
}
|
|
6594
|
-
let
|
|
6595
|
-
while (unary.suffix.length && (
|
|
6791
|
+
let ref14;
|
|
6792
|
+
while (unary.suffix.length && (ref14 = unary.suffix)[ref14.length - 1]?.type === "NonNullAssertion") {
|
|
6596
6793
|
unary.suffix.pop();
|
|
6597
6794
|
}
|
|
6598
|
-
let
|
|
6795
|
+
let ref15;
|
|
6599
6796
|
if (unary.suffix.length || unary.prefix.length)
|
|
6600
|
-
|
|
6797
|
+
ref15 = unary;
|
|
6601
6798
|
else
|
|
6602
|
-
|
|
6603
|
-
const t =
|
|
6799
|
+
ref15 = unary.t;
|
|
6800
|
+
const t = ref15;
|
|
6604
6801
|
if (unary.parent?.type === "TypeTuple") {
|
|
6605
6802
|
if (count === 1) {
|
|
6606
6803
|
unary.suffix.push(last);
|
|
@@ -6626,14 +6823,14 @@ ${js}`
|
|
|
6626
6823
|
]
|
|
6627
6824
|
});
|
|
6628
6825
|
}
|
|
6629
|
-
} else if (typeof
|
|
6630
|
-
const { type } =
|
|
6631
|
-
let
|
|
6632
|
-
while (unary.suffix.length && (
|
|
6826
|
+
} else if (typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "NonNullAssertion") {
|
|
6827
|
+
const { type } = m4;
|
|
6828
|
+
let ref16;
|
|
6829
|
+
while (unary.suffix.length && (ref16 = unary.suffix)[ref16.length - 1]?.type === "NonNullAssertion") {
|
|
6633
6830
|
unary.suffix.pop();
|
|
6634
6831
|
}
|
|
6635
|
-
let
|
|
6636
|
-
while (unary.suffix.length && (
|
|
6832
|
+
let ref17;
|
|
6833
|
+
while (unary.suffix.length && (ref17 = unary.suffix)[ref17.length - 1]?.token === "?") {
|
|
6637
6834
|
unary.suffix.pop();
|
|
6638
6835
|
}
|
|
6639
6836
|
const t = trimFirstSpace(
|
|
@@ -6659,14 +6856,14 @@ ${js}`
|
|
|
6659
6856
|
});
|
|
6660
6857
|
}
|
|
6661
6858
|
function processStatementExpressions(statements) {
|
|
6662
|
-
gatherRecursiveAll(statements, ($
|
|
6859
|
+
gatherRecursiveAll(statements, ($8) => $8.type === "StatementExpression").forEach((_exp) => {
|
|
6663
6860
|
const exp = _exp;
|
|
6664
6861
|
const { statement } = exp;
|
|
6665
|
-
let
|
|
6862
|
+
let ref18;
|
|
6666
6863
|
switch (statement.type) {
|
|
6667
6864
|
case "IfStatement": {
|
|
6668
|
-
if (
|
|
6669
|
-
const expression =
|
|
6865
|
+
if (ref18 = expressionizeIfStatement(statement)) {
|
|
6866
|
+
const expression = ref18;
|
|
6670
6867
|
return replaceNode(statement, expression, exp);
|
|
6671
6868
|
} else {
|
|
6672
6869
|
return replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
@@ -6735,7 +6932,7 @@ ${js}`
|
|
|
6735
6932
|
if (config2.iife || config2.repl) {
|
|
6736
6933
|
rootIIFE = wrapIIFE(root.expressions, root.topLevelAwait);
|
|
6737
6934
|
const newExpressions = [["", rootIIFE]];
|
|
6738
|
-
root.children = root.children.map(($
|
|
6935
|
+
root.children = root.children.map(($9) => $9 === root.expressions ? newExpressions : $9);
|
|
6739
6936
|
root.expressions = newExpressions;
|
|
6740
6937
|
}
|
|
6741
6938
|
addParentPointers(root);
|
|
@@ -6775,17 +6972,17 @@ ${js}`
|
|
|
6775
6972
|
await processComptime(statements);
|
|
6776
6973
|
}
|
|
6777
6974
|
function processRepl(root, rootIIFE) {
|
|
6778
|
-
const topBlock = gatherRecursive(rootIIFE, ($
|
|
6975
|
+
const topBlock = gatherRecursive(rootIIFE, ($10) => $10.type === "BlockStatement")[0];
|
|
6779
6976
|
let i = 0;
|
|
6780
|
-
for (let
|
|
6781
|
-
const decl =
|
|
6977
|
+
for (let ref19 = gatherRecursiveWithinFunction(topBlock, ($11) => $11.type === "Declaration"), i5 = 0, len4 = ref19.length; i5 < len4; i5++) {
|
|
6978
|
+
const decl = ref19[i5];
|
|
6782
6979
|
if (decl.parent === topBlock || decl.decl === "var") {
|
|
6783
6980
|
decl.children.shift();
|
|
6784
6981
|
root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")};`]);
|
|
6785
6982
|
}
|
|
6786
6983
|
}
|
|
6787
|
-
for (let
|
|
6788
|
-
const func =
|
|
6984
|
+
for (let ref20 = gatherRecursive(topBlock, ($12) => $12.type === "FunctionExpression"), i6 = 0, len5 = ref20.length; i6 < len5; i6++) {
|
|
6985
|
+
const func = ref20[i6];
|
|
6789
6986
|
if (func.name && func.parent?.type === "BlockStatement") {
|
|
6790
6987
|
if (func.parent === topBlock) {
|
|
6791
6988
|
replaceNode(func, void 0);
|
|
@@ -6797,17 +6994,17 @@ ${js}`
|
|
|
6797
6994
|
}
|
|
6798
6995
|
}
|
|
6799
6996
|
}
|
|
6800
|
-
for (let
|
|
6801
|
-
const classExp =
|
|
6802
|
-
let
|
|
6803
|
-
if (classExp.name && classExp.parent === topBlock || (
|
|
6997
|
+
for (let ref21 = gatherRecursiveWithinFunction(topBlock, ($13) => $13.type === "ClassExpression"), i7 = 0, len6 = ref21.length; i7 < len6; i7++) {
|
|
6998
|
+
const classExp = ref21[i7];
|
|
6999
|
+
let m5;
|
|
7000
|
+
if (classExp.name && classExp.parent === topBlock || (m5 = classExp.parent, typeof m5 === "object" && m5 != null && "type" in m5 && m5.type === "ReturnStatement" && "parent" in m5 && m5.parent === topBlock)) {
|
|
6804
7001
|
classExp.children.unshift(classExp.name, "=");
|
|
6805
7002
|
root.expressions.splice(i++, 0, ["", `var ${classExp.name};`]);
|
|
6806
7003
|
}
|
|
6807
7004
|
}
|
|
6808
7005
|
}
|
|
6809
7006
|
function populateRefs(statements) {
|
|
6810
|
-
const refNodes = gatherRecursive(statements, ($
|
|
7007
|
+
const refNodes = gatherRecursive(statements, ($14) => $14.type === "Ref");
|
|
6811
7008
|
if (refNodes.length) {
|
|
6812
7009
|
const ids = gatherRecursive(statements, (s) => s.type === "Identifier");
|
|
6813
7010
|
const names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
@@ -6830,11 +7027,11 @@ ${js}`
|
|
|
6830
7027
|
function processPlaceholders(statements) {
|
|
6831
7028
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
6832
7029
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
6833
|
-
gatherRecursiveAll(statements, ($
|
|
7030
|
+
gatherRecursiveAll(statements, ($15) => $15.type === "Placeholder").forEach((_exp) => {
|
|
6834
7031
|
const exp = _exp;
|
|
6835
7032
|
let ancestor;
|
|
6836
7033
|
if (exp.subtype === ".") {
|
|
6837
|
-
({ ancestor } = findAncestor(exp, ($
|
|
7034
|
+
({ ancestor } = findAncestor(exp, ($16) => $16.type === "Call"));
|
|
6838
7035
|
ancestor = ancestor?.parent;
|
|
6839
7036
|
while (ancestor?.parent?.type === "UnaryExpression" || ancestor?.parent?.type === "NewExpression") {
|
|
6840
7037
|
ancestor = ancestor.parent;
|
|
@@ -6853,10 +7050,10 @@ ${js}`
|
|
|
6853
7050
|
if (type === "IfStatement") {
|
|
6854
7051
|
liftedIfs.add(ancestor2);
|
|
6855
7052
|
}
|
|
6856
|
-
let m5;
|
|
6857
7053
|
let m6;
|
|
7054
|
+
let m7;
|
|
6858
7055
|
return type === "Call" || // Block, except for if/else blocks when condition already lifted
|
|
6859
|
-
type === "BlockStatement" && !((
|
|
7056
|
+
type === "BlockStatement" && !((m6 = ancestor2.parent, typeof m6 === "object" && m6 != null && "type" in m6 && m6.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m7 = ancestor2.parent, typeof m7 === "object" && m7 != null && "type" in m7 && m7.type === "ElseClause" && "parent" in m7 && typeof m7.parent === "object" && m7.parent != null && "type" in m7.parent && m7.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
|
|
6860
7057
|
type === "Initializer" || // Right-hand side of assignment
|
|
6861
7058
|
type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
|
|
6862
7059
|
}));
|
|
@@ -6932,11 +7129,11 @@ ${js}`
|
|
|
6932
7129
|
for (const [ancestor, placeholders] of placeholderMap) {
|
|
6933
7130
|
let ref = makeRef("$");
|
|
6934
7131
|
let typeSuffix;
|
|
6935
|
-
for (let
|
|
6936
|
-
const placeholder = placeholders[
|
|
7132
|
+
for (let i8 = 0, len7 = placeholders.length; i8 < len7; i8++) {
|
|
7133
|
+
const placeholder = placeholders[i8];
|
|
6937
7134
|
typeSuffix ??= placeholder.typeSuffix;
|
|
6938
|
-
let
|
|
6939
|
-
replaceNode((
|
|
7135
|
+
let ref22;
|
|
7136
|
+
replaceNode((ref22 = placeholder.children)[ref22.length - 1], ref);
|
|
6940
7137
|
}
|
|
6941
7138
|
const { parent } = ancestor;
|
|
6942
7139
|
const body = maybeUnwrap(ancestor);
|
|
@@ -6957,16 +7154,16 @@ ${js}`
|
|
|
6957
7154
|
}
|
|
6958
7155
|
case "PipelineExpression": {
|
|
6959
7156
|
const i = findChildIndex(parent, ancestor);
|
|
6960
|
-
let
|
|
7157
|
+
let ref23;
|
|
6961
7158
|
if (i === 1) {
|
|
6962
|
-
|
|
7159
|
+
ref23 = ancestor === parent.children[i];
|
|
6963
7160
|
} else if (i === 2) {
|
|
6964
|
-
|
|
7161
|
+
ref23 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3];
|
|
6965
7162
|
} else {
|
|
6966
|
-
|
|
7163
|
+
ref23 = void 0;
|
|
6967
7164
|
}
|
|
6968
7165
|
;
|
|
6969
|
-
outer =
|
|
7166
|
+
outer = ref23;
|
|
6970
7167
|
break;
|
|
6971
7168
|
}
|
|
6972
7169
|
case "AssignmentExpression":
|
|
@@ -6981,9 +7178,9 @@ ${js}`
|
|
|
6981
7178
|
fnExp = makeLeftHandSideExpression(fnExp);
|
|
6982
7179
|
}
|
|
6983
7180
|
replaceNode(ancestor, fnExp, parent);
|
|
6984
|
-
let
|
|
6985
|
-
if (
|
|
6986
|
-
const ws =
|
|
7181
|
+
let ref24;
|
|
7182
|
+
if (ref24 = getTrimmingSpace(body)) {
|
|
7183
|
+
const ws = ref24;
|
|
6987
7184
|
inplaceInsertTrimmingSpace(body, "");
|
|
6988
7185
|
inplacePrepend(ws, fnExp);
|
|
6989
7186
|
}
|
|
@@ -7028,8 +7225,8 @@ ${js}`
|
|
|
7028
7225
|
}
|
|
7029
7226
|
];
|
|
7030
7227
|
}
|
|
7031
|
-
let
|
|
7032
|
-
if (Array.isArray(rest.delim) && (
|
|
7228
|
+
let ref25;
|
|
7229
|
+
if (Array.isArray(rest.delim) && (ref25 = rest.delim)[ref25.length - 1]?.token === ",") {
|
|
7033
7230
|
rest.delim = rest.delim.slice(0, -1);
|
|
7034
7231
|
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
7035
7232
|
}
|
|
@@ -7054,9 +7251,9 @@ ${js}`
|
|
|
7054
7251
|
return root;
|
|
7055
7252
|
}
|
|
7056
7253
|
}
|
|
7057
|
-
for (let
|
|
7058
|
-
const i =
|
|
7059
|
-
const node = array[
|
|
7254
|
+
for (let i9 = 0, len8 = array.length; i9 < len8; i9++) {
|
|
7255
|
+
const i = i9;
|
|
7256
|
+
const node = array[i9];
|
|
7060
7257
|
if (!(node != null)) {
|
|
7061
7258
|
return;
|
|
7062
7259
|
}
|
|
@@ -7080,9 +7277,9 @@ ${js}`
|
|
|
7080
7277
|
return root;
|
|
7081
7278
|
}
|
|
7082
7279
|
}
|
|
7083
|
-
for (let
|
|
7084
|
-
const i =
|
|
7085
|
-
const node = array[
|
|
7280
|
+
for (let i10 = 0, len9 = array.length; i10 < len9; i10++) {
|
|
7281
|
+
const i = i10;
|
|
7282
|
+
const node = array[i10];
|
|
7086
7283
|
if (!(node != null)) {
|
|
7087
7284
|
continue;
|
|
7088
7285
|
}
|
|
@@ -7500,7 +7697,7 @@ ${js}`
|
|
|
7500
7697
|
IgnoreColon,
|
|
7501
7698
|
TryStatement,
|
|
7502
7699
|
CatchClause,
|
|
7503
|
-
|
|
7700
|
+
CatchBinding,
|
|
7504
7701
|
FinallyClause,
|
|
7505
7702
|
CatchParameter,
|
|
7506
7703
|
Condition,
|
|
@@ -7844,6 +8041,7 @@ ${js}`
|
|
|
7844
8041
|
TypeSuffix,
|
|
7845
8042
|
MaybeNestedType,
|
|
7846
8043
|
MaybeNestedTypePrimary,
|
|
8044
|
+
MaybeNestedTypeUnary,
|
|
7847
8045
|
ReturnTypeSuffix,
|
|
7848
8046
|
ReturnType,
|
|
7849
8047
|
TypePredicate,
|
|
@@ -9902,11 +10100,12 @@ ${js}`
|
|
|
9902
10100
|
var ws = $3;
|
|
9903
10101
|
var close = $4;
|
|
9904
10102
|
if (expression.type === "SliceParameters") {
|
|
9905
|
-
const { start, end, children } = expression;
|
|
10103
|
+
const { start, end, reversed, children } = expression;
|
|
9906
10104
|
return {
|
|
9907
10105
|
type: "SliceExpression",
|
|
9908
10106
|
start,
|
|
9909
10107
|
end,
|
|
10108
|
+
reversed,
|
|
9910
10109
|
children: [
|
|
9911
10110
|
{ ...open, token: ".slice(" },
|
|
9912
10111
|
...children,
|
|
@@ -9923,78 +10122,57 @@ ${js}`
|
|
|
9923
10122
|
function MemberBracketContent(ctx, state2) {
|
|
9924
10123
|
return (0, import_lib4.$EVENT)(ctx, state2, "MemberBracketContent", MemberBracketContent$0);
|
|
9925
10124
|
}
|
|
9926
|
-
var SliceParameters$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Expression, __, RangeDots, (0, import_lib4.$E)(Expression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9927
|
-
var
|
|
9928
|
-
var
|
|
9929
|
-
var
|
|
9930
|
-
var
|
|
10125
|
+
var SliceParameters$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, (0, import_lib4.$E)(Expression), __, RangeDots, Loc, (0, import_lib4.$E)(Expression)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
10126
|
+
var ls = $1;
|
|
10127
|
+
var start = $2;
|
|
10128
|
+
var ws = $3;
|
|
10129
|
+
var dots = $4;
|
|
10130
|
+
var le = $5;
|
|
10131
|
+
var end = $6;
|
|
10132
|
+
const reversed = dots.increasing === false;
|
|
10133
|
+
const sign = reversed ? "-" : "+";
|
|
9931
10134
|
let children;
|
|
10135
|
+
start ??= {
|
|
10136
|
+
$loc: ls.$loc,
|
|
10137
|
+
token: reversed ? "-1" : "0"
|
|
10138
|
+
};
|
|
10139
|
+
if (!end) {
|
|
10140
|
+
if (reversed) {
|
|
10141
|
+
end = {
|
|
10142
|
+
$loc: le.$loc,
|
|
10143
|
+
token: "0"
|
|
10144
|
+
};
|
|
10145
|
+
} else if (!dots.right.inclusive && !dots.triple) {
|
|
10146
|
+
end = {
|
|
10147
|
+
$loc: le.$loc,
|
|
10148
|
+
token: "-1"
|
|
10149
|
+
};
|
|
10150
|
+
}
|
|
10151
|
+
}
|
|
9932
10152
|
if (!dots.left.inclusive) {
|
|
9933
|
-
start = [
|
|
10153
|
+
start = [makeLeftHandSideExpression(start), ` ${sign} 1`];
|
|
9934
10154
|
}
|
|
9935
10155
|
if (end) {
|
|
9936
10156
|
const inc = [];
|
|
9937
10157
|
if (dots.right.inclusive) {
|
|
9938
|
-
end = [
|
|
9939
|
-
|
|
10158
|
+
end = [makeLeftHandSideExpression(end), ` ${sign} 1`];
|
|
10159
|
+
if (!reversed)
|
|
10160
|
+
inc.push(" || 1/0");
|
|
9940
10161
|
}
|
|
9941
10162
|
children = [start, [...ws, dots.children[0], { token: ", ", $loc: dots.$loc }], [dots.children[1], end, ...inc]];
|
|
9942
10163
|
} else {
|
|
9943
10164
|
children = [start, ws];
|
|
9944
10165
|
}
|
|
9945
|
-
if (dots.increasing === false) {
|
|
9946
|
-
children.push({
|
|
9947
|
-
type: "Error",
|
|
9948
|
-
message: "Slice range cannot be decreasing",
|
|
9949
|
-
$loc: dots.$loc
|
|
9950
|
-
});
|
|
9951
|
-
}
|
|
9952
10166
|
return {
|
|
9953
10167
|
type: "SliceParameters",
|
|
9954
10168
|
start,
|
|
9955
10169
|
end,
|
|
10170
|
+
reversed,
|
|
9956
10171
|
children
|
|
9957
10172
|
};
|
|
9958
10173
|
});
|
|
9959
|
-
var SliceParameters$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, __, (0, import_lib4.$C)(DotDotDot, DotDot), Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9960
|
-
var l = $1;
|
|
9961
|
-
var ws = $2;
|
|
9962
|
-
var sep = $3;
|
|
9963
|
-
var end = $4;
|
|
9964
|
-
const inclusive = sep.token === "..";
|
|
9965
|
-
const inc = [];
|
|
9966
|
-
if (inclusive) {
|
|
9967
|
-
end = ["1 + ", end];
|
|
9968
|
-
inc.push(" || 1/0");
|
|
9969
|
-
}
|
|
9970
|
-
const start = {
|
|
9971
|
-
$loc: l.$loc,
|
|
9972
|
-
token: "0"
|
|
9973
|
-
};
|
|
9974
|
-
return {
|
|
9975
|
-
type: "SliceParameters",
|
|
9976
|
-
start,
|
|
9977
|
-
end,
|
|
9978
|
-
children: [start, [...ws, { ...sep, token: ", " }], [end, ...inc]]
|
|
9979
|
-
};
|
|
9980
|
-
});
|
|
9981
|
-
var SliceParameters$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(Loc, __, (0, import_lib4.$C)(DotDot, DotDotDot), (0, import_lib4.$Y)((0, import_lib4.$S)(__, CloseBracket))), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9982
|
-
var l = $1;
|
|
9983
|
-
var ws = $2;
|
|
9984
|
-
const start = {
|
|
9985
|
-
$loc: l.$loc,
|
|
9986
|
-
token: "0"
|
|
9987
|
-
};
|
|
9988
|
-
return {
|
|
9989
|
-
type: "SliceParameters",
|
|
9990
|
-
start,
|
|
9991
|
-
end: void 0,
|
|
9992
|
-
children: [start, ws]
|
|
9993
|
-
};
|
|
9994
|
-
});
|
|
9995
|
-
var SliceParameters$$ = [SliceParameters$0, SliceParameters$1, SliceParameters$2];
|
|
9996
10174
|
function SliceParameters(ctx, state2) {
|
|
9997
|
-
return (0, import_lib4.$
|
|
10175
|
+
return (0, import_lib4.$EVENT)(ctx, state2, "SliceParameters", SliceParameters$0);
|
|
9998
10176
|
}
|
|
9999
10177
|
var AccessStart$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(PropertyAccessModifier), Dot, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($R11, "AccessStart /[.\\s]/"))), function($skip, $loc, $0, $1, $2, $3) {
|
|
10000
10178
|
var modifier = $1;
|
|
@@ -11663,6 +11841,7 @@ ${js}`
|
|
|
11663
11841
|
left: { inclusive: true, raw: "" },
|
|
11664
11842
|
right: { inclusive: false, raw: "." },
|
|
11665
11843
|
increasing: void 0,
|
|
11844
|
+
triple: true,
|
|
11666
11845
|
children: []
|
|
11667
11846
|
};
|
|
11668
11847
|
});
|
|
@@ -13940,12 +14119,14 @@ ${js}`
|
|
|
13940
14119
|
};
|
|
13941
14120
|
});
|
|
13942
14121
|
var CaseClause$4 = (0, import_lib4.$TS)((0, import_lib4.$S)(Else, ImpliedColon, (0, import_lib4.$C)(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
|
|
14122
|
+
var e = $1;
|
|
14123
|
+
var colon = $2;
|
|
13943
14124
|
var block = $3;
|
|
13944
|
-
|
|
14125
|
+
e = { ...e, token: "default" };
|
|
13945
14126
|
return {
|
|
13946
14127
|
type: "DefaultClause",
|
|
13947
14128
|
block,
|
|
13948
|
-
children:
|
|
14129
|
+
children: [e, colon, block]
|
|
13949
14130
|
};
|
|
13950
14131
|
});
|
|
13951
14132
|
var CaseClause$$ = [CaseClause$0, CaseClause$1, CaseClause$2, CaseClause$3, CaseClause$4];
|
|
@@ -14016,36 +14197,56 @@ ${js}`
|
|
|
14016
14197
|
function IgnoreColon(ctx, state2) {
|
|
14017
14198
|
return (0, import_lib4.$EVENT)(ctx, state2, "IgnoreColon", IgnoreColon$0);
|
|
14018
14199
|
}
|
|
14019
|
-
var TryStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Try, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($L16, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib4.$
|
|
14200
|
+
var TryStatement$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(Try, (0, import_lib4.$N)((0, import_lib4.$EXPECT)($L16, 'TryStatement ":"')), NoPostfixBracedOrEmptyBlock, (0, import_lib4.$Q)(CatchClause), (0, import_lib4.$E)(ElseClause), (0, import_lib4.$E)(FinallyClause)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
14020
14201
|
return processTryBlock($0);
|
|
14021
14202
|
});
|
|
14022
14203
|
function TryStatement(ctx, state2) {
|
|
14023
14204
|
return (0, import_lib4.$EVENT)(ctx, state2, "TryStatement", TryStatement$0);
|
|
14024
14205
|
}
|
|
14025
|
-
var CatchClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Catch, (0, import_lib4.$E)(
|
|
14206
|
+
var CatchClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Catch, (0, import_lib4.$E)(CatchBinding), (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
14207
|
+
var binding = $3;
|
|
14026
14208
|
var block = $4;
|
|
14027
14209
|
return {
|
|
14028
14210
|
type: "CatchClause",
|
|
14029
14211
|
children: $0,
|
|
14030
|
-
block
|
|
14212
|
+
block,
|
|
14213
|
+
binding
|
|
14031
14214
|
};
|
|
14032
14215
|
});
|
|
14033
14216
|
function CatchClause(ctx, state2) {
|
|
14034
14217
|
return (0, import_lib4.$EVENT)(ctx, state2, "CatchClause", CatchClause$0);
|
|
14035
14218
|
}
|
|
14036
|
-
var
|
|
14037
|
-
|
|
14219
|
+
var CatchBinding$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), OpenParen, __, AllowAll, (0, import_lib4.$E)(CatchParameter), RestoreAll, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
14220
|
+
var ws1 = $1;
|
|
14221
|
+
var open = $2;
|
|
14222
|
+
var ws2 = $3;
|
|
14223
|
+
var parameter = $5;
|
|
14224
|
+
var ws3 = $7;
|
|
14225
|
+
var close = $8;
|
|
14226
|
+
if (!parameter)
|
|
14227
|
+
return $skip;
|
|
14228
|
+
return {
|
|
14229
|
+
type: "CatchBinding",
|
|
14230
|
+
parameter,
|
|
14231
|
+
children: [ws1, open, ws2, parameter, ws3, close]
|
|
14232
|
+
};
|
|
14233
|
+
});
|
|
14234
|
+
var CatchBinding$1 = (0, import_lib4.$TS)((0, import_lib4.$S)(_, InsertOpenParen, (0, import_lib4.$N)(EOS), ForbidIndentedApplication, (0, import_lib4.$E)(CatchParameter), RestoreIndentedApplication, InsertCloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
14038
14235
|
var ws = $1;
|
|
14039
14236
|
var open = $2;
|
|
14040
|
-
var
|
|
14237
|
+
var parameter = $5;
|
|
14041
14238
|
var close = $7;
|
|
14042
|
-
if (!
|
|
14239
|
+
if (!parameter)
|
|
14043
14240
|
return $skip;
|
|
14044
|
-
return
|
|
14241
|
+
return {
|
|
14242
|
+
type: "CatchBinding",
|
|
14243
|
+
parameter,
|
|
14244
|
+
children: [ws, open, parameter, close]
|
|
14245
|
+
};
|
|
14045
14246
|
});
|
|
14046
|
-
var
|
|
14047
|
-
function
|
|
14048
|
-
return (0, import_lib4.$EVENT_C)(ctx, state2, "
|
|
14247
|
+
var CatchBinding$$ = [CatchBinding$0, CatchBinding$1];
|
|
14248
|
+
function CatchBinding(ctx, state2) {
|
|
14249
|
+
return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchBinding", CatchBinding$$);
|
|
14049
14250
|
}
|
|
14050
14251
|
var FinallyClause$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(Nested, _), Finally, (0, import_lib4.$C)(BracedThenClause, BracedOrEmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
|
|
14051
14252
|
var block = $3;
|
|
@@ -14058,9 +14259,34 @@ ${js}`
|
|
|
14058
14259
|
function FinallyClause(ctx, state2) {
|
|
14059
14260
|
return (0, import_lib4.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
|
|
14060
14261
|
}
|
|
14061
|
-
var CatchParameter$0 = (0, import_lib4.$S)(BindingIdentifier, (0, import_lib4.$E)(TypeSuffix))
|
|
14062
|
-
|
|
14063
|
-
|
|
14262
|
+
var CatchParameter$0 = (0, import_lib4.$TS)((0, import_lib4.$S)(BindingIdentifier, (0, import_lib4.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
|
|
14263
|
+
var binding = $1;
|
|
14264
|
+
var typeSuffix = $2;
|
|
14265
|
+
return {
|
|
14266
|
+
type: "CatchParameter",
|
|
14267
|
+
binding,
|
|
14268
|
+
typeSuffix,
|
|
14269
|
+
children: $0
|
|
14270
|
+
};
|
|
14271
|
+
});
|
|
14272
|
+
var CatchParameter$1 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
|
|
14273
|
+
var binding = $1;
|
|
14274
|
+
var typeSuffix = $2;
|
|
14275
|
+
return {
|
|
14276
|
+
type: "CatchParameter",
|
|
14277
|
+
binding,
|
|
14278
|
+
typeSuffix,
|
|
14279
|
+
children: [binding, typeSuffix]
|
|
14280
|
+
};
|
|
14281
|
+
});
|
|
14282
|
+
var CatchParameter$2 = (0, import_lib4.$TS)((0, import_lib4.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
|
|
14283
|
+
return {
|
|
14284
|
+
type: "CatchPattern",
|
|
14285
|
+
children: $0,
|
|
14286
|
+
patterns: $1
|
|
14287
|
+
};
|
|
14288
|
+
});
|
|
14289
|
+
var CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
|
|
14064
14290
|
function CatchParameter(ctx, state2) {
|
|
14065
14291
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "CatchParameter", CatchParameter$$);
|
|
14066
14292
|
}
|
|
@@ -17466,6 +17692,19 @@ ${js}`
|
|
|
17466
17692
|
function MaybeNestedTypePrimary(ctx, state2) {
|
|
17467
17693
|
return (0, import_lib4.$EVENT_C)(ctx, state2, "MaybeNestedTypePrimary", MaybeNestedTypePrimary$$);
|
|
17468
17694
|
}
|
|
17695
|
+
var MaybeNestedTypeUnary$0 = NestedTypeBulletedTuple;
|
|
17696
|
+
var MaybeNestedTypeUnary$1 = NestedInterfaceBlock;
|
|
17697
|
+
var MaybeNestedTypeUnary$2 = NestedTypeBinaryChain;
|
|
17698
|
+
var MaybeNestedTypeUnary$3 = (0, import_lib4.$TS)((0, import_lib4.$S)(PushIndent, (0, import_lib4.$E)((0, import_lib4.$S)(Nested, Type)), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
|
|
17699
|
+
if (!$2)
|
|
17700
|
+
return $skip;
|
|
17701
|
+
return $2;
|
|
17702
|
+
});
|
|
17703
|
+
var MaybeNestedTypeUnary$4 = (0, import_lib4.$S)(NotDedented, TypeUnary);
|
|
17704
|
+
var MaybeNestedTypeUnary$$ = [MaybeNestedTypeUnary$0, MaybeNestedTypeUnary$1, MaybeNestedTypeUnary$2, MaybeNestedTypeUnary$3, MaybeNestedTypeUnary$4];
|
|
17705
|
+
function MaybeNestedTypeUnary(ctx, state2) {
|
|
17706
|
+
return (0, import_lib4.$EVENT_C)(ctx, state2, "MaybeNestedTypeUnary", MaybeNestedTypeUnary$$);
|
|
17707
|
+
}
|
|
17469
17708
|
var ReturnTypeSuffix$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)(_), (0, import_lib4.$E)(QuestionMark), (0, import_lib4.$E)(_), Colon, ReturnType), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
17470
17709
|
var optional = $2;
|
|
17471
17710
|
var t = $5;
|
|
@@ -17520,7 +17759,7 @@ ${js}`
|
|
|
17520
17759
|
function Type(ctx, state2) {
|
|
17521
17760
|
return (0, import_lib4.$EVENT)(ctx, state2, "Type", Type$0);
|
|
17522
17761
|
}
|
|
17523
|
-
var TypeBinary$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __)), TypeUnary, (0, import_lib4.$Q)((0, import_lib4.$S)(NotDedented, TypeBinaryOp,
|
|
17762
|
+
var TypeBinary$0 = (0, import_lib4.$TS)((0, import_lib4.$S)((0, import_lib4.$E)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, __)), TypeUnary, (0, import_lib4.$Q)((0, import_lib4.$S)(NotDedented, TypeBinaryOp, MaybeNestedTypeUnary))), function($skip, $loc, $0, $1, $2, $3) {
|
|
17524
17763
|
var optionalPrefix = $1;
|
|
17525
17764
|
var t = $2;
|
|
17526
17765
|
var ops = $3;
|