def guessexception(self, ctx, *cases): block = self.crnt_block bvars = vars = vars2 = block.getvariables() links = [] for case in [None] + list(cases): if case is not None: assert block.operations[-1].result is bvars[-1] vars = bvars[:-1] vars2 = bvars[:-1] if case is Exception: last_exc = Variable('last_exception') else: last_exc = Constant(case) last_exc_value = Variable('last_exc_value') vars.extend([last_exc, last_exc_value]) vars2.extend([Variable(), Variable()]) egg = EggBlock(vars2, block, case) ctx.pendingblocks.append(egg) link = Link(vars, egg, case) if case is not None: link.extravars(last_exception=last_exc, last_exc_value=last_exc_value) egg.extravars(last_exception=last_exc) links.append(link) block.exitswitch = c_last_exception block.closeblock(*links) raise StopFlowing
def guessexception(self, ctx, *cases): block = self.crnt_block links = [] for case in [None] + list(cases): if case is not None: if case is Exception: last_exc = Variable('last_exception') else: last_exc = Constant(case) last_exc_value = Variable('last_exc_value') vars = [last_exc, last_exc_value] vars2 = [Variable(), Variable()] else: vars = [] vars2 = [] egg = EggBlock(vars2, block, case) ctx.pendingblocks.append(egg) link = Link(vars, egg, case) if case is not None: link.extravars(last_exception=last_exc, last_exc_value=last_exc_value) egg.extravars(last_exception=last_exc) links.append(link) block.exitswitch = c_last_exception block.closeblock(*links) raise StopFlowing