@mintplayer/polyglot-target-typescript 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 +437 -71
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/polyglot-target-typescript",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "description": "MintPlayer Polyglot TypeScript / JavaScript target — a pure-JSON language plugin (spec + emission rules + capabilities + std bindings) for the polyglot transpiler.",
5
5
  "keywords": [
6
6
  "polyglot",
@@ -308,7 +308,8 @@
308
308
  },
309
309
  ".get(",
310
310
  {
311
- "emit": "node.index"
311
+ "map": "node.indices",
312
+ "sep": ", "
312
313
  },
313
314
  ")"
314
315
  ]
@@ -330,6 +331,65 @@
330
331
  }
331
332
  }
332
333
  },
334
+ "IndexAssign": {
335
+ "line": {
336
+ "tmpl": [
337
+ {
338
+ "emitChild": "stmt.receiver",
339
+ "side": "recv"
340
+ },
341
+ ".set(",
342
+ {
343
+ "map": "stmt.indices",
344
+ "sep": ", "
345
+ },
346
+ ", ",
347
+ {
348
+ "emit": "stmt.value"
349
+ },
350
+ ");"
351
+ ]
352
+ }
353
+ },
354
+ "TupleLet": {
355
+ "line": {
356
+ "tmpl": [
357
+ {
358
+ "case": {
359
+ "when": [
360
+ [
361
+ {
362
+ "eq": [
363
+ "stmt.isMutable",
364
+ "true"
365
+ ]
366
+ },
367
+ "let ["
368
+ ]
369
+ ],
370
+ "else": "const ["
371
+ }
372
+ },
373
+ {
374
+ "map": "stmt.names",
375
+ "sep": ", ",
376
+ "item": {
377
+ "fn": "ident",
378
+ "args": [
379
+ {
380
+ "get": "item"
381
+ }
382
+ ]
383
+ }
384
+ },
385
+ "] = ",
386
+ {
387
+ "emit": "stmt.init"
388
+ },
389
+ ";"
390
+ ]
391
+ }
392
+ },
333
393
  "Cond": {
334
394
  "tmpl": [
335
395
  "(",
@@ -384,13 +444,36 @@
384
444
  ]
385
445
  },
386
446
  {
387
- "tmpl": [
388
- " as ",
389
- {
390
- "type": "node.elem"
391
- },
392
- "[]"
393
- ]
447
+ "case": {
448
+ "when": [
449
+ [
450
+ {
451
+ "eq": [
452
+ "node.elemIsFunction",
453
+ "true"
454
+ ]
455
+ },
456
+ {
457
+ "tmpl": [
458
+ " as (",
459
+ {
460
+ "type": "node.elem"
461
+ },
462
+ ")[]"
463
+ ]
464
+ }
465
+ ]
466
+ ],
467
+ "else": {
468
+ "tmpl": [
469
+ " as ",
470
+ {
471
+ "type": "node.elem"
472
+ },
473
+ "[]"
474
+ ]
475
+ }
476
+ }
394
477
  }
395
478
  ]
396
479
  ],
