result = function(arg0, arg1, ...) Call a C function that is not a compiled/native function (for example, a Python C API function). Use Call to call native functions.
| 1251 | |
| 1252 | @final |
| 1253 | class CallC(RegisterOp): |
| 1254 | """result = function(arg0, arg1, ...) |
| 1255 | |
| 1256 | Call a C function that is not a compiled/native function (for |
| 1257 | example, a Python C API function). Use Call to call native |
| 1258 | functions. |
| 1259 | """ |
| 1260 | |
| 1261 | def __init__( |
| 1262 | self, |
| 1263 | function_name: str, |
| 1264 | args: list[Value], |
| 1265 | ret_type: RType, |
| 1266 | steals: StealsDescription, |
| 1267 | is_borrowed: bool, |
| 1268 | error_kind: int, |
| 1269 | line: int, |
| 1270 | var_arg_idx: int = -1, |
| 1271 | *, |
| 1272 | is_pure: bool = False, |
| 1273 | returns_null: bool = False, |
| 1274 | dependencies: list[Dependency] | None = None, |
| 1275 | ) -> None: |
| 1276 | self.error_kind = error_kind |
| 1277 | super().__init__(line) |
| 1278 | self.function_name = function_name |
| 1279 | self.args = args |
| 1280 | self.type = ret_type |
| 1281 | self.steals = steals |
| 1282 | self.is_borrowed = is_borrowed |
| 1283 | # The position of the first variable argument in args (if >= 0) |
| 1284 | self.var_arg_idx = var_arg_idx |
| 1285 | # Is the function pure? Pure functions have no side effects |
| 1286 | # and all the arguments are immutable. Pure functions support |
| 1287 | # additional optimizations. Pure functions never fail. |
| 1288 | self.is_pure = is_pure |
| 1289 | # The function might return a null value that does not indicate |
| 1290 | # an error. |
| 1291 | self.returns_null = returns_null |
| 1292 | # Dependencies (such as capsules) that must be imported and initialized before |
| 1293 | # calling this function (used for C functions exported from librt). |
| 1294 | self.dependencies = dependencies |
| 1295 | if is_pure or returns_null: |
| 1296 | assert error_kind == ERR_NEVER |
| 1297 | |
| 1298 | def sources(self) -> list[Value]: |
| 1299 | return self.args[:] |
| 1300 | |
| 1301 | def set_sources(self, new: list[Value]) -> None: |
| 1302 | self.args = new[:] |
| 1303 | |
| 1304 | def stolen(self) -> list[Value]: |
| 1305 | if isinstance(self.steals, list): |
| 1306 | assert len(self.steals) == len(self.args) |
| 1307 | return [arg for arg, steal in zip(self.args, self.steals) if steal] |
| 1308 | else: |
| 1309 | return [] if not self.steals else self.sources() |
| 1310 |
no outgoing calls
searching dependent graphs…