Data-flow counter update: bump params_in_returns / params_in_conditions * when the current leaf identifier names a parameter and we're inside the * corresponding syntactic scope. */
| 215 | * when the current leaf identifier names a parameter and we're inside the |
| 216 | * corresponding syntactic scope. */ |
| 217 | static void accumulate_data_flow(TSNode node, const char *kind, uint32_t child_count, |
| 218 | const char *source, const char **param_names, int param_count, |
| 219 | bool in_return, bool in_condition, cbm_ast_profile_t *out) { |
| 220 | if (!(child_count == 0 && is_identifier(kind) && source)) { |
| 221 | return; |
| 222 | } |
| 223 | uint32_t start = ts_node_start_byte(node); |
| 224 | uint32_t end = ts_node_end_byte(node); |
| 225 | if (end <= start || (end - start) >= CBM_SZ_128) { |
| 226 | return; |
| 227 | } |
| 228 | char ident_buf[CBM_SZ_128]; |
| 229 | int ilen = (int)(end - start); |
| 230 | memcpy(ident_buf, source + start, (size_t)ilen); |
| 231 | ident_buf[ilen] = '\0'; |
| 232 | if (!is_param_name(ident_buf, source, param_names, param_count)) { |
| 233 | return; |
| 234 | } |
| 235 | if (in_return) { |
| 236 | out->params_in_returns++; |
| 237 | } |
| 238 | if (in_condition) { |
| 239 | out->params_in_conditions++; |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | bool cbm_ast_profile_compute(TSNode func_body, const char *source, const char **param_names, |
| 244 | int param_count, cbm_ast_profile_t *out) { |
no test coverage detected