sonolus.py 0.1.3__py3-none-any.whl → 0.1.5__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 (90) hide show
  1. sonolus/backend/blocks.py +756 -756
  2. sonolus/backend/excepthook.py +37 -37
  3. sonolus/backend/finalize.py +77 -69
  4. sonolus/backend/interpret.py +7 -7
  5. sonolus/backend/ir.py +29 -3
  6. sonolus/backend/mode.py +24 -24
  7. sonolus/backend/node.py +40 -40
  8. sonolus/backend/ops.py +197 -197
  9. sonolus/backend/optimize/__init__.py +0 -0
  10. sonolus/backend/optimize/allocate.py +126 -0
  11. sonolus/backend/optimize/constant_evaluation.py +374 -0
  12. sonolus/backend/optimize/copy_coalesce.py +85 -0
  13. sonolus/backend/optimize/dead_code.py +185 -0
  14. sonolus/backend/optimize/dominance.py +96 -0
  15. sonolus/backend/{flow.py → optimize/flow.py} +122 -92
  16. sonolus/backend/optimize/inlining.py +137 -0
  17. sonolus/backend/optimize/liveness.py +177 -0
  18. sonolus/backend/optimize/optimize.py +44 -0
  19. sonolus/backend/optimize/passes.py +52 -0
  20. sonolus/backend/optimize/simplify.py +191 -0
  21. sonolus/backend/optimize/ssa.py +200 -0
  22. sonolus/backend/place.py +17 -25
  23. sonolus/backend/utils.py +58 -48
  24. sonolus/backend/visitor.py +1151 -882
  25. sonolus/build/cli.py +7 -1
  26. sonolus/build/compile.py +88 -90
  27. sonolus/build/engine.py +10 -5
  28. sonolus/build/level.py +24 -23
  29. sonolus/build/node.py +43 -43
  30. sonolus/script/archetype.py +438 -139
  31. sonolus/script/array.py +27 -10
  32. sonolus/script/array_like.py +297 -0
  33. sonolus/script/bucket.py +253 -191
  34. sonolus/script/containers.py +257 -51
  35. sonolus/script/debug.py +26 -10
  36. sonolus/script/easing.py +365 -0
  37. sonolus/script/effect.py +191 -131
  38. sonolus/script/engine.py +71 -4
  39. sonolus/script/globals.py +303 -269
  40. sonolus/script/instruction.py +205 -151
  41. sonolus/script/internal/__init__.py +5 -5
  42. sonolus/script/internal/builtin_impls.py +255 -144
  43. sonolus/script/{callbacks.py → internal/callbacks.py} +127 -127
  44. sonolus/script/internal/constant.py +139 -0
  45. sonolus/script/internal/context.py +26 -9
  46. sonolus/script/internal/descriptor.py +17 -17
  47. sonolus/script/internal/dict_impl.py +65 -0
  48. sonolus/script/internal/generic.py +6 -9
  49. sonolus/script/internal/impl.py +38 -13
  50. sonolus/script/internal/introspection.py +17 -14
  51. sonolus/script/internal/math_impls.py +121 -0
  52. sonolus/script/internal/native.py +40 -38
  53. sonolus/script/internal/random.py +67 -0
  54. sonolus/script/internal/range.py +81 -0
  55. sonolus/script/internal/transient.py +51 -0
  56. sonolus/script/internal/tuple_impl.py +113 -0
  57. sonolus/script/internal/value.py +3 -3
  58. sonolus/script/interval.py +338 -112
  59. sonolus/script/iterator.py +167 -214
  60. sonolus/script/level.py +24 -0
  61. sonolus/script/num.py +80 -48
  62. sonolus/script/options.py +257 -191
  63. sonolus/script/particle.py +190 -157
  64. sonolus/script/pointer.py +30 -30
  65. sonolus/script/print.py +102 -81
  66. sonolus/script/project.py +8 -0
  67. sonolus/script/quad.py +263 -0
  68. sonolus/script/record.py +47 -16
  69. sonolus/script/runtime.py +52 -1
  70. sonolus/script/sprite.py +418 -333
  71. sonolus/script/text.py +409 -407
  72. sonolus/script/timing.py +114 -42
  73. sonolus/script/transform.py +332 -48
  74. sonolus/script/ui.py +216 -160
  75. sonolus/script/values.py +6 -13
  76. sonolus/script/vec.py +196 -78
  77. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.5.dist-info}/METADATA +1 -1
  78. sonolus_py-0.1.5.dist-info/RECORD +89 -0
  79. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.5.dist-info}/WHEEL +1 -1
  80. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.5.dist-info}/licenses/LICENSE +21 -21
  81. sonolus/backend/allocate.py +0 -51
  82. sonolus/backend/optimize.py +0 -9
  83. sonolus/backend/passes.py +0 -6
  84. sonolus/backend/simplify.py +0 -30
  85. sonolus/script/comptime.py +0 -160
  86. sonolus/script/graphics.py +0 -150
  87. sonolus/script/math.py +0 -92
  88. sonolus/script/range.py +0 -58
  89. sonolus_py-0.1.3.dist-info/RECORD +0 -75
  90. {sonolus_py-0.1.3.dist-info → sonolus_py-0.1.5.dist-info}/entry_points.txt +0 -0
