@mintplayer/polyglot-target-csharp 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/polyglot-plugin.json +594 -127
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/polyglot-target-csharp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "MintPlayer Polyglot C# / .NET target — a pure-JSON language plugin (spec + emission rules + capabilities + std bindings) for the polyglot transpiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyglot",
|
package/polyglot-plugin.json
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema":
|
|
2
|
+
"schema": 2,
|
|
3
3
|
"name": "csharp",
|
|
4
4
|
"sharedPreludeFile": true,
|
|
5
|
+
"options": {
|
|
6
|
+
"namespace": {
|
|
7
|
+
"default": "",
|
|
8
|
+
"pattern": "^([A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)*)?$",
|
|
9
|
+
"scope": "closure"
|
|
10
|
+
},
|
|
11
|
+
"class": {
|
|
12
|
+
"default": "PolyglotProgram",
|
|
13
|
+
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
|
|
14
|
+
"scope": "closure",
|
|
15
|
+
"reserve": true
|
|
16
|
+
},
|
|
17
|
+
"access": {
|
|
18
|
+
"default": "",
|
|
19
|
+
"pattern": "^(public|internal)?$",
|
|
20
|
+
"scope": "closure"
|
|
21
|
+
},
|
|
22
|
+
"entryPoint": {
|
|
23
|
+
"default": "true",
|
|
24
|
+
"pattern": "^(true|false)$",
|
|
25
|
+
"scope": "closure"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
5
28
|
"originMapping": {
|
|
6
29
|
"style": "directive",
|
|
7
30
|
"line": "#line $n \"$f\"",
|
|
@@ -40,17 +63,43 @@
|
|
|
40
63
|
"u16": "(ushort)($x)"
|
|
41
64
|
},
|
|
42
65
|
"wrapAtom": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
66
|
+
"recvPrimary": [
|
|
67
|
+
"var",
|
|
68
|
+
"this",
|
|
69
|
+
"call",
|
|
70
|
+
"methodCall",
|
|
71
|
+
"member",
|
|
72
|
+
"index",
|
|
73
|
+
"str",
|
|
74
|
+
"char",
|
|
75
|
+
"bool",
|
|
76
|
+
"null",
|
|
77
|
+
"extern",
|
|
78
|
+
"nullAssert",
|
|
79
|
+
"int",
|
|
80
|
+
"float",
|
|
81
|
+
"listLit",
|
|
82
|
+
"tuple",
|
|
83
|
+
"new",
|
|
84
|
+
"makeCase",
|
|
85
|
+
"interp"
|
|
50
86
|
]
|
|
51
87
|
},
|
|
52
88
|
"rethrow": "throw;",
|
|
89
|
+
"preludes": {
|
|
90
|
+
"pgStrInt": " internal static string Str(sbyte x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(byte x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(short x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(ushort x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(int x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(uint x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(long x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n internal static string Str(ulong x) => x.ToString(global::System.Globalization.CultureInfo.InvariantCulture);\n",
|
|
91
|
+
"pgStrFloat": " // f32 text is the f32's exact value widened to f64, printed under the f64 rule.\n internal static string Str(float x) => Str((double)x);\n // ECMAScript Number::toString: exact shortest digits (Burger-Dybvig over BigInteger, ties to even), then\n // the ECMAScript layout. Never \"R\": its digits are wrong on .NET Framework and on some .NET 10 patches.\n internal static string Str(double x)\n {\n if (double.IsNaN(x)) return \"NaN\";\n if (double.IsPositiveInfinity(x)) return \"Infinity\";\n if (double.IsNegativeInfinity(x)) return \"-Infinity\";\n if (x == 0) return \"0\";\n bool neg = x < 0;\n if (neg) x = -x;\n long bits = global::System.BitConverter.DoubleToInt64Bits(x);\n int be = (int)((bits >> 52) & 0x7FF);\n long f = bits & 0xFFFFFFFFFFFFFL;\n int e;\n if (be == 0) e = -1074; else { f |= 1L << 52; e = be - 1075; }\n bool even = (f & 1) == 0;\n bool asym = f == (1L << 52) && be > 1;\n global::System.Numerics.BigInteger r, s, mp, mm;\n if (e >= 0)\n {\n global::System.Numerics.BigInteger b = global::System.Numerics.BigInteger.One << e;\n if (!asym) { r = f * b * 2; s = 2; mp = b; mm = b; }\n else { r = f * b * 4; s = 4; mp = b * 2; mm = b; }\n }\n else\n {\n if (!asym) { r = (global::System.Numerics.BigInteger)f * 2; s = global::System.Numerics.BigInteger.One << (1 - e); mp = 1; mm = 1; }\n else { r = (global::System.Numerics.BigInteger)f * 4; s = global::System.Numerics.BigInteger.One << (2 - e); mp = 2; mm = 1; }\n }\n int k = (int)global::System.Math.Ceiling(global::System.Math.Log10(x) - 1e-10);\n if (k >= 0) s *= global::System.Numerics.BigInteger.Pow(10, k);\n else { global::System.Numerics.BigInteger p = global::System.Numerics.BigInteger.Pow(10, -k); r *= p; mp *= p; mm *= p; }\n while (even ? r + mp >= s : r + mp > s) { s *= 10; k++; }\n while (even ? (r + mp) * 10 < s : (r + mp) * 10 <= s) { r *= 10; mp *= 10; mm *= 10; k--; }\n global::System.Text.StringBuilder dg = new global::System.Text.StringBuilder(20);\n while (true)\n {\n r *= 10; mp *= 10; mm *= 10;\n int d = (int)global::System.Numerics.BigInteger.DivRem(r, s, out r);\n bool low = even ? r <= mm : r < mm;\n bool high = even ? r + mp >= s : r + mp > s;\n if (!low && !high) { dg.Append((char)('0' + d)); continue; }\n if (low && high) { int c = (r * 2).CompareTo(s); if (c > 0 || (c == 0 && (d & 1) == 1)) d++; }\n else if (high) d++;\n dg.Append((char)('0' + d));\n break;\n }\n string digits = dg.ToString();\n int n = k, len = digits.Length;\n global::System.Text.StringBuilder sb = new global::System.Text.StringBuilder(32);\n if (neg) sb.Append('-');\n if (len <= n && n <= 21) { sb.Append(digits); sb.Append('0', n - len); }\n else if (0 < n && n <= 21) { sb.Append(digits, 0, n); sb.Append('.'); sb.Append(digits, n, len - n); }\n else if (-6 < n && n <= 0) { sb.Append(\"0.\"); sb.Append('0', -n); sb.Append(digits); }\n else\n {\n sb.Append(digits[0]);\n if (len > 1) { sb.Append('.'); sb.Append(digits, 1, len - 1); }\n sb.Append('e'); sb.Append(n - 1 >= 0 ? '+' : '-');\n sb.Append(global::System.Math.Abs(n - 1).ToString(global::System.Globalization.CultureInfo.InvariantCulture));\n }\n return sb.ToString();\n }\n",
|
|
92
|
+
"pgShow": " // The one stringification rule for a value whose static type is not known here (print, a T-typed hole).\n internal static string Show(object? x) => x switch\n {\n null => \"null\",\n bool b => b ? \"true\" : \"false\",\n string s => s,\n double d => Str(d),\n float f => Str(f),\n int i => Str(i),\n long l => Str(l),\n sbyte i8 => Str(i8),\n byte u8 => Str(u8),\n short i16 => Str(i16),\n ushort u16 => Str(u16),\n uint u32 => Str(u32),\n ulong u64 => Str(u64),\n global::System.IFormattable fm => fm.ToString(null, global::System.Globalization.CultureInfo.InvariantCulture),\n _ => x.ToString() ?? \"\",\n };\n",
|
|
93
|
+
"pgAscii": " // ASCII-only case mapping: every other character is kept as is (System.Text.Ascii stops at the first one).\n internal static string UpperAscii(string s)\n {\n char[]? buf = null;\n for (int i = 0; i < s.Length; i++)\n if (s[i] >= 'a' && s[i] <= 'z') { buf ??= s.ToCharArray(); buf[i] = (char)(s[i] - 32); }\n return buf == null ? s : new string(buf);\n }\n internal static string LowerAscii(string s)\n {\n char[]? buf = null;\n for (int i = 0; i < s.Length; i++)\n if (s[i] >= 'A' && s[i] <= 'Z') { buf ??= s.ToCharArray(); buf[i] = (char)(s[i] + 32); }\n return buf == null ? s : new string(buf);\n }\n"
|
|
94
|
+
},
|
|
53
95
|
"tables": {
|
|
96
|
+
"rangeWideType": {
|
|
97
|
+
"i8": "long", "i16": "long", "i32": "long", "u8": "long", "u16": "long", "u32": "long",
|
|
98
|
+
"i64": "global::System.Int128", "u64": "global::System.UInt128"
|
|
99
|
+
},
|
|
100
|
+
"floatSuffix": {
|
|
101
|
+
"f32": "f"
|
|
102
|
+
},
|
|
54
103
|
"localDecl": {
|
|
55
104
|
"mutable": "var $x",
|
|
56
105
|
"const": "var $x"
|
|
@@ -89,22 +138,47 @@
|
|
|
89
138
|
"constArrayClose": "}",
|
|
90
139
|
"linksWithoutImports": true,
|
|
91
140
|
"forbidsShadowedLocals": true,
|
|
92
|
-
"
|
|
141
|
+
"nativeCompoundAssign": true,
|
|
142
|
+
"nativeCoalesceAssign": true,
|
|
143
|
+
"assignmentOrder": "targetFirst",
|
|
144
|
+
"exprStmt": { "discardPrefix": "_ = " },
|
|
145
|
+
"literals": {
|
|
146
|
+
"string": {
|
|
147
|
+
"quote": "\"",
|
|
148
|
+
"map": {
|
|
149
|
+
"\\": "\\\\",
|
|
150
|
+
"\"": "\\\"",
|
|
151
|
+
"\n": "\\n",
|
|
152
|
+
"\t": "\\t",
|
|
153
|
+
"\r": "\\r"
|
|
154
|
+
},
|
|
155
|
+
"codepoint": "\\u$H4",
|
|
156
|
+
"astral": "\\U$H8"
|
|
157
|
+
},
|
|
93
158
|
"interp": {
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
159
|
+
"quote": "\"",
|
|
160
|
+
"map": {
|
|
161
|
+
"\\": "\\\\",
|
|
162
|
+
"\"": "\\\"",
|
|
163
|
+
"\n": "\\n",
|
|
164
|
+
"\t": "\\t",
|
|
165
|
+
"\r": "\\r",
|
|
166
|
+
"{": "{{",
|
|
167
|
+
"}": "}}"
|
|
168
|
+
},
|
|
169
|
+
"codepoint": "\\u$H4",
|
|
170
|
+
"astral": "\\U$H8"
|
|
101
171
|
},
|
|
102
172
|
"char": {
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
173
|
+
"quote": "'",
|
|
174
|
+
"map": {
|
|
175
|
+
"\\": "\\\\",
|
|
176
|
+
"'": "\\'",
|
|
177
|
+
"\n": "\\n",
|
|
178
|
+
"\t": "\\t",
|
|
179
|
+
"\r": "\\r"
|
|
180
|
+
},
|
|
181
|
+
"codepoint": "\\u$H4"
|
|
108
182
|
}
|
|
109
183
|
},
|
|
110
184
|
"identifiers": {
|
|
@@ -191,14 +265,19 @@
|
|
|
191
265
|
"strategy": "prefix",
|
|
192
266
|
"with": "@"
|
|
193
267
|
},
|
|
268
|
+
"mangle": {
|
|
269
|
+
"replace": "$",
|
|
270
|
+
"with": "__"
|
|
271
|
+
},
|
|
194
272
|
"reserved": [
|
|
195
|
-
"PolyglotProgram",
|
|
196
273
|
"PolyglotExtensions",
|
|
274
|
+
"__PgRt",
|
|
197
275
|
"Main",
|
|
198
276
|
"lhs",
|
|
199
277
|
"__opt*",
|
|
200
278
|
"__w*"
|
|
201
|
-
]
|
|
279
|
+
],
|
|
280
|
+
"renames": { "_": "__u" }
|
|
202
281
|
}
|
|
203
282
|
},
|
|
204
283
|
"rules": {
|
|
@@ -218,7 +297,20 @@
|
|
|
218
297
|
]
|
|
219
298
|
},
|
|
220
299
|
"Float": {
|
|
221
|
-
"
|
|
300
|
+
"tmpl": [
|
|
301
|
+
{
|
|
302
|
+
"get": "node.text"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"fn": "table",
|
|
306
|
+
"args": [
|
|
307
|
+
"floatSuffix",
|
|
308
|
+
{
|
|
309
|
+
"get": "node.type"
|
|
310
|
+
}
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
]
|
|
222
314
|
},
|
|
223
315
|
"Bool": {
|
|
224
316
|
"case": {
|
|
@@ -244,8 +336,9 @@
|
|
|
244
336
|
"get": "spec.nullLit"
|
|
245
337
|
},
|
|
246
338
|
"Str": {
|
|
247
|
-
"fn": "
|
|
339
|
+
"fn": "quoted",
|
|
248
340
|
"args": [
|
|
341
|
+
"string",
|
|
249
342
|
{
|
|
250
343
|
"get": "node.value"
|
|
251
344
|
}
|
|
@@ -286,6 +379,18 @@
|
|
|
286
379
|
{
|
|
287
380
|
"case": {
|
|
288
381
|
"when": [
|
|
382
|
+
[
|
|
383
|
+
{ "eq": ["node.calleeKind", "lambda"] },
|
|
384
|
+
{ "tmpl": [ "((", { "type": "node.calleeType" }, ")", { "emitChild": "node.calleeExpr", "side": "recv" }, ")" ] }
|
|
385
|
+
],
|
|
386
|
+
[
|
|
387
|
+
{ "has": "node.hasCalleeExpr" },
|
|
388
|
+
{ "emitChild": "node.calleeExpr", "side": "recv" }
|
|
389
|
+
],
|
|
390
|
+
[
|
|
391
|
+
{ "has": "node.linkCallee" },
|
|
392
|
+
{ "tmpl": [ { "get": "option.class" }, ".", { "fn": "mangleName", "args": [ { "fn": "ident", "args": [ { "get": "node.linkCallee" } ] } ] } ] }
|
|
393
|
+
],
|
|
289
394
|
[
|
|
290
395
|
{
|
|
291
396
|
"eq": [
|
|
@@ -295,7 +400,8 @@
|
|
|
295
400
|
},
|
|
296
401
|
{
|
|
297
402
|
"tmpl": [
|
|
298
|
-
"
|
|
403
|
+
{ "get": "option.class" },
|
|
404
|
+
".",
|
|
299
405
|
{
|
|
300
406
|
"fn": "ident",
|
|
301
407
|
"args": [
|
|
@@ -318,12 +424,12 @@
|
|
|
318
424
|
}
|
|
319
425
|
}
|
|
320
426
|
},
|
|
321
|
-
"(",
|
|
322
427
|
{
|
|
323
|
-
"
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
428
|
+
"case": {
|
|
429
|
+
"when": [[ { "eq": ["node.isRef", "true"] }, "" ]],
|
|
430
|
+
"else": { "tmpl": [ { "call": "typeArgsSuffix" }, "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
431
|
+
}
|
|
432
|
+
}
|
|
327
433
|
]
|
|
328
434
|
},
|
|
329
435
|
"Member": {
|
|
@@ -647,6 +753,25 @@
|
|
|
647
753
|
{ "type": "node.castType" }
|
|
648
754
|
]
|
|
649
755
|
},
|
|
756
|
+
"NullAssert": {
|
|
757
|
+
"case": {
|
|
758
|
+
"when": [
|
|
759
|
+
[
|
|
760
|
+
{ "eq": ["node.isFail", "true"] },
|
|
761
|
+
{ "tmpl": ["throw new global::System.NullReferenceException(", { "fn": "quoted", "args": ["string", { "get": "node.message" }] }, ")"] }
|
|
762
|
+
]
|
|
763
|
+
],
|
|
764
|
+
"else": {
|
|
765
|
+
"tmpl": [
|
|
766
|
+
"(",
|
|
767
|
+
{ "emitChild": "node.operand", "side": "recv" },
|
|
768
|
+
" ?? throw new global::System.NullReferenceException(",
|
|
769
|
+
{ "fn": "quoted", "args": ["string", { "get": "node.message" }] },
|
|
770
|
+
"))"
|
|
771
|
+
]
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
},
|
|
650
775
|
"Unary": {
|
|
651
776
|
"tmpl": [
|
|
652
777
|
{
|
|
@@ -666,7 +791,7 @@
|
|
|
666
791
|
"lits": "node.chunks",
|
|
667
792
|
"holes": "node.holes",
|
|
668
793
|
"lit": {
|
|
669
|
-
"fn": "
|
|
794
|
+
"fn": "literal",
|
|
670
795
|
"args": [
|
|
671
796
|
"interp",
|
|
672
797
|
{
|
|
@@ -693,15 +818,50 @@
|
|
|
693
818
|
" ? \"true\" : \"false\")}"
|
|
694
819
|
]
|
|
695
820
|
}
|
|
821
|
+
],
|
|
822
|
+
[
|
|
823
|
+
{ "eq": ["item.typeIsInt", "true"] },
|
|
824
|
+
{
|
|
825
|
+
"tmpl": [
|
|
826
|
+
{ "fn": "require", "args": ["pgStrInt"] },
|
|
827
|
+
"{__PgRt.Str(",
|
|
828
|
+
{ "emit": "item" },
|
|
829
|
+
")}"
|
|
830
|
+
]
|
|
831
|
+
}
|
|
832
|
+
],
|
|
833
|
+
[
|
|
834
|
+
{ "eq": ["item.typeIsFloat", "true"] },
|
|
835
|
+
{
|
|
836
|
+
"tmpl": [
|
|
837
|
+
{ "fn": "require", "args": ["pgStrFloat"] },
|
|
838
|
+
"{__PgRt.Str(",
|
|
839
|
+
{ "emit": "item" },
|
|
840
|
+
")}"
|
|
841
|
+
]
|
|
842
|
+
}
|
|
843
|
+
],
|
|
844
|
+
[
|
|
845
|
+
{ "or": [{ "eq": ["item.typeIsString", "true"] }, { "eq": ["item.typeIsChar", "true"] }] },
|
|
846
|
+
{
|
|
847
|
+
"tmpl": [
|
|
848
|
+
"{",
|
|
849
|
+
{ "fn": "parenIfContains", "args": [":", { "emit": "item" }] },
|
|
850
|
+
"}"
|
|
851
|
+
]
|
|
852
|
+
}
|
|
696
853
|
]
|
|
697
854
|
],
|
|
698
855
|
"else": {
|
|
699
856
|
"tmpl": [
|
|
700
|
-
|
|
857
|
+
{ "fn": "require", "args": ["pgShow"] },
|
|
858
|
+
{ "fn": "require", "args": ["pgStrInt"] },
|
|
859
|
+
{ "fn": "require", "args": ["pgStrFloat"] },
|
|
860
|
+
"{__PgRt.Show(",
|
|
701
861
|
{
|
|
702
862
|
"emit": "item"
|
|
703
863
|
},
|
|
704
|
-
"}"
|
|
864
|
+
")}"
|
|
705
865
|
]
|
|
706
866
|
}
|
|
707
867
|
}
|
|
@@ -715,7 +875,7 @@
|
|
|
715
875
|
"tmpl": [
|
|
716
876
|
"'",
|
|
717
877
|
{
|
|
718
|
-
"fn": "
|
|
878
|
+
"fn": "literal",
|
|
719
879
|
"args": [
|
|
720
880
|
"char",
|
|
721
881
|
{
|
|
@@ -1127,7 +1287,7 @@
|
|
|
1127
1287
|
"EnumDecl": {
|
|
1128
1288
|
"line": {
|
|
1129
1289
|
"tmpl": [
|
|
1130
|
-
{ "
|
|
1290
|
+
{ "call": "csAccess" },
|
|
1131
1291
|
"enum ",
|
|
1132
1292
|
{
|
|
1133
1293
|
"fn": "ident",
|
|
@@ -1326,6 +1486,7 @@
|
|
|
1326
1486
|
{
|
|
1327
1487
|
"case": {
|
|
1328
1488
|
"when": [
|
|
1489
|
+
[ { "eq": [ "decl.isAbstract", "true" ] }, "abstract " ],
|
|
1329
1490
|
[
|
|
1330
1491
|
{
|
|
1331
1492
|
"eq": [
|
|
@@ -1384,12 +1545,22 @@
|
|
|
1384
1545
|
},
|
|
1385
1546
|
" ",
|
|
1386
1547
|
{
|
|
1387
|
-
"
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1548
|
+
"case": {
|
|
1549
|
+
"when": [
|
|
1550
|
+
[
|
|
1551
|
+
{ "has": "decl.linkName" },
|
|
1552
|
+
{ "fn": "mangle", "args": [ { "fn": "ident", "args": [ { "get": "decl.linkName" } ] } ] }
|
|
1553
|
+
]
|
|
1554
|
+
],
|
|
1555
|
+
"else": {
|
|
1556
|
+
"fn": "ident",
|
|
1557
|
+
"args": [
|
|
1558
|
+
{
|
|
1559
|
+
"get": "decl.name"
|
|
1560
|
+
}
|
|
1561
|
+
]
|
|
1391
1562
|
}
|
|
1392
|
-
|
|
1563
|
+
}
|
|
1393
1564
|
},
|
|
1394
1565
|
{
|
|
1395
1566
|
"fn": "generics"
|
|
@@ -1434,6 +1605,7 @@
|
|
|
1434
1605
|
"line": {
|
|
1435
1606
|
"tmpl": [
|
|
1436
1607
|
"public ",
|
|
1608
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isStatic", "true" ] }, "static " ] ] } },
|
|
1437
1609
|
{
|
|
1438
1610
|
"type": "decl.returnType"
|
|
1439
1611
|
},
|
|
@@ -1557,6 +1729,7 @@
|
|
|
1557
1729
|
"line": {
|
|
1558
1730
|
"tmpl": [
|
|
1559
1731
|
"public ",
|
|
1732
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isStatic", "true" ] }, "static " ] ] } },
|
|
1560
1733
|
{
|
|
1561
1734
|
"type": "decl.returnType"
|
|
1562
1735
|
},
|
|
@@ -1585,6 +1758,7 @@
|
|
|
1585
1758
|
"line": {
|
|
1586
1759
|
"tmpl": [
|
|
1587
1760
|
"public ",
|
|
1761
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isStatic", "true" ] }, "static " ] ] } },
|
|
1588
1762
|
{
|
|
1589
1763
|
"type": "decl.returnType"
|
|
1590
1764
|
},
|
|
@@ -1715,19 +1889,24 @@
|
|
|
1715
1889
|
{
|
|
1716
1890
|
"indent": [
|
|
1717
1891
|
{
|
|
1718
|
-
"
|
|
1719
|
-
"
|
|
1720
|
-
|
|
1721
|
-
{
|
|
1722
|
-
"
|
|
1723
|
-
|
|
1892
|
+
"case": {
|
|
1893
|
+
"when": [ [ { "eq": [ "decl.setterValueParam", "value" ] }, "" ] ],
|
|
1894
|
+
"else": {
|
|
1895
|
+
"line": {
|
|
1896
|
+
"tmpl": [
|
|
1897
|
+
"var ",
|
|
1724
1898
|
{
|
|
1725
|
-
"
|
|
1726
|
-
|
|
1899
|
+
"fn": "ident",
|
|
1900
|
+
"args": [
|
|
1901
|
+
{
|
|
1902
|
+
"get": "decl.setterValueParam"
|
|
1903
|
+
}
|
|
1904
|
+
]
|
|
1905
|
+
},
|
|
1906
|
+
" = value;"
|
|
1727
1907
|
]
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
]
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1731
1910
|
}
|
|
1732
1911
|
},
|
|
1733
1912
|
{
|
|
@@ -1855,17 +2034,31 @@
|
|
|
1855
2034
|
"tmpl": [
|
|
1856
2035
|
"public virtual bool Equals(",
|
|
1857
2036
|
{
|
|
1858
|
-
"
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
2037
|
+
"type": "decl.params.0.type"
|
|
2038
|
+
},
|
|
2039
|
+
"? ",
|
|
2040
|
+
{
|
|
2041
|
+
"fn": "ident",
|
|
2042
|
+
"args": [
|
|
2043
|
+
{
|
|
2044
|
+
"get": "decl.params.0.name"
|
|
2045
|
+
}
|
|
2046
|
+
]
|
|
1863
2047
|
},
|
|
1864
2048
|
") => ",
|
|
2049
|
+
{
|
|
2050
|
+
"fn": "ident",
|
|
2051
|
+
"args": [
|
|
2052
|
+
{
|
|
2053
|
+
"get": "decl.params.0.name"
|
|
2054
|
+
}
|
|
2055
|
+
]
|
|
2056
|
+
},
|
|
2057
|
+
" is not null && (",
|
|
1865
2058
|
{
|
|
1866
2059
|
"emit": "decl.exprBody"
|
|
1867
2060
|
},
|
|
1868
|
-
";"
|
|
2061
|
+
");"
|
|
1869
2062
|
]
|
|
1870
2063
|
}
|
|
1871
2064
|
}
|
|
@@ -1877,16 +2070,37 @@
|
|
|
1877
2070
|
"tmpl": [
|
|
1878
2071
|
"public virtual bool Equals(",
|
|
1879
2072
|
{
|
|
1880
|
-
"
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
2073
|
+
"type": "decl.params.0.type"
|
|
2074
|
+
},
|
|
2075
|
+
"? ",
|
|
2076
|
+
{
|
|
2077
|
+
"fn": "ident",
|
|
2078
|
+
"args": [
|
|
2079
|
+
{
|
|
2080
|
+
"get": "decl.params.0.name"
|
|
2081
|
+
}
|
|
2082
|
+
]
|
|
1885
2083
|
},
|
|
1886
2084
|
")"
|
|
1887
2085
|
]
|
|
1888
2086
|
},
|
|
1889
2087
|
"body": [
|
|
2088
|
+
{
|
|
2089
|
+
"line": {
|
|
2090
|
+
"tmpl": [
|
|
2091
|
+
"if (",
|
|
2092
|
+
{
|
|
2093
|
+
"fn": "ident",
|
|
2094
|
+
"args": [
|
|
2095
|
+
{
|
|
2096
|
+
"get": "decl.params.0.name"
|
|
2097
|
+
}
|
|
2098
|
+
]
|
|
2099
|
+
},
|
|
2100
|
+
" is null) return false;"
|
|
2101
|
+
]
|
|
2102
|
+
}
|
|
2103
|
+
},
|
|
1890
2104
|
{
|
|
1891
2105
|
"stmts": "decl.body"
|
|
1892
2106
|
}
|
|
@@ -1919,7 +2133,7 @@
|
|
|
1919
2133
|
}
|
|
1920
2134
|
]
|
|
1921
2135
|
},
|
|
1922
|
-
" a, ",
|
|
2136
|
+
"? a, ",
|
|
1923
2137
|
{
|
|
1924
2138
|
"fn": "ident",
|
|
1925
2139
|
"args": [
|
|
@@ -1928,7 +2142,7 @@
|
|
|
1928
2142
|
}
|
|
1929
2143
|
]
|
|
1930
2144
|
},
|
|
1931
|
-
" b) => a is null || b is null ? ReferenceEquals(a, b) : a.Equals(b);"
|
|
2145
|
+
"? b) => a is null || b is null ? ReferenceEquals(a, b) : a.Equals(b);"
|
|
1932
2146
|
]
|
|
1933
2147
|
}
|
|
1934
2148
|
},
|
|
@@ -1944,7 +2158,7 @@
|
|
|
1944
2158
|
}
|
|
1945
2159
|
]
|
|
1946
2160
|
},
|
|
1947
|
-
" a, ",
|
|
2161
|
+
"? a, ",
|
|
1948
2162
|
{
|
|
1949
2163
|
"fn": "ident",
|
|
1950
2164
|
"args": [
|
|
@@ -1953,7 +2167,7 @@
|
|
|
1953
2167
|
}
|
|
1954
2168
|
]
|
|
1955
2169
|
},
|
|
1956
|
-
" b) => !(a == b);"
|
|
2170
|
+
"? b) => !(a == b);"
|
|
1957
2171
|
]
|
|
1958
2172
|
}
|
|
1959
2173
|
},
|
|
@@ -1972,9 +2186,6 @@
|
|
|
1972
2186
|
" __o && this.Equals(__o);"
|
|
1973
2187
|
]
|
|
1974
2188
|
}
|
|
1975
|
-
},
|
|
1976
|
-
{
|
|
1977
|
-
"line": "public override int GetHashCode() => 0;"
|
|
1978
2189
|
}
|
|
1979
2190
|
]
|
|
1980
2191
|
}
|
|
@@ -1986,6 +2197,59 @@
|
|
|
1986
2197
|
]
|
|
1987
2198
|
}
|
|
1988
2199
|
],
|
|
2200
|
+
[
|
|
2201
|
+
{
|
|
2202
|
+
"and": [
|
|
2203
|
+
{
|
|
2204
|
+
"eq": [
|
|
2205
|
+
"decl.kind",
|
|
2206
|
+
"operator"
|
|
2207
|
+
]
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
"eq": [
|
|
2211
|
+
"decl.opSymbol",
|
|
2212
|
+
"hash"
|
|
2213
|
+
]
|
|
2214
|
+
}
|
|
2215
|
+
]
|
|
2216
|
+
},
|
|
2217
|
+
{
|
|
2218
|
+
"case": {
|
|
2219
|
+
"when": [
|
|
2220
|
+
[
|
|
2221
|
+
{
|
|
2222
|
+
"eq": [
|
|
2223
|
+
"decl.exprBodied",
|
|
2224
|
+
"true"
|
|
2225
|
+
]
|
|
2226
|
+
},
|
|
2227
|
+
{
|
|
2228
|
+
"line": {
|
|
2229
|
+
"tmpl": [
|
|
2230
|
+
"public override int GetHashCode() => ",
|
|
2231
|
+
{
|
|
2232
|
+
"emit": "decl.exprBody"
|
|
2233
|
+
},
|
|
2234
|
+
";"
|
|
2235
|
+
]
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
]
|
|
2239
|
+
],
|
|
2240
|
+
"else": {
|
|
2241
|
+
"block": {
|
|
2242
|
+
"head": "public override int GetHashCode()",
|
|
2243
|
+
"body": [
|
|
2244
|
+
{
|
|
2245
|
+
"stmts": "decl.body"
|
|
2246
|
+
}
|
|
2247
|
+
]
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
],
|
|
1989
2253
|
[
|
|
1990
2254
|
{
|
|
1991
2255
|
"and": [
|
|
@@ -2108,6 +2372,10 @@
|
|
|
2108
2372
|
"else": {
|
|
2109
2373
|
"case": {
|
|
2110
2374
|
"when": [
|
|
2375
|
+
[
|
|
2376
|
+
{ "eq": [ "decl.isAbstract", "true" ] },
|
|
2377
|
+
{ "line": { "tmpl": [ { "call": "csMethodSig" }, ";" ] } }
|
|
2378
|
+
],
|
|
2111
2379
|
[
|
|
2112
2380
|
{
|
|
2113
2381
|
"eq": [
|
|
@@ -2149,7 +2417,7 @@
|
|
|
2149
2417
|
},
|
|
2150
2418
|
"csRecordHead": {
|
|
2151
2419
|
"tmpl": [
|
|
2152
|
-
{ "
|
|
2420
|
+
{ "call": "csAccess" },
|
|
2153
2421
|
"record ",
|
|
2154
2422
|
{
|
|
2155
2423
|
"fn": "ident",
|
|
@@ -2381,6 +2649,25 @@
|
|
|
2381
2649
|
}
|
|
2382
2650
|
]
|
|
2383
2651
|
},
|
|
2652
|
+
"csRangeDecl": {
|
|
2653
|
+
"case": {
|
|
2654
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "true" ] }, "var " ] ],
|
|
2655
|
+
"else": { "tmpl": [ { "type": "stmt.rangeType" }, " " ] }
|
|
2656
|
+
}
|
|
2657
|
+
},
|
|
2658
|
+
"rangeEndDecl": {
|
|
2659
|
+
"case": {
|
|
2660
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "false" ] },
|
|
2661
|
+
{ "tmpl": [ ", ", { "fn": "ident", "args": [ { "get": "stmt.rangeEndTemp" } ] }, " = ", { "emit": "stmt.rangeEnd" } ] } ] ],
|
|
2662
|
+
"else": ""
|
|
2663
|
+
}
|
|
2664
|
+
},
|
|
2665
|
+
"rangeEndRead": {
|
|
2666
|
+
"case": {
|
|
2667
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "true" ] }, { "emit": "stmt.rangeEnd" } ] ],
|
|
2668
|
+
"else": { "fn": "ident", "args": [ { "get": "stmt.rangeEndTemp" } ] }
|
|
2669
|
+
}
|
|
2670
|
+
},
|
|
2384
2671
|
"ForStmt": {
|
|
2385
2672
|
"case": {
|
|
2386
2673
|
"when": [
|
|
@@ -2394,16 +2681,59 @@
|
|
|
2394
2681
|
{
|
|
2395
2682
|
"case": {
|
|
2396
2683
|
"when": [
|
|
2684
|
+
[
|
|
2685
|
+
{ "eq": [ "stmt.inclusiveMayWrap", "true" ] },
|
|
2686
|
+
{
|
|
2687
|
+
"block": {
|
|
2688
|
+
"head": {
|
|
2689
|
+
"tmpl": [
|
|
2690
|
+
"for (",
|
|
2691
|
+
{ "fn": "table", "args": [ "rangeWideType", { "get": "stmt.rangeTypeName" } ] },
|
|
2692
|
+
" ",
|
|
2693
|
+
{ "get": "stmt.driver" },
|
|
2694
|
+
" = ",
|
|
2695
|
+
{ "emit": "stmt.rangeStart" },
|
|
2696
|
+
{ "call": "rangeEndDecl" },
|
|
2697
|
+
"; ",
|
|
2698
|
+
{ "get": "stmt.driver" },
|
|
2699
|
+
" <= ",
|
|
2700
|
+
{ "call": "rangeEndRead" },
|
|
2701
|
+
"; ",
|
|
2702
|
+
{ "get": "stmt.driver" },
|
|
2703
|
+
"++)"
|
|
2704
|
+
]
|
|
2705
|
+
},
|
|
2706
|
+
"body": [
|
|
2707
|
+
{
|
|
2708
|
+
"line": {
|
|
2709
|
+
"tmpl": [
|
|
2710
|
+
"var ",
|
|
2711
|
+
{ "fn": "ident", "args": [ { "get": "stmt.binding" } ] },
|
|
2712
|
+
" = (",
|
|
2713
|
+
{ "type": "stmt.rangeType" },
|
|
2714
|
+
")",
|
|
2715
|
+
{ "get": "stmt.driver" },
|
|
2716
|
+
";"
|
|
2717
|
+
]
|
|
2718
|
+
}
|
|
2719
|
+
},
|
|
2720
|
+
{ "stmts": "stmt.body" }
|
|
2721
|
+
]
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
],
|
|
2397
2725
|
[
|
|
2398
2726
|
{ "eq": [ "stmt.captured", "true" ] },
|
|
2399
2727
|
{
|
|
2400
2728
|
"block": {
|
|
2401
2729
|
"head": {
|
|
2402
2730
|
"tmpl": [
|
|
2403
|
-
"for (
|
|
2731
|
+
"for (",
|
|
2732
|
+
{ "call": "csRangeDecl" },
|
|
2404
2733
|
{ "get": "stmt.driver" },
|
|
2405
2734
|
" = ",
|
|
2406
2735
|
{ "emit": "stmt.rangeStart" },
|
|
2736
|
+
{ "call": "rangeEndDecl" },
|
|
2407
2737
|
"; ",
|
|
2408
2738
|
{ "get": "stmt.driver" },
|
|
2409
2739
|
{
|
|
@@ -2412,7 +2742,7 @@
|
|
|
2412
2742
|
"else": " < "
|
|
2413
2743
|
}
|
|
2414
2744
|
},
|
|
2415
|
-
{ "
|
|
2745
|
+
{ "call": "rangeEndRead" },
|
|
2416
2746
|
"; ",
|
|
2417
2747
|
{ "get": "stmt.driver" },
|
|
2418
2748
|
"++)"
|
|
@@ -2440,7 +2770,8 @@
|
|
|
2440
2770
|
"block": {
|
|
2441
2771
|
"head": {
|
|
2442
2772
|
"tmpl": [
|
|
2443
|
-
"for (
|
|
2773
|
+
"for (",
|
|
2774
|
+
{ "call": "csRangeDecl" },
|
|
2444
2775
|
{
|
|
2445
2776
|
"fn": "ident",
|
|
2446
2777
|
"args": [
|
|
@@ -2453,6 +2784,7 @@
|
|
|
2453
2784
|
{
|
|
2454
2785
|
"emit": "stmt.rangeStart"
|
|
2455
2786
|
},
|
|
2787
|
+
{ "call": "rangeEndDecl" },
|
|
2456
2788
|
"; ",
|
|
2457
2789
|
{
|
|
2458
2790
|
"fn": "ident",
|
|
@@ -2478,9 +2810,7 @@
|
|
|
2478
2810
|
"else": " < "
|
|
2479
2811
|
}
|
|
2480
2812
|
},
|
|
2481
|
-
{
|
|
2482
|
-
"emit": "stmt.rangeEnd"
|
|
2483
|
-
},
|
|
2813
|
+
{ "call": "rangeEndRead" },
|
|
2484
2814
|
"; ",
|
|
2485
2815
|
{
|
|
2486
2816
|
"fn": "ident",
|
|
@@ -2571,9 +2901,35 @@
|
|
|
2571
2901
|
},
|
|
2572
2902
|
"Program": {
|
|
2573
2903
|
"seq": [
|
|
2904
|
+
{
|
|
2905
|
+
"line": "// <auto-generated/>"
|
|
2906
|
+
},
|
|
2907
|
+
{
|
|
2908
|
+
"line": "// Generated by Polyglot. Do not edit: regenerate with `polyglot build`."
|
|
2909
|
+
},
|
|
2574
2910
|
{
|
|
2575
2911
|
"line": "#nullable enable"
|
|
2576
2912
|
},
|
|
2913
|
+
{
|
|
2914
|
+
"case": {
|
|
2915
|
+
"when": [
|
|
2916
|
+
[
|
|
2917
|
+
{ "not": { "eq": ["module.allLowercaseTypeNames.count", "0"] } },
|
|
2918
|
+
{ "line": "#pragma warning disable CS8981 // a .pg type name may be all lowercase" }
|
|
2919
|
+
]
|
|
2920
|
+
]
|
|
2921
|
+
}
|
|
2922
|
+
},
|
|
2923
|
+
{
|
|
2924
|
+
"case": {
|
|
2925
|
+
"when": [
|
|
2926
|
+
[
|
|
2927
|
+
{ "not": { "eq": ["option.namespace", ""] } },
|
|
2928
|
+
{ "line": { "tmpl": ["namespace ", { "get": "option.namespace" }, ";"] } }
|
|
2929
|
+
]
|
|
2930
|
+
]
|
|
2931
|
+
}
|
|
2932
|
+
},
|
|
2577
2933
|
{
|
|
2578
2934
|
"case": {
|
|
2579
2935
|
"when": [
|
|
@@ -2608,12 +2964,19 @@
|
|
|
2608
2964
|
}
|
|
2609
2965
|
},
|
|
2610
2966
|
{
|
|
2611
|
-
"line": "using static
|
|
2967
|
+
"line": { "tmpl": ["using static ", { "get": "option.class" }, ";"] }
|
|
2612
2968
|
}
|
|
2613
2969
|
]
|
|
2614
2970
|
]
|
|
2615
2971
|
}
|
|
2616
2972
|
},
|
|
2973
|
+
{
|
|
2974
|
+
"fn": "preludeSlot",
|
|
2975
|
+
"args": [
|
|
2976
|
+
"file static class __PgRt\n{\n",
|
|
2977
|
+
"}\n"
|
|
2978
|
+
]
|
|
2979
|
+
},
|
|
2617
2980
|
{
|
|
2618
2981
|
"line": ""
|
|
2619
2982
|
},
|
|
@@ -2653,9 +3016,7 @@
|
|
|
2653
3016
|
"block": {
|
|
2654
3017
|
"head": {
|
|
2655
3018
|
"tmpl": [
|
|
2656
|
-
{
|
|
2657
|
-
"fn": "access"
|
|
2658
|
-
},
|
|
3019
|
+
{ "call": "csAccess" },
|
|
2659
3020
|
"static ",
|
|
2660
3021
|
{
|
|
2661
3022
|
"case": {
|
|
@@ -2692,7 +3053,7 @@
|
|
|
2692
3053
|
"case": {
|
|
2693
3054
|
"when": [
|
|
2694
3055
|
[
|
|
2695
|
-
{
|
|
3056
|
+
{ "and": [{
|
|
2696
3057
|
"or": [
|
|
2697
3058
|
{
|
|
2698
3059
|
"not": {
|
|
@@ -2735,7 +3096,7 @@
|
|
|
2735
3096
|
}
|
|
2736
3097
|
}
|
|
2737
3098
|
]
|
|
2738
|
-
},
|
|
3099
|
+
}, { "or": [{ "not": { "eq": ["module.globals.count", "0"] } }, { "not": { "eq": ["module.functions.count", "0"] } }] }] },
|
|
2739
3100
|
{
|
|
2740
3101
|
"line": ""
|
|
2741
3102
|
}
|
|
@@ -2744,12 +3105,15 @@
|
|
|
2744
3105
|
}
|
|
2745
3106
|
},
|
|
2746
3107
|
{
|
|
3108
|
+
"case": {
|
|
3109
|
+
"when": [
|
|
3110
|
+
[
|
|
3111
|
+
{ "or": [{ "not": { "eq": ["module.globals.count", "0"] } }, { "not": { "eq": ["module.functions.count", "0"] } }] },
|
|
3112
|
+
{
|
|
2747
3113
|
"block": {
|
|
2748
3114
|
"head": {
|
|
2749
3115
|
"tmpl": [
|
|
2750
|
-
{
|
|
2751
|
-
"fn": "access"
|
|
2752
|
-
},
|
|
3116
|
+
{ "call": "csAccess" },
|
|
2753
3117
|
"static ",
|
|
2754
3118
|
{
|
|
2755
3119
|
"case": {
|
|
@@ -2767,7 +3131,8 @@
|
|
|
2767
3131
|
"else": ""
|
|
2768
3132
|
}
|
|
2769
3133
|
},
|
|
2770
|
-
"class
|
|
3134
|
+
"class ",
|
|
3135
|
+
{ "get": "option.class" }
|
|
2771
3136
|
]
|
|
2772
3137
|
},
|
|
2773
3138
|
"body": [
|
|
@@ -2825,9 +3190,19 @@
|
|
|
2825
3190
|
"when": [
|
|
2826
3191
|
[
|
|
2827
3192
|
{
|
|
2828
|
-
"
|
|
2829
|
-
|
|
2830
|
-
|
|
3193
|
+
"and": [
|
|
3194
|
+
{
|
|
3195
|
+
"eq": [
|
|
3196
|
+
"module.hasEntry",
|
|
3197
|
+
"true"
|
|
3198
|
+
]
|
|
3199
|
+
},
|
|
3200
|
+
{
|
|
3201
|
+
"eq": [
|
|
3202
|
+
"option.entryPoint",
|
|
3203
|
+
"true"
|
|
3204
|
+
]
|
|
3205
|
+
}
|
|
2831
3206
|
]
|
|
2832
3207
|
},
|
|
2833
3208
|
{
|
|
@@ -2846,12 +3221,12 @@
|
|
|
2846
3221
|
]
|
|
2847
3222
|
},
|
|
2848
3223
|
{
|
|
2849
|
-
"line": "static void Main() {
|
|
3224
|
+
"line": "static void Main() { main().GetAwaiter().GetResult(); }"
|
|
2850
3225
|
}
|
|
2851
3226
|
]
|
|
2852
3227
|
],
|
|
2853
3228
|
"else": {
|
|
2854
|
-
"line": "static void Main() {
|
|
3229
|
+
"line": "static void Main() { main(); }"
|
|
2855
3230
|
}
|
|
2856
3231
|
}
|
|
2857
3232
|
}
|
|
@@ -2863,12 +3238,31 @@
|
|
|
2863
3238
|
}
|
|
2864
3239
|
]
|
|
2865
3240
|
}
|
|
3241
|
+
}
|
|
3242
|
+
]
|
|
3243
|
+
]
|
|
3244
|
+
}
|
|
2866
3245
|
}
|
|
2867
3246
|
]
|
|
2868
3247
|
},
|
|
3248
|
+
"csAccess": {
|
|
3249
|
+
"case": {
|
|
3250
|
+
"when": [
|
|
3251
|
+
[
|
|
3252
|
+
{ "not": { "eq": ["option.access", ""] } },
|
|
3253
|
+
{ "tmpl": [{ "get": "option.access" }, " "] }
|
|
3254
|
+
]
|
|
3255
|
+
]
|
|
3256
|
+
}
|
|
3257
|
+
},
|
|
2869
3258
|
"csFnSig": {
|
|
2870
3259
|
"tmpl": [
|
|
2871
|
-
|
|
3260
|
+
{
|
|
3261
|
+
"case": {
|
|
3262
|
+
"when": [[{ "eq": ["decl.isPrelude", "true"] }, "internal static "]],
|
|
3263
|
+
"else": "public static "
|
|
3264
|
+
}
|
|
3265
|
+
},
|
|
2872
3266
|
{
|
|
2873
3267
|
"case": {
|
|
2874
3268
|
"when": [
|
|
@@ -2906,12 +3300,22 @@
|
|
|
2906
3300
|
},
|
|
2907
3301
|
" ",
|
|
2908
3302
|
{
|
|
2909
|
-
"
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
3303
|
+
"case": {
|
|
3304
|
+
"when": [
|
|
3305
|
+
[
|
|
3306
|
+
{ "has": "decl.linkName" },
|
|
3307
|
+
{ "fn": "mangle", "args": [ { "fn": "ident", "args": [ { "get": "decl.linkName" } ] } ] }
|
|
3308
|
+
]
|
|
3309
|
+
],
|
|
3310
|
+
"else": {
|
|
3311
|
+
"fn": "ident",
|
|
3312
|
+
"args": [
|
|
3313
|
+
{
|
|
3314
|
+
"get": "decl.name"
|
|
3315
|
+
}
|
|
3316
|
+
]
|
|
2913
3317
|
}
|
|
2914
|
-
|
|
3318
|
+
}
|
|
2915
3319
|
},
|
|
2916
3320
|
{
|
|
2917
3321
|
"fn": "generics"
|
|
@@ -2944,7 +3348,12 @@
|
|
|
2944
3348
|
},
|
|
2945
3349
|
"csExtSig": {
|
|
2946
3350
|
"tmpl": [
|
|
2947
|
-
|
|
3351
|
+
{
|
|
3352
|
+
"case": {
|
|
3353
|
+
"when": [[{ "eq": ["decl.isPrelude", "true"] }, "internal static "]],
|
|
3354
|
+
"else": "public static "
|
|
3355
|
+
}
|
|
3356
|
+
},
|
|
2948
3357
|
{
|
|
2949
3358
|
"type": "decl.returnType"
|
|
2950
3359
|
},
|
|
@@ -3042,7 +3451,8 @@
|
|
|
3042
3451
|
},
|
|
3043
3452
|
"csClassHead": {
|
|
3044
3453
|
"tmpl": [
|
|
3045
|
-
{ "
|
|
3454
|
+
{ "call": "csAccess" },
|
|
3455
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, "abstract " ] ] } },
|
|
3046
3456
|
"class ",
|
|
3047
3457
|
{
|
|
3048
3458
|
"fn": "ident",
|
|
@@ -3160,9 +3570,9 @@
|
|
|
3160
3570
|
"when": [
|
|
3161
3571
|
[
|
|
3162
3572
|
{
|
|
3163
|
-
"
|
|
3164
|
-
"item.hasInit",
|
|
3165
|
-
"
|
|
3573
|
+
"and": [
|
|
3574
|
+
{ "eq": [ "item.hasInit", "true" ] },
|
|
3575
|
+
{ "eq": [ "item.deferInit", "false" ] }
|
|
3166
3576
|
]
|
|
3167
3577
|
},
|
|
3168
3578
|
{
|
|
@@ -3187,9 +3597,9 @@
|
|
|
3187
3597
|
"when": [
|
|
3188
3598
|
[
|
|
3189
3599
|
{
|
|
3190
|
-
"
|
|
3191
|
-
"decl.hasInit",
|
|
3192
|
-
"
|
|
3600
|
+
"or": [
|
|
3601
|
+
{ "eq": [ "decl.hasInit", "true" ] },
|
|
3602
|
+
{ "not": { "eq": [ "decl.deferredInitFields.count", "0" ] } }
|
|
3193
3603
|
]
|
|
3194
3604
|
},
|
|
3195
3605
|
{
|
|
@@ -3244,6 +3654,12 @@
|
|
|
3244
3654
|
]
|
|
3245
3655
|
},
|
|
3246
3656
|
"body": [
|
|
3657
|
+
{
|
|
3658
|
+
"mapDecl": "decl.deferredInitFields",
|
|
3659
|
+
"each": { "line": { "tmpl": [
|
|
3660
|
+
"this.", { "fn": "ident", "args": [ { "get": "item.name" } ] }, " = ", { "emit": "item.init" }, ";"
|
|
3661
|
+
] } }
|
|
3662
|
+
},
|
|
3247
3663
|
{
|
|
3248
3664
|
"stmts": "decl.initBody"
|
|
3249
3665
|
}
|
|
@@ -3265,7 +3681,7 @@
|
|
|
3265
3681
|
"block": {
|
|
3266
3682
|
"head": {
|
|
3267
3683
|
"tmpl": [
|
|
3268
|
-
{ "
|
|
3684
|
+
{ "call": "csAccess" },
|
|
3269
3685
|
"interface ",
|
|
3270
3686
|
{
|
|
3271
3687
|
"fn": "ident",
|
|
@@ -3392,7 +3808,7 @@
|
|
|
3392
3808
|
{
|
|
3393
3809
|
"line": {
|
|
3394
3810
|
"tmpl": [
|
|
3395
|
-
{ "
|
|
3811
|
+
{ "call": "csAccess" },
|
|
3396
3812
|
"abstract record ",
|
|
3397
3813
|
{
|
|
3398
3814
|
"fn": "ident",
|
|
@@ -3414,7 +3830,7 @@
|
|
|
3414
3830
|
"each": {
|
|
3415
3831
|
"line": {
|
|
3416
3832
|
"tmpl": [
|
|
3417
|
-
{ "
|
|
3833
|
+
{ "call": "csAccess" },
|
|
3418
3834
|
"sealed record ",
|
|
3419
3835
|
{
|
|
3420
3836
|
"fn": "ident",
|
|
@@ -3470,6 +3886,32 @@
|
|
|
3470
3886
|
"Type": {
|
|
3471
3887
|
"case": {
|
|
3472
3888
|
"when": [
|
|
3889
|
+
[
|
|
3890
|
+
{
|
|
3891
|
+
"and": [
|
|
3892
|
+
{
|
|
3893
|
+
"eq": [
|
|
3894
|
+
"type.kind",
|
|
3895
|
+
"function"
|
|
3896
|
+
]
|
|
3897
|
+
},
|
|
3898
|
+
{
|
|
3899
|
+
"eq": [
|
|
3900
|
+
"type.nullable",
|
|
3901
|
+
"true"
|
|
3902
|
+
]
|
|
3903
|
+
}
|
|
3904
|
+
]
|
|
3905
|
+
},
|
|
3906
|
+
{
|
|
3907
|
+
"tmpl": [
|
|
3908
|
+
{
|
|
3909
|
+
"type": "type.base"
|
|
3910
|
+
},
|
|
3911
|
+
"?"
|
|
3912
|
+
]
|
|
3913
|
+
}
|
|
3914
|
+
],
|
|
3473
3915
|
[
|
|
3474
3916
|
{
|
|
3475
3917
|
"eq": [
|
|
@@ -3659,10 +4101,20 @@
|
|
|
3659
4101
|
"List.add": "$this.Add($0)",
|
|
3660
4102
|
"List.clear": "$this.Clear()",
|
|
3661
4103
|
"List.removeAll": "$this.RemoveAll($0)",
|
|
3662
|
-
"List.removeAt": "$this.RemoveAt($0)"
|
|
4104
|
+
"List.removeAt": "$this.RemoveAt($0)",
|
|
4105
|
+
"IMapKey.type": "notnull",
|
|
4106
|
+
"Map.type": "global::System.Collections.Generic.OrderedDictionary<$0, $1>",
|
|
4107
|
+
"Map.constructor": "new $T()",
|
|
4108
|
+
"Map.count": "$this.Count",
|
|
4109
|
+
"Map.get": "($this.TryGetValue($0, out var $tmp) ? $tmp : ($T)null)",
|
|
4110
|
+
"Map.set": "$this[$0] = $1",
|
|
4111
|
+
"Map.has": "$this.ContainsKey($0)",
|
|
4112
|
+
"Map.remove": "$this.Remove($0)",
|
|
4113
|
+
"Map.keys": "new $T($this.Keys)",
|
|
4114
|
+
"Map.values": "new $T($this.Values)"
|
|
3663
4115
|
},
|
|
3664
4116
|
"std.io": {
|
|
3665
|
-
"print": "global::System.Console.WriteLine(x
|
|
4117
|
+
"print": { "template": "global::System.Console.WriteLine(__PgRt.Show(x))", "requires": ["pgShow", "pgStrInt", "pgStrFloat"] },
|
|
3666
4118
|
"readText": "global::System.IO.File.ReadAllText(path)",
|
|
3667
4119
|
"writeText": "global::System.IO.File.WriteAllText(path, content)",
|
|
3668
4120
|
"appendText": "global::System.IO.File.AppendAllText(path, content)",
|
|
@@ -3673,6 +4125,7 @@
|
|
|
3673
4125
|
"Math.PI": "global::System.Math.PI",
|
|
3674
4126
|
"Math.E": "global::System.Math.E",
|
|
3675
4127
|
"Math.sqrt": "global::System.Math.Sqrt($0)",
|
|
4128
|
+
"Math.isNaN": "double.IsNaN($0)",
|
|
3676
4129
|
"Math.ln": "global::System.Math.Log($0)",
|
|
3677
4130
|
"Math.log": "global::System.Math.Log($0)",
|
|
3678
4131
|
"Math.log2": "global::System.Math.Log2($0)",
|
|
@@ -3705,12 +4158,23 @@
|
|
|
3705
4158
|
"std.strings": {
|
|
3706
4159
|
"string.isEmpty": "($this.Length == 0)",
|
|
3707
4160
|
"string.len": "$this.Length",
|
|
3708
|
-
"string.toUpper": "$this.
|
|
3709
|
-
"string.toLower": "$this.
|
|
3710
|
-
"string.
|
|
3711
|
-
"string.
|
|
4161
|
+
"string.toUpper": "$this.ToUpperInvariant()",
|
|
4162
|
+
"string.toLower": "$this.ToLowerInvariant()",
|
|
4163
|
+
"string.toUpperAscii": { "template": "__PgRt.UpperAscii($this)", "requires": ["pgAscii"] },
|
|
4164
|
+
"string.toLowerAscii": { "template": "__PgRt.LowerAscii($this)", "requires": ["pgAscii"] },
|
|
3712
4165
|
"string.codePoints": "global::System.Linq.Enumerable.Select($this.EnumerateRunes(), __r => __r.ToString())",
|
|
3713
|
-
"string.
|
|
4166
|
+
"string.startsWith": "$this.StartsWith($0, global::System.StringComparison.Ordinal)",
|
|
4167
|
+
"string.endsWith": "$this.EndsWith($0, global::System.StringComparison.Ordinal)",
|
|
4168
|
+
"string.contains": "$this.Contains($0)",
|
|
4169
|
+
"string.trimAscii": "$this.Trim('\\t', '\\n', '\\v', '\\f', '\\r', ' ')",
|
|
4170
|
+
"compareOrdinal": "global::System.Math.Sign(string.CompareOrdinal(a, b))",
|
|
4171
|
+
"string.__pgCharAt": "$this[$0].ToString()",
|
|
4172
|
+
"string.__pgCodePointAt": "(char.IsSurrogatePair($this, $0) ? char.ConvertToUtf32($this, $0) : (int)$this[$0])",
|
|
4173
|
+
"string.__pgSubstring": "$this.Substring($0, $1 - $0)",
|
|
4174
|
+
"string.__pgIndexOf": "$this.IndexOf($0, $1, global::System.StringComparison.Ordinal)",
|
|
4175
|
+
"string.__pgReplaceAll": "$this.Replace($0, $1)",
|
|
4176
|
+
"string.__pgSplit": "new global::System.Collections.Generic.List<string>($this.Split($0))",
|
|
4177
|
+
"string.__pgFromCodePoint": "char.ConvertFromUtf32($0)"
|
|
3714
4178
|
},
|
|
3715
4179
|
"std.core": {
|
|
3716
4180
|
"Error.type": "global::System.Exception",
|
|
@@ -3720,17 +4184,20 @@
|
|
|
3720
4184
|
"Array.type": "$0[]",
|
|
3721
4185
|
"Array.constructor": "global::System.Array.Empty<$0>()",
|
|
3722
4186
|
"Array.count": "$this.Length",
|
|
3723
|
-
"
|
|
3724
|
-
"
|
|
3725
|
-
"
|
|
3726
|
-
"
|
|
3727
|
-
"
|
|
3728
|
-
"
|
|
3729
|
-
"
|
|
3730
|
-
"
|
|
3731
|
-
"
|
|
3732
|
-
"
|
|
4187
|
+
"__pgText.rawLen": "$0.Length",
|
|
4188
|
+
"__pgText.rawCode": "((int)$0[$1])",
|
|
4189
|
+
"i8.__pgParse": "sbyte.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4190
|
+
"i16.__pgParse": "short.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4191
|
+
"i32.__pgParse": "int.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4192
|
+
"i64.__pgParse": "long.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4193
|
+
"u8.__pgParse": "byte.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4194
|
+
"u16.__pgParse": "ushort.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4195
|
+
"u32.__pgParse": "uint.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4196
|
+
"u64.__pgParse": "ulong.Parse($0, global::System.Globalization.NumberStyles.Integer, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4197
|
+
"f32.__pgParse": "float.Parse($0, global::System.Globalization.NumberStyles.Float, global::System.Globalization.CultureInfo.InvariantCulture)",
|
|
4198
|
+
"f64.__pgParse": "double.Parse($0, global::System.Globalization.NumberStyles.Float, global::System.Globalization.CultureInfo.InvariantCulture)"
|
|
3733
4199
|
}
|
|
3734
4200
|
},
|
|
3735
|
-
"fileExtension": ".cs"
|
|
4201
|
+
"fileExtension": ".cs",
|
|
4202
|
+
"lineComment": "//"
|
|
3736
4203
|
}
|