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

Function cbm_scope_bind_value

internal/cbm/lsp/scope.c:45–71  ·  view source on GitHub ↗

Returns false when the binding could NOT be recorded in THIS frame. * * The failure that matters is arena exhaustion in alloc_chunk: the old void * form returned silently, so a caller that then consulted the scope CHAIN saw * the parent's binding for the same name and concluded the child had been * bound. For callable-value proof that is a fabricated identity -- the shadow * never took effec

Source from the content-addressed store, hash-verified

43 * needing that distinction must use the checked form and consult the LOCAL
44 * result, not a chain lookup. */
45static bool cbm_scope_bind_value(CBMScope *scope, const char *name, const CBMType *type,
46 const char *callable_qn) {
47 if (!scope || !name) {
48 return false;
49 }
50 for (CBMScopeChunk* c = scope->chunks; c != NULL; c = c->next) {
51 for (int i = 0; i < c->used; i++) {
52 if (c->bindings[i].name && strcmp(c->bindings[i].name, name) == 0) {
53 c->bindings[i].type = type;
54 c->bindings[i].callable_qn = callable_qn;
55 return true;
56 }
57 }
58 }
59 CBMScopeChunk* head = scope->chunks;
60 if (!head || head->used >= CBM_SCOPE_CHUNK_BINDINGS) {
61 head = alloc_chunk(scope);
62 if (!head) {
63 return false; /* arena exhausted: the shadow did NOT take effect */
64 }
65 }
66 head->bindings[head->used].name = name;
67 head->bindings[head->used].type = type;
68 head->bindings[head->used].callable_qn = callable_qn;
69 head->used++;
70 return true;
71}
72
73void cbm_scope_bind(CBMScope *scope, const char *name, const CBMType *type) {
74 (void)cbm_scope_bind_value(scope, name, type, NULL);

Callers 4

cbm_scope_bindFunction · 0.85
cbm_scope_bind_checkedFunction · 0.85
cbm_scope_bind_callableFunction · 0.85

Calls 1

alloc_chunkFunction · 0.85

Tested by

no test coverage detected