@danielx/civet 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/dist/browser.js +498 -330
- package/dist/main.js +600 -342
- package/dist/main.mjs +600 -342
- package/package.json +2 -2
package/dist/browser.js
CHANGED
|
@@ -473,6 +473,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
473
473
|
maybeRefAssignment: () => maybeRefAssignment,
|
|
474
474
|
modifyString: () => modifyString,
|
|
475
475
|
negateCondition: () => negateCondition,
|
|
476
|
+
precedenceCustomDefault: () => precedenceCustomDefault,
|
|
476
477
|
precedenceStep: () => precedenceStep,
|
|
477
478
|
prepend: () => prepend,
|
|
478
479
|
processAssignmentDeclaration: () => processAssignmentDeclaration,
|
|
@@ -1271,6 +1272,14 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1271
1272
|
}
|
|
1272
1273
|
|
|
1273
1274
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\ref.civet.jsx
|
|
1275
|
+
var range = (start, end) => {
|
|
1276
|
+
let length = end - start;
|
|
1277
|
+
if (length <= 0) return [];
|
|
1278
|
+
let arr = Array(length);
|
|
1279
|
+
for (let i = 0; i < length; ++i)
|
|
1280
|
+
arr[i] = i + start;
|
|
1281
|
+
return arr;
|
|
1282
|
+
};
|
|
1274
1283
|
function makeRef(base = "ref", id = base) {
|
|
1275
1284
|
return {
|
|
1276
1285
|
type: "Ref",
|
|
@@ -1281,7 +1290,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1281
1290
|
function needsRef(expression, base = "ref") {
|
|
1282
1291
|
if (expression != null && typeof expression == "object") {
|
|
1283
1292
|
if (Array.isArray(expression)) {
|
|
1284
|
-
let nonempty = (
|
|
1293
|
+
let nonempty = range(0, expression.length).filter((i) => !isWhitespaceOrEmpty(expression[i]));
|
|
1285
1294
|
if (nonempty.length === 1) {
|
|
1286
1295
|
let ref1;
|
|
1287
1296
|
return (ref1 = needsRef(expression[nonempty[0]], base)) ? ref1 : void 0;
|
|
@@ -1320,10 +1329,27 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1320
1329
|
let ref = maybeRef(exp, base);
|
|
1321
1330
|
return ref === exp ? { ref, refAssignmentComma: [] } : { ref, ...makeRefAssignment(ref, exp) };
|
|
1322
1331
|
}
|
|
1332
|
+
function populateRefs(statements) {
|
|
1333
|
+
let refNodes = gatherRecursive(statements, ($) => $.type === "Ref");
|
|
1334
|
+
if (!refNodes.length)
|
|
1335
|
+
return;
|
|
1336
|
+
let ids = gatherRecursive(statements, ($1) => $1.type === "Identifier"), names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
1337
|
+
for (let i1 = 0, len3 = refNodes.length; i1 < len3; i1++) {
|
|
1338
|
+
let ref = refNodes[i1];
|
|
1339
|
+
if (ref.type !== "Ref")
|
|
1340
|
+
continue;
|
|
1341
|
+
let { base } = ref;
|
|
1342
|
+
ref.type = "Identifier";
|
|
1343
|
+
let n = 0, name = base;
|
|
1344
|
+
for (; names.has(name); )
|
|
1345
|
+
n++, name = `${base}${n}`;
|
|
1346
|
+
names.add(name), ref.children = ref.names = [name];
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1323
1349
|
|
|
1324
1350
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\binding.civet.jsx
|
|
1325
1351
|
function adjustAtBindings(statements, asThis = !1) {
|
|
1326
|
-
for (let ref1 = gatherRecursiveAll(statements, ($) =>
|
|
1352
|
+
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "AtBindingProperty"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
1327
1353
|
let binding = ref1[i1], { ref } = binding;
|
|
1328
1354
|
if (asThis) {
|
|
1329
1355
|
let atBinding = binding.binding;
|
|
@@ -1334,7 +1360,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1334
1360
|
}
|
|
1335
1361
|
}
|
|
1336
1362
|
function adjustBindingElements(elements) {
|
|
1337
|
-
let names = elements.flatMap(($
|
|
1363
|
+
let names = elements.flatMap(($2) => $2.names || []), { length } = elements, blockPrefix, restIndex = -1, restCount = 0;
|
|
1338
1364
|
for (let i2 = 0, len1 = elements.length; i2 < len1; i2++) {
|
|
1339
1365
|
let i = i2, { type } = elements[i2];
|
|
1340
1366
|
type === "BindingRestElement" && (restIndex < 0 && (restIndex = i), restCount++);
|
|
@@ -1382,21 +1408,40 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1382
1408
|
length
|
|
1383
1409
|
};
|
|
1384
1410
|
}
|
|
1411
|
+
function gatherSubbindings(node, subbindings = []) {
|
|
1412
|
+
for (let ref2 = gatherRecursiveAll(node, ($) => $.subbinding != null), i3 = 0, len22 = ref2.length; i3 < len22; i3++) {
|
|
1413
|
+
let p = ref2[i3], { subbinding } = p;
|
|
1414
|
+
subbindings.push(", ", subbinding), gatherSubbindings(subbinding, subbindings);
|
|
1415
|
+
}
|
|
1416
|
+
return subbindings;
|
|
1417
|
+
}
|
|
1418
|
+
function simplifyBindingProperties(node) {
|
|
1419
|
+
let results = [];
|
|
1420
|
+
for (let ref3 = gatherRecursiveAll(node, ($3) => $3.type === "BindingProperty"), i4 = 0, len3 = ref3.length; i4 < len3; i4++) {
|
|
1421
|
+
let p = ref3[i4], { name, value } = p;
|
|
1422
|
+
if (value?.type === "NamedBindingPattern" && value.binding === name) {
|
|
1423
|
+
let [ws] = p.children;
|
|
1424
|
+
results.push(p.children = [ws, name, p.delim]);
|
|
1425
|
+
} else
|
|
1426
|
+
results.push(void 0);
|
|
1427
|
+
}
|
|
1428
|
+
return results;
|
|
1429
|
+
}
|
|
1385
1430
|
function gatherBindingCode(statements, opts) {
|
|
1386
1431
|
let thisAssignments = [], splices = [];
|
|
1387
1432
|
function insertRestSplices(s, p, thisAssignments2) {
|
|
1388
1433
|
let m;
|
|
1389
|
-
for (let
|
|
1434
|
+
for (let ref4 = gatherRecursiveAll(
|
|
1390
1435
|
s,
|
|
1391
1436
|
(n) => n.blockPrefix || opts?.injectParamProps && n.accessModifier || n.type === "AtBinding" || opts?.assignPins && (m = n.type, m === "PinPattern" || m === "PinProperty")
|
|
1392
|
-
),
|
|
1393
|
-
let n =
|
|
1437
|
+
), i5 = 0, len4 = ref4.length; i5 < len4; i5++) {
|
|
1438
|
+
let n = ref4[i5];
|
|
1394
1439
|
if (n.type === "AtBinding") {
|
|
1395
1440
|
let { ref } = n, { id } = ref;
|
|
1396
1441
|
thisAssignments2.push([`this.${id} = `, ref]);
|
|
1397
1442
|
continue;
|
|
1398
1443
|
}
|
|
1399
|
-
if (opts?.assignPins && (n.type === "PinProperty" && (n.children = n.children.flatMap(($
|
|
1444
|
+
if (opts?.assignPins && (n.type === "PinProperty" && (n.children = n.children.flatMap(($4) => $4 === n.name ? [n.name, ": ", n.value] : $4), updateParentPointers(n), n = n.value), n.type === "PinPattern")) {
|
|
1400
1445
|
n.ref = makeRef(
|
|
1401
1446
|
n.expression.type === "Identifier" ? n.expression.name : "pin"
|
|
1402
1447
|
), n.children = [n.ref], updateParentPointers(n), thisAssignments2.push({
|
|
@@ -1410,8 +1455,8 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1410
1455
|
continue;
|
|
1411
1456
|
}
|
|
1412
1457
|
if (opts?.injectParamProps && n.type === "Parameter" && n.accessModifier) {
|
|
1413
|
-
for (let
|
|
1414
|
-
let id =
|
|
1458
|
+
for (let ref5 = n.names, i6 = 0, len5 = ref5.length; i6 < len5; i6++) {
|
|
1459
|
+
let id = ref5[i6];
|
|
1415
1460
|
thisAssignments2.push({
|
|
1416
1461
|
type: "AssignmentExpression",
|
|
1417
1462
|
children: [`this.${id} = `, id],
|
|
@@ -1427,7 +1472,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1427
1472
|
return insertRestSplices(statements, splices, thisAssignments), [splices, thisAssignments];
|
|
1428
1473
|
}
|
|
1429
1474
|
function arrayElementHasTrailingComma(elementNode) {
|
|
1430
|
-
let
|
|
1475
|
+
let ref6, lastChild = (ref6 = elementNode.children)[ref6.length - 1];
|
|
1431
1476
|
return lastChild && lastChild[lastChild.length - 1]?.token === ",";
|
|
1432
1477
|
}
|
|
1433
1478
|
function gatherBindingPatternTypeSuffix(pattern) {
|
|
@@ -1437,14 +1482,14 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1437
1482
|
switch (pattern.type) {
|
|
1438
1483
|
case "ArrayBindingPattern": {
|
|
1439
1484
|
{
|
|
1440
|
-
let
|
|
1441
|
-
for (let
|
|
1442
|
-
let elem =
|
|
1485
|
+
let results1 = [];
|
|
1486
|
+
for (let ref7 = pattern.elements, i7 = 0, len6 = ref7.length; i7 < len6; i7++) {
|
|
1487
|
+
let elem = ref7[i7], { typeSuffix } = elem;
|
|
1443
1488
|
typeSuffix ??= elem.binding?.typeSuffix, typeSuffix && count++;
|
|
1444
1489
|
let typeElement = [typeSuffix?.t, elem.delim];
|
|
1445
|
-
typeSuffix?.optional && (typeElement[0] = parenthesizeType(typeElement[0]), typeElement.unshift("undefined |")), elem.type === "BindingRestElement" ? (typeElement[0] ??= "unknown[]", typeElement.unshift(elem.dots)) : typeElement[0] ??= "unknown",
|
|
1490
|
+
typeSuffix?.optional && (typeElement[0] = parenthesizeType(typeElement[0]), typeElement.unshift("undefined |")), elem.type === "BindingRestElement" ? (typeElement[0] ??= "unknown[]", typeElement.unshift(elem.dots)) : typeElement[0] ??= "unknown", results1.push(typeElement);
|
|
1446
1491
|
}
|
|
1447
|
-
let types =
|
|
1492
|
+
let types = results1;
|
|
1448
1493
|
if (count) {
|
|
1449
1494
|
let t = [": [", types, "]"];
|
|
1450
1495
|
pattern.typeSuffix = {
|
|
@@ -1459,9 +1504,9 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1459
1504
|
}
|
|
1460
1505
|
case "ObjectBindingPattern": {
|
|
1461
1506
|
{
|
|
1462
|
-
let restType,
|
|
1463
|
-
for (let
|
|
1464
|
-
let prop =
|
|
1507
|
+
let restType, results2 = [];
|
|
1508
|
+
for (let ref8 = pattern.properties, i8 = 0, len7 = ref8.length; i8 < len7; i8++) {
|
|
1509
|
+
let prop = ref8[i8], { typeSuffix } = prop;
|
|
1465
1510
|
switch (typeSuffix ??= prop.value?.typeSuffix, typeSuffix && count++, typeSuffix ??= {
|
|
1466
1511
|
type: "TypeSuffix",
|
|
1467
1512
|
ts: !0,
|
|
@@ -1469,12 +1514,12 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1469
1514
|
}, prop.type) {
|
|
1470
1515
|
case "BindingProperty": {
|
|
1471
1516
|
let ws = prop.children.slice(0, prop.children.indexOf(prop.name));
|
|
1472
|
-
|
|
1517
|
+
results2.push([...ws, prop.name, typeSuffix, prop.delim]);
|
|
1473
1518
|
break;
|
|
1474
1519
|
}
|
|
1475
1520
|
case "AtBindingProperty": {
|
|
1476
1521
|
let ws = prop.children.slice(0, prop.children.indexOf(prop.binding));
|
|
1477
|
-
|
|
1522
|
+
results2.push([...ws, prop.ref.id.replace(/^#/, ""), typeSuffix, prop.delim]);
|
|
1478
1523
|
break;
|
|
1479
1524
|
}
|
|
1480
1525
|
case "BindingRestProperty": {
|
|
@@ -1483,7 +1528,7 @@ ${body}`), super(message), this.header = header, this.body = body, this.filename
|
|
|
1483
1528
|
}
|
|
1484
1529
|
}
|
|
1485
1530
|
}
|
|
1486
|
-
let types =
|
|
1531
|
+
let types = results2;
|
|
1487
1532
|
if (count) {
|
|
1488
1533
|
let t = ["{", types, "}"];
|
|
1489
1534
|
restType != null && t.push(" & ", parenthesizeType(trimFirstSpace(restType))), pattern.typeSuffix = {
|
|
@@ -2385,7 +2430,7 @@ ${js}`
|
|
|
2385
2430
|
exp = exp;
|
|
2386
2431
|
let outer = exp;
|
|
2387
2432
|
exp.type === "LabelledStatement" && (exp = exp.statement);
|
|
2388
|
-
let ref6;
|
|
2433
|
+
let ref6, m1;
|
|
2389
2434
|
switch (exp.type) {
|
|
2390
2435
|
case "BreakStatement":
|
|
2391
2436
|
case "ContinueStatement":
|
|
@@ -2450,6 +2495,8 @@ ${js}`
|
|
|
2450
2495
|
return;
|
|
2451
2496
|
}
|
|
2452
2497
|
case "PipelineExpression": {
|
|
2498
|
+
if (m1 = exp.children[1]?.type, m1 === "ReturnStatement" || m1 === "ThrowStatement")
|
|
2499
|
+
return;
|
|
2453
2500
|
let semi2 = exp.children.lastIndexOf(";");
|
|
2454
2501
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
2455
2502
|
exp.children.splice(semi2 + 1, 1 / 0, collect(exp.children.slice(semi2 + 1)));
|
|
@@ -2470,8 +2517,8 @@ ${js}`
|
|
|
2470
2517
|
let last = node.expressions[node.expressions.length - 1];
|
|
2471
2518
|
insertReturn(last);
|
|
2472
2519
|
} else {
|
|
2473
|
-
let
|
|
2474
|
-
|
|
2520
|
+
let m2;
|
|
2521
|
+
m2 = node.parent?.type, (m2 === "CatchClause" || m2 === "WhenClause") && node.expressions.push(["", wrapWithReturn(void 0, node)]);
|
|
2475
2522
|
}
|
|
2476
2523
|
return;
|
|
2477
2524
|
}
|
|
@@ -2502,7 +2549,7 @@ ${js}`
|
|
|
2502
2549
|
return;
|
|
2503
2550
|
let outer = exp;
|
|
2504
2551
|
exp.type === "LabelledStatement" && (exp = exp.statement);
|
|
2505
|
-
let ref11;
|
|
2552
|
+
let ref11, m3;
|
|
2506
2553
|
switch (exp.type) {
|
|
2507
2554
|
case "BreakStatement":
|
|
2508
2555
|
case "ContinueStatement":
|
|
@@ -2579,6 +2626,8 @@ ${js}`
|
|
|
2579
2626
|
return;
|
|
2580
2627
|
}
|
|
2581
2628
|
case "PipelineExpression": {
|
|
2629
|
+
if (m3 = exp.children[1]?.type, m3 === "ReturnStatement" || m3 === "ThrowStatement")
|
|
2630
|
+
return;
|
|
2582
2631
|
let semi2 = exp.children.lastIndexOf(";");
|
|
2583
2632
|
if (0 <= semi2 && semi2 < exp.children.length - 1) {
|
|
2584
2633
|
exp.children.splice(semi2 + 1, 1 / 0, wrapWithReturn(exp.children.slice(semi2 + 1)));
|
|
@@ -2597,8 +2646,8 @@ ${js}`
|
|
|
2597
2646
|
))
|
|
2598
2647
|
if (control.with) {
|
|
2599
2648
|
if (control.label) {
|
|
2600
|
-
let
|
|
2601
|
-
if (
|
|
2649
|
+
let m4;
|
|
2650
|
+
if (m4 = statement.parent, !(typeof m4 == "object" && m4 != null && "type" in m4 && m4.type === "LabelledStatement" && "label" in m4 && typeof m4.label == "object" && m4.label != null && "name" in m4.label && m4.label.name === control.label.name))
|
|
2602
2651
|
continue;
|
|
2603
2652
|
} else {
|
|
2604
2653
|
let { ancestor } = findAncestor(
|
|
@@ -2749,8 +2798,8 @@ ${js}`
|
|
|
2749
2798
|
return !1;
|
|
2750
2799
|
let reduction = statement.type === "ForStatement" && statement.reduction;
|
|
2751
2800
|
function fillBlock(expression) {
|
|
2752
|
-
let ref15,
|
|
2753
|
-
return
|
|
2801
|
+
let ref15, m5;
|
|
2802
|
+
return m5 = (ref15 = block.expressions)[ref15.length - 1], Array.isArray(m5) && m5.length >= 2 && typeof m5[1] == "object" && m5[1] != null && "type" in m5[1] && m5[1].type === "EmptyStatement" && "implicit" in m5[1] && m5[1].implicit === !0 && block.expressions.pop(), block.expressions.push(expression), block.empty = !1, braceBlock(block);
|
|
2754
2803
|
}
|
|
2755
2804
|
if (reduction)
|
|
2756
2805
|
switch (reduction.subtype) {
|
|
@@ -2828,7 +2877,8 @@ ${js}`
|
|
|
2828
2877
|
if (parameters.names = before.flatMap(($7) => $7.names), parameters.parameters.splice(0, 1 / 0), tt && parameters.parameters.push(tt), parameters.parameters.push(...before), rest) {
|
|
2829
2878
|
let restIdentifier = rest.binding.ref || rest.binding;
|
|
2830
2879
|
if (parameters.names.push(...rest.names || []), rest.children.pop(), after.length) {
|
|
2831
|
-
|
|
2880
|
+
let m6;
|
|
2881
|
+
m6 = rest.binding.type, (m6 === "ArrayBindingPattern" || m6 === "ObjectBindingPattern" || m6 === "NamedBindingPattern") && parameters.parameters.push({
|
|
2832
2882
|
type: "Error",
|
|
2833
2883
|
message: "Non-end rest parameter cannot be binding pattern"
|
|
2834
2884
|
}), after = trimFirstSpace(after);
|
|
@@ -2924,14 +2974,14 @@ ${js}`
|
|
|
2924
2974
|
let [splices, thisAssignments] = gatherBindingCode(parameters, {
|
|
2925
2975
|
injectParamProps: isConstructor,
|
|
2926
2976
|
assignPins: !0
|
|
2927
|
-
});
|
|
2928
|
-
if (isConstructor) {
|
|
2977
|
+
}), subbindings = gatherSubbindings(parameters.parameters);
|
|
2978
|
+
if (simplifyBindingProperties(parameters.parameters), simplifyBindingProperties(subbindings), isConstructor) {
|
|
2929
2979
|
let { ancestor } = findAncestor(f, ($10) => $10.type === "ClassExpression");
|
|
2930
2980
|
if (ancestor != null) {
|
|
2931
2981
|
let fields = new Set(gatherRecursiveWithinFunction(ancestor, ($11) => $11.type === "FieldDefinition").map(($12) => $12.id).filter((a3) => typeof a3 == "object" && a3 != null && "type" in a3 && a3.type === "Identifier").map(($13) => $13.name)), classExpressions = ancestor.body.expressions, index2 = findChildIndex(classExpressions, f);
|
|
2932
2982
|
assert.notEqual(index2, -1, "Could not find constructor in class");
|
|
2933
|
-
let
|
|
2934
|
-
for (;
|
|
2983
|
+
let m7;
|
|
2984
|
+
for (; m7 = classExpressions[index2 - 1]?.[1], typeof m7 == "object" && m7 != null && "type" in m7 && m7.type === "MethodDefinition" && "name" in m7 && m7.name === "constructor"; )
|
|
2935
2985
|
index2--;
|
|
2936
2986
|
let fStatement = classExpressions[index2];
|
|
2937
2987
|
for (let ref18 = gatherRecursive(parameters, ($14) => $14.type === "Parameter"), i9 = 0, len8 = ref18.length; i9 < len8; i9++) {
|
|
@@ -2957,6 +3007,13 @@ ${js}`
|
|
|
2957
3007
|
type: "SemicolonDelimiter",
|
|
2958
3008
|
children: [";"]
|
|
2959
3009
|
}, prefix = [];
|
|
3010
|
+
subbindings.length && prefix.push(makeNode({
|
|
3011
|
+
type: "Declaration",
|
|
3012
|
+
children: ["const ", subbindings.slice(1)],
|
|
3013
|
+
names: subbindings.flatMap(($16) => $16.names ?? []),
|
|
3014
|
+
bindings: [],
|
|
3015
|
+
decl: "const"
|
|
3016
|
+
}));
|
|
2960
3017
|
for (let ref20 = splices, i11 = 0, len10 = ref20.length; i11 < len10; i11++) {
|
|
2961
3018
|
let binding = ref20[i11];
|
|
2962
3019
|
assert.equal(binding.type, "PostRestBindingElements", "splice should be of type Binding"), prefix.push(makeNode({
|
|
@@ -2996,7 +3053,7 @@ ${js}`
|
|
|
2996
3053
|
if (f.async != null)
|
|
2997
3054
|
f.async.push("async "), signature.modifier.async = !0;
|
|
2998
3055
|
else
|
|
2999
|
-
for (let ref21 = gatherRecursiveWithinFunction(block, ($
|
|
3056
|
+
for (let ref21 = gatherRecursiveWithinFunction(block, ($17) => $17.type === "Await"), i12 = 0, len11 = ref21.length; i12 < len11; i12++) {
|
|
3000
3057
|
let a = ref21[i12], i = findChildIndex(a.parent, a);
|
|
3001
3058
|
a.parent.children.splice(i + 1, 0, {
|
|
3002
3059
|
type: "Error",
|
|
@@ -3007,8 +3064,8 @@ ${js}`
|
|
|
3007
3064
|
if (f.generator != null)
|
|
3008
3065
|
f.generator.push("*"), signature.modifier.generator = !0;
|
|
3009
3066
|
else
|
|
3010
|
-
for (let ref22 = gatherRecursiveWithinFunction(block, ($
|
|
3011
|
-
let y = ref22[i13], i = y.children.findIndex(($
|
|
3067
|
+
for (let ref22 = gatherRecursiveWithinFunction(block, ($18) => $18.type === "YieldExpression"), i13 = 0, len12 = ref22.length; i13 < len12; i13++) {
|
|
3068
|
+
let y = ref22[i13], i = y.children.findIndex(($19) => $19.type === "Yield");
|
|
3012
3069
|
y.children.splice(i + 1, 0, {
|
|
3013
3070
|
type: "Error",
|
|
3014
3071
|
message: `yield invalid in ${f.type === "ArrowFunction" ? "=> arrow function" : signature.modifier.get ? "getter" : signature.modifier.set ? "setter" : signature.name}`
|
|
@@ -3017,7 +3074,7 @@ ${js}`
|
|
|
3017
3074
|
signature.modifier.async && !signature.modifier.generator && signature.returnType && !isPromiseType(signature.returnType.t) && replaceNode(signature.returnType.t, wrapTypeInPromise(signature.returnType.t));
|
|
3018
3075
|
}
|
|
3019
3076
|
function processFunctions(statements, config2) {
|
|
3020
|
-
for (let ref23 = gatherRecursiveAll(statements, ($
|
|
3077
|
+
for (let ref23 = gatherRecursiveAll(statements, ($20) => $20.type === "FunctionExpression" || $20.type === "ArrowFunction" || $20.type === "MethodDefinition"), i14 = 0, len13 = ref23.length; i14 < len13; i14++) {
|
|
3021
3078
|
let f = ref23[i14];
|
|
3022
3079
|
(f.type === "FunctionExpression" || f.type === "MethodDefinition") && implicitFunctionBlock(f), processSignature(f), processParams(f), processReturn(f, config2.implicitReturns);
|
|
3023
3080
|
}
|
|
@@ -3064,7 +3121,7 @@ ${js}`
|
|
|
3064
3121
|
done || (generator || (statements[statements.length - 1][1] = wrapWithReturn(statements[statements.length - 1][1])), children.splice(i, 1, wrapIIFE(statements, async, generator)), updateParentPointers(exp));
|
|
3065
3122
|
}
|
|
3066
3123
|
function processIterationExpressions(statements) {
|
|
3067
|
-
for (let ref25 = gatherRecursiveAll(statements, ($
|
|
3124
|
+
for (let ref25 = gatherRecursiveAll(statements, ($21) => $21.type === "IterationExpression"), i15 = 0, len14 = ref25.length; i15 < len14; i15++) {
|
|
3068
3125
|
let s = ref25[i15];
|
|
3069
3126
|
expressionizeIteration(s);
|
|
3070
3127
|
}
|
|
@@ -3102,12 +3159,12 @@ ${js}`
|
|
|
3102
3159
|
let newParameterList = results1, newParameters = {
|
|
3103
3160
|
...parameters,
|
|
3104
3161
|
parameters: newParameterList,
|
|
3105
|
-
children: parameters.children.map(($
|
|
3162
|
+
children: parameters.children.map(($22) => $22 === parameterList ? newParameterList : $22)
|
|
3106
3163
|
};
|
|
3107
3164
|
expression = {
|
|
3108
3165
|
...expression,
|
|
3109
3166
|
parameters: newParameters,
|
|
3110
|
-
children: expression.children.map(($
|
|
3167
|
+
children: expression.children.map(($23) => $23 === parameters ? newParameters : $23)
|
|
3111
3168
|
};
|
|
3112
3169
|
}
|
|
3113
3170
|
return {
|
|
@@ -3125,7 +3182,7 @@ ${js}`
|
|
|
3125
3182
|
}
|
|
3126
3183
|
function makeAmpersandFunction(rhs) {
|
|
3127
3184
|
let { ref, typeSuffix, body } = rhs;
|
|
3128
|
-
ref == null && (ref = makeRef("$"), inplacePrepend(ref, body)), startsWithPredicate(body, ($
|
|
3185
|
+
ref == null && (ref = makeRef("$"), inplacePrepend(ref, body)), startsWithPredicate(body, ($24) => $24.type === "ObjectExpression") && (body = makeLeftHandSideExpression(body));
|
|
3129
3186
|
let parameterList = [
|
|
3130
3187
|
typeSuffix ? [ref, typeSuffix] : ref
|
|
3131
3188
|
], parameters = makeNode({
|
|
@@ -3642,14 +3699,12 @@ ${js}`
|
|
|
3642
3699
|
break;
|
|
3643
3700
|
}
|
|
3644
3701
|
case "ConditionFragment": {
|
|
3645
|
-
let {
|
|
3646
|
-
if (
|
|
3647
|
-
let [first, ...rest] =
|
|
3648
|
-
ws = [" "].concat(ws), first = [ws, ...op],
|
|
3702
|
+
let { rhs } = pattern;
|
|
3703
|
+
if (rhs.length) {
|
|
3704
|
+
let [first, ...rest] = rhs, [ws, ...op] = first;
|
|
3705
|
+
ws = [" "].concat(ws), first = [ws, ...op], rhs = [first, ...rest];
|
|
3649
3706
|
}
|
|
3650
|
-
conditions.push(
|
|
3651
|
-
processBinaryOpExpression([ref, children])
|
|
3652
|
-
);
|
|
3707
|
+
conditions.push(processBinaryOpExpression([ref, rhs]));
|
|
3653
3708
|
break;
|
|
3654
3709
|
}
|
|
3655
3710
|
case "RegularExpressionLiteral": {
|
|
@@ -3667,6 +3722,10 @@ ${js}`
|
|
|
3667
3722
|
]);
|
|
3668
3723
|
break;
|
|
3669
3724
|
}
|
|
3725
|
+
case "NamedBindingPattern": {
|
|
3726
|
+
getPatternConditions(pattern.pattern, ref, conditions);
|
|
3727
|
+
break;
|
|
3728
|
+
}
|
|
3670
3729
|
case "Literal": {
|
|
3671
3730
|
conditions.push([
|
|
3672
3731
|
ref,
|
|
@@ -3693,37 +3752,38 @@ ${js}`
|
|
|
3693
3752
|
case "Literal":
|
|
3694
3753
|
case "RegularExpressionLiteral":
|
|
3695
3754
|
case "PinPattern":
|
|
3696
|
-
case "ConditionFragment":
|
|
3697
3755
|
return;
|
|
3756
|
+
case "ConditionFragment": {
|
|
3757
|
+
if (!pattern.binding)
|
|
3758
|
+
return;
|
|
3759
|
+
break;
|
|
3760
|
+
}
|
|
3698
3761
|
}
|
|
3699
|
-
let [splices, thisAssignments] = gatherBindingCode(pattern), patternBindings2 = nonMatcherBindings(pattern),
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
splices = splices.map((s) => [", ", nonMatcherBindings(s)]), thisAssignments = thisAssignments.map(($8) => ["", $8, ";"]);
|
|
3706
|
-
let duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices]);
|
|
3707
|
-
return [
|
|
3708
|
-
["", {
|
|
3762
|
+
let [splices, thisAssignments] = gatherBindingCode(pattern), patternBindings2 = nonMatcherBindings(pattern), subbindings = gatherSubbindings(patternBindings2);
|
|
3763
|
+
simplifyBindingProperties(patternBindings2), simplifyBindingProperties(subbindings), splices = splices.flatMap((s) => [", ", nonMatcherBindings(s)]), thisAssignments = thisAssignments.map(($7) => ["", $7, ";"]);
|
|
3764
|
+
let duplicateDeclarations = aggregateDuplicateBindings([patternBindings2, splices, subbindings]), blockPrefix = [];
|
|
3765
|
+
if (ref || subbindings.length || splices.length) {
|
|
3766
|
+
let children = [decl];
|
|
3767
|
+
ref && children.push(patternBindings2, typeSuffix, " = ", ref), children.push(...subbindings), children.push(...splices), ref || children.splice(1, 1), blockPrefix.push(["", {
|
|
3709
3768
|
type: "Declaration",
|
|
3710
|
-
children
|
|
3769
|
+
children,
|
|
3770
|
+
decl,
|
|
3711
3771
|
names: [],
|
|
3712
3772
|
bindings: []
|
|
3713
3773
|
// avoid implicit return of any bindings
|
|
3714
|
-
}, ";"]
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3774
|
+
}, ";"]);
|
|
3775
|
+
}
|
|
3776
|
+
if (blockPrefix.push(...thisAssignments), blockPrefix.push(...duplicateDeclarations.map(($8) => ["", $8, ";"])), !!blockPrefix.length)
|
|
3777
|
+
return blockPrefix;
|
|
3718
3778
|
}
|
|
3719
3779
|
function elideMatchersFromArrayBindings(elements) {
|
|
3720
|
-
let
|
|
3721
|
-
for (let
|
|
3722
|
-
let element = elements[
|
|
3780
|
+
let results = [];
|
|
3781
|
+
for (let i5 = 0, len4 = elements.length; i5 < len4; i5++) {
|
|
3782
|
+
let element = elements[i5];
|
|
3723
3783
|
switch (element.type) {
|
|
3724
3784
|
case "BindingRestElement":
|
|
3725
3785
|
case "ElisionElement": {
|
|
3726
|
-
|
|
3786
|
+
results.push(element);
|
|
3727
3787
|
break;
|
|
3728
3788
|
}
|
|
3729
3789
|
case "BindingElement": {
|
|
@@ -3732,12 +3792,12 @@ ${js}`
|
|
|
3732
3792
|
case "RegularExpressionLiteral":
|
|
3733
3793
|
case "StringLiteral":
|
|
3734
3794
|
case "PinPattern": {
|
|
3735
|
-
|
|
3795
|
+
results.push(element.delim);
|
|
3736
3796
|
break;
|
|
3737
3797
|
}
|
|
3738
3798
|
default: {
|
|
3739
3799
|
let binding = nonMatcherBindings(element.binding);
|
|
3740
|
-
|
|
3800
|
+
results.push(makeNode({
|
|
3741
3801
|
...element,
|
|
3742
3802
|
binding,
|
|
3743
3803
|
children: element.children.map((c) => c === element.binding ? binding : c)
|
|
@@ -3748,26 +3808,20 @@ ${js}`
|
|
|
3748
3808
|
}
|
|
3749
3809
|
}
|
|
3750
3810
|
}
|
|
3751
|
-
return
|
|
3811
|
+
return results;
|
|
3752
3812
|
}
|
|
3753
3813
|
function elideMatchersFromPropertyBindings(properties) {
|
|
3754
|
-
let
|
|
3755
|
-
for (let
|
|
3756
|
-
let p = properties[
|
|
3814
|
+
let results1 = [];
|
|
3815
|
+
for (let i6 = 0, len5 = properties.length; i6 < len5; i6++) {
|
|
3816
|
+
let p = properties[i6];
|
|
3757
3817
|
switch (p.type) {
|
|
3758
3818
|
case "BindingProperty":
|
|
3759
3819
|
case "PinProperty": {
|
|
3760
|
-
let { children, name, value
|
|
3820
|
+
let { children, name, value } = p, [ws] = children;
|
|
3761
3821
|
if (name.type === "NumericLiteral" && !value?.name || name.type === "ComputedPropertyName" && value?.subtype === "NumericLiteral")
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
message: `Cannot bind ${name.type}`
|
|
3766
|
-
});
|
|
3767
|
-
else
|
|
3768
|
-
continue;
|
|
3769
|
-
else {
|
|
3770
|
-
let contents;
|
|
3822
|
+
continue;
|
|
3823
|
+
{
|
|
3824
|
+
let contents, m1;
|
|
3771
3825
|
switch (value?.type) {
|
|
3772
3826
|
case "ArrayBindingPattern":
|
|
3773
3827
|
case "ObjectBindingPattern": {
|
|
@@ -3784,33 +3838,36 @@ ${js}`
|
|
|
3784
3838
|
contents = p;
|
|
3785
3839
|
break;
|
|
3786
3840
|
}
|
|
3841
|
+
case "NamedBindingPattern": {
|
|
3842
|
+
let bindings = nonMatcherBindings(value.pattern);
|
|
3843
|
+
contents = {
|
|
3844
|
+
...p,
|
|
3845
|
+
subbinding: (m1 = bindings?.type, m1 === "ArrayBindingPattern" || m1 === "ObjectBindingPattern" || m1 === "Identifier" ? [
|
|
3846
|
+
bindings,
|
|
3847
|
+
" = ",
|
|
3848
|
+
name
|
|
3849
|
+
] : void 0)
|
|
3850
|
+
}, p.name === value.binding && (contents.children = [ws, name, p.delim]);
|
|
3851
|
+
break;
|
|
3852
|
+
}
|
|
3787
3853
|
default:
|
|
3788
3854
|
contents = void 0;
|
|
3789
3855
|
}
|
|
3790
|
-
if (
|
|
3791
|
-
|
|
3792
|
-
...p,
|
|
3793
|
-
children: [ws, name, p.delim],
|
|
3794
|
-
subbinding: contents?.value ? [
|
|
3795
|
-
contents.value,
|
|
3796
|
-
" = ",
|
|
3797
|
-
name
|
|
3798
|
-
] : void 0
|
|
3799
|
-
});
|
|
3800
|
-
else if (contents)
|
|
3801
|
-
results2.push(contents);
|
|
3856
|
+
if (contents)
|
|
3857
|
+
results1.push(contents);
|
|
3802
3858
|
else
|
|
3803
3859
|
continue;
|
|
3804
3860
|
}
|
|
3805
3861
|
break;
|
|
3806
3862
|
}
|
|
3807
3863
|
default:
|
|
3808
|
-
|
|
3864
|
+
results1.push(p);
|
|
3809
3865
|
}
|
|
3810
3866
|
}
|
|
3811
|
-
return
|
|
3867
|
+
return results1;
|
|
3812
3868
|
}
|
|
3813
3869
|
function nonMatcherBindings(pattern) {
|
|
3870
|
+
let m2;
|
|
3814
3871
|
switch (pattern.type) {
|
|
3815
3872
|
case "ArrayBindingPattern":
|
|
3816
3873
|
case "PostRestBindingElements": {
|
|
@@ -3818,7 +3875,7 @@ ${js}`
|
|
|
3818
3875
|
return makeNode({
|
|
3819
3876
|
...pattern,
|
|
3820
3877
|
elements,
|
|
3821
|
-
children: pattern.children.map(($
|
|
3878
|
+
children: pattern.children.map(($9) => $9 === pattern.elements ? elements : $9)
|
|
3822
3879
|
});
|
|
3823
3880
|
}
|
|
3824
3881
|
case "ObjectBindingPattern": {
|
|
@@ -3826,9 +3883,18 @@ ${js}`
|
|
|
3826
3883
|
return makeNode({
|
|
3827
3884
|
...pattern,
|
|
3828
3885
|
properties,
|
|
3829
|
-
children: pattern.children.map(($
|
|
3886
|
+
children: pattern.children.map(($10) => $10 === pattern.properties ? properties : $10)
|
|
3887
|
+
});
|
|
3888
|
+
}
|
|
3889
|
+
case "NamedBindingPattern": {
|
|
3890
|
+
let bindings = nonMatcherBindings(pattern.pattern);
|
|
3891
|
+
return makeNode({
|
|
3892
|
+
...pattern,
|
|
3893
|
+
subbinding: (m2 = bindings?.type, m2 === "ArrayBindingPattern" || m2 === "ObjectBindingPattern" || m2 === "Identifier" ? [bindings, " = ", pattern.binding] : void 0)
|
|
3830
3894
|
});
|
|
3831
3895
|
}
|
|
3896
|
+
case "ConditionFragment":
|
|
3897
|
+
return pattern.binding;
|
|
3832
3898
|
default:
|
|
3833
3899
|
return pattern;
|
|
3834
3900
|
}
|
|
@@ -3841,9 +3907,9 @@ ${js}`
|
|
|
3841
3907
|
//$.type is "BindingRestProperty"
|
|
3842
3908
|
$.type === "Identifier" && $.parent?.type === "BindingElement" || $.type === "BindingRestElement"
|
|
3843
3909
|
), declarations = [], propsGroupedByName = /* @__PURE__ */ new Map();
|
|
3844
|
-
for (let
|
|
3845
|
-
let p = props[
|
|
3846
|
-
if (
|
|
3910
|
+
for (let i7 = 0, len6 = props.length; i7 < len6; i7++) {
|
|
3911
|
+
let p = props[i7], { name, value } = p, m3;
|
|
3912
|
+
if (m3 = value?.type, m3 === "ArrayBindingPattern" || m3 === "ObjectBindingPattern")
|
|
3847
3913
|
continue;
|
|
3848
3914
|
let key = value?.name || name?.name || name;
|
|
3849
3915
|
key?.type === "NumericLiteral" || key?.type === "ComputedPropertyName" || (propsGroupedByName.has(key) ? propsGroupedByName.get(key).push(p) : propsGroupedByName.set(key, [p]));
|
|
@@ -3856,8 +3922,8 @@ ${js}`
|
|
|
3856
3922
|
pos: 0,
|
|
3857
3923
|
input: key
|
|
3858
3924
|
})) {
|
|
3859
|
-
for (let
|
|
3860
|
-
let p = shared[
|
|
3925
|
+
for (let i8 = 0, len7 = shared.length; i8 < len7; i8++) {
|
|
3926
|
+
let p = shared[i8];
|
|
3861
3927
|
aliasBinding(p, makeRef(`_${key}`, key));
|
|
3862
3928
|
}
|
|
3863
3929
|
return;
|
|
@@ -3938,9 +4004,13 @@ ${js}`
|
|
|
3938
4004
|
function processDeclarations(statements) {
|
|
3939
4005
|
for (let ref1 = gatherRecursiveAll(statements, ($) => $.type === "Declaration"), i1 = 0, len1 = ref1.length; i1 < len1; i1++) {
|
|
3940
4006
|
let declaration = ref1[i1], { bindings } = declaration;
|
|
3941
|
-
if (bindings != null)
|
|
3942
|
-
for (let i2 =
|
|
3943
|
-
let binding = bindings[i2],
|
|
4007
|
+
if (bindings != null) {
|
|
4008
|
+
for (let i2 = bindings.length + -1; i2 >= 0; --i2) {
|
|
4009
|
+
let binding = bindings[i2], subbindings = gatherSubbindings(binding);
|
|
4010
|
+
subbindings.length && (simplifyBindingProperties(binding), simplifyBindingProperties(subbindings), spliceChild(declaration, binding, 1, binding, subbindings));
|
|
4011
|
+
}
|
|
4012
|
+
for (let i3 = 0, len22 = bindings.length; i3 < len22; i3++) {
|
|
4013
|
+
let binding = bindings[i3], { typeSuffix, initializer } = binding;
|
|
3944
4014
|
if (typeSuffix && typeSuffix.optional) {
|
|
3945
4015
|
if (initializer && !typeSuffix.t) {
|
|
3946
4016
|
let expression = trimFirstSpace(initializer.expression), m;
|
|
@@ -3968,6 +4038,19 @@ ${js}`
|
|
|
3968
4038
|
}
|
|
3969
4039
|
initializer && prependStatementExpressionBlock(initializer, declaration);
|
|
3970
4040
|
}
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
for (let ref2 = gatherRecursiveAll(statements, ($1) => $1.type === "ForStatement"), i4 = 0, len3 = ref2.length; i4 < len3; i4++) {
|
|
4044
|
+
let statement = ref2[i4], { declaration } = statement;
|
|
4045
|
+
if (declaration?.type !== "ForDeclaration")
|
|
4046
|
+
continue;
|
|
4047
|
+
let { binding } = declaration, blockPrefix = getPatternBlockPrefix(
|
|
4048
|
+
binding.pattern,
|
|
4049
|
+
void 0,
|
|
4050
|
+
append(declaration.decl, " "),
|
|
4051
|
+
binding.typeSuffix
|
|
4052
|
+
);
|
|
4053
|
+
simplifyBindingProperties(binding), blockPrefix != null && (statement.block.expressions.unshift(...blockPrefix), braceBlock(statement.block));
|
|
3971
4054
|
}
|
|
3972
4055
|
}
|
|
3973
4056
|
function prependStatementExpressionBlock(initializer, statement) {
|
|
@@ -4068,7 +4151,7 @@ ${js}`
|
|
|
4068
4151
|
return;
|
|
4069
4152
|
let { expression } = condition;
|
|
4070
4153
|
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]) {
|
|
4071
|
-
let {
|
|
4154
|
+
let { children: [[], { expression: expression2 }] } = expression;
|
|
4072
4155
|
expression = expression2;
|
|
4073
4156
|
}
|
|
4074
4157
|
processDeclarationCondition(expression, condition.expression, s);
|
|
@@ -4090,8 +4173,8 @@ ${js}`
|
|
|
4090
4173
|
({ children } = condition.expression.children[1]);
|
|
4091
4174
|
}
|
|
4092
4175
|
children.unshift("(");
|
|
4093
|
-
for (let
|
|
4094
|
-
let c = conditions[
|
|
4176
|
+
for (let i5 = 0, len4 = conditions.length; i5 < len4; i5++) {
|
|
4177
|
+
let c = conditions[i5];
|
|
4095
4178
|
children.push(" && ", c);
|
|
4096
4179
|
}
|
|
4097
4180
|
children.push(")");
|
|
@@ -4109,11 +4192,11 @@ ${js}`
|
|
|
4109
4192
|
if (index < 0)
|
|
4110
4193
|
throw new Error("Couldn't find where in block to put postfix declaration");
|
|
4111
4194
|
ancestor.expressions.splice(index + 1, 0, ...blockPrefix), updateParentPointers(ancestor), braceBlock(ancestor);
|
|
4112
|
-
let
|
|
4195
|
+
let ref3;
|
|
4113
4196
|
switch (s.type) {
|
|
4114
4197
|
case "IfStatement": {
|
|
4115
|
-
if (
|
|
4116
|
-
let elseBlock =
|
|
4198
|
+
if (ref3 = s.else?.block) {
|
|
4199
|
+
let elseBlock = ref3;
|
|
4117
4200
|
elseBlock.bare && !elseBlock.semicolon && elseBlock.children.push(elseBlock.semicolon = ";"), ancestor.expressions.splice(index + 1 + blockPrefix.length, 0, ["", elseBlock]), s.children = s.children.filter((a1) => a1 !== s.else), s.else = void 0;
|
|
4118
4201
|
}
|
|
4119
4202
|
let block = s.then;
|
|
@@ -4129,11 +4212,11 @@ ${js}`
|
|
|
4129
4212
|
if (s.negated) {
|
|
4130
4213
|
if (e != null) {
|
|
4131
4214
|
let block = blockWithPrefix(blockPrefix, e.block);
|
|
4132
|
-
e.children = e.children.map(($
|
|
4215
|
+
e.children = e.children.map(($2) => $2 === e.block ? block : $2), e.block = block, updateParentPointers(e);
|
|
4133
4216
|
}
|
|
4134
4217
|
} else {
|
|
4135
4218
|
let block = blockWithPrefix(blockPrefix, s.then);
|
|
4136
|
-
s.children = s.children.map(($
|
|
4219
|
+
s.children = s.children.map(($3) => $3 === s.then ? block : $3), s.then = block, updateParentPointers(s);
|
|
4137
4220
|
}
|
|
4138
4221
|
break;
|
|
4139
4222
|
}
|
|
@@ -4141,7 +4224,7 @@ ${js}`
|
|
|
4141
4224
|
if (!blockPrefix)
|
|
4142
4225
|
return;
|
|
4143
4226
|
let { children, block } = s, newBlock = blockWithPrefix(blockPrefix, block);
|
|
4144
|
-
s.children = children.map(($
|
|
4227
|
+
s.children = children.map(($4) => $4 === block ? newBlock : $4), updateParentPointers(s);
|
|
4145
4228
|
break;
|
|
4146
4229
|
}
|
|
4147
4230
|
case "SwitchStatement": {
|
|
@@ -4158,7 +4241,7 @@ ${js}`
|
|
|
4158
4241
|
return c === s.condition ? newCondition : c;
|
|
4159
4242
|
}), s.condition = newCondition, updateParentPointers(s), statementDeclaration) {
|
|
4160
4243
|
let block = makeEmptyBlock();
|
|
4161
|
-
replaceBlockExpression(s.parent, s, block), block.expressions.push(["", s]), s.children.splice(s.children.findIndex(($
|
|
4244
|
+
replaceBlockExpression(s.parent, s, block), block.expressions.push(["", s]), s.children.splice(s.children.findIndex(($5) => $5.token === "switch"), 0, blockPrefix), s.parent = block;
|
|
4162
4245
|
} else {
|
|
4163
4246
|
let block = blockWithPrefix([["", [{
|
|
4164
4247
|
type: "Declaration",
|
|
@@ -4172,17 +4255,17 @@ ${js}`
|
|
|
4172
4255
|
}
|
|
4173
4256
|
function dynamizeFromClause(from) {
|
|
4174
4257
|
from = from.slice(1), from = trimFirstSpace(from);
|
|
4175
|
-
let
|
|
4176
|
-
if (
|
|
4177
|
-
let
|
|
4178
|
-
|
|
4258
|
+
let ref4;
|
|
4259
|
+
if (ref4 = from[from.length - 1]?.assertion) {
|
|
4260
|
+
let assert2 = ref4, ref5;
|
|
4261
|
+
ref5 = from[from.length - 1], ref5.children = ref5.children.filter((a2) => a2 !== assert2), from.push(", {", assert2.keyword, ":", assert2.object, "}");
|
|
4179
4262
|
}
|
|
4180
4263
|
return ["(", ...from, ")"];
|
|
4181
4264
|
}
|
|
4182
4265
|
function dynamizeImportDeclaration(decl) {
|
|
4183
|
-
let { imports } = decl, { star, binding, specifiers } = imports, justDefault = binding && !specifiers && !star,
|
|
4184
|
-
binding ? specifiers ?
|
|
4185
|
-
let pattern =
|
|
4266
|
+
let { imports } = decl, { star, binding, specifiers } = imports, justDefault = binding && !specifiers && !star, ref6;
|
|
4267
|
+
binding ? specifiers ? ref6 = makeRef() : ref6 = binding : ref6 = convertNamedImportsToObject(imports, !0);
|
|
4268
|
+
let pattern = ref6, c = "const", expression = [
|
|
4186
4269
|
justDefault ? "(" : void 0,
|
|
4187
4270
|
{ type: "Await", children: ["await"] },
|
|
4188
4271
|
" ",
|
|
@@ -4362,7 +4445,7 @@ ${js}`
|
|
|
4362
4445
|
children: args.children.map(
|
|
4363
4446
|
(arg) => {
|
|
4364
4447
|
if (typeof arg == "object" && arg != null && "type" in arg && arg.type === "ArrayElement" && "expression" in arg && "children" in arg) {
|
|
4365
|
-
let {
|
|
4448
|
+
let { expression: exp, children } = arg, expression = processUnaryExpression([last], trimFirstSpace(exp));
|
|
4366
4449
|
return expression = prepend(getTrimmingSpace(exp), expression), {
|
|
4367
4450
|
...arg,
|
|
4368
4451
|
expression,
|
|
@@ -4430,9 +4513,8 @@ ${js}`
|
|
|
4430
4513
|
if (lhs.type === "NewExpression") {
|
|
4431
4514
|
let { expression } = lhs;
|
|
4432
4515
|
return expression = {
|
|
4433
|
-
...expression,
|
|
4434
4516
|
type: "CallExpression",
|
|
4435
|
-
children: [
|
|
4517
|
+
children: [expression, call]
|
|
4436
4518
|
}, {
|
|
4437
4519
|
...lhs,
|
|
4438
4520
|
expression,
|
|
@@ -4478,13 +4560,13 @@ ${js}`
|
|
|
4478
4560
|
];
|
|
4479
4561
|
}
|
|
4480
4562
|
function processPipelineExpressions(statements) {
|
|
4481
|
-
gatherRecursiveAll(statements, (
|
|
4482
|
-
let [ws, , body] = s.children, [, arg] = s.children,
|
|
4483
|
-
for (let
|
|
4484
|
-
let
|
|
4563
|
+
for (let ref1 = gatherRecursiveAll(statements, ($1) => $1.type === "PipelineExpression"), i1 = 0, len3 = ref1.length; i1 < len3; i1++) {
|
|
4564
|
+
let s = ref1[i1], [ws, , body] = s.children, [, arg] = s.children, children = [ws], comma = blockContainingStatement(s) ? ";" : ",", usingRef = null;
|
|
4565
|
+
for (let i2 = 0, len1 = body.length; i2 < len1; i2++) {
|
|
4566
|
+
let i = i2, step = body[i2], [leadingComment, pipe, trailingComment, expr] = step, returns = pipe.token === "||>", ref, result, returning = returns ? arg : null;
|
|
4485
4567
|
if (pipe.token === "|>=") {
|
|
4486
4568
|
let initRef;
|
|
4487
|
-
if (
|
|
4569
|
+
if (i === 0) {
|
|
4488
4570
|
switch (checkValidLHS(arg), arg.type) {
|
|
4489
4571
|
case "MemberExpression":
|
|
4490
4572
|
if (arg.children.length <= 2)
|
|
@@ -4522,7 +4604,7 @@ ${js}`
|
|
|
4522
4604
|
message: "Can't use |>= in the middle of a pipeline"
|
|
4523
4605
|
});
|
|
4524
4606
|
} else
|
|
4525
|
-
|
|
4607
|
+
i === 0 && (s.children = children);
|
|
4526
4608
|
if (returns && (ref = needsRef(arg)) && (usingRef = usingRef || ref, arg = {
|
|
4527
4609
|
type: "ParenthesizedExpression",
|
|
4528
4610
|
children: ["(", {
|
|
@@ -4538,7 +4620,7 @@ ${js}`
|
|
|
4538
4620
|
arg,
|
|
4539
4621
|
returning
|
|
4540
4622
|
), result.type === "ReturnStatement") {
|
|
4541
|
-
|
|
4623
|
+
i < body.length - 1 && result.children.push({
|
|
4542
4624
|
type: "Error",
|
|
4543
4625
|
message: "Can't continue a pipeline after returning"
|
|
4544
4626
|
}), arg = result, children[children.length - 1] === "," && (children.pop(), children.push(";"));
|
|
@@ -4550,22 +4632,22 @@ ${js}`
|
|
|
4550
4632
|
type: "Declaration",
|
|
4551
4633
|
children: ["let ", usingRef],
|
|
4552
4634
|
names: []
|
|
4553
|
-
}), children.push(arg), !children.some(($
|
|
4635
|
+
}), children.push(arg), !children.some(($2) => $2?.type === "ReturnStatement") && children.some(($3) => $3 === ",")) {
|
|
4554
4636
|
let { parent } = s, parenthesizedExpression = makeLeftHandSideExpression({ ...s });
|
|
4555
4637
|
Object.assign(s, parenthesizedExpression, {
|
|
4556
4638
|
parent,
|
|
4557
4639
|
hoistDec: void 0
|
|
4558
4640
|
});
|
|
4559
4641
|
}
|
|
4560
|
-
|
|
4561
|
-
}
|
|
4642
|
+
addParentPointers(s, s.parent);
|
|
4643
|
+
}
|
|
4562
4644
|
}
|
|
4563
4645
|
|
|
4564
4646
|
// unplugin-civet:C:\Users\edemaine\Projects\Civet\source\parser\for.civet.jsx
|
|
4565
|
-
function processRangeExpression(start, ws1,
|
|
4566
|
-
ws1 = [ws1,
|
|
4567
|
-
let ws2 =
|
|
4568
|
-
switch (
|
|
4647
|
+
function processRangeExpression(start, ws1, range2, end) {
|
|
4648
|
+
ws1 = [ws1, range2.children[0]];
|
|
4649
|
+
let ws2 = range2.children[1], comma = { $loc: range2.$loc, token: "," }, ref;
|
|
4650
|
+
switch (range2.increasing) {
|
|
4569
4651
|
case !0: {
|
|
4570
4652
|
ref = ($) => $;
|
|
4571
4653
|
break;
|
|
@@ -4577,14 +4659,14 @@ ${js}`
|
|
|
4577
4659
|
default:
|
|
4578
4660
|
ref = Math.abs;
|
|
4579
4661
|
}
|
|
4580
|
-
let abs = ref, lengthAdjust = 1 - +!
|
|
4662
|
+
let abs = ref, lengthAdjust = 1 - +!range2.left.inclusive - +!range2.right.inclusive, children;
|
|
4581
4663
|
if (typeof start == "object" && start != null && "type" in start && start.type === "Literal" && typeof end == "object" && end != null && "type" in end && end.type === "Literal") {
|
|
4582
4664
|
let startValue = literalValue(start), endValue = literalValue(end);
|
|
4583
4665
|
if (typeof startValue == "string" && typeof endValue == "string") {
|
|
4584
4666
|
if (!(startValue.length === 1 && endValue.length === 1))
|
|
4585
4667
|
throw new Error("String range start and end must be a single character");
|
|
4586
4668
|
let startCode = startValue.charCodeAt(0), endCode = endValue.charCodeAt(0), step = startCode <= endCode ? 1 : -1, length = abs(endCode - startCode) + lengthAdjust;
|
|
4587
|
-
|
|
4669
|
+
range2.left.inclusive || (startCode += step), length <= 26 ? children = [
|
|
4588
4670
|
"[",
|
|
4589
4671
|
Array.from({ length }, (_2, i) => JSON.stringify(String.fromCharCode(startCode + i * step))).join(", "),
|
|
4590
4672
|
"]"
|
|
@@ -4595,25 +4677,25 @@ ${js}`
|
|
|
4595
4677
|
", ",
|
|
4596
4678
|
length.toString(),
|
|
4597
4679
|
")"
|
|
4598
|
-
],
|
|
4680
|
+
], range2.error != null && children.unshift(range2.error);
|
|
4599
4681
|
} else if (typeof startValue == "number" && typeof endValue == "number") {
|
|
4600
4682
|
let step = startValue <= endValue ? 1 : -1, length = abs(endValue - startValue) + lengthAdjust;
|
|
4601
|
-
|
|
4683
|
+
range2.left.inclusive || (startValue += step), length <= 20 && (children = [
|
|
4602
4684
|
"[",
|
|
4603
4685
|
Array.from({ length }, (_2, i) => startValue + i * step).join(", "),
|
|
4604
4686
|
"]"
|
|
4605
|
-
],
|
|
4687
|
+
], range2.error != null && children.unshift(range2.error));
|
|
4606
4688
|
}
|
|
4607
4689
|
}
|
|
4608
4690
|
if (children == null)
|
|
4609
|
-
if (
|
|
4610
|
-
let sign =
|
|
4691
|
+
if (range2.increasing != null) {
|
|
4692
|
+
let sign = range2.increasing ? "+" : "-";
|
|
4611
4693
|
end = makeLeftHandSideExpression(end), children = [
|
|
4612
|
-
getHelperRef(
|
|
4694
|
+
getHelperRef(range2.increasing ? "range" : "revRange"),
|
|
4613
4695
|
"(",
|
|
4614
|
-
|
|
4696
|
+
range2.left.inclusive ? start : [makeLeftHandSideExpression(start), ` ${sign} 1`],
|
|
4615
4697
|
",",
|
|
4616
|
-
|
|
4698
|
+
range2.right.inclusive ? [makeLeftHandSideExpression(end), ` ${sign} 1`] : end,
|
|
4617
4699
|
...ws1,
|
|
4618
4700
|
")"
|
|
4619
4701
|
];
|
|
@@ -4622,11 +4704,11 @@ ${js}`
|
|
|
4622
4704
|
"((s, e) => s > e ? ",
|
|
4623
4705
|
getHelperRef("revRange"),
|
|
4624
4706
|
"(s, e",
|
|
4625
|
-
|
|
4707
|
+
range2.right.inclusive ? " - 1" : void 0,
|
|
4626
4708
|
") : ",
|
|
4627
4709
|
getHelperRef("range"),
|
|
4628
4710
|
"(s, e",
|
|
4629
|
-
|
|
4711
|
+
range2.right.inclusive ? " + 1" : void 0,
|
|
4630
4712
|
"))",
|
|
4631
4713
|
"(",
|
|
4632
4714
|
start,
|
|
@@ -4641,14 +4723,14 @@ ${js}`
|
|
|
4641
4723
|
children,
|
|
4642
4724
|
start,
|
|
4643
4725
|
end,
|
|
4644
|
-
error:
|
|
4645
|
-
left:
|
|
4646
|
-
right:
|
|
4647
|
-
increasing:
|
|
4726
|
+
error: range2.error,
|
|
4727
|
+
left: range2.left,
|
|
4728
|
+
right: range2.right,
|
|
4729
|
+
increasing: range2.increasing
|
|
4648
4730
|
};
|
|
4649
4731
|
}
|
|
4650
|
-
function forRange(open, forDeclaration,
|
|
4651
|
-
let { start, end, left, right, increasing } =
|
|
4732
|
+
function forRange(open, forDeclaration, range2, stepExp, close) {
|
|
4733
|
+
let { start, end, left, right, increasing } = range2, counterRef = makeRef("i"), infinite = typeof end == "object" && end != null && "type" in end && end.type === "Identifier" && "name" in end && end.name === "Infinity", stepRef, asc;
|
|
4652
4734
|
stepExp ? (stepExp = trimFirstSpace(stepExp), stepRef = maybeRef(stepExp, "step")) : infinite ? stepExp = stepRef = makeNumericLiteral(1) : increasing != null && (increasing ? (stepExp = stepRef = makeNumericLiteral(1), asc = !0) : (stepExp = stepRef = makeNumericLiteral(-1), asc = !1));
|
|
4653
4735
|
let ref1;
|
|
4654
4736
|
if (stepExp?.type === "Literal")
|
|
@@ -4704,7 +4786,7 @@ ${js}`
|
|
|
4704
4786
|
// This declaration doesn't always appear in the output,
|
|
4705
4787
|
// but it's still helpful for determining the primary loop variable
|
|
4706
4788
|
declaration: forDeclaration,
|
|
4707
|
-
children: [
|
|
4789
|
+
children: [range2.error, open, declaration, "; ", ...condition, "; ", ...increment, close],
|
|
4708
4790
|
blockPrefix
|
|
4709
4791
|
};
|
|
4710
4792
|
}
|
|
@@ -4749,6 +4831,7 @@ ${js}`
|
|
|
4749
4831
|
return declaration = {
|
|
4750
4832
|
type: "Declaration",
|
|
4751
4833
|
children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", trimFirstSpace(expRef2), ".length"],
|
|
4834
|
+
decl: "let",
|
|
4752
4835
|
names: []
|
|
4753
4836
|
}, { declaration, eachDeclaration, children: [open, declaration, "; ", [counterRef, " < ", lenRef, "; "], counterRef, increment, close], blockPrefix };
|
|
4754
4837
|
} else
|
|
@@ -4762,7 +4845,7 @@ ${js}`
|
|
|
4762
4845
|
message: "'own' is only meaningful in for..in loops"
|
|
4763
4846
|
});
|
|
4764
4847
|
let { binding } = declaration, pattern = binding?.pattern;
|
|
4765
|
-
if (binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
|
|
4848
|
+
if (pattern?.type === "NamedBindingPattern" && (pattern = pattern.binding), binding?.typeSuffix || inOf.token === "in" && declaration2 && pattern.type !== "Identifier") {
|
|
4766
4849
|
let itemRef = makeRef(inOf.token === "in" ? "key" : "item");
|
|
4767
4850
|
blockPrefix.push(["", {
|
|
4768
4851
|
type: "Declaration",
|
|
@@ -4794,11 +4877,13 @@ ${js}`
|
|
|
4794
4877
|
hoistDec = {
|
|
4795
4878
|
type: "Declaration",
|
|
4796
4879
|
children: ["let ", counterRef, " = 0"],
|
|
4880
|
+
decl: "let",
|
|
4797
4881
|
names: []
|
|
4798
4882
|
}, blockPrefix.push(["", {
|
|
4799
4883
|
type: "Declaration",
|
|
4800
4884
|
children: [trimFirstSpace(ws2), decl2, " = ", counterRef, "++"],
|
|
4801
|
-
names: decl2.names
|
|
4885
|
+
names: decl2.names,
|
|
4886
|
+
decl: decl2.decl
|
|
4802
4887
|
}, ";"]);
|
|
4803
4888
|
break;
|
|
4804
4889
|
}
|
|
@@ -4807,7 +4892,8 @@ ${js}`
|
|
|
4807
4892
|
if (expRef2 !== exp && (hoistDec = {
|
|
4808
4893
|
type: "Declaration",
|
|
4809
4894
|
children: ["let ", expRef2],
|
|
4810
|
-
names: []
|
|
4895
|
+
names: [],
|
|
4896
|
+
decl: "let"
|
|
4811
4897
|
}, exp = {
|
|
4812
4898
|
type: "AssignmentExpression",
|
|
4813
4899
|
children: [" ", expRef2, " =", exp]
|
|
@@ -4815,20 +4901,57 @@ ${js}`
|
|
|
4815
4901
|
let hasPropRef = getHelperRef("hasProp");
|
|
4816
4902
|
blockPrefix.push(["", ["if (!", hasPropRef, "(", trimFirstSpace(expRef2), ", ", trimFirstSpace(pattern), ")) continue"], ";"]);
|
|
4817
4903
|
}
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4904
|
+
if (decl2) {
|
|
4905
|
+
let trimmedPattern = trimFirstSpace(pattern), expression = makeNode({
|
|
4906
|
+
type: "MemberExpression",
|
|
4907
|
+
children: [
|
|
4908
|
+
trimFirstSpace(expRef2),
|
|
4909
|
+
makeNode({
|
|
4910
|
+
type: "Index",
|
|
4911
|
+
expression: trimmedPattern,
|
|
4912
|
+
children: ["[", trimmedPattern, "]"]
|
|
4913
|
+
})
|
|
4914
|
+
]
|
|
4915
|
+
});
|
|
4916
|
+
blockPrefix.push([
|
|
4917
|
+
"",
|
|
4918
|
+
(() => {
|
|
4919
|
+
if (decl2.type === "ForDeclaration") {
|
|
4920
|
+
let { binding: binding2, children } = decl2;
|
|
4921
|
+
return binding2.children.push(binding2.initializer = makeNode({
|
|
4922
|
+
type: "Initializer",
|
|
4923
|
+
expression,
|
|
4924
|
+
children: [" = ", expression]
|
|
4925
|
+
})), makeNode({
|
|
4926
|
+
type: "Declaration",
|
|
4927
|
+
children: [
|
|
4928
|
+
trimFirstSpace(ws2),
|
|
4929
|
+
...children
|
|
4930
|
+
],
|
|
4931
|
+
bindings: [decl2.binding],
|
|
4932
|
+
decl: decl2.decl,
|
|
4933
|
+
names: decl2.names
|
|
4934
|
+
});
|
|
4935
|
+
} else
|
|
4936
|
+
return makeNode({
|
|
4937
|
+
type: "AssignmentExpression",
|
|
4938
|
+
children: [
|
|
4939
|
+
trimFirstSpace(ws2),
|
|
4940
|
+
decl2,
|
|
4941
|
+
" = ",
|
|
4942
|
+
trimFirstSpace(expRef2),
|
|
4943
|
+
"[",
|
|
4944
|
+
trimFirstSpace(pattern),
|
|
4945
|
+
"]"
|
|
4946
|
+
],
|
|
4947
|
+
names: decl2.names,
|
|
4948
|
+
lhs: decl2,
|
|
4949
|
+
assigned: decl2
|
|
4950
|
+
});
|
|
4951
|
+
})(),
|
|
4952
|
+
";"
|
|
4953
|
+
]);
|
|
4954
|
+
}
|
|
4832
4955
|
break;
|
|
4833
4956
|
}
|
|
4834
4957
|
default:
|
|
@@ -5168,7 +5291,7 @@ ${js}`
|
|
|
5168
5291
|
}, defaultClause = !1, clauses = cs.map((clause) => {
|
|
5169
5292
|
let ref1;
|
|
5170
5293
|
if ((ref1 = clause.binding?.parameter) && typeof ref1 == "object" && "type" in ref1 && ref1.type === "CatchPattern" && "patterns" in ref1) {
|
|
5171
|
-
let {
|
|
5294
|
+
let { patterns } = ref1;
|
|
5172
5295
|
return {
|
|
5173
5296
|
type: "PatternClause",
|
|
5174
5297
|
patterns,
|
|
@@ -5333,15 +5456,24 @@ ${js}`
|
|
|
5333
5456
|
let i = i2, arg = args[i2];
|
|
5334
5457
|
isComma(arg) && (arg = args[i] = deepCopy(arg), isComma(arg).token = `)${op.token}(`, commaCount++);
|
|
5335
5458
|
}
|
|
5336
|
-
if (args.length
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5459
|
+
if (args.length) {
|
|
5460
|
+
if (commaCount)
|
|
5461
|
+
children.splice(0, 2, {
|
|
5462
|
+
type: "ParenthesizedExpression",
|
|
5463
|
+
children: ["(", call.children, ")"],
|
|
5464
|
+
expression: call.children
|
|
5465
|
+
});
|
|
5466
|
+
else {
|
|
5467
|
+
let middle = call.children.slice(1, -1), ref2;
|
|
5468
|
+
children.splice(0, 2, {
|
|
5469
|
+
type: "ParenthesizedExpression",
|
|
5470
|
+
expression: middle,
|
|
5471
|
+
children: [call.children[0], middle, (ref2 = call.children)[ref2.length - 1]]
|
|
5472
|
+
});
|
|
5473
|
+
}
|
|
5474
|
+
if (children.length === 1)
|
|
5475
|
+
return children[0];
|
|
5476
|
+
}
|
|
5345
5477
|
}
|
|
5346
5478
|
for (let i3 = 0, len22 = children.length; i3 < len22; i3++) {
|
|
5347
5479
|
let i = i3, glob = children[i3];
|
|
@@ -5399,13 +5531,13 @@ ${js}`
|
|
|
5399
5531
|
usesRef: !!ref
|
|
5400
5532
|
});
|
|
5401
5533
|
}
|
|
5402
|
-
let
|
|
5534
|
+
let ref3, object = {
|
|
5403
5535
|
type: "ObjectExpression",
|
|
5404
5536
|
children: [
|
|
5405
5537
|
glob.object.children[0],
|
|
5406
5538
|
// {
|
|
5407
5539
|
...parts,
|
|
5408
|
-
(
|
|
5540
|
+
(ref3 = glob.object.children)[ref3.length - 1]
|
|
5409
5541
|
// whitespace and }
|
|
5410
5542
|
],
|
|
5411
5543
|
properties: parts
|
|
@@ -5460,7 +5592,7 @@ ${js}`
|
|
|
5460
5592
|
]
|
|
5461
5593
|
})
|
|
5462
5594
|
]
|
|
5463
|
-
}),
|
|
5595
|
+
}), ref4;
|
|
5464
5596
|
return processCallMemberExpression({
|
|
5465
5597
|
// in case there are more
|
|
5466
5598
|
...node,
|
|
@@ -5474,7 +5606,7 @@ ${js}`
|
|
|
5474
5606
|
glob.children[0],
|
|
5475
5607
|
// "[" token
|
|
5476
5608
|
call,
|
|
5477
|
-
(
|
|
5609
|
+
(ref4 = glob.children)[ref4.length - 1]
|
|
5478
5610
|
// "]" token
|
|
5479
5611
|
]
|
|
5480
5612
|
}),
|
|
@@ -5486,7 +5618,7 @@ ${js}`
|
|
|
5486
5618
|
{ ...node, children: node.children.slice(0, i) },
|
|
5487
5619
|
{ ...glob.children[0], token: ", " },
|
|
5488
5620
|
...glob.children.slice(1, -1)
|
|
5489
|
-
],
|
|
5621
|
+
], ref5, rsliceCall = makeNode({
|
|
5490
5622
|
type: "CallExpression",
|
|
5491
5623
|
implicit: !0,
|
|
5492
5624
|
children: [
|
|
@@ -5497,7 +5629,7 @@ ${js}`
|
|
|
5497
5629
|
children: [
|
|
5498
5630
|
"(",
|
|
5499
5631
|
args,
|
|
5500
|
-
(
|
|
5632
|
+
(ref5 = glob.children)[ref5.length - 1]
|
|
5501
5633
|
]
|
|
5502
5634
|
})
|
|
5503
5635
|
]
|
|
@@ -5554,7 +5686,7 @@ ${js}`
|
|
|
5554
5686
|
if (specifier.ts)
|
|
5555
5687
|
return { type: "Error", message: "cannot use `type` in dynamic import" };
|
|
5556
5688
|
{
|
|
5557
|
-
let { source, binding } = specifier,
|
|
5689
|
+
let { source, binding } = specifier, ref6, delim = (ref6 = specifier.children)[ref6.length - 1];
|
|
5558
5690
|
return {
|
|
5559
5691
|
type: pattern ? "BindingProperty" : "Property",
|
|
5560
5692
|
name: source,
|
|
@@ -5563,7 +5695,7 @@ ${js}`
|
|
|
5563
5695
|
children: source === binding ? [source, delim] : [source, ":", binding, delim]
|
|
5564
5696
|
};
|
|
5565
5697
|
}
|
|
5566
|
-
}),
|
|
5698
|
+
}), ref7;
|
|
5567
5699
|
return {
|
|
5568
5700
|
type: pattern ? "ObjectBindingPattern" : "ObjectExpression",
|
|
5569
5701
|
names: node.names,
|
|
@@ -5572,7 +5704,7 @@ ${js}`
|
|
|
5572
5704
|
node.children[0],
|
|
5573
5705
|
// {
|
|
5574
5706
|
properties,
|
|
5575
|
-
(
|
|
5707
|
+
(ref7 = node.children)[ref7.length - 1]
|
|
5576
5708
|
// }
|
|
5577
5709
|
]
|
|
5578
5710
|
};
|
|
@@ -5648,11 +5780,15 @@ ${js}`
|
|
|
5648
5780
|
}
|
|
5649
5781
|
function processBindingPatternLHS(lhs, tail) {
|
|
5650
5782
|
adjustAtBindings(lhs, !0);
|
|
5651
|
-
let [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
5652
|
-
|
|
5783
|
+
let [splices, thisAssignments] = gatherBindingCode(lhs), subbindings = gatherSubbindings(lhs);
|
|
5784
|
+
simplifyBindingProperties(lhs), simplifyBindingProperties(subbindings), tail.push(
|
|
5785
|
+
...splices.map((s) => [", ", s]),
|
|
5786
|
+
...thisAssignments.map((a) => [", ", a]),
|
|
5787
|
+
...subbindings
|
|
5788
|
+
);
|
|
5653
5789
|
}
|
|
5654
5790
|
function processAssignments(statements) {
|
|
5655
|
-
for (let
|
|
5791
|
+
for (let ref8 = gatherRecursiveAll(statements, ($4) => $4.type === "AssignmentExpression" || $4.type === "UpdateExpression"), i5 = 0, len3 = ref8.length; i5 < len3; i5++) {
|
|
5656
5792
|
let extractAssignment = function(lhs) {
|
|
5657
5793
|
let expr = lhs;
|
|
5658
5794
|
for (; expr.type === "ParenthesizedExpression"; )
|
|
@@ -5660,25 +5796,25 @@ ${js}`
|
|
|
5660
5796
|
let m1;
|
|
5661
5797
|
if (m1 = expr.type, m1 === "AssignmentExpression" || m1 === "UpdateExpression")
|
|
5662
5798
|
return expr.type === "UpdateExpression" && expr.children[0] === expr.assigned ? (pre.push("("), post.push([", ", lhs, ")"])) : (pre.push(["(", lhs, ", "]), post.push(")")), expr.assigned;
|
|
5663
|
-
}, exp =
|
|
5799
|
+
}, exp = ref8[i5];
|
|
5664
5800
|
checkValidLHS(exp.assigned);
|
|
5665
|
-
let pre = [], post = [],
|
|
5801
|
+
let pre = [], post = [], ref9;
|
|
5666
5802
|
switch (exp.type) {
|
|
5667
5803
|
case "AssignmentExpression": {
|
|
5668
5804
|
if (!exp.lhs)
|
|
5669
5805
|
continue;
|
|
5670
|
-
for (let
|
|
5671
|
-
let lhsPart =
|
|
5672
|
-
if (
|
|
5673
|
-
let newLhs =
|
|
5806
|
+
for (let ref10 = exp.lhs, i6 = 0, len4 = ref10.length; i6 < len4; i6++) {
|
|
5807
|
+
let lhsPart = ref10[i6], ref11;
|
|
5808
|
+
if (ref11 = extractAssignment(lhsPart[1])) {
|
|
5809
|
+
let newLhs = ref11;
|
|
5674
5810
|
lhsPart[1] = newLhs;
|
|
5675
5811
|
}
|
|
5676
5812
|
}
|
|
5677
5813
|
break;
|
|
5678
5814
|
}
|
|
5679
5815
|
case "UpdateExpression": {
|
|
5680
|
-
if (
|
|
5681
|
-
let newLhs =
|
|
5816
|
+
if (ref9 = extractAssignment(exp.assigned)) {
|
|
5817
|
+
let newLhs = ref9, i = exp.children.indexOf(exp.assigned);
|
|
5682
5818
|
exp.assigned = exp.children[i] = newLhs;
|
|
5683
5819
|
}
|
|
5684
5820
|
break;
|
|
@@ -5693,19 +5829,19 @@ ${js}`
|
|
|
5693
5829
|
}), replaceNode(exp, newMemberExp));
|
|
5694
5830
|
}
|
|
5695
5831
|
}
|
|
5696
|
-
for (let
|
|
5697
|
-
let exp =
|
|
5832
|
+
for (let ref12 = gatherRecursiveAll(statements, ($6) => $6.type === "AssignmentExpression"), i7 = 0, len5 = ref12.length; i7 < len5; i7++) {
|
|
5833
|
+
let exp = ref12[i7];
|
|
5698
5834
|
if (exp.names !== null)
|
|
5699
5835
|
continue;
|
|
5700
|
-
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length, block,
|
|
5701
|
-
if (blockContainingStatement(exp) && !(
|
|
5836
|
+
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length, block, ref13;
|
|
5837
|
+
if (blockContainingStatement(exp) && !(ref13 = $1[$1.length - 1])?.[ref13.length - 1]?.special) {
|
|
5702
5838
|
block = makeBlockFragment();
|
|
5703
|
-
let
|
|
5704
|
-
if (
|
|
5839
|
+
let ref14;
|
|
5840
|
+
if (ref14 = prependStatementExpressionBlock(
|
|
5705
5841
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
5706
5842
|
block
|
|
5707
5843
|
)) {
|
|
5708
|
-
let ref =
|
|
5844
|
+
let ref = ref14;
|
|
5709
5845
|
exp.children = exp.children.map(($7) => $7 === $2 ? ref : $7), $2 = ref;
|
|
5710
5846
|
} else
|
|
5711
5847
|
block = void 0;
|
|
@@ -5751,7 +5887,7 @@ ${js}`
|
|
|
5751
5887
|
message: "Slice range cannot be decreasing in assignment"
|
|
5752
5888
|
});
|
|
5753
5889
|
break;
|
|
5754
|
-
} else m3 = lhs.type, (m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern") && (processBindingPatternLHS(lhs, tail), gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare)));
|
|
5890
|
+
} else m3 = lhs.type, (m3 === "ObjectBindingPattern" || m3 === "ArrayBindingPattern" || m3 === "NamedBindingPattern") && (processBindingPatternLHS(lhs, tail), gatherRecursiveAll(lhs, ($9) => $9.type === "Ref").forEach(refsToDeclare.add.bind(refsToDeclare)));
|
|
5755
5891
|
}
|
|
5756
5892
|
i--;
|
|
5757
5893
|
}
|
|
@@ -5808,9 +5944,9 @@ ${js}`
|
|
|
5808
5944
|
}
|
|
5809
5945
|
j++;
|
|
5810
5946
|
}
|
|
5811
|
-
let
|
|
5812
|
-
if (
|
|
5813
|
-
let l =
|
|
5947
|
+
let ref15;
|
|
5948
|
+
if (ref15 = conditions.length) {
|
|
5949
|
+
let l = ref15, cs = flatJoin(conditions, " && ");
|
|
5814
5950
|
return {
|
|
5815
5951
|
...exp,
|
|
5816
5952
|
children: [...cs, " ? ", innerExp(children), " : void 0"],
|
|
@@ -5842,12 +5978,12 @@ ${js}`
|
|
|
5842
5978
|
}
|
|
5843
5979
|
function processTypes(node) {
|
|
5844
5980
|
let results1 = [];
|
|
5845
|
-
for (let
|
|
5846
|
-
let unary =
|
|
5981
|
+
for (let ref16 = gatherRecursiveAll(node, ($11) => $11.type === "TypeUnary"), i8 = 0, len6 = ref16.length; i8 < len6; i8++) {
|
|
5982
|
+
let unary = ref16[i8], suffixIndex = unary.suffix.length - 1, results2 = [];
|
|
5847
5983
|
for (; suffixIndex >= 0; ) {
|
|
5848
5984
|
let suffix = unary.suffix[suffixIndex];
|
|
5849
5985
|
if (typeof suffix == "object" && suffix != null && "token" in suffix && suffix.token === "?") {
|
|
5850
|
-
let {
|
|
5986
|
+
let {} = suffix, count = 0, m4;
|
|
5851
5987
|
for (; m4 = unary.suffix[suffixIndex], typeof m4 == "object" && m4 != null && "token" in m4 && m4.token === "?"; )
|
|
5852
5988
|
unary.suffix.splice(suffixIndex--, 1), count++;
|
|
5853
5989
|
let m5;
|
|
@@ -5894,7 +6030,7 @@ ${js}`
|
|
|
5894
6030
|
children: [prefix, replace, outer]
|
|
5895
6031
|
})), results2.push(replaceNode(unary, replace, parent));
|
|
5896
6032
|
} else if (typeof suffix == "object" && suffix != null && "type" in suffix && suffix.type === "NonNullAssertion") {
|
|
5897
|
-
let {
|
|
6033
|
+
let {} = suffix, m6;
|
|
5898
6034
|
for (; m6 = unary.suffix[suffixIndex], typeof m6 == "object" && m6 != null && "type" in m6 && m6.type === "NonNullAssertion"; )
|
|
5899
6035
|
unary.suffix.splice(suffixIndex--, 1);
|
|
5900
6036
|
let m7;
|
|
@@ -5904,9 +6040,9 @@ ${js}`
|
|
|
5904
6040
|
unary.prefix = [], unary.children = unary.children.filter((a2) => a2 !== prefix);
|
|
5905
6041
|
let outer = unary.suffix.splice(suffixIndex + 1, 1 / 0), space = getTrimmingSpace(unary);
|
|
5906
6042
|
inplaceInsertTrimmingSpace(unary, "");
|
|
5907
|
-
let
|
|
5908
|
-
unary.suffix.length ?
|
|
5909
|
-
let t =
|
|
6043
|
+
let ref17;
|
|
6044
|
+
unary.suffix.length ? ref17 = unary : ref17 = unary.t;
|
|
6045
|
+
let t = ref17, argArray = [makeNode({
|
|
5910
6046
|
type: "TypeArgument",
|
|
5911
6047
|
ts: !0,
|
|
5912
6048
|
t,
|
|
@@ -5942,16 +6078,16 @@ ${js}`
|
|
|
5942
6078
|
return results1;
|
|
5943
6079
|
}
|
|
5944
6080
|
function processStatementExpressions(statements) {
|
|
5945
|
-
for (let
|
|
5946
|
-
let exp =
|
|
6081
|
+
for (let ref18 = gatherRecursiveAll(statements, ($12) => $12.type === "StatementExpression"), i9 = 0, len7 = ref18.length; i9 < len7; i9++) {
|
|
6082
|
+
let exp = ref18[i9], { maybe, statement } = exp;
|
|
5947
6083
|
if ((maybe || statement.type === "ThrowStatement") && blockContainingStatement(exp)) {
|
|
5948
6084
|
replaceNode(exp, statement);
|
|
5949
6085
|
continue;
|
|
5950
6086
|
}
|
|
5951
|
-
let
|
|
6087
|
+
let ref19;
|
|
5952
6088
|
switch (statement.type) {
|
|
5953
6089
|
case "IfStatement": {
|
|
5954
|
-
(
|
|
6090
|
+
(ref19 = expressionizeIfStatement(statement)) ? replaceNode(statement, ref19, exp) : replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
5955
6091
|
break;
|
|
5956
6092
|
}
|
|
5957
6093
|
case "IterationExpression": {
|
|
@@ -5992,11 +6128,11 @@ ${js}`
|
|
|
5992
6128
|
});
|
|
5993
6129
|
}
|
|
5994
6130
|
function processFinallyClauses(statements) {
|
|
5995
|
-
for (let
|
|
5996
|
-
let f =
|
|
5997
|
-
if (!((
|
|
6131
|
+
for (let ref20 = gatherRecursiveAll(statements, ($) => $.type === "FinallyClause" && $.parent?.type !== "TryStatement"), i10 = 0, len8 = ref20.length; i10 < len8; i10++) {
|
|
6132
|
+
let f = ref20[i10], ref21;
|
|
6133
|
+
if (!((ref21 = blockContainingStatement(f)) && typeof ref21 == "object" && "block" in ref21 && "index" in ref21))
|
|
5998
6134
|
throw new Error("finally clause must be inside try statement or block");
|
|
5999
|
-
let { block, index } =
|
|
6135
|
+
let { block, index } = ref21, indent = block.expressions[index][0], expressions = block.expressions.slice(index + 1), t = makeNode({
|
|
6000
6136
|
type: "BlockStatement",
|
|
6001
6137
|
expressions,
|
|
6002
6138
|
children: ["{", expressions, "}"],
|
|
@@ -6056,8 +6192,8 @@ ${js}`
|
|
|
6056
6192
|
}
|
|
6057
6193
|
}
|
|
6058
6194
|
function processCoffeeClasses(statements) {
|
|
6059
|
-
for (let
|
|
6060
|
-
let ce =
|
|
6195
|
+
for (let ref22 = gatherRecursiveAll(statements, ($13) => $13.type === "ClassExpression"), i11 = 0, len9 = ref22.length; i11 < len9; i11++) {
|
|
6196
|
+
let ce = ref22[i11], { expressions } = ce.body, indent = expressions[0]?.[0] ?? `
|
|
6061
6197
|
`, autoBinds = expressions.filter(($14) => $14[1]?.autoBind);
|
|
6062
6198
|
if (autoBinds.length) {
|
|
6063
6199
|
let construct;
|
|
@@ -6147,38 +6283,23 @@ ${js}`
|
|
|
6147
6283
|
}
|
|
6148
6284
|
function processRepl(root, rootIIFE) {
|
|
6149
6285
|
let topBlock = gatherRecursive(rootIIFE, ($17) => $17.type === "BlockStatement")[0], i = 0;
|
|
6150
|
-
for (let
|
|
6151
|
-
let decl =
|
|
6286
|
+
for (let ref23 = gatherRecursiveWithinFunction(topBlock, ($18) => $18.type === "Declaration"), i14 = 0, len11 = ref23.length; i14 < len11; i14++) {
|
|
6287
|
+
let decl = ref23[i14];
|
|
6152
6288
|
decl.names?.length && (decl.parent === topBlock || decl.decl === "var") && (decl.children.shift(), decl.bindings[0]?.pattern?.type === "ObjectBindingPattern" && (decl.children.unshift("("), decl.children.push(")")), root.expressions.splice(i++, 0, ["", `var ${decl.names.join(",")}`, ";"]));
|
|
6153
6289
|
}
|
|
6154
|
-
for (let
|
|
6155
|
-
let func =
|
|
6290
|
+
for (let ref24 = gatherRecursive(topBlock, ($19) => $19.type === "FunctionExpression"), i15 = 0, len12 = ref24.length; i15 < len12; i15++) {
|
|
6291
|
+
let func = ref24[i15];
|
|
6156
6292
|
func.name && func.parent?.type === "BlockStatement" && (func.parent === topBlock ? (replaceNode(func, void 0), root.expressions.splice(i++, 0, ["", func]), func.parent = root) : (func.children.unshift(func.name, "="), root.expressions.splice(i++, 0, ["", `var ${func.name}`, ";"])));
|
|
6157
6293
|
}
|
|
6158
|
-
for (let
|
|
6159
|
-
let classExp =
|
|
6294
|
+
for (let ref25 = gatherRecursiveWithinFunction(topBlock, ($20) => $20.type === "ClassExpression"), i16 = 0, len13 = ref25.length; i16 < len13; i16++) {
|
|
6295
|
+
let classExp = ref25[i16], m8;
|
|
6160
6296
|
(classExp.name && classExp.parent === topBlock || (m8 = classExp.parent, typeof m8 == "object" && m8 != null && "type" in m8 && m8.type === "ReturnStatement" && "parent" in m8 && m8.parent === topBlock)) && (classExp.children.unshift(classExp.name, "="), root.expressions.splice(i++, 0, ["", `var ${classExp.name}`, ";"]));
|
|
6161
6297
|
}
|
|
6162
6298
|
}
|
|
6163
|
-
function populateRefs(statements) {
|
|
6164
|
-
let refNodes = gatherRecursive(statements, ($21) => $21.type === "Ref");
|
|
6165
|
-
if (refNodes.length) {
|
|
6166
|
-
let ids = gatherRecursive(statements, (s) => s.type === "Identifier"), names = new Set(ids.flatMap(({ names: names2 }) => names2 || []));
|
|
6167
|
-
refNodes.forEach((ref) => {
|
|
6168
|
-
let { type, base } = ref;
|
|
6169
|
-
if (type !== "Ref") return;
|
|
6170
|
-
ref.type = "Identifier";
|
|
6171
|
-
let n = 0, name = base;
|
|
6172
|
-
for (; names.has(name); )
|
|
6173
|
-
n++, name = `${base}${n}`;
|
|
6174
|
-
return names.add(name), ref.children = ref.names = [name];
|
|
6175
|
-
});
|
|
6176
|
-
}
|
|
6177
|
-
}
|
|
6178
6299
|
function processPlaceholders(statements) {
|
|
6179
6300
|
let placeholderMap = /* @__PURE__ */ new Map(), liftedIfs = /* @__PURE__ */ new Set();
|
|
6180
|
-
for (let
|
|
6181
|
-
let exp =
|
|
6301
|
+
for (let ref26 = gatherRecursiveAll(statements, ($21) => $21.type === "Placeholder"), i17 = 0, len14 = ref26.length; i17 < len14; i17++) {
|
|
6302
|
+
let exp = ref26[i17], ancestor;
|
|
6182
6303
|
if (exp.subtype === ".") {
|
|
6183
6304
|
({ ancestor } = findAncestor(
|
|
6184
6305
|
exp,
|
|
@@ -6250,8 +6371,8 @@ ${js}`
|
|
|
6250
6371
|
for (let i18 = 0, len15 = placeholders.length; i18 < len15; i18++) {
|
|
6251
6372
|
let placeholder = placeholders[i18];
|
|
6252
6373
|
typeSuffix ??= placeholder.typeSuffix;
|
|
6253
|
-
let
|
|
6254
|
-
(
|
|
6374
|
+
let ref27;
|
|
6375
|
+
(ref27 = placeholder.children)[ref27.length - 1] = ref;
|
|
6255
6376
|
}
|
|
6256
6377
|
let { parent } = ancestor, body = maybeUnwrap(ancestor), fnExp = makeAmpersandFunction({ ref, typeSuffix, body }), outer;
|
|
6257
6378
|
switch (parent?.type) {
|
|
@@ -6268,8 +6389,8 @@ ${js}`
|
|
|
6268
6389
|
break;
|
|
6269
6390
|
}
|
|
6270
6391
|
case "PipelineExpression": {
|
|
6271
|
-
let i = findChildIndex(parent, ancestor),
|
|
6272
|
-
i === 1 ?
|
|
6392
|
+
let i = findChildIndex(parent, ancestor), ref28;
|
|
6393
|
+
i === 1 ? ref28 = ancestor === parent.children[i] : i === 2 ? ref28 = ancestor === parent.children[i][findChildIndex(parent.children[i], ancestor)][3] : ref28 = void 0, outer = ref28;
|
|
6273
6394
|
break;
|
|
6274
6395
|
}
|
|
6275
6396
|
case "AssignmentExpression":
|
|
@@ -6280,10 +6401,10 @@ ${js}`
|
|
|
6280
6401
|
break;
|
|
6281
6402
|
}
|
|
6282
6403
|
}
|
|
6283
|
-
outer || (fnExp = makeLeftHandSideExpression(fnExp)), replaceNode(ancestor, fnExp, parent);
|
|
6284
|
-
let
|
|
6285
|
-
if (
|
|
6286
|
-
let ws =
|
|
6404
|
+
outer || (fnExp = makeLeftHandSideExpression(fnExp)), replaceNode(ancestor, fnExp, parent), typeof parent == "object" && parent != null && "type" in parent && parent.type === "BlockStatement" && "parent" in parent && typeof parent.parent == "object" && parent.parent != null && "type" in parent.parent && parent.parent.type === "ArrowFunction" && "ampersandBlock" in parent.parent && parent.parent.ampersandBlock === !0 && "body" in parent.parent && parent.parent.body === body && (parent.parent.body = fnExp);
|
|
6405
|
+
let ref29;
|
|
6406
|
+
if (ref29 = getTrimmingSpace(body)) {
|
|
6407
|
+
let ws = ref29;
|
|
6287
6408
|
inplaceInsertTrimmingSpace(body, ""), inplacePrepend(ws, fnExp);
|
|
6288
6409
|
}
|
|
6289
6410
|
}
|
|
@@ -6314,8 +6435,8 @@ ${js}`
|
|
|
6314
6435
|
}
|
|
6315
6436
|
];
|
|
6316
6437
|
}
|
|
6317
|
-
let
|
|
6318
|
-
Array.isArray(rest.delim) && (
|
|
6438
|
+
let ref30;
|
|
6439
|
+
Array.isArray(rest.delim) && (ref30 = rest.delim)[ref30.length - 1]?.token === "," && (rest.delim = rest.delim.slice(0, -1), rest.children = [...rest.children.slice(0, -1), rest.delim]);
|
|
6319
6440
|
let children = [...props, ...after, rest];
|
|
6320
6441
|
return restCount > 1 && children.push({
|
|
6321
6442
|
type: "Error",
|
|
@@ -6525,6 +6646,7 @@ ${js}`
|
|
|
6525
6646
|
NWBindingIdentifier,
|
|
6526
6647
|
AtIdentifierRef,
|
|
6527
6648
|
PinPattern,
|
|
6649
|
+
NamedBindingPattern,
|
|
6528
6650
|
BindingPattern,
|
|
6529
6651
|
ObjectBindingPattern,
|
|
6530
6652
|
ObjectBindingPatternContent,
|
|
@@ -7899,20 +8021,22 @@ ${js}`
|
|
|
7899
8021
|
function PipelineHeadItem(ctx, state2) {
|
|
7900
8022
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineHeadItem", PipelineHeadItem$$);
|
|
7901
8023
|
}
|
|
7902
|
-
var PipelineTailItem$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$C)(AwaitOp,
|
|
8024
|
+
var PipelineTailItem$0 = (0, import_lib2.$T)((0, import_lib2.$S)((0, import_lib2.$C)(AwaitOp, Return, Throw), (0, import_lib2.$N)(AccessStart), (0, import_lib2.$N)(MaybeParenNestedExpression)), function(value) {
|
|
7903
8025
|
return value[0];
|
|
7904
|
-
}), PipelineTailItem$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$
|
|
8026
|
+
}), PipelineTailItem$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$TEXT)((0, import_lib2.$S)(Yield, (0, import_lib2.$E)((0, import_lib2.$S)((0, import_lib2.$E)(_), Star)))), (0, import_lib2.$N)(AccessStart), (0, import_lib2.$N)(MaybeParenNestedExpression)), function($skip, $loc, $0, $1, $2, $3) {
|
|
8027
|
+
return { $loc, token: $1, type: "Yield" };
|
|
8028
|
+
}), PipelineTailItem$2 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L15, 'PipelineTailItem "import"'), (0, import_lib2.$N)(AccessStart)), function($skip, $loc, $0, $1, $2) {
|
|
7905
8029
|
return {
|
|
7906
8030
|
type: "Identifier",
|
|
7907
8031
|
children: [$1]
|
|
7908
8032
|
};
|
|
7909
|
-
}), PipelineTailItem$
|
|
8033
|
+
}), PipelineTailItem$3 = (0, import_lib2.$TS)((0, import_lib2.$S)(NWTypePostfix, (0, import_lib2.$Q)(TypePostfix)), function($skip, $loc, $0, $1, $2) {
|
|
7910
8034
|
return makeAmpersandFunction({
|
|
7911
8035
|
body: [" ", $1, ...$2]
|
|
7912
8036
|
});
|
|
7913
|
-
}), PipelineTailItem$
|
|
8037
|
+
}), PipelineTailItem$4 = (0, import_lib2.$T)((0, import_lib2.$S)(PipelineHeadItem), function(value) {
|
|
7914
8038
|
return value[0];
|
|
7915
|
-
}), PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3];
|
|
8039
|
+
}), PipelineTailItem$$ = [PipelineTailItem$0, PipelineTailItem$1, PipelineTailItem$2, PipelineTailItem$3, PipelineTailItem$4];
|
|
7916
8040
|
function PipelineTailItem(ctx, state2) {
|
|
7917
8041
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PipelineTailItem", PipelineTailItem$$);
|
|
7918
8042
|
}
|
|
@@ -8370,7 +8494,7 @@ ${js}`
|
|
|
8370
8494
|
children: $0,
|
|
8371
8495
|
expression
|
|
8372
8496
|
};
|
|
8373
|
-
}), LeftHandSideExpression$1 = CallExpression, LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1];
|
|
8497
|
+
}), LeftHandSideExpression$1 = NamedBindingPattern, LeftHandSideExpression$2 = CallExpression, LeftHandSideExpression$$ = [LeftHandSideExpression$0, LeftHandSideExpression$1, LeftHandSideExpression$2];
|
|
8374
8498
|
function LeftHandSideExpression(ctx, state2) {
|
|
8375
8499
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "LeftHandSideExpression", LeftHandSideExpression$$);
|
|
8376
8500
|
}
|
|
@@ -8827,7 +8951,7 @@ ${js}`
|
|
|
8827
8951
|
function FunctionRestParameter(ctx, state2) {
|
|
8828
8952
|
return (0, import_lib2.$EVENT)(ctx, state2, "FunctionRestParameter", FunctionRestParameter$0);
|
|
8829
8953
|
}
|
|
8830
|
-
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)(
|
|
8954
|
+
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) {
|
|
8831
8955
|
var accessModifier = $2, binding = $4, typeSuffix = $5, initializer = $6, delim = $7;
|
|
8832
8956
|
return typeSuffix ??= binding.typeSuffix, {
|
|
8833
8957
|
type: "Parameter",
|
|
@@ -8920,7 +9044,22 @@ ${js}`
|
|
|
8920
9044
|
function PinPattern(ctx, state2) {
|
|
8921
9045
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PinPattern", PinPattern$$);
|
|
8922
9046
|
}
|
|
8923
|
-
var
|
|
9047
|
+
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) {
|
|
9048
|
+
var binding = $1, ws = $3, pattern = $4;
|
|
9049
|
+
return pattern = prepend(ws, pattern), {
|
|
9050
|
+
type: "NamedBindingPattern",
|
|
9051
|
+
// NOTE: children just has binding, not pattern, for easy destructuring
|
|
9052
|
+
children: [binding],
|
|
9053
|
+
binding,
|
|
9054
|
+
pattern,
|
|
9055
|
+
subbinding: [pattern, " = ", binding],
|
|
9056
|
+
typeSuffix: pattern.typeSuffix
|
|
9057
|
+
};
|
|
9058
|
+
});
|
|
9059
|
+
function NamedBindingPattern(ctx, state2) {
|
|
9060
|
+
return (0, import_lib2.$EVENT)(ctx, state2, "NamedBindingPattern", NamedBindingPattern$0);
|
|
9061
|
+
}
|
|
9062
|
+
var BindingPattern$0 = ObjectBindingPattern, BindingPattern$1 = ArrayBindingPattern, BindingPattern$2 = PinPattern, BindingPattern$3 = Literal, BindingPattern$4 = RegularExpressionLiteral, BindingPattern$5 = NamedBindingPattern, BindingPattern$$ = [BindingPattern$0, BindingPattern$1, BindingPattern$2, BindingPattern$3, BindingPattern$4, BindingPattern$5];
|
|
8924
9063
|
function BindingPattern(ctx, state2) {
|
|
8925
9064
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingPattern", BindingPattern$$);
|
|
8926
9065
|
}
|
|
@@ -9016,8 +9155,21 @@ ${js}`
|
|
|
9016
9155
|
function NestedBindingPropertyList(ctx, state2) {
|
|
9017
9156
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingPropertyList", NestedBindingPropertyList$0);
|
|
9018
9157
|
}
|
|
9019
|
-
var BindingProperty$0 = BindingRestProperty, 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)(
|
|
9158
|
+
var BindingProperty$0 = BindingRestProperty, 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) {
|
|
9020
9159
|
var ws1 = $1, name = $2, bind = $3, ws2 = $4, colon = $5, ws3 = $6, value = $7, typeSuffix = $8, initializer = $9;
|
|
9160
|
+
if (bind) {
|
|
9161
|
+
let binding = name, pattern = value;
|
|
9162
|
+
value = {
|
|
9163
|
+
type: "NamedBindingPattern",
|
|
9164
|
+
// NOTE: children just has binding, not pattern, for easy destructuring
|
|
9165
|
+
children: [binding],
|
|
9166
|
+
binding,
|
|
9167
|
+
pattern,
|
|
9168
|
+
subbinding: [pattern, " = ", binding],
|
|
9169
|
+
typeSuffix: pattern.typeSuffix,
|
|
9170
|
+
names: value.names
|
|
9171
|
+
};
|
|
9172
|
+
}
|
|
9021
9173
|
return {
|
|
9022
9174
|
type: "BindingProperty",
|
|
9023
9175
|
children: [ws1, name, ws2, colon, ws3, value, initializer],
|
|
@@ -9026,8 +9178,7 @@ ${js}`
|
|
|
9026
9178
|
value,
|
|
9027
9179
|
typeSuffix,
|
|
9028
9180
|
initializer,
|
|
9029
|
-
names: value.names
|
|
9030
|
-
bind: !!bind
|
|
9181
|
+
names: value.names
|
|
9031
9182
|
};
|
|
9032
9183
|
}), 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) {
|
|
9033
9184
|
var ws = $1, pin = $2, binding = $3, typeSuffix = $4, initializer = $5;
|
|
@@ -9070,8 +9221,7 @@ ${js}`
|
|
|
9070
9221
|
typeSuffix,
|
|
9071
9222
|
initializer,
|
|
9072
9223
|
names: binding.names,
|
|
9073
|
-
identifier: binding
|
|
9074
|
-
bind: !!bind
|
|
9224
|
+
identifier: binding
|
|
9075
9225
|
};
|
|
9076
9226
|
}), BindingProperty$$ = [BindingProperty$0, BindingProperty$1, BindingProperty$2, BindingProperty$3];
|
|
9077
9227
|
function BindingProperty(ctx, state2) {
|
|
@@ -9117,7 +9267,7 @@ ${js}`
|
|
|
9117
9267
|
function NestedBindingElements(ctx, state2) {
|
|
9118
9268
|
return (0, import_lib2.$EVENT)(ctx, state2, "NestedBindingElements", NestedBindingElements$0);
|
|
9119
9269
|
}
|
|
9120
|
-
var BindingElement$0 = BindingRestElement, BindingElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
9270
|
+
var BindingElement$0 = BindingRestElement, 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) {
|
|
9121
9271
|
var ws = $1, binding = $2, typeSuffix = $3, initializer = $4;
|
|
9122
9272
|
return {
|
|
9123
9273
|
type: "BindingElement",
|
|
@@ -9137,7 +9287,7 @@ ${js}`
|
|
|
9137
9287
|
function BindingElement(ctx, state2) {
|
|
9138
9288
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "BindingElement", BindingElement$$);
|
|
9139
9289
|
}
|
|
9140
|
-
var BindingRestElement$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), DotDotDot, (0, import_lib2.$C)(
|
|
9290
|
+
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) {
|
|
9141
9291
|
var ws = $1, dots = $2, binding = $3, typeSuffix = $4;
|
|
9142
9292
|
return {
|
|
9143
9293
|
type: "BindingRestElement",
|
|
@@ -9149,7 +9299,7 @@ ${js}`
|
|
|
9149
9299
|
names: binding.names,
|
|
9150
9300
|
rest: !0
|
|
9151
9301
|
};
|
|
9152
|
-
}), BindingRestElement$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)(
|
|
9302
|
+
}), 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) {
|
|
9153
9303
|
var ws = $1, binding = $2, dots = $3;
|
|
9154
9304
|
return {
|
|
9155
9305
|
type: "BindingRestElement",
|
|
@@ -9220,11 +9370,12 @@ ${js}`
|
|
|
9220
9370
|
signature,
|
|
9221
9371
|
ts: !0
|
|
9222
9372
|
};
|
|
9223
|
-
}), FunctionExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(ArrowFunction), OpenParen, BinaryOp, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9224
|
-
var open = $2,
|
|
9373
|
+
}), FunctionExpression$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$N)(ArrowFunction), OpenParen, __, BinaryOp, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
9374
|
+
var open = $2, ws1 = $3, op = $4, ws2 = $5, close = $6;
|
|
9225
9375
|
if (op.special && op.call && !op.negated) return op.call;
|
|
9376
|
+
ws1 || (ws1 = op.spaced ? [" "] : []), ws2 || (ws2 = op.spaced ? [" "] : []);
|
|
9226
9377
|
let refA = makeRef("a"), refB = makeRef("b"), body = processBinaryOpExpression([refA, [
|
|
9227
|
-
[
|
|
9378
|
+
[ws1, op, ws2, refB]
|
|
9228
9379
|
// BinaryOpRHS
|
|
9229
9380
|
]]), parameterList = [[refA, ","], refB], parameters = {
|
|
9230
9381
|
type: "Parameters",
|
|
@@ -9247,6 +9398,7 @@ ${js}`
|
|
|
9247
9398
|
};
|
|
9248
9399
|
}), FunctionExpression$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, NonPipelineAssignmentExpression, __, BinaryOp, __, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
|
|
9249
9400
|
var open = $1, lhs = $2, ws1 = $3, op = $4, ws2 = $5, close = $6;
|
|
9401
|
+
ws1 || (ws1 = op.spaced ? [" "] : []), ws2 || (ws2 = op.spaced ? [" "] : []);
|
|
9250
9402
|
let refB = makeRef("b"), fn = makeAmpersandFunction({
|
|
9251
9403
|
ref: refB,
|
|
9252
9404
|
body: processBinaryOpExpression([lhs, [
|
|
@@ -9294,6 +9446,7 @@ ${js}`
|
|
|
9294
9446
|
};
|
|
9295
9447
|
}), FunctionExpression$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(OpenParen, __, (0, import_lib2.$N)((0, import_lib2.$EXPECT)($R15, "FunctionExpression /\\+\\+|--|\u29FA|\u2014|[\\+\\-&]\\S/")), (0, import_lib2.$N)((0, import_lib2.$S)(Placeholder, (0, import_lib2.$C)(TypePostfix, BinaryOpRHS))), BinaryOp, __, NonPipelineAssignmentExpression, CloseParen), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
9296
9448
|
var open = $1, ws1 = $2, op = $5, ws2 = $6, rhs = $7, close = $8;
|
|
9449
|
+
ws1 || (ws1 = op.spaced ? [" "] : []), ws2 || (ws2 = op.spaced ? [" "] : []);
|
|
9297
9450
|
let refA = makeRef("a"), fn = makeAmpersandFunction({
|
|
9298
9451
|
ref: refA,
|
|
9299
9452
|
body: processBinaryOpExpression([refA, [
|
|
@@ -9312,10 +9465,7 @@ ${js}`
|
|
|
9312
9465
|
}
|
|
9313
9466
|
var OperatorDeclaration$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, (0, import_lib2.$E)(OperatorBehavior), _, LexicalDeclaration), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9314
9467
|
var op = $1, behavior = $2, w = $3, decl = $4;
|
|
9315
|
-
return decl.names.forEach((name) => state.operators.set(name, behavior)),
|
|
9316
|
-
...decl,
|
|
9317
|
-
children: [trimFirstSpace(w), ...decl.children]
|
|
9318
|
-
};
|
|
9468
|
+
return decl.names.forEach((name) => state.operators.set(name, behavior)), behavior?.error && (decl = prepend(behavior.error, decl)), decl = prepend(trimFirstSpace(w), decl), decl;
|
|
9319
9469
|
}), OperatorDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(OperatorSignature, BracedBlock), function($skip, $loc, $0, $1, $2) {
|
|
9320
9470
|
var signature = $1, block = $2;
|
|
9321
9471
|
return state.operators.set(signature.id.name, signature.behavior), {
|
|
@@ -9328,9 +9478,12 @@ ${js}`
|
|
|
9328
9478
|
};
|
|
9329
9479
|
}), OperatorDeclaration$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(Operator, _, Identifier, (0, import_lib2.$E)(OperatorBehavior), (0, import_lib2.$Q)((0, import_lib2.$S)(CommaDelimiter, (0, import_lib2.$E)(_), Identifier, (0, import_lib2.$E)(OperatorBehavior)))), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
9330
9480
|
var op = $1, w1 = $2, id = $3, behavior = $4, ids = $5;
|
|
9331
|
-
|
|
9481
|
+
let children = [];
|
|
9482
|
+
return state.operators.set(id.name, behavior), behavior?.error && children.push(behavior.error), ids.forEach(([, , id2, behavior2]) => {
|
|
9483
|
+
state.operators.set(id2.name, behavior2), behavior2?.error && children.push(behavior2.error);
|
|
9484
|
+
}), {
|
|
9332
9485
|
id,
|
|
9333
|
-
children
|
|
9486
|
+
children
|
|
9334
9487
|
};
|
|
9335
9488
|
}), OperatorDeclaration$$ = [OperatorDeclaration$0, OperatorDeclaration$1, OperatorDeclaration$2];
|
|
9336
9489
|
function OperatorDeclaration(ctx, state2) {
|
|
@@ -9351,7 +9504,7 @@ ${js}`
|
|
|
9351
9504
|
generator: !!generator.length
|
|
9352
9505
|
},
|
|
9353
9506
|
block: null,
|
|
9354
|
-
children: [async, func, generator, w1, id, w2, parameters, returnType],
|
|
9507
|
+
children: [async, func, generator, w1, id, behavior?.error, w2, parameters, returnType],
|
|
9355
9508
|
behavior
|
|
9356
9509
|
};
|
|
9357
9510
|
});
|
|
@@ -9368,16 +9521,19 @@ ${js}`
|
|
|
9368
9521
|
}
|
|
9369
9522
|
var OperatorPrecedence$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$E)(_), (0, import_lib2.$C)((0, import_lib2.$EXPECT)($L27, 'OperatorPrecedence "tighter"'), (0, import_lib2.$EXPECT)($L28, 'OperatorPrecedence "looser"'), (0, import_lib2.$EXPECT)($L29, 'OperatorPrecedence "same"')), NonIdContinue, (0, import_lib2.$E)(_), (0, import_lib2.$C)(Identifier, (0, import_lib2.$S)(OpenParen, BinaryOp, CloseParen))), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
9370
9523
|
var mod = $2, op = $5;
|
|
9371
|
-
let prec
|
|
9372
|
-
switch (
|
|
9524
|
+
let prec, error;
|
|
9525
|
+
switch (op.type === "Identifier" ? state.operators.has(op.name) ? prec = state.operators.get(op.name).prec : (prec = precedenceCustomDefault, error = {
|
|
9526
|
+
type: "Error",
|
|
9527
|
+
message: `Precedence refers to unknown operator ${op.name}`
|
|
9528
|
+
}) : prec = getPrecedence(op[1]), mod) {
|
|
9373
9529
|
case "tighter":
|
|
9374
|
-
prec +=
|
|
9530
|
+
prec += precedenceStep;
|
|
9375
9531
|
break;
|
|
9376
9532
|
case "looser":
|
|
9377
|
-
prec -=
|
|
9533
|
+
prec -= precedenceStep;
|
|
9378
9534
|
break;
|
|
9379
9535
|
}
|
|
9380
|
-
return { prec };
|
|
9536
|
+
return { prec, error };
|
|
9381
9537
|
});
|
|
9382
9538
|
function OperatorPrecedence(ctx, state2) {
|
|
9383
9539
|
return (0, import_lib2.$EVENT)(ctx, state2, "OperatorPrecedence", OperatorPrecedence$0);
|
|
@@ -9933,8 +10089,8 @@ ${js}`
|
|
|
9933
10089
|
return (0, import_lib2.$EVENT)(ctx, state2, "RangeEnd", RangeEnd$0);
|
|
9934
10090
|
}
|
|
9935
10091
|
var RangeExpression$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(Expression, __, RangeDots, Expression), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
9936
|
-
var start = $1, ws = $2,
|
|
9937
|
-
return processRangeExpression(start, ws,
|
|
10092
|
+
var start = $1, ws = $2, range2 = $3, end = $4;
|
|
10093
|
+
return processRangeExpression(start, ws, range2, end);
|
|
9938
10094
|
}), 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) {
|
|
9939
10095
|
var s = $1, ws = $2;
|
|
9940
10096
|
return {
|
|
@@ -10791,6 +10947,7 @@ ${js}`
|
|
|
10791
10947
|
return {
|
|
10792
10948
|
$loc,
|
|
10793
10949
|
token: "instanceof",
|
|
10950
|
+
spaced: !0,
|
|
10794
10951
|
relational: !0,
|
|
10795
10952
|
special: !0
|
|
10796
10953
|
};
|
|
@@ -10798,6 +10955,7 @@ ${js}`
|
|
|
10798
10955
|
return {
|
|
10799
10956
|
$loc,
|
|
10800
10957
|
token: "instanceof",
|
|
10958
|
+
spaced: !0,
|
|
10801
10959
|
relational: !0,
|
|
10802
10960
|
special: !0,
|
|
10803
10961
|
negated: !0
|
|
@@ -10844,6 +11002,7 @@ ${js}`
|
|
|
10844
11002
|
return {
|
|
10845
11003
|
$loc,
|
|
10846
11004
|
token: $1,
|
|
11005
|
+
spaced: !0,
|
|
10847
11006
|
relational: !0,
|
|
10848
11007
|
special: !0
|
|
10849
11008
|
// for typeof shorthand
|
|
@@ -10923,6 +11082,7 @@ ${js}`
|
|
|
10923
11082
|
return {
|
|
10924
11083
|
$loc,
|
|
10925
11084
|
token: "in",
|
|
11085
|
+
spaced: !0,
|
|
10926
11086
|
special: !0,
|
|
10927
11087
|
negated: !0
|
|
10928
11088
|
};
|
|
@@ -10942,6 +11102,7 @@ ${js}`
|
|
|
10942
11102
|
return {
|
|
10943
11103
|
$loc,
|
|
10944
11104
|
token: "instanceof",
|
|
11105
|
+
spaced: !0,
|
|
10945
11106
|
relational: !0,
|
|
10946
11107
|
special: !0,
|
|
10947
11108
|
negated: !0
|
|
@@ -10950,6 +11111,7 @@ ${js}`
|
|
|
10950
11111
|
return {
|
|
10951
11112
|
$loc,
|
|
10952
11113
|
token: "in",
|
|
11114
|
+
spaced: !0,
|
|
10953
11115
|
special: !0,
|
|
10954
11116
|
negated: !0
|
|
10955
11117
|
};
|
|
@@ -11547,10 +11709,10 @@ ${js}`
|
|
|
11547
11709
|
};
|
|
11548
11710
|
}), ForDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(InsertConst, (0, import_lib2.$N)(ActualMemberExpression), ForBinding), function($skip, $loc, $0, $1, $2, $3) {
|
|
11549
11711
|
var c = $1, binding = $3;
|
|
11550
|
-
return {
|
|
11712
|
+
return gatherRecursive(binding, ($) => $.type === "PinPattern").length ? $skip : {
|
|
11551
11713
|
type: "ForDeclaration",
|
|
11552
11714
|
children: [c, binding],
|
|
11553
|
-
decl: c.token,
|
|
11715
|
+
decl: c.token.trimEnd(),
|
|
11554
11716
|
binding,
|
|
11555
11717
|
names: binding.names
|
|
11556
11718
|
};
|
|
@@ -11691,12 +11853,16 @@ ${js}`
|
|
|
11691
11853
|
function PatternExpressionList(ctx, state2) {
|
|
11692
11854
|
return (0, import_lib2.$EVENT)(ctx, state2, "PatternExpressionList", PatternExpressionList$0);
|
|
11693
11855
|
}
|
|
11694
|
-
var PatternExpression$0 = BindingPattern, 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) {
|
|
11695
|
-
var
|
|
11696
|
-
|
|
11856
|
+
var PatternExpression$0 = BindingPattern, 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) {
|
|
11857
|
+
var body = $2;
|
|
11858
|
+
if (!body) return $skip;
|
|
11859
|
+
let [named, rhs] = body, binding;
|
|
11860
|
+
return named && ([binding] = named), {
|
|
11697
11861
|
type: "ConditionFragment",
|
|
11698
|
-
children:
|
|
11699
|
-
|
|
11862
|
+
children: [binding, rhs],
|
|
11863
|
+
binding,
|
|
11864
|
+
rhs
|
|
11865
|
+
};
|
|
11700
11866
|
}), PatternExpression$$ = [PatternExpression$0, PatternExpression$1];
|
|
11701
11867
|
function PatternExpression(ctx, state2) {
|
|
11702
11868
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "PatternExpression", PatternExpression$$);
|
|
@@ -11779,15 +11945,7 @@ ${js}`
|
|
|
11779
11945
|
function FinallyClause(ctx, state2) {
|
|
11780
11946
|
return (0, import_lib2.$EVENT)(ctx, state2, "FinallyClause", FinallyClause$0);
|
|
11781
11947
|
}
|
|
11782
|
-
var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)(
|
|
11783
|
-
var binding = $1, typeSuffix = $2;
|
|
11784
|
-
return {
|
|
11785
|
-
type: "CatchParameter",
|
|
11786
|
-
binding,
|
|
11787
|
-
typeSuffix,
|
|
11788
|
-
children: $0
|
|
11789
|
-
};
|
|
11790
|
-
}), CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
|
|
11948
|
+
var CatchParameter$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)(ObjectBindingPattern, ArrayBindingPattern), TypeSuffix), function($skip, $loc, $0, $1, $2) {
|
|
11791
11949
|
var binding = $1, typeSuffix = $2;
|
|
11792
11950
|
return {
|
|
11793
11951
|
type: "CatchParameter",
|
|
@@ -11795,12 +11953,20 @@ ${js}`
|
|
|
11795
11953
|
typeSuffix,
|
|
11796
11954
|
children: [binding, typeSuffix]
|
|
11797
11955
|
};
|
|
11798
|
-
}), CatchParameter$
|
|
11956
|
+
}), CatchParameter$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(PatternExpressionList), function($skip, $loc, $0, $1) {
|
|
11799
11957
|
return {
|
|
11800
11958
|
type: "CatchPattern",
|
|
11801
11959
|
children: $0,
|
|
11802
11960
|
patterns: $1
|
|
11803
11961
|
};
|
|
11962
|
+
}), CatchParameter$2 = (0, import_lib2.$TS)((0, import_lib2.$S)(BindingIdentifier, (0, import_lib2.$E)(TypeSuffix)), function($skip, $loc, $0, $1, $2) {
|
|
11963
|
+
var binding = $1, typeSuffix = $2;
|
|
11964
|
+
return {
|
|
11965
|
+
type: "CatchParameter",
|
|
11966
|
+
binding,
|
|
11967
|
+
typeSuffix,
|
|
11968
|
+
children: $0
|
|
11969
|
+
};
|
|
11804
11970
|
}), CatchParameter$$ = [CatchParameter$0, CatchParameter$1, CatchParameter$2];
|
|
11805
11971
|
function CatchParameter(ctx, state2) {
|
|
11806
11972
|
return (0, import_lib2.$EVENT_C)(ctx, state2, "CatchParameter", CatchParameter$$);
|
|
@@ -12195,11 +12361,12 @@ ${js}`
|
|
|
12195
12361
|
};
|
|
12196
12362
|
}), ImportDeclaration$1 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$C)((0, import_lib2.$S)(Import, __), ImpliedImport), Operator, (0, import_lib2.$E)(OperatorBehavior), __, OperatorNamedImports, __, FromClause), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
12197
12363
|
var i = $1, behavior = $3, ws1 = $4, imports = $5, ws2 = $6, from = $7;
|
|
12198
|
-
|
|
12199
|
-
|
|
12364
|
+
let errors = [];
|
|
12365
|
+
return behavior?.error && errors.push(behavior.error), imports.specifiers.forEach((spec) => {
|
|
12366
|
+
state.operators.set(spec.binding.name, spec.behavior ?? behavior), spec.behavior?.error && errors.push(spec.behavior.error);
|
|
12200
12367
|
}), {
|
|
12201
12368
|
type: "ImportDeclaration",
|
|
12202
|
-
children: [i, trimFirstSpace(ws1), imports, ws2, from],
|
|
12369
|
+
children: [i, ...errors, trimFirstSpace(ws1), imports, ws2, from],
|
|
12203
12370
|
// omit $2 = Operator and $3 = OperatorBehavior
|
|
12204
12371
|
imports,
|
|
12205
12372
|
from
|
|
@@ -12224,11 +12391,12 @@ ${js}`
|
|
|
12224
12391
|
}, { type: "ImportDeclaration", ts: !!t, children: [i, t, imports, w, from], imports, from };
|
|
12225
12392
|
}), ImportDeclaration$5 = (0, import_lib2.$TS)((0, import_lib2.$S)(ImpliedFromClause, __, Import, __, Operator, (0, import_lib2.$E)(OperatorBehavior), __, OperatorNamedImports), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12226
12393
|
var from = $1, fws = $2, i = $3, iws = $4, behavior = $6, ows = $7, imports = $8;
|
|
12227
|
-
|
|
12228
|
-
|
|
12394
|
+
let errors = [];
|
|
12395
|
+
return behavior?.error && errors.push(behavior.error), imports.specifiers.forEach((spec) => {
|
|
12396
|
+
state.operators.set(spec.binding.name, spec.behavior ?? behavior), spec.behavior?.error && errors.push(spec.behavior.error);
|
|
12229
12397
|
}), {
|
|
12230
12398
|
type: "ImportDeclaration",
|
|
12231
|
-
children: [i, iws, trimFirstSpace(ows), imports, fws, from],
|
|
12399
|
+
children: [i, iws, ...errors, trimFirstSpace(ows), imports, fws, from],
|
|
12232
12400
|
// omit Operator and OperatorBehavior
|
|
12233
12401
|
imports,
|
|
12234
12402
|
from
|
|
@@ -12382,14 +12550,14 @@ ${js}`
|
|
|
12382
12550
|
return {
|
|
12383
12551
|
binding,
|
|
12384
12552
|
behavior,
|
|
12385
|
-
children: [$1, $2, $4, $5, $6, $7]
|
|
12553
|
+
children: [$1, $2, $3?.error, $4, $5, $6, $7]
|
|
12386
12554
|
};
|
|
12387
12555
|
}), OperatorImportSpecifier$1 = (0, import_lib2.$TS)((0, import_lib2.$S)(__, ImportedBinding, (0, import_lib2.$E)(OperatorBehavior), ObjectPropertyDelimiter), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12388
12556
|
var binding = $2, behavior = $3;
|
|
12389
12557
|
return {
|
|
12390
12558
|
binding,
|
|
12391
12559
|
behavior,
|
|
12392
|
-
children: [$1, $2, $4]
|
|
12560
|
+
children: [$1, $2, $3?.error, $4]
|
|
12393
12561
|
};
|
|
12394
12562
|
}), OperatorImportSpecifier$$ = [OperatorImportSpecifier$0, OperatorImportSpecifier$1];
|
|
12395
12563
|
function OperatorImportSpecifier(ctx, state2) {
|
|
@@ -13123,7 +13291,7 @@ ${js}`
|
|
|
13123
13291
|
function By(ctx, state2) {
|
|
13124
13292
|
return (0, import_lib2.$EVENT)(ctx, state2, "By", By$0);
|
|
13125
13293
|
}
|
|
13126
|
-
var Caret$0 = (0, import_lib2.$
|
|
13294
|
+
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) {
|
|
13127
13295
|
return { $loc, token: $1 };
|
|
13128
13296
|
});
|
|
13129
13297
|
function Caret(ctx, state2) {
|
|
@@ -13362,7 +13530,7 @@ ${js}`
|
|
|
13362
13530
|
return (0, import_lib2.$EVENT)(ctx, state2, "Import", Import$0);
|
|
13363
13531
|
}
|
|
13364
13532
|
var In$0 = (0, import_lib2.$TS)((0, import_lib2.$S)((0, import_lib2.$EXPECT)($L180, 'In "in"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
13365
|
-
return { $loc, token: $1 };
|
|
13533
|
+
return { $loc, token: $1, spaced: !0 };
|
|
13366
13534
|
});
|
|
13367
13535
|
function In(ctx, state2) {
|
|
13368
13536
|
return (0, import_lib2.$EVENT)(ctx, state2, "In", In$0);
|