MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / resolve_objectscript_callee

Function resolve_objectscript_callee

internal/cbm/extract_calls.c:3821–3863  ·  view source on GitHub ↗

Preserve ObjectScript's grammar/type-map resolution while feeding the invocation descriptor used by the exact callee-usage suppression pass.

Source from the content-addressed store, hash-verified

3819// Preserve ObjectScript's grammar/type-map resolution while feeding the
3820// invocation descriptor used by the exact callee-usage suppression pass.
3821static const char *resolve_objectscript_callee(CBMExtractCtx *ctx, TSNode node, WalkState *state,
3822 const char *callee) {
3823 if (!is_objectscript_language(ctx->language)) {
3824 return callee;
3825 }
3826
3827 const char *kind = ts_node_type(node);
3828 if ((!callee || !callee[0]) && strcmp(kind, "method_call") == 0) {
3829 callee =
3830 resolve_objectscript_instance_call(ctx->arena, node, ctx->source, &state->os_type_map);
3831 }
3832
3833 if ((!callee || !callee[0]) && strcmp(kind, "relative_dot_method") == 0 &&
3834 state->enclosing_class_qn && state->enclosing_class_qn[0]) {
3835 TSNode oref = cbm_find_child_by_kind(node, "oref_method");
3836 TSNode method_name =
3837 ts_node_is_null(oref) ? (TSNode){0} : cbm_find_child_by_kind(oref, "method_name");
3838 TSNode identifier =
3839 !ts_node_is_null(method_name) && ts_node_named_child_count(method_name) > 0
3840 ? ts_node_named_child(method_name, 0)
3841 : (TSNode){0};
3842 if (!ts_node_is_null(identifier)) {
3843 char *method = cbm_node_text(ctx->arena, identifier, ctx->source);
3844 if (method && method[0]) {
3845 callee = cbm_arena_sprintf(ctx->arena, "%s.%s", state->enclosing_class_qn, method);
3846 }
3847 }
3848 }
3849
3850 if (callee && strncmp(callee, "$$$", 3) == 0 && ctx->macro_table) {
3851 const CBMMacroEntry *entry = cbm_macro_table_find(ctx->macro_table, callee + 3);
3852 if (entry) {
3853 if (entry->resolved_callee) {
3854 callee = cbm_arena_strdup(ctx->arena, entry->resolved_callee);
3855 } else if (entry->expansion) {
3856 callee = cbm_macro_extract_callee(ctx->arena, entry->expansion);
3857 } else {
3858 callee = NULL;
3859 }
3860 }
3861 }
3862 return callee;
3863}
3864
3865static TSNode objectscript_call_args(TSNode node) {
3866 TSNode oref = cbm_find_child_by_kind(node, "oref_method");

Callers 1

select_primary_calleeFunction · 0.85

Calls 8

is_objectscript_languageFunction · 0.85
cbm_find_child_by_kindFunction · 0.85
cbm_node_textFunction · 0.85
cbm_macro_table_findFunction · 0.85
cbm_macro_extract_calleeFunction · 0.85
cbm_arena_sprintfFunction · 0.70
cbm_arena_strdupFunction · 0.70

Tested by

no test coverage detected