MCPcopy Create free account
hub / github.com/arktypeio/arktype / keptCallsIn

Function keptCallsIn

ark/aot/flat.ts:531–563  ·  view source on GitHub ↗
(module: SourceModule, kept: KeptCode)

Source from the content-addressed store, hash-verified

529}
530
531const keptCallsIn = (module: SourceModule, kept: KeptCode) => {
532 const result: {
533 statement: Node
534 declaration: Extract<Node, { type: "VariableDeclaration" }>
535 call: Call
536 }[] = []
537 for (const statement of module.program.body) {
538 const declaration =
539 statement.type === "ExportNamedDeclaration" ?
540 statement.declaration
541 : statement
542 if (
543 declaration?.type !== "VariableDeclaration" ||
544 !kept.statements.has(statement)
545 )
546 continue
547 for (const { init } of declaration.declarations) {
548 const call = init && unwrapExpression(init)
549 if (call?.type !== "CallExpression") continue
550 // a validator held with what sets the cells it reads
551 const held = call.arguments[0]
552 result.push({
553 statement,
554 declaration,
555 call:
556 isHeldCall(call, module) && held?.type === "CallExpression" ?
557 held
558 : call
559 })
560 }
561 }
562 return result
563}
564
565// if it reads only units and runtime members that don't change after load, as configuration may
566const creatorFnOf = (module: SourceModule): string | undefined => {

Callers 2

creationsInFunction · 0.85
keptAnnotationsInFunction · 0.85

Calls 4

unwrapExpressionFunction · 0.90
isHeldCallFunction · 0.85
hasMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected