@mintplayer/polyglot-target-python 0.9.1 → 0.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/polyglot-plugin.json +244 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mintplayer/polyglot-target-python",
3
- "version": "0.9.1",
3
+ "version": "0.9.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",
@@ -643,26 +643,62 @@
643
643
  "map": "decl.fields",
644
644
  "sep": " and ",
645
645
  "item": {
646
- "tmpl": [
647
- "self.",
648
- {
649
- "fn": "ident",
650
- "args": [
646
+ "case": {
647
+ "when": [
648
+ [
651
649
  {
652
- "get": "item.name"
650
+ "eq": [
651
+ "item.typeIsList",
652
+ "true"
653
+ ]
654
+ },
655
+ {
656
+ "tmpl": [
657
+ "self.",
658
+ {
659
+ "fn": "ident",
660
+ "args": [
661
+ {
662
+ "get": "item.name"
663
+ }
664
+ ]
665
+ },
666
+ " is other.",
667
+ {
668
+ "fn": "ident",
669
+ "args": [
670
+ {
671
+ "get": "item.name"
672
+ }
673
+ ]
674
+ }
675
+ ]
653
676
  }
654
677
  ]
655
- },
656
- " == other.",
657
- {
658
- "fn": "ident",
659
- "args": [
678
+ ],
679
+ "else": {
680
+ "tmpl": [
681
+ "self.",
660
682
  {
661
- "get": "item.name"
683
+ "fn": "ident",
684
+ "args": [
685
+ {
686
+ "get": "item.name"
687
+ }
688
+ ]
689
+ },
690
+ " == other.",
691
+ {
692
+ "fn": "ident",
693
+ "args": [
694
+ {
695
+ "get": "item.name"
696
+ }
697
+ ]
662
698
  }
663
699
  ]
664
700
  }
665
- ]
701
+ }
666
702
  }
667
703
  }
668
704
  ]
@@ -2150,6 +2186,80 @@
2150
2186
  ")"
2151
2187
  ]
2152
2188
  }
2189
+ ],
2190
+ [
2191
+ {
2192
+ "and": [
2193
+ {
2194
+ "eq": [
2195
+ "node.typeIsSmallInt",
2196
+ "true"
2197
+ ]
2198
+ },
2199
+ {
2200
+ "eq": [
2201
+ "node.fromIsInt",
2202
+ "true"
2203
+ ]
2204
+ },
2205
+ {
2206
+ "not": {
2207
+ "eq": [
2208
+ "node.castSame",
2209
+ "true"
2210
+ ]
2211
+ }
2212
+ }
2213
+ ]
2214
+ },
2215
+ {
2216
+ "fn": "wrap",
2217
+ "args": [
2218
+ {
2219
+ "get": "node.type"
2220
+ },
2221
+ {
2222
+ "emit": "node.operand"
2223
+ }
2224
+ ]
2225
+ }
2226
+ ],
2227
+ [
2228
+ {
2229
+ "and": [
2230
+ {
2231
+ "eq": [
2232
+ "node.typeIsInt64",
2233
+ "true"
2234
+ ]
2235
+ },
2236
+ {
2237
+ "eq": [
2238
+ "node.fromIsInt64",
2239
+ "true"
2240
+ ]
2241
+ },
2242
+ {
2243
+ "not": {
2244
+ "eq": [
2245
+ "node.castSame",
2246
+ "true"
2247
+ ]
2248
+ }
2249
+ }
2250
+ ]
2251
+ },
2252
+ {
2253
+ "fn": "wrap",
2254
+ "args": [
2255
+ {
2256
+ "get": "node.type"
2257
+ },
2258
+ {
2259
+ "emit": "node.operand"
2260
+ }
2261
+ ]
2262
+ }
2153
2263
  ]
2154
2264
  ],
2155
2265
  "else": {
@@ -2693,6 +2803,37 @@
2693
2803
  }
2694
2804
  }
