| 82 | branch_op_names: Final = {Branch.BOOL: ("%r", "bool"), Branch.IS_ERROR: ("is_error(%r)", "")} |
| 83 | |
| 84 | def visit_branch(self, op: Branch) -> str: |
| 85 | fmt, typ = self.branch_op_names[op.op] |
| 86 | if op.negated: |
| 87 | fmt = f"not {fmt}" |
| 88 | |
| 89 | cond = self.format(fmt, op.value) |
| 90 | tb = "" |
| 91 | if op.traceback_entry: |
| 92 | tb = " (error at %s:%d)" % op.traceback_entry |
| 93 | fmt = f"if {cond} goto %l{tb} else goto %l" |
| 94 | if typ: |
| 95 | fmt += f" :: {typ}" |
| 96 | return self.format(fmt, op.true, op.false) |
| 97 | |
| 98 | def visit_return(self, op: Return) -> str: |
| 99 | return self.format("return %r", op.value) |