sonolus/script/vec.py CHANGED
@@ -1,78 +1,196 @@
1
- from typing import Self
2
-
3
- from sonolus.script.math import atan2, cos, sin
4
- from sonolus.script.num import Num
5
- from sonolus.script.record import Record
6
-
7
-
8
- class Vec2(Record):
9
- x: float
10
- y: float
11
-
12
- @classmethod
13
- def zero(cls) -> Self:
14
- return cls(x=0, y=0)
15
-
16
- @classmethod
17
- def one(cls) -> Self:
18
- return cls(x=1, y=1)
19
-
20
- @classmethod
21
- def up(cls) -> Self:
22
- return cls(x=0, y=1)
23
-
24
- @classmethod
25
- def down(cls) -> Self:
26
- return cls(x=0, y=-1)
27
-
28
- @classmethod
29
- def left(cls) -> Self:
30
- return cls(x=-1, y=0)
31
-
32
- @classmethod
33
- def right(cls) -> Self:
34
- return cls(x=1, y=0)
35
-
36
- @property
37
- def magnitude(self) -> Num:
38
- return (self.x**2 + self.y**2) ** 0.5
39
-
40
- @property
41
- def angle(self) -> Num:
42
- return atan2(self.y, self.x)
43
-
44
- def dot(self, other: Self) -> Num:
45
- return self.x * other.x + self.y * other.y
46
-
47
- def rotate(self, angle: Num) -> Self:
48
- return Vec2(
49
- x=self.x * cos(angle) - self.y * sin(angle),
50
- y=self.x * sin(angle) + self.y * cos(angle),
51
- )
52
-
53
- @property
54
- def tuple(self) -> tuple[float, float]:
55
- return self.x, self.y
56
-
57
- def __add__(self, other: Self) -> Self:
58
- return Vec2(x=self.x + other.x, y=self.y + other.y)
59
-
60
- def __sub__(self, other: Self) -> Self:
61
- return Vec2(x=self.x - other.x, y=self.y - other.y)
62
-
63
- def __mul__(self, other: Self | float) -> Self:
64
- match other:
65
- case Vec2(x, y):
66
- return Vec2(x=self.x * x, y=self.y * y)
67
- case float() | int() as factor:
68
- return Vec2(x=self.x * factor, y=self.y * factor)
69
-
70
- def __truediv__(self, other: Self | float) -> Self:
71
- match other:
72
- case Vec2(x, y):
73
- return Vec2(x=self.x / x, y=self.y / y)
74
- case float() | int() as factor:
75
- return Vec2(x=self.x / factor, y=self.y / factor)
76
-
77
- def __neg__(self) -> Self:
78
- return Vec2(x=-self.x, y=-self.y)
1
+ from math import atan2, cos, sin
2
+ from typing import Self
3
+
4
+ from sonolus.script.num import Num
5
+ from sonolus.script.record import Record
6
+
7
+
8
+ class Vec2(Record):
9
+ """A 2D vector.
10
+
11
+ Usage:
12
+ ```python
13
+ Vec2(x: float, y: float)
14
+ ```
15
+ """
16
+
17
+ x: float
18
+ y: float
19
+
20
+ @classmethod
21
+ def zero(cls) -> Self:
22
+ """Return a vector with x and y set to 0.
23
+
24
+ Returns:
25
+ A new vector with x=0 and y=0.
26
+ """
27
+ return cls(x=0, y=0)
28
+
29
+ @classmethod
30
+ def one(cls) -> Self:
31
+ """Return a vector with x and y set to 1.
32
+
33
+ Returns:
34
+ A new vector with x=1 and y=1.
35
+ """
36
+ return cls(x=1, y=1)
37
+
38
+ @classmethod
39
+ def up(cls) -> Self:
40
+ """Return a vector pointing upwards (x=0, y=1).
41
+
42
+ Returns:
43
+ A new vector pointing upwards.
44
+ """
45
+ return cls(x=0, y=1)
46
+
47
+ @classmethod
48
+ def down(cls) -> Self:
49
+ """Return a vector pointing downwards (x=0, y=-1).
50
+
51
+ Returns:
52
+ A new vector pointing downwards.
53
+ """
54
+ return cls(x=0, y=-1)
55
+
56
+ @classmethod
57
+ def left(cls) -> Self:
58
+ """Return a vector pointing to the left (x=-1, y=0).
59
+
60
+ Returns:
61
+ A new vector pointing to the left.
62
+ """
63
+ return cls(x=-1, y=0)
64
+
65
+ @classmethod
66
+ def right(cls) -> Self:
67
+ """Return a vector pointing to the right (x=1, y=0).
68
+
69
+ Returns:
70
+ A new vector pointing to the right.
71
+ """
72
+ return cls(x=1, y=0)
73
+
74
+ @property
75
+ def magnitude(self) -> Num:
76
+ """Calculate the magnitude (length) of the vector.
77
+
78
+ Returns:
79
+ The magnitude of the vector.
80
+ """
81
+ return (self.x**2 + self.y**2) ** 0.5
82
+
83
+ @property
84
+ def angle(self) -> Num:
85
+ """Calculate the angle of the vector in radians from the positive x-axis.
86
+
87
+ Returns:
88
+ The angle of the vector in radians.
89
+ """
90
+ return atan2(self.y, self.x)
91
+
92
+ def dot(self, other: Self) -> Num:
93
+ """Calculate the dot product of this vector with another vector.
94
+
95
+ Args:
96
+ other: The other vector to calculate the dot product with.
97
+
98
+ Returns:
99
+ The dot product of the two vectors.
100
+ """
101
+ return self.x * other.x + self.y * other.y
102
+
103
+ def rotate(self, angle: Num) -> Self:
104
+ """Rotate the vector by a given angle in radians and return a new vector.
105
+
106
+ Args:
107
+ angle: The angle to rotate the vector by, in radians.
108
+
109
+ Returns:
110
+ A new vector rotated by the given angle.
111
+ """
112
+ return Vec2(
113
+ x=self.x * cos(angle) - self.y * sin(angle),
114
+ y=self.x * sin(angle) + self.y * cos(angle),
115
+ )
116
+
117
+ def rotate_about(self, angle: Num, pivot: Self) -> Self:
118
+ """Rotate the vector about a pivot by a given angle in radians and return a new vector.
119
+
120
+ Args:
121
+ angle: The angle to rotate the vector by, in radians.
122
+ pivot: The pivot point to rotate about.
123
+
124
+ Returns:
125
+ A new vector rotated about the pivot by the given angle.
126
+ """
127
+ return (self - pivot).rotate(angle) + pivot
128
+
129
+ @property
130
+ def tuple(self) -> tuple[float, float]:
131
+ """Return the vector as a tuple (x, y).
132
+
133
+ Returns:
134
+ A tuple representation of the vector.
135
+ """
136
+ return self.x, self.y
137
+
138
+ def __add__(self, other: Self) -> Self:
139
+ """Add this vector to another vector and return a new vector.
140
+
141
+ Args:
142
+ other: The vector to add.
143
+
144
+ Returns:
145
+ A new vector resulting from the addition.
146
+ """
147
+ return Vec2(x=self.x + other.x, y=self.y + other.y)
148
+
149
+ def __sub__(self, other: Self) -> Self:
150
+ """Subtract another vector from this vector and return a new vector.
151
+
152
+ Args:
153
+ other: The vector to subtract.
154
+
155
+ Returns:
156
+ A new vector resulting from the subtraction.
157
+ """
158
+ return Vec2(x=self.x - other.x, y=self.y - other.y)
159
+
160
+ def __mul__(self, other: Self | float) -> Self:
161
+ """Multiply this vector by another vector or a scalar and return a new vector.
162
+
163
+ Args:
164
+ other: The vector or scalar to multiply by.
165
+
166
+ Returns:
167
+ A new vector resulting from the multiplication.
168
+ """
169
+ match other:
170
+ case Vec2(x, y):
171
+ return Vec2(x=self.x * x, y=self.y * y)
172
+ case Num(factor):
173
+ return Vec2(x=self.x * factor, y=self.y * factor)
174
+
175
+ def __truediv__(self, other: Self | float) -> Self:
176
+ """Divide this vector by another vector or a scalar and return a new vector.
177
+
178
+ Args:
179
+ other: The vector or scalar to divide by.
180
+
181
+ Returns:
182
+ A new vector resulting from the division.
183
+ """
184
+ match other:
185
+ case Vec2(x, y):
186
+ return Vec2(x=self.x / x, y=self.y / y)
187
+ case Num(factor):
188
+ return Vec2(x=self.x / factor, y=self.y / factor)
189
+
190
+ def __neg__(self) -> Self:
191
+ """Negate the vector (invert the direction) and return a new vector.
192
+
193
+ Returns:
194
+ A new vector with inverted direction.
195
+ """
196
+ return Vec2(x=-self.x, y=-self.y)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sonolus.py
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: Sonolus engine development in Python
5
5
  Requires-Python: >=3.13
