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:169–195  ·  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

167 * needing that distinction must use the checked form and consult the LOCAL
168 * result, not a chain lookup. */
169static bool cbm_scope_bind_value(CBMScope *scope, const char *name, const CBMType *type,
170 const char *callable_qn) {
171 if (!scope || !name) {
172 return false;
173 }
174 CBMVarBinding *existing = scope_frame_find(scope, name);
175 if (existing) {
176 existing->type = type;
177 existing->callable_qn = callable_qn;
178 return true;
179 }
180 CBMScopeChunk* head = scope->chunks;
181 if (!head || head->used >= CBM_SCOPE_CHUNK_BINDINGS) {
182 head = alloc_chunk(scope);
183 if (!head) {
184 return false; /* arena exhausted: the shadow did NOT take effect */
185 }
186 }
187 CBMVarBinding *b = &head->bindings[head->used];
188 b->name = name;
189 b->type = type;
190 b->callable_qn = callable_qn;
191 head->used++;
192 scope->binding_count++;
193 scope_index_note(scope, b);
194 return true;
195}
196
197void cbm_scope_bind(CBMScope *scope, const char *name, const CBMType *type) {
198 (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 3

scope_frame_findFunction · 0.85
alloc_chunkFunction · 0.85
scope_index_noteFunction · 0.85

Tested by

no test coverage detected