@mintplayer/polyglot-target-php 0.1.0 → 0.3.0

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.1.0",
3
+ "version": "0.3.0",
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",
@@ -155,6 +155,34 @@
155
155
  "std.core": {
156
156
  "i32.parse": "(intval($0) & 0xffffffff)",
157
157
  "f64.parse": "floatval($0)"
158
+ },
159
+ "std.math": {
160
+ "Math.PI": "M_PI",
161
+ "Math.E": "M_E",
162
+ "Math.sqrt": "sqrt($0)",
163
+ "Math.ln": "log($0)",
164
+ "Math.log": "log($0)",
165
+ "Math.log2": "log($0, 2)",
166
+ "Math.log10": "log10($0)",
167
+ "Math.exp": "exp($0)",
168
+ "Math.pow": "pow($0, $1)",
169
+ "Math.sin": "sin($0)",
170
+ "Math.cos": "cos($0)",
171
+ "Math.tan": "tan($0)",
172
+ "Math.asin": "asin($0)",
173
+ "Math.acos": "acos($0)",
174
+ "Math.atan": "atan($0)",
175
+ "Math.atan2": "atan2($0, $1)",
176
+ "Math.sinh": "sinh($0)",
177
+ "Math.cosh": "cosh($0)",
178
+ "Math.tanh": "tanh($0)",
179
+ "Math.trunc": "(float)(int)($0)",
180
+ "Math.floor": "floor($0)",
181
+ "Math.ceil": "ceil($0)",
182
+ "Math.min": "min($0, $1)",
183
+ "Math.max": "max($0, $1)",
184
+ "Math.abs": "abs($0)",
185
+ "Math.round": "round($0)"
158
186
  }
159
187
  },
160
188
  "rules": {
@@ -561,20 +589,12 @@
561
589
  ]
562
590
  },
563
591
  {
564
- "fn": "wrap",
565
- "args": [
592
+ "tmpl": [
593
+ "(int)(",
566
594
  {
567
- "get": "node.type"
595
+ "emit": "node.operand"
568
596
  },
569
- {
570
- "tmpl": [
571
- "(int)(",
572
- {
573
- "emit": "node.operand"
574
- },
575
- ")"
576
- ]
577
- }
597
+ ")"
578
598
  ]
579
599
  }
580
600
  ]
@@ -608,13 +628,36 @@
608
628
  ]
609
629
  },
610
630
  "hole": {
611
- "tmpl": [
612
- " . (",
613
- {
614
- "emit": "item"
615
- },
616
- ") . "
617
- ]
631
+ "case": {
632
+ "when": [
633
+ [
634
+ {
635
+ "eq": [
636
+ "item.typeIsBool",
637
+ "true"
638
+ ]
639
+ },
640
+ {
641
+ "tmpl": [
642
+ " . ((",
643
+ {
644
+ "emit": "item"
645
+ },
646
+ ") ? \"true\" : \"false\") . "
647
+ ]
648
+ }
649
+ ]
650
+ ],
651
+ "else": {
652
+ "tmpl": [
653
+ " . (",
654
+ {
655
+ "emit": "item"
656
+ },
657
+ ") . "
658
+ ]
659
+ }
660
+ }
618
661
  }
619
662
  }
620
663
  },
@@ -1403,6 +1446,14 @@
1403
1446
  {
1404
1447
  "line": "<?php"
1405
1448
  },
1449
+ {
1450
+ "mapDecl": "module.imports",
1451
+ "each": {
1452
+ "line": {
1453
+ "tmpl": [ "require_once __DIR__ . '/", { "get": "item.path" }, ".php';" ]
1454
+ }
1455
+ }
1456
+ },
1406
1457
  {
1407
1458
  "mapMembers": "module.enums",
1408
1459
  "rule": "EnumDecl"