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

Class Truncate

mypyc/ir/ops.py:1316–1343  ·  view source on GitHub ↗

result = truncate src from src_type to dst_type Truncate a value from type with more bits to type with less bits. dst_type and src_type can be native integer types, bools or tagged integers. Tagged integers should have the tag bit unset.

Source from the content-addressed store, hash-verified

1314
1315@final
1316class Truncate(RegisterOp):
1317 """result = truncate src from src_type to dst_type
1318
1319 Truncate a value from type with more bits to type with less bits.
1320
1321 dst_type and src_type can be native integer types, bools or tagged
1322 integers. Tagged integers should have the tag bit unset.
1323 """
1324
1325 error_kind = ERR_NEVER
1326
1327 def __init__(self, src: Value, dst_type: RType, line: int = -1) -> None:
1328 super().__init__(line)
1329 self.src = src
1330 self.type = dst_type
1331 self.src_type = src.type
1332
1333 def sources(self) -> list[Value]:
1334 return [self.src]
1335
1336 def set_sources(self, new: list[Value]) -> None:
1337 (self.src,) = new
1338
1339 def stolen(self) -> list[Value]:
1340 return []
1341
1342 def accept(self, visitor: OpVisitor[T]) -> T:
1343 return visitor.visit_truncate(self)
1344
1345
1346@final

Callers 7

translate_i32Function · 0.90
translate_i16Function · 0.90
translate_u8Function · 0.90
coerce_i64_to_ssize_tMethod · 0.90
call_cMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…