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

Function py_register_lambda

internal/cbm/lsp/py_lsp.c:825–850  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823/* ── lambda + dict-literal-dispatch registries ────────────────── */
824
825static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambda_node) {
826 if (!ctx || !name)
827 return;
828 if (ctx->lambda_count >= ctx->lambda_cap) {
829 int new_cap = ctx->lambda_cap == 0 ? 8 : ctx->lambda_cap * 2;
830 CBMLambdaEntry *grown =
831 (CBMLambdaEntry *)cbm_arena_alloc(ctx->arena, (size_t)new_cap * sizeof(CBMLambdaEntry));
832 if (!grown)
833 return;
834 if (ctx->lambdas && ctx->lambda_count > 0) {
835 memcpy(grown, ctx->lambdas, (size_t)ctx->lambda_count * sizeof(CBMLambdaEntry));
836 }
837 ctx->lambdas = grown;
838 ctx->lambda_cap = new_cap;
839 }
840 // Overwrite if name already registered.
841 for (int i = 0; i < ctx->lambda_count; i++) {
842 if (ctx->lambdas[i].name && strcmp(ctx->lambdas[i].name, name) == 0) {
843 ctx->lambdas[i].lambda_node = lambda_node;
844 return;
845 }
846 }
847 ctx->lambdas[ctx->lambda_count].name = cbm_arena_strdup(ctx->arena, name);
848 ctx->lambdas[ctx->lambda_count].lambda_node = lambda_node;
849 ctx->lambda_count++;
850}
851
852static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name) {
853 TSNode null_node = {0};

Callers 1

py_process_statementFunction · 0.85

Calls 2

cbm_arena_allocFunction · 0.50
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected