|
13 | 13 | from .. import setproctitle |
14 | 14 | from ..cache import SharedCache |
15 | 15 | from ..clock import BeatCounter, system_clock |
16 | | -from ..language.vm import log_vm_stats, ProgramInvalid |
| 16 | +from ..language.vm import log_vm_stats, StableChanged |
17 | 17 | from ..model import Vector, StateDict, Context, null, numbers_cache_counts, empty_numbers_cache |
18 | 18 | from ..plugins import get_plugin |
19 | 19 | from ..render.window.models import Model |
@@ -195,20 +195,27 @@ async def run(self): |
195 | 195 | run_program = current_program = program |
196 | 196 | self.handle_pragmas(program.pragmas, frame_time) |
197 | 197 | errors = logs = None |
| 198 | + stables = set() |
| 199 | + stable_cache = {} |
198 | 200 |
|
199 | 201 | now = system_clock() |
200 | 202 | housekeeping += now |
201 | 203 | execution -= now |
202 | 204 |
|
203 | 205 | if run_program is not None: |
204 | | - context = Context(names={key: Vector.coerce(value) for key, value in dynamic.items()}, |
205 | | - state=self.state, references=self._references, stables=stables, stable_cache=stable_cache) |
206 | | - try: |
207 | | - run_program.run(context, record_stats=self.vm_stats) |
208 | | - except ProgramInvalid: |
209 | | - logger.debug("Simplified program invalidated due to change of stable value") |
210 | | - run_program = current_program |
211 | | - run_program.run(context, record_stats=self.vm_stats) |
| 206 | + while True: |
| 207 | + context = Context(names={key: Vector.coerce(value) for key, value in dynamic.items()}, |
| 208 | + state=self.state, references=self._references, stables=stables, stable_cache=stable_cache) |
| 209 | + try: |
| 210 | + run_program.run(context, record_stats=self.vm_stats) |
| 211 | + except StableChanged as exc: |
| 212 | + if run_program is not current_program: |
| 213 | + logger.debug("Simplified program invalidated due to change of stable value") |
| 214 | + run_program = current_program |
| 215 | + else: |
| 216 | + raise RuntimeError("Compiled program contains unexpected StableAssert") from exc |
| 217 | + else: |
| 218 | + break |
212 | 219 | else: |
213 | 220 | context = Context() |
214 | 221 |
|
|
0 commit comments