IRIS embedded Python names the target class in the receiver: iris.cls("Pkg.Class").Method(...) calls ClassMethod Pkg.Class.Method. Returns "Pkg.Class.Method", or NULL unless the receiver is iris.cls() with a string-literal first argument. A non-literal class names nothing, so it gets no class-qualified callee rather than a guessed one.
| 2398 | // a string-literal first argument. A non-literal class names nothing, so it |
| 2399 | // gets no class-qualified callee rather than a guessed one. |
| 2400 | static const char *python_iris_cls_callee(CBMExtractCtx *ctx, TSNode call_node) { |
| 2401 | TSNode fn = ts_node_child_by_field_name(call_node, TS_FIELD("function")); |
| 2402 | if (ts_node_is_null(fn) || strcmp(ts_node_type(fn), "attribute") != 0) { |
| 2403 | return NULL; |
| 2404 | } |
| 2405 | TSNode recv = ts_node_child_by_field_name(fn, TS_FIELD("object")); |
| 2406 | TSNode meth = ts_node_child_by_field_name(fn, TS_FIELD("attribute")); |
| 2407 | if (ts_node_is_null(recv) || ts_node_is_null(meth) || strcmp(ts_node_type(recv), "call") != 0) { |
| 2408 | return NULL; |
| 2409 | } |
| 2410 | TSNode recv_fn = ts_node_child_by_field_name(recv, TS_FIELD("function")); |
| 2411 | TSNode recv_args = ts_node_child_by_field_name(recv, TS_FIELD("arguments")); |
| 2412 | if (ts_node_is_null(recv_fn) || ts_node_is_null(recv_args) || |
| 2413 | ts_node_named_child_count(recv_args) == 0) { |
| 2414 | return NULL; |
| 2415 | } |
| 2416 | const char *recv_text = cbm_node_text(ctx->arena, recv_fn, ctx->source); |
| 2417 | if (!recv_text || strcmp(recv_text, "iris.cls") != 0) { |
| 2418 | return NULL; |
| 2419 | } |
| 2420 | TSNode cls_arg = ts_node_named_child(recv_args, 0); |
| 2421 | if (!is_string_like(ts_node_type(cls_arg))) { |
| 2422 | return NULL; |
| 2423 | } |
| 2424 | // Plain quoted literals only: an f-string or other prefixed string is a |
| 2425 | // "string" node too, but its text is not a class name. |
| 2426 | char *cls_text = cbm_node_text(ctx->arena, cls_arg, ctx->source); |
| 2427 | if (!cls_text || (cls_text[0] != '"' && cls_text[0] != '\'')) { |
| 2428 | return NULL; |
| 2429 | } |
| 2430 | const char *cls = strip_and_validate_string_arg(ctx->arena, cls_text); |
| 2431 | const char *mth = cbm_node_text(ctx->arena, meth, ctx->source); |
| 2432 | if (!cls || !cls[0] || !mth || !mth[0]) { |
| 2433 | return NULL; |
| 2434 | } |
| 2435 | return cbm_arena_sprintf(ctx->arena, "%s.%s", cls, mth); |
| 2436 | } |
| 2437 | |
| 2438 | // --- Unified handler: called once per node by the cursor walk --- |
| 2439 |
no test coverage detected