@mintplayer/polyglot-target-csharp 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/polyglot-plugin.json +671 -175
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/polyglot-target-csharp",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "MintPlayer Polyglot C# / .NET target — a pure-JSON language plugin (spec + emission rules + capabilities + std bindings) for the polyglot transpiler.",
5
5
  "keywords": [
6
6
  "polyglot",
@@ -369,11 +369,56 @@
369
369
  },
370
370
  "[",
371
371
  {
372
- "emit": "node.index"
372
+ "map": "node.indices",
373
+ "sep": ", "
373
374
  },
374
375
  "]"
375
376
  ]
376
377
  },
378
+ "IndexAssign": {
379
+ "line": {
380
+ "tmpl": [
381
+ {
382
+ "emitChild": "stmt.receiver",
383
+ "side": "recv"
384
+ },
385
+ "[",
386
+ {
387
+ "map": "stmt.indices",
388
+ "sep": ", "
389
+ },
390
+ "] = ",
391
+ {
392
+ "emit": "stmt.value"
393
+ },
394
+ ";"
395
+ ]
396
+ }
397
+ },
398
+ "TupleLet": {
399
+ "line": {
400
+ "tmpl": [
401
+ "var (",
402
+ {
403
+ "map": "stmt.names",
404
+ "sep": ", ",
405
+ "item": {
406
+ "fn": "ident",
407
+ "args": [
408
+ {
409
+ "get": "item"
410
+ }
411
+ ]
412
+ }
413
+ },
414
+ ") = ",
415
+ {
416
+ "emit": "stmt.init"
417
+ },
418
+ ";"
419
+ ]
420
+ }
421
+ },
377
422
  "Cond": {
378
423
  "tmpl": [
379
424
  "(",
@@ -710,29 +755,146 @@
710
755
  ]
711
756
  },
712
757
  "Match": {
713
- "tmpl": [
714
- {
715
- "emitChild": "node.scrutinee",
716
- "side": "recv"
717
- },
718
- " switch { ",
719
- {
720
- "map": "node.arms",
721
- "sep": ", ",
722
- "item": {
723
- "tmpl": [
724
- {
725
- "case": {
726
- "when": [
727
- [
758
+ "case": {
759
+ "when": [
760
+ [
761
+ {
762
+ "eq": [
763
+ "node.isStatement",
764
+ "true"
765
+ ]
766
+ },
767
+ {
768
+ "tmpl": [
769
+ "switch (",
770
+ {
771
+ "emitChild": "node.scrutinee",
772
+ "side": "recv"
773
+ },
774
+ ") { ",
775
+ {
776
+ "map": "node.arms",
777
+ "sep": " ",
778
+ "item": {
779
+ "tmpl": [
780
+ "case ",
728
781
  {
729
- "eq": [
730
- "item.pattern.kind",
731
- "wildcard"
732
- ]
782
+ "call": "csMatchPat"
733
783
  },
734
- "_"
735
- ],
784
+ {
785
+ "call": "csMatchGuard"
786
+ },
787
+ ": ",
788
+ {
789
+ "emit": "item.body"
790
+ },
791
+ "; break;"
792
+ ]
793
+ }
794
+ },
795
+ " }"
796
+ ]
797
+ }
798
+ ]
799
+ ],
800
+ "else": {
801
+ "tmpl": [
802
+ {
803
+ "emitChild": "node.scrutinee",
804
+ "side": "recv"
805
+ },
806
+ " switch { ",
807
+ {
808
+ "map": "node.arms",
809
+ "sep": ", ",
810
+ "item": {
811
+ "tmpl": [
812
+ {
813
+ "call": "csMatchPat"
814
+ },
815
+ {
816
+ "call": "csMatchGuard"
817
+ },
818
+ " => ",
819
+ {
820
+ "emit": "item.body"
821
+ }
822
+ ]
823
+ }
824
+ },
825
+ {
826
+ "case": {
827
+ "when": [
828
+ [
829
+ {
830
+ "eq": [
831
+ "node.hasCatchAll",
832
+ "true"
833
+ ]
834
+ },
835
+ ""
836
+ ]
837
+ ],
838
+ "else": ", _ => throw new global::System.InvalidOperationException()"
839
+ }
840
+ },
841
+ " }"
842
+ ]
843
+ }
844
+ }
845
+ },
846
+ "csMatchGuard": {
847
+ "case": {
848
+ "when": [
849
+ [
850
+ {
851
+ "eq": [
852
+ "item.hasGuard",
853
+ "true"
854
+ ]
855
+ },
856
+ {
857
+ "tmpl": [
858
+ " when ",
859
+ {
860
+ "emit": "item.guard"
861
+ }
862
+ ]
863
+ }
864
+ ]
865
+ ],
866
+ "else": ""
867
+ }
868
+ },
869
+ "csMatchPat": {
870
+ "tmpl": [
871
+ {
872
+ "case": {
873
+ "when": [
874
+ [
875
+ {
876
+ "eq": [
877
+ "item.pattern.kind",
878
+ "wildcard"
879
+ ]
880
+ },
881
+ "_"
882
+ ],
883
+ [
884
+ {
885
+ "eq": [
886
+ "item.pattern.kind",
887
+ "typeTest"
888
+ ]
889
+ },
890
+ {
891
+ "tmpl": [
892
+ { "type": "item.pattern.testType" },
893
+ " ",
894
+ { "fn": "ident", "args": [ { "get": "item.pattern.binding" } ] }
895
+ ]
896
+ }
897
+ ],
736
898
  [
737
899
  {
738
900
  "eq": [
@@ -817,71 +979,50 @@
817
979
  "map": "item.pattern.binders",
818
980
  "sep": ", ",
819
981
  "item": {
820
- "tmpl": [
821
- "var ",
822
- {
823
- "fn": "ident",
824
- "args": [
982
+ "case": {
983
+ "when": [
984
+ [
985
+ {
986
+ "eq": [
987
+ "item.isLiteral",
988
+ "true"
989
+ ]
990
+ },
991
+ {
992
+ "emit": "item.literal"
993
+ }
994
+ ],
995
+ [
996
+ {
997
+ "eq": [
998
+ "item.isWildcard",
999
+ "true"
1000
+ ]
1001
+ },
1002
+ "_"
1003
+ ]
1004
+ ],
1005
+ "else": {
1006
+ "tmpl": [
1007
+ "var ",
825
1008
  {
826
- "get": "item.binding"
1009
+ "fn": "ident",
1010
+ "args": [
1011
+ {
1012
+ "get": "item.binding"
1013
+ }
1014
+ ]
827
1015
  }
828
1016
  ]
829
1017
  }
830
- ]
1018
+ }
831
1019
  }
832
1020
  },
833
1021
  ")"
834
1022
  ]
835
1023
  }
836
1024
  }
837
- },
838
- {
839
- "case": {
840
- "when": [
841
- [
842
- {
843
- "eq": [
844
- "item.hasGuard",
845
- "true"
846
- ]
847
- },
848
- {
849
- "tmpl": [
850
- " when ",
851
- {
852
- "emit": "item.guard"
853
- }
854
- ]
855
- }
856
- ]
857
- ],
858
- "else": ""
859
- }
860
- },
861
- " => ",
862
- {
863
- "emit": "item.body"
864
1025
  }
865
- ]
866
- }
867
- },
868
- {
869
- "case": {
870
- "when": [
871
- [
872
- {
873
- "eq": [
874
- "node.hasCatchAll",
875
- "true"
876
- ]
877
- },
878
- ""
879
- ]
880
- ],
881
- "else": ", _ => throw new global::System.InvalidOperationException()"
882
- }
883
- },
884
- " }"
885
1026
  ]
886
1027
  },
887
1028
  "Lambda": {
@@ -1137,6 +1278,30 @@
1137
1278
  ]
1138
1279
  }
1139
1280
  },
1281
+ {
1282
+ "case": {
1283
+ "when": [
1284
+ [
1285
+ {
1286
+ "eq": [
1287
+ "decl.isOverride",
1288
+ "true"
1289
+ ]
1290
+ },
1291
+ "override "
1292
+ ],
1293
+ [
1294
+ {
1295
+ "eq": [
1296
+ "decl.isVirtual",
1297
+ "true"
1298
+ ]
1299
+ },
1300
+ "virtual "
1301
+ ]
1302
+ ]
1303
+ }
1304
+ },
1140
1305
  {
1141
1306
  "case": {
1142
1307
  "when": [
@@ -1209,31 +1374,117 @@
1209
1374
  ]
1210
1375
  },
1211
1376
  {
1212
- "line": {
1213
- "tmpl": [
1214
- "public ",
1215
- {
1216
- "type": "decl.returnType"
1217
- },
1218
- " ",
1219
- {
1220
- "fn": "ident",
1221
- "args": [
1222
- {
1223
- "get": "decl.name"
1224
- }
1225
- ]
1226
- },
1227
- " => ",
1228
- {
1229
- "emit": "decl.exprBody"
1230
- },
1231
- ";"
1232
- ]
1233
- }
1234
- }
1235
- ],
1236
- [
1377
+ "case": {
1378
+ "when": [
1379
+ [
1380
+ {
1381
+ "eq": [
1382
+ "decl.propHasSetter",
1383
+ "true"
1384
+ ]
1385
+ },
1386
+ {
1387
+ "seq": [
1388
+ {
1389
+ "line": {
1390
+ "tmpl": [
1391
+ "public ",
1392
+ { "type": "decl.returnType" },
1393
+ " ",
1394
+ { "fn": "ident", "args": [ { "get": "decl.name" } ] },
1395
+ " {"
1396
+ ]
1397
+ }
1398
+ },
1399
+ {
1400
+ "indent": [
1401
+ {
1402
+ "case": {
1403
+ "when": [
1404
+ [
1405
+ { "eq": [ "decl.exprBodied", "true" ] },
1406
+ { "line": { "tmpl": [ "get => ", { "emit": "decl.exprBody" }, ";" ] } }
1407
+ ]
1408
+ ],
1409
+ "else": {
1410
+ "seq": [
1411
+ { "line": "get {" },
1412
+ { "indent": [ { "stmts": "decl.body" } ] },
1413
+ { "line": "}" }
1414
+ ]
1415
+ }
1416
+ }
1417
+ },
1418
+ { "line": "set {" },
1419
+ {
1420
+ "indent": [
1421
+ {
1422
+ "case": {
1423
+ "when": [
1424
+ [
1425
+ { "eq": [ "decl.propSetterParam", "value" ] },
1426
+ ""
1427
+ ]
1428
+ ],
1429
+ "else": {
1430
+ "line": {
1431
+ "tmpl": [
1432
+ "var ",
1433
+ { "fn": "ident", "args": [ { "get": "decl.propSetterParam" } ] },
1434
+ " = value;"
1435
+ ]
1436
+ }
1437
+ }
1438
+ }
1439
+ },
1440
+ { "stmts": "decl.propSetterBody" }
1441
+ ]
1442
+ },
1443
+ { "line": "}" }
1444
+ ]
1445
+ },
1446
+ { "line": "}" }
1447
+ ]
1448
+ }
1449
+ ],
1450
+ [
1451
+ { "eq": [ "decl.exprBodied", "true" ] },
1452
+ {
1453
+ "line": {
1454
+ "tmpl": [
1455
+ "public ",
1456
+ { "type": "decl.returnType" },
1457
+ " ",
1458
+ { "fn": "ident", "args": [ { "get": "decl.name" } ] },
1459
+ " => ",
1460
+ { "emit": "decl.exprBody" },
1461
+ ";"
1462
+ ]
1463
+ }
1464
+ }
1465
+ ]
1466
+ ],
1467
+ "else": {
1468
+ "seq": [
1469
+ {
1470
+ "line": {
1471
+ "tmpl": [
1472
+ "public ",
1473
+ { "type": "decl.returnType" },
1474
+ " ",
1475
+ { "fn": "ident", "args": [ { "get": "decl.name" } ] },
1476
+ " {"
1477
+ ]
1478
+ }
1479
+ },
1480
+ { "indent": [ { "line": "get {" }, { "indent": [ { "stmts": "decl.body" } ] }, { "line": "}" } ] },
1481
+ { "line": "}" }
1482
+ ]
1483
+ }
1484
+ }
1485
+ }
1486
+ ],
1487
+ [
1237
1488
  {
1238
1489
  "and": [
1239
1490
  {
@@ -1250,6 +1501,201 @@
1250
1501
  }
1251
1502
  ]
1252
1503
  },
1504
+ {
1505
+ "case": {
1506
+ "when": [
1507
+ [
1508
+ {
1509
+ "eq": [
1510
+ "decl.hasSetter",
1511
+ "true"
1512
+ ]
1513
+ },
1514
+ {
1515
+ "seq": [
1516
+ {
1517
+ "line": {
1518
+ "tmpl": [
1519
+ {
1520
+ "call": "csIndexerSig"
1521
+ },
1522
+ " {"
1523
+ ]
1524
+ }
1525
+ },
1526
+ {
1527
+ "indent": [
1528
+ {
1529
+ "case": {
1530
+ "when": [
1531
+ [
1532
+ {
1533
+ "eq": [
1534
+ "decl.exprBodied",
1535
+ "true"
1536
+ ]
1537
+ },
1538
+ {
1539
+ "line": {
1540
+ "tmpl": [
1541
+ "get => ",
1542
+ {
1543
+ "emit": "decl.exprBody"
1544
+ },
1545
+ ";"
1546
+ ]
1547
+ }
1548
+ }
1549
+ ]
1550
+ ],
1551
+ "else": {
1552
+ "seq": [
1553
+ {
1554
+ "line": "get {"
1555
+ },
1556
+ {
1557
+ "indent": [
1558
+ {
1559
+ "stmts": "decl.body"
1560
+ }
1561
+ ]
1562
+ },
1563
+ {
1564
+ "line": "}"
1565
+ }
1566
+ ]
1567
+ }
1568
+ }
1569
+ },
1570
+ {
1571
+ "line": "set {"
1572
+ },
1573
+ {
1574
+ "indent": [
1575
+ {
1576
+ "line": {
1577
+ "tmpl": [
1578
+ "var ",
1579
+ {
1580
+ "fn": "ident",
1581
+ "args": [
1582
+ {
1583
+ "get": "decl.setterValueParam"
1584
+ }
1585
+ ]
1586
+ },
1587
+ " = value;"
1588
+ ]
1589
+ }
1590
+ },
1591
+ {
1592
+ "stmts": "decl.setterBody"
1593
+ }
1594
+ ]
1595
+ },
1596
+ {
1597
+ "line": "}"
1598
+ }
1599
+ ]
1600
+ },
1601
+ {
1602
+ "line": "}"
1603
+ }
1604
+ ]
1605
+ }
1606
+ ]
1607
+ ],
1608
+ "else": {
1609
+ "case": {
1610
+ "when": [
1611
+ [
1612
+ {
1613
+ "eq": [
1614
+ "decl.exprBodied",
1615
+ "true"
1616
+ ]
1617
+ },
1618
+ {
1619
+ "line": {
1620
+ "tmpl": [
1621
+ {
1622
+ "call": "csIndexerSig"
1623
+ },
1624
+ " => ",
1625
+ {
1626
+ "emit": "decl.exprBody"
1627
+ },
1628
+ ";"
1629
+ ]
1630
+ }
1631
+ }
1632
+ ]
1633
+ ],
1634
+ "else": {
1635
+ "seq": [
1636
+ {
1637
+ "block": {
1638
+ "head": {
1639
+ "tmpl": [
1640
+ {
1641
+ "call": "csIndexerSig"
1642
+ },
1643
+ " { get"
1644
+ ]
1645
+ },
1646
+ "body": [
1647
+ {
1648
+ "stmts": "decl.body"
1649
+ }
1650
+ ]
1651
+ }
1652
+ },
1653
+ {
1654
+ "line": "}"
1655
+ }
1656
+ ]
1657
+ }
1658
+ }
1659
+ }
1660
+ }
1661
+ }
1662
+ ],
1663
+ [
1664
+ {
1665
+ "and": [
1666
+ {
1667
+ "eq": [
1668
+ "decl.kind",
1669
+ "operator"
1670
+ ]
1671
+ },
1672
+ {
1673
+ "eq": [
1674
+ "decl.opSymbol",
1675
+ "set"
1676
+ ]
1677
+ }
1678
+ ]
1679
+ },
1680
+ ""
1681
+ ],
1682
+ [
1683
+ {
1684
+ "and": [
1685
+ {
1686
+ "eq": [
1687
+ "decl.kind",
1688
+ "operator"
1689
+ ]
1690
+ },
1691
+ {
1692
+ "eq": [
1693
+ "decl.opSymbol",
1694
+ "=="
1695
+ ]
1696
+ }
1697
+ ]
1698
+ },
1253
1699
  {
1254
1700
  "case": {
1255
1701
  "when": [
@@ -1263,10 +1709,15 @@
1263
1709
  {
1264
1710
  "line": {
1265
1711
  "tmpl": [
1712
+ "public virtual bool Equals(",
1266
1713
  {
1267
- "call": "csIndexerSig"
1714
+ "map": "decl.params",
1715
+ "sep": ", ",
1716
+ "item": {
1717
+ "call": "csParam"
1718
+ }
1268
1719
  },
1269
- " => ",
1720
+ ") => ",
1270
1721
  {
1271
1722
  "emit": "decl.exprBody"
1272
1723
  },
@@ -1277,28 +1728,26 @@
1277
1728
  ]
1278
1729
  ],
1279
1730
  "else": {
1280
- "seq": [
1281
- {
1282
- "block": {
1283
- "head": {
1284
- "tmpl": [
1285
- {
1286
- "call": "csIndexerSig"
1287
- },
1288
- " { get"
1289
- ]
1290
- },
1291
- "body": [
1292
- {
1293
- "stmts": "decl.body"
1731
+ "block": {
1732
+ "head": {
1733
+ "tmpl": [
1734
+ "public virtual bool Equals(",
1735
+ {
1736
+ "map": "decl.params",
1737
+ "sep": ", ",
1738
+ "item": {
1739
+ "call": "csParam"
1294
1740
  }
1295
- ]
1296
- }
1741
+ },
1742
+ ")"
1743
+ ]
1297
1744
  },
1298
- {
1299
- "line": "}"
1300
- }
1301
- ]
1745
+ "body": [
1746
+ {
1747
+ "stmts": "decl.body"
1748
+ }
1749
+ ]
1750
+ }
1302
1751
  }
1303
1752
  }
1304
1753
  }
@@ -1639,67 +2088,114 @@
1639
2088
  ]
1640
2089
  },
1641
2090
  {
1642
- "block": {
1643
- "head": {
1644
- "tmpl": [
1645
- "for (var ",
1646
- {
1647
- "fn": "ident",
1648
- "args": [
1649
- {
1650
- "get": "stmt.binding"
1651
- }
1652
- ]
1653
- },
1654
- " = ",
1655
- {
1656
- "emit": "stmt.rangeStart"
1657
- },
1658
- "; ",
1659
- {
1660
- "fn": "ident",
1661
- "args": [
1662
- {
1663
- "get": "stmt.binding"
1664
- }
1665
- ]
1666
- },
2091
+ "case": {
2092
+ "when": [
2093
+ [
2094
+ { "eq": [ "stmt.captured", "true" ] },
1667
2095
  {
1668
- "case": {
1669
- "when": [
1670
- [
2096
+ "block": {
2097
+ "head": {
2098
+ "tmpl": [
2099
+ "for (var ",
2100
+ { "get": "stmt.driver" },
2101
+ " = ",
2102
+ { "emit": "stmt.rangeStart" },
2103
+ "; ",
2104
+ { "get": "stmt.driver" },
1671
2105
  {
1672
- "eq": [
1673
- "stmt.inclusive",
1674
- "true"
1675
- ]
2106
+ "case": {
2107
+ "when": [ [ { "eq": [ "stmt.inclusive", "true" ] }, " <= " ] ],
2108
+ "else": " < "
2109
+ }
1676
2110
  },
1677
- " <= "
2111
+ { "emit": "stmt.rangeEnd" },
2112
+ "; ",
2113
+ { "get": "stmt.driver" },
2114
+ "++)"
1678
2115
  ]
1679
- ],
1680
- "else": " < "
2116
+ },
2117
+ "body": [
2118
+ {
2119
+ "line": {
2120
+ "tmpl": [
2121
+ "var ",
2122
+ { "fn": "ident", "args": [ { "get": "stmt.binding" } ] },
2123
+ " = ",
2124
+ { "get": "stmt.driver" },
2125
+ ";"
2126
+ ]
2127
+ }
2128
+ },
2129
+ { "stmts": "stmt.body" }
2130
+ ]
1681
2131
  }
1682
- },
1683
- {
1684
- "emit": "stmt.rangeEnd"
1685
- },
1686
- "; ",
1687
- {
1688
- "fn": "ident",
1689
- "args": [
2132
+ }
2133
+ ]
2134
+ ],
2135
+ "else": {
2136
+ "block": {
2137
+ "head": {
2138
+ "tmpl": [
2139
+ "for (var ",
1690
2140
  {
1691
- "get": "stmt.binding"
1692
- }
2141
+ "fn": "ident",
2142
+ "args": [
2143
+ {
2144
+ "get": "stmt.binding"
2145
+ }
2146
+ ]
2147
+ },
2148
+ " = ",
2149
+ {
2150
+ "emit": "stmt.rangeStart"
2151
+ },
2152
+ "; ",
2153
+ {
2154
+ "fn": "ident",
2155
+ "args": [
2156
+ {
2157
+ "get": "stmt.binding"
2158
+ }
2159
+ ]
2160
+ },
2161
+ {
2162
+ "case": {
2163
+ "when": [
2164
+ [
2165
+ {
2166
+ "eq": [
2167
+ "stmt.inclusive",
2168
+ "true"
2169
+ ]
2170
+ },
2171
+ " <= "
2172
+ ]
2173
+ ],
2174
+ "else": " < "
2175
+ }
2176
+ },
2177
+ {
2178
+ "emit": "stmt.rangeEnd"
2179
+ },
2180
+ "; ",
2181
+ {
2182
+ "fn": "ident",
2183
+ "args": [
2184
+ {
2185
+ "get": "stmt.binding"
2186
+ }
2187
+ ]
2188
+ },
2189
+ "++)"
1693
2190
  ]
1694
2191
  },
1695
- "++)"
1696
- ]
1697
- },
1698
- "body": [
1699
- {
1700
- "stmts": "stmt.body"
2192
+ "body": [
2193
+ {
2194
+ "stmts": "stmt.body"
2195
+ }
2196
+ ]
1701
2197
  }
1702
- ]
2198
+ }
1703
2199
  }
1704
2200
  }
1705
2201
  ],