def __eval__(self, context: Context): forked = context.fork(symbols=context.symbols.fork( opaque=False)) if self.fork_context else context try: if self.create_stack_frame: return self.body.eval(forked) else: return self.body.child.eval(forked) finally: context.join(forked)
def values(self, context: Context): condition_value = self.condition.eval(context) while condition_value: forked = context.fork(symbols=context.symbols.fork(opaque=False)) yield self.body.eval(forked) context.join(forked) condition_value = self.condition.eval(context)
def __eval__(self, context: Context, assignment: bool = False): if self.expression is None: return None forked = context.fork() value = self.expression.eval(forked) if isinstance(value, Music): return Music(self.get_events(context, forked, value)) else: context.join(forked) return value
def get_events(self, context: Context, forked: Context, value: Music): try: for event in value.expand(context): yield event finally: context.join(forked)