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

Function sh_function

src/pipeline/pass_shell.c:2697–2728  ·  view source on GitHub ↗

A function body, read where it is defined: its locals stay inside; the * globals it sets and a directory it changes are unknown after it. */

Source from the content-addressed store, hash-verified

2695/* A function body, read where it is defined: its locals stay inside; the
2696 * globals it sets and a directory it changes are unknown after it. */
2697static void sh_function(sh_t *s, TSNode n) {
2698 TSNode body = ts_node_child_by_field_name(n, TS_FIELD("body"));
2699 if (ts_node_is_null(body)) {
2700 return;
2701 }
2702 sh_mark_t m = sh_mark(s);
2703 s->in_func++;
2704 if (sh_type(body, "compound_statement")) {
2705 sh_walk_children(s, body);
2706 } else {
2707 sh_walk(s, body);
2708 }
2709 s->in_func--;
2710 sh_touch_t t = {0};
2711 CBMHashTable *locals = cbm_ht_create(0);
2712 for (int i = m.undo; locals && i < s->nundo; i++) {
2713 if (s->undo[i].local) {
2714 cbm_ht_set(locals, s->undo[i].name, (void *)s->undo[i].name);
2715 }
2716 }
2717 for (int i = m.undo; i < s->nundo; i++) {
2718 if (!locals || !cbm_ht_get(locals, s->undo[i].name)) {
2719 sh_touch_add(&t, s->undo[i].name);
2720 }
2721 }
2722 if (locals) {
2723 cbm_ht_free(locals);
2724 }
2725 t.cwd = !sh_cwd_same(s->cwd, m.cwd) || s->ndirs != m.ndirs;
2726 sh_rewind(s, m);
2727 sh_group_end(s, &t);
2728}
2729
2730static void sh_walk(sh_t *s, TSNode n) {
2731 const char *t = ts_node_type(n);

Callers 1

sh_walkFunction · 0.85

Calls 12

sh_markFunction · 0.85
sh_typeFunction · 0.85
sh_walk_childrenFunction · 0.85
sh_walkFunction · 0.85
cbm_ht_createFunction · 0.85
cbm_ht_setFunction · 0.85
cbm_ht_getFunction · 0.85
sh_touch_addFunction · 0.85
cbm_ht_freeFunction · 0.85
sh_cwd_sameFunction · 0.85
sh_rewindFunction · 0.85
sh_group_endFunction · 0.85

Tested by

no test coverage detected