Call method using the vectorcall API if possible. Return the return value if successful. Return None if a non-vectorcall API should be used instead.
(
self,
obj: Value,
method_name: str,
arg_values: list[Value],
line: int,
arg_kinds: list[ArgKind] | None,
arg_names: Sequence[str | None] | None,
)
| 1236 | return self.py_call(method, arg_values, line, arg_kinds=arg_kinds, arg_names=arg_names) |
| 1237 | |
| 1238 | def _py_vector_method_call( |
| 1239 | self, |
| 1240 | obj: Value, |
| 1241 | method_name: str, |
| 1242 | arg_values: list[Value], |
| 1243 | line: int, |
| 1244 | arg_kinds: list[ArgKind] | None, |
| 1245 | arg_names: Sequence[str | None] | None, |
| 1246 | ) -> Value | None: |
| 1247 | """Call method using the vectorcall API if possible. |
| 1248 | |
| 1249 | Return the return value if successful. Return None if a non-vectorcall |
| 1250 | API should be used instead. |
| 1251 | """ |
| 1252 | if arg_kinds is None or all( |
| 1253 | not kind.is_star() and not kind.is_optional() for kind in arg_kinds |
| 1254 | ): |
| 1255 | method_name_reg = self.load_str(method_name) |
| 1256 | coerced_args = [ |
| 1257 | self.coerce(arg, object_rprimitive, line) for arg in [obj] + arg_values |
| 1258 | ] |
| 1259 | arg_ptr = self.setup_rarray(object_rprimitive, coerced_args, line, object_ptr=True) |
| 1260 | num_pos = num_positional_args(arg_values, arg_kinds) |
| 1261 | keywords = self._vectorcall_keywords(arg_names) |
| 1262 | value = self.call_c( |
| 1263 | py_vectorcall_method_op, |
| 1264 | [ |
| 1265 | method_name_reg, |
| 1266 | arg_ptr, |
| 1267 | Integer((num_pos + 1) | PY_VECTORCALL_ARGUMENTS_OFFSET, c_size_t_rprimitive), |
| 1268 | keywords, |
| 1269 | ], |
| 1270 | line, |
| 1271 | ) |
| 1272 | # Make sure arguments won't be freed until after the call. |
| 1273 | # We need this because RArray doesn't support automatic |
| 1274 | # memory management. |
| 1275 | self.add(KeepAlive(coerced_args, line)) |
| 1276 | return value |
| 1277 | return None |
| 1278 | |
| 1279 | def call( |
| 1280 | self, |
no test coverage detected