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

Function accumulate_halstead

src/semantic/ast_profile.c:196–212  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

194 * and booleans are "operands"; recognized statement/expression kinds are
195 * "operators". Uses an open-addressed hash set for unique counting. */
196static 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

Callers 1

cbm_ast_profile_computeFunction · 0.85

Calls 6

is_operator_nodeFunction · 0.85
halstead_insertFunction · 0.85
is_identifierFunction · 0.85
is_string_litFunction · 0.85
is_number_litFunction · 0.85
is_bool_litFunction · 0.85

Tested by

no test coverage detected