sonolus.py 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl

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.

Potentially problematic release.


This version of sonolus.py might be problematic. Click here for more details.

Files changed (68) hide show
  1. sonolus/backend/allocate.py +125 -51
  2. sonolus/backend/blocks.py +756 -756
  3. sonolus/backend/coalesce.py +85 -0
  4. sonolus/backend/constant_evaluation.py +374 -0
  5. sonolus/backend/dead_code.py +80 -0
  6. sonolus/backend/dominance.py +111 -0
  7. sonolus/backend/excepthook.py +37 -37
  8. sonolus/backend/finalize.py +69 -69
  9. sonolus/backend/flow.py +121 -92
  10. sonolus/backend/inlining.py +150 -0
  11. sonolus/backend/ir.py +5 -3
  12. sonolus/backend/liveness.py +173 -0
  13. sonolus/backend/mode.py +24 -24
  14. sonolus/backend/node.py +40 -40
  15. sonolus/backend/ops.py +197 -197
  16. sonolus/backend/optimize.py +37 -9
  17. sonolus/backend/passes.py +52 -6
  18. sonolus/backend/simplify.py +47 -30
  19. sonolus/backend/ssa.py +187 -0
  20. sonolus/backend/utils.py +48 -48
  21. sonolus/backend/visitor.py +892 -882
  22. sonolus/build/cli.py +7 -1
  23. sonolus/build/compile.py +88 -90
  24. sonolus/build/level.py +24 -23
  25. sonolus/build/node.py +43 -43
  26. sonolus/script/archetype.py +23 -6
  27. sonolus/script/array.py +2 -2
  28. sonolus/script/bucket.py +191 -191
  29. sonolus/script/callbacks.py +127 -127
  30. sonolus/script/comptime.py +1 -1
  31. sonolus/script/containers.py +23 -0
  32. sonolus/script/debug.py +19 -3
  33. sonolus/script/easing.py +323 -0
  34. sonolus/script/effect.py +131 -131
  35. sonolus/script/globals.py +269 -269
  36. sonolus/script/graphics.py +200 -150
  37. sonolus/script/instruction.py +151 -151
  38. sonolus/script/internal/__init__.py +5 -5
  39. sonolus/script/internal/builtin_impls.py +144 -144
  40. sonolus/script/internal/context.py +12 -4
  41. sonolus/script/internal/descriptor.py +17 -17
  42. sonolus/script/internal/introspection.py +14 -14
  43. sonolus/script/internal/native.py +40 -38
  44. sonolus/script/internal/value.py +3 -3
  45. sonolus/script/interval.py +120 -112
  46. sonolus/script/iterator.py +214 -214
  47. sonolus/script/math.py +30 -1
  48. sonolus/script/num.py +1 -1
  49. sonolus/script/options.py +191 -191
  50. sonolus/script/particle.py +157 -157
  51. sonolus/script/pointer.py +30 -30
  52. sonolus/script/print.py +81 -81
  53. sonolus/script/random.py +14 -0
  54. sonolus/script/range.py +58 -58
  55. sonolus/script/record.py +3 -3
  56. sonolus/script/runtime.py +2 -0
  57. sonolus/script/sprite.py +333 -333
  58. sonolus/script/text.py +407 -407
  59. sonolus/script/timing.py +42 -42
  60. sonolus/script/transform.py +77 -23
  61. sonolus/script/ui.py +160 -160
  62. sonolus/script/vec.py +81 -78
  63. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.4.dist-info}/METADATA +1 -1
  64. sonolus_py-0.1.4.dist-info/RECORD +84 -0
  65. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.4.dist-info}/WHEEL +1 -1
  66. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.4.dist-info}/licenses/LICENSE +21 -21
  67. sonolus_py-0.1.3.dist-info/RECORD +0 -75
  68. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.4.dist-info}/entry_points.txt +0 -0
