(
self,
rtuple: RTuple,
tuple_expr_in_c: str,
c_type_compare_val: Callable[[RType], str],
compare: str,
*,
check_exception: bool = True,
)
| 514 | return f"{value} {compare} {self.c_error_value(rtype)}" |
| 515 | |
| 516 | def tuple_undefined_check_cond( |
| 517 | self, |
| 518 | rtuple: RTuple, |
| 519 | tuple_expr_in_c: str, |
| 520 | c_type_compare_val: Callable[[RType], str], |
| 521 | compare: str, |
| 522 | *, |
| 523 | check_exception: bool = True, |
| 524 | ) -> str: |
| 525 | if len(rtuple.types) == 0: |
| 526 | # empty tuple |
| 527 | return "{}.empty_struct_error_flag {} {}".format( |
| 528 | tuple_expr_in_c, compare, c_type_compare_val(int_rprimitive) |
| 529 | ) |
| 530 | if rtuple.error_overlap: |
| 531 | i = 0 |
| 532 | item_type = rtuple.types[0] |
| 533 | else: |
| 534 | for i, typ in enumerate(rtuple.types): |
| 535 | if not typ.error_overlap: |
| 536 | item_type = rtuple.types[i] |
| 537 | break |
| 538 | else: |
| 539 | assert False, "not expecting tuple with error overlap" |
| 540 | if isinstance(item_type, RTuple): |
| 541 | return self.tuple_undefined_check_cond( |
| 542 | item_type, tuple_expr_in_c + f".f{i}", c_type_compare_val, compare |
| 543 | ) |
| 544 | elif isinstance(item_type, RVec): |
| 545 | return f"{tuple_expr_in_c}.f{i}.len {compare} -1" |
| 546 | else: |
| 547 | check = f"{tuple_expr_in_c}.f{i} {compare} {c_type_compare_val(item_type)}" |
| 548 | if rtuple.error_overlap and check_exception: |
| 549 | check += " && PyErr_Occurred()" |
| 550 | return check |
| 551 | |
| 552 | def tuple_undefined_value(self, rtuple: RTuple) -> str: |
| 553 | """Undefined tuple value suitable in an expression.""" |
no test coverage detected