| 2730 | } |
| 2731 | |
| 2732 | static const char **extract_param_names(CBMArena *a, TSNode params, const char *source, |
| 2733 | CBMLanguage lang) { |
| 2734 | (void)lang; |
| 2735 | if (ts_node_is_null(params)) { |
| 2736 | return NULL; |
| 2737 | } |
| 2738 | |
| 2739 | const char *names[MAX_PARAMS]; |
| 2740 | int count = 0; |
| 2741 | |
| 2742 | uint32_t nc = ts_node_child_count(params); |
| 2743 | for (uint32_t i = 0; i < nc && count < MAX_PARAMS_MINUS_1; i++) { |
| 2744 | TSNode param = ts_node_child(params, i); |
| 2745 | if (ts_node_is_null(param) || !ts_node_is_named(param)) { |
| 2746 | continue; |
| 2747 | } |
| 2748 | |
| 2749 | char *name_text = resolve_param_name(a, param, source); |
| 2750 | |
| 2751 | if (name_text && name_text[0]) { |
| 2752 | names[count++] = name_text; |
| 2753 | } |
| 2754 | } |
| 2755 | |
| 2756 | if (count == 0) { |
| 2757 | return NULL; |
| 2758 | } |
| 2759 | |
| 2760 | const char **result = |
| 2761 | (const char **)cbm_arena_alloc(a, (count + NULL_TERM) * sizeof(const char *)); |
| 2762 | for (int i = 0; i < count; i++) { |
| 2763 | result[i] = names[i]; |
| 2764 | } |
| 2765 | result[count] = NULL; |
| 2766 | return result; |
| 2767 | } |
| 2768 | |
| 2769 | // Extract return_types from a return type node. |
| 2770 | // Parses Go-style multi-return (T1, T2) and single return types. |
no test coverage detected