Get the address of a struct element from a pointer to a struct. If you have a struct value, use GetElement instead. Note that you may need to use KeepAlive to avoid the struct being freed, if it's reference counted, such as PyObject *.
| 1721 | |
| 1722 | @final |
| 1723 | class GetElementPtr(RegisterOp): |
| 1724 | """Get the address of a struct element from a pointer to a struct. |
| 1725 | |
| 1726 | If you have a struct value, use GetElement instead. |
| 1727 | |
| 1728 | Note that you may need to use KeepAlive to avoid the struct |
| 1729 | being freed, if it's reference counted, such as PyObject *. |
| 1730 | """ |
| 1731 | |
| 1732 | error_kind = ERR_NEVER |
| 1733 | |
| 1734 | def __init__(self, src: Value, src_type: RType, field: str, line: int = -1) -> None: |
| 1735 | super().__init__(line) |
| 1736 | assert not isinstance(src.type, (RStruct, RVec)) |
| 1737 | self.type = pointer_rprimitive |
| 1738 | self.src = src |
| 1739 | self.src_type = src_type |
| 1740 | self.field = field |
| 1741 | |
| 1742 | def sources(self) -> list[Value]: |
| 1743 | return [self.src] |
| 1744 | |
| 1745 | def set_sources(self, new: list[Value]) -> None: |
| 1746 | (self.src,) = new |
| 1747 | |
| 1748 | def accept(self, visitor: OpVisitor[T]) -> T: |
| 1749 | return visitor.visit_get_element_ptr(self) |
| 1750 | |
| 1751 | |
| 1752 | @final |
no outgoing calls
searching dependent graphs…