2695
2805
  ],
2806
+ [
2807
+ {
2808
+ "and": [
2809
+ {
2810
+ "eq": [
2811
+ "node.typeIsFloat",
2812
+ "true"
2813
+ ]
2814
+ },
2815
+ {
2816
+ "eq": [
2817
+ "node.op",
2818
+ "%"
2819
+ ]
2820
+ }
2821
+ ]
2822
+ },
2823
+ {
2824
+ "tmpl": [
2825
+ "__import__('math').fmod(",
2826
+ {
2827
+ "emit": "node.lhs"
2828
+ },
2829
+ ", ",
2830
+ {
2831
+ "emit": "node.rhs"
2832
+ },
2833
+ ")"
2834
+ ]
2835
+ }
2836
+ ],
2696
2837
  [
2697
2838
  {
2698
2839
  "and": [
@@ -2733,6 +2874,18 @@
2733
2874
  "node.op",
2734
2875
  "%"
2735
2876
  ]
2877
+ },
2878
+ {
2879
+ "eq": [
2880
+ "node.op",
2881
+ "<<"
2882
+ ]
2883
+ },
2884
+ {
2885
+ "eq": [
2886
+ "node.op",
2887
+ ">>"
2888
+ ]
2736
2889
  }
2737
2890
  ]
2738
2891
  }
@@ -2747,6 +2900,82 @@
2747
2900
  {
2748
2901
  "case": {
2749
2902
  "when": [
2903
+ [
2904
+ {
2905
+ "eq": [
2906
+ "node.op",
2907
+ "<<"
2908
+ ]
2909
+ },
2910
+ {
2911
+ "tmpl": [
2912
+ "(",
2913
+ {
2914
+ "emit": "node.lhs"
2915
+ },
2916
+ " << (",
2917
+ {
2918
+ "emit": "node.rhs"
2919
+ },
2920
+ " & ",
2921
+ {
2922
+ "case": {
2923
+ "when": [
2924
+ [
2925
+ {
2926
+ "eq": [
2927
+ "node.typeIsInt64",
2928
+ "true"
2929
+ ]
2930
+ },
2931
+ "63"
2932
+ ]
2933
+ ],
2934
+ "else": "31"
2935
+ }
2936
+ },
2937
+ "))"
2938
+ ]
2939
+ }
2940
+ ],
2941
+ [
2942
+ {
2943
+ "eq": [
2944
+ "node.op",
2945
+ ">>"
2946
+ ]
2947
+ },
2948
+ {
2949
+ "tmpl": [
2950
+ "(",
2951
+ {
2952
+ "emit": "node.lhs"
2953
+ },
2954
+ " >> (",
2955
+ {
2956
+ "emit": "node.rhs"
2957
+ },
2958
+ " & ",
2959
+ {
2960
+ "case": {
2961
+ "when": [
2962
+ [
2963
+ {
2964
+ "eq": [
2965
+ "node.typeIsInt64",
2966
+ "true"
2967
+ ]
2968
+ },
2969
+ "63"
2970
+ ]
2971
+ ],
2972
+ "else": "31"
2973
+ }
2974
+ },
2975
+ "))"
2976
+ ]
2977
+ }
2978
+ ],
2750
2979
  [
2751
2980
  {
2752
2981
  "eq": [
@@ -2864,8 +3093,8 @@
2864
3093
  "List.init": "[]",
2865
3094
  "List.count": "len($this)",
2866
3095
  "List.add": "$this.append($0)",
2867
- "List.clear": "$this = []",
2868
- "List.removeAll": "$this = [__e for __e in $this if not (($0)(__e))]",
3096
+ "List.clear": "$this.clear()",
3097
+ "List.removeAll": "$this[:] = [__e for __e in $this if not (($0)(__e))]",
2869
3098
  "List.removeAt": "$this.pop($0)"
2870
3099
  },
2871
3100
  "std.io": {