@mintplayer/polyglot-target-python 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 +384 -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.2",
|
|
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,12 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema":
|
|
2
|
+
"schema": 2,
|
|
3
3
|
"name": "python",
|
|
4
|
+
"preludePerFile": true,
|
|
5
|
+
"originMapping": {
|
|
6
|
+
"style": "sourceMapV3",
|
|
7
|
+
"sidecarExtension": ".map",
|
|
8
|
+
"footer": "# sourceMappingURL=$f"
|
|
9
|
+
},
|
|
4
10
|
"capabilities": {
|
|
11
|
+
"utf16Strings:index": "emulated",
|
|
5
12
|
"blockLambdas": "emulated",
|
|
6
13
|
"interfaces": "emulated",
|
|
7
14
|
"interfaces:runtimeIdentity": "native",
|
|
8
15
|
"attributes:target.field": false,
|
|
9
|
-
"attributes:target.param": false
|
|
16
|
+
"attributes:target.param": false,
|
|
17
|
+
"propertySetters:static": false
|
|
10
18
|
},
|
|
11
19
|
"spec": {
|
|
12
20
|
"name": "python",
|
|
@@ -28,21 +36,48 @@
|
|
|
28
36
|
"i64": "(((($x) & 0xffffffffffffffff) ^ 0x8000000000000000) - 0x8000000000000000)"
|
|
29
37
|
},
|
|
30
38
|
"wrapAtom": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
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"
|
|
39
56
|
]
|
|
40
57
|
},
|
|
41
58
|
"rethrow": "raise",
|
|
42
59
|
"preludes": {
|
|
43
|
-
"
|
|
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",
|
|
44
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",
|
|
45
|
-
"
|
|
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"]
|
|
46
81
|
},
|
|
47
82
|
"tables": {
|
|
48
83
|
"localDecl": {
|
|
@@ -60,7 +95,48 @@
|
|
|
60
95
|
"trueLit": "True",
|
|
61
96
|
"falseLit": "False",
|
|
62
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
|
+
},
|
|
63
136
|
"expressionOnlyLambdas": true,
|
|
137
|
+
"unboundImports": ["union", "unionCase"],
|
|
138
|
+
"nativeCoalesceAssign": false,
|
|
139
|
+
"assignmentOrder": "valueFirst",
|
|
64
140
|
"identifiers": {
|
|
65
141
|
"keywords": [
|
|
66
142
|
"False",
|
|
@@ -107,13 +183,17 @@
|
|
|
107
183
|
},
|
|
108
184
|
"mangle": {
|
|
109
185
|
"replace": "$",
|
|
110
|
-
"with": "
|
|
186
|
+
"with": "__"
|
|
111
187
|
},
|
|
112
188
|
"reserved": [
|
|
113
189
|
"_m",
|
|
114
190
|
"self",
|
|
115
191
|
"_pg_idiv",
|
|
116
192
|
"_pg_irem",
|
|
193
|
+
"_pg_fdiv",
|
|
194
|
+
"_pg_fmod",
|
|
195
|
+
"_pg_int",
|
|
196
|
+
"_pg_f32",
|
|
117
197
|
"__c*",
|
|
118
198
|
"__o*",
|
|
119
199
|
"__e",
|
|
@@ -122,10 +202,14 @@
|
|
|
122
202
|
"__dw*",
|
|
123
203
|
"tag",
|
|
124
204
|
"__opt*",
|
|
205
|
+
"_PG_*",
|
|
125
206
|
"__w*"
|
|
126
207
|
],
|
|
208
|
+
"runtimeNames": [
|
|
209
|
+
"builtins"
|
|
210
|
+
],
|
|
127
211
|
"globals": [
|
|
128
|
-
"
|
|
212
|
+
"Exception"
|
|
129
213
|
]
|
|
130
214
|
}
|
|
131
215
|
},
|
|
@@ -146,7 +230,7 @@
|
|
|
146
230
|
]
|
|
147
231
|
},
|
|
148
232
|
"Float": {
|
|
149
|
-
"get": "node.
|
|
233
|
+
"get": "node.widenedText"
|
|
150
234
|
},
|
|
151
235
|
"Bool": {
|
|
152
236
|
"case": {
|
|
@@ -172,8 +256,9 @@
|
|
|
172
256
|
"get": "spec.nullLit"
|
|
173
257
|
},
|
|
174
258
|
"Str": {
|
|
175
|
-
"fn": "
|
|
259
|
+
"fn": "quoted",
|
|
176
260
|
"args": [
|
|
261
|
+
"string",
|
|
177
262
|
{
|
|
178
263
|
"get": "node.value"
|
|
179
264
|
}
|
|
@@ -201,27 +286,37 @@
|
|
|
201
286
|
]
|
|
202
287
|
},
|
|
203
288
|
"Call": {
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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": [
|
|
208
298
|
{
|
|
209
|
-
"fn": "
|
|
299
|
+
"fn": "mangleName",
|
|
210
300
|
"args": [
|
|
211
301
|
{
|
|
212
|
-
"
|
|
302
|
+
"fn": "ident",
|
|
303
|
+
"args": [
|
|
304
|
+
{
|
|
305
|
+
"get": "node.mangledCallee"
|
|
306
|
+
}
|
|
307
|
+
]
|
|
213
308
|
}
|
|
214
309
|
]
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"case": {
|
|
313
|
+
"when": [[ { "eq": ["node.isRef", "true"] }, "" ]],
|
|
314
|
+
"else": { "tmpl": [ "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
315
|
+
}
|
|
215
316
|
}
|
|
216
317
|
]
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
{
|
|
220
|
-
"map": "node.args",
|
|
221
|
-
"sep": ", "
|
|
222
|
-
},
|
|
223
|
-
")"
|
|
224
|
-
]
|
|
318
|
+
}
|
|
319
|
+
}
|
|
225
320
|
},
|
|
226
321
|
"Member": {
|
|
227
322
|
"case": {
|
|
@@ -295,7 +390,8 @@
|
|
|
295
390
|
"get": "node.field"
|
|
296
391
|
}
|
|
297
392
|
]
|
|
298
|
-
}
|
|
393
|
+
},
|
|
394
|
+
{ "case": { "when": [ [ { "and": [ { "eq": [ "node.isProperty", "true" ] }, { "has": "node.staticType" } ] }, "()" ] ] } }
|
|
299
395
|
]
|
|
300
396
|
}
|
|
301
397
|
}
|
|
@@ -387,7 +483,8 @@
|
|
|
387
483
|
"tmpl": [
|
|
388
484
|
"(",
|
|
389
485
|
{
|
|
390
|
-
"
|
|
486
|
+
"emitChild": "node.then",
|
|
487
|
+
"side": "operand"
|
|
391
488
|
},
|
|
392
489
|
" if ",
|
|
393
490
|
{
|
|
@@ -733,7 +830,7 @@
|
|
|
733
830
|
[
|
|
734
831
|
{
|
|
735
832
|
"eq": [
|
|
736
|
-
"item.
|
|
833
|
+
"item.typeIsRefCollection",
|
|
737
834
|
"true"
|
|
738
835
|
]
|
|
739
836
|
},
|
|
@@ -889,7 +986,7 @@
|
|
|
889
986
|
},
|
|
890
987
|
{
|
|
891
988
|
"tmpl": [
|
|
892
|
-
" and isinstance(__e, ",
|
|
989
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " and builtins.isinstance(__e, ",
|
|
893
990
|
{
|
|
894
991
|
"type": "item.type"
|
|
895
992
|
},
|
|
@@ -1138,7 +1235,7 @@
|
|
|
1138
1235
|
}
|
|
1139
1236
|
]
|
|
1140
1237
|
},
|
|
1141
|
-
" in range(",
|
|
1238
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " in builtins.range(",
|
|
1142
1239
|
{
|
|
1143
1240
|
"emit": "stmt.rangeStart"
|
|
1144
1241
|
},
|
|
@@ -1251,6 +1348,15 @@
|
|
|
1251
1348
|
},
|
|
1252
1349
|
"Program": {
|
|
1253
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
|
+
},
|
|
1254
1360
|
{
|
|
1255
1361
|
"case": {
|
|
1256
1362
|
"when": [
|
|
@@ -1315,10 +1421,15 @@
|
|
|
1315
1421
|
},
|
|
1316
1422
|
" import ",
|
|
1317
1423
|
{
|
|
1318
|
-
"
|
|
1424
|
+
"fn": "mangle",
|
|
1425
|
+
"args": [ { "get": "item.names" } ]
|
|
1319
1426
|
}
|
|
1320
1427
|
]
|
|
1321
1428
|
}
|
|
1429
|
+
],
|
|
1430
|
+
[
|
|
1431
|
+
{ "not": { "eq": ["item.allNames", ""] } },
|
|
1432
|
+
{ "tmpl": ["from ", { "get": "item.path" }, " import *"] }
|
|
1322
1433
|
]
|
|
1323
1434
|
],
|
|
1324
1435
|
"else": {
|
|
@@ -1338,84 +1449,65 @@
|
|
|
1338
1449
|
"when": [
|
|
1339
1450
|
[
|
|
1340
1451
|
{
|
|
1341
|
-
"
|
|
1342
|
-
"eq": [
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
]
|
|
1346
|
-
}
|
|
1452
|
+
"or": [
|
|
1453
|
+
{ "not": { "eq": [ "module.interfaces.count", "0" ] } },
|
|
1454
|
+
{ "not": { "eq": [ "module.abstractClasses.count", "0" ] } }
|
|
1455
|
+
]
|
|
1347
1456
|
},
|
|
1348
1457
|
{
|
|
1349
|
-
"line": "import abc"
|
|
1458
|
+
"line": "import abc as _PG_abc"
|
|
1350
1459
|
}
|
|
1351
1460
|
]
|
|
1352
1461
|
]
|
|
1353
1462
|
}
|
|
1354
1463
|
},
|
|
1355
1464
|
{
|
|
1356
|
-
"
|
|
1357
|
-
"
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
"rule": "RecordDecl"
|
|
1370
|
-
},
|
|
1371
|
-
{
|
|
1372
|
-
"mapMembers": "module.classes",
|
|
1373
|
-
"rule": "ClassDecl"
|
|
1374
|
-
},
|
|
1375
|
-
{
|
|
1376
|
-
"mapDecl": "module.globals",
|
|
1377
|
-
"each": {
|
|
1378
|
-
"line": {
|
|
1379
|
-
"tmpl": [
|
|
1380
|
-
{
|
|
1381
|
-
"fn": "ident",
|
|
1382
|
-
"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": [
|
|
1383
1478
|
{
|
|
1384
|
-
"
|
|
1385
|
-
|
|
1386
|
-
]
|
|
1387
|
-
},
|
|
1388
|
-
" = ",
|
|
1389
|
-
{
|
|
1390
|
-
"case": {
|
|
1391
|
-
"when": [
|
|
1392
|
-
[
|
|
1393
|
-
{
|
|
1394
|
-
"eq": [
|
|
1395
|
-
"item.hasInit",
|
|
1396
|
-
"true"
|
|
1397
|
-
]
|
|
1398
|
-
},
|
|
1479
|
+
"fn": "ident",
|
|
1480
|
+
"args": [
|
|
1399
1481
|
{
|
|
1400
|
-
"
|
|
1482
|
+
"get": "item.name"
|
|
1401
1483
|
}
|
|
1402
1484
|
]
|
|
1403
|
-
|
|
1404
|
-
"
|
|
1405
|
-
|
|
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
|
+
]
|
|
1406
1506
|
}
|
|
1407
|
-
|
|
1507
|
+
}
|
|
1408
1508
|
}
|
|
1409
1509
|
}
|
|
1410
1510
|
},
|
|
1411
|
-
{
|
|
1412
|
-
"mapMembers": "module.functions",
|
|
1413
|
-
"rule": "FunctionDecl"
|
|
1414
|
-
},
|
|
1415
|
-
{
|
|
1416
|
-
"mapMembers": "module.extensions",
|
|
1417
|
-
"rule": "FunctionDecl"
|
|
1418
|
-
},
|
|
1419
1511
|
{
|
|
1420
1512
|
"case": {
|
|
1421
1513
|
"when": [
|
|
@@ -1439,7 +1531,7 @@
|
|
|
1439
1531
|
{
|
|
1440
1532
|
"line": {
|
|
1441
1533
|
"tmpl": [
|
|
1442
|
-
"
|
|
1534
|
+
"_PG_asyncio.run(",
|
|
1443
1535
|
{
|
|
1444
1536
|
"fn": "mangle",
|
|
1445
1537
|
"args": [
|
|
@@ -1542,7 +1634,8 @@
|
|
|
1542
1634
|
"else": ""
|
|
1543
1635
|
}
|
|
1544
1636
|
},
|
|
1545
|
-
{ "stmts": "stmt.body" }
|
|
1637
|
+
{ "stmts": "stmt.body" },
|
|
1638
|
+
{ "case": { "when": [ [ { "eq": [ "stmt.body.count", "0" ] }, { "line": "pass" } ] ] } }
|
|
1546
1639
|
]
|
|
1547
1640
|
}
|
|
1548
1641
|
},
|
|
@@ -1641,6 +1734,15 @@
|
|
|
1641
1734
|
{
|
|
1642
1735
|
"case": {
|
|
1643
1736
|
"when": [
|
|
1737
|
+
[
|
|
1738
|
+
{
|
|
1739
|
+
"and": [
|
|
1740
|
+
{ "eq": [ "decl.bases.count", "0" ] },
|
|
1741
|
+
{ "eq": [ "decl.isAbstract", "true" ] }
|
|
1742
|
+
]
|
|
1743
|
+
},
|
|
1744
|
+
"(_PG_abc.ABC)"
|
|
1745
|
+
],
|
|
1644
1746
|
[
|
|
1645
1747
|
{
|
|
1646
1748
|
"eq": [
|
|
@@ -1661,6 +1763,7 @@
|
|
|
1661
1763
|
"type": "item"
|
|
1662
1764
|
}
|
|
1663
1765
|
},
|
|
1766
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, ", _PG_abc.ABC" ] ] } },
|
|
1664
1767
|
")"
|
|
1665
1768
|
]
|
|
1666
1769
|
}
|
|
@@ -1709,7 +1812,7 @@
|
|
|
1709
1812
|
}
|
|
1710
1813
|
}
|
|
1711
1814
|
},
|
|
1712
|
-
"
|
|
1815
|
+
"_PG_abc.ABC)"
|
|
1713
1816
|
]
|
|
1714
1817
|
},
|
|
1715
1818
|
"body": [
|
|
@@ -1718,7 +1821,7 @@
|
|
|
1718
1821
|
"each": {
|
|
1719
1822
|
"seq": [
|
|
1720
1823
|
{
|
|
1721
|
-
"line": "@
|
|
1824
|
+
"line": "@_PG_abc.abstractmethod"
|
|
1722
1825
|
},
|
|
1723
1826
|
{
|
|
1724
1827
|
"line": {
|
|
@@ -1756,6 +1859,8 @@
|
|
|
1756
1859
|
}
|
|
1757
1860
|
},
|
|
1758
1861
|
"ClassDecl": {
|
|
1862
|
+
"seq": [
|
|
1863
|
+
{
|
|
1759
1864
|
"block": {
|
|
1760
1865
|
"head": {
|
|
1761
1866
|
"call": "pyClassHead"
|
|
@@ -1764,6 +1869,11 @@
|
|
|
1764
1869
|
{
|
|
1765
1870
|
"mapDecl": "decl.staticInitFields",
|
|
1766
1871
|
"each": {
|
|
1872
|
+
"case": {
|
|
1873
|
+
"when": [
|
|
1874
|
+
[
|
|
1875
|
+
{ "eq": ["item.initIsLiteral", "true"] },
|
|
1876
|
+
{
|
|
1767
1877
|
"line": {
|
|
1768
1878
|
"tmpl": [
|
|
1769
1879
|
{
|
|
@@ -1779,6 +1889,10 @@
|
|
|
1779
1889
|
"emit": "item.init"
|
|
1780
1890
|
}
|
|
1781
1891
|
]
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
]
|
|
1895
|
+
]
|
|
1782
1896
|
}
|
|
1783
1897
|
}
|
|
1784
1898
|
},
|
|
@@ -1819,7 +1933,7 @@
|
|
|
1819
1933
|
[
|
|
1820
1934
|
{
|
|
1821
1935
|
"eq": [
|
|
1822
|
-
"decl.
|
|
1936
|
+
"decl.baseHasInit",
|
|
1823
1937
|
"true"
|
|
1824
1938
|
]
|
|
1825
1939
|
},
|
|
@@ -1875,7 +1989,7 @@
|
|
|
1875
1989
|
"and": [
|
|
1876
1990
|
{
|
|
1877
1991
|
"eq": [
|
|
1878
|
-
"decl.
|
|
1992
|
+
"decl.baseHasInit",
|
|
1879
1993
|
"false"
|
|
1880
1994
|
]
|
|
1881
1995
|
},
|
|
@@ -1919,7 +2033,7 @@
|
|
|
1919
2033
|
"and": [
|
|
1920
2034
|
{
|
|
1921
2035
|
"eq": [
|
|
1922
|
-
"decl.
|
|
2036
|
+
"decl.literalStaticInitCount",
|
|
1923
2037
|
"0"
|
|
1924
2038
|
]
|
|
1925
2039
|
},
|
|
@@ -1946,6 +2060,27 @@
|
|
|
1946
2060
|
}
|
|
1947
2061
|
]
|
|
1948
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
|
+
]
|
|
1949
2084
|
},
|
|
1950
2085
|
"pyParam": {
|
|
1951
2086
|
"tmpl": [
|
|
@@ -2146,6 +2281,15 @@
|
|
|
2146
2281
|
]
|
|
2147
2282
|
},
|
|
2148
2283
|
"__rshift__"
|
|
2284
|
+
],
|
|
2285
|
+
[
|
|
2286
|
+
{
|
|
2287
|
+
"eq": [
|
|
2288
|
+
"decl.opSymbol",
|
|
2289
|
+
"hash"
|
|
2290
|
+
]
|
|
2291
|
+
},
|
|
2292
|
+
"__hash__"
|
|
2149
2293
|
]
|
|
2150
2294
|
],
|
|
2151
2295
|
"else": {
|
|
@@ -2254,15 +2398,16 @@
|
|
|
2254
2398
|
"case": {
|
|
2255
2399
|
"when": [
|
|
2256
2400
|
[
|
|
2257
|
-
{
|
|
2258
|
-
|
|
2259
|
-
"
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
"
|
|
2265
|
-
}
|
|
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" ] } }
|
|
2266
2411
|
]
|
|
2267
2412
|
]
|
|
2268
2413
|
}
|
|
@@ -2277,13 +2422,12 @@
|
|
|
2277
2422
|
"true"
|
|
2278
2423
|
]
|
|
2279
2424
|
},
|
|
2280
|
-
{
|
|
2281
|
-
"line": "@staticmethod"
|
|
2282
|
-
}
|
|
2425
|
+
{ "line": { "tmpl": [ { "fn": "require", "args": ["pyBuiltins"] }, "@builtins.staticmethod" ] } }
|
|
2283
2426
|
]
|
|
2284
2427
|
]
|
|
2285
2428
|
}
|
|
2286
2429
|
},
|
|
2430
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, { "line": "@_PG_abc.abstractmethod" } ] ] } },
|
|
2287
2431
|
{
|
|
2288
2432
|
"case": {
|
|
2289
2433
|
"when": [
|
|
@@ -2413,8 +2557,9 @@
|
|
|
2413
2557
|
"tmpl": [
|
|
2414
2558
|
"{\"tag\": ",
|
|
2415
2559
|
{
|
|
2416
|
-
"fn": "
|
|
2560
|
+
"fn": "quoted",
|
|
2417
2561
|
"args": [
|
|
2562
|
+
"string",
|
|
2418
2563
|
{
|
|
2419
2564
|
"get": "node.caseName"
|
|
2420
2565
|
}
|
|
@@ -2427,8 +2572,9 @@
|
|
|
2427
2572
|
"tmpl": [
|
|
2428
2573
|
", ",
|
|
2429
2574
|
{
|
|
2430
|
-
"fn": "
|
|
2575
|
+
"fn": "quoted",
|
|
2431
2576
|
"args": [
|
|
2577
|
+
"string",
|
|
2432
2578
|
{
|
|
2433
2579
|
"get": "item.name"
|
|
2434
2580
|
}
|
|
@@ -2446,13 +2592,52 @@
|
|
|
2446
2592
|
},
|
|
2447
2593
|
"IsTest": {
|
|
2448
2594
|
"tmpl": [
|
|
2449
|
-
"isinstance(",
|
|
2595
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.isinstance(",
|
|
2450
2596
|
{ "emit": "node.operand" },
|
|
2451
2597
|
", ",
|
|
2452
2598
|
{ "type": "node.testType" },
|
|
2453
2599
|
")"
|
|
2454
2600
|
]
|
|
2455
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
|
+
},
|
|
2456
2641
|
"AsCast": {
|
|
2457
2642
|
"case": {
|
|
2458
2643
|
"when": [
|
|
@@ -2462,7 +2647,7 @@
|
|
|
2462
2647
|
"tmpl": [
|
|
2463
2648
|
"(",
|
|
2464
2649
|
{ "emit": "node.operand" },
|
|
2465
|
-
" if isinstance(",
|
|
2650
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " if builtins.isinstance(",
|
|
2466
2651
|
{ "emit": "node.operand" },
|
|
2467
2652
|
", ",
|
|
2468
2653
|
{ "type": "node.castType" },
|
|
@@ -2475,7 +2660,7 @@
|
|
|
2475
2660
|
"tmpl": [
|
|
2476
2661
|
"(",
|
|
2477
2662
|
{ "get": "node.tempName" },
|
|
2478
|
-
" if isinstance((",
|
|
2663
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, " if builtins.isinstance((",
|
|
2479
2664
|
{ "get": "node.tempName" },
|
|
2480
2665
|
" := ",
|
|
2481
2666
|
{ "emit": "node.operand" },
|
|
@@ -2595,7 +2780,7 @@
|
|
|
2595
2780
|
},
|
|
2596
2781
|
{
|
|
2597
2782
|
"tmpl": [
|
|
2598
|
-
"float(",
|
|
2783
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.float(",
|
|
2599
2784
|
{
|
|
2600
2785
|
"emit": "node.operand"
|
|
2601
2786
|
},
|
|
@@ -2633,7 +2818,7 @@
|
|
|
2633
2818
|
},
|
|
2634
2819
|
{
|
|
2635
2820
|
"tmpl": [
|
|
2636
|
-
"int(",
|
|
2821
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.int(",
|
|
2637
2822
|
{
|
|
2638
2823
|
"emit": "node.operand"
|
|
2639
2824
|
},
|
|
@@ -2775,8 +2960,9 @@
|
|
|
2775
2960
|
"lits": "node.chunks",
|
|
2776
2961
|
"holes": "node.holes",
|
|
2777
2962
|
"lit": {
|
|
2778
|
-
"fn": "
|
|
2963
|
+
"fn": "quoted",
|
|
2779
2964
|
"args": [
|
|
2965
|
+
"interp",
|
|
2780
2966
|
{
|
|
2781
2967
|
"get": "item"
|
|
2782
2968
|
}
|
|
@@ -2811,14 +2997,7 @@
|
|
|
2811
2997
|
},
|
|
2812
2998
|
{
|
|
2813
2999
|
"tmpl": [
|
|
2814
|
-
{
|
|
2815
|
-
"fn": "ident",
|
|
2816
|
-
"args": [
|
|
2817
|
-
{
|
|
2818
|
-
"get": "node.method"
|
|
2819
|
-
}
|
|
2820
|
-
]
|
|
2821
|
-
},
|
|
3000
|
+
{ "fn": "mangleName", "args": [ { "fn": "ident", "args": [ { "get": "node.freeName" } ] } ] },
|
|
2822
3001
|
"(",
|
|
2823
3002
|
{
|
|
2824
3003
|
"emit": "node.object"
|
|
@@ -3065,7 +3244,8 @@
|
|
|
3065
3244
|
]
|
|
3066
3245
|
],
|
|
3067
3246
|
"else": {
|
|
3068
|
-
"
|
|
3247
|
+
"emitChild": "item.body",
|
|
3248
|
+
"side": "operand"
|
|
3069
3249
|
}
|
|
3070
3250
|
}
|
|
3071
3251
|
},
|
|
@@ -3226,12 +3406,16 @@
|
|
|
3226
3406
|
},
|
|
3227
3407
|
{
|
|
3228
3408
|
"tmpl": [
|
|
3229
|
-
"isinstance(_m, ",
|
|
3409
|
+
{ "fn": "require", "args": ["pyBuiltins"] }, "builtins.isinstance(_m, ",
|
|
3230
3410
|
{ "type": "item.pattern.testType" },
|
|
3231
3411
|
")"
|
|
3232
3412
|
]
|
|
3233
3413
|
}
|
|
3234
3414
|
],
|
|
3415
|
+
[
|
|
3416
|
+
{ "eq": ["item.pattern.isNullLiteral", "true"] },
|
|
3417
|
+
{ "tmpl": ["_m is None"] }
|
|
3418
|
+
],
|
|
3235
3419
|
[
|
|
3236
3420
|
{
|
|
3237
3421
|
"eq": [
|
|
@@ -3279,8 +3463,9 @@
|
|
|
3279
3463
|
"tmpl": [
|
|
3280
3464
|
"_m[\"tag\"] == ",
|
|
3281
3465
|
{
|
|
3282
|
-
"fn": "
|
|
3466
|
+
"fn": "quoted",
|
|
3283
3467
|
"args": [
|
|
3468
|
+
"string",
|
|
3284
3469
|
{
|
|
3285
3470
|
"get": "item.pattern.ctorCase"
|
|
3286
3471
|
}
|
|
@@ -3490,7 +3675,8 @@
|
|
|
3490
3675
|
},
|
|
3491
3676
|
{
|
|
3492
3677
|
"tmpl": [
|
|
3493
|
-
"
|
|
3678
|
+
{ "fn": "require", "args": ["fdiv"] },
|
|
3679
|
+
"_pg_fmod(",
|
|
3494
3680
|
{
|
|
3495
3681
|
"emit": "node.lhs"
|
|
3496
3682
|
},
|
|
@@ -3502,6 +3688,10 @@
|
|
|
3502
3688
|
]
|
|
3503
3689
|
}
|
|
3504
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
|
+
],
|
|
3505
3695
|
[
|
|
3506
3696
|
{
|
|
3507
3697
|
"and": [
|
|
@@ -3747,8 +3937,9 @@
|
|
|
3747
3937
|
}
|
|
3748
3938
|
},
|
|
3749
3939
|
"Char": {
|
|
3750
|
-
"fn": "
|
|
3940
|
+
"fn": "quoted",
|
|
3751
3941
|
"args": [
|
|
3942
|
+
"char",
|
|
3752
3943
|
{
|
|
3753
3944
|
"get": "node.value"
|
|
3754
3945
|
}
|
|
@@ -3759,17 +3950,26 @@
|
|
|
3759
3950
|
"std.collections": {
|
|
3760
3951
|
"List.type": "list",
|
|
3761
3952
|
"List.constructor": "[]",
|
|
3762
|
-
"List.count": "len($this)",
|
|
3953
|
+
"List.count": { "template": "builtins.len($this)", "requires": ["pyBuiltins"] },
|
|
3763
3954
|
"List.add": "$this.append($0)",
|
|
3764
3955
|
"List.clear": "$this.clear()",
|
|
3765
3956
|
"List.removeAll": "$this[:] = [__e for __e in $this if not (($0)(__e))]",
|
|
3766
|
-
"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"] }
|
|
3767
3967
|
},
|
|
3768
3968
|
"std.io": {
|
|
3769
|
-
"print": "
|
|
3969
|
+
"print": { "template": "__import__('builtins').print(_pg_out16(_pg_str(x)))", "requires": ["fstr", "pgOut16"] },
|
|
3770
3970
|
"readText": "__import__('pathlib').Path(path).read_text()",
|
|
3771
3971
|
"writeText": "__import__('pathlib').Path(path).write_text(content)",
|
|
3772
|
-
"appendText": "open(path, 'a').write(content)",
|
|
3972
|
+
"appendText": { "template": "builtins.open(path, 'a').write(content)", "requires": ["pyBuiltins"] },
|
|
3773
3973
|
"fileExists": "__import__('os').path.exists(path)",
|
|
3774
3974
|
"deleteFile": "__import__('os').remove(path)"
|
|
3775
3975
|
},
|
|
@@ -3777,6 +3977,7 @@
|
|
|
3777
3977
|
"Math.PI": "__import__('math').pi",
|
|
3778
3978
|
"Math.E": "__import__('math').e",
|
|
3779
3979
|
"Math.sqrt": "__import__('math').sqrt($0)",
|
|
3980
|
+
"Math.isNaN": "__import__('math').isnan($0)",
|
|
3780
3981
|
"Math.ln": "__import__('math').log($0)",
|
|
3781
3982
|
"Math.log": "__import__('math').log($0)",
|
|
3782
3983
|
"Math.log2": "__import__('math').log2($0)",
|
|
@@ -3796,45 +3997,59 @@
|
|
|
3796
3997
|
"Math.asinh": "__import__('math').asinh($0)",
|
|
3797
3998
|
"Math.acosh": "__import__('math').acosh($0)",
|
|
3798
3999
|
"Math.atanh": "__import__('math').atanh($0)",
|
|
3799
|
-
"Math.trunc": "float(__import__('math').trunc($0))",
|
|
3800
|
-
"Math.floor": "float(__import__('math').floor($0))",
|
|
3801
|
-
"Math.ceil": "float(__import__('math').ceil($0))",
|
|
3802
|
-
"Math.min": "min($0, $1)",
|
|
3803
|
-
"Math.max": "max($0, $1)",
|
|
3804
|
-
"Math.abs": "abs($0)",
|
|
3805
|
-
"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"] },
|
|
3806
4007
|
"Math.clamp": "(lambda x, lo, hi: lo if x < lo else (hi if x > hi else x))($0, $1, $2)",
|
|
3807
|
-
"Math.round": "float(round($0))"
|
|
4008
|
+
"Math.round": { "template": "builtins.float(builtins.round($0))", "requires": ["pyBuiltins"] }
|
|
3808
4009
|
},
|
|
3809
4010
|
"std.strings": {
|
|
3810
|
-
"string.isEmpty": "(len($this) == 0)",
|
|
3811
|
-
"string.len": "
|
|
4011
|
+
"string.isEmpty": { "template": "(builtins.len($this) == 0)", "requires": ["pyBuiltins"] },
|
|
4012
|
+
"string.len": { "template": "_pg_len16($this)", "requires": ["pgU16"] },
|
|
3812
4013
|
"string.toUpper": "$this.upper()",
|
|
3813
4014
|
"string.toLower": "$this.lower()",
|
|
3814
|
-
"string.
|
|
3815
|
-
"string.
|
|
3816
|
-
"string.codePoints": "list($this)",
|
|
3817
|
-
"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"] }
|
|
3818
4030
|
},
|
|
3819
4031
|
"std.core": {
|
|
3820
4032
|
"Error.type": "Exception",
|
|
3821
4033
|
"Error.constructor": "$T($0)",
|
|
3822
|
-
"Error.message": "str($this)",
|
|
4034
|
+
"Error.message": { "template": "builtins.str($this)", "requires": ["pyBuiltins"] },
|
|
3823
4035
|
"Iterable.type": "list",
|
|
3824
4036
|
"Array.type": "list",
|
|
3825
4037
|
"Array.constructor": "[]",
|
|
3826
|
-
"Array.count": "len($this)",
|
|
3827
|
-
"
|
|
3828
|
-
"
|
|
3829
|
-
"
|
|
3830
|
-
"
|
|
3831
|
-
"
|
|
3832
|
-
"
|
|
3833
|
-
"
|
|
3834
|
-
"
|
|
3835
|
-
"
|
|
3836
|
-
"
|
|
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"] }
|
|
3837
4051
|
}
|
|
3838
4052
|
},
|
|
3839
|
-
"fileExtension": ".py"
|
|
4053
|
+
"fileExtension": ".py",
|
|
4054
|
+
"lineComment": "#"
|
|
3840
4055
|
}
|