@mintplayer/polyglot-target-php 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 +452 -154
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintplayer/polyglot-target-php",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
4
4
|
"description": "MintPlayer Polyglot PHP 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,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schema":
|
|
2
|
+
"schema": 2,
|
|
3
3
|
"name": "php",
|
|
4
4
|
"preludePerFile": true,
|
|
5
|
+
"options": {
|
|
6
|
+
"namespace": {
|
|
7
|
+
"default": "",
|
|
8
|
+
"pattern": "^([A-Za-z_][A-Za-z0-9_]*(\\\\[A-Za-z_][A-Za-z0-9_]*)*)?$",
|
|
9
|
+
"scope": "closure"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
5
12
|
"originMapping": {
|
|
6
13
|
"style": "sourceMapV3",
|
|
7
14
|
"sidecarExtension": ".map",
|
|
8
15
|
"footer": "// sourceMappingURL=$f"
|
|
9
16
|
},
|
|
10
17
|
"capabilities": {
|
|
18
|
+
"utf16Strings:index": "emulated",
|
|
11
19
|
"patternMatching": "native",
|
|
12
20
|
"withExpressions": "native",
|
|
13
21
|
"properties": "emulated",
|
|
@@ -39,6 +47,7 @@
|
|
|
39
47
|
},
|
|
40
48
|
"blockStyle": "bracesKnR",
|
|
41
49
|
"stmtEnd": ";",
|
|
50
|
+
"operandSnapshot": "(${tmp} = {0})",
|
|
42
51
|
"throwKeyword": "throw",
|
|
43
52
|
"rethrow": "throw $__e;",
|
|
44
53
|
"memberOp": "->",
|
|
@@ -46,6 +55,49 @@
|
|
|
46
55
|
"trueLit": "true",
|
|
47
56
|
"falseLit": "false",
|
|
48
57
|
"nullLit": "null",
|
|
58
|
+
"nativeCoalesceAssign": true,
|
|
59
|
+
"assignmentOrder": "valueFirst",
|
|
60
|
+
"literals": {
|
|
61
|
+
"string": {
|
|
62
|
+
"quote": "\"",
|
|
63
|
+
"map": {
|
|
64
|
+
"\\": "\\\\",
|
|
65
|
+
"\"": "\\\"",
|
|
66
|
+
"\n": "\\n",
|
|
67
|
+
"\t": "\\t",
|
|
68
|
+
"\r": "\\r",
|
|
69
|
+
"$": "\\$"
|
|
70
|
+
},
|
|
71
|
+
"codepoint": "\\u{$H}",
|
|
72
|
+
"astral": "\\u{$H}"
|
|
73
|
+
},
|
|
74
|
+
"interp": {
|
|
75
|
+
"quote": "\"",
|
|
76
|
+
"map": {
|
|
77
|
+
"\\": "\\\\",
|
|
78
|
+
"\"": "\\\"",
|
|
79
|
+
"\n": "\\n",
|
|
80
|
+
"\t": "\\t",
|
|
81
|
+
"\r": "\\r",
|
|
82
|
+
"$": "\\$"
|
|
83
|
+
},
|
|
84
|
+
"codepoint": "\\u{$H}",
|
|
85
|
+
"astral": "\\u{$H}"
|
|
86
|
+
},
|
|
87
|
+
"char": {
|
|
88
|
+
"quote": "\"",
|
|
89
|
+
"map": {
|
|
90
|
+
"\\": "\\\\",
|
|
91
|
+
"\"": "\\\"",
|
|
92
|
+
"\n": "\\n",
|
|
93
|
+
"\t": "\\t",
|
|
94
|
+
"\r": "\\r",
|
|
95
|
+
"$": "\\$"
|
|
96
|
+
},
|
|
97
|
+
"codepoint": "\\u{$H}",
|
|
98
|
+
"astral": "\\u{$H}"
|
|
99
|
+
}
|
|
100
|
+
},
|
|
49
101
|
"wrapInt": {
|
|
50
102
|
"u8": "(($x) & 0xff)",
|
|
51
103
|
"u16": "(($x) & 0xffff)",
|
|
@@ -55,14 +107,21 @@
|
|
|
55
107
|
"i32": "(((($x) & 0xffffffff) ^ 0x80000000) - 0x80000000)"
|
|
56
108
|
},
|
|
57
109
|
"wrapAtom": {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
110
|
+
"recvPrimary": [
|
|
111
|
+
"var",
|
|
112
|
+
"this",
|
|
113
|
+
"call",
|
|
114
|
+
"methodCall",
|
|
115
|
+
"member",
|
|
116
|
+
"index",
|
|
117
|
+
"str",
|
|
118
|
+
"char",
|
|
119
|
+
"bool",
|
|
120
|
+
"null",
|
|
121
|
+
"extern",
|
|
122
|
+
"nullAssert",
|
|
123
|
+
"tuple",
|
|
124
|
+
"makeCase"
|
|
66
125
|
]
|
|
67
126
|
},
|
|
68
127
|
"generics": {
|
|
@@ -70,7 +129,8 @@
|
|
|
70
129
|
"boundsIntro": "",
|
|
71
130
|
"boundsSep": "",
|
|
72
131
|
"erase": [
|
|
73
|
-
"INumber"
|
|
132
|
+
"INumber",
|
|
133
|
+
"IMapKey"
|
|
74
134
|
]
|
|
75
135
|
},
|
|
76
136
|
"tables": {
|
|
@@ -149,15 +209,36 @@
|
|
|
149
209
|
"var",
|
|
150
210
|
"while",
|
|
151
211
|
"xor",
|
|
152
|
-
"yield"
|
|
212
|
+
"yield",
|
|
213
|
+
"self",
|
|
214
|
+
"parent",
|
|
215
|
+
"int",
|
|
216
|
+
"float",
|
|
217
|
+
"bool",
|
|
218
|
+
"string",
|
|
219
|
+
"true",
|
|
220
|
+
"false",
|
|
221
|
+
"null",
|
|
222
|
+
"void",
|
|
223
|
+
"iterable",
|
|
224
|
+
"object",
|
|
225
|
+
"mixed",
|
|
226
|
+
"never",
|
|
227
|
+
"die",
|
|
228
|
+
"exit",
|
|
229
|
+
"eval",
|
|
230
|
+
"require_once",
|
|
231
|
+
"include_once",
|
|
232
|
+
"__halt_compiler"
|
|
153
233
|
],
|
|
234
|
+
"caseInsensitive": true,
|
|
154
235
|
"escape": {
|
|
155
236
|
"strategy": "suffix",
|
|
156
237
|
"with": "_"
|
|
157
238
|
},
|
|
158
239
|
"mangle": {
|
|
159
240
|
"replace": "$",
|
|
160
|
-
"with": "
|
|
241
|
+
"with": "__"
|
|
161
242
|
},
|
|
162
243
|
"reserved": [
|
|
163
244
|
"__e",
|
|
@@ -166,10 +247,29 @@
|
|
|
166
247
|
"__opt*",
|
|
167
248
|
"__w*"
|
|
168
249
|
],
|
|
250
|
+
"classBuiltins": [
|
|
251
|
+
"directory", "error", "generator", "closure", "exception", "errorexception", "typeerror", "valueerror",
|
|
252
|
+
"arithmeticerror", "divisionbyzeroerror", "argumentcounterror", "assertionerror", "compileerror", "parseerror",
|
|
253
|
+
"unhandledmatcherror", "throwable", "traversable", "iterator", "iteratoraggregate", "arrayaccess", "countable",
|
|
254
|
+
"stringable", "serializable", "jsonserializable", "arrayobject", "arrayiterator", "stdclass", "datetime",
|
|
255
|
+
"datetimeimmutable", "datetimeinterface", "datetimezone", "dateinterval", "dateperiod", "weakmap",
|
|
256
|
+
"weakreference", "fiber", "attribute", "unitenum", "backedenum", "splstack", "splqueue", "splobjectstorage",
|
|
257
|
+
"spldoublylinkedlist", "splfixedarray", "splheap", "splminheap", "splmaxheap", "splpriorityqueue",
|
|
258
|
+
"splsubject", "splobserver", "emptyiterator", "internaliterator", "runtimeexception", "logicexception",
|
|
259
|
+
"invalidargumentexception", "domainexception", "lengthexception", "outofrangeexception",
|
|
260
|
+
"outofboundsexception", "overflowexception", "rangeexception", "underflowexception",
|
|
261
|
+
"unexpectedvalueexception", "badfunctioncallexception", "badmethodcallexception"
|
|
262
|
+
],
|
|
169
263
|
"functionBuiltins": {
|
|
170
264
|
"suffix": "_pg",
|
|
171
265
|
"names": [
|
|
172
|
-
"abs", "
|
|
266
|
+
"abs", "acos", "acosh", "array_key_exists", "array_key_first", "get_class", "is_object", "method_exists", "asin", "asinh", "atan", "atan2", "atanh",
|
|
267
|
+
"chr", "cosh", "fdiv", "file_exists", "file_get_contents", "file_put_contents", "fmod", "function_exists",
|
|
268
|
+
"iconv", "ini_set", "intdiv", "is_bool", "is_float", "is_infinite", "is_int", "is_nan", "is_string", "log10",
|
|
269
|
+
"ltrim", "pack", "preg_match", "preg_replace", "preg_replace_callback", "preg_split", "rtrim", "sinh",
|
|
270
|
+
"str_contains", "str_ends_with", "str_repeat", "str_replace", "str_starts_with", "strcmp", "strpos",
|
|
271
|
+
"strtolower", "strtoupper", "strtr", "tanh", "unlink", "unpack", "var_export",
|
|
272
|
+
"array_filter", "array_keys", "array_map", "array_merge",
|
|
173
273
|
"array_pop", "array_push", "array_reverse", "array_shift", "array_slice",
|
|
174
274
|
"array_splice", "array_values", "assert", "ceil", "compact", "cos", "count",
|
|
175
275
|
"current", "date", "die", "each", "end", "eval", "exit",
|
|
@@ -182,7 +282,15 @@
|
|
|
182
282
|
]
|
|
183
283
|
}
|
|
184
284
|
},
|
|
185
|
-
"preludes": {
|
|
285
|
+
"preludes": {
|
|
286
|
+
"pgUeq": "if (!function_exists(__NAMESPACE__.'\\\\__pg_ueq')) {\n // a union value (a tagged array) compared as C# compares its generated case records (review r5): a record\n // payload by its equals(), a nested union recursively, anything else (a scalar, a class instance, a list) by ===\n function __pg_ueq($a, $b) {\n if (is_array($a)) {\n if (!is_array($b) || count($a) !== count($b)) {\n return false;\n }\n foreach ($a as $k => $v) {\n if (!array_key_exists($k, $b) || !__pg_ueq($v, $b[$k])) {\n return false;\n }\n }\n return true;\n }\n if (is_object($a) && is_object($b) && get_class($a) === get_class($b) && method_exists($a, 'equals')) {\n return $a->equals($b);\n }\n return $a === $b;\n }\n}\n",
|
|
287
|
+
"pgU64": "if (!function_exists(__NAMESPACE__.'\\\\__pg_u64parse')) {\n // a u64 above PHP_INT_MAX has no PHP int: refuse it loudly instead of clamping (SPEC 3.C PHP caveat)\n function __pg_u64parse($s) {\n $d = ltrim(ltrim($s, '+'), '0');\n if (strlen($d) > 19 || (strlen($d) === 19 && strcmp($d, '9223372036854775807') > 0)) {\n throw new \\Error(\"u64.parse: '\" . $s . \"' exceeds PHP's 63-bit integer range\");\n }\n return intval($s);\n }\n}\n",
|
|
288
|
+
"pgU16": "if (!function_exists(__NAMESPACE__.'\\\\__pg_u16')) {\n // UTF-16 code-unit indexing over PHP's UTF-8 strings (P40 B3, D15: needs ext-iconv). An ASCII string is\n // its own UTF-16 index space (fast path); any other is indexed through a cached UTF-16LE copy.\n function __pg_u16($s) {\n // null when ASCII, else the UTF-16LE copy. A short string is just recomputed; a long one is cached\n // (the last one, plus a small LRU), so indexing a long string in a loop is O(1) per call.\n static $ks = null, $kv = null, $lru = [];\n if ($ks === $s) {\n return $kv;\n }\n if (strlen($s) < 256) {\n return preg_match('/[\\x80-\\xFF]/', $s) ? __pg_u16le($s) : null;\n }\n if (array_key_exists($s, $lru)) {\n $v = $lru[$s];\n unset($lru[$s]);\n } else {\n $v = preg_match('/[\\x80-\\xFF]/', $s) ? __pg_u16le($s) : null;\n if (count($lru) >= 8) {\n unset($lru[array_key_first($lru)]);\n }\n }\n $lru[$s] = $v;\n $ks = $s;\n $kv = $v;\n return $v;\n }\n function __pg_u16le($s) {\n if (!function_exists('iconv')) {\n throw new \\Error('Polyglot: the PHP target needs the iconv extension (ext-iconv) for non-ASCII strings');\n }\n $r = @iconv('UTF-8', 'UTF-16LE', $s);\n if ($r !== false) {\n return $r;\n }\n // not valid UTF-8: a lone surrogate a substring split off (held as WTF-8) \u2014 decode by hand\n $out = '';\n $n = strlen($s);\n for ($i = 0; $i < $n;) {\n $b = ord($s[$i]);\n if ($b < 0x80) {\n $c = $b;\n $i += 1;\n } elseif ($b < 0xE0) {\n $c = (($b & 0x1F) << 6) | (ord($s[$i + 1]) & 0x3F);\n $i += 2;\n } elseif ($b < 0xF0) {\n $c = (($b & 0x0F) << 12) | ((ord($s[$i + 1]) & 0x3F) << 6) | (ord($s[$i + 2]) & 0x3F);\n $i += 3;\n } else {\n $c = (($b & 0x07) << 18) | ((ord($s[$i + 1]) & 0x3F) << 12) | ((ord($s[$i + 2]) & 0x3F) << 6) | (ord($s[$i + 3]) & 0x3F);\n $i += 4;\n }\n if ($c >= 0x10000) {\n $c -= 0x10000;\n $out .= pack('v2', 0xD800 + ($c >> 10), 0xDC00 + ($c & 0x3FF));\n } else {\n $out .= pack('v', $c);\n }\n }\n return $out;\n }\n function __pg_u16_unit8($c) {\n if ($c < 0x80) {\n return chr($c);\n }\n if ($c < 0x800) {\n return chr(0xC0 | ($c >> 6)) . chr(0x80 | ($c & 0x3F));\n }\n return chr(0xE0 | ($c >> 12)) . chr(0x80 | (($c >> 6) & 0x3F)) . chr(0x80 | ($c & 0x3F));\n }\n function __pg_u16_to8($u) {\n $r = @iconv('UTF-16LE', 'UTF-8', $u);\n if ($r !== false) {\n return $r;\n }\n $out = '';\n $n = strlen($u);\n for ($i = 0; $i < $n; $i += 2) {\n $c = ord($u[$i]) | (ord($u[$i + 1]) << 8);\n if ($c >= 0xD800 && $c <= 0xDBFF && $i + 3 < $n) {\n $d = ord($u[$i + 2]) | (ord($u[$i + 3]) << 8);\n if ($d >= 0xDC00 && $d <= 0xDFFF) {\n $c = 0x10000 + (($c - 0xD800) << 10) + ($d - 0xDC00);\n $out .= chr(0xF0 | ($c >> 18)) . chr(0x80 | (($c >> 12) & 0x3F)) . chr(0x80 | (($c >> 6) & 0x3F)) . chr(0x80 | ($c & 0x3F));\n $i += 2;\n continue;\n }\n }\n $out .= __pg_u16_unit8($c);\n }\n return $out;\n }\n function __pg_len16($s) {\n $v = __pg_u16($s);\n return $v === null ? strlen($s) : strlen($v) >> 1;\n }\n function __pg_u16_char($s, $i) {\n $v = __pg_u16($s);\n return $v === null ? $s[$i] : __pg_u16_unit8(ord($v[2 * $i]) | (ord($v[2 * $i + 1]) << 8));\n }\n function __pg_u16_cp($s, $i) {\n $v = __pg_u16($s);\n if ($v === null) {\n return ord($s[$i]);\n }\n $c = ord($v[2 * $i]) | (ord($v[2 * $i + 1]) << 8);\n if ($c >= 0xD800 && $c <= 0xDBFF && 2 * $i + 3 < strlen($v)) {\n $d = ord($v[2 * $i + 2]) | (ord($v[2 * $i + 3]) << 8);\n if ($d >= 0xDC00 && $d <= 0xDFFF) {\n return 0x10000 + (($c - 0xD800) << 10) + ($d - 0xDC00);\n }\n }\n return $c;\n }\n function __pg_u16_sub($s, $a, $b) {\n $v = __pg_u16($s);\n return $v === null ? substr($s, $a, $b - $a) : __pg_u16_to8(substr($v, 2 * $a, 2 * ($b - $a)));\n }\n function __pg_u16_find($s, $n, $f) {\n static $kn = null, $kascii = true, $kv = '';\n if ($kn !== $n) {\n $kascii = !preg_match('/[\\x80-\\xFF]/', $n);\n $kv = null;\n $kn = $n;\n }\n $v = __pg_u16($s);\n if ($v === null) {\n if (!$kascii) {\n return -1;\n }\n $p = strpos($s, $n, $f);\n return $p === false ? -1 : $p;\n }\n if ($kv === null) {\n $kv = __pg_u16le($n); // the needle is reconverted only when it changes\n }\n $p = 2 * $f;\n while (($p = strpos($v, $kv, $p)) !== false) {\n if (($p & 1) === 0) {\n return $p >> 1;\n }\n $p++;\n }\n return -1;\n }\n function __pg_cmp16($a, $b) {\n if (preg_match('/[\\x80-\\xFF]/', $a) || preg_match('/[\\x80-\\xFF]/', $b)) {\n // UTF-16BE bytes order exactly as UTF-16 code units do (UTF-8 bytes order as code points)\n $a = $a === '' ? '' : pack('n*', ...unpack('v*', __pg_u16le($a)));\n $b = $b === '' ? '' : pack('n*', ...unpack('v*', __pg_u16le($b)));\n }\n $r = strcmp($a, $b);\n return $r < 0 ? -1 : ($r > 0 ? 1 : 0);\n }\n function __pg_u16_lone(...$xs) {\n // a lone surrogate (held as WTF-8, ED A0-BF ..) only matches like C#/TS in the UTF-16 view; without\n // one, the UTF-8 byte answer is the UTF-16 answer\n foreach ($xs as $x) {\n if (preg_match('/\\xED[\\xA0-\\xBF]/', $x)) {\n return true;\n }\n }\n return false;\n }\n function __pg_u16_has($s, $n) {\n return __pg_u16_lone($s, $n) ? __pg_u16_find($s, $n, 0) !== -1 : str_contains($s, $n);\n }\n function __pg_u16_starts($s, $p) {\n return __pg_u16_lone($s, $p) ? str_starts_with(__pg_u16le($s), __pg_u16le($p)) : str_starts_with($s, $p);\n }\n function __pg_u16_ends($s, $p) {\n return __pg_u16_lone($s, $p) ? str_ends_with(__pg_u16le($s), __pg_u16le($p)) : str_ends_with($s, $p);\n }\n function __pg_u16_pieces($s, $sep) {\n // the UTF-16LE pieces of $s around $sep, matching only at unit-aligned (even) offsets\n $v = __pg_u16le($s);\n $k = __pg_u16le($sep);\n $kl = strlen($k);\n $out = [];\n $from = 0;\n $p = 0;\n while (($p = strpos($v, $k, $p)) !== false) {\n if (($p & 1) === 0) {\n $out[] = substr($v, $from, $p - $from);\n $p += $kl;\n $from = $p;\n } else {\n $p++;\n }\n }\n $out[] = substr($v, $from);\n return $out;\n }\n function __pg_u16_replace($s, $n, $r) {\n if (!__pg_u16_lone($s, $n, $r)) {\n return str_replace($n, $r, $s);\n }\n return __pg_u16_to8(implode(__pg_u16le($r), __pg_u16_pieces($s, $n)));\n }\n function __pg_u16_split($s, $sep) {\n if (!__pg_u16_lone($s, $sep)) {\n return explode($sep, $s);\n }\n return array_map(fn($u) => __pg_u16_to8($u),__pg_u16_pieces($s, $sep));\n }\n}\n",
|
|
289
|
+
"pgChr8": "if (!function_exists(__NAMESPACE__.'\\\\__pg_chr8')) {\n // a Unicode scalar value -> UTF-8 (string.fromCodePoint; no mbstring needed, S17)\n function __pg_chr8($c) {\n if ($c < 0x80) {\n return chr($c);\n }\n if ($c < 0x800) {\n return chr(0xC0 | ($c >> 6)) . chr(0x80 | ($c & 0x3F));\n }\n if ($c < 0x10000) {\n return chr(0xE0 | ($c >> 12)) . chr(0x80 | (($c >> 6) & 0x3F)) . chr(0x80 | ($c & 0x3F));\n }\n return chr(0xF0 | ($c >> 18)) . chr(0x80 | (($c >> 12) & 0x3F)) . chr(0x80 | (($c >> 6) & 0x3F)) . chr(0x80 | ($c & 0x3F));\n }\n}\n",
|
|
290
|
+
"pgMap": "if (!function_exists(__NAMESPACE__.'\\\\__pg_mk')) {\n // Map<K, V> over \\ArrayObject (P40 B4). A PHP array turns the string key \"10\" into the int 10, so string\n // keys are stored prefixed with \"s\" and stripped again by keys(); integer keys are stored as they are.\n function __pg_mk($k) {\n return is_int($k) ? $k : \"s\" . $k;\n }\n function __pg_mget($m, $k) {\n $k = __pg_mk($k);\n return $m->offsetExists($k) ? $m[$k] : null;\n }\n function __pg_mdel($m, $k) {\n $k = __pg_mk($k);\n if (!$m->offsetExists($k)) {\n return false;\n }\n $m->offsetUnset($k);\n return true;\n }\n function __pg_mkeys($m) {\n $r = [];\n foreach ($m as $k => $v) {\n $r[] = is_int($k) ? $k : substr($k, 1);\n }\n return new \\ArrayObject($r);\n }\n}\n",
|
|
291
|
+
"pgNn": "if (!function_exists(__NAMESPACE__.'\\\\__pg_nn')) {\n function __pg_nn($v, $at) {\n if ($v === null) {\n throw new \\UnexpectedValueException(\"null-assert failed (\" . $at . \")\");\n }\n return $v;\n }\n}\n",
|
|
292
|
+
"pgStr": "if (!function_exists(__NAMESPACE__.'\\\\__pg_str')) {\n function __pg_str($x) {\n if ($x === null) {\n return \"null\";\n }\n if (is_bool($x)) {\n return $x ? \"true\" : \"false\";\n }\n if (is_string($x)) {\n if (preg_match('//u', $x)) {\n return $x;\n }\n $x = preg_replace_callback('/\\xED([\\xA0-\\xAF])([\\x80-\\xBF])\\xED([\\xB0-\\xBF])([\\x80-\\xBF])/', function ($m) {\n $c = 0x10000 + ((((ord($m[1]) & 0x0F) << 6) | (ord($m[2]) & 0x3F)) << 10) + ((((ord($m[3]) & 0x0F) << 6) | (ord($m[4]) & 0x3F)));\n return chr(0xF0 | ($c >> 18)) . chr(0x80 | (($c >> 12) & 0x3F)) . chr(0x80 | (($c >> 6) & 0x3F)) . chr(0x80 | ($c & 0x3F));\n }, $x);\n return preg_replace('/\\xED[\\xA0-\\xBF][\\x80-\\xBF]/', \"\\u{FFFD}\", $x);\n }\n if (!is_float($x)) {\n return (string)$x;\n }\n if (is_nan($x)) {\n return \"NaN\";\n }\n if (is_infinite($x)) {\n return $x > 0 ? \"Infinity\" : \"-Infinity\";\n }\n if ($x == 0.0) {\n return \"0\";\n }\n $old = ini_set('serialize_precision', '-1');\n $s = var_export($x, true);\n if ($old !== false) {\n ini_set('serialize_precision', $old);\n }\n $neg = $s[0] === '-';\n if ($neg) {\n $s = substr($s, 1);\n }\n $p = strpos($s, 'E');\n $m = $p === false ? $s : substr($s, 0, $p);\n $e = $p === false ? 0 : (int)substr($s, $p + 1);\n $dot = strpos($m, '.');\n $i = $dot === false ? $m : substr($m, 0, $dot);\n $f = $dot === false ? '' : substr($m, $dot + 1);\n $d = ltrim($i . $f, '0');\n $n = strlen($i) + $e - (strlen($i) + strlen($f) - strlen($d));\n $d = rtrim($d, '0');\n $k = strlen($d);\n if ($k <= $n && $n <= 21) {\n $r = $d . str_repeat('0', $n - $k);\n } elseif (0 < $n && $n <= 21) {\n $r = substr($d, 0, $n) . '.' . substr($d, $n);\n } elseif (-6 < $n && $n <= 0) {\n $r = '0.' . str_repeat('0', -$n) . $d;\n } else {\n $r = $d[0] . ($k > 1 ? '.' . substr($d, 1) : '') . 'e' . ($n >= 1 ? '+' : '-') . abs($n - 1);\n }\n return $neg ? '-' . $r : $r;\n }\n}\n"
|
|
293
|
+
}
|
|
186
294
|
},
|
|
187
295
|
"std": {
|
|
188
296
|
"std.collections": {
|
|
@@ -192,10 +300,19 @@
|
|
|
192
300
|
"List.add": "$this[] = $0",
|
|
193
301
|
"List.clear": "$this->exchangeArray([])",
|
|
194
302
|
"List.removeAll": "$this->exchangeArray(array_values(array_filter($this->getArrayCopy(), fn($__e) => !(($0)($__e)))))",
|
|
195
|
-
"List.removeAt": "$this->exchangeArray((function ($__a, $__i) { array_splice($__a, $__i, 1); return $__a; })($this->getArrayCopy(), $0))"
|
|
303
|
+
"List.removeAt": "$this->exchangeArray((function ($__a, $__i) { array_splice($__a, $__i, 1); return $__a; })($this->getArrayCopy(), $0))",
|
|
304
|
+
"Map.type": "\\ArrayObject",
|
|
305
|
+
"Map.constructor": "new \\ArrayObject([])",
|
|
306
|
+
"Map.count": "count($this)",
|
|
307
|
+
"Map.get": { "template": "__pg_mget($this, $0)", "requires": ["pgMap"] },
|
|
308
|
+
"Map.set": { "template": "$this[__pg_mk($0)] = $1", "requires": ["pgMap"] },
|
|
309
|
+
"Map.has": { "template": "$this->offsetExists(__pg_mk($0))", "requires": ["pgMap"] },
|
|
310
|
+
"Map.remove": { "template": "__pg_mdel($this, $0)", "requires": ["pgMap"] },
|
|
311
|
+
"Map.keys": { "template": "__pg_mkeys($this)", "requires": ["pgMap"] },
|
|
312
|
+
"Map.values": "new \\ArrayObject(array_values($this->getArrayCopy()))"
|
|
196
313
|
},
|
|
197
314
|
"std.io": {
|
|
198
|
-
"print": "echo
|
|
315
|
+
"print": { "template": "echo __pg_str($x), \"\\n\"", "requires": ["pgStr"] },
|
|
199
316
|
"readText": "file_get_contents($path)",
|
|
200
317
|
"writeText": "file_put_contents($path, $content)",
|
|
201
318
|
"appendText": "file_put_contents($path, $content, FILE_APPEND)",
|
|
@@ -204,13 +321,24 @@
|
|
|
204
321
|
},
|
|
205
322
|
"std.strings": {
|
|
206
323
|
"string.isEmpty": "($this === '')",
|
|
207
|
-
"string.len": "
|
|
324
|
+
"string.len": { "template": "__pg_len16($this)", "requires": ["pgU16"] },
|
|
208
325
|
"string.toUpper": "strtoupper($this)",
|
|
209
326
|
"string.toLower": "strtolower($this)",
|
|
210
|
-
"string.
|
|
211
|
-
"string.
|
|
212
|
-
"string.codePoints": "
|
|
213
|
-
"string.
|
|
327
|
+
"string.toUpperAscii": "strtr($this, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')",
|
|
328
|
+
"string.toLowerAscii": "strtr($this, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')",
|
|
329
|
+
"string.codePoints": "preg_split('//u', $this, -1, PREG_SPLIT_NO_EMPTY)",
|
|
330
|
+
"string.startsWith": { "template": "__pg_u16_starts($this, $0)", "requires": ["pgU16"] },
|
|
331
|
+
"string.endsWith": { "template": "__pg_u16_ends($this, $0)", "requires": ["pgU16"] },
|
|
332
|
+
"string.contains": { "template": "__pg_u16_has($this, $0)", "requires": ["pgU16"] },
|
|
333
|
+
"string.trimAscii": "trim($this, \" \\t\\n\\x0B\\x0C\\r\")",
|
|
334
|
+
"compareOrdinal": { "template": "__pg_cmp16($a, $b)", "requires": ["pgU16"] },
|
|
335
|
+
"string.__pgCharAt": { "template": "__pg_u16_char($this, $0)", "requires": ["pgU16"] },
|
|
336
|
+
"string.__pgCodePointAt": { "template": "__pg_u16_cp($this, $0)", "requires": ["pgU16"] },
|
|
337
|
+
"string.__pgSubstring": { "template": "__pg_u16_sub($this, $0, $1)", "requires": ["pgU16"] },
|
|
338
|
+
"string.__pgIndexOf": { "template": "__pg_u16_find($this, $0, $1)", "requires": ["pgU16"] },
|
|
339
|
+
"string.__pgReplaceAll": { "template": "__pg_u16_replace($this, $0, $1)", "requires": ["pgU16"] },
|
|
340
|
+
"string.__pgSplit": { "template": "new \\ArrayObject(__pg_u16_split($this, $0))", "requires": ["pgU16"] },
|
|
341
|
+
"string.__pgFromCodePoint": { "template": "__pg_chr8($0)", "requires": ["pgChr8"] }
|
|
214
342
|
},
|
|
215
343
|
"std.core": {
|
|
216
344
|
"Error.type": "\\Exception",
|
|
@@ -220,21 +348,24 @@
|
|
|
220
348
|
"Array.type": "\\ArrayObject",
|
|
221
349
|
"Array.constructor": "new \\ArrayObject()",
|
|
222
350
|
"Array.count": "count($this)",
|
|
223
|
-
"
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
-
"
|
|
229
|
-
"
|
|
230
|
-
"
|
|
231
|
-
"
|
|
232
|
-
"
|
|
351
|
+
"__pgText.rawLen": "strlen($0)",
|
|
352
|
+
"__pgText.rawCode": "ord($0[$1])",
|
|
353
|
+
"i8.__pgParse": "intval($0)",
|
|
354
|
+
"i16.__pgParse": "intval($0)",
|
|
355
|
+
"i32.__pgParse": "intval($0)",
|
|
356
|
+
"i64.__pgParse": "intval($0)",
|
|
357
|
+
"u8.__pgParse": "intval($0)",
|
|
358
|
+
"u16.__pgParse": "intval($0)",
|
|
359
|
+
"u32.__pgParse": "intval($0)",
|
|
360
|
+
"u64.__pgParse": { "template": "__pg_u64parse($0)", "requires": ["pgU64"] },
|
|
361
|
+
"f32.__pgParse": "unpack('g', pack('g', floatval($0)))[1]",
|
|
362
|
+
"f64.__pgParse": "floatval($0)"
|
|
233
363
|
},
|
|
234
364
|
"std.math": {
|
|
235
365
|
"Math.PI": "M_PI",
|
|
236
366
|
"Math.E": "M_E",
|
|
237
367
|
"Math.sqrt": "sqrt($0)",
|
|
368
|
+
"Math.isNaN": "is_nan($0)",
|
|
238
369
|
"Math.ln": "log($0)",
|
|
239
370
|
"Math.log": "log($0)",
|
|
240
371
|
"Math.log2": "log($0, 2)",
|
|
@@ -270,7 +401,7 @@
|
|
|
270
401
|
"get": "node.text"
|
|
271
402
|
},
|
|
272
403
|
"Float": {
|
|
273
|
-
"get": "node.
|
|
404
|
+
"get": "node.widenedText"
|
|
274
405
|
},
|
|
275
406
|
"Bool": {
|
|
276
407
|
"case": {
|
|
@@ -290,33 +421,45 @@
|
|
|
290
421
|
},
|
|
291
422
|
"Null": "null",
|
|
292
423
|
"Str": {
|
|
293
|
-
"fn": "
|
|
424
|
+
"fn": "quoted",
|
|
294
425
|
"args": [
|
|
426
|
+
"string",
|
|
295
427
|
{
|
|
296
428
|
"get": "node.value"
|
|
297
429
|
}
|
|
298
430
|
]
|
|
299
431
|
},
|
|
300
432
|
"Char": {
|
|
301
|
-
"fn": "
|
|
433
|
+
"fn": "quoted",
|
|
302
434
|
"args": [
|
|
435
|
+
"char",
|
|
303
436
|
{
|
|
304
437
|
"get": "node.value"
|
|
305
438
|
}
|
|
306
439
|
]
|
|
307
440
|
},
|
|
308
441
|
"Var": {
|
|
309
|
-
"
|
|
310
|
-
"
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
442
|
+
"case": {
|
|
443
|
+
"when": [
|
|
444
|
+
[
|
|
445
|
+
{ "eq": ["node.liveModuleRead", "true"] },
|
|
446
|
+
{ "tmpl": ["$GLOBALS['", { "fn": "ident", "args": [ { "get": "node.name" } ] }, "']"] }
|
|
447
|
+
]
|
|
448
|
+
],
|
|
449
|
+
"else": {
|
|
450
|
+
"tmpl": [
|
|
451
|
+
"$",
|
|
314
452
|
{
|
|
315
|
-
"
|
|
453
|
+
"fn": "ident",
|
|
454
|
+
"args": [
|
|
455
|
+
{
|
|
456
|
+
"get": "node.name"
|
|
457
|
+
}
|
|
458
|
+
]
|
|
316
459
|
}
|
|
317
460
|
]
|
|
318
461
|
}
|
|
319
|
-
|
|
462
|
+
}
|
|
320
463
|
},
|
|
321
464
|
"This": "$this",
|
|
322
465
|
"Extern": {
|
|
@@ -327,6 +470,14 @@
|
|
|
327
470
|
{
|
|
328
471
|
"case": {
|
|
329
472
|
"when": [
|
|
473
|
+
[
|
|
474
|
+
{ "eq": ["node.calleeKind", "member"] },
|
|
475
|
+
{ "tmpl": ["(", { "emit": "node.calleeExpr" }, ")"] }
|
|
476
|
+
],
|
|
477
|
+
[
|
|
478
|
+
{ "has": "node.hasCalleeExpr" },
|
|
479
|
+
{ "emitChild": "node.calleeExpr", "side": "recv" }
|
|
480
|
+
],
|
|
330
481
|
[
|
|
331
482
|
{ "eq": ["node.isFree", "true"] },
|
|
332
483
|
{
|
|
@@ -339,7 +490,7 @@
|
|
|
339
490
|
"fn": "identFn",
|
|
340
491
|
"args": [
|
|
341
492
|
{
|
|
342
|
-
"get": "node.
|
|
493
|
+
"get": "node.uniqueCallee"
|
|
343
494
|
}
|
|
344
495
|
]
|
|
345
496
|
}
|
|
@@ -369,12 +520,12 @@
|
|
|
369
520
|
}
|
|
370
521
|
}
|
|
371
522
|
},
|
|
372
|
-
"(",
|
|
373
523
|
{
|
|
374
|
-
"
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
524
|
+
"case": {
|
|
525
|
+
"when": [[ { "eq": ["node.isRef", "true"] }, "(...)" ]],
|
|
526
|
+
"else": { "tmpl": [ "(", { "map": "node.args", "sep": ", " }, ")" ] }
|
|
527
|
+
}
|
|
528
|
+
}
|
|
378
529
|
]
|
|
379
530
|
},
|
|
380
531
|
"Member": {
|
|
@@ -388,10 +539,20 @@
|
|
|
388
539
|
},
|
|
389
540
|
{
|
|
390
541
|
"tmpl": [
|
|
391
|
-
{
|
|
542
|
+
{ "fn": "identType", "args": [ {
|
|
392
543
|
"get": "node.staticType"
|
|
393
|
-
},
|
|
394
|
-
"::"
|
|
544
|
+
} ] },
|
|
545
|
+
"::",
|
|
546
|
+
{ "case": { "when": [ [
|
|
547
|
+
{ "and": [
|
|
548
|
+
{ "eq": ["node.staticField", "true"] },
|
|
549
|
+
{ "not": { "and": [
|
|
550
|
+
{ "eq": ["node.staticFieldMutable", "false"] },
|
|
551
|
+
{ "eq": ["node.staticFieldInitIsLiteral", "true"] }
|
|
552
|
+
] } }
|
|
553
|
+
] },
|
|
554
|
+
"$"
|
|
555
|
+
] ] } }
|
|
395
556
|
]
|
|
396
557
|
}
|
|
397
558
|
]
|
|
@@ -459,14 +620,7 @@
|
|
|
459
620
|
},
|
|
460
621
|
{
|
|
461
622
|
"tmpl": [
|
|
462
|
-
{
|
|
463
|
-
"fn": "ident",
|
|
464
|
-
"args": [
|
|
465
|
-
{
|
|
466
|
-
"get": "node.method"
|
|
467
|
-
}
|
|
468
|
-
]
|
|
469
|
-
},
|
|
623
|
+
{ "fn": "mangleName", "args": [ { "fn": "ident", "args": [ { "get": "node.freeName" } ] } ] },
|
|
470
624
|
"(",
|
|
471
625
|
{
|
|
472
626
|
"emit": "node.object"
|
|
@@ -505,9 +659,9 @@
|
|
|
505
659
|
},
|
|
506
660
|
{
|
|
507
661
|
"tmpl": [
|
|
508
|
-
{
|
|
662
|
+
{ "fn": "identType", "args": [ {
|
|
509
663
|
"get": "node.staticType"
|
|
510
|
-
},
|
|
664
|
+
} ] },
|
|
511
665
|
"::",
|
|
512
666
|
{
|
|
513
667
|
"fn": "ident",
|
|
@@ -725,7 +879,7 @@
|
|
|
725
879
|
"tmpl": [
|
|
726
880
|
"new ",
|
|
727
881
|
{
|
|
728
|
-
"fn": "
|
|
882
|
+
"fn": "identType",
|
|
729
883
|
"args": [
|
|
730
884
|
{
|
|
731
885
|
"get": "node.typeName"
|
|
@@ -747,6 +901,26 @@
|
|
|
747
901
|
{ "type": "node.testType" }
|
|
748
902
|
]
|
|
749
903
|
},
|
|
904
|
+
"NullAssert": {
|
|
905
|
+
"case": {
|
|
906
|
+
"when": [
|
|
907
|
+
[
|
|
908
|
+
{ "eq": ["node.isFail", "true"] },
|
|
909
|
+
{ "tmpl": ["throw new \\UnexpectedValueException(", { "fn": "quoted", "args": ["string", { "get": "node.message" }] }, ")"] }
|
|
910
|
+
]
|
|
911
|
+
],
|
|
912
|
+
"else": {
|
|
913
|
+
"tmpl": [
|
|
914
|
+
{ "fn": "require", "args": ["pgNn"] },
|
|
915
|
+
"__pg_nn(",
|
|
916
|
+
{ "emit": "node.operand" },
|
|
917
|
+
", ",
|
|
918
|
+
{ "fn": "quoted", "args": ["string", { "get": "node.where" }] },
|
|
919
|
+
")"
|
|
920
|
+
]
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
},
|
|
750
924
|
"AsCast": {
|
|
751
925
|
"case": {
|
|
752
926
|
"when": [
|
|
@@ -783,6 +957,10 @@
|
|
|
783
957
|
"Unary": {
|
|
784
958
|
"case": {
|
|
785
959
|
"when": [
|
|
960
|
+
[
|
|
961
|
+
{ "eq": ["node.negatesInt64Min", "true"] },
|
|
962
|
+
"PHP_INT_MIN"
|
|
963
|
+
],
|
|
786
964
|
[
|
|
787
965
|
{
|
|
788
966
|
"and": [
|
|
@@ -951,8 +1129,9 @@
|
|
|
951
1129
|
"lits": "node.chunks",
|
|
952
1130
|
"holes": "node.holes",
|
|
953
1131
|
"lit": {
|
|
954
|
-
"fn": "
|
|
1132
|
+
"fn": "quoted",
|
|
955
1133
|
"args": [
|
|
1134
|
+
"interp",
|
|
956
1135
|
{
|
|
957
1136
|
"get": "item"
|
|
958
1137
|
}
|
|
@@ -977,11 +1156,30 @@
|
|
|
977
1156
|
") ? \"true\" : \"false\") . "
|
|
978
1157
|
]
|
|
979
1158
|
}
|
|
1159
|
+
],
|
|
1160
|
+
[
|
|
1161
|
+
{
|
|
1162
|
+
"or": [
|
|
1163
|
+
{ "eq": ["item.typeIsInt", "true"] },
|
|
1164
|
+
{ "eq": ["item.typeIsString", "true"] },
|
|
1165
|
+
{ "eq": ["item.typeIsChar", "true"] }
|
|
1166
|
+
]
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
"tmpl": [
|
|
1170
|
+
" . (",
|
|
1171
|
+
{
|
|
1172
|
+
"emit": "item"
|
|
1173
|
+
},
|
|
1174
|
+
") . "
|
|
1175
|
+
]
|
|
1176
|
+
}
|
|
980
1177
|
]
|
|
981
1178
|
],
|
|
982
1179
|
"else": {
|
|
983
1180
|
"tmpl": [
|
|
984
|
-
"
|
|
1181
|
+
{ "fn": "require", "args": ["pgStr"] },
|
|
1182
|
+
" . __pg_str(",
|
|
985
1183
|
{
|
|
986
1184
|
"emit": "item"
|
|
987
1185
|
},
|
|
@@ -998,6 +1196,19 @@
|
|
|
998
1196
|
"Binary": {
|
|
999
1197
|
"case": {
|
|
1000
1198
|
"when": [
|
|
1199
|
+
[
|
|
1200
|
+
{
|
|
1201
|
+
"and": [
|
|
1202
|
+
{ "or": [ { "eq": [ "node.op", "==" ] }, { "eq": [ "node.op", "!=" ] } ] },
|
|
1203
|
+
{ "eq": [ "node.lhsIsUnion", "true" ] }
|
|
1204
|
+
]
|
|
1205
|
+
},
|
|
1206
|
+
{ "tmpl": [
|
|
1207
|
+
{ "fn": "require", "args": ["pgUeq"] },
|
|
1208
|
+
{ "case": { "when": [ [ { "eq": [ "node.op", "!=" ] }, "!" ] ] } },
|
|
1209
|
+
"__pg_ueq(", { "emit": "node.lhs" }, ", ", { "emit": "node.rhs" }, ")"
|
|
1210
|
+
] }
|
|
1211
|
+
],
|
|
1001
1212
|
[
|
|
1002
1213
|
{
|
|
1003
1214
|
"and": [
|
|
@@ -1167,6 +1378,10 @@
|
|
|
1167
1378
|
]
|
|
1168
1379
|
}
|
|
1169
1380
|
],
|
|
1381
|
+
[
|
|
1382
|
+
{ "and": [ { "eq": ["node.typeIsFloat", "true"] }, { "eq": ["node.op", "/"] } ] },
|
|
1383
|
+
{ "tmpl": [ "fdiv(", { "emit": "node.lhs" }, ", ", { "emit": "node.rhs" }, ")" ] }
|
|
1384
|
+
],
|
|
1170
1385
|
[
|
|
1171
1386
|
{
|
|
1172
1387
|
"and": [
|
|
@@ -1459,7 +1674,10 @@
|
|
|
1459
1674
|
"tmpl": [
|
|
1460
1675
|
" && $__e instanceof ",
|
|
1461
1676
|
{
|
|
1462
|
-
"
|
|
1677
|
+
"case": {
|
|
1678
|
+
"when": [[{ "eq": ["item.typeName", "Error"] }, "\\Throwable"]],
|
|
1679
|
+
"else": { "type": "item.type" }
|
|
1680
|
+
}
|
|
1463
1681
|
}
|
|
1464
1682
|
]
|
|
1465
1683
|
}
|
|
@@ -1582,6 +1800,15 @@
|
|
|
1582
1800
|
{
|
|
1583
1801
|
"case": {
|
|
1584
1802
|
"when": [
|
|
1803
|
+
[
|
|
1804
|
+
{
|
|
1805
|
+
"eq": [
|
|
1806
|
+
"item.typeName",
|
|
1807
|
+
"Error"
|
|
1808
|
+
]
|
|
1809
|
+
},
|
|
1810
|
+
"\\Throwable"
|
|
1811
|
+
],
|
|
1585
1812
|
[
|
|
1586
1813
|
{
|
|
1587
1814
|
"eq": [
|
|
@@ -1593,7 +1820,8 @@
|
|
|
1593
1820
|
"type": "item.type"
|
|
1594
1821
|
}
|
|
1595
1822
|
]
|
|
1596
|
-
]
|
|
1823
|
+
],
|
|
1824
|
+
"else": "\\Throwable"
|
|
1597
1825
|
}
|
|
1598
1826
|
},
|
|
1599
1827
|
" $__e)"
|
|
@@ -1669,8 +1897,9 @@
|
|
|
1669
1897
|
"tmpl": [
|
|
1670
1898
|
"[\"tag\" => ",
|
|
1671
1899
|
{
|
|
1672
|
-
"fn": "
|
|
1900
|
+
"fn": "quoted",
|
|
1673
1901
|
"args": [
|
|
1902
|
+
"string",
|
|
1674
1903
|
{
|
|
1675
1904
|
"get": "node.caseName"
|
|
1676
1905
|
}
|
|
@@ -1683,8 +1912,9 @@
|
|
|
1683
1912
|
"tmpl": [
|
|
1684
1913
|
", ",
|
|
1685
1914
|
{
|
|
1686
|
-
"fn": "
|
|
1915
|
+
"fn": "quoted",
|
|
1687
1916
|
"args": [
|
|
1917
|
+
"string",
|
|
1688
1918
|
{
|
|
1689
1919
|
"get": "item.name"
|
|
1690
1920
|
}
|
|
@@ -1875,8 +2105,9 @@
|
|
|
1875
2105
|
"tmpl": [
|
|
1876
2106
|
"$_m[",
|
|
1877
2107
|
{
|
|
1878
|
-
"fn": "
|
|
2108
|
+
"fn": "quoted",
|
|
1879
2109
|
"args": [
|
|
2110
|
+
"string",
|
|
1880
2111
|
{
|
|
1881
2112
|
"get": "item.field"
|
|
1882
2113
|
}
|
|
@@ -2030,8 +2261,9 @@
|
|
|
2030
2261
|
"tmpl": [
|
|
2031
2262
|
"$_m[",
|
|
2032
2263
|
{
|
|
2033
|
-
"fn": "
|
|
2264
|
+
"fn": "quoted",
|
|
2034
2265
|
"args": [
|
|
2266
|
+
"string",
|
|
2035
2267
|
{
|
|
2036
2268
|
"get": "item.field"
|
|
2037
2269
|
}
|
|
@@ -2068,6 +2300,10 @@
|
|
|
2068
2300
|
]
|
|
2069
2301
|
}
|
|
2070
2302
|
],
|
|
2303
|
+
[
|
|
2304
|
+
{ "eq": ["item.pattern.isNullLiteral", "true"] },
|
|
2305
|
+
{ "tmpl": ["$_m === null"] }
|
|
2306
|
+
],
|
|
2071
2307
|
[
|
|
2072
2308
|
{
|
|
2073
2309
|
"eq": [
|
|
@@ -2077,7 +2313,7 @@
|
|
|
2077
2313
|
},
|
|
2078
2314
|
{
|
|
2079
2315
|
"tmpl": [
|
|
2080
|
-
"$_m
|
|
2316
|
+
"$_m === ",
|
|
2081
2317
|
{
|
|
2082
2318
|
"emit": "item.pattern.literal"
|
|
2083
2319
|
}
|
|
@@ -2093,7 +2329,7 @@
|
|
|
2093
2329
|
},
|
|
2094
2330
|
{
|
|
2095
2331
|
"tmpl": [
|
|
2096
|
-
"$_m
|
|
2332
|
+
"$_m === ",
|
|
2097
2333
|
{
|
|
2098
2334
|
"get": "item.pattern.enumType"
|
|
2099
2335
|
},
|
|
@@ -2113,10 +2349,11 @@
|
|
|
2113
2349
|
},
|
|
2114
2350
|
{
|
|
2115
2351
|
"tmpl": [
|
|
2116
|
-
"$_m[\"tag\"]
|
|
2352
|
+
"$_m[\"tag\"] === ",
|
|
2117
2353
|
{
|
|
2118
|
-
"fn": "
|
|
2354
|
+
"fn": "quoted",
|
|
2119
2355
|
"args": [
|
|
2356
|
+
"string",
|
|
2120
2357
|
{
|
|
2121
2358
|
"get": "item.pattern.ctorCase"
|
|
2122
2359
|
}
|
|
@@ -2139,8 +2376,9 @@
|
|
|
2139
2376
|
"tmpl": [
|
|
2140
2377
|
" && $_m[",
|
|
2141
2378
|
{
|
|
2142
|
-
"fn": "
|
|
2379
|
+
"fn": "quoted",
|
|
2143
2380
|
"args": [
|
|
2381
|
+
"string",
|
|
2144
2382
|
{
|
|
2145
2383
|
"get": "item.field"
|
|
2146
2384
|
}
|
|
@@ -2220,7 +2458,7 @@
|
|
|
2220
2458
|
"tmpl": [
|
|
2221
2459
|
"interface ",
|
|
2222
2460
|
{
|
|
2223
|
-
"fn": "
|
|
2461
|
+
"fn": "identType",
|
|
2224
2462
|
"args": [
|
|
2225
2463
|
{
|
|
2226
2464
|
"get": "decl.name"
|
|
@@ -2350,7 +2588,7 @@
|
|
|
2350
2588
|
]
|
|
2351
2589
|
],
|
|
2352
2590
|
"else": {
|
|
2353
|
-
"fn": "
|
|
2591
|
+
"fn": "identType",
|
|
2354
2592
|
"args": [
|
|
2355
2593
|
{
|
|
2356
2594
|
"get": "type.name"
|
|
@@ -2359,6 +2597,19 @@
|
|
|
2359
2597
|
}
|
|
2360
2598
|
}
|
|
2361
2599
|
},
|
|
2600
|
+
"rangeEndDecl": {
|
|
2601
|
+
"case": {
|
|
2602
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "false" ] },
|
|
2603
|
+
{ "tmpl": [ ", $", { "fn": "ident", "args": [ { "get": "stmt.rangeEndTemp" } ] }, " = ", { "emit": "stmt.rangeEnd" } ] } ] ],
|
|
2604
|
+
"else": ""
|
|
2605
|
+
}
|
|
2606
|
+
},
|
|
2607
|
+
"rangeEndRead": {
|
|
2608
|
+
"case": {
|
|
2609
|
+
"when": [ [ { "eq": [ "stmt.rangeEndSimple", "true" ] }, { "emit": "stmt.rangeEnd" } ] ],
|
|
2610
|
+
"else": { "tmpl": [ "$", { "fn": "ident", "args": [ { "get": "stmt.rangeEndTemp" } ] } ] }
|
|
2611
|
+
}
|
|
2612
|
+
},
|
|
2362
2613
|
"ForStmt": {
|
|
2363
2614
|
"case": {
|
|
2364
2615
|
"when": [
|
|
@@ -2386,7 +2637,20 @@
|
|
|
2386
2637
|
{
|
|
2387
2638
|
"emit": "stmt.rangeStart"
|
|
2388
2639
|
},
|
|
2389
|
-
"
|
|
2640
|
+
{ "call": "rangeEndDecl" },
|
|
2641
|
+
"; ",
|
|
2642
|
+
{
|
|
2643
|
+
"case": {
|
|
2644
|
+
"when": [
|
|
2645
|
+
[
|
|
2646
|
+
{ "and": [ { "eq": [ "stmt.inclusiveMayWrap", "true" ] }, { "eq": [ "stmt.rangeIs64", "true" ] } ] },
|
|
2647
|
+
{ "tmpl": [ "\\is_int($", { "fn": "ident", "args": [ { "get": "stmt.binding" } ] }, ") && " ] }
|
|
2648
|
+
]
|
|
2649
|
+
],
|
|
2650
|
+
"else": ""
|
|
2651
|
+
}
|
|
2652
|
+
},
|
|
2653
|
+
"$",
|
|
2390
2654
|
{
|
|
2391
2655
|
"fn": "ident",
|
|
2392
2656
|
"args": [
|
|
@@ -2411,9 +2675,7 @@
|
|
|
2411
2675
|
"else": " < "
|
|
2412
2676
|
}
|
|
2413
2677
|
},
|
|
2414
|
-
{
|
|
2415
|
-
"emit": "stmt.rangeEnd"
|
|
2416
|
-
},
|
|
2678
|
+
{ "call": "rangeEndRead" },
|
|
2417
2679
|
"; $",
|
|
2418
2680
|
{
|
|
2419
2681
|
"fn": "ident",
|
|
@@ -2573,7 +2835,7 @@
|
|
|
2573
2835
|
"fn": "identFn",
|
|
2574
2836
|
"args": [
|
|
2575
2837
|
{
|
|
2576
|
-
"get": "decl.
|
|
2838
|
+
"get": "decl.uniqueName"
|
|
2577
2839
|
}
|
|
2578
2840
|
]
|
|
2579
2841
|
}
|
|
@@ -2677,12 +2939,12 @@
|
|
|
2677
2939
|
"block": {
|
|
2678
2940
|
"head": {
|
|
2679
2941
|
"tmpl": [
|
|
2680
|
-
"if (!function_exists('",
|
|
2942
|
+
"if (!function_exists(__NAMESPACE__.'\\\\",
|
|
2681
2943
|
{
|
|
2682
2944
|
"fn": "ident",
|
|
2683
2945
|
"args": [
|
|
2684
2946
|
{
|
|
2685
|
-
"get": "decl.
|
|
2947
|
+
"get": "decl.uniqueName"
|
|
2686
2948
|
}
|
|
2687
2949
|
]
|
|
2688
2950
|
},
|
|
@@ -2759,7 +3021,9 @@
|
|
|
2759
3021
|
")"
|
|
2760
3022
|
]
|
|
2761
3023
|
},
|
|
2762
|
-
"MethodDecl": {
|
|
3024
|
+
"MethodDecl": { "case": { "when": [
|
|
3025
|
+
[ { "eq": [ "decl.isAbstract", "true" ] }, { "line": { "tmpl": [ "abstract ", { "call": "phpMethodSig" }, ";" ] } } ]
|
|
3026
|
+
], "else": {
|
|
2763
3027
|
"block": {
|
|
2764
3028
|
"head": {
|
|
2765
3029
|
"call": "phpMethodSig"
|
|
@@ -2798,14 +3062,14 @@
|
|
|
2798
3062
|
}
|
|
2799
3063
|
]
|
|
2800
3064
|
}
|
|
2801
|
-
},
|
|
3065
|
+
} } },
|
|
2802
3066
|
"EnumDecl": {
|
|
2803
3067
|
"block": {
|
|
2804
3068
|
"head": {
|
|
2805
3069
|
"tmpl": [
|
|
2806
3070
|
"class ",
|
|
2807
3071
|
{
|
|
2808
|
-
"fn": "
|
|
3072
|
+
"fn": "identType",
|
|
2809
3073
|
"args": [
|
|
2810
3074
|
{
|
|
2811
3075
|
"get": "decl.name"
|
|
@@ -2847,7 +3111,7 @@
|
|
|
2847
3111
|
"tmpl": [
|
|
2848
3112
|
"class ",
|
|
2849
3113
|
{
|
|
2850
|
-
"fn": "
|
|
3114
|
+
"fn": "identType",
|
|
2851
3115
|
"args": [
|
|
2852
3116
|
{
|
|
2853
3117
|
"get": "decl.name"
|
|
@@ -3036,12 +3300,15 @@
|
|
|
3036
3300
|
}
|
|
3037
3301
|
},
|
|
3038
3302
|
"ClassDecl": {
|
|
3303
|
+
"seq": [
|
|
3304
|
+
{
|
|
3039
3305
|
"block": {
|
|
3040
3306
|
"head": {
|
|
3041
3307
|
"tmpl": [
|
|
3308
|
+
{ "case": { "when": [ [ { "eq": [ "decl.isAbstract", "true" ] }, "abstract " ] ] } },
|
|
3042
3309
|
"class ",
|
|
3043
3310
|
{
|
|
3044
|
-
"fn": "
|
|
3311
|
+
"fn": "identType",
|
|
3045
3312
|
"args": [
|
|
3046
3313
|
{
|
|
3047
3314
|
"get": "decl.name"
|
|
@@ -3121,6 +3388,12 @@
|
|
|
3121
3388
|
"item.isMutable",
|
|
3122
3389
|
"false"
|
|
3123
3390
|
]
|
|
3391
|
+
},
|
|
3392
|
+
{
|
|
3393
|
+
"eq": [
|
|
3394
|
+
"item.initIsLiteral",
|
|
3395
|
+
"true"
|
|
3396
|
+
]
|
|
3124
3397
|
}
|
|
3125
3398
|
]
|
|
3126
3399
|
},
|
|
@@ -3188,6 +3461,12 @@
|
|
|
3188
3461
|
"item.isStatic",
|
|
3189
3462
|
"true"
|
|
3190
3463
|
]
|
|
3464
|
+
},
|
|
3465
|
+
{
|
|
3466
|
+
"eq": [
|
|
3467
|
+
"item.initIsLiteral",
|
|
3468
|
+
"true"
|
|
3469
|
+
]
|
|
3191
3470
|
}
|
|
3192
3471
|
]
|
|
3193
3472
|
},
|
|
@@ -3241,19 +3520,9 @@
|
|
|
3241
3520
|
"when": [
|
|
3242
3521
|
[
|
|
3243
3522
|
{
|
|
3244
|
-
"
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
"decl.hasSuper",
|
|
3248
|
-
"true"
|
|
3249
|
-
]
|
|
3250
|
-
},
|
|
3251
|
-
{
|
|
3252
|
-
"eq": [
|
|
3253
|
-
"decl.baseHasInit",
|
|
3254
|
-
"true"
|
|
3255
|
-
]
|
|
3256
|
-
}
|
|
3523
|
+
"eq": [
|
|
3524
|
+
"decl.baseHasInit",
|
|
3525
|
+
"true"
|
|
3257
3526
|
]
|
|
3258
3527
|
},
|
|
3259
3528
|
{
|
|
@@ -3314,12 +3583,50 @@
|
|
|
3314
3583
|
}
|
|
3315
3584
|
]
|
|
3316
3585
|
}
|
|
3586
|
+
},
|
|
3587
|
+
{
|
|
3588
|
+
"mapDecl": "decl.staticInitFields",
|
|
3589
|
+
"each": {
|
|
3590
|
+
"case": {
|
|
3591
|
+
"when": [
|
|
3592
|
+
[
|
|
3593
|
+
{ "eq": ["item.initIsLiteral", "false"] },
|
|
3594
|
+
{ "line": { "tmpl": [
|
|
3595
|
+
{ "fn": "identType", "args": [ { "get": "decl.name" } ] },
|
|
3596
|
+
"::$",
|
|
3597
|
+
{ "fn": "ident", "args": [ { "get": "item.name" } ] },
|
|
3598
|
+
" = ",
|
|
3599
|
+
{ "emit": "item.init" },
|
|
3600
|
+
";"
|
|
3601
|
+
] } }
|
|
3602
|
+
]
|
|
3603
|
+
]
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
]
|
|
3317
3608
|
},
|
|
3318
3609
|
"Program": {
|
|
3319
3610
|
"seq": [
|
|
3320
3611
|
{
|
|
3321
3612
|
"line": "<?php"
|
|
3322
3613
|
},
|
|
3614
|
+
{
|
|
3615
|
+
"line": "// <auto-generated/>"
|
|
3616
|
+
},
|
|
3617
|
+
{
|
|
3618
|
+
"line": "// Generated by Polyglot. Do not edit: regenerate with `polyglot build`."
|
|
3619
|
+
},
|
|
3620
|
+
{
|
|
3621
|
+
"case": {
|
|
3622
|
+
"when": [
|
|
3623
|
+
[
|
|
3624
|
+
{ "not": { "eq": ["option.namespace", ""] } },
|
|
3625
|
+
{ "line": { "tmpl": ["namespace ", { "get": "option.namespace" }, ";"] } }
|
|
3626
|
+
]
|
|
3627
|
+
]
|
|
3628
|
+
}
|
|
3629
|
+
},
|
|
3323
3630
|
{
|
|
3324
3631
|
"case": {
|
|
3325
3632
|
"when": [
|
|
@@ -3356,67 +3663,57 @@
|
|
|
3356
3663
|
}
|
|
3357
3664
|
},
|
|
3358
3665
|
{
|
|
3359
|
-
"
|
|
3360
|
-
"rule": "EnumDecl"
|
|
3666
|
+
"fn": "preludeSlot"
|
|
3361
3667
|
},
|
|
3362
3668
|
{
|
|
3363
|
-
"
|
|
3364
|
-
"
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
"line": {
|
|
3378
|
-
"tmpl": [
|
|
3379
|
-
"$",
|
|
3380
|
-
{
|
|
3381
|
-
"fn": "ident",
|
|
3382
|
-
"args": [
|
|
3669
|
+
"mapOrder": "module.order",
|
|
3670
|
+
"kinds": {
|
|
3671
|
+
"enum": { "rule": "EnumDecl" },
|
|
3672
|
+
"interface": { "rule": "InterfaceDecl" },
|
|
3673
|
+
"union": { "rule": "UnionDecl" },
|
|
3674
|
+
"record": { "rule": "RecordDecl" },
|
|
3675
|
+
"function": { "rule": "FunctionDecl" },
|
|
3676
|
+
"extension": { "rule": "FunctionDecl" },
|
|
3677
|
+
"class": { "rule": "ClassDecl" },
|
|
3678
|
+
"global": {
|
|
3679
|
+
"each": {
|
|
3680
|
+
"line": {
|
|
3681
|
+
"tmpl": [
|
|
3682
|
+
"$",
|
|
3383
3683
|
{
|
|
3384
|
-
"
|
|
3385
|
-
|
|
3386
|
-
]
|
|
3387
|
-
},
|
|
3388
|
-
" = ",
|
|
3389
|
-
{
|
|
3390
|
-
"case": {
|
|
3391
|
-
"when": [
|
|
3392
|
-
[
|
|
3393
|
-
{
|
|
3394
|
-
"eq": [
|
|
3395
|
-
"item.hasInit",
|
|
3396
|
-
"true"
|
|
3397
|
-
]
|
|
3398
|
-
},
|
|
3684
|
+
"fn": "ident",
|
|
3685
|
+
"args": [
|
|
3399
3686
|
{
|
|
3400
|
-
"
|
|
3687
|
+
"get": "item.name"
|
|
3401
3688
|
}
|
|
3402
3689
|
]
|
|
3403
|
-
|
|
3404
|
-
"
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3690
|
+
},
|
|
3691
|
+
" = ",
|
|
3692
|
+
{
|
|
3693
|
+
"case": {
|
|
3694
|
+
"when": [
|
|
3695
|
+
[
|
|
3696
|
+
{
|
|
3697
|
+
"eq": [
|
|
3698
|
+
"item.hasInit",
|
|
3699
|
+
"true"
|
|
3700
|
+
]
|
|
3701
|
+
},
|
|
3702
|
+
{
|
|
3703
|
+
"emit": "item.init"
|
|
3704
|
+
}
|
|
3705
|
+
]
|
|
3706
|
+
],
|
|
3707
|
+
"else": "null"
|
|
3708
|
+
}
|
|
3709
|
+
},
|
|
3710
|
+
";"
|
|
3711
|
+
]
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3409
3714
|
}
|
|
3410
3715
|
}
|
|
3411
3716
|
},
|
|
3412
|
-
{
|
|
3413
|
-
"mapMembers": "module.functions",
|
|
3414
|
-
"rule": "FunctionDecl"
|
|
3415
|
-
},
|
|
3416
|
-
{
|
|
3417
|
-
"mapMembers": "module.extensions",
|
|
3418
|
-
"rule": "FunctionDecl"
|
|
3419
|
-
},
|
|
3420
3717
|
{
|
|
3421
3718
|
"case": {
|
|
3422
3719
|
"when": [
|
|
@@ -3449,5 +3746,6 @@
|
|
|
3449
3746
|
]
|
|
3450
3747
|
}
|
|
3451
3748
|
},
|
|
3452
|
-
"fileExtension": ".php"
|
|
3749
|
+
"fileExtension": ".php",
|
|
3750
|
+
"lineComment": "//"
|
|
3453
3751
|
}
|