sonolus/script/range.py CHANGED
@@ -1,58 +1,58 @@
1
- from sonolus.script.iterator import ArrayLike, SonolusIterator
2
- from sonolus.script.num import Num
3
- from sonolus.script.record import Record
4
-
5
-
6
- class Range(Record, ArrayLike[Num]):
7
- start: int
8
- end: int
9
- step: int
10
-
11
- def __new__(cls, start: Num, end: Num | None = None, step: Num = 1):
12
- if end is None:
13
- start, end = 0, start
14
- return super().__new__(cls, start, end, step)
15
-
16
- def __iter__(self) -> SonolusIterator:
17
- return RangeIterator(self.start, self.end, self.step)
18
-
19
- def __contains__(self, item):
20
- if self.step > 0:
21
- return self.start <= item < self.end and (item - self.start) % self.step == 0
22
- else:
23
- return self.end < item <= self.start and (self.start - item) % -self.step == 0
24
-
25
- def size(self) -> int:
26
- if self.step > 0:
27
- diff = self.end - self.start
28
- if diff <= 0:
29
- return 0
30
- return (diff + self.step - 1) // self.step
31
- else:
32
- diff = self.start - self.end
33
- if diff <= 0:
34
- return 0
35
- return (diff - self.step - 1) // -self.step
36
-
37
- def __getitem__(self, index: Num) -> Num:
38
- return self.start + index * self.step
39
-
40
- def __setitem__(self, index: Num, value: Num):
41
- raise TypeError("Range does not support item assignment")
42
-
43
-
44
- class RangeIterator(Record, SonolusIterator):
45
- value: int
46
- end: int
47
- step: int
48
-
49
- def has_next(self) -> bool:
50
- if self.step > 0:
51
- return self.value < self.end
52
- else:
53
- return self.value > self.end
54
-
55
- def next(self) -> Num:
56
- value = self.value
57
- self.value += self.step
58
- return value
1
+ from sonolus.script.iterator import ArrayLike, SonolusIterator
2
+ from sonolus.script.num import Num
3
+ from sonolus.script.record import Record
4
+
5
+
6
+ class Range(Record, ArrayLike[Num]):
7
+ start: int
8
+ end: int
9
+ step: int
10
+
11
+ def __new__(cls, start: Num, end: Num | None = None, step: Num = 1):
12
+ if end is None:
13
+ start, end = 0, start
14
+ return super().__new__(cls, start, end, step)
15
+
16
+ def __iter__(self) -> SonolusIterator:
17
+ return RangeIterator(self.start, self.end, self.step)
18
+
19
+ def __contains__(self, item):
20
+ if self.step > 0:
21
+ return self.start <= item < self.end and (item - self.start) % self.step == 0
22
+ else:
23
+ return self.end < item <= self.start and (self.start - item) % -self.step == 0
24
+
25
+ def size(self) -> int:
26
+ if self.step > 0:
27
+ diff = self.end - self.start
28
+ if diff <= 0:
29
+ return 0
30
+ return (diff + self.step - 1) // self.step
31
+ else:
32
+ diff = self.start - self.end
33
+ if diff <= 0:
34
+ return 0
35
+ return (diff - self.step - 1) // -self.step
36
+
37
+ def __getitem__(self, index: Num) -> Num:
38
+ return self.start + index * self.step
39
+
40
+ def __setitem__(self, index: Num, value: Num):
41
+ raise TypeError("Range does not support item assignment")
42
+
43
+
44
+ class RangeIterator(Record, SonolusIterator):
45
+ value: int
46
+ end: int
47
+ step: int
48
+
49
+ def has_next(self) -> bool:
50
+ if self.step > 0:
51
+ return self.value < self.end
52
+ else:
53
+ return self.value > self.end
54
+
55
+ def next(self) -> Num:
56
+ value = self.value
57
+ self.value += self.step
58
+ return value
sonolus/script/record.py CHANGED
@@ -111,7 +111,7 @@ class Record(GenericValue):
111
111
  values[field.name] = value._get_()
112
112
  for type_param in cls.__type_params__:
113
113
  if type_param not in type_vars:
114
- raise TypeError(f"Type parameter {type_param} is not used")
114
+ raise TypeError(f"Type parameter {type_param} cannot be inferred and must be provided explicitly")
115
115
  type_args = tuple(type_vars[type_param] for type_param in cls.__type_params__)
116
116
  if cls._type_args_ is not None:
117
117
  parameterized = cls
@@ -168,10 +168,10 @@ class Record(GenericValue):
168
168
  iterator = iter(values)
169
169
  return cls(**{field.name: field.type._from_list_(iterator) for field in cls._fields})
170
170
 
171
- def _to_list_(self) -> list[float | BlockPlace]:
171
+ def _to_list_(self, level_refs: dict[Any, int] | None = None) -> list[float | BlockPlace]:
172
172
  result = []
173
173
  for field in self._fields:
174
- result.extend(self._value[field.name]._to_list_())
174
+ result.extend(self._value[field.name]._to_list_(level_refs))
175
175
  return result
176
176
 
177
177
  @classmethod
sonolus/script/runtime.py CHANGED
@@ -308,6 +308,7 @@ class _SkinTransform:
308
308
  a12=Num(values[1 * 4 + 3]),
309
309
  a20=Num(values[3 * 4 + 0]),
310
310
  a21=Num(values[3 * 4 + 1]),
311
+ a22=Num(values[3 * 4 + 3]),
311
312
  )
312
313
 
313
314
 
@@ -328,6 +329,7 @@ class _ParticleTransform:
328
329
  a12=Num(values[1 * 4 + 3]),
329
330
  a20=Num(values[3 * 4 + 0]),
330
331
  a21=Num(values[3 * 4 + 1]),
332
+ a22=Num(values[3 * 4 + 3]),
331
333
  )
332
334
 
333
335