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

Function push_pre_node_scope

internal/cbm/extract_unified.c:2252–2297  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2250}
2251
2252static bool push_pre_node_scope(CBMExtractCtx *ctx, TSNode node, const CBMLangSpec *spec,
2253 WalkState *state, uint32_t depth) {
2254 for (int i = 0; i < state->scope_top; i++) {
2255 if (state->scopes[i].kind == SCOPE_FUNC) {
2256 return false;
2257 }
2258 }
2259
2260 TSNode label = {0};
2261 if (ctx->language == CBM_LANG_NASM && strcmp(ts_node_type(node), "actual_instruction") == 0) {
2262 label = nasm_preceding_label(node);
2263 } else if (ctx->language == CBM_LANG_OBJECTSCRIPT_ROUTINE) {
2264 if (strcmp(ts_node_type(node), "tag_statement") == 0) {
2265 /* A parameterized flat tag owns its header as well as the following
2266 * sibling command statements. Anchor before descending so its
2267 * parameter_list records lexical bindings under the same tag QN. */
2268 label = cbm_find_child_by_kind(node, "tag");
2269 } else {
2270 label = objectscript_routine_preceding_tag(node);
2271 }
2272 }
2273 if (ts_node_is_null(label)) {
2274 return false;
2275 }
2276 const char *fqn = compute_func_qn(ctx, label, spec, state);
2277 if (!fqn) {
2278 return false;
2279 }
2280 uint32_t anchor_start = ts_node_start_byte(label);
2281 uint32_t anchor_end = ts_node_end_byte(label);
2282 bool same_flat_callable = state->flat_function_scope_id != 0 &&
2283 state->flat_anchor_start_byte == anchor_start &&
2284 state->flat_anchor_end_byte == anchor_end &&
2285 state->flat_function_qn && strcmp(state->flat_function_qn, fqn) == 0;
2286 bool pushed = same_flat_callable
2287 ? push_existing_lexical_scope(state, SCOPE_FUNC, depth, fqn,
2288 state->flat_function_scope_id, node)
2289 : push_function_scope(state, depth, fqn, node);
2290 if (pushed && !same_flat_callable) {
2291 state->flat_function_scope_id = state->scopes[state->scope_top - SKIP_ONE].lexical_scope_id;
2292 state->flat_anchor_start_byte = anchor_start;
2293 state->flat_anchor_end_byte = anchor_end;
2294 state->flat_function_qn = fqn;
2295 }
2296 return pushed;
2297}
2298
2299static bool unified_kind_in_set(const char *kind, const char *const *set) {
2300 for (int i = 0; kind && set && set[i]; i++) {

Callers 1

cbm_extract_unifiedFunction · 0.85

Calls 6

nasm_preceding_labelFunction · 0.85
cbm_find_child_by_kindFunction · 0.85
compute_func_qnFunction · 0.85
push_function_scopeFunction · 0.85

Tested by

no test coverage detected