MCPcopy Create free account
hub / github.com/python/mypy / SetElement

Class SetElement

mypyc/ir/ops.py:1753–1782  ·  view source on GitHub ↗

Set the value of a struct element. This evaluates to a new struct with the changed value. Use together with Undef to initialize a fresh struct value (see Undef for more details).

Source from the content-addressed store, hash-verified

1751
1752@final
1753class SetElement(RegisterOp):
1754 """Set the value of a struct element.
1755
1756 This evaluates to a new struct with the changed value.
1757
1758 Use together with Undef to initialize a fresh struct value
1759 (see Undef for more details).
1760 """
1761
1762 error_kind = ERR_NEVER
1763
1764 def __init__(self, src: Value, field: str, item: Value, line: int = -1) -> None:
1765 super().__init__(line)
1766 assert isinstance(src.type, (RStruct, RVec)), src.type
1767 self.type = src.type
1768 self.src = src
1769 self.item = item
1770 self.field = field
1771
1772 def sources(self) -> list[Value]:
1773 return [self.src]
1774
1775 def set_sources(self, new: list[Value]) -> None:
1776 (self.src,) = new
1777
1778 def stolen(self) -> list[Value]:
1779 return [self.src]
1780
1781 def accept(self, visitor: OpVisitor[T]) -> T:
1782 return visitor.visit_set_element(self)
1783
1784
1785@final

Callers 3

convert_to_t_ext_itemFunction · 0.90
convert_from_t_ext_itemFunction · 0.90
test_set_elementMethod · 0.90

Calls

no outgoing calls

Tested by 1

test_set_elementMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…