/** * Where every value the program holds is put: slots, cells, registers, * channels and state regions. * * `compiled-program.md` 2.10 and 2.11 describe three regions with three * lifetimes, and the checker has already decided which one each name belongs * to. What is left is the arithmetic: an index per name, per frame, in a table * an engine reads by position. That is all this file does, and keeping it out * of the passes that emit code is what stops an index being allocated twice in * one place and read as a different number in another. * * The one decision here rather than in the checker is the frame. Slots and cell * operands are relative to the frame that holds them, so a function body * numbers its own from zero and the call site supplies the base (2.12). A * single global counter would produce a program that runs correctly from one * call site and wrongly from the second. */ import type { Binding } from '../check/index.js'; import type { Cell, Channel, Register } from './program.js'; /** One frame's slots, its cells and the library state its body needs. */ export declare class FrameLayout { readonly slotNames: string[]; readonly cellNames: (string | null)[]; readonly cellKinds: ('var' | 'live')[]; /** Relative state index to the index into `lib.functions` that owns it. */ readonly stateFns: number[]; private readonly bindingSlot; private readonly bindingCell; /** A slot with no name in the source: a loop's limit, a step, a cursor. */ slot(name: string): number; slotFor(binding: Binding): number; hasSlotFor(binding: Binding): boolean; cellFor(binding: Binding): number; hasCellFor(binding: Binding): boolean; /** A per-call-site region for a stateful library call, relative to the base. */ state(libraryFunction: number): number; get slotCount(): number; } /** * The tables that are one per program rather than one per frame. * * A register, a channel and a library function entry are addressed the same way * from every frame, which is what lets a function body read a series and write * a plot column without knowing where it was called from. */ export declare class Layout { readonly registers: Register[]; readonly channels: Channel[]; readonly channelNames: string[]; private readonly barFields; private readonly bindingRegister; /** The register the engine fills from the host's bar, 2.10. One per field. */ bar(field: string): number; /** A top-level name whose history the program reads, written by `SSTORE`. */ computedFor(binding: Binding): number; hasComputedFor(binding: Binding): boolean; registerFor(binding: Binding): number | undefined; computed(name: string): number; /** A series argument retained for one call site, 2.10 and 4.10. */ argument(name: string): number; /** * A register the engine fills rather than the program, 2.10 and 2.16. * * A read's value per chart bar, and a setting a read's expression needs on * every requested bar. Neither is ever written by an instruction, which is * why neither is a `computed`. */ filled(kind: 'request' | 'input', name: string): number; channel(type: Channel['type'], defer: boolean, once: boolean, name: string): number; } /** The cells of one frame, as the program's `cells[]` carries them. */ export declare function cellsOf(frame: FrameLayout, base: number): Cell[]; //# sourceMappingURL=layout.d.ts.map