Accumulate Halstead operator/operand counts. Leaf identifiers, literals, * and booleans are "operands"; recognized statement/expression kinds are * "operators". Uses an open-addressed hash set for unique counting. */
| 194 | * and booleans are "operands"; recognized statement/expression kinds are |
| 195 | * "operators". Uses an open-addressed hash set for unique counting. */ |
| 196 | static void accumulate_halstead(const char *kind, uint32_t child_count, uint32_t *op_set, |
| 197 | uint32_t *operand_set, cbm_ast_profile_t *out) { |
| 198 | if (is_operator_node(kind)) { |
| 199 | out->total_operators++; |
| 200 | if (halstead_insert(op_set, kind)) { |
| 201 | out->unique_operators++; |
| 202 | } |
| 203 | } |
| 204 | if (child_count == 0 && |
| 205 | (is_identifier(kind) || is_string_lit(kind) || is_number_lit(kind) || is_bool_lit(kind))) { |
| 206 | out->total_operands++; |
| 207 | if (halstead_insert(operand_set, kind)) { |
| 208 | out->unique_operands++; |
| 209 | } |
| 210 | out->body_tokens++; |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | /* Data-flow counter update: bump params_in_returns / params_in_conditions |
| 215 | * when the current leaf identifier names a parameter and we're inside the |
no test coverage detected