import type { AgencyNode, ScopeType } from "../../types.js"; import type { AccessChainElement } from "../../types/access.js"; import type { FunctionCall } from "../../types/function.js"; import type { TsNode } from "../../ir/tsIR.js"; /** * Callbacks AssignmentEmitter needs from the parent TypeScriptBuilder. * * Access chains and slice bounds can contain arbitrary expressions, so we * take the relevant builder routines as dependencies rather than holding * a reference to the whole builder. */ export type AssignmentEmitterDeps = { moduleId: string; processNode: (node: AgencyNode) => TsNode; buildCallDescriptor: (call: FunctionCall) => TsNode; buildStateConfig: () => TsNode | undefined; /** Resolve a relative block depth to the owning block's frame binding * (`__bframe_`), or undefined for the current block. */ resolveBlockFrameVar: (blockDepth: number) => string | undefined; }; /** * Encapsulates the construction of assignment LHS nodes and assignment * statements. This is the boring half of assignment lowering — building * `obj.foo[i] = value` style nodes from a scope + variable name + access * chain. * * The interesting / stateful half (handling llm calls, interrupts, async * function calls, message threads, etc.) stays in TypeScriptBuilder * because it touches most other subsystems; extracting it would not * meaningfully reduce coupling. * * Public API: * - {@link scopedAssign} — build a full assignment statement * (`lhs = value`, or `__ctx.globals.set(...)` for globals, or * `.splice(...)` for slice assignment) * - {@link lhs} — build just the assignment target node * - {@link accessChain} — apply an access chain to an arbitrary base * expression (used for `this.field = value` lowering) */ export declare class AssignmentEmitter { private deps; constructor(deps: AssignmentEmitterDeps); /** * Assign a value to a scoped variable. * * - Global scope, no access chain → `__ctx.globals.set(moduleId, name, value)` * - Slice as the last access element → array `.splice(...)` call * - Otherwise → ordinary `lhs = value` */ scopedAssign(scope: ScopeType, varName: string, value: TsNode, accessChain?: AccessChainElement[], blockDepth?: number): TsNode; /** Build the assignment target node (no value) for `scope.varName.chain`. */ lhs(scope: ScopeType, variableName: string, chain?: AccessChainElement[], blockDepth?: number): TsNode; /** * Apply an access chain (`.foo`, `[i]`, `.method(args)`) to an * arbitrary base expression. Used both for ordinary LHS construction * and for `this.field = value` / `super.field = value` lowering where * the base is a bare identifier rather than a scoped variable. */ accessChain(base: TsNode, chain?: AccessChainElement[]): TsNode; /** * Slice assignment lowering: * * arr[1:3] = [10, 20] → arr.splice(1, 3 - 1, ...[10, 20]) * arr[2:] = [10] → arr.splice(2, arr.length - 2, ...[10]) */ private sliceAssign; }