(
self,
rtype: RType,
attr_expr: str,
compare: str,
obj: str,
attr: str,
cl: ClassIR,
*,
unlikely: bool = False,
)
| 478 | self.emit_line("}") |
| 479 | |
| 480 | def emit_undefined_attr_check( |
| 481 | self, |
| 482 | rtype: RType, |
| 483 | attr_expr: str, |
| 484 | compare: str, |
| 485 | obj: str, |
| 486 | attr: str, |
| 487 | cl: ClassIR, |
| 488 | *, |
| 489 | unlikely: bool = False, |
| 490 | ) -> None: |
| 491 | check = self.error_value_check(rtype, attr_expr, compare) |
| 492 | if unlikely: |
| 493 | check = f"unlikely({check})" |
| 494 | if rtype.error_overlap: |
| 495 | index = cl.bitmap_attrs.index(attr) |
| 496 | bit = 1 << (index & (BITMAP_BITS - 1)) |
| 497 | attr = self.bitmap_field(index) |
| 498 | obj_expr = f"({cl.struct_name(self.names)} *){obj}" |
| 499 | check = f"{check} && !(({obj_expr})->{attr} & {bit})" |
| 500 | self.emit_line(f"if ({check}) {{") |
| 501 | |
| 502 | def error_value_check(self, rtype: RType, value: str, compare: str) -> str: |
| 503 | if isinstance(rtype, RTuple): |
no test coverage detected