* How each arm ends, decided after its body is known: an arm whose last item * answers the request ends with the reply — the strongest thing a reader can * be told about an endpoint's arm — and otherwise the arm keeps how its code * leaves, read at the site.
(input: ProgramInput, block: WireBlock)
| 377 | * leaves, read at the site. |
| 378 | */ |
| 379 | function seal(input: ProgramInput, block: WireBlock): void { |
| 380 | for (const item of block) { |
| 381 | if (item.kind === 'fork') { |
| 382 | // A switch's head is the thing being decided on, which only its arms |
| 383 | // together say: every case was written `<subject> === <value>`. |
| 384 | if (item.form === 'switch') item.on = subjectOf(item.arms.map((a) => a.when)); |
| 385 | for (const arm of item.arms) { |
| 386 | seal(input, arm.body); |
| 387 | if (repliesLast(input, arm.body)) arm.ends = 'reply'; |
| 388 | } |
| 389 | } else if (item.kind === 'block') seal(input, item.body); |
| 390 | else if (item.kind === 'step' && item.body) seal(input, item.body); |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | /** |
| 395 | * What every arm of a switch is deciding on: the longest start they share, cut |
no test coverage detected