Fixed-length C array type (for example, int[5]). Note that the implementation is a bit limited, and these can basically be only used for local variables that are initialized in one location.
| 1205 | |
| 1206 | @final |
| 1207 | class RArray(RType): |
| 1208 | """Fixed-length C array type (for example, int[5]). |
| 1209 | |
| 1210 | Note that the implementation is a bit limited, and these can basically |
| 1211 | be only used for local variables that are initialized in one location. |
| 1212 | """ |
| 1213 | |
| 1214 | def __init__(self, item_type: RType, length: int) -> None: |
| 1215 | self.item_type = item_type |
| 1216 | # Number of items |
| 1217 | self.length = length |
| 1218 | self.is_refcounted = False |
| 1219 | |
| 1220 | def accept(self, visitor: RTypeVisitor[T]) -> T: |
| 1221 | return visitor.visit_rarray(self) |
| 1222 | |
| 1223 | @property |
| 1224 | def may_be_immortal(self) -> bool: |
| 1225 | return False |
| 1226 | |
| 1227 | def __str__(self) -> str: |
| 1228 | return f"{self.item_type}[{self.length}]" |
| 1229 | |
| 1230 | def __repr__(self) -> str: |
| 1231 | return f"<RArray {self.item_type!r}[{self.length}]>" |
| 1232 | |
| 1233 | def __eq__(self, other: object) -> TypeGuard[RArray]: |
| 1234 | return ( |
| 1235 | isinstance(other, RArray) |
| 1236 | and self.item_type == other.item_type |
| 1237 | and self.length == other.length |
| 1238 | ) |
| 1239 | |
| 1240 | def __hash__(self) -> int: |
| 1241 | return hash((self.item_type, self.length)) |
| 1242 | |
| 1243 | def serialize(self) -> JsonDict: |
| 1244 | assert False |
| 1245 | |
| 1246 | @classmethod |
| 1247 | def deserialize(cls, data: JsonDict, ctx: DeserMaps) -> RArray: |
| 1248 | assert False |
| 1249 | |
| 1250 | |
| 1251 | PyObject = RStruct( |
no outgoing calls
searching dependent graphs…