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. */
| 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. */ |
| 2697 | static 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 | |
| 2730 | static void sh_walk(sh_t *s, TSNode n) { |
| 2731 | const char *t = ts_node_type(n); |
no test coverage detected