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

Method functionStandIn

ark/aot/interpreter.ts:2780–2809  ·  view source on GitHub ↗
(closure: Closure, node: Node)

Source from the content-addressed store, hash-verified

2778 }
2779
2780 private functionStandIn(closure: Closure, node: Node): object {
2781 // one stand-in per expression, however often it's evaluated
2782 const evaluated = !closure.env && this.standInsByNode.get(closure.node)
2783 if (evaluated) return evaluated
2784 const arity = parameterCount(closure.node)
2785 const name = this.holeNameOf(
2786 closure.node,
2787 closure.module,
2788 declaredNameOf(closure.node)
2789 )
2790 const standIn = createStandIn("function", closure.module, node, {
2791 closure,
2792 arity
2793 })
2794 const target =
2795 closure.node.type === "ArrowFunctionExpression" ?
2796 createArrowTarget()
2797 : createClassTarget(undefined)
2798 if (name) this.standInsByName.set(name, standIn)
2799 const proxy = Interpreter.createStandInProxy({
2800 kind: "function",
2801 target,
2802 length: arity,
2803 name
2804 })
2805 this.standIns.set(proxy, standIn)
2806 proveFunction(proxy as Fn, closure.node, this.opts.runtime !== "arktype")
2807 if (!closure.env) this.standInsByNode.set(closure.node, proxy)
2808 return proxy
2809 }
2810
2811 traceOf<t>(f: () => t): [result: t, trace: Trace] {
2812 return this.withActive(() => {

Callers 2

evaluateNodeMethod · 0.95
bindingValueMethod · 0.95

Calls 10

holeNameOfMethod · 0.95
declaredNameOfFunction · 0.90
proveFunctionFunction · 0.90
parameterCountFunction · 0.85
createStandInFunction · 0.85
createArrowTargetFunction · 0.85
createClassTargetFunction · 0.85
createStandInProxyMethod · 0.80
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected