| 631 | // a detailed size build's traversals: a unifying node's Apply is its Allows, |
| 632 | // reporting only to a ctx |
| 633 | class UnifiedCompiler extends StandaloneCompiler { |
| 634 | override refToId(id: NodeId, opts?: ReferenceOptions): string { |
| 635 | const node = this.link.byId[id] |
| 636 | return super.refToId( |
| 637 | id, |
| 638 | node && (opts?.kind ?? this.trav) === "Apply" && this.unifies(node) ? |
| 639 | { ...opts, kind: "Allows" } |
| 640 | : opts |
| 641 | ) |
| 642 | } |
| 643 | |
| 644 | override needsCtxFor( |
| 645 | node: BaseNode, |
| 646 | kind: TraversalKind = this.trav |
| 647 | ): boolean { |
| 648 | return ( |
| 649 | (kind !== "Allows" || !this.unifies(node)) && |
| 650 | super.needsCtxFor(node, kind) |
| 651 | ) |
| 652 | } |
| 653 | |
| 654 | // a key's union value is applied by its own traversal, which allows unpassed |
| 655 | override failingSiteOf(): undefined {} |
| 656 | override failingApplyOf(): undefined {} |
| 657 | |
| 658 | // read where it fails, as a site is, so a unit needn't receive it. Each |
| 659 | // stops where it's passed no ctx, as failsAtKey does at a key |
| 660 | override failsSite(site: string, data: string, key?: string): string { |
| 661 | if (key === undefined) { |
| 662 | const failure = this.failureOf(site) |
| 663 | return failure === undefined ? |
| 664 | `runtime.failsAt(ctx, ${site}, ${data})` |
| 665 | : `runtime.failsWith(ctx, ${data}, ${failure})` |
| 666 | } |
| 667 | const keyed = this.keyFailureOf(site) |
| 668 | return keyed === undefined ? |
| 669 | `runtime.failsAtKey(ctx, ${site}, ${data}, ${key})` |
| 670 | : `runtime.failsKeyWith(ctx, ${data}, ${key}, ${keyed})` |
| 671 | } |
| 672 | |
| 673 | override failsIn(args: string): string { |
| 674 | return `runtime.failsIn(ctx, ${args})` |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | // by the members a unit was written with, which passes reaching it share |
| 679 | const unifiedMembers = new WeakMap<RootUnit["members"], RootUnit["members"]>() |
nothing calls this directly
no outgoing calls
no test coverage detected