@mintplayer/polyglot-target-php 0.8.1 → 0.9.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/polyglot-target-php",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
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",
@@ -156,13 +156,13 @@
156
156
  },
157
157
  "std": {
158
158
  "std.collections": {
159
- "List.type": "array",
160
- "List.init": "[]",
159
+ "List.type": "\\ArrayObject",
160
+ "List.init": "new \\ArrayObject()",
161
161
  "List.count": "count($this)",
162
162
  "List.add": "$this[] = $0",
163
- "List.clear": "$this = []",
164
- "List.removeAll": "$this = array_values(array_filter($this, fn($__e) => !(($0)($__e))))",
165
- "List.removeAt": "array_splice($this, $0, 1)"
163
+ "List.clear": "$this->exchangeArray([])",
164
+ "List.removeAll": "$this->exchangeArray(array_values(array_filter($this->getArrayCopy(), fn($__e) => !(($0)($__e)))))",
165
+ "List.removeAt": "$this->exchangeArray((function ($__a, $__i) { array_splice($__a, $__i, 1); return $__a; })($this->getArrayCopy(), $0))"
166
166
  },
167
167
  "std.io": {
168
168
  "print": "echo is_bool($x) ? ($x ? \"true\" : \"false\") : $x, \"\\n\"",
@@ -178,6 +178,7 @@
178
178
  "string.toUpper": "strtoupper($this)",
179
179
  "string.toLower": "strtolower($this)",
180
180
  "string.charAt": "substr($this, $0, 1)",
181
+ "string.codePointAt": "ord(substr($this, $0, 1))",
181
182
  "string.codePoints": "str_split($this)",
182
183
  "string.toI32": "intval($this)"
183
184
  },
@@ -186,8 +187,8 @@
186
187
  "Error.init": "new $T($0)",
187
188
  "Error.message": "$this->getMessage()",
188
189
  "Iterable.type": "iterable",
189
- "Array.type": "array",
190
- "Array.init": "[]",
190
+ "Array.type": "\\ArrayObject",
191
+ "Array.init": "new \\ArrayObject()",
191
192
  "Array.count": "count($this)",
192
193
  "i8.parse": "intval($0)",
193
194
  "i16.parse": "intval($0)",
@@ -554,12 +555,12 @@
554
555
  },
555
556
  "ListLit": {
556
557
  "tmpl": [
557
- "[",
558
+ "new \\ArrayObject([",
558
559
  {
559
560
  "map": "node.elements",
560
561
  "sep": ", "
561
562
  },
562
- "]"
563
+ "])"
563
564
  ]
564
565
  },
565
566
  "Tuple": {
@@ -1860,43 +1861,46 @@
1860
1861
  ")"
1861
1862
  ]
1862
1863
  },
1864
+ "phpGlobalsPrologue": {
1865
+ "case": {
1866
+ "when": [
1867
+ [
1868
+ {
1869
+ "not": {
1870
+ "eq": [
1871
+ "decl.globalRefs.count",
1872
+ "0"
1873
+ ]
1874
+ }
1875
+ },
1876
+ {
1877
+ "line": {
1878
+ "tmpl": [
1879
+ "global ",
1880
+ {
1881
+ "map": "decl.globalRefs",
1882
+ "sep": ", ",
1883
+ "item": {
1884
+ "tmpl": [
1885
+ "$",
1886
+ {
1887
+ "get": "item"
1888
+ }
1889
+ ]
1890
+ }
1891
+ },
1892
+ ";"
1893
+ ]
1894
+ }
1895
+ }
1896
+ ]
1897
+ ]
1898
+ }
1899
+ },
1863
1900
  "phpFnBody": {
1864
1901
  "seq": [
1865
1902
  {
1866
- "case": {
1867
- "when": [
1868
- [
1869
- {
1870
- "not": {
1871
- "eq": [
1872
- "decl.globalRefs.count",
1873
- "0"
1874
- ]
1875
- }
1876
- },
1877
- {
1878
- "line": {
1879
- "tmpl": [
1880
- "global ",
1881
- {
1882
- "map": "decl.globalRefs",
1883
- "sep": ", ",
1884
- "item": {
1885
- "tmpl": [
1886
- "$",
1887
- {
1888
- "get": "item"
1889
- }
1890
- ]
1891
- }
1892
- },
1893
- ";"
1894
- ]
1895
- }
1896
- }
1897
- ]
1898
- ]
1899
- }
1903
+ "call": "phpGlobalsPrologue"
1900
1904
  },
1901
1905
  {
1902
1906
  "case": {
@@ -2030,6 +2034,9 @@
2030
2034
  "call": "phpMethodSig"
2031
2035
  },
2032
2036
  "body": [
2037
+ {
2038
+ "call": "phpGlobalsPrologue"
2039
+ },
2033
2040
  {
2034
2041
  "case": {
2035
2042
  "when": [
@@ -2343,9 +2350,19 @@
2343
2350
  "when": [
2344
2351
  [
2345
2352
  {
2346
- "eq": [
2347
- "item.hasInit",
2348
- "true"
2353
+ "and": [
2354
+ {
2355
+ "eq": [
2356
+ "item.hasInit",
2357
+ "true"
2358
+ ]
2359
+ },
2360
+ {
2361
+ "eq": [
2362
+ "item.isStatic",
2363
+ "true"
2364
+ ]
2365
+ }
2349
2366
  ]
2350
2367
  },
2351
2368
  {
@@ -2373,7 +2390,7 @@
2373
2390
  [
2374
2391
  {
2375
2392
  "eq": [
2376
- "decl.hasInit",
2393
+ "decl.needsCtor",
2377
2394
  "true"
2378
2395
  ]
2379
2396
  },
@@ -2422,6 +2439,29 @@
2422
2439
  ]
2423
2440
  }
2424
2441
  },
2442
+ {
2443
+ "mapDecl": "decl.instanceInitFields",
2444
+ "each": {
2445
+ "line": {
2446
+ "tmpl": [
2447
+ "$this->",
2448
+ {
2449
+ "fn": "ident",
2450
+ "args": [
2451
+ {
2452
+ "get": "item.name"
2453
+ }
2454
+ ]
2455
+ },
2456
+ " = ",
2457
+ {
2458
+ "emit": "item.init"
2459
+ },
2460
+ ";"
2461
+ ]
2462
+ }
2463
+ }
2464
+ },
2425
2465
  {
2426
2466
  "stmts": "decl.initBody"
2427
2467
  }