6
6
  Description-Content-Type: text/markdown
@@ -0,0 +1,89 @@
1
+ sonolus/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ sonolus/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ sonolus/backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ sonolus/backend/blocks.py,sha256=3peyb9eYBy0s53xNVJ1KmK4IgoyVkkwG-lqDQ_VZTHc,18531
5
+ sonolus/backend/excepthook.py,sha256=pqI9gtPBh0mlTgMNqul8bEVO1ARzKb8pNE9EN_CyDpk,994
6
+ sonolus/backend/finalize.py,sha256=XjFeJgpKLI5_vU-okhSXRVTv31BZrUGbnBG_ITr3wrU,3963
7
+ sonolus/backend/interpret.py,sha256=B0jqlLmEGoyO2mxpcvwRwV17Tq_gOE9wLNt26Q5QOfs,14306
8
+ sonolus/backend/ir.py,sha256=TCDLMvlX2S8emFDQwFVeD2OUC4fnhbrMObgYtoa_7PQ,2845
9
+ sonolus/backend/mode.py,sha256=NkcPZJm8dn83LX35uP24MtQOCnfRDFZ280dHeEEfauE,613
10
+ sonolus/backend/node.py,sha256=H8qgnNyIseR-DhfgtcbDX03SUmhAJSSrYAlUEJTkkUo,999
11
+ sonolus/backend/ops.py,sha256=ekkHSdgRubIYLSYFk0wTUuBvyf3TKdApM4AyR_koTQ8,10122
12
+ sonolus/backend/place.py,sha256=Z3yFx-Ki2z32MXsVb6TkZ_D95RyZCu8iJPQRXNiyiNg,2364
13
+ sonolus/backend/utils.py,sha256=9-mmCUwGlNdjp51jKrNBN2dGxCAXVV2PdJn031kaXHM,1717
14
+ sonolus/backend/visitor.py,sha256=a7cRdiM9g1fLuR8_BxOwRTDvtq3JNfE4k1JqZioiQyU,45756
15
+ sonolus/backend/optimize/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ sonolus/backend/optimize/allocate.py,sha256=LCqxvT8YsVGTaVAu58fb6lrrytVLWx1LNbcOfx8CqL8,5671
17
+ sonolus/backend/optimize/constant_evaluation.py,sha256=ty3vNey7I44GK17lQA-3whkioFQGleYKD3P5a22foj0,15997
18
+ sonolus/backend/optimize/copy_coalesce.py,sha256=vKeq1UYxA7cJq5HgP8HdsIACFPjNyK4m_asakm1SOZ4,3966
19
+ sonolus/backend/optimize/dead_code.py,sha256=qYmUqBmAp-O5mUpNusOoMEJVkbc9YIHx6Ynrg6dyNGY,8077
20
+ sonolus/backend/optimize/dominance.py,sha256=oTFUqN8twrw6lTzqr1nlYs-Gk1NzIa-4qGdEQvDGzlM,3217
21
+ sonolus/backend/optimize/flow.py,sha256=mMf5Um2uxwF65nw13UiIv7dFMHZZHnyWv2WaOVnGw2c,4266
22
+ sonolus/backend/optimize/inlining.py,sha256=jwTiuHivSq9bB7FfVbD9Wd_Ztaz8ml_5CRnikr2d6yU,5719
23
+ sonolus/backend/optimize/liveness.py,sha256=c0ejVf1LNcYBlByf3rxkNs18IoXmiOdCFwEk3Afv8DE,7121
24
+ sonolus/backend/optimize/optimize.py,sha256=oGPmsDD0FFNihhrpV9uSybkGHP3C_EU0Rpw6x7kvf8c,1329
25
+ sonolus/backend/optimize/passes.py,sha256=OPzcpFUU7qbQFSrgr84UuzDg_vB1GYkZj2K2aqGkkag,1643
26
+ sonolus/backend/optimize/simplify.py,sha256=Tz4RftjH5TpIxoIOwiZuLchsrwzI9GaS_exdjAW6HKk,7927
27
+ sonolus/backend/optimize/ssa.py,sha256=D3CQm3s3gcuU0_k_0pXVrwirm4xjAZsX6corrTDS1Co,9013
28
+ sonolus/build/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ sonolus/build/cli.py,sha256=YlWg3Jfe1gi2wnlIJDh8LCMLSPV3l9AiuDWk2Bbphmg,5812
30
+ sonolus/build/collection.py,sha256=IsDgedsAJ-foHzQ4LnQ9zSVXSz5wVVt4sgqiUICBvCU,10573
31
+ sonolus/build/compile.py,sha256=wBiRX6rnq8Op4_vVXJ-bPLtffgV4ppNBa9M9hIe9twI,3579
32
+ sonolus/build/engine.py,sha256=TAJCdSWOsEcTq9o6jfR3A2JZ8gOoc9YQx6FC_qW-dFw,6766
33
+ sonolus/build/level.py,sha256=3sdGPvIZ4a15u3-JdITnB6rznp6a2E3k6A0gB8A15JA,610
34
+ sonolus/build/node.py,sha256=jwsVWt6Brh4M9MypUt3Nqnxfm7fXrCMRWYQGwBTAszI,1162
35
+ sonolus/build/project.py,sha256=x350tPcwKCYakdbrP796b545hVUaBwrzY0yEcQR7ut4,4023
36
+ sonolus/script/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ sonolus/script/archetype.py,sha256=gYRkUD_hI_MhXA-diIObIp0xqpX6aNiPqWLhiw-t094,33887
38
+ sonolus/script/array.py,sha256=KJxyL4I7A-CNFQW1RbZYQGVI527XZmoesDR-q6BurB8,9339
39
+ sonolus/script/array_like.py,sha256=OVOLMadS-Jj941S-EgoxlFPdaQLT6ZrHzaMnKtB6PfU,8346
40
+ sonolus/script/bucket.py,sha256=ZNlNeBZ1FzRLQ49bTuuJDmnYZ-_sjQEvosySx3ESxQc,6944
41
+ sonolus/script/containers.py,sha256=tf0-UUSq8NH6k9jIKq6qgXRxanFQ0f5olH6uHghTynk,13171
42
+ sonolus/script/debug.py,sha256=ua8FM7h563ZMQp7oyjJRGzjjF0zi4xcnFhI3RgIdOSw,2443
43
+ sonolus/script/easing.py,sha256=7zaDKIfM_whUpb4FBz1DAF4NNG2vk_nDjl8kL2Y90aU,11396
44
+ sonolus/script/effect.py,sha256=kFshJhpVh5XiRPYms30vhry7_P6bQMVEkZ1K90jprgk,5830
45
+ sonolus/script/engine.py,sha256=WUCENp-G_12jN_QW-w1RJCJQrkyRbsVtB1z7OeNV2mQ,6975
46
+ sonolus/script/globals.py,sha256=Z8RfLkgDuXPIKiq-aOqblP0s__ALGmvcKdlyWZH21EM,9166
47
+ sonolus/script/instruction.py,sha256=PNfxC1dhT_hB0BxhDV3KXMn_kKxfI0t1iZmg8m6ddMU,6725
48
+ sonolus/script/interval.py,sha256=3wMy7YlL6XV0g7w3eIDQDXl1WfTjW4NunKtwRxRMnDQ,9004
49
+ sonolus/script/iterator.py,sha256=ZErUmpRrXISe1xiT3VOjHzcqqLhpfT9FI7Kz2s2vUpk,4163
50
+ sonolus/script/level.py,sha256=NuXr8SalXn4eMm00OOYfWPQ-EXhJIKVCtbiIKX2SGag,1872
51
+ sonolus/script/num.py,sha256=-u1wwFkPJYrJCjD8yE2DArrH3SMVKqQaHQhgVpd8EeA,13911
52
+ sonolus/script/options.py,sha256=nTOuoRC2p_qoMx4ngOVDY2WZDooTxwwGTGKyb994v2A,7516
53
+ sonolus/script/particle.py,sha256=K06ArT9tstRNdbuGIviDmDDWcK3-ieA53LHg0Xvizow,8304
54
+ sonolus/script/pointer.py,sha256=pOh5vCSl6xR7mDm5PMOhBc_wf4O-b938DE0LtZWBmPc,1119
55
+ sonolus/script/print.py,sha256=mNYu9QWiacBBGZrnePZQMVwbbguoelUps9GiOK_aVRU,2096
56
+ sonolus/script/project.py,sha256=iGdMEpT6mUcyTmfGwmIW25ucHB51ETd1_SyQ6UC7AYg,612
57
+ sonolus/script/quad.py,sha256=SVMcfRYx8Bv5t7A2vhus9QUiw-1V-qtRhldr3DnnNWw,7693
58
+ sonolus/script/record.py,sha256=rOVlo-eUUvFG_Ee-wKrgX_ZwOqWKWtS7s8m-juM70yE,11216
59
+ sonolus/script/runtime.py,sha256=xeiLJFeqkCev1x6pBiM5afyvi3GWdpLJ5OYRg9M9nwo,18562
60
+ sonolus/script/sprite.py,sha256=-hURLrLrxtu73qSQ4x4_gJqnJ3XiORUmNojh5fdm2E8,15732
61
+ sonolus/script/text.py,sha256=IsoINZJXefjReYDjJFwVaFsUCdgeQvPBDeywljM2dWo,13025
62
+ sonolus/script/timing.py,sha256=ZR0ypV2PIoDCMHHGOMfCeezStCsBQdzomdqaz5VKex0,2981
63
+ sonolus/script/transform.py,sha256=hH6KSRQC8vV-Z10CRCrGewMYqQwUMH3mQIEmniuC2Zw,10760
64
+ sonolus/script/ui.py,sha256=kyuP88sLRJPT-Yx-7fx8Xu9Wdegyw_CJNslcP4WnDUs,7268
65
+ sonolus/script/values.py,sha256=JuvJknskuY6FPprUp9R-6Gj2TDJLu4ppbVcYedG5dG0,1049
66
+ sonolus/script/vec.py,sha256=Uph6Z9xofwbKGZu0H7rl6fzlO4bj5i0cnWu4LQeIL4I,5270
67
+ sonolus/script/internal/__init__.py,sha256=T6rzLoiOUaiSQtaHMZ88SNO-ijSjSSv33TKtUwu-Ms8,136
68
+ sonolus/script/internal/builtin_impls.py,sha256=w27aKMhLX4Ivd7uKz1ZgVy1lC5scSSJ23-VfsbCfIb0,7731
69
+ sonolus/script/internal/callbacks.py,sha256=vWzJG8uiJoEtsNnbeZPqOHogCwoLpz2D1MnHY2wVV8s,2801
70
+ sonolus/script/internal/constant.py,sha256=lIBBR84Rfw0rBSZU2reCrUnB3yEMEdOX6A7_LgptYz8,3776
71
+ sonolus/script/internal/context.py,sha256=evLOXcOqskK5Gh5Je86ghKlMaon-Opi7dDoMtkCjEh8,13533
72
+ sonolus/script/internal/descriptor.py,sha256=XRFey-EjiAm_--KsNl-8N0Mi_iyQwlPh68gDp0pKf3E,392
73
+ sonolus/script/internal/dict_impl.py,sha256=alu_wKGSk1kZajNf64qbe7t71shEzD4N5xNIATH8Swo,1885
74
+ sonolus/script/internal/error.py,sha256=ZNnsvQVQAnFKzcvsm6-sste2lo-tP5pPI8sD7XlAZWc,490
75
+ sonolus/script/internal/generic.py,sha256=YU1hUJoBcGc0OSrFStK5JI6CikOwSmd_IR20pCuT82k,7310
76
+ sonolus/script/internal/impl.py,sha256=HKQVoHknw5t43Wmj_G1vFjGSmnFpOj1FUYnhbUM3rHc,2969
77
+ sonolus/script/internal/introspection.py,sha256=A0P2R2pNQTyj4N6-v-bCzuyIi7F-ST3qzQ3AM5l9P58,819
78
+ sonolus/script/internal/math_impls.py,sha256=7L450U7gW-jUkTWcQ1AMg9IX0yhu4G2WUsJ5xMZ8r3o,2306
79
+ sonolus/script/internal/native.py,sha256=XKlNnWSJ-lxbwVGWhGj_CSSoWsVN18imqT5sAsDJT1w,1551
80
+ sonolus/script/internal/random.py,sha256=6Ku5edRcDUh7rtqEEYCJz0BQavw69RALsVHS25z50pI,1695
81
+ sonolus/script/internal/range.py,sha256=lrTanQFHU7RuQxSSPwDdoC30Y8FnHGxcP1Ahditu3zU,2297
82
+ sonolus/script/internal/transient.py,sha256=pSDFGu0m26zVsp6owmNTeSPue-osDd1JahjJSijW8t0,1520
83
+ sonolus/script/internal/tuple_impl.py,sha256=vjXmScLVdeTkDn3t9fgIRqtW31iwngnaP2rmA6nlsLw,3431
84
+ sonolus/script/internal/value.py,sha256=ik9sMKl0TbsH_C6QNxD4WfpAnmBFISgmmlazWwh3kY0,4308
85
+ sonolus_py-0.1.5.dist-info/METADATA,sha256=HHVoPymf7iwqOCBJqIEMETzGgzgPIwEA3Owrjudj_a4,216
86
+ sonolus_py-0.1.5.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
87
+ sonolus_py-0.1.5.dist-info/entry_points.txt,sha256=oTYspY_b7SA8TptEMTDxh4-Aj-ZVPnYC9f1lqH6s9G4,54
88
+ sonolus_py-0.1.5.dist-info/licenses/LICENSE,sha256=JEKpqVhQYfEc7zg3Mj462sKbKYmO1K7WmvX1qvg9IJk,1067
89
+ sonolus_py-0.1.5.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.1
2
+ Generator: hatchling 1.26.3
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Kyle Chang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kyle Chang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,51 +0,0 @@
1
- from sonolus.backend.flow import BasicBlock, traverse_cfg_preorder
2
- from sonolus.backend.ir import IRConst, IRGet, IRInstr, IRPureInstr, IRSet
3
- from sonolus.backend.passes import CompilerPass
4
- from sonolus.backend.place import BlockPlace, TempBlock
5
-
6
-
7
- class AllocateBasic(CompilerPass):
8
- def run(self, entry: BasicBlock):
9
- offsets = {}
10
- index = 16
11
-
12
- def process(stmt):
13
- nonlocal index
14
- match stmt:
15
- case int():
16
- return stmt
17
- case IRConst():
18
- return stmt
19
- case IRPureInstr(op=op, args=args):
20
- return IRPureInstr(
21
- op=op,
22
- args=[process(arg) for arg in args],
23
- )
24
- case IRInstr(op=op, args=args):
25
- return IRInstr(
26
- op=op,
27
- args=[process(arg) for arg in args],
28
- )
29
- case IRGet(place=place):
30
- return IRGet(place=process(place))
31
- case IRSet(place=place, value=value):
32
- return IRSet(place=process(place), value=process(value))
33
- case BlockPlace() as place:
34
- if isinstance(place.block, TempBlock):
35
- if place.block not in offsets:
36
- offsets[place.block] = index
37
- index += place.block.size
38
- return BlockPlace(10000, process(place.index), place.offset + offsets[place.block])
39
- return BlockPlace(
40
- process(place.block) if isinstance(place.block, BlockPlace) else place.block,
41
- process(place.index),
42
- process(place.offset),
43
- )
44
- case _:
45
- raise NotImplementedError
46
-
47
- for block in traverse_cfg_preorder(entry):
48
- block.statements = [process(statement) for statement in block.statements]
49
- block.test = process(block.test)
50
-
51
- return entry
@@ -1,9 +0,0 @@
1
- from sonolus.backend.allocate import AllocateBasic
2
- from sonolus.backend.flow import BasicBlock
3
- from sonolus.backend.simplify import CoalesceFlow
4
-
5
-
6
- def optimize_and_allocate(cfg: BasicBlock):
7
- cfg = CoalesceFlow().run(cfg)
8
- cfg = AllocateBasic().run(cfg)
9
- return cfg
sonolus/backend/passes.py DELETED
@@ -1,6 +0,0 @@
1
- from sonolus.backend.flow import BasicBlock
2
-
3
-
4
- class CompilerPass:
5
- def run(self, entry: BasicBlock) -> BasicBlock:
6
- pass
@@ -1,30 +0,0 @@
1
- from sonolus.backend.flow import BasicBlock
2
- from sonolus.backend.passes import CompilerPass
3
-
4
-
5
- class CoalesceFlow(CompilerPass):
6
- def run(self, entry: BasicBlock) -> BasicBlock:
7
- queue = [entry]
8
- processed = set()
9
- while queue:
10
- block = queue.pop()
11
- if block in processed:
12
- continue
13
- processed.add(block)
14
- if len(block.outgoing) != 1:
15
- queue.extend(edge.dst for edge in block.outgoing)
16
- continue
17
- next_block = next(iter(block.outgoing)).dst
18
- if len(next_block.incoming) != 1:
19
- queue.append(next_block)
20
- continue
21
- block.statements.extend(next_block.statements)
22
- block.test = next_block.test
23
- for edge in next_block.outgoing:
24
- edge.src = block
25
- block.outgoing = next_block.outgoing
26
- processed.add(next_block)
27
- queue.extend(edge.dst for edge in block.outgoing)
28
- processed.remove(block)
29
- queue.append(block)
30
- return entry