Read a memory location: result = *(type *)src. Attributes: type: Type of the read value src: Pointer to memory to read
| 1635 | |
| 1636 | @final |
| 1637 | class LoadMem(RegisterOp): |
| 1638 | """Read a memory location: result = *(type *)src. |
| 1639 | |
| 1640 | Attributes: |
| 1641 | type: Type of the read value |
| 1642 | src: Pointer to memory to read |
| 1643 | """ |
| 1644 | |
| 1645 | error_kind = ERR_NEVER |
| 1646 | |
| 1647 | def __init__(self, type: RType, src: Value, line: int = -1, *, borrow: bool = False) -> None: |
| 1648 | super().__init__(line) |
| 1649 | self.type = type |
| 1650 | # TODO: Support other native integer types |
| 1651 | assert is_pointer_rprimitive(src.type) |
| 1652 | self.src = src |
| 1653 | self.is_borrowed = borrow and type.is_refcounted |
| 1654 | |
| 1655 | def sources(self) -> list[Value]: |
| 1656 | return [self.src] |
| 1657 | |
| 1658 | def set_sources(self, new: list[Value]) -> None: |
| 1659 | (self.src,) = new |
| 1660 | |
| 1661 | def accept(self, visitor: OpVisitor[T]) -> T: |
| 1662 | return visitor.visit_load_mem(self) |
| 1663 | |
| 1664 | |
| 1665 | @final |
no outgoing calls
searching dependent graphs…