(closure: Closure, node: Node)
| 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(() => { |
no test coverage detected