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

Function gc_local

src/pipeline/pass_operator.c:1465–1502  ·  view source on GitHub ↗

A local assigned exactly once in the enclosing function, before the call. */

Source from the content-addressed store, hash-verified

1463
1464/* A local assigned exactly once in the enclosing function, before the call. */
1465static bool gc_local(const gc_scope_t *sc, const char *name, size_t nl, const char **vs,
1466 size_t *vlen) {
1467 if (!sc->body) {
1468 return false;
1469 }
1470 int seen = 0;
1471 for (const char *p = sc->body; p < sc->body_end;) {
1472 const char *q = gc_skip(p);
1473 if (q != p) {
1474 p = q;
1475 continue;
1476 }
1477 if (strncmp(p, name, nl) == 0 && (p == sc->body || !op_ident_char(p[-SKIP_ONE])) &&
1478 !op_ident_char(p[nl]) && p[-SKIP_ONE] != '.') {
1479 const char *a = p + nl;
1480 while (*a == ' ' || *a == '\t') {
1481 a++;
1482 }
1483 if (a[0] && strchr("+-*/%|&^", a[0]) && a[SKIP_ONE] == '=') {
1484 return false; /* modified in place */
1485 }
1486 bool assign =
1487 (a[0] == ':' && a[SKIP_ONE] == '=') || (a[0] == '=' && a[SKIP_ONE] != '=');
1488 if (assign) {
1489 if (++seen > SKIP_ONE || p > sc->at) {
1490 return false;
1491 }
1492 const char *v = a + (a[0] == ':' ? PAIR_LEN : SKIP_ONE);
1493 const char *le = strchr(v, '\n');
1494 le = le ? le : v + strlen(v);
1495 *vs = v;
1496 *vlen = (size_t)(op_comment_start(v, le) - v);
1497 }
1498 }
1499 p++;
1500 }
1501 return seen == SKIP_ONE;
1502}
1503
1504static void gc_const_value(const gc_scope_t *sc, const char *dir, const char *name, int depth,
1505 gc_val_t *out) {

Callers 1

gc_evalFunction · 0.85

Calls 3

gc_skipFunction · 0.85
op_ident_charFunction · 0.85
op_comment_startFunction · 0.85

Tested by

no test coverage detected