@@ -903,6 +986,34 @@
903
986
  "item": {
904
987
  "case": {
905
988
  "when": [
989
+ [
990
+ {
991
+ "eq": [
992
+ "item.pattern.kind",
993
+ "typeTest"
994
+ ]
995
+ },
996
+ {
997
+ "tmpl": [
998
+ "if (_m instanceof ",
999
+ { "type": "item.pattern.testType" },
1000
+ ") { const ",
1001
+ { "fn": "ident", "args": [ { "get": "item.pattern.binding" } ] },
1002
+ " = _m; ",
1003
+ {
1004
+ "case": {
1005
+ "when": [
1006
+ [
1007
+ { "eq": [ "item.hasGuard", "true" ] },
1008
+ { "tmpl": [ "if (", { "emit": "item.guard" }, ") return ", { "emit": "item.body" }, "; } " ] }
1009
+ ]
1010
+ ],
1011
+ "else": { "tmpl": [ "return ", { "emit": "item.body" }, "; } " ] }
1012
+ }
1013
+ }
1014
+ ]
1015
+ }
1016
+ ],
906
1017
  [
907
1018
  {
908
1019
  "eq": [
@@ -921,6 +1032,94 @@
921
1032
  }
922
1033
  ]
923
1034
  },
1035
+ {
1036
+ "map": "item.pattern.binders",
1037
+ "sep": "",
1038
+ "item": {
1039
+ "case": {
1040
+ "when": [
1041
+ [
1042
+ {
1043
+ "eq": [
1044
+ "item.isLiteral",
1045
+ "true"
1046
+ ]
1047
+ },
1048
+ {
1049
+ "tmpl": [
1050
+ " && _m.",
1051
+ {
1052
+ "fn": "ident",
1053
+ "args": [
1054
+ {
1055
+ "get": "item.field"
1056
+ }
1057
+ ]
1058
+ },
1059
+ " === ",
1060
+ {
1061
+ "emit": "item.literal"
1062
+ }
1063
+ ]
1064
+ }
1065
+ ]
1066
+ ],
1067
+ "else": ""
1068
+ }
1069
+ }
1070
+ },
1071
+ ") { ",
1072
+ {
1073
+ "map": "item.pattern.binders",
1074
+ "sep": "",
1075
+ "item": {
1076
+ "case": {
1077
+ "when": [
1078
+ [
1079
+ {
1080
+ "eq": [
1081
+ "item.isLiteral",
1082
+ "true"
1083
+ ]
1084
+ },
1085
+ ""
1086
+ ],
1087
+ [
1088
+ {
1089
+ "eq": [
1090
+ "item.isWildcard",
1091
+ "true"
1092
+ ]
1093
+ },
1094
+ ""
1095
+ ]
1096
+ ],
1097
+ "else": {
1098
+ "tmpl": [
1099
+ "const ",
1100
+ {
1101
+ "fn": "ident",
1102
+ "args": [
1103
+ {
1104
+ "get": "item.binding"
1105
+ }
1106
+ ]
1107
+ },
1108
+ " = _m.",
1109
+ {
1110
+ "fn": "ident",
1111
+ "args": [
1112
+ {
1113
+ "get": "item.field"
1114
+ }
1115
+ ]
1116
+ },
1117
+ "; "
1118
+ ]
1119
+ }
1120
+ }
1121
+ }
1122
+ },
924
1123
  {
925
1124
  "case": {
926
1125
  "when": [
@@ -933,51 +1132,30 @@
933
1132
  },
934
1133
  {
935
1134
  "tmpl": [
936
- " && (",
1135
+ "if (",
937
1136
  {
938
1137
  "emit": "item.guard"
939
1138
  },
940
- ")"
1139
+ ") return ",
1140
+ {
1141
+ "emit": "item.body"
1142
+ },
1143
+ "; } "
941
1144
  ]
942
1145
  }
943
1146
  ]
944
1147
  ],
945
- "else": ""
946
- }
947
- },
948
- ") { ",
949
- {
950
- "map": "item.pattern.binders",
951
- "sep": "",
952
- "item": {
953
- "tmpl": [
954
- "const ",
955
- {
956
- "fn": "ident",
957
- "args": [
958
- {
959
- "get": "item.binding"
960
- }
961
- ]
962
- },
963
- " = _m.",
964
- {
965
- "fn": "ident",
966
- "args": [
967
- {
968
- "get": "item.field"
969
- }
970
- ]
971
- },
972
- "; "
973
- ]
1148
+ "else": {
1149
+ "tmpl": [
1150
+ "return ",
1151
+ {
1152
+ "emit": "item.body"
1153
+ },
1154
+ "; } "
1155
+ ]
1156
+ }
974
1157
  }
975
- },
976
- "return ",
977
- {
978
- "emit": "item.body"
979
- },
980
- "; } "
1158
+ }
981
1159
  ]
982
1160
  }
983
1161
  ],
@@ -1336,6 +1514,21 @@
1336
1514
  ]
1337
1515
  }
1338
1516
  },
1517
+ {
1518
+ "case": {
1519
+ "when": [
1520
+ [
1521
+ {
1522
+ "eq": [
1523
+ "decl.isOverride",
1524
+ "true"
1525
+ ]
1526
+ },
1527
+ "override "
1528
+ ]
1529
+ ]
1530
+ }
1531
+ },
1339
1532
  {
1340
1533
  "case": {
1341
1534
  "when": [
@@ -1351,6 +1544,21 @@
1351
1544
  ]
1352
1545
  }
1353
1546
  },
1547
+ {
1548
+ "case": {
1549
+ "when": [
1550
+ [
1551
+ {
1552
+ "eq": [
1553
+ "decl.isIterator",
1554
+ "true"
1555
+ ]
1556
+ },
1557
+ "*"
1558
+ ]
1559
+ ]
1560
+ }
1561
+ },
1354
1562
  {
1355
1563
  "fn": "ident",
1356
1564
  "args": [
@@ -1410,38 +1618,59 @@
1410
1618
  ]
1411
1619
  },
