/** * The instructions whose behaviour is more than one line, lifted out of the * dispatch loop. * * Four of the forty-one have rules a reader has to be able to find: the two * history reads, the array subscript and the numeric `for`. Each is written * here as a plain function of what it needs, so the loop stays a switch that * can be read top to bottom and each rule sits beside the part of * `compiled-program.md` section 4 that states it. */ import type { Span } from '../span/index.js'; import type { Frame } from './frames.js'; import type { Memory } from './memory.js'; import type { Registers } from './registers.js'; import type { CompiledProgram, Constant, Instruction } from './types.js'; import type { Heap, Value } from './values/index.js'; /** What the operations below need from the machine, and nothing more. */ export interface Ops { readonly program: CompiledProgram; readonly registers: Registers; readonly memory: Memory; readonly heap: Heap; readonly slots: Value[]; here(): Span; barIndex(): number; } /** A pool entry as a machine value. Entries 0, 1 and 2 are fixed by 2.9. */ export declare function constantValueOf(held: Constant | undefined): Value; /** * `HIST`, resolved in the order 4.4 gives and in no other. * * Case 3 and case 4 are different on purpose. A depth past the start of the * dataset is absence, because the value never existed; a depth past the * retained history is OS4002, because it existed and the engine threw it away. * Returning absence for both would hide a real bug behind a plausible gap. */ export declare function historyRead(ops: Ops, register: number, back: Value): Value; /** `ELEM`: an index outside the array is a mistake, not a missing measurement. */ export declare function elementRead(ops: Ops, array: Value, index: Value): Value; /** * `FOR_INIT`: pops the step, then the limit, then the start, in that order. * * An absent bound is OS4013 rather than zero iterations. Treating absence as * "do not run" was rejected because a `for` loop whose bound is absent during * warmup would silently produce nothing and the script would look correct. */ export declare function forInit(ops: Ops, instruction: Instruction, frame: Frame): void; /** `FOR_NEXT`: advance, and jump back to the `TICK` when another turn is due. */ export declare function forNext(instruction: Instruction, frame: Frame): void; /** * The name a value goes by, for a diagnostic that has to say which array. * * The scan is over the named slots and cells of frame 0, which is where a * script's own names live. A value held only inside another object has no name * in the program, and the message says "the array" rather than inventing one: a * fix that named something the reader cannot find in their file is worse than a * fix that names nothing. */ export declare function nameOf(ops: Ops, value: Value): string; /** A value as a diagnostic has to print it. */ export declare function describe(value: Value): string; //# sourceMappingURL=operations.d.ts.map