MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / requiredFeatures

Function requiredFeatures

src/compute-engine/fungrim/loader.ts:544–561  ·  view source on GitHub ↗

The features (named heads/symbols) that must appear somewhere in any * expression the pattern can match with `useVariations: false`.

(pattern: Expression)

Source from the content-addressed store, hash-verified

542}
543
544/** The features (named heads/symbols) that must appear somewhere in any
545 * expression the pattern can match with `useVariations: false`. */
546function requiredFeatures(pattern: Expression): ReadonlyArray<string> {
547 const out = new Set<string>();
548 const walk = (p: Expression): void => {
549 const sym = (p as { symbol?: string }).symbol;
550 if (sym !== undefined) {
551 if (!sym.startsWith('_')) out.add(FEATURE_SYM_PREFIX + sym);
552 return;
553 }
554 const ops = (p as { ops?: ReadonlyArray<Expression> }).ops;
555 if (ops === undefined) return; // number/string literal: not required
556 const op = p.operator;
557 if (!op.startsWith('_') && !CROSS_HEAD_PATTERN_OPS.has(op))
558 out.add(FEATURE_OP_PREFIX + op);
559 for (const x of ops) walk(x);
560 };
561 walk(pattern);
562 return [...out];
563}
564

Callers 1

wrapHotHeadRuleFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected