Raise built-in exception with an optional error string. We have a separate opcode for this for convenience and to generate smaller, more idiomatic C code.
| 1210 | |
| 1211 | @final |
| 1212 | class RaiseStandardError(RegisterOp): |
| 1213 | """Raise built-in exception with an optional error string. |
| 1214 | |
| 1215 | We have a separate opcode for this for convenience and to |
| 1216 | generate smaller, more idiomatic C code. |
| 1217 | """ |
| 1218 | |
| 1219 | # TODO: Make it more explicit at IR level that this always raises |
| 1220 | |
| 1221 | error_kind = ERR_FALSE |
| 1222 | |
| 1223 | VALUE_ERROR: Final = "ValueError" |
| 1224 | ASSERTION_ERROR: Final = "AssertionError" |
| 1225 | STOP_ITERATION: Final = "StopIteration" |
| 1226 | UNBOUND_LOCAL_ERROR: Final = "UnboundLocalError" |
| 1227 | RUNTIME_ERROR: Final = "RuntimeError" |
| 1228 | NAME_ERROR: Final = "NameError" |
| 1229 | ZERO_DIVISION_ERROR: Final = "ZeroDivisionError" |
| 1230 | INDEX_ERROR: Final = "IndexError" |
| 1231 | |
| 1232 | def __init__(self, class_name: str, value: str | Value | None, line: int) -> None: |
| 1233 | super().__init__(line) |
| 1234 | self.class_name = class_name |
| 1235 | self.value = value |
| 1236 | self.type = bool_rprimitive |
| 1237 | |
| 1238 | def sources(self) -> list[Value]: |
| 1239 | return [] |
| 1240 | |
| 1241 | def set_sources(self, new: list[Value]) -> None: |
| 1242 | assert not new |
| 1243 | |
| 1244 | def accept(self, visitor: OpVisitor[T]) -> T: |
| 1245 | return visitor.visit_raise_standard_error(self) |
| 1246 | |
| 1247 | |
| 1248 | # True steals all arguments, False steals none, a list steals those in matching positions |
no outgoing calls
no test coverage detected
searching dependent graphs…