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

Function c_binary_yields_bool

internal/cbm/lsp/c_lsp.c:1686–1708  ·  view source on GitHub ↗

A binary operator whose result is bool: c_eval_expr_type_inner returns * bool for it WITHOUT evaluating the left operand. Mirrors its operator test * (the first anonymous child's source text). */

Source from the content-addressed store, hash-verified

1684 * bool for it WITHOUT evaluating the left operand. Mirrors its operator test
1685 * (the first anonymous child's source text). */
1686static bool c_binary_yields_bool(const CLSPContext *ctx, TSNode node) {
1687 static const char *const bool_ops[] = {"==", "!=", "<", ">", "<=", ">=", "&&", "||"};
1688 uint32_t nc = ts_node_child_count(node);
1689 for (uint32_t i = 0; i < nc; i++) {
1690 TSNode child = ts_node_child(node, i);
1691 if (ts_node_is_named(child)) {
1692 continue;
1693 }
1694 uint32_t start = ts_node_start_byte(child);
1695 uint32_t end = ts_node_end_byte(child);
1696 if (end > (uint32_t)ctx->source_len) {
1697 return true; /* unreadable operator: do not pre-evaluate */
1698 }
1699 size_t len = end > start ? (size_t)(end - start) : 0;
1700 for (size_t k = 0; k < sizeof(bool_ops) / sizeof(bool_ops[0]); k++) {
1701 if (strlen(bool_ops[k]) == len && memcmp(ctx->source + start, bool_ops[k], len) == 0) {
1702 return true;
1703 }
1704 }
1705 return false;
1706 }
1707 return false;
1708}
1709
1710/* The chain operand of a link: the operand c_eval_expr_type_inner evaluates
1711 * first and unconditionally, whose type the link's type is derived from. A

Callers 1

c_chain_operandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected