/** * bodySlots — the single source of truth for "which fields of a node hold * statements". The statement-body twin of `expressionChildren` (node.ts). * * Consumed by: * - `mapBodies` (mapBodies.ts) — immutable rewrite of every body * - `walkNodes` (node.ts) — read descent into every body * * Adding a new body-bearing node type means adding ONE case here; both * consumers pick it up. Before this existed, each consumer hand-listed the * node types and they drifted (mapBodies missed `messageThread`, then * `withModifier`/`staticStatement` — each miss silently skipped lowering). * * Class methods are intentionally NOT included — classes are being removed * from the language. Add them here if that decision is reversed. * * The expression/statement seam (mirrored in expressionSlots.ts): some * expressions also own statement bodies — a thread block in value * position, a call with a block argument. The rule: when a consumer * walks an expression and that node has bodySlots, its statement bodies * are reached through THIS table, never through expression slots. An * ifElse contributes only its condition to expressionSlots; its * branches are statement bodies here, even in the value-position form * pattern lowering rewrites at parse time. */ import type { AgencyNode } from "../types.js"; import type { BlockArgument } from "../types/blockArgument.js"; export type BodySlot = { /** Statements at this slot. A read view — never mutate it in place. */ body: AgencyNode[]; /** Set on slots that wrap a single statement field (`with ...` / * `static ...`): a rewrite must map the one statement to exactly one. */ single?: boolean; /** Extra ancestor between the owner and the body during walks — the * functionCall's `block:` argument (inline or not). */ blockAncestor?: BlockArgument; /** True when a `return` inside this slot's body yields to the slot's * own closure rather than the enclosing def: block arguments (the * __block_N lifting), inline handler bodies (their own arrow), and * finalize bodies (the __finalize closure). guardDesugar's return- * target rule keys on this — a new return-retargeting construct * must set it here or that feature silently mis-stamps. */ retargetsReturn?: boolean; /** Fresh copy of `owner` with this slot's statements replaced. Takes the * CURRENT owner (not the node bodySlots was called on) so a fold over * several slots composes: each write builds on the previous one. */ write: (owner: AgencyNode, body: AgencyNode[]) => AgencyNode; }; /** Immediate statement bodies of `node`, each with an immutable writer. * Returns `[]` for nodes that carry no statements. Shallow by design: * consumers drive their own recursion. */ export declare function bodySlots(node: AgencyNode): BodySlot[];