@mintplayer/polyglot-target-python 0.10.1 → 0.10.3
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 +378 -169
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/polyglot-target-python",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "MintPlayer Polyglot Python 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,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema":
|
|
2
|
+
"schema": 2,
|
|
3
3
|
"name": "python",
|
|
4
4
|
"preludePerFile": true,
|
|
5
5
|
"originMapping": {
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
"footer": "# sourceMappingURL=$f"
|
|
9
9
|
},
|
|
10
10
|
"capabilities": {
|
|
11
|
+
"utf16Strings:index": "emulated",
|
|
11
12
|
"blockLambdas": "emulated",
|
|
12
13
|
"interfaces": "emulated",
|
|
13
14
|
"interfaces:runtimeIdentity": "native",
|
|
14
15
|
"attributes:target.field": false,
|
|
15
|
-
"attributes:target.param": false
|
|
16
|
+
"attributes:target.param": false,
|
|
17
|
+
"propertySetters:static": false
|
|
16
18
|
},
|
|
17
19
|
"spec": {
|
|
18
20
|
"name": "python",
|
|
@@ -34,21 +36,48 @@
|
|
|
34
36
|
"i64": "(((($x) & 0xffffffffffffffff) ^ 0x8000000000000000) - 0x8000000000000000)"
|
|
35
37
|
},
|
|
36
38
|
"wrapAtom": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
39
|
+
"recvPrimary": [
|
|
40
|
+
"var",
|
|
41
|
+
"this",
|
|
42
|
+
"call",
|
|
43
|
+
"methodCall",
|
|
44
|
+
"member",
|
|
45
|
+
"index",
|
|
46
|
+
"str",
|
|
47
|
+
"char",
|
|
48
|
+
"bool",
|
|
49
|
+
"null",
|
|
50
|
+
"extern",
|
|
51
|
+
"nullAssert",
|
|
52
|
+
"listLit",
|
|
53
|
+
"tuple",
|
|
54
|
+
"new",
|
|
55
|
+
"makeCase"
|
|
45
56
|
]
|
|
46
57
|
},
|
|
47
58
|
"rethrow": "raise",
|
|
48
59
|
"preludes": {
|
|
49
|
-
"
|
|
60
|
+
"pgU16": "_PG_ASTRAL = __import__('re').compile('[\\U00010000-\\U0010FFFF]')\n_PG_SURR = __import__('re').compile('[\\ud800-\\udfff]')\n_PG_U16_CACHE = {}\n_PG_U16_LAST = [None, None]\ndef _pg_u16_pair(m):\n c = builtins.ord(m.group(0)) - 0x10000\n return builtins.chr(0xD800 + (c >> 10)) + builtins.chr(0xDC00 + (c & 0x3FF))\ndef _pg_u16v(s):\n # the UTF-16 view of a non-ASCII str: each astral code point expanded to its surrogate pair. A short\n # string is just recomputed; a long one is cached (the last one, plus a small LRU), so indexing a long\n # string in a loop is O(1) per call even when short strings are indexed in between.\n last = _PG_U16_LAST\n if last[0] is s:\n return last[1]\n if builtins.len(s) < 256:\n return _PG_ASTRAL.sub(_pg_u16_pair, s)\n cache = _PG_U16_CACHE\n e = cache.pop(builtins.id(s), None)\n if e is not None and e[0] is s:\n v = e[1]\n else:\n v = _PG_ASTRAL.sub(_pg_u16_pair, s)\n if builtins.len(cache) >= 8:\n cache.pop(builtins.next(builtins.iter(cache)))\n cache[builtins.id(s)] = (s, v)\n last[0] = s\n last[1] = v\n return v\ndef _pg_len16(s):\n return builtins.len(s) if s.isascii() else builtins.len(_pg_u16v(s))\ndef _pg_u16_char(s, i):\n return s[i] if s.isascii() else _pg_u16v(s)[i]\ndef _pg_u16_cp(s, i):\n if s.isascii():\n return builtins.ord(s[i])\n v = _pg_u16v(s)\n c = builtins.ord(v[i])\n if 0xD800 <= c <= 0xDBFF and i + 1 < builtins.len(v):\n d = builtins.ord(v[i + 1])\n if 0xDC00 <= d <= 0xDFFF:\n return 0x10000 + ((c - 0xD800) << 10) + (d - 0xDC00)\n return c\ndef _pg_u16_sub(s, a, b):\n if s.isascii():\n return s[a:b]\n return _pg_u16_fix(_pg_u16v(s)[a:b])\ndef _pg_u16_find(s, n, f):\n if s.isascii():\n return s.find(n, f) if n.isascii() else -1\n return _pg_u16v(s).find(n if n.isascii() else _pg_u16v(n), f)\ndef _pg_cmp16(a, b):\n if not (a.isascii() and b.isascii()):\n a = a.encode('utf-16-be', 'surrogatepass')\n b = b.encode('utf-16-be', 'surrogatepass')\n return -1 if a < b else (1 if a > b else 0)\ndef _pg_u16_fix(r):\n # re-pair the surrogate halves of a UTF-16 view slice into the str's astral code points\n return r.encode('utf-16-le', 'surrogatepass').decode('utf-16-le', 'surrogatepass') if _PG_SURR.search(r) else r\ndef _pg_u16_lone(*xs):\n # a str holding a surrogate code point (a lone half a substring split off, or halves joined by +) only\n # matches like C#/TS in the UTF-16 view; without one, the code-point answer is the UTF-16 answer\n for x in xs:\n if not x.isascii() and _PG_SURR.search(x):\n return True\n return False\ndef _pg_u16_has(s, n):\n return _pg_u16v(s).find(_pg_u16v(n)) >= 0 if _pg_u16_lone(s, n) else n in s\ndef _pg_u16_starts(s, p):\n return _pg_u16v(s).startswith(_pg_u16v(p)) if _pg_u16_lone(s, p) else s.startswith(p)\ndef _pg_u16_ends(s, p):\n return _pg_u16v(s).endswith(_pg_u16v(p)) if _pg_u16_lone(s, p) else s.endswith(p)\ndef _pg_u16_replace(s, n, r):\n if _pg_u16_lone(s, n, r):\n return _pg_u16_fix(_pg_u16v(s).replace(_pg_u16v(n), _pg_u16v(r)))\n return s.replace(n, r)\ndef _pg_u16_split(s, sep):\n if _pg_u16_lone(s, sep):\n return [_pg_u16_fix(p) for p in _pg_u16v(s).split(_pg_u16v(sep))]\n return s.split(sep)\n",
|
|
61
|
+
"pgOut16": "def _pg_out16(s):\n # stdout: re-pair adjacent surrogate halves, and print a lone one as U+FFFD (as C# and Node do)\n return s if s.isascii() else s.encode('utf-16-le', 'surrogatepass').decode('utf-16-le', 'replace')\n",
|
|
62
|
+
"asyncEntry": "import asyncio as _PG_asyncio\n",
|
|
63
|
+
"pyBuiltins": "import builtins\n",
|
|
64
|
+
"fdiv": "def _pg_fdiv(a, b):\n # IEEE division like C#/JS: x/0.0 is an infinity, 0.0/0.0 NaN (Python raises ZeroDivisionError)\n try:\n return a / b\n except builtins.ZeroDivisionError:\n if a != a or a == 0:\n return builtins.float(\"nan\")\n return builtins.float(\"inf\") if (a > 0) == (__import__('math').copysign(1.0, b) > 0) else builtins.float(\"-inf\")\ndef _pg_fmod(a, b):\n # C# % on doubles: NaN for a zero divisor or an infinite dividend (math.fmod raises ValueError there)\n if b == 0 or a != a or b != b or a in (builtins.float(\"inf\"), builtins.float(\"-inf\")):\n return builtins.float(\"nan\")\n return __import__('math').fmod(a, b)\n",
|
|
65
|
+
"pgInt": "def _pg_int(s):\n # the validated integer text, without the leading zeros that trip Python's 4300-digit int() limit\n d = s.lstrip(\"+-\").lstrip(\"0\") or \"0\"\n return -builtins.int(d) if s[:1] == \"-\" else builtins.int(d)\n",
|
|
66
|
+
"pgF32": "def _pg_f32(x):\n # round a double to the nearest f32 (an out-of-range value becomes an infinity, as C# float.Parse does)\n import ctypes\n return ctypes.c_float(x).value\n",
|
|
50
67
|
"idiv": "def _pg_idiv(a, b):\n q = a // b\n return q + 1 if (q < 0 and q * b != a) else q\ndef _pg_irem(a, b):\n return a - _pg_idiv(a, b) * b\n",
|
|
51
|
-
"
|
|
68
|
+
"pgFail": "def _pg_fail(at):\n raise builtins.TypeError(\"null-assert failed (\" + at + \")\")\n",
|
|
69
|
+
"fstr": "def _pg_str(x):\n if x is None:\n return \"null\"\n if builtins.isinstance(x, builtins.bool):\n return \"true\" if x else \"false\"\n if not builtins.isinstance(x, builtins.float):\n return builtins.str(x)\n if x != x:\n return \"NaN\"\n if x in (builtins.float(\"inf\"), builtins.float(\"-inf\")):\n return \"Infinity\" if x > 0 else \"-Infinity\"\n if x == 0:\n return \"0\"\n s = builtins.repr(x)\n neg = s[0] == \"-\"\n if neg:\n s = s[1:]\n m, _, e = s.partition(\"e\")\n i, _, f = m.partition(\".\")\n d = (i + f).lstrip(\"0\")\n n = builtins.len(i) + (builtins.int(e) if e else 0) - (builtins.len(i) + builtins.len(f) - builtins.len(d))\n d = d.rstrip(\"0\")\n k = builtins.len(d)\n if k <= n <= 21:\n r = d + \"0\" * (n - k)\n elif 0 < n <= 21:\n r = d[:n] + \".\" + d[n:]\n elif -6 < n <= 0:\n r = \"0.\" + \"0\" * -n + d\n else:\n r = d[0] + (\".\" + d[1:] if k > 1 else \"\") + \"e\" + (\"+\" if n >= 1 else \"-\") + builtins.str(builtins.abs(n - 1))\n return \"-\" + r if neg else r\n",
|
|
70
|
+
"pgAbsent": "_PG_ABSENT = builtins.object() # Map.remove's pop sentinel: never a stored value\n",
|
|
71
|
+
"pgAscii": "_PG_UPPER = builtins.str.maketrans(\"abcdefghijklmnopqrstuvwxyz\", \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\n_PG_LOWER = builtins.str.maketrans(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\", \"abcdefghijklmnopqrstuvwxyz\")\n"
|
|
72
|
+
},
|
|
73
|
+
"preludeRequires": {
|
|
74
|
+
"pgU16": ["pyBuiltins"],
|
|
75
|
+
"fdiv": ["pyBuiltins"],
|
|
76
|
+
"pgInt": ["pyBuiltins"],
|
|
77
|
+
"pgFail": ["pyBuiltins"],
|
|
78
|
+
"fstr": ["pyBuiltins"],
|
|
79
|
+
"pgAbsent": ["pyBuiltins"],
|
|
80
|
+
"pgAscii": ["pyBuiltins"]
|
|
52
81
|
},
|
|
53
82
|
"tables": {
|
|
54
83
|
"localDecl": {
|
|
@@ -66,7 +95,48 @@
|
|
|
66
95
|
"trueLit": "True",
|
|
67
96
|
"falseLit": "False",
|
|
68
97
|
"nullLit": "None",
|
|
98
|
+
"literals": {
|
|
99
|
+
"string": {
|
|
100
|
+
"quote": "\"",
|
|
101
|
+
"map": {
|
|
102
|
+
"\\": "\\\\",
|
|
103
|
+
"\"": "\\\"",
|
|
104
|
+
"\n": "\\n",
|
|
105
|
+
"\t": "\\t",
|
|
106
|
+
"\r": "\\r"
|
|
107
|
+
},
|
|
108
|
+
"codepoint": "\\u$H4",
|
|
109
|
+
"astral": "\\U$H8"
|
|
110
|
+
},
|
|
111
|
+
"interp": {
|
|
112
|
+
"quote": "\"",
|
|
113
|
+
"map": {
|
|
114
|
+
"\\": "\\\\",
|
|
115
|
+
"\"": "\\\"",
|
|
116
|
+
"\n": "\\n",
|
|
117
|
+
"\t": "\\t",
|
|
118
|
+
"\r": "\\r"
|
|
119
|
+
},
|
|
120
|
+
"codepoint": "\\u$H4",
|
|
121
|
+
"astral": "\\U$H8"
|
|
122
|
+
},
|
|
123
|
+
"char": {
|
|
124
|
+
"quote": "\"",
|
|
125
|
+
"map": {
|
|
126
|
+
"\\": "\\\\",
|
|
127
|
+
"\"": "\\\"",
|
|
128
|
+
"\n": "\\n",
|
|
129
|
+
"\t": "\\t",
|
|
130
|
+
"\r": "\\r"
|
|
131
|
+
},
|
|
132
|
+
"codepoint": "\\u$H4",
|
|
133
|
+
"astral": "\\U$H8"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
69
136
|
"expressionOnlyLambdas": true,
|
|
137
|
+
"unboundImports": ["union", "unionCase"],
|
|
138
|
+
"nativeCoalesceAssign": false,
|
|
139
|
+
"assignmentOrder": "valueFirst",
|
|
70
140
|
"identifiers": {
|
|
71
141
|
"keywords": [
|
|
72
142
|
"False",
|
|
@@ -113,13 +183,17 @@
|
|
|
113
183
|
},
|
|
114
184
|
"mangle": {
|
|
115
185
|
"replace": "$",
|
|
116
|
-
"with": "
|
|
186
|
+
"with": "__"
|
|
117
187
|
},
|
|
118
188
|
"reserved": [
|
|
119
189
|
"_m",
|
|
120
190
|
"self",
|
|
121
191
|
"_pg_idiv",
|
|
122
192
|
"_pg_irem",
|
|
193
|
+
"_pg_fdiv",
|
|
194
|
+
"_pg_fmod",
|
|
195
|
+
"_pg_int",
|
|
196
|
+
"_pg_f32",
|
|
123
197
|
"__c*",
|
|
124
198
|
"__o*",
|
|
125
199
|
"__e",
|
|
@@ -128,10 +202,14 @@
|
|
|
128
202
|
"__dw*",
|
|
129
203
|
"tag",
|
|
130
204
|
"__opt*",
|
|
205
|
+
"_PG_*",
|
|
131
206
|
"__w*"
|
|
132
207
|
],
|
|
208
|
+
"runtimeNames": [
|
|
209
|
+
"builtins"
|
|
210
|
+
],
|
|
133
211
|
"globals": [
|
|
134
|
-
"
|
|
212
|
+
"Exception"
|
|
135
213
|
]
|
|
136
214
|
}
|
|
137
215
|
},
|
|
@@ -152,7 +230,7 @@
|
|
|
152
230
|
]
|
|
153
231
|
},
|
|
154
232
|
"Float": {
|
|
155
|
-
"get": "node.
|
|
233
|
+
"get": "node.widenedText"
|
|
156
234
|
},
|
|
157
235
|
"Bool": {
|
|
158
236
|
"case": {
|
|
@@ -178,8 +256,9 @@
|
|
|
178
256
|
"get": "spec.nullLit"
|
|
179
257
|
},
|
|
180
258
|
"Str": {
|
|
181
|
-
"fn": "
|
|
259
|
+
"fn": "quoted",
|
|
182
260
|
"args": [
|
|
261
|
+
"string",
|
|
183
262
|
{
|
|
184
263
|
"get": "node.value"
|
|
185
264
|
}
|
|
@@ -207,27 +286,37 @@
|
|
|
207
286
|
]
|
|
208
287
|
},
|
|
209
288
|
"Call": {
|
|
210
|
-
"
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
289
|
+
"case": {
|
|
290
|
+
"when": [
|
|
291
|
+
[
|
|
292
|
+
{ "has": "node.hasCalleeExpr" },
|
|
293
|
+
{ "tmpl": [ { "emitChild": "node.calleeExpr", "side": "recv" }, "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
294
|
+
]
|
|
295
|
+
],
|
|
296
|
+
"else": {
|
|
297
|
+
"tmpl": [
|
|
214
298
|
{
|
|
215
|
-
"fn": "
|
|
299
|
+
"fn": "mangleName",
|
|
216
300
|
"args": [
|
|
217
301
|
{
|
|
218
|
-
"
|
|
302
|
+
"fn": "ident",
|
|
303
|
+
"args": [
|
|
304
|
+
{
|
|
305
|
+
"get": "node.mangledCallee"
|
|
306
|
+
}
|
|
307
|
+
]
|
|
219
308
|
}
|
|
220
309
|
]
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"case": {
|
|
313
|
+
"when": [[ { "eq": ["node.isRef", "true"] }, "" ]],
|
|
314
|
+
"else": { "tmpl": [ "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
315
|
+
}
|
|
221
316
|
}
|
|
222
317
|
]
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
{
|
|
226
|
-
"map": "node.args",
|
|
227
|
-
"sep": ", "
|
|
228
|
-
},
|
|
229
|
-
")"
|
|
230
|
-
]
|
|
318
|
+
}
|
|
319
|
+
}
|
|
231
320
|
},
|
|
232
321
|
"Member": {
|
|
233
322
|
"case": {
|
|
@@ -301,7 +390,8 @@
|
|
|
301
390
|
"get": "node.field"
|
|
302
391
|
}
|
|
303
392
|
]
|
|
304
|
-
}
|
|
393
|
+
},
|
|
394
|
+
{ "case": { "when": [ [ { "and": [ { "eq": [ "node.isProperty", "true" ] }, { "has": "node.staticType" } ] }, "()" ] ] } }
|
|
305
395
|
]
|
|
306
396
|
}
|
|
307
397
|
}
|
|
@@ -393,7 +483,8 @@
|
|
|
393
483
|
"tmpl": [
|
|
394
484
|
"(",
|
|
395
485
|
{
|
|
396
|
-
"
|
|
486
|
+
"emitChild": "node.then",
|
|
487
|
+
"side": "operand"
|
|
397
488
|
},
|
|
398
489
|
" if ",
|
|
399
490
|
{
|
|
@@ -739,7 +830,7 @@
|
|
|
739
830
|
[
|
|
740
831
|
{
|
|
741
832
|
"eq": [
|
|
742
|
-
"item.
|
|
833
|
+
"item.typeIsRefCollection",
|
|
743
834
|
"true"
|
|
744
835
|
]
|
|
745
836
|
},
|
|
@@ -895,7 +986,7 @@
|
|
|
895
986
|
},
|
|
896
987
|
{
|
|
897
988
|
"tmpl": [
|
|
898
|
-
" and isinstance(__e, ",
|
|
989
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " and builtins.isinstance(__e, ",
|
|
899
990
|
{
|
|
900
991
|
"type": "item.type"
|
|
901
992
|
},
|
|
@@ -1144,7 +1235,7 @@
|
|
|
1144
1235
|
}
|
|
1145
1236
|
]
|
|
1146
1237
|
},
|
|
1147
|
-
" in range(",
|
|
1238
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " in builtins.range(",
|
|
1148
1239
|
{
|
|
1149
1240
|
"emit": "stmt.rangeStart"
|
|
1150
1241
|
},
|
|
@@ -1257,6 +1348,15 @@
|
|
|
1257
1348
|
},
|
|
1258
1349
|
"Program": {
|
|
1259
1350
|
"seq": [
|
|
1351
|
+
{
|
|
1352
|
+
"line": "# <auto-generated/>"
|
|
1353
|
+
},
|
|
1354
|
+
{
|
|
1355
|
+
"line": "# Generated by Polyglot. Do not edit: regenerate with `polyglot build`."
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
"fn": "preludeSlot"
|
|
1359
|
+
},
|
|
1260
1360
|
{
|
|
1261
1361
|
"case": {
|
|
1262
1362
|
"when": [
|
|
@@ -1321,10 +1421,15 @@
|
|
|
1321
1421
|
},
|
|
1322
1422
|
" import ",
|
|
1323
1423
|
{
|
|
1324
|
-
"
|
|
1424
|
+
"fn": "mangle",
|
|
1425
|
+
"args": [ { "get": "item.names" } ]
|
|
1325
1426
|
}
|
|
1326
1427
|
]
|
|
1327
1428
|
}
|
|
1429
|
+
],
|
|
1430
|
+
[
|
|
1431
|
+
{ "not": { "eq": ["item.allNames", ""] } },
|
|
1432
|
+
{ "tmpl": ["from ", { "get": "item.path" }, " import *"] }
|
|
1328
1433
|
]
|
|
1329
1434
|
],
|
|
1330
1435
|
"else": {
|
|
@@ -1344,84 +1449,65 @@
|
|
|
1344
1449
|
"when": [
|
|
1345
1450
|
[
|
|
1346
1451
|
{
|
|
1347
|
-
"
|
|
1348
|
-
"eq": [
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
]
|
|
1352
|
-
}
|
|
1452
|
+
"or": [
|
|
1453
|
+
{ "not": { "eq": [ "module.interfaces.count", "0" ] } },
|
|
1454
|
+
{ "not": { "eq": [ "module.abstractClasses.count", "0" ] } }
|
|
1455
|
+
]
|
|
1353
1456
|
},
|
|
1354
1457
|
{
|
|
1355
|
-
"line": "import abc"
|
|
1458
|
+
"line": "import abc as _PG_abc"
|
|
1356
1459
|
}
|
|
1357
1460
|
]
|
|
1358
1461
|
]
|
|
1359
1462
|
}
|
|
1360
1463
|
},
|
|
1361
1464
|
{
|
|
1362
|
-
"
|
|
1363
|
-
"
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
"rule": "RecordDecl"
|
|
1376
|
-
},
|
|
1377
|
-
{
|
|
1378
|
-
"mapMembers": "module.classes",
|
|
1379
|
-
"rule": "ClassDecl"
|
|
1380
|
-
},
|
|
1381
|
-
{
|
|
1382
|
-
"mapDecl": "module.globals",
|
|
1383
|
-
"each": {
|
|
1384
|
-
"line": {
|
|
1385
|
-
"tmpl": [
|
|
1386
|
-
{
|
|
1387
|
-
"fn": "ident",
|
|
1388
|
-
"args": [
|
|
1465
|
+
"mapOrder": "module.order",
|
|
1466
|
+
"kinds": {
|
|
1467
|
+
"enum": { "rule": "EnumDecl" },
|
|
1468
|
+
"interface": { "rule": "InterfaceDecl" },
|
|
1469
|
+
"union": { "rule": "UnionDecl" },
|
|
1470
|
+
"record": { "rule": "RecordDecl" },
|
|
1471
|
+
"function": { "rule": "FunctionDecl" },
|
|
1472
|
+
"extension": { "rule": "FunctionDecl" },
|
|
1473
|
+
"class": { "rule": "ClassDecl" },
|
|
1474
|
+
"global": {
|
|
1475
|
+
"each": {
|
|
1476
|
+
"line": {
|
|
1477
|
+
"tmpl": [
|
|
1389
1478
|
{
|
|
1390
|
-
"
|
|
1391
|
-
|
|
1392
|
-
]
|
|
1393
|
-
},
|
|
1394
|
-
" = ",
|
|
1395
|
-
{
|
|
1396
|
-
"case": {
|
|
1397
|
-
"when": [
|
|
1398
|
-
[
|
|
1399
|
-
{
|
|
1400
|
-
"eq": [
|
|
1401
|
-
"item.hasInit",
|
|
1402
|
-
"true"
|
|
1403
|
-
]
|
|
1404
|
-
},
|
|
1479
|
+
"fn": "ident",
|
|
1480
|
+
"args": [
|
|
1405
1481
|
{
|
|
1406
|
-
"
|
|
1482
|
+
"get": "item.name"
|
|
1407
1483
|
}
|
|
1408
1484
|
]
|
|
1409
|
-
|
|
1410
|
-
"
|
|
1411
|
-
|
|
1485
|
+
},
|
|
1486
|
+
" = ",
|
|
1487
|
+
{
|
|
1488
|
+
"case": {
|
|
1489
|
+
"when": [
|
|
1490
|
+
[
|
|
1491
|
+
{
|
|
1492
|
+
"eq": [
|
|
1493
|
+
"item.hasInit",
|
|
1494
|
+
"true"
|
|
1495
|
+
]
|
|
1496
|
+
},
|
|
1497
|
+
{
|
|
1498
|
+
"emit": "item.init"
|
|
1499
|
+
}
|
|
1500
|
+
]
|
|
1501
|
+
],
|
|
1502
|
+
"else": "None"
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
]
|
|
1412
1506
|
}
|
|
1413
|
-
|
|
1507
|
+
}
|
|
1414
1508
|
}
|
|
1415
1509
|
}
|
|
1416
1510
|
},
|
|
1417
|
-
{
|
|
1418
|
-
"mapMembers": "module.functions",
|
|
1419
|
-
"rule": "FunctionDecl"
|
|
1420
|
-
},
|
|
1421
|
-
{
|
|
1422
|
-
"mapMembers": "module.extensions",
|
|
1423
|
-
"rule": "FunctionDecl"
|
|
1424
|
-
},
|
|
1425
1511
|
{
|
|
1426
1512
|
"case": {
|
|
1427
1513
|
"when": [
|
|
@@ -1445,7 +1531,7 @@
|
|
|
1445
1531
|
{
|
|
1446
1532
|
"line": {
|
|
1447
1533
|
"tmpl": [
|
|
1448
|
-
"
|
|
1534
|
+
"_PG_asyncio.run(",
|
|
1449
1535
|
{
|
|
1450
1536
|
"fn": "mangle",
|
|
1451
1537
|
"args": [
|
|
@@ -1548,7 +1634,8 @@
|
|
|
1548
1634
|
"else": ""
|
|
1549
1635
|
}
|
|
1550
1636
|
},
|
|
1551
|
-
{ "stmts": "stmt.body" }
|
|
1637
|
+
{ "stmts": "stmt.body" },
|
|
1638
|
+
{ "case": { "when": [ [ { "eq": [ "stmt.body.count", "0" ] }, { "line": "pass" } ] ] } }
|
|
1552
1639
|
]
|
|
1553
1640
|
}
|
|
1554
1641
|
},
|
|
@@ -1647,6 +1734,15 @@
|
|
|
1647
1734
|
{
|
|
1648
1735
|
"case": {
|
|
1649
1736
|
"when": [
|
|
1737
|
+
[
|
|
1738
|
+
{
|
|
1739
|
+
"and": [
|
|
1740
|
+
{ "eq": [ "decl.bases.count", "0" ] },
|
|
1741
|
+
{ "eq": [ "decl.isAbstract", "true" ] }
|
|
1742
|
+
]
|
|
1743
|
+
},
|
|
1744
|
+
"(_PG_abc.ABC)"
|
|
1745
|
+
],
|
|
1650
1746
|
[
|
|
1651
1747
|
{
|
|
1652
1748
|
"eq": [
|
|
@@ -1667,6 +1763,7 @@
|
|
|
1667
1763
|
"type": "item"
|
|
1668
1764
|
}
|
|
1669
1765
|
},
|
|
1766
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, ", _PG_abc.ABC" ] ] } },
|
|
1670
1767
|
")"
|
|
1671
1768
|
]
|
|
1672
1769
|
}
|
|
@@ -1715,7 +1812,7 @@
|
|
|
1715
1812
|
}
|
|
1716
1813
|
}
|
|
1717
1814
|
},
|
|
1718
|
-
"
|
|
1815
|
+
"_PG_abc.ABC)"
|
|
1719
1816
|
]
|
|
1720
1817
|
},
|
|
1721
1818
|
"body": [
|
|
@@ -1724,7 +1821,7 @@
|
|
|
1724
1821
|
"each": {
|
|
1725
1822
|
"seq": [
|
|
1726
1823
|
{
|
|
1727
|
-
"line": "@
|
|
1824
|
+
"line": "@_PG_abc.abstractmethod"
|
|
1728
1825
|
},
|
|
1729
1826
|
{
|
|
1730
1827
|
"line": {
|
|
@@ -1762,6 +1859,8 @@
|
|
|
1762
1859
|
}
|
|
1763
1860
|
},
|
|
1764
1861
|
"ClassDecl": {
|
|
1862
|
+
"seq": [
|
|
1863
|
+
{
|
|
1765
1864
|
"block": {
|
|
1766
1865
|
"head": {
|
|
1767
1866
|
"call": "pyClassHead"
|
|
@@ -1770,6 +1869,11 @@
|
|
|
1770
1869
|
{
|
|
1771
1870
|
"mapDecl": "decl.staticInitFields",
|
|
1772
1871
|
"each": {
|
|
1872
|
+
"case": {
|
|
1873
|
+
"when": [
|
|
1874
|
+
[
|
|
1875
|
+
{ "eq": ["item.initIsLiteral", "true"] },
|
|
1876
|
+
{
|
|
1773
1877
|
"line": {
|
|
1774
1878
|
"tmpl": [
|
|
1775
1879
|
{
|
|
@@ -1785,6 +1889,10 @@
|
|
|
1785
1889
|
"emit": "item.init"
|
|
1786
1890
|
}
|
|
1787
1891
|
]
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
]
|
|
1895
|
+
]
|
|
1788
1896
|
}
|
|
1789
1897
|
}
|
|
1790
1898
|
},
|
|
@@ -1825,7 +1933,7 @@
|
|
|
1825
1933
|
[
|
|
1826
1934
|
{
|
|
1827
1935
|
"eq": [
|
|
1828
|
-
"decl.
|
|
1936
|
+
"decl.baseHasInit",
|
|
1829
1937
|
"true"
|
|
1830
1938
|
]
|
|
1831
1939
|
},
|
|
@@ -1881,7 +1989,7 @@
|
|
|
1881
1989
|
"and": [
|
|
1882
1990
|
{
|
|
1883
1991
|
"eq": [
|
|
1884
|
-
"decl.
|
|
1992
|
+
"decl.baseHasInit",
|
|
1885
1993
|
"false"
|
|
1886
1994
|
]
|
|
1887
1995
|
},
|
|
@@ -1925,7 +2033,7 @@
|
|
|
1925
2033
|
"and": [
|
|
1926
2034
|
{
|
|
1927
2035
|
"eq": [
|
|
1928
|
-
"decl.
|
|
2036
|
+
"decl.literalStaticInitCount",
|
|
1929
2037
|
"0"
|
|
1930
2038
|
]
|
|
1931
2039
|
},
|
|
@@ -1952,6 +2060,27 @@
|
|
|
1952
2060
|
}
|
|
1953
2061
|
]
|
|
1954
2062
|
}
|
|
2063
|
+
},
|
|
2064
|
+
{
|
|
2065
|
+
"mapDecl": "decl.staticInitFields",
|
|
2066
|
+
"each": {
|
|
2067
|
+
"case": {
|
|
2068
|
+
"when": [
|
|
2069
|
+
[
|
|
2070
|
+
{ "eq": ["item.initIsLiteral", "false"] },
|
|
2071
|
+
{ "line": { "tmpl": [
|
|
2072
|
+
{ "fn": "ident", "args": [ { "get": "decl.name" } ] },
|
|
2073
|
+
".",
|
|
2074
|
+
{ "fn": "ident", "args": [ { "get": "item.name" } ] },
|
|
2075
|
+
" = ",
|
|
2076
|
+
{ "emit": "item.init" }
|
|
2077
|
+
] } }
|
|
2078
|
+
]
|
|
2079
|
+
]
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
]
|
|
1955
2084
|
},
|
|
1956
2085
|
"pyParam": {
|
|
1957
2086
|
"tmpl": [
|
|
@@ -2152,6 +2281,15 @@
|
|
|
2152
2281
|
]
|
|
2153
2282
|
},
|
|
2154
2283
|
"__rshift__"
|
|
2284
|
+
],
|
|
2285
|
+
[
|
|
2286
|
+
{
|
|
2287
|
+
"eq": [
|
|
2288
|
+
"decl.opSymbol",
|
|
2289
|
+
"hash"
|
|
2290
|
+
]
|
|
2291
|
+
},
|
|
2292
|
+
"__hash__"
|
|
2155
2293
|
]
|
|
2156
2294
|
],
|
|
2157
2295
|
"else": {
|
|
@@ -2260,15 +2398,16 @@
|
|
|
2260
2398
|
"case": {
|
|
2261
2399
|
"when": [
|
|
2262
2400
|
[
|
|
2263
|
-
{
|
|
2264
|
-
|
|
2265
|
-
"
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
"
|
|
2271
|
-
}
|
|
2401
|
+
{ "and": [
|
|
2402
|
+
{
|
|
2403
|
+
"eq": [
|
|
2404
|
+
"decl.kind",
|
|
2405
|
+
"property"
|
|
2406
|
+
]
|
|
2407
|
+
},
|
|
2408
|
+
{ "eq": [ "decl.isStatic", "false" ] }
|
|
2409
|
+
] },
|
|
2410
|
+
{ "line": { "tmpl": [ { "fn": "require", "args": ["pyBuiltins"] }, "@builtins.property" ] } }
|
|
2272
2411
|
]
|
|
2273
2412
|
]
|
|
2274
2413
|
}
|
|
@@ -2283,13 +2422,12 @@
|
|
|
2283
2422
|
"true"
|
|
2284
2423
|
]
|
|
2285
2424
|
},
|
|
2286
|
-
{
|
|
2287
|
-
"line": "@staticmethod"
|
|
2288
|
-
}
|
|
2425
|
+
{ "line": { "tmpl": [ { "fn": "require", "args": ["pyBuiltins"] }, "@builtins.staticmethod" ] } }
|
|
2289
2426
|
]
|
|
2290
2427
|
]
|
|
2291
2428
|
}
|
|
2292
2429
|
},
|
|
2430
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, { "line": "@_PG_abc.abstractmethod" } ] ] } },
|
|
2293
2431
|
{
|
|
2294
2432
|
"case": {
|
|
2295
2433
|
"when": [
|
|
@@ -2419,8 +2557,9 @@
|
|
|
2419
2557
|
"tmpl": [
|
|
2420
2558
|
"{\"tag\": ",
|
|
2421
2559
|
{
|
|
2422
|
-
"fn": "
|
|
2560
|
+
"fn": "quoted",
|
|
2423
2561
|
"args": [
|
|
2562
|
+
"string",
|
|
2424
2563
|
{
|
|
2425
2564
|
"get": "node.caseName"
|
|
2426
2565
|
}
|
|
@@ -2433,8 +2572,9 @@
|
|
|
2433
2572
|
"tmpl": [
|
|
2434
2573
|
", ",
|
|
2435
2574
|
{
|
|
2436
|
-
"fn": "
|
|
2575
|
+
"fn": "quoted",
|
|
2437
2576
|
"args": [
|
|
2577
|
+
"string",
|
|
2438
2578
|
{
|
|
2439
2579
|
"get": "item.name"
|
|
2440
2580
|
}
|
|
@@ -2452,13 +2592,52 @@
|
|
|
2452
2592
|
},
|
|
2453
2593
|
"IsTest": {
|
|
2454
2594
|
"tmpl": [
|
|
2455
|
-
"isinstance(",
|
|
2595
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.isinstance(",
|
|
2456
2596
|
{ "emit": "node.operand" },
|
|
2457
2597
|
", ",
|
|
2458
2598
|
{ "type": "node.testType" },
|
|
2459
2599
|
")"
|
|
2460
2600
|
]
|
|
2461
2601
|
},
|
|
2602
|
+
"NullAssert": {
|
|
2603
|
+
"case": {
|
|
2604
|
+
"when": [
|
|
2605
|
+
[
|
|
2606
|
+
{ "eq": ["node.isFail", "true"] },
|
|
2607
|
+
{ "tmpl": [{ "fn": "require", "args": ["pgFail"] }, "_pg_fail(", { "fn": "quoted", "args": ["string", { "get": "node.where" }] }, ")"] }
|
|
2608
|
+
],
|
|
2609
|
+
[
|
|
2610
|
+
{ "eq": ["node.operandIsSimple", "true"] },
|
|
2611
|
+
{
|
|
2612
|
+
"tmpl": [
|
|
2613
|
+
{ "fn": "require", "args": ["pgFail"] },
|
|
2614
|
+
"(",
|
|
2615
|
+
{ "emit": "node.operand" },
|
|
2616
|
+
" if ",
|
|
2617
|
+
{ "emit": "node.operand" },
|
|
2618
|
+
" is not None else _pg_fail(",
|
|
2619
|
+
{ "fn": "quoted", "args": ["string", { "get": "node.where" }] },
|
|
2620
|
+
"))"
|
|
2621
|
+
]
|
|
2622
|
+
}
|
|
2623
|
+
]
|
|
2624
|
+
],
|
|
2625
|
+
"else": {
|
|
2626
|
+
"tmpl": [
|
|
2627
|
+
{ "fn": "require", "args": ["pgFail"] },
|
|
2628
|
+
"(",
|
|
2629
|
+
{ "get": "node.tempName" },
|
|
2630
|
+
" if (",
|
|
2631
|
+
{ "get": "node.tempName" },
|
|
2632
|
+
" := ",
|
|
2633
|
+
{ "emit": "node.operand" },
|
|
2634
|
+
") is not None else _pg_fail(",
|
|
2635
|
+
{ "fn": "quoted", "args": ["string", { "get": "node.where" }] },
|
|
2636
|
+
"))"
|
|
2637
|
+
]
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
},
|
|
2462
2641
|
"AsCast": {
|
|
2463
2642
|
"case": {
|
|
2464
2643
|
"when": [
|
|
@@ -2468,7 +2647,7 @@
|
|
|
2468
2647
|
"tmpl": [
|
|
2469
2648
|
"(",
|
|
2470
2649
|
{ "emit": "node.operand" },
|
|
2471
|
-
" if isinstance(",
|
|
2650
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " if builtins.isinstance(",
|
|
2472
2651
|
{ "emit": "node.operand" },
|
|
2473
2652
|
", ",
|
|
2474
2653
|
{ "type": "node.castType" },
|
|
@@ -2481,7 +2660,7 @@
|
|
|
2481
2660
|
"tmpl": [
|
|
2482
2661
|
"(",
|
|
2483
2662
|
{ "get": "node.tempName" },
|
|
2484
|
-
" if isinstance((",
|
|
2663
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " if builtins.isinstance((",
|
|
2485
2664
|
{ "get": "node.tempName" },
|
|
2486
2665
|
" := ",
|
|
2487
2666
|
{ "emit": "node.operand" },
|
|
@@ -2601,7 +2780,7 @@
|
|
|
2601
2780
|
},
|
|
2602
2781
|
{
|
|
2603
2782
|
"tmpl": [
|
|
2604
|
-
"float(",
|
|
2783
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.float(",
|
|
2605
2784
|
{
|
|
2606
2785
|
"emit": "node.operand"
|
|
2607
2786
|
},
|
|
@@ -2639,7 +2818,7 @@
|
|
|
2639
2818
|
},
|
|
2640
2819
|
{
|
|
2641
2820
|
"tmpl": [
|
|
2642
|
-
"int(",
|
|
2821
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.int(",
|
|
2643
2822
|
{
|
|
2644
2823
|
"emit": "node.operand"
|
|
2645
2824
|
},
|
|
@@ -2781,8 +2960,9 @@
|
|
|
2781
2960
|
"lits": "node.chunks",
|
|
2782
2961
|
"holes": "node.holes",
|
|
2783
2962
|
"lit": {
|
|
2784
|
-
"fn": "
|
|
2963
|
+
"fn": "quoted",
|
|
2785
2964
|
"args": [
|
|
2965
|
+
"interp",
|
|
2786
2966
|
{
|
|
2787
2967
|
"get": "item"
|
|
2788
2968
|
}
|
|
@@ -2817,14 +2997,7 @@
|
|
|
2817
2997
|
},
|
|
2818
2998
|
{
|
|
2819
2999
|
"tmpl": [
|
|
2820
|
-
{
|
|
2821
|
-
"fn": "ident",
|
|
2822
|
-
"args": [
|
|
2823
|
-
{
|
|
2824
|
-
"get": "node.method"
|
|
2825
|
-
}
|
|
2826
|
-
]
|
|
2827
|
-
},
|
|
3000
|
+
{ "fn": "mangleName", "args": [ { "fn": "ident", "args": [ { "get": "node.freeName" } ] } ] },
|
|
2828
3001
|
"(",
|
|
2829
3002
|
{
|
|
2830
3003
|
"emit": "node.object"
|
|
@@ -3071,7 +3244,8 @@
|
|
|
3071
3244
|
]
|
|
3072
3245
|
],
|
|
3073
3246
|
"else": {
|
|
3074
|
-
"
|
|
3247
|
+
"emitChild": "item.body",
|
|
3248
|
+
"side": "operand"
|
|
3075
3249
|
}
|
|
3076
3250
|
}
|
|
3077
3251
|
},
|
|
@@ -3232,12 +3406,16 @@
|
|
|
3232
3406
|
},
|
|
3233
3407
|
{
|
|
3234
3408
|
"tmpl": [
|
|
3235
|
-
"isinstance(_m, ",
|
|
3409
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.isinstance(_m, ",
|
|
3236
3410
|
{ "type": "item.pattern.testType" },
|
|
3237
3411
|
")"
|
|
3238
3412
|
]
|
|
3239
3413
|
}
|
|
3240
3414
|
],
|
|
3415
|
+
[
|
|
3416
|
+
{ "eq": ["item.pattern.isNullLiteral", "true"] },
|
|
3417
|
+
{ "tmpl": ["_m is None"] }
|
|
3418
|
+
],
|
|
3241
3419
|
[
|
|
3242
3420
|
{
|
|
3243
3421
|
"eq": [
|
|
@@ -3285,8 +3463,9 @@
|
|
|
3285
3463
|
"tmpl": [
|
|
3286
3464
|
"_m[\"tag\"] == ",
|
|
3287
3465
|
{
|
|
3288
|
-
"fn": "
|
|
3466
|
+
"fn": "quoted",
|
|
3289
3467
|
"args": [
|
|
3468
|
+
"string",
|
|
3290
3469
|
{
|
|
3291
3470
|
"get": "item.pattern.ctorCase"
|
|
3292
3471
|
}
|
|
@@ -3496,7 +3675,8 @@
|
|
|
3496
3675
|
},
|
|
3497
3676
|
{
|
|
3498
3677
|
"tmpl": [
|
|
3499
|
-
"
|
|
3678
|
+
{ "fn": "require", "args": ["fdiv"] },
|
|
3679
|
+
"_pg_fmod(",
|
|
3500
3680
|
{
|
|
3501
3681
|
"emit": "node.lhs"
|
|
3502
3682
|
},
|
|
@@ -3508,6 +3688,10 @@
|
|
|
3508
3688
|
]
|
|
3509
3689
|
}
|
|
3510
3690
|
],
|
|
3691
|
+
[
|
|
3692
|
+
{ "and": [ { "eq": ["node.typeIsFloat", "true"] }, { "eq": ["node.op", "/"] } ] },
|
|
3693
|
+
{ "tmpl": [ { "fn": "require", "args": ["fdiv"] }, "_pg_fdiv(", { "emit": "node.lhs" }, ", ", { "emit": "node.rhs" }, ")" ] }
|
|
3694
|
+
],
|
|
3511
3695
|
[
|
|
3512
3696
|
{
|
|
3513
3697
|
"and": [
|
|
@@ -3753,8 +3937,9 @@
|
|
|
3753
3937
|
}
|
|
3754
3938
|
},
|
|
3755
3939
|
"Char": {
|
|
3756
|
-
"fn": "
|
|
3940
|
+
"fn": "quoted",
|
|
3757
3941
|
"args": [
|
|
3942
|
+
"char",
|
|
3758
3943
|
{
|
|
3759
3944
|
"get": "node.value"
|
|
3760
3945
|
}
|
|
@@ -3765,17 +3950,26 @@
|
|
|
3765
3950
|
"std.collections": {
|
|
3766
3951
|
"List.type": "list",
|
|
3767
3952
|
"List.constructor": "[]",
|
|
3768
|
-
"List.count": "len($this)",
|
|
3953
|
+
"List.count": { "template": "builtins.len($this)", "requires": ["pyBuiltins"] },
|
|
3769
3954
|
"List.add": "$this.append($0)",
|
|
3770
3955
|
"List.clear": "$this.clear()",
|
|
3771
3956
|
"List.removeAll": "$this[:] = [__e for __e in $this if not (($0)(__e))]",
|
|
3772
|
-
"List.removeAt": "$this.pop($0)"
|
|
3957
|
+
"List.removeAt": "$this.pop($0)",
|
|
3958
|
+
"Map.type": "dict",
|
|
3959
|
+
"Map.constructor": "{}",
|
|
3960
|
+
"Map.count": { "template": "builtins.len($this)", "requires": ["pyBuiltins"] },
|
|
3961
|
+
"Map.get": "$this.get($0)",
|
|
3962
|
+
"Map.set": "$this.__setitem__($0, $1)",
|
|
3963
|
+
"Map.has": "($0 in $this)",
|
|
3964
|
+
"Map.remove": { "template": "($this.pop($0, _PG_ABSENT) is not _PG_ABSENT)", "requires": ["pgAbsent"] },
|
|
3965
|
+
"Map.keys": { "template": "builtins.list($this.keys())", "requires": ["pyBuiltins"] },
|
|
3966
|
+
"Map.values": { "template": "builtins.list($this.values())", "requires": ["pyBuiltins"] }
|
|
3773
3967
|
},
|
|
3774
3968
|
"std.io": {
|
|
3775
|
-
"print": "
|
|
3969
|
+
"print": { "template": "__import__('builtins').print(_pg_out16(_pg_str(x)))", "requires": ["fstr", "pgOut16"] },
|
|
3776
3970
|
"readText": "__import__('pathlib').Path(path).read_text()",
|
|
3777
3971
|
"writeText": "__import__('pathlib').Path(path).write_text(content)",
|
|
3778
|
-
"appendText": "open(path, 'a').write(content)",
|
|
3972
|
+
"appendText": { "template": "builtins.open(path, 'a').write(content)", "requires": ["pyBuiltins"] },
|
|
3779
3973
|
"fileExists": "__import__('os').path.exists(path)",
|
|
3780
3974
|
"deleteFile": "__import__('os').remove(path)"
|
|
3781
3975
|
},
|
|
@@ -3783,6 +3977,7 @@
|
|
|
3783
3977
|
"Math.PI": "__import__('math').pi",
|
|
3784
3978
|
"Math.E": "__import__('math').e",
|
|
3785
3979
|
"Math.sqrt": "__import__('math').sqrt($0)",
|
|
3980
|
+
"Math.isNaN": "__import__('math').isnan($0)",
|
|
3786
3981
|
"Math.ln": "__import__('math').log($0)",
|
|
3787
3982
|
"Math.log": "__import__('math').log($0)",
|
|
3788
3983
|
"Math.log2": "__import__('math').log2($0)",
|
|
@@ -3802,45 +3997,59 @@
|
|
|
3802
3997
|
"Math.asinh": "__import__('math').asinh($0)",
|
|
3803
3998
|
"Math.acosh": "__import__('math').acosh($0)",
|
|
3804
3999
|
"Math.atanh": "__import__('math').atanh($0)",
|
|
3805
|
-
"Math.trunc": "float(__import__('math').trunc($0))",
|
|
3806
|
-
"Math.floor": "float(__import__('math').floor($0))",
|
|
3807
|
-
"Math.ceil": "float(__import__('math').ceil($0))",
|
|
3808
|
-
"Math.min": "min($0, $1)",
|
|
3809
|
-
"Math.max": "max($0, $1)",
|
|
3810
|
-
"Math.abs": "abs($0)",
|
|
3811
|
-
"Math.sign": "(lambda a: type(a)(1) if a > 0 else (type(a)(-1) if a < 0 else a - a))($0)",
|
|
4000
|
+
"Math.trunc": { "template": "builtins.float(__import__('math').trunc($0))", "requires": ["pyBuiltins"] },
|
|
4001
|
+
"Math.floor": { "template": "builtins.float(__import__('math').floor($0))", "requires": ["pyBuiltins"] },
|
|
4002
|
+
"Math.ceil": { "template": "builtins.float(__import__('math').ceil($0))", "requires": ["pyBuiltins"] },
|
|
4003
|
+
"Math.min": { "template": "builtins.min($0, $1)", "requires": ["pyBuiltins"] },
|
|
4004
|
+
"Math.max": { "template": "builtins.max($0, $1)", "requires": ["pyBuiltins"] },
|
|
4005
|
+
"Math.abs": { "template": "builtins.abs($0)", "requires": ["pyBuiltins"] },
|
|
4006
|
+
"Math.sign": { "template": "(lambda a: builtins.type(a)(1) if a > 0 else (builtins.type(a)(-1) if a < 0 else a - a))($0)", "requires": ["pyBuiltins"] },
|
|
3812
4007
|
"Math.clamp": "(lambda x, lo, hi: lo if x < lo else (hi if x > hi else x))($0, $1, $2)",
|
|
3813
|
-
"Math.round": "float(round($0))"
|
|
4008
|
+
"Math.round": { "template": "builtins.float(builtins.round($0))", "requires": ["pyBuiltins"] }
|
|
3814
4009
|
},
|
|
3815
4010
|
"std.strings": {
|
|
3816
|
-
"string.isEmpty": "(len($this) == 0)",
|
|
3817
|
-
"string.len": "
|
|
4011
|
+
"string.isEmpty": { "template": "(builtins.len($this) == 0)", "requires": ["pyBuiltins"] },
|
|
4012
|
+
"string.len": { "template": "_pg_len16($this)", "requires": ["pgU16"] },
|
|
3818
4013
|
"string.toUpper": "$this.upper()",
|
|
3819
4014
|
"string.toLower": "$this.lower()",
|
|
3820
|
-
"string.
|
|
3821
|
-
"string.
|
|
3822
|
-
"string.codePoints": "list($this)",
|
|
3823
|
-
"string.
|
|
4015
|
+
"string.toUpperAscii": { "template": "$this.translate(_PG_UPPER)", "requires": ["pgAscii"] },
|
|
4016
|
+
"string.toLowerAscii": { "template": "$this.translate(_PG_LOWER)", "requires": ["pgAscii"] },
|
|
4017
|
+
"string.codePoints": { "template": "builtins.list($this)", "requires": ["pyBuiltins"] },
|
|
4018
|
+
"string.startsWith": { "template": "_pg_u16_starts($this, $0)", "requires": ["pgU16"] },
|
|
4019
|
+
"string.endsWith": { "template": "_pg_u16_ends($this, $0)", "requires": ["pgU16"] },
|
|
4020
|
+
"string.contains": { "template": "_pg_u16_has($this, $0)", "requires": ["pgU16"] },
|
|
4021
|
+
"string.trimAscii": "$this.strip(\"\\t\\n\\x0b\\x0c\\r \")",
|
|
4022
|
+
"compareOrdinal": { "template": "_pg_cmp16(a, b)", "requires": ["pgU16"] },
|
|
4023
|
+
"string.__pgCharAt": { "template": "_pg_u16_char($this, $0)", "requires": ["pgU16"] },
|
|
4024
|
+
"string.__pgCodePointAt": { "template": "_pg_u16_cp($this, $0)", "requires": ["pgU16"] },
|
|
4025
|
+
"string.__pgSubstring": { "template": "_pg_u16_sub($this, $0, $1)", "requires": ["pgU16"] },
|
|
4026
|
+
"string.__pgIndexOf": { "template": "_pg_u16_find($this, $0, $1)", "requires": ["pgU16"] },
|
|
4027
|
+
"string.__pgReplaceAll": { "template": "_pg_u16_replace($this, $0, $1)", "requires": ["pgU16"] },
|
|
4028
|
+
"string.__pgSplit": { "template": "_pg_u16_split($this, $0)", "requires": ["pgU16"] },
|
|
4029
|
+
"string.__pgFromCodePoint": { "template": "builtins.chr($0)", "requires": ["pyBuiltins"] }
|
|
3824
4030
|
},
|
|
3825
4031
|
"std.core": {
|
|
3826
4032
|
"Error.type": "Exception",
|
|
3827
4033
|
"Error.constructor": "$T($0)",
|
|
3828
|
-
"Error.message": "str($this)",
|
|
4034
|
+
"Error.message": { "template": "builtins.str($this)", "requires": ["pyBuiltins"] },
|
|
3829
4035
|
"Iterable.type": "list",
|
|
3830
4036
|
"Array.type": "list",
|
|
3831
4037
|
"Array.constructor": "[]",
|
|
3832
|
-
"Array.count": "len($this)",
|
|
3833
|
-
"
|
|
3834
|
-
"
|
|
3835
|
-
"
|
|
3836
|
-
"
|
|
3837
|
-
"
|
|
3838
|
-
"
|
|
3839
|
-
"
|
|
3840
|
-
"
|
|
3841
|
-
"
|
|
3842
|
-
"
|
|
4038
|
+
"Array.count": { "template": "builtins.len($this)", "requires": ["pyBuiltins"] },
|
|
4039
|
+
"__pgText.rawLen": { "template": "builtins.len($0)", "requires": ["pyBuiltins"] },
|
|
4040
|
+
"__pgText.rawCode": { "template": "builtins.ord($0[$1])", "requires": ["pyBuiltins"] },
|
|
4041
|
+
"i8.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4042
|
+
"i16.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4043
|
+
"i32.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4044
|
+
"i64.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4045
|
+
"u8.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4046
|
+
"u16.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4047
|
+
"u32.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4048
|
+
"u64.__pgParse": { "template": "_pg_int($0)", "requires": ["pgInt"] },
|
|
4049
|
+
"f32.__pgParse": { "template": "_pg_f32(builtins.float($0))", "requires": ["pgF32", "pyBuiltins"] },
|
|
4050
|
+
"f64.__pgParse": { "template": "builtins.float($0)", "requires": ["pyBuiltins"] }
|
|
3843
4051
|
}
|
|
3844
4052
|
},
|
|
3845
|
-
"fileExtension": ".py"
|
|
4053
|
+
"fileExtension": ".py",
|
|
4054
|
+
"lineComment": "#"
|
|
3846
4055
|
}
|