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