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

Function unwrap_value

internal/cbm/extract_url_fold.c:301–321  ·  view source on GitHub ↗

Strip type wrappers and `Object.freeze(...)` from a constant's value. */

Source from the content-addressed store, hash-verified

299
300/* Strip type wrappers and `Object.freeze(...)` from a constant's value. */
301static TSNode unwrap_value(CBMExtractCtx *ctx, TSNode v) {
302 for (int i = 0; i < FOLD_MAX_OBJ_DEPTH && !ts_node_is_null(v); i++) {
303 const char *k = ts_node_type(v);
304 if (is_transparent_wrapper(k) && ts_node_named_child_count(v) > 0) {
305 v = ts_node_named_child(v, 0);
306 continue;
307 }
308 if (strcmp(k, "call_expression") != 0) {
309 break;
310 }
311 TSNode fn = ts_node_child_by_field_name(v, TS_FIELD("function"));
312 TSNode args = ts_node_child_by_field_name(v, TS_FIELD("arguments"));
313 const char *ft = ts_node_is_null(fn) ? NULL : cbm_node_text(ctx->arena, fn, ctx->source);
314 if (!ft || strcmp(ft, "Object.freeze") != 0 || ts_node_is_null(args) ||
315 ts_node_named_child_count(args) != SKIP_ONE) {
316 break;
317 }
318 v = ts_node_named_child(args, 0);
319 }
320 return v;
321}
322
323static void record_value(CBMExtractCtx *ctx, const char *name, TSNode value, int depth);
324

Callers 1

record_valueFunction · 0.85

Calls 2

is_transparent_wrapperFunction · 0.85
cbm_node_textFunction · 0.85

Tested by

no test coverage detected