@mintplayer/polyglot-target-typescript 0.10.0 → 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 +437 -178
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/polyglot-target-typescript",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "MintPlayer Polyglot TypeScript / JavaScript target — a pure-JSON language plugin (spec + emission rules + capabilities + std bindings) for the polyglot transpiler.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"polyglot",
|
package/polyglot-plugin.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema":
|
|
2
|
+
"schema": 2,
|
|
3
3
|
"name": "typescript",
|
|
4
4
|
"crossDirImports": true,
|
|
5
|
+
"preludePerFile": true,
|
|
5
6
|
"originMapping": {
|
|
6
7
|
"style": "sourceMapV3",
|
|
7
8
|
"sidecarExtension": ".map",
|
|
@@ -83,11 +84,24 @@
|
|
|
83
84
|
"void"
|
|
84
85
|
],
|
|
85
86
|
"globals": [
|
|
86
|
-
"console"
|
|
87
|
-
]
|
|
87
|
+
"console", "globalThis", "Math", "Number", "String", "BigInt", "Array", "JSON", "Promise"
|
|
88
|
+
],
|
|
89
|
+
"classNames": {
|
|
90
|
+
"Object": "TS2725: a class named 'Object' is a compile error under --module nodenext (a field, local or enum of that name is fine)"
|
|
91
|
+
}
|
|
88
92
|
},
|
|
89
93
|
"rethrow": "throw __e;",
|
|
94
|
+
"preludes": {
|
|
95
|
+
"unionEq": "function __pgUnionEq(a: unknown, b: unknown): boolean {\n // a union value (a tagged object literal) compared as C# compares its generated case records (review r5): the\n // same case with equal payloads, a record payload by its equals(), a nested union recursively, anything else (a\n // class instance, a list) by reference. (Comparing serialized text matched class payloads by content and threw on a bigint.)\n if (a === b) {\n return true;\n }\n if (typeof a === \"number\" && typeof b === \"number\") {\n return a !== a && b !== b;\n }\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) {\n return false;\n }\n const proto = globalThis.Object.getPrototypeOf(a);\n if (proto !== globalThis.Object.getPrototypeOf(b)) {\n return false;\n }\n if (proto === globalThis.Object.prototype) {\n const ra = a as { [k: string]: unknown }, rb = b as { [k: string]: unknown };\n const ka = globalThis.Object.keys(ra);\n if (ka.length !== globalThis.Object.keys(rb).length) {\n return false;\n }\n for (const k of ka) {\n if (!(k in rb) || !__pgUnionEq(ra[k], rb[k])) {\n return false;\n }\n }\n return true;\n }\n const eq = (a as { equals?: unknown }).equals;\n return typeof eq === \"function\" && (eq as (o: unknown) => boolean).call(a, b);\n}\n",
|
|
96
|
+
"nullAssert": "function __pgNullAssert(at: string): never {\n throw new globalThis.TypeError(\"null-assert failed (\" + at + \")\");\n}\n"
|
|
97
|
+
},
|
|
90
98
|
"tables": {
|
|
99
|
+
"baseRootMembers": {
|
|
100
|
+
"Error.cause": "true",
|
|
101
|
+
"Error.message": "true",
|
|
102
|
+
"Error.name": "true",
|
|
103
|
+
"Error.stack": "true"
|
|
104
|
+
},
|
|
91
105
|
"opMethod": {
|
|
92
106
|
"+": "plus",
|
|
93
107
|
"-": "minus",
|
|
@@ -115,6 +129,9 @@
|
|
|
115
129
|
"mutable": "let $x: $T",
|
|
116
130
|
"const": "const $x: $T"
|
|
117
131
|
},
|
|
132
|
+
"localNullInit": {
|
|
133
|
+
"typed": "$x as $T"
|
|
134
|
+
},
|
|
118
135
|
"yield": {
|
|
119
136
|
"value": "yield $x;",
|
|
120
137
|
"empty": "return;"
|
|
@@ -128,11 +145,43 @@
|
|
|
128
145
|
"u32": "BigInt.asUintN(32, $x)"
|
|
129
146
|
}
|
|
130
147
|
},
|
|
131
|
-
"
|
|
148
|
+
"literals": {
|
|
149
|
+
"string": {
|
|
150
|
+
"quote": "\"",
|
|
151
|
+
"map": {
|
|
152
|
+
"\\": "\\\\",
|
|
153
|
+
"\"": "\\\"",
|
|
154
|
+
"\n": "\\n",
|
|
155
|
+
"\t": "\\t",
|
|
156
|
+
"\r": "\\r"
|
|
157
|
+
},
|
|
158
|
+
"codepoint": "\\u{$H}",
|
|
159
|
+
"astral": "\\u{$H}"
|
|
160
|
+
},
|
|
132
161
|
"interp": {
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
|
|
162
|
+
"quote": "`",
|
|
163
|
+
"map": {
|
|
164
|
+
"\\": "\\\\",
|
|
165
|
+
"`": "\\`",
|
|
166
|
+
"\n": "\\n",
|
|
167
|
+
"\t": "\\t",
|
|
168
|
+
"\r": "\\r",
|
|
169
|
+
"${": "\\${"
|
|
170
|
+
},
|
|
171
|
+
"codepoint": "\\u{$H}",
|
|
172
|
+
"astral": "\\u{$H}"
|
|
173
|
+
},
|
|
174
|
+
"char": {
|
|
175
|
+
"quote": "\"",
|
|
176
|
+
"map": {
|
|
177
|
+
"\\": "\\\\",
|
|
178
|
+
"\"": "\\\"",
|
|
179
|
+
"\n": "\\n",
|
|
180
|
+
"\t": "\\t",
|
|
181
|
+
"\r": "\\r"
|
|
182
|
+
},
|
|
183
|
+
"codepoint": "\\u{$H}",
|
|
184
|
+
"astral": "\\u{$H}"
|
|
136
185
|
}
|
|
137
186
|
},
|
|
138
187
|
"wrapInt": {
|
|
@@ -145,13 +194,31 @@
|
|
|
145
194
|
"i64": "BigInt.asIntN(64, $x)",
|
|
146
195
|
"u64": "BigInt.asUintN(64, $x)"
|
|
147
196
|
},
|
|
197
|
+
"absentNormalize": { "prefix": "(", "suffix": " ?? null)", "foldedBy": ["coalesce", "nullAssert", "nullSafe"] },
|
|
198
|
+
"nativeCoalesceAssign": true,
|
|
199
|
+
"typeOnlyImports": ["union", "interface"],
|
|
200
|
+
"unboundImports": ["unionCase"],
|
|
201
|
+
"assignmentOrder": "targetFirst",
|
|
202
|
+
"exprStmt": { "parenIfStarts": ["{"] },
|
|
148
203
|
"wrapAtom": {
|
|
149
|
-
"
|
|
150
|
-
"
|
|
151
|
-
"
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"
|
|
204
|
+
"recvPrimary": [
|
|
205
|
+
"var",
|
|
206
|
+
"this",
|
|
207
|
+
"call",
|
|
208
|
+
"methodCall",
|
|
209
|
+
"member",
|
|
210
|
+
"index",
|
|
211
|
+
"str",
|
|
212
|
+
"char",
|
|
213
|
+
"bool",
|
|
214
|
+
"null",
|
|
215
|
+
"extern",
|
|
216
|
+
"nullAssert",
|
|
217
|
+
"listLit",
|
|
218
|
+
"tuple",
|
|
219
|
+
"interp",
|
|
220
|
+
"new",
|
|
221
|
+
"makeCase"
|
|
155
222
|
]
|
|
156
223
|
},
|
|
157
224
|
"generics": {
|
|
@@ -159,7 +226,8 @@
|
|
|
159
226
|
"boundsIntro": " extends ",
|
|
160
227
|
"boundsSep": " & ",
|
|
161
228
|
"erase": [
|
|
162
|
-
"INumber"
|
|
229
|
+
"INumber",
|
|
230
|
+
"IMapKey"
|
|
163
231
|
]
|
|
164
232
|
}
|
|
165
233
|
},
|
|
@@ -180,7 +248,7 @@
|
|
|
180
248
|
]
|
|
181
249
|
},
|
|
182
250
|
"Float": {
|
|
183
|
-
"get": "node.
|
|
251
|
+
"get": "node.widenedText"
|
|
184
252
|
},
|
|
185
253
|
"Bool": {
|
|
186
254
|
"case": {
|
|
@@ -206,16 +274,18 @@
|
|
|
206
274
|
"get": "spec.nullLit"
|
|
207
275
|
},
|
|
208
276
|
"Str": {
|
|
209
|
-
"fn": "
|
|
277
|
+
"fn": "quoted",
|
|
210
278
|
"args": [
|
|
279
|
+
"string",
|
|
211
280
|
{
|
|
212
281
|
"get": "node.value"
|
|
213
282
|
}
|
|
214
283
|
]
|
|
215
284
|
},
|
|
216
285
|
"Char": {
|
|
217
|
-
"fn": "
|
|
286
|
+
"fn": "quoted",
|
|
218
287
|
"args": [
|
|
288
|
+
"char",
|
|
219
289
|
{
|
|
220
290
|
"get": "node.value"
|
|
221
291
|
}
|
|
@@ -268,22 +338,32 @@
|
|
|
268
338
|
]
|
|
269
339
|
},
|
|
270
340
|
"Call": {
|
|
271
|
-
"
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
341
|
+
"case": {
|
|
342
|
+
"when": [
|
|
343
|
+
[
|
|
344
|
+
{ "has": "node.hasCalleeExpr" },
|
|
345
|
+
{ "tmpl": [ { "emitChild": "node.calleeExpr", "side": "recv" }, "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
346
|
+
]
|
|
347
|
+
],
|
|
348
|
+
"else": {
|
|
349
|
+
"tmpl": [
|
|
275
350
|
{
|
|
276
|
-
"
|
|
351
|
+
"fn": "ident",
|
|
352
|
+
"args": [
|
|
353
|
+
{
|
|
354
|
+
"get": "node.mangledCallee"
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"case": {
|
|
360
|
+
"when": [[ { "eq": ["node.isRef", "true"] }, "" ]],
|
|
361
|
+
"else": { "tmpl": [ { "call": "typeArgsSuffix" }, "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
362
|
+
}
|
|
277
363
|
}
|
|
278
364
|
]
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
{
|
|
282
|
-
"map": "node.args",
|
|
283
|
-
"sep": ", "
|
|
284
|
-
},
|
|
285
|
-
")"
|
|
286
|
-
]
|
|
365
|
+
}
|
|
366
|
+
}
|
|
287
367
|
},
|
|
288
368
|
"Member": {
|
|
289
369
|
"tmpl": [
|
|
@@ -577,13 +657,15 @@
|
|
|
577
657
|
"tmpl": [
|
|
578
658
|
"{ tag: ",
|
|
579
659
|
{
|
|
580
|
-
"fn": "
|
|
660
|
+
"fn": "quoted",
|
|
581
661
|
"args": [
|
|
662
|
+
"string",
|
|
582
663
|
{
|
|
583
664
|
"get": "node.caseName"
|
|
584
665
|
}
|
|
585
666
|
]
|
|
586
667
|
},
|
|
668
|
+
" as const",
|
|
587
669
|
{
|
|
588
670
|
"map": "node.fields",
|
|
589
671
|
"sep": "",
|
|
@@ -615,6 +697,26 @@
|
|
|
615
697
|
{ "type": "node.testType" }
|
|
616
698
|
]
|
|
617
699
|
},
|
|
700
|
+
"NullAssert": {
|
|
701
|
+
"case": {
|
|
702
|
+
"when": [
|
|
703
|
+
[
|
|
704
|
+
{ "eq": ["node.isFail", "true"] },
|
|
705
|
+
{ "tmpl": [{ "fn": "require", "args": ["nullAssert"] }, "__pgNullAssert(", { "fn": "quoted", "args": ["string", { "get": "node.where" }] }, ")"] }
|
|
706
|
+
]
|
|
707
|
+
],
|
|
708
|
+
"else": {
|
|
709
|
+
"tmpl": [
|
|
710
|
+
{ "fn": "require", "args": ["nullAssert"] },
|
|
711
|
+
"(",
|
|
712
|
+
{ "emitChild": "node.operand", "side": "recv" },
|
|
713
|
+
" ?? __pgNullAssert(",
|
|
714
|
+
{ "fn": "quoted", "args": ["string", { "get": "node.where" }] },
|
|
715
|
+
"))"
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
},
|
|
618
720
|
"AsCast": {
|
|
619
721
|
"case": {
|
|
620
722
|
"when": [
|
|
@@ -1029,7 +1131,7 @@
|
|
|
1029
1131
|
"lits": "node.chunks",
|
|
1030
1132
|
"holes": "node.holes",
|
|
1031
1133
|
"lit": {
|
|
1032
|
-
"fn": "
|
|
1134
|
+
"fn": "literal",
|
|
1033
1135
|
"args": [
|
|
1034
1136
|
"interp",
|
|
1035
1137
|
{
|
|
@@ -1063,14 +1165,7 @@
|
|
|
1063
1165
|
},
|
|
1064
1166
|
{
|
|
1065
1167
|
"tmpl": [
|
|
1066
|
-
{
|
|
1067
|
-
"fn": "ident",
|
|
1068
|
-
"args": [
|
|
1069
|
-
{
|
|
1070
|
-
"get": "node.method"
|
|
1071
|
-
}
|
|
1072
|
-
]
|
|
1073
|
-
},
|
|
1168
|
+
{ "fn": "mangleName", "args": [ { "fn": "ident", "args": [ { "get": "node.freeName" } ] } ] },
|
|
1074
1169
|
"(",
|
|
1075
1170
|
{
|
|
1076
1171
|
"emit": "node.object"
|
|
@@ -1145,7 +1240,14 @@
|
|
|
1145
1240
|
},
|
|
1146
1241
|
"Match": {
|
|
1147
1242
|
"tmpl": [
|
|
1148
|
-
"(() => { const _m
|
|
1243
|
+
"(() => { const _m",
|
|
1244
|
+
{
|
|
1245
|
+
"case": {
|
|
1246
|
+
"when": [[ { "has": "node.scrutineeScalar" }, { "tmpl": [": ", { "get": "node.scrutineeScalar" }] } ]],
|
|
1247
|
+
"else": ""
|
|
1248
|
+
}
|
|
1249
|
+
},
|
|
1250
|
+
" = ",
|
|
1149
1251
|
{
|
|
1150
1252
|
"emit": "node.scrutinee"
|
|
1151
1253
|
},
|
|
@@ -1195,8 +1297,9 @@
|
|
|
1195
1297
|
"tmpl": [
|
|
1196
1298
|
"if (_m.tag === ",
|
|
1197
1299
|
{
|
|
1198
|
-
"fn": "
|
|
1300
|
+
"fn": "quoted",
|
|
1199
1301
|
"args": [
|
|
1302
|
+
"string",
|
|
1200
1303
|
{
|
|
1201
1304
|
"get": "item.pattern.ctorCase"
|
|
1202
1305
|
}
|
|
@@ -1498,7 +1601,7 @@
|
|
|
1498
1601
|
}
|
|
1499
1602
|
}
|
|
1500
1603
|
},
|
|
1501
|
-
"throw new Error(\"non-exhaustive match\"); })()"
|
|
1604
|
+
"throw new globalThis.Error(\"non-exhaustive match\"); })()"
|
|
1502
1605
|
]
|
|
1503
1606
|
},
|
|
1504
1607
|
"Lambda": {
|
|
@@ -1555,7 +1658,8 @@
|
|
|
1555
1658
|
]
|
|
1556
1659
|
},
|
|
1557
1660
|
{
|
|
1558
|
-
"
|
|
1661
|
+
"fn": "parenIfStarts",
|
|
1662
|
+
"args": ["{", { "emit": "node.body" }]
|
|
1559
1663
|
}
|
|
1560
1664
|
]
|
|
1561
1665
|
],
|
|
@@ -1577,7 +1681,10 @@
|
|
|
1577
1681
|
{
|
|
1578
1682
|
"line": {
|
|
1579
1683
|
"tmpl": [
|
|
1580
|
-
|
|
1684
|
+
{
|
|
1685
|
+
"call": "tsExport"
|
|
1686
|
+
},
|
|
1687
|
+
"type ",
|
|
1581
1688
|
{
|
|
1582
1689
|
"fn": "ident",
|
|
1583
1690
|
"args": [
|
|
@@ -1593,7 +1700,10 @@
|
|
|
1593
1700
|
{
|
|
1594
1701
|
"line": {
|
|
1595
1702
|
"tmpl": [
|
|
1596
|
-
|
|
1703
|
+
{
|
|
1704
|
+
"call": "tsExport"
|
|
1705
|
+
},
|
|
1706
|
+
"const ",
|
|
1597
1707
|
{
|
|
1598
1708
|
"fn": "ident",
|
|
1599
1709
|
"args": [
|
|
@@ -1695,7 +1805,8 @@
|
|
|
1695
1805
|
]
|
|
1696
1806
|
},
|
|
1697
1807
|
"override "
|
|
1698
|
-
]
|
|
1808
|
+
],
|
|
1809
|
+
[ { "eq": [ "decl.isAbstract", "true" ] }, "abstract " ]
|
|
1699
1810
|
]
|
|
1700
1811
|
}
|
|
1701
1812
|
},
|
|
@@ -1872,6 +1983,7 @@
|
|
|
1872
1983
|
"block": {
|
|
1873
1984
|
"head": {
|
|
1874
1985
|
"tmpl": [
|
|
1986
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isStatic", "true" ] }, "static " ] ] } },
|
|
1875
1987
|
"get ",
|
|
1876
1988
|
{
|
|
1877
1989
|
"fn": "ident",
|
|
@@ -1933,6 +2045,7 @@
|
|
|
1933
2045
|
"block": {
|
|
1934
2046
|
"head": {
|
|
1935
2047
|
"tmpl": [
|
|
2048
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isStatic", "true" ] }, "static " ] ] } },
|
|
1936
2049
|
"set ",
|
|
1937
2050
|
{
|
|
1938
2051
|
"fn": "ident",
|
|
@@ -2169,7 +2282,9 @@
|
|
|
2169
2282
|
}
|
|
2170
2283
|
]
|
|
2171
2284
|
],
|
|
2172
|
-
"else": {
|
|
2285
|
+
"else": { "case": { "when": [
|
|
2286
|
+
[ { "eq": [ "decl.isAbstract", "true" ] }, { "line": { "tmpl": [ { "call": "tsMethodSig" }, ";" ] } } ]
|
|
2287
|
+
], "else": {
|
|
2173
2288
|
"block": {
|
|
2174
2289
|
"head": {
|
|
2175
2290
|
"call": "tsMethodSig"
|
|
@@ -2205,12 +2320,15 @@
|
|
|
2205
2320
|
}
|
|
2206
2321
|
]
|
|
2207
2322
|
}
|
|
2208
|
-
}
|
|
2323
|
+
} } }
|
|
2209
2324
|
}
|
|
2210
2325
|
},
|
|
2211
2326
|
"tsRecordHead": {
|
|
2212
2327
|
"tmpl": [
|
|
2213
|
-
|
|
2328
|
+
{
|
|
2329
|
+
"call": "tsExport"
|
|
2330
|
+
},
|
|
2331
|
+
"class ",
|
|
2214
2332
|
{
|
|
2215
2333
|
"fn": "ident",
|
|
2216
2334
|
"args": [
|
|
@@ -2632,6 +2750,17 @@
|
|
|
2632
2750
|
{
|
|
2633
2751
|
"case": {
|
|
2634
2752
|
"when": [
|
|
2753
|
+
[
|
|
2754
|
+
{
|
|
2755
|
+
"eq": [
|
|
2756
|
+
"stmt.catchesDiverge",
|
|
2757
|
+
"true"
|
|
2758
|
+
]
|
|
2759
|
+
},
|
|
2760
|
+
{
|
|
2761
|
+
"line": "throw __e;"
|
|
2762
|
+
}
|
|
2763
|
+
],
|
|
2635
2764
|
[
|
|
2636
2765
|
{
|
|
2637
2766
|
"eq": [
|
|
@@ -2802,6 +2931,19 @@
|
|
|
2802
2931
|
}
|
|
2803
2932
|
]
|
|
2804
2933
|
},
|
|
2934
|
+
"rangeEndDecl": {
|
|
2935
|
+
"case": {
|
|
2936
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "false" ] },
|
|
2937
|
+
{ "tmpl": [ ", ", { "fn": "ident", "args": [ { "get": "stmt.rangeEndTemp" } ] }, " = ", { "emit": "stmt.rangeEnd" } ] } ] ],
|
|
2938
|
+
"else": ""
|
|
2939
|
+
}
|
|
2940
|
+
},
|
|
2941
|
+
"rangeEndRead": {
|
|
2942
|
+
"case": {
|
|
2943
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "true" ] }, { "emit": "stmt.rangeEnd" } ] ],
|
|
2944
|
+
"else": { "fn": "ident", "args": [ { "get": "stmt.rangeEndTemp" } ] }
|
|
2945
|
+
}
|
|
2946
|
+
},
|
|
2805
2947
|
"ForStmt": {
|
|
2806
2948
|
"case": {
|
|
2807
2949
|
"when": [
|
|
@@ -2829,6 +2971,7 @@
|
|
|
2829
2971
|
{
|
|
2830
2972
|
"emit": "stmt.rangeStart"
|
|
2831
2973
|
},
|
|
2974
|
+
{ "call": "rangeEndDecl" },
|
|
2832
2975
|
"; ",
|
|
2833
2976
|
{
|
|
2834
2977
|
"fn": "ident",
|
|
@@ -2854,9 +2997,7 @@
|
|
|
2854
2997
|
"else": " < "
|
|
2855
2998
|
}
|
|
2856
2999
|
},
|
|
2857
|
-
{
|
|
2858
|
-
"emit": "stmt.rangeEnd"
|
|
2859
|
-
},
|
|
3000
|
+
{ "call": "rangeEndRead" },
|
|
2860
3001
|
"; ",
|
|
2861
3002
|
{
|
|
2862
3003
|
"fn": "ident",
|
|
@@ -2945,6 +3086,15 @@
|
|
|
2945
3086
|
},
|
|
2946
3087
|
"Program": {
|
|
2947
3088
|
"seq": [
|
|
3089
|
+
{
|
|
3090
|
+
"line": "// <auto-generated/>"
|
|
3091
|
+
},
|
|
3092
|
+
{
|
|
3093
|
+
"line": "// Generated by Polyglot. Do not edit: regenerate with `polyglot build`."
|
|
3094
|
+
},
|
|
3095
|
+
{
|
|
3096
|
+
"fn": "preludeSlot"
|
|
3097
|
+
},
|
|
2948
3098
|
{
|
|
2949
3099
|
"case": {
|
|
2950
3100
|
"when": [
|
|
@@ -2968,8 +3118,26 @@
|
|
|
2968
3118
|
},
|
|
2969
3119
|
{
|
|
2970
3120
|
"mapDecl": "module.imports",
|
|
2971
|
-
"each": {
|
|
2972
|
-
|
|
3121
|
+
"each": { "seq": [
|
|
3122
|
+
{
|
|
3123
|
+
"case": {
|
|
3124
|
+
"when": [
|
|
3125
|
+
[
|
|
3126
|
+
{ "not": { "eq": ["item.typeNames", ""] } },
|
|
3127
|
+
{ "line": { "tmpl": ["import type { ", { "get": "item.typeNames" }, " } from \"", { "get": "item.path" }, "\";"] } }
|
|
3128
|
+
]
|
|
3129
|
+
]
|
|
3130
|
+
}
|
|
3131
|
+
},
|
|
3132
|
+
{ "case": {
|
|
3133
|
+
"when": [
|
|
3134
|
+
[
|
|
3135
|
+
{ "and": [ { "eq": ["item.names", ""] }, { "eq": ["item.allNames", ""] }, { "not": { "eq": ["item.typeNames", ""] } } ] },
|
|
3136
|
+
{ "seq": [] }
|
|
3137
|
+
]
|
|
3138
|
+
],
|
|
3139
|
+
"else": {
|
|
3140
|
+
"line": {
|
|
2973
3141
|
"case": {
|
|
2974
3142
|
"when": [
|
|
2975
3143
|
[
|
|
@@ -3015,6 +3183,10 @@
|
|
|
3015
3183
|
"\";"
|
|
3016
3184
|
]
|
|
3017
3185
|
}
|
|
3186
|
+
],
|
|
3187
|
+
[
|
|
3188
|
+
{ "not": { "eq": ["item.allNames", ""] } },
|
|
3189
|
+
{ "tmpl": ["import { ", { "get": "item.allNames" }, " } from \"", { "get": "item.path" }, "\";"] }
|
|
3018
3190
|
]
|
|
3019
3191
|
],
|
|
3020
3192
|
"else": {
|
|
@@ -3028,97 +3200,96 @@
|
|
|
3028
3200
|
}
|
|
3029
3201
|
}
|
|
3030
3202
|
}
|
|
3031
|
-
}
|
|
3203
|
+
} } }
|
|
3204
|
+
] }
|
|
3032
3205
|
},
|
|
3033
3206
|
{
|
|
3034
|
-
"
|
|
3035
|
-
"
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
"export ",
|
|
3059
|
-
{
|
|
3060
|
-
"case": {
|
|
3061
|
-
"when": [
|
|
3062
|
-
[
|
|
3063
|
-
{
|
|
3064
|
-
"eq": [
|
|
3065
|
-
"item.isConst",
|
|
3066
|
-
"true"
|
|
3207
|
+
"mapOrder": "module.order",
|
|
3208
|
+
"kinds": {
|
|
3209
|
+
"enum": { "rule": "EnumDecl" },
|
|
3210
|
+
"interface": { "rule": "InterfaceDecl" },
|
|
3211
|
+
"union": { "rule": "UnionDecl" },
|
|
3212
|
+
"record": { "rule": "RecordDecl" },
|
|
3213
|
+
"function": { "rule": "FunctionDecl" },
|
|
3214
|
+
"extension": { "rule": "ExtensionDecl" },
|
|
3215
|
+
"class": { "rule": "ClassDecl" },
|
|
3216
|
+
"global": {
|
|
3217
|
+
"each": {
|
|
3218
|
+
"line": {
|
|
3219
|
+
"tmpl": [
|
|
3220
|
+
{
|
|
3221
|
+
"case": {
|
|
3222
|
+
"when": [
|
|
3223
|
+
[
|
|
3224
|
+
{
|
|
3225
|
+
"eq": [
|
|
3226
|
+
"item.isPrelude",
|
|
3227
|
+
"true"
|
|
3228
|
+
]
|
|
3229
|
+
},
|
|
3230
|
+
""
|
|
3067
3231
|
]
|
|
3068
|
-
|
|
3069
|
-
"
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
"else": "let "
|
|
3073
|
-
}
|
|
3074
|
-
},
|
|
3075
|
-
{
|
|
3076
|
-
"fn": "ident",
|
|
3077
|
-
"args": [
|
|
3232
|
+
],
|
|
3233
|
+
"else": "export "
|
|
3234
|
+
}
|
|
3235
|
+
},
|
|
3078
3236
|
{
|
|
3079
|
-
"
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
"when": [
|
|
3090
|
-
[
|
|
3091
|
-
{
|
|
3092
|
-
"eq": [
|
|
3093
|
-
"item.hasInit",
|
|
3094
|
-
"true"
|
|
3237
|
+
"case": {
|
|
3238
|
+
"when": [
|
|
3239
|
+
[
|
|
3240
|
+
{
|
|
3241
|
+
"eq": [
|
|
3242
|
+
"item.isConst",
|
|
3243
|
+
"true"
|
|
3244
|
+
]
|
|
3245
|
+
},
|
|
3246
|
+
"const "
|
|
3095
3247
|
]
|
|
3096
|
-
|
|
3248
|
+
],
|
|
3249
|
+
"else": "let "
|
|
3250
|
+
}
|
|
3251
|
+
},
|
|
3252
|
+
{
|
|
3253
|
+
"fn": "ident",
|
|
3254
|
+
"args": [
|
|
3097
3255
|
{
|
|
3098
|
-
"
|
|
3099
|
-
|
|
3256
|
+
"get": "item.name"
|
|
3257
|
+
}
|
|
3258
|
+
]
|
|
3259
|
+
},
|
|
3260
|
+
": ",
|
|
3261
|
+
{
|
|
3262
|
+
"type": "item.type"
|
|
3263
|
+
},
|
|
3264
|
+
{
|
|
3265
|
+
"case": {
|
|
3266
|
+
"when": [
|
|
3267
|
+
[
|
|
3100
3268
|
{
|
|
3101
|
-
"
|
|
3269
|
+
"eq": [
|
|
3270
|
+
"item.hasInit",
|
|
3271
|
+
"true"
|
|
3272
|
+
]
|
|
3273
|
+
},
|
|
3274
|
+
{
|
|
3275
|
+
"tmpl": [
|
|
3276
|
+
" = ",
|
|
3277
|
+
{
|
|
3278
|
+
"emit": "item.init"
|
|
3279
|
+
}
|
|
3280
|
+
]
|
|
3102
3281
|
}
|
|
3103
3282
|
]
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3283
|
+
]
|
|
3284
|
+
}
|
|
3285
|
+
},
|
|
3286
|
+
";"
|
|
3287
|
+
]
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3111
3290
|
}
|
|
3112
3291
|
}
|
|
3113
3292
|
},
|
|
3114
|
-
{
|
|
3115
|
-
"mapMembers": "module.extensions",
|
|
3116
|
-
"rule": "ExtensionDecl"
|
|
3117
|
-
},
|
|
3118
|
-
{
|
|
3119
|
-
"mapMembers": "module.functions",
|
|
3120
|
-
"rule": "FunctionDecl"
|
|
3121
|
-
},
|
|
3122
3293
|
{
|
|
3123
3294
|
"case": {
|
|
3124
3295
|
"when": [
|
|
@@ -3142,12 +3313,35 @@
|
|
|
3142
3313
|
]
|
|
3143
3314
|
]
|
|
3144
3315
|
}
|
|
3316
|
+
},
|
|
3317
|
+
{
|
|
3318
|
+
"case": {
|
|
3319
|
+
"when": [[{ "eq": ["module.userDecls.count", "0"] }, { "line": "export {};" }]]
|
|
3320
|
+
}
|
|
3145
3321
|
}
|
|
3146
3322
|
]
|
|
3147
3323
|
},
|
|
3324
|
+
"tsExport": {
|
|
3325
|
+
"case": {
|
|
3326
|
+
"when": [
|
|
3327
|
+
[
|
|
3328
|
+
{
|
|
3329
|
+
"eq": [
|
|
3330
|
+
"decl.isPrelude",
|
|
3331
|
+
"true"
|
|
3332
|
+
]
|
|
3333
|
+
},
|
|
3334
|
+
""
|
|
3335
|
+
]
|
|
3336
|
+
],
|
|
3337
|
+
"else": "export "
|
|
3338
|
+
}
|
|
3339
|
+
},
|
|
3148
3340
|
"tsFnSig": {
|
|
3149
3341
|
"tmpl": [
|
|
3150
|
-
|
|
3342
|
+
{
|
|
3343
|
+
"call": "tsExport"
|
|
3344
|
+
},
|
|
3151
3345
|
{
|
|
3152
3346
|
"case": {
|
|
3153
3347
|
"when": [
|
|
@@ -3230,12 +3424,15 @@
|
|
|
3230
3424
|
},
|
|
3231
3425
|
"tsExtSig": {
|
|
3232
3426
|
"tmpl": [
|
|
3233
|
-
|
|
3427
|
+
{
|
|
3428
|
+
"call": "tsExport"
|
|
3429
|
+
},
|
|
3430
|
+
"function ",
|
|
3234
3431
|
{
|
|
3235
3432
|
"fn": "ident",
|
|
3236
3433
|
"args": [
|
|
3237
3434
|
{
|
|
3238
|
-
"get": "decl.
|
|
3435
|
+
"get": "decl.emitName"
|
|
3239
3436
|
}
|
|
3240
3437
|
]
|
|
3241
3438
|
},
|
|
@@ -3295,7 +3492,11 @@
|
|
|
3295
3492
|
},
|
|
3296
3493
|
"tsClassHead": {
|
|
3297
3494
|
"tmpl": [
|
|
3298
|
-
|
|
3495
|
+
{
|
|
3496
|
+
"call": "tsExport"
|
|
3497
|
+
},
|
|
3498
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, "abstract " ] ] } },
|
|
3499
|
+
"class ",
|
|
3299
3500
|
{
|
|
3300
3501
|
"fn": "ident",
|
|
3301
3502
|
"args": [
|
|
@@ -3404,6 +3605,21 @@
|
|
|
3404
3605
|
"else": ""
|
|
3405
3606
|
}
|
|
3406
3607
|
},
|
|
3608
|
+
{
|
|
3609
|
+
"case": {
|
|
3610
|
+
"when": [
|
|
3611
|
+
[
|
|
3612
|
+
{
|
|
3613
|
+
"eq": [
|
|
3614
|
+
"item.shadowsBaseRoot",
|
|
3615
|
+
"true"
|
|
3616
|
+
]
|
|
3617
|
+
},
|
|
3618
|
+
"override "
|
|
3619
|
+
]
|
|
3620
|
+
]
|
|
3621
|
+
}
|
|
3622
|
+
},
|
|
3407
3623
|
{
|
|
3408
3624
|
"fn": "ident",
|
|
3409
3625
|
"args": [
|
|
@@ -3519,7 +3735,10 @@
|
|
|
3519
3735
|
"block": {
|
|
3520
3736
|
"head": {
|
|
3521
3737
|
"tmpl": [
|
|
3522
|
-
|
|
3738
|
+
{
|
|
3739
|
+
"call": "tsExport"
|
|
3740
|
+
},
|
|
3741
|
+
"interface ",
|
|
3523
3742
|
{
|
|
3524
3743
|
"fn": "ident",
|
|
3525
3744
|
"args": [
|
|
@@ -3640,7 +3859,10 @@
|
|
|
3640
3859
|
"UnionDecl": {
|
|
3641
3860
|
"line": {
|
|
3642
3861
|
"tmpl": [
|
|
3643
|
-
|
|
3862
|
+
{
|
|
3863
|
+
"call": "tsExport"
|
|
3864
|
+
},
|
|
3865
|
+
"type ",
|
|
3644
3866
|
{
|
|
3645
3867
|
"fn": "ident",
|
|
3646
3868
|
"args": [
|
|
@@ -3700,6 +3922,33 @@
|
|
|
3700
3922
|
"Type": {
|
|
3701
3923
|
"case": {
|
|
3702
3924
|
"when": [
|
|
3925
|
+
[
|
|
3926
|
+
{
|
|
3927
|
+
"and": [
|
|
3928
|
+
{
|
|
3929
|
+
"eq": [
|
|
3930
|
+
"type.kind",
|
|
3931
|
+
"function"
|
|
3932
|
+
]
|
|
3933
|
+
},
|
|
3934
|
+
{
|
|
3935
|
+
"eq": [
|
|
3936
|
+
"type.nullable",
|
|
3937
|
+
"true"
|
|
3938
|
+
]
|
|
3939
|
+
}
|
|
3940
|
+
]
|
|
3941
|
+
},
|
|
3942
|
+
{
|
|
3943
|
+
"tmpl": [
|
|
3944
|
+
"((",
|
|
3945
|
+
{
|
|
3946
|
+
"type": "type.base"
|
|
3947
|
+
},
|
|
3948
|
+
") | null)"
|
|
3949
|
+
]
|
|
3950
|
+
}
|
|
3951
|
+
],
|
|
3703
3952
|
[
|
|
3704
3953
|
{
|
|
3705
3954
|
"eq": [
|
|
@@ -3981,30 +4230,16 @@
|
|
|
3981
4230
|
},
|
|
3982
4231
|
{
|
|
3983
4232
|
"tmpl": [
|
|
3984
|
-
"
|
|
3985
|
-
{
|
|
3986
|
-
"emit": "node.lhs"
|
|
3987
|
-
},
|
|
3988
|
-
") === JSON.stringify(",
|
|
3989
|
-
{
|
|
3990
|
-
"emit": "node.rhs"
|
|
3991
|
-
},
|
|
3992
|
-
")"
|
|
4233
|
+
{ "fn": "require", "args": ["unionEq"] },
|
|
4234
|
+
"__pgUnionEq(", { "emit": "node.lhs" }, ", ", { "emit": "node.rhs" }, ")"
|
|
3993
4235
|
]
|
|
3994
4236
|
}
|
|
3995
4237
|
]
|
|
3996
4238
|
],
|
|
3997
4239
|
"else": {
|
|
3998
4240
|
"tmpl": [
|
|
3999
|
-
"
|
|
4000
|
-
{
|
|
4001
|
-
"emit": "node.lhs"
|
|
4002
|
-
},
|
|
4003
|
-
") !== JSON.stringify(",
|
|
4004
|
-
{
|
|
4005
|
-
"emit": "node.rhs"
|
|
4006
|
-
},
|
|
4007
|
-
")"
|
|
4241
|
+
{ "fn": "require", "args": ["unionEq"] },
|
|
4242
|
+
"!__pgUnionEq(", { "emit": "node.lhs" }, ", ", { "emit": "node.rhs" }, ")"
|
|
4008
4243
|
]
|
|
4009
4244
|
}
|
|
4010
4245
|
}
|
|
@@ -4490,20 +4725,30 @@
|
|
|
4490
4725
|
"List.add": "$this.push($0)",
|
|
4491
4726
|
"List.clear": "$this.length = 0",
|
|
4492
4727
|
"List.removeAll": "$this.splice(0, $this.length, ...$this.filter(__e => !(($0)(__e))))",
|
|
4493
|
-
"List.removeAt": "$this.splice($0, 1)"
|
|
4728
|
+
"List.removeAt": "$this.splice($0, 1)",
|
|
4729
|
+
"Map.type": "Map<$0, $1>",
|
|
4730
|
+
"Map.constructor": "new $T()",
|
|
4731
|
+
"Map.count": "$this.size",
|
|
4732
|
+
"Map.get": "($this.get($0) ?? null)",
|
|
4733
|
+
"Map.set": "$this.set($0, $1)",
|
|
4734
|
+
"Map.has": "$this.has($0)",
|
|
4735
|
+
"Map.remove": "$this.delete($0)",
|
|
4736
|
+
"Map.keys": "[...$this.keys()]",
|
|
4737
|
+
"Map.values": "[...$this.values()]"
|
|
4494
4738
|
},
|
|
4495
4739
|
"std.io": {
|
|
4496
4740
|
"print": "console.log(String(x))",
|
|
4497
|
-
"readText": "process.getBuiltinModule('fs').readFileSync(path, 'utf8')",
|
|
4498
|
-
"writeText": "process.getBuiltinModule('fs').writeFileSync(path, content)",
|
|
4499
|
-
"appendText": "process.getBuiltinModule('fs').appendFileSync(path, content)",
|
|
4500
|
-
"fileExists": "process.getBuiltinModule('fs').existsSync(path)",
|
|
4501
|
-
"deleteFile": "process.getBuiltinModule('fs').unlinkSync(path)"
|
|
4741
|
+
"readText": "globalThis.process.getBuiltinModule('fs').readFileSync(path, 'utf8')",
|
|
4742
|
+
"writeText": "globalThis.process.getBuiltinModule('fs').writeFileSync(path, content)",
|
|
4743
|
+
"appendText": "globalThis.process.getBuiltinModule('fs').appendFileSync(path, content)",
|
|
4744
|
+
"fileExists": "globalThis.process.getBuiltinModule('fs').existsSync(path)",
|
|
4745
|
+
"deleteFile": "globalThis.process.getBuiltinModule('fs').unlinkSync(path)"
|
|
4502
4746
|
},
|
|
4503
4747
|
"std.math": {
|
|
4504
4748
|
"Math.PI": "Math.PI",
|
|
4505
4749
|
"Math.E": "Math.E",
|
|
4506
4750
|
"Math.sqrt": "Math.sqrt($0)",
|
|
4751
|
+
"Math.isNaN": "Number.isNaN($0)",
|
|
4507
4752
|
"Math.ln": "Math.log($0)",
|
|
4508
4753
|
"Math.log": "Math.log($0)",
|
|
4509
4754
|
"Math.log2": "Math.log2($0)",
|
|
@@ -4538,10 +4783,21 @@
|
|
|
4538
4783
|
"string.len": "$this.length",
|
|
4539
4784
|
"string.toUpper": "$this.toUpperCase()",
|
|
4540
4785
|
"string.toLower": "$this.toLowerCase()",
|
|
4541
|
-
"string.
|
|
4542
|
-
"string.
|
|
4786
|
+
"string.toUpperAscii": "$this.replace(/[a-z]+/g, (__m) => __m.toUpperCase())",
|
|
4787
|
+
"string.toLowerAscii": "$this.replace(/[A-Z]+/g, (__m) => __m.toLowerCase())",
|
|
4543
4788
|
"string.codePoints": "Array.from($this)",
|
|
4544
|
-
"string.
|
|
4789
|
+
"string.startsWith": "$this.startsWith($0)",
|
|
4790
|
+
"string.endsWith": "$this.endsWith($0)",
|
|
4791
|
+
"string.contains": "$this.includes($0)",
|
|
4792
|
+
"string.trimAscii": "$this.replace(/^[\\t\\n\\v\\f\\r ]+|[\\t\\n\\v\\f\\r ]+$/g, \"\")",
|
|
4793
|
+
"compareOrdinal": "(a < b ? -1 : (a > b ? 1 : 0))",
|
|
4794
|
+
"string.__pgCharAt": "$this.charAt($0)",
|
|
4795
|
+
"string.__pgCodePointAt": "$this.codePointAt($0)!",
|
|
4796
|
+
"string.__pgSubstring": "$this.substring($0, $1)",
|
|
4797
|
+
"string.__pgIndexOf": "$this.indexOf($0, $1)",
|
|
4798
|
+
"string.__pgReplaceAll": "$this.split($0).join($1)",
|
|
4799
|
+
"string.__pgSplit": "$this.split($0)",
|
|
4800
|
+
"string.__pgFromCodePoint": "String.fromCodePoint($0)"
|
|
4545
4801
|
},
|
|
4546
4802
|
"std.core": {
|
|
4547
4803
|
"Error.type": "Error",
|
|
@@ -4551,17 +4807,20 @@
|
|
|
4551
4807
|
"Array.type": "$0[]",
|
|
4552
4808
|
"Array.constructor": "[]",
|
|
4553
4809
|
"Array.count": "$this.length",
|
|
4554
|
-
"
|
|
4555
|
-
"
|
|
4556
|
-
"
|
|
4557
|
-
"
|
|
4558
|
-
"
|
|
4559
|
-
"
|
|
4560
|
-
"
|
|
4561
|
-
"
|
|
4562
|
-
"
|
|
4563
|
-
"
|
|
4810
|
+
"__pgText.rawLen": "$0.length",
|
|
4811
|
+
"__pgText.rawCode": "$0.charCodeAt($1)",
|
|
4812
|
+
"i8.__pgParse": "(Number.parseInt($0, 10) << 24 >> 24)",
|
|
4813
|
+
"i16.__pgParse": "(Number.parseInt($0, 10) << 16 >> 16)",
|
|
4814
|
+
"i32.__pgParse": "(Number.parseInt($0, 10) | 0)",
|
|
4815
|
+
"i64.__pgParse": "BigInt($0)",
|
|
4816
|
+
"u8.__pgParse": "(Number.parseInt($0, 10) & 0xff)",
|
|
4817
|
+
"u16.__pgParse": "(Number.parseInt($0, 10) & 0xffff)",
|
|
4818
|
+
"u32.__pgParse": "(Number.parseInt($0, 10) >>> 0)",
|
|
4819
|
+
"u64.__pgParse": "BigInt($0)",
|
|
4820
|
+
"f32.__pgParse": "Math.fround(Number($0))",
|
|
4821
|
+
"f64.__pgParse": "Number($0)"
|
|
4564
4822
|
}
|
|
4565
4823
|
},
|
|
4566
|
-
"fileExtension": ".ts"
|
|
4824
|
+
"fileExtension": ".ts",
|
|
4825
|
+
"lineComment": "//"
|
|
4567
4826
|
}
|