@mintplayer/polyglot-target-typescript 0.1.0

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 +23 -0
  2. package/polyglot-plugin.json +3294 -0
@@ -0,0 +1,3294 @@
1
+ {
2
+ "schema": 1,
3
+ "name": "typescript",
4
+ "capabilities": {},
5
+ "spec": {
6
+ "name": "typescript",
7
+ "scalarType": {
8
+ "unit": "void",
9
+ "bool": "boolean",
10
+ "string": "string",
11
+ "char": "string",
12
+ "i64": "bigint",
13
+ "u64": "bigint",
14
+ "i8": "number",
15
+ "i16": "number",
16
+ "i32": "number",
17
+ "u8": "number",
18
+ "u16": "number",
19
+ "u32": "number",
20
+ "f32": "number",
21
+ "f64": "number"
22
+ },
23
+ "intSuffix": {
24
+ "i64": "n",
25
+ "u64": "n"
26
+ },
27
+ "binaryOp": {
28
+ "==": "===",
29
+ "!=": "!=="
30
+ },
31
+ "delimited": {
32
+ "tuple": {
33
+ "open": "[",
34
+ "sep": ", ",
35
+ "close": "]"
36
+ },
37
+ "list": {
38
+ "open": "[",
39
+ "sep": ", ",
40
+ "close": "]"
41
+ }
42
+ },
43
+ "blockStyle": "bracesKnR",
44
+ "stmtEnd": ";",
45
+ "throwKeyword": "throw",
46
+ "trueLit": "true",
47
+ "falseLit": "false",
48
+ "nullLit": "null",
49
+ "identifiers": {
50
+ "reserved": [
51
+ "_m",
52
+ "__e",
53
+ "__handled",
54
+ "tag",
55
+ "equals",
56
+ "__opt*",
57
+ "__w*",
58
+ "case",
59
+ "debugger",
60
+ "default",
61
+ "delete",
62
+ "export",
63
+ "extends",
64
+ "function",
65
+ "implements",
66
+ "instanceof",
67
+ "new",
68
+ "package",
69
+ "protected",
70
+ "public",
71
+ "switch",
72
+ "typeof",
73
+ "void"
74
+ ],
75
+ "globals": [
76
+ "console"
77
+ ]
78
+ },
79
+ "rethrow": "throw __e;",
80
+ "tables": {
81
+ "opMethod": {
82
+ "+": "plus",
83
+ "-": "minus",
84
+ "*": "times",
85
+ "/": "div",
86
+ "%": "rem",
87
+ "==": "eq",
88
+ "<": "lt",
89
+ "<=": "le",
90
+ ">": "gt",
91
+ ">=": "ge"
92
+ },
93
+ "localDecl": {
94
+ "mutable": "let $x",
95
+ "const": "const $x"
96
+ },
97
+ "yield": {
98
+ "value": "yield $x;",
99
+ "empty": "return;"
100
+ },
101
+ "bigNarrow": {
102
+ "i8": "BigInt.asIntN(8, $x)",
103
+ "i16": "BigInt.asIntN(16, $x)",
104
+ "i32": "BigInt.asIntN(32, $x)",
105
+ "u8": "BigInt.asUintN(8, $x)",
106
+ "u16": "BigInt.asUintN(16, $x)",
107
+ "u32": "BigInt.asUintN(32, $x)"
108
+ }
109
+ },
110
+ "escapes": {
111
+ "interp": {
112
+ "`": "\\`",
113
+ "\\": "\\\\",
114
+ "${": "\\${"
115
+ }
116
+ },
117
+ "wrapInt": {
118
+ "i8": "($x << 24 >> 24)",
119
+ "i16": "($x << 16 >> 16)",
120
+ "u8": "($x & 0xff)",
121
+ "u16": "($x & 0xffff)",
122
+ "u32": "($x >>> 0)",
123
+ "i32": "($x | 0)",
124
+ "i64": "BigInt.asIntN(64, $x)",
125
+ "u64": "BigInt.asUintN(64, $x)"
126
+ },
127
+ "wrapAtom": {
128
+ "recv": [
129
+ "unary",
130
+ "binaryScalar"
131
+ ],
132
+ "unary": [
133
+ "binary"
134
+ ]
135
+ },
136
+ "generics": {
137
+ "style": "inlineBounds",
138
+ "boundsIntro": " extends ",
139
+ "boundsSep": " & ",
140
+ "erase": [
141
+ "INumber"
142
+ ]
143
+ }
144
+ },
145
+ "rules": {
146
+ "Int": {
147
+ "tmpl": [
148
+ {
149
+ "get": "node.text"
150
+ },
151
+ {
152
+ "fn": "intSuffix",
153
+ "args": [
154
+ {
155
+ "get": "node.type"
156
+ }
157
+ ]
158
+ }
159
+ ]
160
+ },
161
+ "Float": {
162
+ "get": "node.text"
163
+ },
164
+ "Bool": {
165
+ "case": {
166
+ "when": [
167
+ [
168
+ {
169
+ "eq": [
170
+ "node.value",
171
+ "true"
172
+ ]
173
+ },
174
+ {
175
+ "get": "spec.trueLit"
176
+ }
177
+ ]
178
+ ],
179
+ "else": {
180
+ "get": "spec.falseLit"
181
+ }
182
+ }
183
+ },
184
+ "Null": {
185
+ "get": "spec.nullLit"
186
+ },
187
+ "Str": {
188
+ "fn": "escapeString",
189
+ "args": [
190
+ {
191
+ "get": "node.value"
192
+ }
193
+ ]
194
+ },
195
+ "Char": {
196
+ "fn": "escapeString",
197
+ "args": [
198
+ {
199
+ "get": "node.value"
200
+ }
201
+ ]
202
+ },
203
+ "Var": {
204
+ "fn": "ident",
205
+ "args": [
206
+ {
207
+ "get": "node.name"
208
+ }
209
+ ]
210
+ },
211
+ "This": "this",
212
+ "Extern": {
213
+ "get": "node.code"
214
+ },
215
+ "Await": {
216
+ "tmpl": [
217
+ "await ",
218
+ {
219
+ "emitChild": "node.operand",
220
+ "side": "recv"
221
+ }
222
+ ]
223
+ },
224
+ "Call": {
225
+ "tmpl": [
226
+ {
227
+ "fn": "ident",
228
+ "args": [
229
+ {
230
+ "get": "node.mangledCallee"
231
+ }
232
+ ]
233
+ },
234
+ "(",
235
+ {
236
+ "map": "node.args",
237
+ "sep": ", "
238
+ },
239
+ ")"
240
+ ]
241
+ },
242
+ "Member": {
243
+ "tmpl": [
244
+ {
245
+ "case": {
246
+ "when": [
247
+ [
248
+ {
249
+ "has": "node.staticType"
250
+ },
251
+ {
252
+ "get": "node.staticType"
253
+ }
254
+ ]
255
+ ],
256
+ "else": {
257
+ "emitChild": "node.object",
258
+ "side": "recv"
259
+ }
260
+ }
261
+ },
262
+ {
263
+ "case": {
264
+ "when": [
265
+ [
266
+ {
267
+ "eq": [
268
+ "node.nullSafe",
269
+ "true"
270
+ ]
271
+ },
272
+ "?."
273
+ ]
274
+ ],
275
+ "else": "."
276
+ }
277
+ },
278
+ {
279
+ "fn": "ident",
280
+ "args": [
281
+ {
282
+ "get": "node.field"
283
+ }
284
+ ]
285
+ }
286
+ ]
287
+ },
288
+ "Index": {
289
+ "case": {
290
+ "when": [
291
+ [
292
+ {
293
+ "eq": [
294
+ "node.receiverHasIndexer",
295
+ "true"
296
+ ]
297
+ },
298
+ {
299
+ "tmpl": [
300
+ {
301
+ "emitChild": "node.receiver",
302
+ "side": "recv"
303
+ },
304
+ ".get(",
305
+ {
306
+ "emit": "node.index"
307
+ },
308
+ ")"
309
+ ]
310
+ }
311
+ ]
312
+ ],
313
+ "else": {
314
+ "tmpl": [
315
+ {
316
+ "emitChild": "node.receiver",
317
+ "side": "recv"
318
+ },
319
+ "[",
320
+ {
321
+ "emit": "node.index"
322
+ },
323
+ "]"
324
+ ]
325
+ }
326
+ }
327
+ },
328
+ "Cond": {
329
+ "tmpl": [
330
+ "(",
331
+ {
332
+ "emit": "node.cond"
333
+ },
334
+ " ? ",
335
+ {
336
+ "emit": "node.then"
337
+ },
338
+ " : ",
339
+ {
340
+ "emit": "node.els"
341
+ },
342
+ ")"
343
+ ]
344
+ },
345
+ "Tuple": {
346
+ "tmpl": [
347
+ {
348
+ "get": "spec.delimited.tuple.open"
349
+ },
350
+ {
351
+ "map": "node.elements",
352
+ "sep": ", "
353
+ },
354
+ {
355
+ "get": "spec.delimited.tuple.close"
356
+ }
357
+ ]
358
+ },
359
+ "ListLit": {
360
+ "tmpl": [
361
+ {
362
+ "get": "spec.delimited.list.open"
363
+ },
364
+ {
365
+ "map": "node.elements",
366
+ "sep": ", "
367
+ },
368
+ {
369
+ "get": "spec.delimited.list.close"
370
+ }
371
+ ]
372
+ },
373
+ "typeArgsSuffix": {
374
+ "case": {
375
+ "when": [
376
+ [
377
+ {
378
+ "eq": [
379
+ "node.typeArgs.count",
380
+ "0"
381
+ ]
382
+ },
383
+ ""
384
+ ]
385
+ ],
386
+ "else": {
387
+ "tmpl": [
388
+ "<",
389
+ {
390
+ "map": "node.typeArgs",
391
+ "sep": ", ",
392
+ "item": {
393
+ "type": "item"
394
+ }
395
+ },
396
+ ">"
397
+ ]
398
+ }
399
+ }
400
+ },
401
+ "New": {
402
+ "tmpl": [
403
+ "new ",
404
+ {
405
+ "fn": "ident",
406
+ "args": [
407
+ {
408
+ "get": "node.typeName"
409
+ }
410
+ ]
411
+ },
412
+ {
413
+ "call": "typeArgsSuffix"
414
+ },
415
+ "(",
416
+ {
417
+ "map": "node.args",
418
+ "sep": ", "
419
+ },
420
+ ")"
421
+ ]
422
+ },
423
+ "MakeCase": {
424
+ "tmpl": [
425
+ "{ tag: ",
426
+ {
427
+ "fn": "escapeString",
428
+ "args": [
429
+ {
430
+ "get": "node.caseName"
431
+ }
432
+ ]
433
+ },
434
+ {
435
+ "map": "node.fields",
436
+ "sep": "",
437
+ "item": {
438
+ "tmpl": [
439
+ ", ",
440
+ {
441
+ "fn": "ident",
442
+ "args": [
443
+ {
444
+ "get": "item.name"
445
+ }
446
+ ]
447
+ },
448
+ ": ",
449
+ {
450
+ "emit": "item.value"
451
+ }
452
+ ]
453
+ }
454
+ },
455
+ " }"
456
+ ]
457
+ },
458
+ "Unary": {
459
+ "case": {
460
+ "when": [
461
+ [
462
+ {
463
+ "and": [
464
+ {
465
+ "eq": [
466
+ "node.typeIsSmallInt",
467
+ "true"
468
+ ]
469
+ },
470
+ {
471
+ "eq": [
472
+ "node.op",
473
+ "-"
474
+ ]
475
+ }
476
+ ]
477
+ },
478
+ {
479
+ "fn": "wrap",
480
+ "args": [
481
+ {
482
+ "get": "node.type"
483
+ },
484
+ {
485
+ "tmpl": [
486
+ "-",
487
+ {
488
+ "emitChild": "node.operand",
489
+ "side": "unary"
490
+ }
491
+ ]
492
+ }
493
+ ]
494
+ }
495
+ ]
496
+ ],
497
+ "else": {
498
+ "tmpl": [
499
+ {
500
+ "get": "node.op"
501
+ },
502
+ {
503
+ "emitChild": "node.operand",
504
+ "side": "unary"
505
+ }
506
+ ]
507
+ }
508
+ }
509
+ },
510
+ "Cast": {
511
+ "case": {
512
+ "when": [
513
+ [
514
+ {
515
+ "eq": [
516
+ "node.castSame",
517
+ "true"
518
+ ]
519
+ },
520
+ {
521
+ "emit": "node.operand"
522
+ }
523
+ ],
524
+ [
525
+ {
526
+ "and": [
527
+ {
528
+ "eq": [
529
+ "node.typeIsInt64",
530
+ "true"
531
+ ]
532
+ },
533
+ {
534
+ "eq": [
535
+ "node.fromIsInt64",
536
+ "true"
537
+ ]
538
+ }
539
+ ]
540
+ },
541
+ {
542
+ "fn": "wrap",
543
+ "args": [
544
+ {
545
+ "get": "node.type"
546
+ },
547
+ {
548
+ "emit": "node.operand"
549
+ }
550
+ ]
551
+ }
552
+ ],
553
+ [
554
+ {
555
+ "and": [
556
+ {
557
+ "eq": [
558
+ "node.typeIsInt64",
559
+ "true"
560
+ ]
561
+ },
562
+ {
563
+ "eq": [
564
+ "node.fromIsFloat",
565
+ "true"
566
+ ]
567
+ }
568
+ ]
569
+ },
570
+ {
571
+ "tmpl": [
572
+ "BigInt(Math.trunc(",
573
+ {
574
+ "emit": "node.operand"
575
+ },
576
+ "))"
577
+ ]
578
+ }
579
+ ],
580
+ [
581
+ {
582
+ "eq": [
583
+ "node.typeIsInt64",
584
+ "true"
585
+ ]
586
+ },
587
+ {
588
+ "tmpl": [
589
+ "BigInt(",
590
+ {
591
+ "emit": "node.operand"
592
+ },
593
+ ")"
594
+ ]
595
+ }
596
+ ],
597
+ [
598
+ {
599
+ "and": [
600
+ {
601
+ "eq": [
602
+ "node.typeIsFloat",
603
+ "true"
604
+ ]
605
+ },
606
+ {
607
+ "eq": [
608
+ "node.fromIsInt64",
609
+ "true"
610
+ ]
611
+ }
612
+ ]
613
+ },
614
+ {
615
+ "tmpl": [
616
+ "Number(",
617
+ {
618
+ "emit": "node.operand"
619
+ },
620
+ ")"
621
+ ]
622
+ }
623
+ ],
624
+ [
625
+ {
626
+ "eq": [
627
+ "node.typeIsFloat",
628
+ "true"
629
+ ]
630
+ },
631
+ {
632
+ "emit": "node.operand"
633
+ }
634
+ ],
635
+ [
636
+ {
637
+ "eq": [
638
+ "node.fromIsInt64",
639
+ "true"
640
+ ]
641
+ },
642
+ {
643
+ "tmpl": [
644
+ "Number(",
645
+ {
646
+ "fn": "subst",
647
+ "args": [
648
+ "bigNarrow",
649
+ {
650
+ "get": "node.type"
651
+ },
652
+ {
653
+ "emit": "node.operand"
654
+ }
655
+ ]
656
+ },
657
+ ")"
658
+ ]
659
+ }
660
+ ],
661
+ [
662
+ {
663
+ "eq": [
664
+ "node.fromIsFloat",
665
+ "true"
666
+ ]
667
+ },
668
+ {
669
+ "fn": "wrap",
670
+ "args": [
671
+ {
672
+ "get": "node.type"
673
+ },
674
+ {
675
+ "tmpl": [
676
+ "Math.trunc(",
677
+ {
678
+ "emit": "node.operand"
679
+ },
680
+ ")"
681
+ ]
682
+ }
683
+ ]
684
+ }
685
+ ]
686
+ ],
687
+ "else": {
688
+ "fn": "wrap",
689
+ "args": [
690
+ {
691
+ "get": "node.type"
692
+ },
693
+ {
694
+ "emit": "node.operand"
695
+ }
696
+ ]
697
+ }
698
+ }
699
+ },
700
+ "With": {
701
+ "case": {
702
+ "when": [
703
+ [
704
+ {
705
+ "eq": [
706
+ "node.baseIsSimple",
707
+ "true"
708
+ ]
709
+ },
710
+ {
711
+ "tmpl": [
712
+ "new ",
713
+ {
714
+ "get": "node.type"
715
+ },
716
+ "(",
717
+ {
718
+ "map": "node.ctorArgs",
719
+ "sep": ", "
720
+ },
721
+ ")"
722
+ ]
723
+ }
724
+ ]
725
+ ],
726
+ "else": {
727
+ "tmpl": [
728
+ "(() => { const ",
729
+ {
730
+ "get": "node.tempName"
731
+ },
732
+ " = ",
733
+ {
734
+ "emit": "node.base"
735
+ },
736
+ "; return new ",
737
+ {
738
+ "get": "node.type"
739
+ },
740
+ "(",
741
+ {
742
+ "map": "node.ctorArgs",
743
+ "sep": ", "
744
+ },
745
+ "); })()"
746
+ ]
747
+ }
748
+ }
749
+ },
750
+ "Interp": {
751
+ "tmpl": [
752
+ "`",
753
+ {
754
+ "interleave": {
755
+ "lits": "node.chunks",
756
+ "holes": "node.holes",
757
+ "lit": {
758
+ "fn": "escape",
759
+ "args": [
760
+ "interp",
761
+ {
762
+ "get": "item"
763
+ }
764
+ ]
765
+ },
766
+ "hole": {
767
+ "tmpl": [
768
+ "${",
769
+ {
770
+ "emit": "item"
771
+ },
772
+ "}"
773
+ ]
774
+ }
775
+ }
776
+ },
777
+ "`"
778
+ ]
779
+ },
780
+ "MethodCall": {
781
+ "case": {
782
+ "when": [
783
+ [
784
+ {
785
+ "eq": [
786
+ "node.isExtension",
787
+ "true"
788
+ ]
789
+ },
790
+ {
791
+ "tmpl": [
792
+ {
793
+ "fn": "ident",
794
+ "args": [
795
+ {
796
+ "get": "node.method"
797
+ }
798
+ ]
799
+ },
800
+ "(",
801
+ {
802
+ "emit": "node.object"
803
+ },
804
+ {
805
+ "case": {
806
+ "when": [
807
+ [
808
+ {
809
+ "eq": [
810
+ "node.args.count",
811
+ "0"
812
+ ]
813
+ },
814
+ ""
815
+ ]
816
+ ],
817
+ "else": {
818
+ "tmpl": [
819
+ ", ",
820
+ {
821
+ "map": "node.args",
822
+ "sep": ", "
823
+ }
824
+ ]
825
+ }
826
+ }
827
+ },
828
+ ")"
829
+ ]
830
+ }
831
+ ]
832
+ ],
833
+ "else": {
834
+ "tmpl": [
835
+ {
836
+ "case": {
837
+ "when": [
838
+ [
839
+ {
840
+ "has": "node.staticType"
841
+ },
842
+ {
843
+ "get": "node.staticType"
844
+ }
845
+ ]
846
+ ],
847
+ "else": {
848
+ "emitChild": "node.object",
849
+ "side": "recv"
850
+ }
851
+ }
852
+ },
853
+ ".",
854
+ {
855
+ "fn": "ident",
856
+ "args": [
857
+ {
858
+ "get": "node.method"
859
+ }
860
+ ]
861
+ },
862
+ "(",
863
+ {
864
+ "map": "node.args",
865
+ "sep": ", "
866
+ },
867
+ ")"
868
+ ]
869
+ }
870
+ }
871
+ },
872
+ "Match": {
873
+ "tmpl": [
874
+ "(() => { const _m = ",
875
+ {
876
+ "emit": "node.scrutinee"
877
+ },
878
+ "; ",
879
+ {
880
+ "map": "node.arms",
881
+ "sep": "",
882
+ "item": {
883
+ "case": {
884
+ "when": [
885
+ [
886
+ {
887
+ "eq": [
888
+ "item.pattern.kind",
889
+ "ctor"
890
+ ]
891
+ },
892
+ {
893
+ "tmpl": [
894
+ "if (_m.tag === ",
895
+ {
896
+ "fn": "escapeString",
897
+ "args": [
898
+ {
899
+ "get": "item.pattern.ctorCase"
900
+ }
901
+ ]
902
+ },
903
+ {
904
+ "case": {
905
+ "when": [
906
+ [
907
+ {
908
+ "eq": [
909
+ "item.hasGuard",
910
+ "true"
911
+ ]
912
+ },
913
+ {
914
+ "tmpl": [
915
+ " && (",
916
+ {
917
+ "emit": "item.guard"
918
+ },
919
+ ")"
920
+ ]
921
+ }
922
+ ]
923
+ ],
924
+ "else": ""
925
+ }
926
+ },
927
+ ") { ",
928
+ {
929
+ "map": "item.pattern.binders",
930
+ "sep": "",
931
+ "item": {
932
+ "tmpl": [
933
+ "const ",
934
+ {
935
+ "fn": "ident",
936
+ "args": [
937
+ {
938
+ "get": "item.binding"
939
+ }
940
+ ]
941
+ },
942
+ " = _m.",
943
+ {
944
+ "fn": "ident",
945
+ "args": [
946
+ {
947
+ "get": "item.field"
948
+ }
949
+ ]
950
+ },
951
+ "; "
952
+ ]
953
+ }
954
+ },
955
+ "return ",
956
+ {
957
+ "emit": "item.body"
958
+ },
959
+ "; } "
960
+ ]
961
+ }
962
+ ],
963
+ [
964
+ {
965
+ "eq": [
966
+ "item.pattern.kind",
967
+ "binding"
968
+ ]
969
+ },
970
+ {
971
+ "tmpl": [
972
+ "{ const ",
973
+ {
974
+ "fn": "ident",
975
+ "args": [
976
+ {
977
+ "get": "item.pattern.binding"
978
+ }
979
+ ]
980
+ },
981
+ " = _m; ",
982
+ {
983
+ "case": {
984
+ "when": [
985
+ [
986
+ {
987
+ "eq": [
988
+ "item.hasGuard",
989
+ "true"
990
+ ]
991
+ },
992
+ {
993
+ "tmpl": [
994
+ "if (",
995
+ {
996
+ "emit": "item.guard"
997
+ },
998
+ ") return ",
999
+ {
1000
+ "emit": "item.body"
1001
+ },
1002
+ "; }"
1003
+ ]
1004
+ }
1005
+ ]
1006
+ ],
1007
+ "else": {
1008
+ "tmpl": [
1009
+ "return ",
1010
+ {
1011
+ "emit": "item.body"
1012
+ },
1013
+ "; }"
1014
+ ]
1015
+ }
1016
+ }
1017
+ },
1018
+ " "
1019
+ ]
1020
+ }
1021
+ ],
1022
+ [
1023
+ {
1024
+ "eq": [
1025
+ "item.pattern.kind",
1026
+ "wildcard"
1027
+ ]
1028
+ },
1029
+ {
1030
+ "case": {
1031
+ "when": [
1032
+ [
1033
+ {
1034
+ "eq": [
1035
+ "item.hasGuard",
1036
+ "true"
1037
+ ]
1038
+ },
1039
+ {
1040
+ "tmpl": [
1041
+ "if (",
1042
+ {
1043
+ "emit": "item.guard"
1044
+ },
1045
+ ") return ",
1046
+ {
1047
+ "emit": "item.body"
1048
+ },
1049
+ "; "
1050
+ ]
1051
+ }
1052
+ ]
1053
+ ],
1054
+ "else": {
1055
+ "tmpl": [
1056
+ "return ",
1057
+ {
1058
+ "emit": "item.body"
1059
+ },
1060
+ "; "
1061
+ ]
1062
+ }
1063
+ }
1064
+ }
1065
+ ]
1066
+ ],
1067
+ "else": {
1068
+ "tmpl": [
1069
+ "if (_m === ",
1070
+ {
1071
+ "case": {
1072
+ "when": [
1073
+ [
1074
+ {
1075
+ "eq": [
1076
+ "item.pattern.kind",
1077
+ "literal"
1078
+ ]
1079
+ },
1080
+ {
1081
+ "emit": "item.pattern.literal"
1082
+ }
1083
+ ]
1084
+ ],
1085
+ "else": {
1086
+ "tmpl": [
1087
+ {
1088
+ "get": "item.pattern.enumType"
1089
+ },
1090
+ ".",
1091
+ {
1092
+ "get": "item.pattern.enumCase"
1093
+ }
1094
+ ]
1095
+ }
1096
+ }
1097
+ },
1098
+ {
1099
+ "case": {
1100
+ "when": [
1101
+ [
1102
+ {
1103
+ "eq": [
1104
+ "item.hasGuard",
1105
+ "true"
1106
+ ]
1107
+ },
1108
+ {
1109
+ "tmpl": [
1110
+ " && (",
1111
+ {
1112
+ "emit": "item.guard"
1113
+ },
1114
+ ")"
1115
+ ]
1116
+ }
1117
+ ]
1118
+ ],
1119
+ "else": ""
1120
+ }
1121
+ },
1122
+ ") return ",
1123
+ {
1124
+ "emit": "item.body"
1125
+ },
1126
+ "; "
1127
+ ]
1128
+ }
1129
+ }
1130
+ }
1131
+ },
1132
+ "})()"
1133
+ ]
1134
+ },
1135
+ "Lambda": {
1136
+ "tmpl": [
1137
+ "(",
1138
+ {
1139
+ "map": "node.params",
1140
+ "sep": ", ",
1141
+ "item": {
1142
+ "tmpl": [
1143
+ {
1144
+ "fn": "ident",
1145
+ "args": [
1146
+ {
1147
+ "get": "item.name"
1148
+ }
1149
+ ]
1150
+ },
1151
+ {
1152
+ "case": {
1153
+ "when": [
1154
+ [
1155
+ {
1156
+ "eq": [
1157
+ "item.hasType",
1158
+ "true"
1159
+ ]
1160
+ },
1161
+ {
1162
+ "tmpl": [
1163
+ ": ",
1164
+ {
1165
+ "type": "item.type"
1166
+ }
1167
+ ]
1168
+ }
1169
+ ]
1170
+ ],
1171
+ "else": ""
1172
+ }
1173
+ }
1174
+ ]
1175
+ }
1176
+ },
1177
+ ") => ",
1178
+ {
1179
+ "case": {
1180
+ "when": [
1181
+ [
1182
+ {
1183
+ "eq": [
1184
+ "node.exprBodied",
1185
+ "true"
1186
+ ]
1187
+ },
1188
+ {
1189
+ "emit": "node.body"
1190
+ }
1191
+ ]
1192
+ ],
1193
+ "else": {
1194
+ "tmpl": [
1195
+ "{ ",
1196
+ {
1197
+ "fn": "inlineBlock"
1198
+ },
1199
+ "}"
1200
+ ]
1201
+ }
1202
+ }
1203
+ }
1204
+ ]
1205
+ },
1206
+ "EnumDecl": {
1207
+ "seq": [
1208
+ {
1209
+ "line": {
1210
+ "tmpl": [
1211
+ "type ",
1212
+ {
1213
+ "fn": "ident",
1214
+ "args": [
1215
+ {
1216
+ "get": "decl.name"
1217
+ }
1218
+ ]
1219
+ },
1220
+ " = number;"
1221
+ ]
1222
+ }
1223
+ },
1224
+ {
1225
+ "line": {
1226
+ "tmpl": [
1227
+ "const ",
1228
+ {
1229
+ "fn": "ident",
1230
+ "args": [
1231
+ {
1232
+ "get": "decl.name"
1233
+ }
1234
+ ]
1235
+ },
1236
+ " = { ",
1237
+ {
1238
+ "map": "decl.cases",
1239
+ "sep": ", ",
1240
+ "item": {
1241
+ "tmpl": [
1242
+ {
1243
+ "fn": "ident",
1244
+ "args": [
1245
+ {
1246
+ "get": "item.name"
1247
+ }
1248
+ ]
1249
+ },
1250
+ ": ",
1251
+ {
1252
+ "get": "item.value"
1253
+ }
1254
+ ]
1255
+ }
1256
+ },
1257
+ " };"
1258
+ ]
1259
+ }
1260
+ }
1261
+ ]
1262
+ },
1263
+ "tsParam": {
1264
+ "tmpl": [
1265
+ {
1266
+ "fn": "ident",
1267
+ "args": [
1268
+ {
1269
+ "get": "item.name"
1270
+ }
1271
+ ]
1272
+ },
1273
+ ": ",
1274
+ {
1275
+ "type": "item.type"
1276
+ },
1277
+ {
1278
+ "case": {
1279
+ "when": [
1280
+ [
1281
+ {
1282
+ "eq": [
1283
+ "item.hasDefault",
1284
+ "true"
1285
+ ]
1286
+ },
1287
+ {
1288
+ "tmpl": [
1289
+ " = ",
1290
+ {
1291
+ "emit": "item.default"
1292
+ }
1293
+ ]
1294
+ }
1295
+ ]
1296
+ ]
1297
+ }
1298
+ }
1299
+ ]
1300
+ },
1301
+ "tsMethodSig": {
1302
+ "tmpl": [
1303
+ {
1304
+ "case": {
1305
+ "when": [
1306
+ [
1307
+ {
1308
+ "eq": [
1309
+ "decl.isStatic",
1310
+ "true"
1311
+ ]
1312
+ },
1313
+ "static "
1314
+ ]
1315
+ ]
1316
+ }
1317
+ },
1318
+ {
1319
+ "case": {
1320
+ "when": [
1321
+ [
1322
+ {
1323
+ "eq": [
1324
+ "decl.isAsync",
1325
+ "true"
1326
+ ]
1327
+ },
1328
+ "async "
1329
+ ]
1330
+ ]
1331
+ }
1332
+ },
1333
+ {
1334
+ "fn": "ident",
1335
+ "args": [
1336
+ {
1337
+ "get": "decl.name"
1338
+ }
1339
+ ]
1340
+ },
1341
+ {
1342
+ "fn": "generics"
1343
+ },
1344
+ "(",
1345
+ {
1346
+ "map": "decl.params",
1347
+ "sep": ", ",
1348
+ "item": {
1349
+ "call": "tsParam"
1350
+ }
1351
+ },
1352
+ "): ",
1353
+ {
1354
+ "case": {
1355
+ "when": [
1356
+ [
1357
+ {
1358
+ "eq": [
1359
+ "decl.isAsync",
1360
+ "true"
1361
+ ]
1362
+ },
1363
+ {
1364
+ "tmpl": [
1365
+ "Promise<",
1366
+ {
1367
+ "type": "decl.returnType"
1368
+ },
1369
+ ">"
1370
+ ]
1371
+ }
1372
+ ]
1373
+ ],
1374
+ "else": {
1375
+ "type": "decl.returnType"
1376
+ }
1377
+ }
1378
+ }
1379
+ ]
1380
+ },
1381
+ "MethodDecl": {
1382
+ "case": {
1383
+ "when": [
1384
+ [
1385
+ {
1386
+ "eq": [
1387
+ "decl.kind",
1388
+ "property"
1389
+ ]
1390
+ },
1391
+ {
1392
+ "block": {
1393
+ "head": {
1394
+ "tmpl": [
1395
+ "get ",
1396
+ {
1397
+ "fn": "ident",
1398
+ "args": [
1399
+ {
1400
+ "get": "decl.name"
1401
+ }
1402
+ ]
1403
+ },
1404
+ "(): ",
1405
+ {
1406
+ "type": "decl.returnType"
1407
+ }
1408
+ ]
1409
+ },
1410
+ "body": [
1411
+ {
1412
+ "line": {
1413
+ "tmpl": [
1414
+ "return ",
1415
+ {
1416
+ "emit": "decl.exprBody"
1417
+ },
1418
+ ";"
1419
+ ]
1420
+ }
1421
+ }
1422
+ ]
1423
+ }
1424
+ }
1425
+ ]
1426
+ ],
1427
+ "else": {
1428
+ "block": {
1429
+ "head": {
1430
+ "call": "tsMethodSig"
1431
+ },
1432
+ "body": [
1433
+ {
1434
+ "case": {
1435
+ "when": [
1436
+ [
1437
+ {
1438
+ "eq": [
1439
+ "decl.exprBodied",
1440
+ "true"
1441
+ ]
1442
+ },
1443
+ {
1444
+ "line": {
1445
+ "tmpl": [
1446
+ "return ",
1447
+ {
1448
+ "emit": "decl.exprBody"
1449
+ },
1450
+ ";"
1451
+ ]
1452
+ }
1453
+ }
1454
+ ]
1455
+ ],
1456
+ "else": {
1457
+ "stmts": "decl.body"
1458
+ }
1459
+ }
1460
+ }
1461
+ ]
1462
+ }
1463
+ }
1464
+ }
1465
+ },
1466
+ "tsRecordHead": {
1467
+ "tmpl": [
1468
+ "class ",
1469
+ {
1470
+ "fn": "ident",
1471
+ "args": [
1472
+ {
1473
+ "get": "decl.name"
1474
+ }
1475
+ ]
1476
+ },
1477
+ {
1478
+ "fn": "generics"
1479
+ },
1480
+ {
1481
+ "case": {
1482
+ "when": [
1483
+ [
1484
+ {
1485
+ "eq": [
1486
+ "decl.bases.count",
1487
+ "0"
1488
+ ]
1489
+ },
1490
+ ""
1491
+ ]
1492
+ ],
1493
+ "else": {
1494
+ "tmpl": [
1495
+ " implements ",
1496
+ {
1497
+ "map": "decl.bases",
1498
+ "sep": ", ",
1499
+ "item": {
1500
+ "type": "item"
1501
+ }
1502
+ }
1503
+ ]
1504
+ }
1505
+ }
1506
+ }
1507
+ ]
1508
+ },
1509
+ "RecordDecl": {
1510
+ "block": {
1511
+ "head": {
1512
+ "call": "tsRecordHead"
1513
+ },
1514
+ "body": [
1515
+ {
1516
+ "mapDecl": "decl.fields",
1517
+ "each": {
1518
+ "line": {
1519
+ "tmpl": [
1520
+ {
1521
+ "fn": "ident",
1522
+ "args": [
1523
+ {
1524
+ "get": "item.name"
1525
+ }
1526
+ ]
1527
+ },
1528
+ ": ",
1529
+ {
1530
+ "type": "item.type"
1531
+ },
1532
+ ";"
1533
+ ]
1534
+ }
1535
+ }
1536
+ },
1537
+ {
1538
+ "block": {
1539
+ "head": {
1540
+ "tmpl": [
1541
+ "constructor(",
1542
+ {
1543
+ "map": "decl.fields",
1544
+ "sep": ", ",
1545
+ "item": {
1546
+ "tmpl": [
1547
+ {
1548
+ "fn": "ident",
1549
+ "args": [
1550
+ {
1551
+ "get": "item.name"
1552
+ }
1553
+ ]
1554
+ },
1555
+ ": ",
1556
+ {
1557
+ "type": "item.type"
1558
+ }
1559
+ ]
1560
+ }
1561
+ },
1562
+ ")"
1563
+ ]
1564
+ },
1565
+ "body": [
1566
+ {
1567
+ "mapDecl": "decl.fields",
1568
+ "each": {
1569
+ "line": {
1570
+ "tmpl": [
1571
+ "this.",
1572
+ {
1573
+ "fn": "ident",
1574
+ "args": [
1575
+ {
1576
+ "get": "item.name"
1577
+ }
1578
+ ]
1579
+ },
1580
+ " = ",
1581
+ {
1582
+ "fn": "ident",
1583
+ "args": [
1584
+ {
1585
+ "get": "item.name"
1586
+ }
1587
+ ]
1588
+ },
1589
+ ";"
1590
+ ]
1591
+ }
1592
+ }
1593
+ }
1594
+ ]
1595
+ }
1596
+ },
1597
+ {
1598
+ "block": {
1599
+ "head": {
1600
+ "tmpl": [
1601
+ "equals(other: ",
1602
+ {
1603
+ "fn": "ident",
1604
+ "args": [
1605
+ {
1606
+ "get": "decl.name"
1607
+ }
1608
+ ]
1609
+ },
1610
+ "): boolean"
1611
+ ]
1612
+ },
1613
+ "body": [
1614
+ {
1615
+ "case": {
1616
+ "when": [
1617
+ [
1618
+ {
1619
+ "eq": [
1620
+ "decl.fields.count",
1621
+ "0"
1622
+ ]
1623
+ },
1624
+ {
1625
+ "line": "return true;"
1626
+ }
1627
+ ]
1628
+ ],
1629
+ "else": {
1630
+ "line": {
1631
+ "tmpl": [
1632
+ "return ",
1633
+ {
1634
+ "map": "decl.fields",
1635
+ "sep": " && ",
1636
+ "item": {
1637
+ "case": {
1638
+ "when": [
1639
+ [
1640
+ {
1641
+ "eq": [
1642
+ "item.typeIsRecord",
1643
+ "true"
1644
+ ]
1645
+ },
1646
+ {
1647
+ "tmpl": [
1648
+ "this.",
1649
+ {
1650
+ "fn": "ident",
1651
+ "args": [
1652
+ {
1653
+ "get": "item.name"
1654
+ }
1655
+ ]
1656
+ },
1657
+ ".equals(other.",
1658
+ {
1659
+ "fn": "ident",
1660
+ "args": [
1661
+ {
1662
+ "get": "item.name"
1663
+ }
1664
+ ]
1665
+ },
1666
+ ")"
1667
+ ]
1668
+ }
1669
+ ]
1670
+ ],
1671
+ "else": {
1672
+ "tmpl": [
1673
+ "this.",
1674
+ {
1675
+ "fn": "ident",
1676
+ "args": [
1677
+ {
1678
+ "get": "item.name"
1679
+ }
1680
+ ]
1681
+ },
1682
+ " === other.",
1683
+ {
1684
+ "fn": "ident",
1685
+ "args": [
1686
+ {
1687
+ "get": "item.name"
1688
+ }
1689
+ ]
1690
+ }
1691
+ ]
1692
+ }
1693
+ }
1694
+ }
1695
+ },
1696
+ ";"
1697
+ ]
1698
+ }
1699
+ }
1700
+ }
1701
+ }
1702
+ ]
1703
+ }
1704
+ },
1705
+ {
1706
+ "mapMembers": "decl.methods",
1707
+ "rule": "MethodDecl"
1708
+ }
1709
+ ]
1710
+ }
1711
+ },
1712
+ "TryStmt": {
1713
+ "seq": [
1714
+ {
1715
+ "line": "try {"
1716
+ },
1717
+ {
1718
+ "indent": [
1719
+ {
1720
+ "stmts": "stmt.body"
1721
+ }
1722
+ ]
1723
+ },
1724
+ {
1725
+ "case": {
1726
+ "when": [
1727
+ [
1728
+ {
1729
+ "not": {
1730
+ "eq": [
1731
+ "stmt.catches.count",
1732
+ "0"
1733
+ ]
1734
+ }
1735
+ },
1736
+ {
1737
+ "seq": [
1738
+ {
1739
+ "line": "} catch (__e) {"
1740
+ },
1741
+ {
1742
+ "indent": [
1743
+ {
1744
+ "line": "let __handled = false;"
1745
+ },
1746
+ {
1747
+ "mapDecl": "stmt.catches",
1748
+ "each": {
1749
+ "seq": [
1750
+ {
1751
+ "line": {
1752
+ "tmpl": [
1753
+ "if (!__handled",
1754
+ {
1755
+ "case": {
1756
+ "when": [
1757
+ [
1758
+ {
1759
+ "eq": [
1760
+ "item.hasType",
1761
+ "true"
1762
+ ]
1763
+ },
1764
+ {
1765
+ "tmpl": [
1766
+ " && __e instanceof ",
1767
+ {
1768
+ "type": "item.type"
1769
+ }
1770
+ ]
1771
+ }
1772
+ ]
1773
+ ]
1774
+ }
1775
+ },
1776
+ ") {"
1777
+ ]
1778
+ }
1779
+ },
1780
+ {
1781
+ "indent": [
1782
+ {
1783
+ "case": {
1784
+ "when": [
1785
+ [
1786
+ {
1787
+ "eq": [
1788
+ "item.hasBinding",
1789
+ "true"
1790
+ ]
1791
+ },
1792
+ {
1793
+ "line": {
1794
+ "tmpl": [
1795
+ "const ",
1796
+ {
1797
+ "fn": "ident",
1798
+ "args": [
1799
+ {
1800
+ "get": "item.binding"
1801
+ }
1802
+ ]
1803
+ },
1804
+ " = __e;"
1805
+ ]
1806
+ }
1807
+ }
1808
+ ]
1809
+ ]
1810
+ }
1811
+ },
1812
+ {
1813
+ "case": {
1814
+ "when": [
1815
+ [
1816
+ {
1817
+ "eq": [
1818
+ "item.hasGuard",
1819
+ "true"
1820
+ ]
1821
+ },
1822
+ {
1823
+ "seq": [
1824
+ {
1825
+ "line": {
1826
+ "tmpl": [
1827
+ "if (",
1828
+ {
1829
+ "emit": "item.guard"
1830
+ },
1831
+ ") {"
1832
+ ]
1833
+ }
1834
+ },
1835
+ {
1836
+ "indent": [
1837
+ {
1838
+ "line": "__handled = true;"
1839
+ },
1840
+ {
1841
+ "stmts": "item.body"
1842
+ }
1843
+ ]
1844
+ },
1845
+ {
1846
+ "line": "}"
1847
+ }
1848
+ ]
1849
+ }
1850
+ ]
1851
+ ],
1852
+ "else": {
1853
+ "seq": [
1854
+ {
1855
+ "line": "__handled = true;"
1856
+ },
1857
+ {
1858
+ "stmts": "item.body"
1859
+ }
1860
+ ]
1861
+ }
1862
+ }
1863
+ }
1864
+ ]
1865
+ },
1866
+ {
1867
+ "line": "}"
1868
+ }
1869
+ ]
1870
+ }
1871
+ },
1872
+ {
1873
+ "case": {
1874
+ "when": [
1875
+ [
1876
+ {
1877
+ "eq": [
1878
+ "stmt.hasCatchAll",
1879
+ "false"
1880
+ ]
1881
+ },
1882
+ {
1883
+ "line": "if (!__handled) { throw __e; }"
1884
+ }
1885
+ ]
1886
+ ]
1887
+ }
1888
+ }
1889
+ ]
1890
+ }
1891
+ ]
1892
+ }
1893
+ ]
1894
+ ]
1895
+ }
1896
+ },
1897
+ {
1898
+ "case": {
1899
+ "when": [
1900
+ [
1901
+ {
1902
+ "eq": [
1903
+ "stmt.hasFinally",
1904
+ "true"
1905
+ ]
1906
+ },
1907
+ {
1908
+ "seq": [
1909
+ {
1910
+ "line": "} finally {"
1911
+ },
1912
+ {
1913
+ "indent": [
1914
+ {
1915
+ "stmts": "stmt.finallyBody"
1916
+ }
1917
+ ]
1918
+ }
1919
+ ]
1920
+ }
1921
+ ]
1922
+ ]
1923
+ }
1924
+ },
1925
+ {
1926
+ "line": "}"
1927
+ }
1928
+ ]
1929
+ },
1930
+ "ForStmt": {
1931
+ "case": {
1932
+ "when": [
1933
+ [
1934
+ {
1935
+ "eq": [
1936
+ "stmt.isRange",
1937
+ "true"
1938
+ ]
1939
+ },
1940
+ {
1941
+ "block": {
1942
+ "head": {
1943
+ "tmpl": [
1944
+ "for (let ",
1945
+ {
1946
+ "fn": "ident",
1947
+ "args": [
1948
+ {
1949
+ "get": "stmt.binding"
1950
+ }
1951
+ ]
1952
+ },
1953
+ " = ",
1954
+ {
1955
+ "emit": "stmt.rangeStart"
1956
+ },
1957
+ "; ",
1958
+ {
1959
+ "fn": "ident",
1960
+ "args": [
1961
+ {
1962
+ "get": "stmt.binding"
1963
+ }
1964
+ ]
1965
+ },
1966
+ {
1967
+ "case": {
1968
+ "when": [
1969
+ [
1970
+ {
1971
+ "eq": [
1972
+ "stmt.inclusive",
1973
+ "true"
1974
+ ]
1975
+ },
1976
+ " <= "
1977
+ ]
1978
+ ],
1979
+ "else": " < "
1980
+ }
1981
+ },
1982
+ {
1983
+ "emit": "stmt.rangeEnd"
1984
+ },
1985
+ "; ",
1986
+ {
1987
+ "fn": "ident",
1988
+ "args": [
1989
+ {
1990
+ "get": "stmt.binding"
1991
+ }
1992
+ ]
1993
+ },
1994
+ "++)"
1995
+ ]
1996
+ },
1997
+ "body": [
1998
+ {
1999
+ "stmts": "stmt.body"
2000
+ }
2001
+ ]
2002
+ }
2003
+ }
2004
+ ],
2005
+ [
2006
+ {
2007
+ "not": {
2008
+ "eq": [
2009
+ "stmt.tupleBindings.count",
2010
+ "0"
2011
+ ]
2012
+ }
2013
+ },
2014
+ {
2015
+ "block": {
2016
+ "head": {
2017
+ "tmpl": [
2018
+ "for (const [",
2019
+ {
2020
+ "map": "stmt.tupleBindings",
2021
+ "sep": ", ",
2022
+ "item": {
2023
+ "get": "item"
2024
+ }
2025
+ },
2026
+ "] of ",
2027
+ {
2028
+ "emit": "stmt.iterable"
2029
+ },
2030
+ ")"
2031
+ ]
2032
+ },
2033
+ "body": [
2034
+ {
2035
+ "stmts": "stmt.body"
2036
+ }
2037
+ ]
2038
+ }
2039
+ }
2040
+ ]
2041
+ ],
2042
+ "else": {
2043
+ "block": {
2044
+ "head": {
2045
+ "tmpl": [
2046
+ "for (const ",
2047
+ {
2048
+ "fn": "ident",
2049
+ "args": [
2050
+ {
2051
+ "get": "stmt.binding"
2052
+ }
2053
+ ]
2054
+ },
2055
+ " of ",
2056
+ {
2057
+ "emit": "stmt.iterable"
2058
+ },
2059
+ ")"
2060
+ ]
2061
+ },
2062
+ "body": [
2063
+ {
2064
+ "stmts": "stmt.body"
2065
+ }
2066
+ ]
2067
+ }
2068
+ }
2069
+ }
2070
+ },
2071
+ "Program": {
2072
+ "seq": [
2073
+ {
2074
+ "mapMembers": "module.enums",
2075
+ "rule": "EnumDecl"
2076
+ },
2077
+ {
2078
+ "mapMembers": "module.interfaces",
2079
+ "rule": "InterfaceDecl"
2080
+ },
2081
+ {
2082
+ "mapMembers": "module.unions",
2083
+ "rule": "UnionDecl"
2084
+ },
2085
+ {
2086
+ "mapMembers": "module.records",
2087
+ "rule": "RecordDecl"
2088
+ },
2089
+ {
2090
+ "mapMembers": "module.classes",
2091
+ "rule": "ClassDecl"
2092
+ },
2093
+ {
2094
+ "mapDecl": "module.globals",
2095
+ "each": {
2096
+ "line": {
2097
+ "tmpl": [
2098
+ {
2099
+ "case": {
2100
+ "when": [
2101
+ [
2102
+ {
2103
+ "eq": [
2104
+ "item.isConst",
2105
+ "true"
2106
+ ]
2107
+ },
2108
+ "const "
2109
+ ]
2110
+ ],
2111
+ "else": "let "
2112
+ }
2113
+ },
2114
+ {
2115
+ "fn": "ident",
2116
+ "args": [
2117
+ {
2118
+ "get": "item.name"
2119
+ }
2120
+ ]
2121
+ },
2122
+ ": ",
2123
+ {
2124
+ "type": "item.type"
2125
+ },
2126
+ {
2127
+ "case": {
2128
+ "when": [
2129
+ [
2130
+ {
2131
+ "eq": [
2132
+ "item.hasInit",
2133
+ "true"
2134
+ ]
2135
+ },
2136
+ {
2137
+ "tmpl": [
2138
+ " = ",
2139
+ {
2140
+ "emit": "item.init"
2141
+ }
2142
+ ]
2143
+ }
2144
+ ]
2145
+ ]
2146
+ }
2147
+ },
2148
+ ";"
2149
+ ]
2150
+ }
2151
+ }
2152
+ },
2153
+ {
2154
+ "mapMembers": "module.extensions",
2155
+ "rule": "ExtensionDecl"
2156
+ },
2157
+ {
2158
+ "mapMembers": "module.functions",
2159
+ "rule": "FunctionDecl"
2160
+ },
2161
+ {
2162
+ "case": {
2163
+ "when": [
2164
+ [
2165
+ {
2166
+ "eq": [
2167
+ "module.hasEntry",
2168
+ "true"
2169
+ ]
2170
+ },
2171
+ {
2172
+ "line": {
2173
+ "tmpl": [
2174
+ {
2175
+ "get": "module.entry.mangledName"
2176
+ },
2177
+ "();"
2178
+ ]
2179
+ }
2180
+ }
2181
+ ]
2182
+ ]
2183
+ }
2184
+ }
2185
+ ]
2186
+ },
2187
+ "tsFnSig": {
2188
+ "tmpl": [
2189
+ {
2190
+ "case": {
2191
+ "when": [
2192
+ [
2193
+ {
2194
+ "eq": [
2195
+ "decl.isAsync",
2196
+ "true"
2197
+ ]
2198
+ },
2199
+ "async function "
2200
+ ],
2201
+ [
2202
+ {
2203
+ "eq": [
2204
+ "decl.isIterator",
2205
+ "true"
2206
+ ]
2207
+ },
2208
+ "function* "
2209
+ ]
2210
+ ],
2211
+ "else": "function "
2212
+ }
2213
+ },
2214
+ {
2215
+ "get": "decl.mangledName"
2216
+ },
2217
+ {
2218
+ "fn": "generics"
2219
+ },
2220
+ "(",
2221
+ {
2222
+ "map": "decl.params",
2223
+ "sep": ", ",
2224
+ "item": {
2225
+ "call": "tsParam"
2226
+ }
2227
+ },
2228
+ "): ",
2229
+ {
2230
+ "case": {
2231
+ "when": [
2232
+ [
2233
+ {
2234
+ "eq": [
2235
+ "decl.isAsync",
2236
+ "true"
2237
+ ]
2238
+ },
2239
+ {
2240
+ "tmpl": [
2241
+ "Promise<",
2242
+ {
2243
+ "type": "decl.returnType"
2244
+ },
2245
+ ">"
2246
+ ]
2247
+ }
2248
+ ]
2249
+ ],
2250
+ "else": {
2251
+ "type": "decl.returnType"
2252
+ }
2253
+ }
2254
+ }
2255
+ ]
2256
+ },
2257
+ "FunctionDecl": {
2258
+ "block": {
2259
+ "head": {
2260
+ "call": "tsFnSig"
2261
+ },
2262
+ "body": [
2263
+ {
2264
+ "stmts": "decl.body"
2265
+ }
2266
+ ]
2267
+ }
2268
+ },
2269
+ "tsExtSig": {
2270
+ "tmpl": [
2271
+ "function ",
2272
+ {
2273
+ "fn": "ident",
2274
+ "args": [
2275
+ {
2276
+ "get": "decl.name"
2277
+ }
2278
+ ]
2279
+ },
2280
+ {
2281
+ "fn": "generics"
2282
+ },
2283
+ "(",
2284
+ {
2285
+ "map": "decl.params",
2286
+ "sep": ", ",
2287
+ "item": {
2288
+ "call": "tsParam"
2289
+ }
2290
+ },
2291
+ "): ",
2292
+ {
2293
+ "type": "decl.returnType"
2294
+ }
2295
+ ]
2296
+ },
2297
+ "ExtensionDecl": {
2298
+ "block": {
2299
+ "head": {
2300
+ "call": "tsExtSig"
2301
+ },
2302
+ "body": [
2303
+ {
2304
+ "case": {
2305
+ "when": [
2306
+ [
2307
+ {
2308
+ "eq": [
2309
+ "decl.exprBodied",
2310
+ "true"
2311
+ ]
2312
+ },
2313
+ {
2314
+ "line": {
2315
+ "tmpl": [
2316
+ "return ",
2317
+ {
2318
+ "emit": "decl.exprBody"
2319
+ },
2320
+ ";"
2321
+ ]
2322
+ }
2323
+ }
2324
+ ]
2325
+ ],
2326
+ "else": {
2327
+ "stmts": "decl.body"
2328
+ }
2329
+ }
2330
+ }
2331
+ ]
2332
+ }
2333
+ },
2334
+ "tsClassHead": {
2335
+ "tmpl": [
2336
+ "class ",
2337
+ {
2338
+ "fn": "ident",
2339
+ "args": [
2340
+ {
2341
+ "get": "decl.name"
2342
+ }
2343
+ ]
2344
+ },
2345
+ {
2346
+ "fn": "generics"
2347
+ },
2348
+ {
2349
+ "case": {
2350
+ "when": [
2351
+ [
2352
+ {
2353
+ "eq": [
2354
+ "decl.hasExtBase",
2355
+ "true"
2356
+ ]
2357
+ },
2358
+ {
2359
+ "tmpl": [
2360
+ " extends ",
2361
+ {
2362
+ "type": "decl.extBase"
2363
+ }
2364
+ ]
2365
+ }
2366
+ ]
2367
+ ]
2368
+ }
2369
+ },
2370
+ {
2371
+ "case": {
2372
+ "when": [
2373
+ [
2374
+ {
2375
+ "eq": [
2376
+ "decl.ifaceBases.count",
2377
+ "0"
2378
+ ]
2379
+ },
2380
+ ""
2381
+ ]
2382
+ ],
2383
+ "else": {
2384
+ "tmpl": [
2385
+ " implements ",
2386
+ {
2387
+ "map": "decl.ifaceBases",
2388
+ "sep": ", ",
2389
+ "item": {
2390
+ "type": "item"
2391
+ }
2392
+ }
2393
+ ]
2394
+ }
2395
+ }
2396
+ }
2397
+ ]
2398
+ },
2399
+ "ClassDecl": {
2400
+ "block": {
2401
+ "head": {
2402
+ "call": "tsClassHead"
2403
+ },
2404
+ "body": [
2405
+ {
2406
+ "mapDecl": "decl.fields",
2407
+ "each": {
2408
+ "line": {
2409
+ "tmpl": [
2410
+ {
2411
+ "case": {
2412
+ "when": [
2413
+ [
2414
+ {
2415
+ "and": [
2416
+ {
2417
+ "eq": [
2418
+ "item.isStatic",
2419
+ "true"
2420
+ ]
2421
+ },
2422
+ {
2423
+ "eq": [
2424
+ "item.isMutable",
2425
+ "true"
2426
+ ]
2427
+ }
2428
+ ]
2429
+ },
2430
+ "static "
2431
+ ],
2432
+ [
2433
+ {
2434
+ "eq": [
2435
+ "item.isStatic",
2436
+ "true"
2437
+ ]
2438
+ },
2439
+ "static readonly "
2440
+ ]
2441
+ ],
2442
+ "else": ""
2443
+ }
2444
+ },
2445
+ {
2446
+ "fn": "ident",
2447
+ "args": [
2448
+ {
2449
+ "get": "item.name"
2450
+ }
2451
+ ]
2452
+ },
2453
+ ": ",
2454
+ {
2455
+ "type": "item.type"
2456
+ },
2457
+ {
2458
+ "case": {
2459
+ "when": [
2460
+ [
2461
+ {
2462
+ "eq": [
2463
+ "item.hasInit",
2464
+ "true"
2465
+ ]
2466
+ },
2467
+ {
2468
+ "tmpl": [
2469
+ " = ",
2470
+ {
2471
+ "emit": "item.init"
2472
+ }
2473
+ ]
2474
+ }
2475
+ ]
2476
+ ]
2477
+ }
2478
+ },
2479
+ ";"
2480
+ ]
2481
+ }
2482
+ }
2483
+ },
2484
+ {
2485
+ "case": {
2486
+ "when": [
2487
+ [
2488
+ {
2489
+ "eq": [
2490
+ "decl.hasInit",
2491
+ "true"
2492
+ ]
2493
+ },
2494
+ {
2495
+ "block": {
2496
+ "head": {
2497
+ "tmpl": [
2498
+ "constructor(",
2499
+ {
2500
+ "map": "decl.initParams",
2501
+ "sep": ", ",
2502
+ "item": {
2503
+ "call": "tsParam"
2504
+ }
2505
+ },
2506
+ ")"
2507
+ ]
2508
+ },
2509
+ "body": [
2510
+ {
2511
+ "case": {
2512
+ "when": [
2513
+ [
2514
+ {
2515
+ "eq": [
2516
+ "decl.hasSuper",
2517
+ "true"
2518
+ ]
2519
+ },
2520
+ {
2521
+ "line": {
2522
+ "tmpl": [
2523
+ "super(",
2524
+ {
2525
+ "map": "decl.superArgs",
2526
+ "sep": ", ",
2527
+ "item": {
2528
+ "emit": "item"
2529
+ }
2530
+ },
2531
+ ");"
2532
+ ]
2533
+ }
2534
+ }
2535
+ ]
2536
+ ]
2537
+ }
2538
+ },
2539
+ {
2540
+ "stmts": "decl.initBody"
2541
+ }
2542
+ ]
2543
+ }
2544
+ }
2545
+ ]
2546
+ ]
2547
+ }
2548
+ },
2549
+ {
2550
+ "mapMembers": "decl.methods",
2551
+ "rule": "MethodDecl"
2552
+ }
2553
+ ]
2554
+ }
2555
+ },
2556
+ "InterfaceDecl": {
2557
+ "block": {
2558
+ "head": {
2559
+ "tmpl": [
2560
+ "interface ",
2561
+ {
2562
+ "fn": "ident",
2563
+ "args": [
2564
+ {
2565
+ "get": "decl.name"
2566
+ }
2567
+ ]
2568
+ },
2569
+ {
2570
+ "fn": "generics"
2571
+ },
2572
+ {
2573
+ "case": {
2574
+ "when": [
2575
+ [
2576
+ {
2577
+ "eq": [
2578
+ "decl.bases.count",
2579
+ "0"
2580
+ ]
2581
+ },
2582
+ ""
2583
+ ]
2584
+ ],
2585
+ "else": {
2586
+ "tmpl": [
2587
+ " extends ",
2588
+ {
2589
+ "map": "decl.bases",
2590
+ "sep": ", ",
2591
+ "item": {
2592
+ "type": "item"
2593
+ }
2594
+ }
2595
+ ]
2596
+ }
2597
+ }
2598
+ }
2599
+ ]
2600
+ },
2601
+ "body": [
2602
+ {
2603
+ "mapDecl": "decl.methods",
2604
+ "each": {
2605
+ "line": {
2606
+ "tmpl": [
2607
+ {
2608
+ "fn": "ident",
2609
+ "args": [
2610
+ {
2611
+ "get": "item.name"
2612
+ }
2613
+ ]
2614
+ },
2615
+ {
2616
+ "fn": "generics",
2617
+ "args": [
2618
+ {
2619
+ "get": "item.#"
2620
+ }
2621
+ ]
2622
+ },
2623
+ "(",
2624
+ {
2625
+ "map": "item.params",
2626
+ "sep": ", ",
2627
+ "item": {
2628
+ "tmpl": [
2629
+ {
2630
+ "fn": "ident",
2631
+ "args": [
2632
+ {
2633
+ "get": "item.name"
2634
+ }
2635
+ ]
2636
+ },
2637
+ ": ",
2638
+ {
2639
+ "type": "item.type"
2640
+ },
2641
+ {
2642
+ "case": {
2643
+ "when": [
2644
+ [
2645
+ {
2646
+ "eq": [
2647
+ "item.hasDefault",
2648
+ "true"
2649
+ ]
2650
+ },
2651
+ {
2652
+ "tmpl": [
2653
+ " = ",
2654
+ {
2655
+ "emit": "item.default"
2656
+ }
2657
+ ]
2658
+ }
2659
+ ]
2660
+ ]
2661
+ }
2662
+ }
2663
+ ]
2664
+ }
2665
+ },
2666
+ "): ",
2667
+ {
2668
+ "type": "item.returnType"
2669
+ },
2670
+ ";"
2671
+ ]
2672
+ }
2673
+ }
2674
+ }
2675
+ ]
2676
+ }
2677
+ },
2678
+ "UnionDecl": {
2679
+ "line": {
2680
+ "tmpl": [
2681
+ "type ",
2682
+ {
2683
+ "fn": "ident",
2684
+ "args": [
2685
+ {
2686
+ "get": "decl.name"
2687
+ }
2688
+ ]
2689
+ },
2690
+ {
2691
+ "fn": "generics"
2692
+ },
2693
+ " = ",
2694
+ {
2695
+ "map": "decl.cases",
2696
+ "sep": " | ",
2697
+ "item": {
2698
+ "tmpl": [
2699
+ "{ tag: \"",
2700
+ {
2701
+ "fn": "ident",
2702
+ "args": [
2703
+ {
2704
+ "get": "item.name"
2705
+ }
2706
+ ]
2707
+ },
2708
+ "\"",
2709
+ {
2710
+ "map": "item.fields",
2711
+ "sep": "",
2712
+ "item": {
2713
+ "tmpl": [
2714
+ "; ",
2715
+ {
2716
+ "fn": "ident",
2717
+ "args": [
2718
+ {
2719
+ "get": "item.name"
2720
+ }
2721
+ ]
2722
+ },
2723
+ ": ",
2724
+ {
2725
+ "type": "item.type"
2726
+ }
2727
+ ]
2728
+ }
2729
+ },
2730
+ " }"
2731
+ ]
2732
+ }
2733
+ },
2734
+ ";"
2735
+ ]
2736
+ }
2737
+ },
2738
+ "Type": {
2739
+ "case": {
2740
+ "when": [
2741
+ [
2742
+ {
2743
+ "eq": [
2744
+ "type.kind",
2745
+ "function"
2746
+ ]
2747
+ },
2748
+ {
2749
+ "tmpl": [
2750
+ "(",
2751
+ {
2752
+ "map": "type.args",
2753
+ "sep": ", ",
2754
+ "item": {
2755
+ "tmpl": [
2756
+ "arg",
2757
+ {
2758
+ "get": "item.#"
2759
+ },
2760
+ ": ",
2761
+ {
2762
+ "type": "item"
2763
+ }
2764
+ ]
2765
+ }
2766
+ },
2767
+ ") => ",
2768
+ {
2769
+ "case": {
2770
+ "when": [
2771
+ [
2772
+ {
2773
+ "eq": [
2774
+ "type.hasRet",
2775
+ "true"
2776
+ ]
2777
+ },
2778
+ {
2779
+ "type": "type.ret"
2780
+ }
2781
+ ]
2782
+ ],
2783
+ "else": "void"
2784
+ }
2785
+ }
2786
+ ]
2787
+ }
2788
+ ],
2789
+ [
2790
+ {
2791
+ "eq": [
2792
+ "type.kind",
2793
+ "tuple"
2794
+ ]
2795
+ },
2796
+ {
2797
+ "tmpl": [
2798
+ "[",
2799
+ {
2800
+ "map": "type.args",
2801
+ "sep": ", ",
2802
+ "item": {
2803
+ "type": "item"
2804
+ }
2805
+ },
2806
+ "]"
2807
+ ]
2808
+ }
2809
+ ],
2810
+ [
2811
+ {
2812
+ "eq": [
2813
+ "type.nullable",
2814
+ "true"
2815
+ ]
2816
+ },
2817
+ {
2818
+ "tmpl": [
2819
+ {
2820
+ "type": "type.base"
2821
+ },
2822
+ " | null"
2823
+ ]
2824
+ }
2825
+ ],
2826
+ [
2827
+ {
2828
+ "has": "type.scalar"
2829
+ },
2830
+ {
2831
+ "get": "type.scalar"
2832
+ }
2833
+ ],
2834
+ [
2835
+ {
2836
+ "eq": [
2837
+ "type.nameEmpty",
2838
+ "true"
2839
+ ]
2840
+ },
2841
+ "unknown"
2842
+ ],
2843
+ [
2844
+ {
2845
+ "has": "type.externTemplate"
2846
+ },
2847
+ {
2848
+ "fn": "substExtern"
2849
+ }
2850
+ ]
2851
+ ],
2852
+ "else": {
2853
+ "tmpl": [
2854
+ {
2855
+ "fn": "ident",
2856
+ "args": [
2857
+ {
2858
+ "get": "type.name"
2859
+ }
2860
+ ]
2861
+ },
2862
+ {
2863
+ "case": {
2864
+ "when": [
2865
+ [
2866
+ {
2867
+ "eq": [
2868
+ "type.args.count",
2869
+ "0"
2870
+ ]
2871
+ },
2872
+ ""
2873
+ ]
2874
+ ],
2875
+ "else": {
2876
+ "tmpl": [
2877
+ "<",
2878
+ {
2879
+ "map": "type.args",
2880
+ "sep": ", ",
2881
+ "item": {
2882
+ "type": "item"
2883
+ }
2884
+ },
2885
+ ">"
2886
+ ]
2887
+ }
2888
+ }
2889
+ }
2890
+ ]
2891
+ }
2892
+ }
2893
+ },
2894
+ "Binary": {
2895
+ "case": {
2896
+ "when": [
2897
+ [
2898
+ {
2899
+ "and": [
2900
+ {
2901
+ "or": [
2902
+ {
2903
+ "eq": [
2904
+ "node.op",
2905
+ "=="
2906
+ ]
2907
+ },
2908
+ {
2909
+ "eq": [
2910
+ "node.op",
2911
+ "!="
2912
+ ]
2913
+ }
2914
+ ]
2915
+ },
2916
+ {
2917
+ "eq": [
2918
+ "node.lhsIsRecord",
2919
+ "true"
2920
+ ]
2921
+ }
2922
+ ]
2923
+ },
2924
+ {
2925
+ "case": {
2926
+ "when": [
2927
+ [
2928
+ {
2929
+ "eq": [
2930
+ "node.op",
2931
+ "=="
2932
+ ]
2933
+ },
2934
+ {
2935
+ "tmpl": [
2936
+ {
2937
+ "emitChild": "node.lhs",
2938
+ "side": "recv"
2939
+ },
2940
+ ".equals(",
2941
+ {
2942
+ "emit": "node.rhs"
2943
+ },
2944
+ ")"
2945
+ ]
2946
+ }
2947
+ ]
2948
+ ],
2949
+ "else": {
2950
+ "tmpl": [
2951
+ "!",
2952
+ {
2953
+ "emitChild": "node.lhs",
2954
+ "side": "recv"
2955
+ },
2956
+ ".equals(",
2957
+ {
2958
+ "emit": "node.rhs"
2959
+ },
2960
+ ")"
2961
+ ]
2962
+ }
2963
+ }
2964
+ }
2965
+ ],
2966
+ [
2967
+ {
2968
+ "or": [
2969
+ {
2970
+ "eq": [
2971
+ "node.op",
2972
+ "=="
2973
+ ]
2974
+ },
2975
+ {
2976
+ "eq": [
2977
+ "node.op",
2978
+ "!="
2979
+ ]
2980
+ }
2981
+ ]
2982
+ },
2983
+ {
2984
+ "tmpl": [
2985
+ {
2986
+ "emitChild": "node.lhs",
2987
+ "side": "l"
2988
+ },
2989
+ " ",
2990
+ {
2991
+ "fn": "opSpelling",
2992
+ "args": [
2993
+ {
2994
+ "get": "node.op"
2995
+ }
2996
+ ]
2997
+ },
2998
+ " ",
2999
+ {
3000
+ "emitChild": "node.rhs",
3001
+ "side": "r"
3002
+ }
3003
+ ]
3004
+ }
3005
+ ],
3006
+ [
3007
+ {
3008
+ "eq": [
3009
+ "node.hasOpMethod",
3010
+ "true"
3011
+ ]
3012
+ },
3013
+ {
3014
+ "tmpl": [
3015
+ {
3016
+ "emitChild": "node.lhs",
3017
+ "side": "recv"
3018
+ },
3019
+ ".",
3020
+ {
3021
+ "fn": "table",
3022
+ "args": [
3023
+ "opMethod",
3024
+ {
3025
+ "get": "node.op"
3026
+ }
3027
+ ]
3028
+ },
3029
+ "(",
3030
+ {
3031
+ "emit": "node.rhs"
3032
+ },
3033
+ ")"
3034
+ ]
3035
+ }
3036
+ ],
3037
+ [
3038
+ {
3039
+ "or": [
3040
+ {
3041
+ "eq": [
3042
+ "node.type",
3043
+ "i64"
3044
+ ]
3045
+ },
3046
+ {
3047
+ "eq": [
3048
+ "node.type",
3049
+ "u64"
3050
+ ]
3051
+ }
3052
+ ]
3053
+ },
3054
+ {
3055
+ "fn": "wrap",
3056
+ "args": [
3057
+ {
3058
+ "get": "node.type"
3059
+ },
3060
+ {
3061
+ "tmpl": [
3062
+ {
3063
+ "emitChild": "node.lhs",
3064
+ "side": "l"
3065
+ },
3066
+ " ",
3067
+ {
3068
+ "get": "node.op"
3069
+ },
3070
+ " ",
3071
+ {
3072
+ "emitChild": "node.rhs",
3073
+ "side": "r"
3074
+ }
3075
+ ]
3076
+ }
3077
+ ]
3078
+ }
3079
+ ],
3080
+ [
3081
+ {
3082
+ "and": [
3083
+ {
3084
+ "eq": [
3085
+ "node.typeIsSmallInt",
3086
+ "true"
3087
+ ]
3088
+ },
3089
+ {
3090
+ "eq": [
3091
+ "node.op",
3092
+ "*"
3093
+ ]
3094
+ }
3095
+ ]
3096
+ },
3097
+ {
3098
+ "case": {
3099
+ "when": [
3100
+ [
3101
+ {
3102
+ "eq": [
3103
+ "node.type",
3104
+ "i32"
3105
+ ]
3106
+ },
3107
+ {
3108
+ "tmpl": [
3109
+ "Math.imul(",
3110
+ {
3111
+ "emit": "node.lhs"
3112
+ },
3113
+ ", ",
3114
+ {
3115
+ "emit": "node.rhs"
3116
+ },
3117
+ ")"
3118
+ ]
3119
+ }
3120
+ ]
3121
+ ],
3122
+ "else": {
3123
+ "fn": "wrap",
3124
+ "args": [
3125
+ {
3126
+ "get": "node.type"
3127
+ },
3128
+ {
3129
+ "tmpl": [
3130
+ "Math.imul(",
3131
+ {
3132
+ "emit": "node.lhs"
3133
+ },
3134
+ ", ",
3135
+ {
3136
+ "emit": "node.rhs"
3137
+ },
3138
+ ")"
3139
+ ]
3140
+ }
3141
+ ]
3142
+ }
3143
+ }
3144
+ }
3145
+ ],
3146
+ [
3147
+ {
3148
+ "and": [
3149
+ {
3150
+ "eq": [
3151
+ "node.typeIsSmallInt",
3152
+ "true"
3153
+ ]
3154
+ },
3155
+ {
3156
+ "or": [
3157
+ {
3158
+ "eq": [
3159
+ "node.op",
3160
+ "+"
3161
+ ]
3162
+ },
3163
+ {
3164
+ "eq": [
3165
+ "node.op",
3166
+ "-"
3167
+ ]
3168
+ },
3169
+ {
3170
+ "eq": [
3171
+ "node.op",
3172
+ "/"
3173
+ ]
3174
+ },
3175
+ {
3176
+ "eq": [
3177
+ "node.op",
3178
+ "%"
3179
+ ]
3180
+ }
3181
+ ]
3182
+ }
3183
+ ]
3184
+ },
3185
+ {
3186
+ "fn": "wrap",
3187
+ "args": [
3188
+ {
3189
+ "get": "node.type"
3190
+ },
3191
+ {
3192
+ "tmpl": [
3193
+ {
3194
+ "emitChild": "node.lhs",
3195
+ "side": "l"
3196
+ },
3197
+ " ",
3198
+ {
3199
+ "get": "node.op"
3200
+ },
3201
+ " ",
3202
+ {
3203
+ "emitChild": "node.rhs",
3204
+ "side": "r"
3205
+ }
3206
+ ]
3207
+ }
3208
+ ]
3209
+ }
3210
+ ]
3211
+ ],
3212
+ "else": {
3213
+ "tmpl": [
3214
+ {
3215
+ "emitChild": "node.lhs",
3216
+ "side": "l"
3217
+ },
3218
+ " ",
3219
+ {
3220
+ "fn": "opSpelling",
3221
+ "args": [
3222
+ {
3223
+ "get": "node.op"
3224
+ }
3225
+ ]
3226
+ },
3227
+ " ",
3228
+ {
3229
+ "emitChild": "node.rhs",
3230
+ "side": "r"
3231
+ }
3232
+ ]
3233
+ }
3234
+ }
3235
+ }
3236
+ },
3237
+ "std": {
3238
+ "std.collections": {
3239
+ "List.type": "$0[]",
3240
+ "List.init": "[]",
3241
+ "List.count": "$this.length",
3242
+ "List.add": "$this.push($0)",
3243
+ "List.clear": "$this = []",
3244
+ "List.removeAll": "$this = $this.filter(__e => !(($0)(__e)))",
3245
+ "List.removeAt": "$this.splice($0, 1)"
3246
+ },
3247
+ "std.io": {
3248
+ "print": "console.log(String(x))",
3249
+ "readText": "require('fs').readFileSync(path, 'utf8')",
3250
+ "writeText": "require('fs').writeFileSync(path, content)",
3251
+ "appendText": "require('fs').appendFileSync(path, content)",
3252
+ "fileExists": "require('fs').existsSync(path)",
3253
+ "deleteFile": "require('fs').unlinkSync(path)"
3254
+ },
3255
+ "std.math": {
3256
+ "Math.PI": "Math.PI",
3257
+ "Math.E": "Math.E",
3258
+ "Math.sqrt": "Math.sqrt($0)",
3259
+ "Math.ln": "Math.log($0)",
3260
+ "Math.floor": "Math.floor($0)",
3261
+ "Math.ceil": "Math.ceil($0)",
3262
+ "Math.min": "((a, b) => (a <= b ? a : b))($0, $1)",
3263
+ "Math.max": "((a, b) => (a >= b ? a : b))($0, $1)",
3264
+ "Math.abs": "((a) => (a < (a - a) ? -a : a))($0)",
3265
+ "Math.round": "Math.round($0)"
3266
+ },
3267
+ "std.strings": {
3268
+ "string.isEmpty": "($this.length === 0)",
3269
+ "string.len": "$this.length",
3270
+ "string.toUpper": "$this.toUpperCase()",
3271
+ "string.toLower": "$this.toLowerCase()",
3272
+ "string.charAt": "$this.charAt($0)",
3273
+ "string.codePoints": "Array.from($this)",
3274
+ "string.toI32": "parseInt($this, 10)"
3275
+ },
3276
+ "std.core": {
3277
+ "Error.type": "Error",
3278
+ "Error.init": "new $T($0)",
3279
+ "Error.message": "$this.message",
3280
+ "Iterable.type": "Iterable<$0>",
3281
+ "i8.parse": "(Number.parseInt($0, 10) << 24 >> 24)",
3282
+ "i16.parse": "(Number.parseInt($0, 10) << 16 >> 16)",
3283
+ "i32.parse": "(Number.parseInt($0, 10) | 0)",
3284
+ "i64.parse": "BigInt($0)",
3285
+ "u8.parse": "(Number.parseInt($0, 10) & 0xff)",
3286
+ "u16.parse": "(Number.parseInt($0, 10) & 0xffff)",
3287
+ "u32.parse": "(Number.parseInt($0, 10) >>> 0)",
3288
+ "u64.parse": "BigInt($0)",
3289
+ "f32.parse": "Number($0)",
3290
+ "f64.parse": "Number($0)"
3291
+ }
3292
+ },
3293
+ "fileExtension": ".ts"
3294
+ }