sonolus.py 0.1.2__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.
- sonolus/backend/allocate.py +125 -51
- sonolus/backend/blocks.py +756 -756
- sonolus/backend/coalesce.py +85 -0
- sonolus/backend/constant_evaluation.py +374 -0
- sonolus/backend/dead_code.py +80 -0
- sonolus/backend/dominance.py +111 -0
- sonolus/backend/excepthook.py +37 -37
- sonolus/backend/finalize.py +69 -69
- sonolus/backend/flow.py +121 -92
- sonolus/backend/inlining.py +150 -0
- sonolus/backend/ir.py +5 -3
- sonolus/backend/liveness.py +173 -0
- sonolus/backend/mode.py +24 -24
- sonolus/backend/node.py +40 -40
- sonolus/backend/ops.py +197 -197
- sonolus/backend/optimize.py +37 -9
- sonolus/backend/passes.py +52 -6
- sonolus/backend/simplify.py +47 -30
- sonolus/backend/ssa.py +187 -0
- sonolus/backend/utils.py +48 -48
- sonolus/backend/visitor.py +892 -880
- sonolus/build/cli.py +7 -1
- sonolus/build/compile.py +88 -90
- sonolus/build/engine.py +55 -5
- sonolus/build/level.py +24 -23
- sonolus/build/node.py +43 -43
- sonolus/script/archetype.py +23 -6
- sonolus/script/array.py +2 -2
- sonolus/script/bucket.py +191 -191
- sonolus/script/callbacks.py +127 -115
- sonolus/script/comptime.py +1 -1
- sonolus/script/containers.py +23 -0
- sonolus/script/debug.py +19 -3
- sonolus/script/easing.py +323 -0
- sonolus/script/effect.py +131 -131
- sonolus/script/engine.py +37 -1
- sonolus/script/globals.py +269 -269
- sonolus/script/graphics.py +200 -150
- sonolus/script/instruction.py +151 -0
- sonolus/script/internal/__init__.py +5 -5
- sonolus/script/internal/builtin_impls.py +144 -144
- sonolus/script/internal/context.py +12 -4
- sonolus/script/internal/descriptor.py +17 -17
- sonolus/script/internal/introspection.py +14 -14
- sonolus/script/internal/native.py +40 -38
- sonolus/script/internal/value.py +3 -3
- sonolus/script/interval.py +120 -112
- sonolus/script/iterator.py +214 -211
- sonolus/script/math.py +30 -1
- sonolus/script/num.py +1 -1
- sonolus/script/options.py +191 -191
- sonolus/script/particle.py +157 -157
- sonolus/script/pointer.py +30 -30
- sonolus/script/{preview.py → print.py} +81 -81
- sonolus/script/random.py +14 -0
- sonolus/script/range.py +58 -58
- sonolus/script/record.py +3 -3
- sonolus/script/runtime.py +45 -6
- sonolus/script/sprite.py +333 -333
- sonolus/script/text.py +407 -407
- sonolus/script/timing.py +42 -42
- sonolus/script/transform.py +77 -23
- sonolus/script/ui.py +160 -160
- sonolus/script/vec.py +81 -72
- {sonolus_py-0.1.2.dist-info → sonolus_py-0.1.4.dist-info}/METADATA +1 -2
- sonolus_py-0.1.4.dist-info/RECORD +84 -0
- {sonolus_py-0.1.2.dist-info → sonolus_py-0.1.4.dist-info}/WHEEL +1 -1
- {sonolus_py-0.1.2.dist-info → sonolus_py-0.1.4.dist-info}/licenses/LICENSE +21 -21
- sonolus/build/defaults.py +0 -32
- sonolus/script/icon.py +0 -73
- sonolus_py-0.1.2.dist-info/RECORD +0 -76
- {sonolus_py-0.1.2.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}
|
|
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
|
@@ -18,6 +18,7 @@ from sonolus.script.globals import (
|
|
|
18
18
|
_runtime_particle_transform,
|
|
19
19
|
_runtime_skin_transform,
|
|
20
20
|
_runtime_touch_array,
|
|
21
|
+
_tutorial_instruction,
|
|
21
22
|
_tutorial_runtime_environment,
|
|
22
23
|
_tutorial_runtime_ui,
|
|
23
24
|
_tutorial_runtime_ui_configuration,
|
|
@@ -181,6 +182,37 @@ class RuntimeUiLayout(Record):
|
|
|
181
182
|
self.background = background
|
|
182
183
|
|
|
183
184
|
|
|
185
|
+
class BasicRuntimeUiLayout(Record):
|
|
186
|
+
anchor: Vec2
|
|
187
|
+
pivot: Vec2
|
|
188
|
+
dimensions: Vec2
|
|
189
|
+
rotation: float
|
|
190
|
+
alpha: float
|
|
191
|
+
background: bool
|
|
192
|
+
|
|
193
|
+
def update(
|
|
194
|
+
self,
|
|
195
|
+
anchor: Vec2 | None = None,
|
|
196
|
+
pivot: Vec2 | None = None,
|
|
197
|
+
dimensions: Vec2 | None = None,
|
|
198
|
+
rotation: float | None = None,
|
|
199
|
+
alpha: float | None = None,
|
|
200
|
+
background: bool | None = None,
|
|
201
|
+
):
|
|
202
|
+
if anchor is not None:
|
|
203
|
+
self.anchor = anchor
|
|
204
|
+
if pivot is not None:
|
|
205
|
+
self.pivot = pivot
|
|
206
|
+
if dimensions is not None:
|
|
207
|
+
self.dimensions = dimensions
|
|
208
|
+
if rotation is not None:
|
|
209
|
+
self.rotation = rotation
|
|
210
|
+
if alpha is not None:
|
|
211
|
+
self.alpha = alpha
|
|
212
|
+
if background is not None:
|
|
213
|
+
self.background = background
|
|
214
|
+
|
|
215
|
+
|
|
184
216
|
@_play_runtime_ui
|
|
185
217
|
class _PlayRuntimeUi:
|
|
186
218
|
menu: RuntimeUiLayout
|
|
@@ -208,16 +240,16 @@ class _WatchRuntimeUi:
|
|
|
208
240
|
|
|
209
241
|
@_preview_runtime_ui
|
|
210
242
|
class _PreviewRuntimeUi:
|
|
211
|
-
menu:
|
|
212
|
-
progress:
|
|
243
|
+
menu: BasicRuntimeUiLayout
|
|
244
|
+
progress: BasicRuntimeUiLayout
|
|
213
245
|
|
|
214
246
|
|
|
215
247
|
@_tutorial_runtime_ui
|
|
216
248
|
class _TutorialRuntimeUi:
|
|
217
|
-
menu:
|
|
218
|
-
previous:
|
|
219
|
-
next:
|
|
220
|
-
instruction:
|
|
249
|
+
menu: BasicRuntimeUiLayout
|
|
250
|
+
previous: BasicRuntimeUiLayout
|
|
251
|
+
next: BasicRuntimeUiLayout
|
|
252
|
+
instruction: BasicRuntimeUiLayout
|
|
221
253
|
|
|
222
254
|
|
|
223
255
|
class Touch(Record):
|
|
@@ -276,6 +308,7 @@ class _SkinTransform:
|
|
|
276
308
|
a12=Num(values[1 * 4 + 3]),
|
|
277
309
|
a20=Num(values[3 * 4 + 0]),
|
|
278
310
|
a21=Num(values[3 * 4 + 1]),
|
|
311
|
+
a22=Num(values[3 * 4 + 3]),
|
|
279
312
|
)
|
|
280
313
|
|
|
281
314
|
|
|
@@ -296,6 +329,7 @@ class _ParticleTransform:
|
|
|
296
329
|
a12=Num(values[1 * 4 + 3]),
|
|
297
330
|
a20=Num(values[3 * 4 + 0]),
|
|
298
331
|
a21=Num(values[3 * 4 + 1]),
|
|
332
|
+
a22=Num(values[3 * 4 + 3]),
|
|
299
333
|
)
|
|
300
334
|
|
|
301
335
|
|
|
@@ -392,6 +426,11 @@ class _LevelLife:
|
|
|
392
426
|
self.consecutive_good_step = consecutive_good_step
|
|
393
427
|
|
|
394
428
|
|
|
429
|
+
@_tutorial_instruction
|
|
430
|
+
class _TutorialInstruction:
|
|
431
|
+
text_id: int
|
|
432
|
+
|
|
433
|
+
|
|
395
434
|
@meta_fn
|
|
396
435
|
def is_debug() -> bool:
|
|
397
436
|
if not ctx():
|