1412
1620
  {
1413
- "block": {
1414
- "head": {
1415
- "tmpl": [
1416
- "get ",
1417
- {
1418
- "fn": "ident",
1419
- "args": [
1420
- {
1421
- "get": "decl.name"
1422
- }
1621
+ "seq": [
1622
+ {
1623
+ "block": {
1624
+ "head": {
1625
+ "tmpl": [
1626
+ "get ",
1627
+ { "fn": "ident", "args": [ { "get": "decl.name" } ] },
1628
+ "(): ",
1629
+ { "type": "decl.returnType" }
1423
1630
  ]
1424
1631
  },
1425
- "(): ",
1426
- {
1427
- "type": "decl.returnType"
1428
- }
1429
- ]
1632
+ "body": [
1633
+ {
1634
+ "case": {
1635
+ "when": [
1636
+ [
1637
+ { "eq": [ "decl.exprBodied", "true" ] },
1638
+ { "line": { "tmpl": [ "return ", { "emit": "decl.exprBody" }, ";" ] } }
1639
+ ]
1640
+ ],
1641
+ "else": { "stmts": "decl.body" }
1642
+ }
1643
+ }
1644
+ ]
1645
+ }
1430
1646
  },
1431
- "body": [
1432
- {
1433
- "line": {
1434
- "tmpl": [
1435
- "return ",
1647
+ {
1648
+ "case": {
1649
+ "when": [
1650
+ [
1651
+ { "eq": [ "decl.propHasSetter", "true" ] },
1436
1652
  {
1437
- "emit": "decl.exprBody"
1438
- },
1439
- ";"
1653
+ "block": {
1654
+ "head": {
1655
+ "tmpl": [
1656
+ "set ",
1657
+ { "fn": "ident", "args": [ { "get": "decl.name" } ] },
1658
+ "(",
1659
+ { "fn": "ident", "args": [ { "get": "decl.propSetterParam" } ] },
1660
+ ": ",
1661
+ { "type": "decl.returnType" },
1662
+ ")"
1663
+ ]
1664
+ },
1665
+ "body": [ { "stmts": "decl.propSetterBody" } ]
1666
+ }
1667
+ }
1440
1668
  ]
1441
- }
1669
+ ],
1670
+ "else": ""
1442
1671
  }
1443
- ]
1444
- }
1672
+ }
1673
+ ]
1445
1674
  }
1446
1675
  ]
1447
1676
  ],
@@ -3135,6 +3364,143 @@
3135
3364
  "Binary": {
3136
3365
  "case": {
3137
3366
  "when": [
3367
+ [
3368
+ {
3369
+ "and": [
3370
+ {
3371
+ "or": [
3372
+ {
3373
+ "eq": [
3374
+ "node.op",
3375
+ "=="
3376
+ ]
3377
+ },
3378
+ {
3379
+ "eq": [
3380
+ "node.op",
3381
+ "!="
3382
+ ]
3383
+ }
3384
+ ]
3385
+ },
3386
+ {
3387
+ "eq": [
3388
+ "node.lhsHasUserEq",
3389
+ "true"
3390
+ ]
3391
+ }
3392
+ ]
3393
+ },
3394
+ {
3395
+ "case": {
3396
+ "when": [
3397
+ [
3398
+ {
3399
+ "eq": [
3400
+ "node.op",
3401
+ "=="
3402
+ ]
3403
+ },
3404
+ {
3405
+ "tmpl": [
3406
+ {
3407
+ "emitChild": "node.lhs",
3408
+ "side": "recv"
3409
+ },
3410
+ ".eq(",
3411
+ {
3412
+ "emit": "node.rhs"
3413
+ },
3414
+ ")"
3415
+ ]
3416
+ }
3417
+ ]
3418
+ ],
3419
+ "else": {
3420
+ "tmpl": [
3421
+ "!",
3422
+ {
3423
+ "emitChild": "node.lhs",
3424
+ "side": "recv"
3425
+ },
3426
+ ".eq(",
3427
+ {
3428
+ "emit": "node.rhs"
3429
+ },
3430
+ ")"
3431
+ ]
3432
+ }
3433
+ }
3434
+ }
3435
+ ],
3436
+ [
3437
+ {
3438
+ "and": [
3439
+ {
3440
+ "or": [
3441
+ {
3442
+ "eq": [
3443
+ "node.op",
3444
+ "=="
3445
+ ]
3446
+ },
3447
+ {
3448
+ "eq": [
3449
+ "node.op",
3450
+ "!="
3451
+ ]
3452
+ }
3453
+ ]
3454
+ },
3455
+ {
3456
+ "eq": [
3457
+ "node.lhsIsUnion",
3458
+ "true"
3459
+ ]
3460
+ }
3461
+ ]
3462
+ },
3463
+ {
3464
+ "case": {
3465
+ "when": [
3466
+ [
3467
+ {
3468
+ "eq": [
3469
+ "node.op",
3470
+ "=="
3471
+ ]
3472
+ },
3473
+ {
3474
+ "tmpl": [
3475
+ "JSON.stringify(",
3476
+ {
3477
+ "emit": "node.lhs"
3478
+ },
3479
+ ") === JSON.stringify(",
3480
+ {
3481
+ "emit": "node.rhs"
3482
+ },
3483
+ ")"
3484
+ ]
3485
+ }
3486
+ ]
3487
+ ],
3488
+ "else": {
3489
+ "tmpl": [
3490
+ "JSON.stringify(",
3491
+ {
3492
+ "emit": "node.lhs"
3493
+ },
3494
+ ") !== JSON.stringify(",
3495
+ {
3496
+ "emit": "node.rhs"
3497
+ },
3498
+ ")"
3499
+ ]
3500
+ }
3501
+ }
3502
+ }
3503
+ ],
3138
3504
  [
3139
3505
  {
3140
3506
  "and": [