fix(extract): string-dispatch CALLS edges never emitted — detection was in dead code#447
fix(extract): string-dispatch CALLS edges never emitted — detection was in dead code#447isc-tdyar wants to merge 1 commit into
Conversation
…o target
Python calls of the form iris_obj.classMethodValue('Pkg.Class', 'Method')
emitted no CALLS edge. The detection existed in walk_calls, which is dead
code — the pipeline uses cbm_extract_unified → handle_calls, not walk_calls.
Move the IRIS Native API string-dispatch detection to handle_calls. When a
Python call's callee ends in .classMethodValue, .classMethodVoid,
.classMethodBoolean, or .classMethodObject, and both string-literal arguments
can be extracted, emit a synthetic CALLS edge to Arg1.Arg2.
The pattern generalizes beyond this specific API: any library that takes
class/method names as string literals follows the same shape.
Regression test: python_iris_classMethodValue in test_extraction.c.
Signed-off-by: Thomas Dyar <tdyar@intersystems.com>
|
Thanks for the contribution — and for the clean, signed-off commits. Will review properly when time allows. One heads-up on CI: everything is green except |
|
Great, thanks! As a heads-up, I have some actual feature additions in the hopper - I spent time recently adding support for ObjectScript, InterSystems proprietary but well-established language that is tied to our database technology. I will be following the CONTRIBUTING guidelines with an issue submission, but at a high level I propose adding CBM_LANG_OBJECTSCRIPT to lang_specs.c and supporting infrastructure for specifics of that language. I hope this will be something that is viewed as a positive for CBMM, and I am willing to shape it however it can fit within the wider team's conception of "good code" :) |
String-dispatch CALLS edges never emitted — detection was in dead code
Discovered while indexing a Python codebase that uses string-literal method dispatch — calls of the form:
where the class and method are passed as string literals rather than referenced directly. These produced no CALLS edge in the graph. The callee appeared as an anonymous call with no link to the target.
This pattern appears in Python reflection libraries, plugin systems, and RPC frameworks — any API that takes a class name and method name as strings and dispatches dynamically.
Root cause
The string-dispatch detection existed in
walk_calls()inextract_calls.c. Butwalk_callsis dead code — the pipeline callscbm_extract_unified()→handle_calls(), nevercbm_extract_calls()/walk_calls()directly. The detection logic was never reachable during normal indexing.Fix
Move the detection into
handle_calls(), immediately after the standard CALLS edge is pushed. When a Python call's callee name ends in one of the four dispatch suffixes (.classMethodValue,.classMethodVoid,.classMethodBoolean,.classMethodObject) and both string-literal arguments can be extracted, emit a synthetic CALLS edge toArg0.Arg1.Also adds
extract_nth_string_arg()— a small helper to extract the N-th string-literal positional argument from an argument list node.The suffix list is easily extended for other APIs that follow the same shape.
Regression test
python_iris_classMethodValueintests/test_extraction.c— indexes a minimal Python snippet using.classMethodValue('Pkg.Class', 'Method', ...)and asserts a CALLS edge toPkg.Class.Methodis emitted.