MCPcopy Index your code
hub / github.com/python/mypy / GetElementPtr

Class GetElementPtr

mypyc/ir/ops.py:1723–1749  ·  view source on GitHub ↗

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 *.

Source from the content-addressed store, hash-verified

1721
1722@final
1723class 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

Callers 7

load_struct_fieldMethod · 0.90
set_struct_fieldMethod · 0.90
get_type_of_objMethod · 0.90
builtin_lenMethod · 0.90
test_get_element_ptrMethod · 0.90
list_itemsFunction · 0.90
var_object_sizeFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_get_element_ptrMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…