vba-interpreter 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +96 -2
- package/dist/contract-CBGNXslV.d.ts +226 -0
- package/dist/exec/index.d.ts +12 -0
- package/dist/exec/index.js +1 -0
- package/dist/exec-DYWJe-eU.js +306 -0
- package/dist/exec-DYWJe-eU.js.map +1 -0
- package/dist/index-DnrotnmB.d.ts +2015 -0
- package/dist/index-DtaSNo0V.d.ts +111 -0
- package/dist/index-DyoT9JOJ.d.ts +4 -0
- package/dist/index-gM7FYTaq.d.ts +1353 -0
- package/dist/index-zKYgEJdV.d.ts +900 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +3 -0
- package/dist/interp/index.d.ts +10 -0
- package/dist/interp/index.js +1 -0
- package/dist/interp-ChrsgBCf.js +3433 -0
- package/dist/interp-ChrsgBCf.js.map +1 -0
- package/dist/lang/index.d.ts +10 -0
- package/dist/lang/index.js +1 -0
- package/dist/lang-Bo63dJb9.js +4740 -0
- package/dist/lang-Bo63dJb9.js.map +1 -0
- package/dist/runtime/index.d.ts +33 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime-C8-PPxmH.js +8284 -0
- package/dist/runtime-C8-PPxmH.js.map +1 -0
- package/dist/semantic/index.d.ts +12 -0
- package/dist/semantic/index.js +1 -0
- package/dist/semantic-CAVxm72C.js +2877 -0
- package/dist/semantic-CAVxm72C.js.map +1 -0
- package/package.json +91 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interp-ChrsgBCf.js","names":["runtime","runtime.error","runtime.vStr","runtime.toStr","runtime.EMPTY","EMPTY","HANDLERS","EMPTY","EMPTY","EMPTY","EMPTY"],"sources":["../src/interp/async.ts","../src/interp/error-handler.ts","../src/interp/executor.ts","../src/interp/frame.ts","../src/interp/library.ts","../src/interp/objects/lifetime.ts","../src/interp/storage.ts","../src/interp/compile/cells.ts","../src/interp/compile/context.ts","../src/interp/compile/const-eval.ts","../src/interp/ops.ts","../src/interp/objects/class-instance.ts","../src/interp/objects/interface-view.ts","../src/interp/objects/type-of.ts","../src/interp/objects/members.ts","../src/interp/compile/variables.ts","../src/interp/compile/args.ts","../src/interp/compile/types.ts","../src/interp/compile/calls.ts","../src/interp/compile/names.ts","../src/interp/compile/refs.ts","../src/interp/compile/dynamic.ts","../src/interp/compile/expressions.ts","../src/interp/compile/builder.ts","../src/interp/compile/stores.ts","../src/interp/compile/for-each.ts","../src/interp/compile/for-loop.ts","../src/interp/compile/truth.ts","../src/interp/compile/control.ts","../src/interp/compile/flow.ts","../src/interp/compile/simple.ts","../src/interp/compile/statements.ts","../src/interp/compile/procedure.ts","../src/interp/objects/events.ts","../src/interp/module-runtime.ts","../src/interp/module-state.ts","../src/interp/objects/library-objects.ts","../src/interp/run-context.ts","../src/interp/scheduler.ts","../src/interp/core.ts","../src/interp/program.ts"],"sourcesContent":["// The interpreter runs synchronously until a host answers with a Promise; from that point the\n// enclosing evaluation continues asynchronously. These helpers keep that switch cheap: callers test\n// `isPromise` and take the slower path only when one appears.\nimport type { Value } from '../runtime/index';\n\nexport type MaybePromise<T> = T | Promise<T>;\n\n/** A Value, or the Promise of one. */\nexport type MaybeValue = MaybePromise<Value>;\n\nexport const isPromise = <T>(x: MaybePromise<T>): x is Promise<T> => x instanceof Promise;\n\n/**\n * Applies `f` to a value now, or when its Promise settles. Not named `then`: a module exporting\n * `then` is a thenable namespace, which dynamic `import()` would call.\n */\nexport function andThen<T, R>(\n\tx: MaybePromise<T>,\n\tf: (value: T) => MaybePromise<R>,\n): MaybePromise<R> {\n\treturn x instanceof Promise ? x.then(f) : f(x);\n}\n\n/** Evaluates a list of thunks in order, staying synchronous until one returns a Promise. */\nexport function all<T>(thunks: readonly (() => MaybePromise<T>)[]): MaybePromise<T[]> {\n\tconst out: T[] = [];\n\tfor (let i = 0; i < thunks.length; i++) {\n\t\tconst r = (thunks[i] as () => MaybePromise<T>)();\n\t\tif (r instanceof Promise) return finishAll(thunks, out, i, r);\n\t\tout.push(r);\n\t}\n\treturn out;\n}\n\nasync function finishAll<T>(\n\tthunks: readonly (() => MaybePromise<T>)[],\n\tout: T[],\n\tat: number,\n\tpending: Promise<T>,\n): Promise<T[]> {\n\tout.push(await pending);\n\tfor (let i = at + 1; i < thunks.length; i++)\n\t\tout.push(await (thunks[i] as () => MaybePromise<T>)());\n\treturn out;\n}\n","// The `On Error` state of one procedure activation ([MS-VBAL] 5.4.4) and the transitions of\n// On Error, Resume and a trapped error.\nimport { VbaRuntimeError, type ErrObject } from '../runtime/index';\nimport { isTrappable } from '../exec/index';\n\nexport class ErrorHandlerState {\n\t/** `goto0` errors propagate, `next` is Resume Next, `label` jumps to `target`. */\n\tmode: 'goto0' | 'next' | 'label' = 'goto0';\n\t/** The instruction of the handler label. */\n\ttarget = -1;\n\t/** True while the handler runs: a new error then propagates to the caller. */\n\thandling = false;\n\t/** The instruction that raised the error being handled. */\n\terrorPc = -1;\n\n\t/** `On Error GoTo label` / `Resume Next` / `GoTo 0`; any On Error clears Err. */\n\tset(mode: 'goto0' | 'next' | 'label', target: number, err: ErrObject): void {\n\t\tthis.mode = mode;\n\t\tthis.target = target;\n\t\terr.clear();\n\t}\n\n\t/** `On Error GoTo -1`: leaves the handler without resuming, so a new error can be trapped. */\n\treset(err: ErrObject): void {\n\t\tthis.handling = false;\n\t\terr.clear();\n\t}\n\n\t/**\n\t * Decides where an error raised by instruction `pc` goes: the instruction to continue at, or\n\t * a rethrow when this activation does not trap it.\n\t */\n\ttrap(e: unknown, pc: number, err: ErrObject, next: number = pc + 1): number {\n\t\tif (!isTrappable(e) || this.mode === 'goto0' || this.handling) throw e;\n\t\terr.capture(e);\n\t\tif (this.mode === 'next') return next;\n\t\tthis.handling = true;\n\t\tthis.errorPc = pc;\n\t\treturn this.target;\n\t}\n\n\t/** `Resume` (`retry`), `Resume Next` or `Resume label`: leaves the handler and clears Err. */\n\tresume(\n\t\tkind: 'retry' | 'next' | 'label',\n\t\tlabel: number,\n\t\terr: ErrObject,\n\t\tnextOf: (pc: number) => number = (pc) => pc + 1,\n\t): number {\n\t\tif (!this.handling) throw new VbaRuntimeError(20);\n\t\tthis.handling = false;\n\t\terr.clear();\n\t\treturn kind === 'retry' ? this.errorPc : kind === 'next' ? nextOf(this.errorPc) : label;\n\t}\n}\n\n/** The instruction Resume Next continues at after an error in instruction `pc`. */\nexport const nextOf = (\n\tcode: readonly { readonly skip?: { readonly pc: number } }[],\n\tpc: number,\n): number => code[pc]?.skip?.pc ?? pc + 1;\n","// Runs a frame's instructions. The loop is synchronous; the first instruction that answers with a\n// Promise moves the rest of the activation onto an async loop (and its callers with it, as their\n// call expressions then see a Promise). An error goes to the frame's On Error state, which either\n// gives the instruction to continue at or rethrows to the caller.\nimport { toVbaError } from '../runtime/index';\nimport type { MaybePromise } from './async';\nimport { nextOf } from './error-handler';\nimport type { Frame } from './frame';\nimport type { RunContext } from './run-context';\nimport { MAX_STACK_FRAMES, isTrappable } from '../exec/outcome';\n\n/** Adds this frame to the call stack of an error that leaves it. */\nfunction note(f: Frame, e: unknown, pc: number): void {\n\tif (typeof e !== 'object' || e === null) return;\n\tconst instr = f.code.code[pc];\n\tlet stack = f.run.stacks.get(e);\n\tif (!stack) {\n\t\tstack = [];\n\t\tf.run.stacks.set(e, stack);\n\t}\n\tif (stack.length >= MAX_STACK_FRAMES) return;\n\tstack.push({\n\t\tmodule: f.code.bound.module.name,\n\t\tprocedure: f.code.bound.name,\n\t\tline: instr?.line ?? 0,\n\t\tcolumn: instr?.column ?? 0,\n\t});\n}\n\n/** The instruction to continue at after an error, or a rethrow. */\nfunction recover(f: Frame, e: unknown, pc: number): number {\n\tif (!isTrappable(e)) throw e;\n\ttry {\n\t\tif (f.handler.mode === 'goto0' || f.handler.handling) throw e;\n\t\tif (typeof e === 'object' && e !== null) {\n\t\t\t// Errors VBA does not let this frame trap: recursive GoSub out of stack space, an error\n\t\t\t// that left an event handler.\n\t\t\tconst only = f.run.untrappable.get(e);\n\t\t\tif (only === null || only === f) throw e;\n\t\t}\n\t\tf.erl = f.line;\n\t\treturn f.handler.trap(\n\t\t\te instanceof RangeError ? toVbaError(e) : e,\n\t\t\tpc,\n\t\t\tf.session.err,\n\t\t\tnextOf(f.code.code, pc),\n\t\t);\n\t} catch (thrown) {\n\t\tnote(f, thrown, pc);\n\t\tthrow thrown;\n\t}\n}\n\n/**\n * Runs Class_Terminate of the objects whose last reference went during the statement that just\n * ended in a frame at call depth `depth` (or in its callees). A Terminate that waits on its host\n * makes the caller wait too; its errors do not reach the caller.\n */\nexport function collectGarbage(run: RunContext, depth = 0, since = 0): MaybePromise<void> {\n\tconst due = run.terminations.take(depth, since);\n\tif (due.length === 0) return undefined;\n\t// An error that leaves Class_Terminate is dropped, and Err is left as the interrupted code had it.\n\tconst err = run.session.err;\n\tconst swallow = (restore: () => void, e: unknown): void => {\n\t\tif (!isTrappable(e)) throw e;\n\t\trestore();\n\t};\n\tconst next = (i: number): MaybePromise<void> => {\n\t\tfor (; i < due.length; i++) {\n\t\t\tconst restore = err.save();\n\t\t\tlet r: unknown;\n\t\t\ttry {\n\t\t\t\tr = (due[i] as (typeof due)[number]).terminate(run);\n\t\t\t} catch (e) {\n\t\t\t\tswallow(restore, e);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (r instanceof Promise)\n\t\t\t\treturn r.then(\n\t\t\t\t\t() => next(i + 1),\n\t\t\t\t\t(e: unknown) => {\n\t\t\t\t\t\tswallow(restore, e);\n\t\t\t\t\t\treturn next(i + 1);\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t}\n\t\treturn undefined;\n\t};\n\treturn next(0);\n}\n\n/** Runs a frame's instructions from `from`. */\nexport function execute(f: Frame, from = 0): MaybePromise<void> {\n\tconst code = f.code.code;\n\tconst run = f.run;\n\tconst guard = run.guard;\n\tlet pc = from;\n\twhile (pc < code.length) {\n\t\tif (guard.step()) return resume(f, pc);\n\t\tlet r: MaybePromise<number | undefined>;\n\t\ttry {\n\t\t\tr = (code[pc] as (typeof code)[number]).run(f);\n\t\t} catch (e) {\n\t\t\tpc = recover(f, e, pc);\n\t\t\tcontinue;\n\t\t}\n\t\tif (r instanceof Promise) return continueAsync(f, pc, r);\n\t\tif (run.terminations.size > 0) {\n\t\t\tconst g = collectGarbage(run, f.depth, f.since);\n\t\t\tif (g instanceof Promise)\n\t\t\t\treturn continueAsync(\n\t\t\t\t\tf,\n\t\t\t\t\tpc,\n\t\t\t\t\tg.then(() => r),\n\t\t\t\t);\n\t\t}\n\t\tpc = r === undefined ? pc + 1 : r;\n\t}\n\treturn undefined;\n}\n\n/** Yields to the event loop, then goes on at `pc`. */\nasync function resume(f: Frame, pc: number): Promise<void> {\n\tawait pause(f.run);\n\treturn execute(f, pc);\n}\n\nasync function continueAsync(\n\tf: Frame,\n\tat: number,\n\tpending: Promise<number | undefined>,\n): Promise<void> {\n\tconst code = f.code.code;\n\tconst run = f.run;\n\tconst guard = run.guard;\n\tlet pc = at;\n\tlet r: MaybePromise<number | undefined> = pending;\n\tfor (;;) {\n\t\ttry {\n\t\t\tconst next = r instanceof Promise ? await run.park(guard.wait(r)) : r;\n\t\t\tif (run.terminations.size > 0) await collectGarbage(run, f.depth, f.since);\n\t\t\tpc = next === undefined ? pc + 1 : next;\n\t\t} catch (e) {\n\t\t\tpc = recover(f, e, pc);\n\t\t}\n\t\tif (pc >= code.length) return;\n\t\ttry {\n\t\t\tif (guard.step()) await pause(run);\n\t\t\tr = (code[pc] as (typeof code)[number]).run(f);\n\t\t} catch (e) {\n\t\t\tr = Promise.reject(e);\n\t\t}\n\t}\n}\n\n/** Yields to the event loop; cancel and the time limit end the run (On Error cannot trap them). */\nfunction pause(run: RunContext): Promise<void> {\n\treturn run.park(run.guard.pause());\n}\n","// One activation of a procedure: its storage, `Me`, With subjects, loop state, GoSub returns and\n// error handler. Compiled closures read and write through it.\nimport {\n\tForEachCursor,\n\ttype Ref,\n\ttype Value,\n\ttype VbaObject,\n\ttype VbaSession,\n} from '../runtime/index';\nimport type { CompiledProcedure } from './compile/types';\nimport { ErrorHandlerState } from './error-handler';\nimport type { ClassInstance } from './objects/class-instance';\nimport type { RunContext } from './run-context';\n\nexport class Frame {\n\t/** The subject of each With block, by block id. */\n\treadonly with: Value[] = [];\n\t/** The storage of a With block over a user-defined type: `.X` reads and writes the variable. */\n\treadonly withRefs: Ref[] = [];\n\t/** Per-loop state (For limits and step, For Each iterators), by loop id. */\n\treadonly loops: unknown[] = [];\n\t/** Return points of GoSub. */\n\treadonly gosub: number[] = [];\n\treadonly handler = new ErrorHandlerState();\n\t/** The call depth of this activation (Class_Terminate checks use it). */\n\treadonly depth: number;\n\t/** The termination queue's mark when the activation began. */\n\treadonly since: number;\n\t/** The last line number passed (Erl reads it after an error). */\n\tline = 0;\n\t/** Erl: the line number before the statement that raised the trapped error. */\n\terl = 0;\n\n\tconstructor(\n\t\treadonly code: CompiledProcedure,\n\t\treadonly run: RunContext,\n\t\t/** Parameters, the result and locals (see `BoundProcedure.frameSize`). */\n\t\treadonly slots: Ref[],\n\t\t/** `Me`: a class instance, a document's host object, or null in a standard module. */\n\t\treadonly me: VbaObject | null,\n\t\treadonly instance: ClassInstance | null,\n\t\t/** The procedure's Static locals (per instance in a class module). */\n\t\treadonly statics: Ref[],\n\t) {\n\t\tthis.depth = run.guard.depth;\n\t\tthis.since = run.terminations.mark;\n\t}\n\n\tget session(): VbaSession {\n\t\treturn this.run.session;\n\t}\n}\n\n/** Ends the For Each loop of block `id`, if one is open (unlocks its array). */\nexport function closeCursor(f: Frame, id: number): void {\n\tconst c = f.loops[id];\n\tif (c instanceof ForEachCursor) c.close();\n\tf.loops[id] = undefined;\n}\n\n/** Ends every open For Each loop of a frame (the procedure is left). */\nexport function closeCursors(f: Frame): void {\n\tfor (const c of f.loops) if (c instanceof ForEachCursor) c.close();\n}\n","// Calls into VBA's standard library: each catalogue entry (semantic/library) names the runtime\n// export that implements it and its calling convention; this table turns that into one closure\n// per entry and module. The `special` entries need the frame or the module and live here.\nimport * as runtime from '../runtime/index';\nimport {\n\tVbaRuntimeError,\n\tarrayOf,\n\tgiven,\n\tscalar,\n\ttoLng,\n\tvArr,\n\tvLng,\n\ttype Value,\n\ttype VbaSession,\n} from '../runtime/index';\nimport type { BoundModule, LibraryFunction } from '../semantic/index';\nimport type { MaybeValue } from './async';\nimport type { Frame } from './frame';\n\nexport type LibraryCall = (\n\targs: readonly (Value | undefined)[],\n\trest: readonly Value[],\n\tf: Frame,\n) => MaybeValue;\n\ntype RuntimeFn = (...args: unknown[]) => runtime.MaybePromise<Value> | void;\n\nconst exports = runtime as unknown as Record<string, unknown>;\n\nconst optional = (v: Value | undefined): Value | undefined => (v && given(v) ? v : undefined);\n\n/** `LBound`/`UBound`: the bound of dimension `dim` (1 by default) of an array value. */\nfunction bound(\n\twhich: 'lbound' | 'ubound',\n\targs: readonly (Value | undefined)[],\n\ts: VbaSession,\n): Value {\n\tconst a = args[0];\n\tif (!a || a.vt !== 8192) throw new VbaRuntimeError(13);\n\tconst d = optional(args[1]);\n\tconst dim = d ? toLng(scalar(d), s) : 1;\n\treturn vLng(which === 'lbound' ? a.v.lbound(dim) : a.v.ubound(dim));\n}\n\nfunction special(entry: LibraryFunction, module: BoundModule): LibraryCall {\n\tswitch (entry.name.toLowerCase()) {\n\t\tcase 'array': {\n\t\t\tconst base = module.options.base;\n\t\t\treturn (_args, rest, f) => vArr(arrayOf(rest, base, f.session));\n\t\t}\n\t\tcase 'lbound':\n\t\t\treturn (args, _rest, f) => bound('lbound', args, f.session);\n\t\tcase 'ubound':\n\t\t\treturn (args, _rest, f) => bound('ubound', args, f.session);\n\t\tcase 'erl':\n\t\t\treturn (_args, _rest, f) => vLng(f.erl);\n\t\tcase 'error':\n\t\tcase 'error$': {\n\t\t\tconst text = entry.name.endsWith('$');\n\t\t\treturn (args, _rest, f) => {\n\t\t\t\tconst n = optional(args[0]) ?? vLng(f.session.err.number);\n\t\t\t\tconst v = runtime.error(n, f.session);\n\t\t\t\treturn text && v.vt !== 8 ? vStrOf(v, f.session) : v;\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn () => {\n\t\t\t\tthrow new VbaRuntimeError(445, `${entry.name} is not supported in this environment`);\n\t\t\t};\n\t}\n}\n\nconst vStrOf = (v: Value, s: VbaSession): Value => runtime.vStr(runtime.toStr(scalar(v), s));\n\nexport class LibraryDispatch {\n\tprivate readonly cache = new Map<string, LibraryCall>();\n\t/** `typed`: a conversion whose argument has a static type (the invocation's `typedArgument`). */\n\tcompile(entry: LibraryFunction, module: BoundModule, typed = false): LibraryCall {\n\t\tconst key = `${module.name}\\u0000${entry.name}\\u0000${typed}`;\n\t\tlet call = this.cache.get(key);\n\t\tif (!call) {\n\t\t\tcall = this.build(entry, module, typed);\n\t\t\tthis.cache.set(key, call);\n\t\t}\n\t\treturn call;\n\t}\n\n\tprivate build(entry: LibraryFunction, module: BoundModule, typed: boolean): LibraryCall {\n\t\tif (entry.convention === 'special') return special(entry, module);\n\t\tconst fn = entry.runtime ? exports[entry.runtime] : undefined;\n\t\tif (typeof fn !== 'function')\n\t\t\treturn () => {\n\t\t\t\tthrow new VbaRuntimeError(445, `${entry.name} is not supported in this environment`);\n\t\t\t};\n\t\tconst f = fn as RuntimeFn;\n\t\tconst n = entry.paramArray ? entry.params.length - 1 : entry.params.length;\n\t\tconst pad = (args: readonly (Value | undefined)[]): (Value | undefined)[] => {\n\t\t\tconst out = args.slice(0, n);\n\t\t\twhile (out.length < n) out.push(undefined);\n\t\t\treturn out;\n\t\t};\n\t\tconst result = (r: runtime.MaybePromise<Value> | void): MaybeValue => r ?? runtime.EMPTY;\n\t\tconst compareText: runtime.CompareMode = module.options.compareText ? 1 : 0;\n\t\tswitch (entry.convention) {\n\t\t\tcase 'env':\n\t\t\t\treturn (args, _rest, fr) => result(f(...pad(args), fr.session));\n\t\t\tcase 'conversion':\n\t\t\t\treturn (args, _rest, fr) => result(f(args[0], fr.session, typed));\n\t\t\tcase 'compare':\n\t\t\t\treturn (args, _rest, fr) => result(f(...pad(args), compareText, fr.session));\n\t\t\tcase 'session':\n\t\t\t\treturn (args, _rest, fr) => result(f(fr.session, ...pad(args)));\n\t\t\tcase 'pure':\n\t\t\t\treturn (args) => result(f(...pad(args)));\n\t\t\tcase 'list':\n\t\t\t\treturn (args, rest, fr) => result(f(...pad(args), rest, fr.session));\n\t\t}\n\t}\n}\n","// Interface views and the default interface of an object. Reference counting itself is the\n// runtime's (runtime/lifetime.ts), shared by both executors.\nimport type { Value } from '../../runtime/index';\nexport { counted, escape, release, retain, type Counted } from '../../runtime/index';\n\n/** Marks an interface view; its value is the instance it views. */\nexport const VIEW = Symbol('vba.view');\n\n/**\n * The object as a Variant or `As Object` variable holds it: an interface view becomes the\n * instance's default interface ([MS-VBAL] 5.3.1.3), anything else is unchanged.\n */\nexport function defaultInterface(v: Value): Value {\n\tif (v.vt !== 9 || v.v === null) return v;\n\tconst instance = (v.v as unknown as Record<symbol, unknown>)[VIEW];\n\treturn instance ? { vt: 9, v: instance as NonNullable<typeof v.v> } : v;\n}\n","// Variable storage ([MS-VBAL] 5.2.3.1, 5.5): one `Ref` class per kind of declared type, so a store\n// applies VBA's rules for that type. Locals, module variables, class fields, array parameters and\n// temporaries all use these.\nimport {\n\tEMPTY,\n\tNOTHING,\n\tVbaArray,\n\tVbaRuntimeError,\n\tassignArray,\n\tcopyValue,\n\tdefaultFor,\n\tfixLen,\n\tletAs,\n\tvArr,\n\tvStr,\n\tvUdt,\n\ttype Ref,\n\ttype Udt,\n\ttype UdtType,\n\ttype Value,\n\ttype VbaEnv,\n\ttype VObj,\n} from '../runtime/index';\nimport { defaultInterface, escape, release, retain } from './objects/lifetime';\nimport type { MaybePromise } from './async';\nimport type { RunContext } from './run-context';\n\n/** A Variant variable. Holds any value; object references are counted. */\nexport class VariantCell implements Ref {\n\tconstructor(public value: Value = EMPTY) {}\n\tget(): Value {\n\t\treturn this.value;\n\t}\n\tset(v: Value): void {\n\t\tif (v.vt === 9 || this.value.vt === 9) {\n\t\t\tretain(v);\n\t\t\trelease(this.value);\n\t\t\tv = defaultInterface(v);\n\t\t} else if (v.vt === 8192 || v.vt === 36) v = copyValue(v);\n\t\tthis.value = v;\n\t}\n}\n\n/** A temporary passed for a ByRef parameter given an expression: writes go nowhere else. */\nexport class TempCell extends VariantCell {}\n\n/** A variable of a scalar type: stores are Let-coerced to it. */\nexport class ScalarCell implements Ref {\n\tvalue: Value;\n\tconstructor(\n\t\treadonly vt: number,\n\t\tprivate readonly env: VbaEnv,\n\t) {\n\t\tthis.value = defaultFor(vt);\n\t}\n\tget(): Value {\n\t\treturn this.value;\n\t}\n\tset(v: Value): void {\n\t\tthis.value = v.vt === this.vt ? v : letAs(this.vt, v, this.env);\n\t}\n}\n\n/** `String * n`: padded with spaces or cut to n characters. */\nexport class FixedStringCell implements Ref {\n\tvalue: Value;\n\tconstructor(\n\t\tprivate readonly length: number,\n\t\tprivate readonly env: VbaEnv,\n\t) {\n\t\tthis.value = vStr('\\0'.repeat(length));\n\t}\n\tget(): Value {\n\t\treturn this.value;\n\t}\n\tset(v: Value): void {\n\t\tconst s = letAs(8, v, this.env);\n\t\tthis.value = vStr(fixLen((s as { v: string }).v, this.length));\n\t}\n}\n\n/** An object variable (`As Object`, `As Class`): Set stores, converted to the declared interface. */\nexport class ObjectCell implements Ref {\n\tvalue: VObj = NOTHING;\n\tconstructor(private readonly cast: (v: Value) => Value = (v) => v) {}\n\tget(): Value {\n\t\treturn this.value;\n\t}\n\tset(v: Value): void {\n\t\tif (v.vt !== 9) throw new VbaRuntimeError(v.vt === 0 ? 91 : 13);\n\t\tconst next = this.cast(v);\n\t\tretain(next);\n\t\trelease(this.value);\n\t\tthis.value = next as VObj;\n\t}\n}\n\n/** `Dim x As New Class`: a new object is created whenever the variable is used while Nothing. */\nexport class AutoNewCell extends ObjectCell {\n\tconstructor(\n\t\tprivate readonly create: () => Value,\n\t\tcast?: (v: Value) => Value,\n\t\t/** Creates the object, waiting for an asynchronous Class_Initialize (compiled reads). */\n\t\tprivate readonly createLater?: (run: RunContext) => MaybePromise<Value>,\n\t) {\n\t\tsuper(cast);\n\t}\n\t/** The object, created first when Nothing; a Promise only for an asynchronous Class_Initialize. */\n\tensure(run: RunContext): MaybePromise<Value> {\n\t\tif (this.value.v !== null || !this.createLater) return this.get();\n\t\tconst r = this.createLater(run);\n\t\tconst keep = (v: Value): Value => {\n\t\t\tif (this.value.v === null) this.set(v);\n\t\t\treturn this.value;\n\t\t};\n\t\treturn r instanceof Promise ? r.then(keep) : keep(r);\n\t}\n\toverride get(): Value {\n\t\tif (this.value.v === null) this.set(this.create());\n\t\treturn this.value;\n\t}\n\t/** The value without creating an object (`x Is Nothing` is never True for As New). */\n\tpeek(): Value {\n\t\treturn this.value;\n\t}\n}\n\n/** An array variable: whole-array assignment copies ([MS-VBAL] 5.5.1.2.6). */\nexport class ArrayCell implements Ref {\n\tvalue: Value;\n\tconstructor(\n\t\treadonly array: VbaArray,\n\t\tprivate readonly env: VbaEnv,\n\t) {\n\t\tthis.value = vArr(array);\n\t}\n\tget(): Value {\n\t\treturn this.value;\n\t}\n\tset(v: Value): void {\n\t\tconst current = (this.value as { v: VbaArray }).v;\n\t\tif (current.fixed) throw new VbaRuntimeError(13, \"Can't assign to array\");\n\t\tconst next = vArr(assignArray(current.elemVt, v, this.env));\n\t\tcurrent.releaseAll();\n\t\tthis.value = next;\n\t}\n}\n\n/** A user-defined type variable: assignment copies the record. */\nexport class UdtCell implements Ref {\n\tvalue: Value;\n\tconstructor(private readonly type: UdtType) {\n\t\tthis.value = vUdt(type.create());\n\t}\n\tget(): Value {\n\t\treturn this.value;\n\t}\n\tset(v: Value): void {\n\t\tif (v.vt !== 36 || v.v.type !== this.type) throw new VbaRuntimeError(13);\n\t\tthis.value = copyValue(v);\n\t}\n}\n\n/** Builds a fresh array of an element type (a declared `Dim a(1 To 3) As Long`). */\nexport function newArray(\n\telemVt: number,\n\tbounds: readonly { lo: number; hi: number }[],\n\tfixed: boolean,\n\tenv: VbaEnv,\n\tinit?: () => Value,\n\tcounting = false,\n): VbaArray {\n\treturn new VbaArray(elemVt, bounds, { fixed, env, counting, ...(init ? { init } : {}) });\n}\n\n/** An element of an array, as a ByRef argument or the target of a store. */\nexport class ElementRef implements Ref {\n\tconstructor(\n\t\treadonly array: VbaArray,\n\t\treadonly at: readonly number[],\n\t) {}\n\tget(): Value {\n\t\treturn this.array.get(this.at);\n\t}\n\tset(v: Value): void {\n\t\tif (!this.array.counting) escape(v);\n\t\tthis.array.set(this.at, v);\n\t}\n}\n\n/** A field of a user-defined type value. */\nexport class FieldRef implements Ref {\n\tconstructor(\n\t\treadonly udt: Udt,\n\t\treadonly index: number,\n\t) {}\n\tget(): Value {\n\t\treturn this.udt.values[this.index] as Value;\n\t}\n\tset(v: Value): void {\n\t\tescape(v);\n\t\tthis.udt.set((this.udt.type.fields[this.index] as { name: string }).name, v);\n\t}\n}\n\n/** `Dim a(n) As New Class`: an element read while Nothing gets a new object first. */\nexport class AutoNewArray extends VbaArray {\n\tconstructor(\n\t\telemVt: number,\n\t\tbounds: readonly { lo: number; hi: number }[],\n\t\toptions: ConstructorParameters<typeof VbaArray>[2],\n\t\tprivate readonly create: () => Value,\n\t) {\n\t\tsuper(elemVt, bounds, options);\n\t}\n\n\toverride get(indices: readonly number[]): Value {\n\t\tconst v = super.get(indices);\n\t\tif (v.vt !== 9 || v.v !== null) return v;\n\t\tconst o = this.create();\n\t\tif (!this.counting) escape(o);\n\t\tsuper.set(indices, o);\n\t\treturn o;\n\t}\n}\n","// Storage factories: for a declared type, the function that creates a fresh variable of it\n// ([MS-VBAL] 5.2.3.1.3 default values). Fixed array bounds are constant expressions, evaluated\n// once when the factory is built.\nimport { VT, VbaRuntimeError, defaultFor, vObj, type Ref, type Value } from '../../runtime/index';\nimport type { ArrayBound } from '../../lang/index';\nimport type { StaticType } from '../../semantic/index';\nimport type { Services } from '../services';\nimport {\n\tArrayCell,\n\tAutoNewArray,\n\tAutoNewCell,\n\tFixedStringCell,\n\tObjectCell,\n\tScalarCell,\n\tUdtCell,\n\tVariantCell,\n\tnewArray,\n} from '../storage';\nimport type { ConstEvaluator } from './const-eval';\nimport type { RunContext } from '../run-context';\n\n/** The element `VarType` of arrays of a static type. */\nexport function elementVt(t: StaticType): number {\n\tswitch (t.kind) {\n\t\tcase 'scalar':\n\t\t\treturn t.vt;\n\t\tcase 'object':\n\t\t\treturn VT.Object;\n\t\tcase 'udt':\n\t\t\treturn VT.UserDefinedType;\n\t\tdefault:\n\t\t\treturn VT.Variant;\n\t}\n}\n\nexport interface CellOptions {\n\treadonly bounds: readonly ArrayBound[] | null;\n\treadonly isNew: boolean;\n\t/** Option Base of the declaring module. */\n\treadonly base: number;\n}\n\nexport class CellFactories {\n\tconstructor(\n\t\tprivate readonly services: Services,\n\t\tprivate readonly consts: ConstEvaluator,\n\t) {}\n\n\t/** The factory for a variable of `type`. */\n\tmake(type: StaticType, options: CellOptions): () => Ref {\n\t\tconst env = this.services.session;\n\t\tswitch (type.kind) {\n\t\t\tcase 'variant':\n\t\t\t\treturn () => new VariantCell();\n\t\t\tcase 'scalar': {\n\t\t\t\tif (type.fixedLength) {\n\t\t\t\t\tconst n = this.consts.number(type.fixedLength);\n\t\t\t\t\treturn () => new FixedStringCell(n, env);\n\t\t\t\t}\n\t\t\t\tconst vt = type.vt;\n\t\t\t\treturn () => new ScalarCell(vt, env);\n\t\t\t}\n\t\t\tcase 'object': {\n\t\t\t\tconst cast = this.services.castObject(type);\n\t\t\t\tif (options.isNew) {\n\t\t\t\t\tconst later = (run: RunContext) => this.services.createObject(type, run);\n\t\t\t\t\treturn () => new AutoNewCell(this.creator(type), cast, later);\n\t\t\t\t}\n\t\t\t\treturn () => new ObjectCell(cast);\n\t\t\t}\n\t\t\tcase 'udt': {\n\t\t\t\tconst udt = this.services.udtType(type.udt);\n\t\t\t\treturn () => new UdtCell(udt);\n\t\t\t}\n\t\t\tcase 'array': {\n\t\t\t\tconst element = type.element;\n\t\t\t\tconst vt = elementVt(element);\n\t\t\t\tconst init = this.elementInit(element);\n\t\t\t\tconst bounds = (options.bounds ?? []).map((b) => ({\n\t\t\t\t\tlo: b.lower ? this.consts.number(b.lower) : options.base,\n\t\t\t\t\thi: this.consts.number(b.upper),\n\t\t\t\t}));\n\t\t\t\tconst fixed = bounds.length > 0;\n\t\t\t\t// Arrays that can hold objects count their elements' references (Class_Terminate).\n\t\t\t\tconst counting = element.kind === 'object' || element.kind === 'variant';\n\t\t\t\tif (options.isNew && element.kind === 'object') {\n\t\t\t\t\tconst create = this.creator(element);\n\t\t\t\t\treturn () =>\n\t\t\t\t\t\tnew ArrayCell(new AutoNewArray(vt, bounds, { fixed, env, counting }, create), env);\n\t\t\t\t}\n\t\t\t\treturn () => new ArrayCell(newArray(vt, bounds, fixed, env, init, counting), env);\n\t\t\t}\n\t\t}\n\t}\n\n\t/** Creates a new object of `type` (for As New), synchronously. */\n\tcreator(type: StaticType): () => Value {\n\t\treturn () => {\n\t\t\tconst r = this.services.createObject(type, this.services.activeRun());\n\t\t\tif (r instanceof Promise)\n\t\t\t\tthrow new VbaRuntimeError(51, 'As New with an asynchronous Class_Initialize');\n\t\t\treturn r;\n\t\t};\n\t}\n\t/** A fresh element of an array or field of `t` (UDTs and objects need more than a default). */\n\telementInit(t: StaticType): (() => Value) | undefined {\n\t\tif (t.kind === 'udt') {\n\t\t\tconst udt = this.services.udtType(t.udt);\n\t\t\treturn () => ({ vt: 36, v: udt.create() });\n\t\t}\n\t\tif (t.kind === 'object') return () => vObj(null);\n\t\tif (t.kind === 'scalar' && t.fixedLength) {\n\t\t\tconst n = this.consts.number(t.fixedLength);\n\t\t\treturn () => ({ vt: 8, v: '\\0'.repeat(n) });\n\t\t}\n\t\treturn t.kind === 'scalar' ? () => defaultFor(t.vt) : undefined;\n\t}\n}\n","// What compiling one procedure (or one module's constant expressions) needs: the bound program's\n// tables, the module and procedure being compiled, and the interpreter's services.\nimport type { Expression, Statement } from '../../lang/index';\nimport type {\n\tBinding,\n\tBoundModule,\n\tBoundProcedure,\n\tBoundProgram,\n\tInvocation,\n\tStaticType,\n\tWithBlock,\n} from '../../semantic/index';\nimport type { Services } from '../services';\nimport type { CellFactories } from './cells';\nimport type { ConstEvaluator } from './const-eval';\n\nexport class CompileContext {\n\treadonly program: BoundProgram;\n\n\tconstructor(\n\t\treadonly services: Services,\n\t\treadonly module: BoundModule,\n\t\treadonly procedure: BoundProcedure | null,\n\t\treadonly consts: ConstEvaluator,\n\t\treadonly cells: CellFactories,\n\t) {\n\t\tthis.program = services.program;\n\t}\n\n\tbinding(e: Expression): Binding | undefined {\n\t\treturn this.program.binding(e);\n\t}\n\n\tinvocation(n: Expression | Statement): Invocation | undefined {\n\t\treturn this.program.invocation(n);\n\t}\n\n\ttypeOf(e: Expression): StaticType {\n\t\treturn this.program.typeOf(e);\n\t}\n\n\twithBlock(e: Expression): WithBlock | undefined {\n\t\treturn this.program.withBlock(e);\n\t}\n\n\tget compareText(): boolean {\n\t\treturn this.module.options.compareText;\n\t}\n}\n","// Constant expressions ([MS-VBAL] 5.6.16.2): Const values, Enum values, array bounds, String * n\n// lengths and Optional defaults. Each is evaluated once, synchronously, the first time it is used.\nimport type { Expression } from '../../lang/index';\nimport { VbaRuntimeError, scalar, toLng, type Value, type VbaEnv } from '../../runtime/index';\n\nexport class ConstEvaluator {\n\tprivate readonly memo = new Map<Expression, Value>();\n\tprivate readonly active = new Set<Expression>();\n\n\tconstructor(\n\t\t/** Evaluates an expression in its module (compiled with the module-level context). */\n\t\tprivate readonly evaluate: (e: Expression) => Value | Promise<Value>,\n\t\tprivate readonly env: VbaEnv,\n\t) {}\n\n\tvalue(e: Expression): Value {\n\t\tconst known = this.memo.get(e);\n\t\tif (known) return known;\n\t\tif (this.active.has(e))\n\t\t\tthrow new VbaRuntimeError(5, 'Circular reference in a constant expression');\n\t\tthis.active.add(e);\n\t\ttry {\n\t\t\tconst v = this.evaluate(e);\n\t\t\tif (v instanceof Promise) throw new VbaRuntimeError(5, 'Constant expression required');\n\t\t\tthis.memo.set(e, v);\n\t\t\treturn v;\n\t\t} finally {\n\t\t\tthis.active.delete(e);\n\t\t}\n\t}\n\n\t/** A constant used as a count or bound: Let-coerced to Long. */\n\tnumber(e: Expression): number {\n\t\treturn toLng(scalar(this.value(e)), this.env);\n\t}\n}\n","// The operators as the interpreter calls them: one adapter over the runtime's operator functions,\n// with the strict-overflow, Option Compare and typed-comparison flags fixed at compile time. The\n// session is the environment every runtime operation reads (locale, limits, clock).\nimport type { BinaryOperator, UnaryOperator } from '../lang/index';\nimport {\n\tadd,\n\tand,\n\tcat,\n\tdiv,\n\teq,\n\teqv,\n\tge,\n\tgt,\n\tidiv,\n\timp,\n\tis,\n\tle,\n\tlike,\n\tlt,\n\tmod,\n\tmul,\n\tne,\n\tneg,\n\tnot,\n\tor,\n\tpow,\n\tsub,\n\txor,\n\ttype CompareMode,\n\ttype Value,\n\ttype VbaSession,\n\tresolveDefaultMaybe,\n} from '../runtime/index';\nimport type { MaybeValue } from './async';\n\nexport type BinaryFn = (a: Value, b: Value, s: VbaSession) => Value;\nexport type UnaryFn = (a: Value, s: VbaSession) => Value;\n\nexport interface OperatorFlags {\n\t/** No operand is declared Variant: integer overflow raises error 6 instead of widening. */\n\treadonly strict: boolean;\n\t/** `Option Compare Text` in the module. */\n\treadonly compareText: boolean;\n\t/** An operand of a comparison has a declared type ([MS-VBAL] 5.6.9.8.1). */\n\treadonly typed: boolean;\n}\n\n/** The function of a binary operator (`Is` compares objects and needs no default values). */\nexport function binaryOperator(op: BinaryOperator, flags: OperatorFlags): BinaryFn {\n\tconst { strict, typed } = flags;\n\tconst compare: CompareMode = flags.compareText ? 1 : 0;\n\tswitch (op) {\n\t\tcase '+':\n\t\t\treturn (a, b, s) => add(a, b, strict, s);\n\t\tcase '-':\n\t\t\treturn (a, b, s) => sub(a, b, strict, s);\n\t\tcase '*':\n\t\t\treturn (a, b, s) => mul(a, b, strict, s);\n\t\tcase '/':\n\t\t\treturn (a, b, s) => div(a, b, strict, s);\n\t\tcase '\\\\':\n\t\t\treturn (a, b, s) => idiv(a, b, strict, s);\n\t\tcase 'Mod':\n\t\t\treturn (a, b, s) => mod(a, b, strict, s);\n\t\tcase '^':\n\t\t\treturn (a, b, s) => pow(a, b, s);\n\t\tcase '&':\n\t\t\treturn (a, b, s) => cat(a, b, s);\n\t\tcase '=':\n\t\t\treturn (a, b, s) => eq(a, b, compare, typed, s);\n\t\tcase '<>':\n\t\t\treturn (a, b, s) => ne(a, b, compare, typed, s);\n\t\tcase '<':\n\t\t\treturn (a, b, s) => lt(a, b, compare, typed, s);\n\t\tcase '>':\n\t\t\treturn (a, b, s) => gt(a, b, compare, typed, s);\n\t\tcase '<=':\n\t\t\treturn (a, b, s) => le(a, b, compare, typed, s);\n\t\tcase '>=':\n\t\t\treturn (a, b, s) => ge(a, b, compare, typed, s);\n\t\tcase 'Like':\n\t\t\treturn (a, b, s) => like(a, b, compare, s);\n\t\tcase 'Is':\n\t\t\treturn (a, b) => is(a, b);\n\t\tcase 'And':\n\t\t\treturn (a, b, s) => and(a, b, strict, s);\n\t\tcase 'Or':\n\t\t\treturn (a, b, s) => or(a, b, strict, s);\n\t\tcase 'Xor':\n\t\t\treturn (a, b, s) => xor(a, b, strict, s);\n\t\tcase 'Eqv':\n\t\t\treturn (a, b, s) => eqv(a, b, strict, s);\n\t\tcase 'Imp':\n\t\t\treturn (a, b, s) => imp(a, b, strict, s);\n\t}\n}\n\nexport function unaryOperator(op: UnaryOperator, strict: boolean): UnaryFn {\n\tswitch (op) {\n\t\tcase '-':\n\t\t\treturn (a, s) => neg(a, strict, s);\n\t\tcase 'Not':\n\t\t\treturn (a, s) => not(a, strict, s);\n\t\tcase '+':\n\t\t\treturn (a) => a;\n\t}\n}\n\n/** The simple data value (an object's default member), synchronous unless a host answers later. */\nexport const scalarOf = (v: Value): MaybeValue => (v.vt === 9 ? resolveDefaultMaybe(v) : v);\n","// An object of a class module ([MS-VBAL] 5.2.4): its fields and Static locals, member dispatch\n// for callers that only know the host object protocol, events, and the reference count behind\n// Class_Terminate.\nimport {\n\tMISSING,\n\tscalar,\n\ttoLng,\n\tVbaRuntimeError,\n\ttype EventSink,\n\ttype NamedArgs,\n\ttype Ref,\n\ttype Value,\n\ttype VbaObject,\n\ttype VObj,\n} from '../../runtime/index';\nimport { PropertyGroup, type BoundModule, type BoundProcedure } from '../../semantic/index';\nimport { andThen, type MaybePromise, type MaybeValue } from '../async';\nimport type { RunContext } from '../run-context';\nimport type { Services } from '../services';\nimport { TempCell } from '../storage';\nimport { counted, type Counted } from './lifetime';\n\nexport type Access = 'get' | 'let' | 'set' | 'call';\n\nconst temps = (args: readonly Value[]): Ref[] => args.map((a) => new TempCell(a));\nconst EMPTY: Value = { vt: 0 };\n\nexport class ClassInstance implements VbaObject, Counted {\n\treadonly vars: Ref[] = [];\n\treadonly statics = new Map<BoundProcedure, Ref[]>();\n\tprivate readonly sinks = new Set<EventSink>();\n\tprivate refs = 0;\n\tprivate escaped = false;\n\tprivate terminated = false;\n\n\tconstructor(\n\t\treadonly module: BoundModule,\n\t\tprivate readonly services: Services,\n\t) {\n\t\tcounted(this);\n\t}\n\n\ttypeName(): string {\n\t\treturn this.module.name;\n\t}\n\n\tidentity(): unknown {\n\t\treturn this;\n\t}\n\n\tget(name: string, args: readonly Value[], named?: NamedArgs): MaybeValue {\n\t\treturn this.external(name, 'get', args, named, undefined, false);\n\t}\n\n\tlet(name: string, args: readonly Value[], value: Value): MaybePromise<void> {\n\t\treturn andThen(this.external(name, 'let', args, undefined, value, false), () => undefined);\n\t}\n\n\tset(name: string, args: readonly Value[], value: VObj): MaybePromise<void> {\n\t\treturn andThen(this.external(name, 'set', args, undefined, value, false), () => undefined);\n\t}\n\n\tcall(name: string, args: readonly Value[], named?: NamedArgs): MaybeValue {\n\t\treturn this.external(name, 'call', args, named, undefined, false);\n\t}\n\n\tenumerate(): Iterable<Value> | AsyncIterable<Value> {\n\t\tconst g = this.module.newEnum;\n\t\tif (!g) throw new VbaRuntimeError(438);\n\t\tconst r = this.external(g.name, 'get', [], undefined, undefined, true);\n\t\tconst items = (v: Value): Iterable<Value> | AsyncIterable<Value> => {\n\t\t\tif (v.vt !== 9 || v.v === null || !v.v.enumerate) throw new VbaRuntimeError(438);\n\t\t\treturn v.v.enumerate();\n\t\t};\n\t\tif (!(r instanceof Promise)) return items(r);\n\t\treturn {\n\t\t\tasync *[Symbol.asyncIterator]() {\n\t\t\t\tyield* items(await r);\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * A call through the host object protocol (by the host, a runtime operation or late binding):\n\t * it joins the run in progress or runs as a callback of its own (`Services.enter`).\n\t * `internal` reaches private members (an interface's implementation).\n\t */\n\texternal(\n\t\tname: string,\n\t\taccess: Access,\n\t\targs: readonly Value[],\n\t\tnamed: NamedArgs | undefined,\n\t\tvalue: Value | undefined,\n\t\tinternal: boolean,\n\t): MaybeValue {\n\t\treturn this.services.enter(\n\t\t\t(run) => this.dispatch(name, access, temps(args), named, value, run, internal),\n\t\t\tEMPTY,\n\t\t);\n\t}\n\n\tconnect(sink: EventSink): () => void {\n\t\tthis.sinks.add(sink);\n\t\treturn () => this.sinks.delete(sink);\n\t}\n\n\t/** `RaiseEvent`: runs every connected handler in turn; arguments are references. */\n\traise(event: string, args: readonly Ref[]): MaybePromise<void> {\n\t\tconst sinks = [...this.sinks];\n\t\tconst next = (i: number): MaybePromise<void> => {\n\t\t\tfor (; i < sinks.length; i++) {\n\t\t\t\tconst r = (sinks[i] as EventSink).fire(this, event, args);\n\t\t\t\tif (r instanceof Promise) return r.then(() => next(i + 1));\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\t\treturn next(0);\n\t}\n\n\t/**\n\t * Calls a member with argument references (the interpreter's own calls pass ByRef arguments\n\t * through). `value` is the right-hand side of a Let or Set. Private members are reachable only\n\t * with `internal` (an interface implementation, `Class_Initialize`).\n\t */\n\tdispatch(\n\t\tname: string,\n\t\taccess: Access,\n\t\targs: readonly (Ref | null)[],\n\t\tnamed: NamedArgs | undefined,\n\t\tvalue: Value | undefined,\n\t\trun: RunContext,\n\t\tinternal = false,\n\t): MaybeValue {\n\t\tconst group =\n\t\t\tname === '' ? this.module.defaultMember : this.module.members.get(name.toLowerCase());\n\t\tif (!group) throw new VbaRuntimeError(438);\n\t\tif (!(group instanceof PropertyGroup)) {\n\t\t\tif (group.kind !== 'variable' || (!group.isPublic && !internal))\n\t\t\t\tthrow new VbaRuntimeError(438);\n\t\t\treturn this.field(group.slot, access, args, value, run);\n\t\t}\n\t\tconst proc = group.forAccess(access);\n\t\tif (!proc) throw new VbaRuntimeError(451);\n\t\t// Late binding reaches Public members only (a Friend member is early-bound only).\n\t\tif (proc.visibility !== 'public' && !internal) throw new VbaRuntimeError(438);\n\t\tconst reading = access === 'get' || access === 'call';\n\t\tconst takes = proc.params.length;\n\t\tif (reading && takes === 0 && args.length > 0) {\n\t\t\t// `obj.Items(1)` where Items takes no arguments: index what it returns.\n\t\t\tconst r = this.services.invoke(proc, [], [], this, run);\n\t\t\treturn andThen(r, (v) => applyArgs(v, args, run));\n\t\t}\n\t\tconst placed = place(proc, args, named, value);\n\t\treturn this.services.invoke(proc, placed.args, placed.rest, this, run);\n\t}\n\n\tprivate field(\n\t\tslot: number,\n\t\taccess: Access,\n\t\targs: readonly (Ref | null)[],\n\t\tvalue: Value | undefined,\n\t\trun: RunContext,\n\t): MaybeValue {\n\t\tconst ref = this.vars[slot] as Ref;\n\t\tif (access === 'let' || access === 'set') {\n\t\t\tif (args.length > 0) throw new VbaRuntimeError(450);\n\t\t\tref.set(value ?? MISSING);\n\t\t\treturn { vt: 0 };\n\t\t}\n\t\tconst v = ref.get();\n\t\treturn args.length === 0 ? v : applyArgs(v, args, run);\n\t}\n\n\tretain(): void {\n\t\tthis.refs++;\n\t}\n\n\trelease(): void {\n\t\tif (--this.refs > 0 || this.escaped || this.terminated) return;\n\t\tthis.services.lastReleased(this);\n\t}\n\n\tescape(): void {\n\t\tthis.escaped = true;\n\t}\n\n\t/**\n\t * Runs Class_Terminate once no counted reference is left (checked at the end of a statement,\n\t * so a function's result on its way to a variable is not terminated), then releases the\n\t * objects the instance's own fields hold.\n\t */\n\tterminate(run: RunContext): MaybeValue | undefined {\n\t\tif (this.terminated || this.escaped || this.refs > 0) return undefined;\n\t\tthis.terminated = true;\n\t\tconst p = this.module.groups.get('class_terminate')?.method;\n\t\tconst done = (): undefined => {\n\t\t\tfor (const ref of this.vars) {\n\t\t\t\tconst v = ref.get();\n\t\t\t\tif (v.vt === 9 && v.v !== null) ref.set({ vt: 9, v: null });\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\t\tif (!p) return done();\n\t\treturn andThen(this.services.invoke(p, [], [], this, run), done) as MaybeValue | undefined;\n\t}\n}\n\n/** Places positional and named arguments (and a Let/Set value) on a procedure's parameters. */\nexport function place(\n\tproc: BoundProcedure,\n\targs: readonly (Ref | null)[],\n\tnamed: NamedArgs | undefined,\n\tvalue: Value | undefined,\n): { args: (Ref | null)[]; rest: Value[] } {\n\tconst params = proc.params;\n\tconst fixed = params.at(-1)?.paramArray ? params.length - 1 : params.length;\n\tconst valueSlot = value === undefined ? -1 : fixed - 1;\n\tconst limit = valueSlot >= 0 ? valueSlot : fixed;\n\tconst out: (Ref | null)[] = params.slice(0, fixed).map(() => null);\n\tconst rest: Value[] = [];\n\targs.forEach((a, i) => {\n\t\tif (i < limit) out[i] = a;\n\t\telse if (fixed < params.length) rest.push(a?.get() ?? MISSING);\n\t\telse throw new VbaRuntimeError(450);\n\t});\n\tif (named)\n\t\tfor (const [n, v] of named) {\n\t\t\tconst i = params.findIndex((p) => p.name.toLowerCase() === n.toLowerCase());\n\t\t\tif (i < 0 || i >= limit) throw new VbaRuntimeError(448);\n\t\t\tout[i] = new TempCell(v);\n\t\t}\n\tif (valueSlot >= 0) out[valueSlot] = new TempCell(value as Value);\n\treturn { args: out, rest };\n}\n\n/** Applies arguments to a value: an array element, or the default member of an object. */\nfunction applyArgs(v: Value, args: readonly (Ref | null)[], run: RunContext): MaybeValue {\n\tconst values = args.map((a) => a?.get() ?? MISSING);\n\tif (v.vt === 8192) return v.v.get(values.map((x) => toLng(scalar(x), run.session)));\n\tif (v.vt !== 9) throw new VbaRuntimeError(450);\n\tif (v.v === null) throw new VbaRuntimeError(91);\n\tif (v.v instanceof ClassInstance) return v.v.dispatch('', 'get', args, undefined, undefined, run);\n\treturn v.v.get('', values);\n}\n\n/** The class instance a value holds (directly or through an interface view), else null. */\nexport function classInstanceOf(v: Value): ClassInstance | null {\n\tif (v.vt !== 9 || v.v === null) return null;\n\tconst o = v.v;\n\tif (o instanceof ClassInstance) return o;\n\tconst viewed = (o as { instance?: unknown }).instance;\n\treturn viewed instanceof ClassInstance ? viewed : null;\n}\n","// An object seen through an interface it implements ([MS-VBAL] 5.3.1.3): `Dim s As IShape` holding\n// a CCircle. Member `Area` runs the class's `IShape_Area`; identity, TypeName and the reference\n// count are the instance's.\nimport type { NamedArgs, Value, VbaObject, VObj } from '../../runtime/index';\nimport type { BoundModule } from '../../semantic/index';\nimport { andThen, type MaybePromise, type MaybeValue } from '../async';\nimport type { ClassInstance } from './class-instance';\nimport { VIEW, counted, type Counted } from './lifetime';\n\nexport class InterfaceView implements VbaObject, Counted {\n\tconstructor(\n\t\treadonly instance: ClassInstance,\n\t\treadonly iface: BoundModule,\n\t) {\n\t\tcounted(this);\n\t\t(this as unknown as Record<symbol, unknown>)[VIEW] = instance;\n\t}\n\n\ttypeName(): string {\n\t\treturn this.instance.typeName();\n\t}\n\n\tidentity(): unknown {\n\t\treturn this.instance;\n\t}\n\n\t/** The implementing member's name: `IShape_Area`, or the default member's. */\n\tmember(name: string): string {\n\t\tconst n = name === '' ? this.iface.defaultMember?.name : name;\n\t\treturn n === undefined ? '' : `${this.iface.name}_${n}`;\n\t}\n\n\tget(name: string, args: readonly Value[], named?: NamedArgs): MaybeValue {\n\t\treturn this.instance.external(this.member(name), 'get', args, named, undefined, true);\n\t}\n\n\tlet(name: string, args: readonly Value[], value: Value): MaybePromise<void> {\n\t\tconst r = this.instance.external(this.member(name), 'let', args, undefined, value, true);\n\t\treturn andThen(r, () => undefined);\n\t}\n\n\tset(name: string, args: readonly Value[], value: VObj): MaybePromise<void> {\n\t\tconst r = this.instance.external(this.member(name), 'set', args, undefined, value, true);\n\t\treturn andThen(r, () => undefined);\n\t}\n\n\tcall(name: string, args: readonly Value[], named?: NamedArgs): MaybeValue {\n\t\treturn this.instance.external(this.member(name), 'call', args, named, undefined, true);\n\t}\n\n\tretain(): void {\n\t\tthis.instance.retain();\n\t}\n\n\trelease(): void {\n\t\tthis.instance.release();\n\t}\n\n\tescape(): void {\n\t\tthis.instance.escape();\n\t}\n}\n","// `TypeOf x Is T` ([MS-VBAL] 5.6.9.9) through the runtime's `typeIs`: a class of the project\n// matches its instances and the classes that implement it; any other name matches a host object's\n// `TypeName`. A name qualified by another project never matches a class of this one.\nimport type { TypeRef } from '../../lang/index';\nimport { typeIs, type ClassFacts, type Value, type VbaObject } from '../../runtime/index';\nimport type { CompileContext } from '../compile/context';\nimport { ClassInstance } from './class-instance';\nimport { InterfaceView } from './interface-view';\n\nconst FACTS = new WeakMap<object, ClassFacts>();\n\n/** The class facts of an interpreter object (an instance, or one seen through an interface). */\nfunction classOf(o: VbaObject): ClassFacts | null {\n\tconst instance = o instanceof ClassInstance ? o : o instanceof InterfaceView ? o.instance : null;\n\tif (!instance) return null;\n\tconst m = instance.module;\n\tlet facts = FACTS.get(m);\n\tif (!facts) {\n\t\tfacts = { name: m.name, implements: m.implements.map((i) => i.name) };\n\t\tFACTS.set(m, facts);\n\t}\n\treturn facts;\n}\n\nexport function typeOfTest(ctx: CompileContext, type: TypeRef): (v: Value) => boolean {\n\tconst name = type.parts.at(-1)?.name ?? type.name;\n\tconst qualified = type.parts.length > 1 ? (type.parts[0]?.name ?? '').toLowerCase() : null;\n\tconst foreign =\n\t\tqualified !== null && qualified !== ctx.services.session.projectName.toLowerCase();\n\t// `OtherLib.Class1` never names a class of this project: compare host objects only.\n\tconst facts = foreign\n\t\t? (o: VbaObject) => (classOf(o) ? { name: '', implements: [] } : null)\n\t\t: classOf;\n\treturn (v) => typeIs(v, name, facts);\n}\n","// Member access on run-time objects ([MS-VBAL] 5.6.12, 5.6.13.1): reads, calls, Let and Set on\n// class instances (which take references, so ByRef arguments work late-bound too) and on host\n// objects (which take values), and indexing into arrays.\nimport {\n\tMISSING,\n\tVbaRuntimeError,\n\ttoLng,\n\tvObj,\n\ttype NamedArgs,\n\ttype Ref,\n\ttype Value,\n\ttype VbaObject,\n\ttype VbaSession,\n\ttype VObj,\n} from '../../runtime/index';\nimport { andThen, type MaybePromise, type MaybeValue } from '../async';\nimport { scalarOf } from '../ops';\nimport type { RunContext } from '../run-context';\nimport { ClassInstance, type Access } from './class-instance';\nimport { InterfaceView } from './interface-view';\nimport { escape } from './lifetime';\nimport { isCountingStore, letMember } from '../../runtime/index';\nimport { ElementRef } from '../storage';\n\n/** The object a value holds: error 91 for Nothing, 424 for a value that is not an object. */\nexport function objectOf(v: Value): VbaObject {\n\tif (v.vt !== 9) throw new VbaRuntimeError(424);\n\tif (v.v === null) throw new VbaRuntimeError(91);\n\treturn v.v;\n}\n\n/** Argument values for a host member: objects escape, unless the host counts its references. */\nconst values = (args: readonly (Ref | null)[], counting: boolean): Value[] =>\n\targs.map((a) => {\n\t\tif (!a) return MISSING;\n\t\tconst v = a.get();\n\t\tif (!counting) escape(v);\n\t\treturn v;\n\t});\n\n/** Calls a member of an object with argument references (`value` for Let and Set). */\nexport function member(\n\to: VbaObject,\n\tname: string,\n\taccess: Access,\n\targs: readonly (Ref | null)[],\n\tnamed: NamedArgs | undefined,\n\trun: RunContext,\n\tvalue?: Value,\n): MaybeValue {\n\tif (o instanceof ClassInstance) return o.dispatch(name, access, args, named, value, run);\n\tif (o instanceof InterfaceView)\n\t\treturn o.instance.dispatch(o.member(name), access, args, named, value, run, true);\n\tif (name.toLowerCase() === '_newenum' && o.enumerate && args.length === 0)\n\t\treturn vObj(enumerator(o));\n\tconst list = values(args, isCountingStore(o));\n\tswitch (access) {\n\t\tcase 'get':\n\t\t\treturn o.get(name, list, named);\n\t\tcase 'call':\n\t\t\treturn o.call(name, list, named);\n\t\tcase 'let':\n\t\t\t// A read-only member's result takes the value through its default member (`ActiveCell = 5`).\n\t\t\treturn done(\n\t\t\t\tletMember(o, name, list, value as Value, (t, v) =>\n\t\t\t\t\tandThen(member(t, '', 'let', [], undefined, run, v), () => undefined),\n\t\t\t\t),\n\t\t\t);\n\t\tcase 'set':\n\t\t\tescape(value as Value);\n\t\t\treturn done(o.set(name, list, value as VObj));\n\t}\n}\n\nconst EMPTY_RESULT: Value = { vt: 0 };\nconst done = (r: MaybePromise<void>): MaybeValue => andThen(r, () => EMPTY_RESULT);\n\n/** `obj.[_NewEnum]`: an object that enumerates what `obj` enumerates. */\nfunction enumerator(o: VbaObject): VbaObject {\n\treturn {\n\t\ttypeName: () => 'IEnumVARIANT',\n\t\tget: () => {\n\t\t\tthrow new VbaRuntimeError(438);\n\t\t},\n\t\tlet: () => {\n\t\t\tthrow new VbaRuntimeError(438);\n\t\t},\n\t\tset: () => {\n\t\t\tthrow new VbaRuntimeError(438);\n\t\t},\n\t\tcall: () => {\n\t\t\tthrow new VbaRuntimeError(438);\n\t\t},\n\t\tenumerate: () => (o.enumerate as NonNullable<VbaObject['enumerate']>)(),\n\t};\n}\n\n/** An array index: each index Let-coerced to Long (error 9 out of range, 13 for a non-number). */\nexport function indexOf(v: Value, s: VbaSession): number {\n\tif (v.vt === 2 || v.vt === 3) return v.v;\n\treturn toLng(v, s);\n}\n\n/**\n * `value(args)`: an array element, else the default member called with the arguments. With\n * `access` let or set, stores `newValue` there instead.\n */\nexport function indexValue(\n\tvalue: Value,\n\targs: readonly Value[],\n\trefs: readonly (Ref | null)[],\n\tf: { readonly session: VbaSession; readonly run: RunContext },\n\taccess: Access = 'get',\n\tnewValue?: Value,\n): MaybeValue {\n\tif (value.vt === 8192) {\n\t\tconst idx: number[] = [];\n\t\tfor (let i = 0; i < args.length; i++) {\n\t\t\tconst s = scalarOf(args[i] as Value);\n\t\t\tif (s instanceof Promise)\n\t\t\t\treturn s.then(() => indexValue(value, args, refs, f, access, newValue));\n\t\t\tidx.push(indexOf(s, f.session));\n\t\t}\n\t\tif (access === 'let' || access === 'set') {\n\t\t\tnew ElementRef(value.v, idx).set(newValue as Value);\n\t\t\treturn EMPTY_RESULT;\n\t\t}\n\t\treturn value.v.get(idx);\n\t}\n\tif (value.vt === 9) return member(objectOf(value), '', access, refs, undefined, f.run, newValue);\n\tthrow new VbaRuntimeError(13);\n}\n","// Where a variable lives at run time: a frame slot, a Static slot, the current instance's field\n// or a module variable. Each binding compiles to one small accessor.\nimport { VbaRuntimeError, copyValue, type Ref, type Value } from '../../runtime/index';\nimport type { ParamSymbol, VariableSymbol } from '../../semantic/index';\nimport type { Frame } from '../frame';\nimport { TempCell } from '../storage';\nimport type { CompileContext } from './context';\n\nexport type RefAt = (f: Frame) => Ref;\n\nexport function variableRef(ctx: CompileContext, sym: VariableSymbol | ParamSymbol): RefAt {\n\tconst i = sym.slot;\n\tif (sym.kind === 'param') return (f) => f.slots[i] as Ref;\n\tswitch (sym.scope) {\n\t\tcase 'local':\n\t\tcase 'result':\n\t\t\treturn (f) => f.slots[i] as Ref;\n\t\tcase 'static':\n\t\t\treturn (f) => f.statics[i] as Ref;\n\t\tcase 'instance':\n\t\t\treturn (f) => {\n\t\t\t\tif (!f.instance) throw new VbaRuntimeError(91);\n\t\t\t\treturn f.instance.vars[i] as Ref;\n\t\t\t};\n\t\tcase 'module': {\n\t\t\tconst m = ctx.program.module(sym.module);\n\t\t\tif (!m) throw new Error(`unknown module ${sym.module}`);\n\t\t\tconst state = ctx.services.moduleState(m);\n\t\t\treturn () => state.vars[i] as Ref;\n\t\t}\n\t}\n}\n\n/** A temporary for an expression passed ByRef: arrays and records are copied, as VBA does. */\nexport const temp = (v: Value): TempCell =>\n\tnew TempCell(v.vt === 8192 || v.vt === 36 ? copyValue(v) : v);\n","// Argument lists: evaluated left to right, synchronously until one argument answers with a\n// Promise. Compiled procedures get references (ByRef) or temporaries (ByVal) placed on their\n// parameters by the binder; library functions get values; late-bound members get references for\n// plain variables (so ByRef works through `Object` and Variants too) and values otherwise.\nimport type { Argument, Expression } from '../../lang/index';\nimport { MISSING, type NamedArgs, type Ref, type Value } from '../../runtime/index';\nimport type { CallSite } from '../../semantic/index';\nimport type { MaybePromise } from '../async';\nimport type { Frame } from '../frame';\nimport { TempCell } from '../storage';\nimport type { Compiler } from './types';\nimport { temp } from './variables';\n\nexport type Part<T> = (f: Frame) => MaybePromise<T>;\n\n/** Runs parts in order; the result is synchronous unless a part returns a Promise. */\nexport function collect<T>(parts: readonly Part<T>[], f: Frame): MaybePromise<T[]> {\n\tconst out: T[] = new Array<T>(parts.length);\n\tfor (let i = 0; i < parts.length; i++) {\n\t\tconst r = (parts[i] as Part<T>)(f);\n\t\tif (r instanceof Promise) return finish(parts, f, out, i, r);\n\t\tout[i] = r;\n\t}\n\treturn out;\n}\n\nasync function finish<T>(\n\tparts: readonly Part<T>[],\n\tf: Frame,\n\tout: T[],\n\tat: number,\n\tpending: Promise<T>,\n): Promise<T[]> {\n\tout[at] = await pending;\n\tfor (let i = at + 1; i < parts.length; i++) out[i] = await (parts[i] as Part<T>)(f);\n\treturn out;\n}\n\nconst NONE: Part<null> = () => null;\n\nfunction tempOf(x: Compiler, e: Expression, copy: boolean): Part<Ref> {\n\tconst v = x.value(e);\n\treturn (f) => {\n\t\tconst r = v(f);\n\t\tif (r instanceof Promise) return r.then((y) => (copy ? temp(y) : new TempCell(y)));\n\t\treturn copy ? temp(r) : new TempCell(r);\n\t};\n}\n\nexport interface SiteArgs {\n\treadonly refs: (Ref | null)[];\n\treadonly rest: Value[];\n}\n\n/** The arguments of a call to a compiled procedure, as the binder matched them. */\nexport function siteArgs(x: Compiler, site: CallSite): (f: Frame) => MaybePromise<SiteArgs> {\n\tconst parts: Part<Ref | null>[] = site.params.map((a) => {\n\t\tif (!a || !a.expression) return NONE;\n\t\tif (a.passing === 'ref') return x.ref(a.expression);\n\t\treturn tempOf(x, a.expression, a.passing === 'temp');\n\t});\n\tconst rest: Part<Value>[] = site.rest.map((e) => (e ? x.value(e) : () => MISSING));\n\tif (rest.length === 0) {\n\t\tif (parts.length === 0) return () => ({ refs: [], rest: [] });\n\t\treturn (f) => {\n\t\t\tconst r = collect(parts, f);\n\t\t\treturn r instanceof Promise ? r.then((refs) => ({ refs, rest: [] })) : { refs: r, rest: [] };\n\t\t};\n\t}\n\tconst all: Part<Ref | null | Value>[] = [...parts, ...rest];\n\tconst n = parts.length;\n\treturn (f) => {\n\t\tconst r = collect(all, f);\n\t\tconst split = (list: (Ref | null | Value)[]): SiteArgs => ({\n\t\t\trefs: list.slice(0, n) as (Ref | null)[],\n\t\t\trest: list.slice(n) as Value[],\n\t\t});\n\t\treturn r instanceof Promise ? r.then(split) : split(r);\n\t};\n}\n\n/** The arguments of a library call: values, undefined where omitted. */\nexport function libraryArgs(\n\tx: Compiler,\n\tsite: CallSite,\n): (f: Frame) => MaybePromise<{ args: (Value | undefined)[]; rest: Value[] }> {\n\tconst parts: Part<Value | undefined>[] = site.params.map((a) =>\n\t\ta && a.expression ? x.value(a.expression) : () => undefined,\n\t);\n\tconst all: Part<Value | undefined>[] = [\n\t\t...parts,\n\t\t...site.rest.map((e) => (e ? x.value(e) : () => MISSING)),\n\t];\n\tconst n = parts.length;\n\treturn (f) => {\n\t\tconst r = collect(all, f);\n\t\tconst split = (list: (Value | undefined)[]) => ({\n\t\t\targs: list.slice(0, n),\n\t\t\trest: list.slice(n) as Value[],\n\t\t});\n\t\treturn r instanceof Promise ? r.then(split) : split(r);\n\t};\n}\n\nexport interface LateArgs {\n\treadonly refs: (Ref | null)[];\n\treadonly named: NamedArgs | undefined;\n}\n\n/** Arguments of a late-bound member: variables by reference, the rest as temporaries. */\nexport function lateArgs(\n\tx: Compiler,\n\targs: readonly Argument[],\n): (f: Frame) => MaybePromise<LateArgs> {\n\tconst positional = args.filter((a) => !a.name);\n\tconst named = args.filter((a) => a.name);\n\tconst parts: Part<Ref | null>[] = positional.map((a) => {\n\t\tif (!a.value) return NONE;\n\t\tif (!a.byVal && x.isVariable(a.value)) return x.ref(a.value);\n\t\treturn tempOf(x, a.value, true);\n\t});\n\tconst names = named.map((a) => (a.name?.name ?? '').toLowerCase());\n\tconst values: Part<Value>[] = named.map((a) => (a.value ? x.value(a.value) : () => MISSING));\n\tif (named.length === 0) {\n\t\tif (parts.length === 0) return () => ({ refs: [], named: undefined });\n\t\treturn (f) => {\n\t\t\tconst r = collect(parts, f);\n\t\t\treturn r instanceof Promise\n\t\t\t\t? r.then((refs) => ({ refs, named: undefined }))\n\t\t\t\t: { refs: r, named: undefined };\n\t\t};\n\t}\n\tconst all: Part<Ref | null | Value>[] = [...parts, ...values];\n\tconst n = parts.length;\n\treturn (f) => {\n\t\tconst r = collect(all, f);\n\t\tconst split = (list: (Ref | null | Value)[]): LateArgs => ({\n\t\t\trefs: list.slice(0, n) as (Ref | null)[],\n\t\t\tnamed: new Map(names.map((name, i) => [name, list[n + i] as Value])),\n\t\t});\n\t\treturn r instanceof Promise ? r.then(split) : split(r);\n\t};\n}\n","// What the compiler produces: closures over a `Frame` for expressions, references and statements,\n// and the instruction list of a procedure. No source text is generated or evaluated.\nimport { VbaRuntimeError, type Ref, type Value } from '../../runtime/index';\nimport type { BoundProcedure } from '../../semantic/index';\nimport type { MaybePromise, MaybeValue } from '../async';\nimport type { Frame } from '../frame';\nimport type { CompileContext } from './context';\nimport type {\n\tArgument,\n\tDictionaryAccess,\n\tExpression,\n\tMemberAccess,\n\tStatement,\n} from '../../lang/index';\nimport type { DynamicNames } from './dynamic';\n\n/** Evaluates an expression. */\nexport type Eval = (f: Frame) => MaybeValue;\n/** Evaluates a reference to storage (a variable, element or field). */\nexport type RefEval = (f: Frame) => MaybePromise<Ref>;\n/** Runs one instruction: undefined continues with the next, a number jumps to that instruction. */\nexport type Step = (f: Frame) => MaybePromise<number | undefined>;\n\nexport interface Instr {\n\treadonly run: Step;\n\t/** The 1-based source line of the statement, for error reports. */\n\treadonly line: number;\n\treadonly column: number;\n\t/** Where Resume Next continues after an error here, when not the next instruction. */\n\tskip?: { readonly pc: number };\n}\n\n/** Builds the storage of a local, Static local or result when a frame starts. */\nexport type CellFactory = () => Ref;\n\nexport interface CompiledProcedure {\n\treadonly bound: BoundProcedure;\n\treadonly code: readonly Instr[];\n\t/** Locals in slot order (after the parameters and the result slot). */\n\treadonly locals: readonly CellFactory[];\n\treadonly statics: readonly CellFactory[];\n\treadonly result: CellFactory | null;\n\t/** Per parameter: the storage of a ByVal (or temporary) argument, typed as declared. */\n\treadonly params: readonly ParamPlan[];\n}\n\nexport interface ParamPlan {\n\t/** Shares the caller's reference (ByRef given a variable). */\n\treadonly byRef: boolean;\n\treadonly optional: boolean;\n\treadonly paramArray: boolean;\n\t/** A cell of the declared type holding `value`. */\n\treadonly cell: CellFactory;\n\t/** The value of an omitted Optional parameter (its default, Missing or the type's default). */\n\treadonly omitted: Value | null;\n}\n\n/** How a member is used: read, called as a statement, or assigned with Let or Set. */\nexport type Access = 'get' | 'call' | 'let' | 'set';\n\n/**\n * The expression compiler as the satellite modules (names, calls, references, stores) see it, so\n * they reach each other through it rather than importing each other.\n */\nexport interface Compiler {\n\treadonly ctx: CompileContext;\n\tvalue(e: Expression): Eval;\n\tscalar(e: Expression): Eval;\n\tref(e: Expression): RefEval;\n\t/** A plain variable or parameter: passed by reference to late-bound members. */\n\tisVariable(e: Expression): boolean;\n\t/** A call or index (`node` carries the invocation). */\n\tinvoke(\n\t\tnode: Expression | Statement,\n\t\ttarget: Expression,\n\t\targs: readonly Argument[],\n\t\taccess: Access,\n\t): Eval;\n\t/** The object of a member access: its qualifier, or the subject of the enclosing With. */\n\tqualifier(e: MemberAccess | DictionaryAccess): Eval;\n\t/** The run-time resolution of an undeclared name (see `dynamic.ts`). */\n\treadonly dynamics: DynamicNames;\n}\n\n/** An expression that always raises error `n` (a member that cannot run, an unbound call). */\nexport const fail =\n\t(n: number, what?: string): Eval =>\n\t() => {\n\t\tthrow new VbaRuntimeError(n, what);\n\t};\n","// Calls and indexes ([MS-VBAL] 5.6.13, 5.4.2.2): compiles each `Invocation` kind the binder chose:\n// a procedure of the project, a library function, an array element, a member of a run-time\n// object, or the default member / element decided at run time.\nimport type { Argument, Expression, Statement } from '../../lang/index';\nimport {\n\tVbaRuntimeError,\n\tlenOfType,\n\tnotSupported,\n\ttype Ref,\n\ttype Value,\n} from '../../runtime/index';\nimport { andThen, type MaybeValue } from '../async';\nimport type { Binding, Invocation, PropertyGroup, CallSite } from '../../semantic/index';\nimport type { Frame } from '../frame';\nimport { ClassInstance, classInstanceOf } from '../objects/class-instance';\nimport { indexOf, indexValue, member, objectOf } from '../objects/members';\nimport { scalarOf } from '../ops';\nimport { TempCell } from '../storage';\nimport { collect, lateArgs, libraryArgs, siteArgs, type Part } from './args';\nimport { fail, type Access, type Compiler, type Eval } from './types';\n\n/**\n * Compiles a call or index. `value` (for Let and Set) is the right-hand side, appended as the\n * last argument of a Property Let/Set or stored into the element or default member.\n */\nexport function invocationValue(\n\tx: Compiler,\n\tnode: Expression | Statement,\n\ttarget: Expression,\n\targs: readonly Argument[],\n\taccess: Access,\n\tvalue?: Eval,\n): Eval {\n\tconst inv: Invocation | undefined = x.ctx.invocation(node);\n\tswitch (inv?.kind) {\n\t\tcase 'call': {\n\t\t\tif (!inv.indexResult) return procedureCall(x, target, inv.group, inv.site, access, value);\n\t\t\tconst base = procedureCall(x, target, inv.group, inv.site, 'get', undefined);\n\t\t\treturn indexed(x, base, args, access, value);\n\t\t}\n\t\tcase 'declare':\n\t\t\treturn () => notSupported(`Calling the DLL procedure ${inv.symbol.name} (Declare)`);\n\t\tcase 'library': {\n\t\t\tif (inv.typedLength !== undefined) {\n\t\t\t\tconst size = lenOfType(inv.typedLength);\n\t\t\t\treturn () => size;\n\t\t\t}\n\t\t\tconst call = x.ctx.services.library.compile(\n\t\t\t\tinv.entry,\n\t\t\t\tx.ctx.module,\n\t\t\t\tinv.typedArgument ?? false,\n\t\t\t);\n\t\t\tconst values = libraryArgs(x, inv.site);\n\t\t\treturn (f) => {\n\t\t\t\tconst a = values(f);\n\t\t\t\tif (a instanceof Promise) return a.then((r) => call(r.args, r.rest, f));\n\t\t\t\treturn call(a.args, a.rest, f);\n\t\t\t};\n\t\t}\n\t\tcase 'index':\n\t\t\treturn indexCall(x, target, args, access, value);\n\t\tcase 'dynamic':\n\t\t\treturn dynamicCall(x, target, args, access, value);\n\t\tcase 'member':\n\t\t\treturn memberCall(x, target, args, inv.name, access, value);\n\t\tdefault:\n\t\t\treturn fail(51, 'Internal error: an unbound call');\n\t}\n}\n\nexport function procedureCall(\n\tx: Compiler,\n\ttarget: Expression,\n\tgroup: PropertyGroup,\n\tsite: CallSite,\n\taccess: Access,\n\tvalue: Eval | undefined,\n): Eval {\n\tconst proc = group.forAccess(access);\n\tif (!proc) return fail(access === 'get' ? 451 : 438);\n\tconst services = x.ctx.services;\n\tconst argsOf = siteArgs(x, site);\n\tconst me = receiverOf(x, target);\n\t// The object of an early-bound member is evaluated first, then the right-hand side, then the\n\t// arguments.\n\treturn (f) => {\n\t\tconst call = (instance: ClassInstance | null): MaybeValue => {\n\t\t\tconst withArgs = (r: Args, rhs?: Value) =>\n\t\t\t\tservices.invoke(\n\t\t\t\t\tproc,\n\t\t\t\t\trhs ? [...r.refs, new TempCell(rhs)] : r.refs,\n\t\t\t\t\tr.rest,\n\t\t\t\t\tinstance,\n\t\t\t\t\tf.run,\n\t\t\t\t);\n\t\t\tif (!value) return andThen(argsOf(f), (r) => withArgs(r));\n\t\t\treturn andThen(value(f), (rhs) => andThen(argsOf(f), (r) => withArgs(r, rhs)));\n\t\t};\n\t\tconst instance = me(f);\n\t\treturn instance instanceof Promise ? instance.then(call) : call(instance);\n\t};\n}\n\ntype Args = { refs: (Ref | null)[]; rest: Value[] };\n\n/** Where `Me` of the called procedure comes from: none, the caller's own, or the member's object. */\nfunction receiverOf(\n\tx: Compiler,\n\ttarget: Expression,\n): (f: Frame) => ClassInstance | null | Promise<ClassInstance | null> {\n\tconst b: Binding | undefined = x.ctx.binding(target);\n\tif (b?.kind !== 'procedure' || b.receiver === 'none') return () => null;\n\tif (b.receiver === 'self' || target.kind !== 'MemberAccess') return (f) => f.instance;\n\tconst object = x.qualifier(target);\n\treturn (f) => {\n\t\tconst o = object(f);\n\t\treturn o instanceof Promise ? o.then(instanceOf) : instanceOf(o);\n\t};\n}\n\n/** Values of index arguments, Let-coerced to Long when used on an array. */\nfunction indexParts(x: Compiler, args: readonly Argument[]): Part<Value>[] {\n\treturn args.map((a) => {\n\t\tif (!a.value) return fail(449);\n\t\treturn x.value(a.value);\n\t});\n}\n\nfunction indexCall(\n\tx: Compiler,\n\ttarget: Expression,\n\targs: readonly Argument[],\n\taccess: Access,\n\tvalue: Eval | undefined,\n): Eval {\n\tconst base = x.value(target);\n\tconst parts = indexParts(x, args);\n\tif (parts.length === 1 && !value && access !== 'let' && access !== 'set') {\n\t\tconst only = parts[0] as Part<Value>;\n\t\treturn (f) => {\n\t\t\tconst a = base(f);\n\t\t\tconst i = only(f);\n\t\t\tif (a instanceof Promise || i instanceof Promise)\n\t\t\t\treturn Promise.all([a, i]).then(([av, iv]) => indexValue(av, [iv], [], f));\n\t\t\tif (a.vt === 8192 && (i.vt === 2 || i.vt === 3)) return a.v.get([i.v]);\n\t\t\tif (a.vt === 8192) {\n\t\t\t\tconst s = scalarOf(i);\n\t\t\t\tif (!(s instanceof Promise)) return a.v.get([indexOf(s, f.session)]);\n\t\t\t}\n\t\t\treturn indexValue(a, [i], [], f);\n\t\t};\n\t}\n\t// Storing into an element of a declared array evaluates the right-hand side before the\n\t// indexes; a Variant holding an array evaluates the indexes first (as Office does).\n\tconst rhsFirst = value !== undefined && x.ctx.typeOf(target).kind === 'array';\n\treturn indexed(x, x.value(target), args, access, value, rhsFirst);\n}\n\nfunction dynamicCall(\n\tx: Compiler,\n\ttarget: Expression,\n\targs: readonly Argument[],\n\taccess: Access,\n\tvalue: Eval | undefined,\n): Eval {\n\treturn indexed(x, x.value(target), args, access, value);\n}\n\n/** Indexes a value at run time: an array element, or the default member with the arguments. */\nfunction indexed(\n\tx: Compiler,\n\tbase: Eval,\n\targs: readonly Argument[],\n\taccess: Access,\n\tvalue: Eval | undefined,\n\trhsFirst = false,\n): Eval {\n\tconst parts = indexParts(x, args);\n\tif (rhsFirst && value)\n\t\treturn (f) => {\n\t\t\tconst r = value(f);\n\t\t\tconst store = (rv: Value): ReturnType<Eval> => {\n\t\t\t\tconst a = base(f);\n\t\t\t\tconst on = (av: Value): ReturnType<Eval> => {\n\t\t\t\t\tconst list = collect(parts, f);\n\t\t\t\t\tconst put = (vals: Value[]) => indexValue(av, vals, [], f, access, rv);\n\t\t\t\t\treturn list instanceof Promise ? list.then(put) : put(list);\n\t\t\t\t};\n\t\t\t\treturn a instanceof Promise ? a.then(on) : on(a);\n\t\t\t};\n\t\t\treturn r instanceof Promise ? r.then(store) : store(r);\n\t\t};\n\treturn (f) => {\n\t\tconst a = base(f);\n\t\tconst go = (av: Value): ReturnType<Eval> => {\n\t\t\tconst list = collect(parts, f);\n\t\t\tconst withArgs = (vals: Value[]) => {\n\t\t\t\tconst refs = av.vt === 9 ? vals.map((v) => new TempCell(v)) : [];\n\t\t\t\tif (!value) return indexValue(av, vals, refs, f, access === 'call' ? 'get' : access);\n\t\t\t\tconst rhs = value(f);\n\t\t\t\treturn rhs instanceof Promise\n\t\t\t\t\t? rhs.then((r) => indexValue(av, vals, refs, f, access, r))\n\t\t\t\t\t: indexValue(av, vals, refs, f, access, rhs);\n\t\t\t};\n\t\t\treturn list instanceof Promise ? list.then(withArgs) : withArgs(list);\n\t\t};\n\t\treturn a instanceof Promise ? a.then(go) : go(a);\n\t};\n}\n\nfunction memberCall(\n\tx: Compiler,\n\ttarget: Expression,\n\targs: readonly Argument[],\n\tname: string,\n\taccess: Access,\n\tvalue: Eval | undefined,\n): Eval {\n\tconst argsOf = lateArgs(x, args);\n\tconst rhsOf = value ?? (() => undefined as unknown as Value);\n\tconst b = x.ctx.binding(target);\n\tif (target.kind === 'Name' && b?.kind === 'dynamic') {\n\t\tconst n = x.dynamics.of(b.name, b.document, b.fallback);\n\t\treturn (f) => {\n\t\t\tconst a = argsOf(f);\n\t\t\tconst go = (r: Awaited<typeof a>) => {\n\t\t\t\tconst rhs = value ? rhsOf(f) : undefined;\n\t\t\t\tif (rhs instanceof Promise)\n\t\t\t\t\treturn rhs.then((v) => x.dynamics.access(n, f, access, r.refs, r.named, v));\n\t\t\t\treturn x.dynamics.access(n, f, access, r.refs, r.named, rhs);\n\t\t\t};\n\t\t\treturn a instanceof Promise ? a.then(go) : go(a);\n\t\t};\n\t}\n\tif (target.kind !== 'MemberAccess' && target.kind !== 'DictionaryAccess')\n\t\treturn fail(51, 'Internal error: a member call without an object');\n\tconst object = x.qualifier(target);\n\treturn (f) => {\n\t\tconst o = object(f);\n\t\tconst go = (ov: Value) => {\n\t\t\tconst obj = objectOf(ov);\n\t\t\tconst a = argsOf(f);\n\t\t\tconst call = (r: Awaited<typeof a>) => {\n\t\t\t\tconst rhs = value ? rhsOf(f) : undefined;\n\t\t\t\tif (rhs instanceof Promise)\n\t\t\t\t\treturn rhs.then((v) => member(obj, name, access, r.refs, r.named, f.run, v));\n\t\t\t\treturn member(obj, name, access, r.refs, r.named, f.run, rhs);\n\t\t\t};\n\t\t\treturn a instanceof Promise ? a.then(call) : call(a);\n\t\t};\n\t\treturn o instanceof Promise ? o.then(go) : go(o);\n\t};\n}\n\n/** The instance an early-bound member is called on: error 91 for Nothing, 13 for another object. */\nfunction instanceOf(v: Value): ClassInstance {\n\tif (v.vt !== 9 || v.v === null) throw new VbaRuntimeError(91);\n\tconst o = classInstanceOf(v);\n\tif (!o) throw new VbaRuntimeError(13);\n\treturn o;\n}\n","// Names and member accesses as values ([MS-VBAL] 5.6.10, 5.6.12): each `Binding` kind compiles to\n// one closure. Calls of procedures and library functions without parentheses go to `invoke`.\nimport type { DictionaryAccess, Expression, MemberAccess, NameExpression } from '../../lang/index';\nimport {\n\tNOTHING,\n\tVbaRuntimeError,\n\tletAs,\n\tvDbl,\n\tvLng,\n\tvObj,\n\tvStr,\n\ttype Value,\n} from '../../runtime/index';\nimport type { Binding, LibraryConstant } from '../../semantic/index';\nimport type { Frame } from '../frame';\nimport { member, objectOf } from '../objects/members';\nimport { procedureCall } from './calls';\nimport { AutoNewCell, TempCell } from '../storage';\nimport { fail, type Access, type Compiler, type Eval } from './types';\nimport { variableRef } from './variables';\n\nexport function libraryConstantValue(entry: LibraryConstant): Value {\n\tif (typeof entry.value === 'string') return vStr(entry.value);\n\tif (entry.type.kind === 'scalar') return letAs(entry.type.vt, vDbl(entry.value));\n\treturn vLng(entry.value);\n}\n\n/** The value of a bound name-like node; `access` is `call` when it stands alone as a statement. */\nexport function bindingValue(\n\tx: Compiler,\n\tnode: Expression,\n\tb: Binding | undefined,\n\taccess: Access,\n): Eval {\n\tconst services = x.ctx.services;\n\tswitch (b?.kind) {\n\t\tcase 'variable':\n\t\tcase 'param':\n\t\tcase 'implicit':\n\t\tcase 'result': {\n\t\t\tconst ref = variableRef(x.ctx, b.symbol);\n\t\t\tif (b.symbol.kind === 'variable' && b.symbol.isNew && b.symbol.bounds === null)\n\t\t\t\t// `Dim o As New C`: the first use creates the object, waiting for an asynchronous\n\t\t\t\t// Class_Initialize when there is one.\n\t\t\t\treturn (f) => {\n\t\t\t\t\tconst cell = ref(f);\n\t\t\t\t\treturn cell instanceof AutoNewCell ? cell.ensure(f.run) : cell.get();\n\t\t\t\t};\n\t\t\treturn (f) => ref(f).get();\n\t\t}\n\t\tcase 'const': {\n\t\t\tconst symbol = b.symbol;\n\t\t\tlet v: Value | undefined;\n\t\t\treturn () => (v ??= services.constValue(symbol));\n\t\t}\n\t\tcase 'enumMember': {\n\t\t\tconst symbol = b.symbol;\n\t\t\tlet v: Value | undefined;\n\t\t\treturn () => (v ??= services.enumValue(symbol));\n\t\t}\n\t\tcase 'libraryConstant': {\n\t\t\tconst v = libraryConstantValue(b.entry);\n\t\t\treturn () => v;\n\t\t}\n\t\tcase 'procedure':\n\t\t\t// A property used as a qualifier (`Items.Add x`) carries no invocation of its own.\n\t\t\tif (!x.ctx.invocation(node))\n\t\t\t\treturn procedureCall(\n\t\t\t\t\tx,\n\t\t\t\t\tnode,\n\t\t\t\t\tb.group,\n\t\t\t\t\t{ params: [], rest: [] },\n\t\t\t\t\taccess === 'call' ? 'get' : access,\n\t\t\t\t\tundefined,\n\t\t\t\t);\n\t\t\treturn x.invoke(node, node, [], access);\n\t\tcase 'libraryFunction':\n\t\tcase 'declare':\n\t\t\treturn x.invoke(node, node, [], access);\n\t\tcase 'libraryObject': {\n\t\t\tif (b.entry.name === 'VBA') return fail(424);\n\t\t\tconst o = b.entry.name === 'Err' ? services.err : services.debug;\n\t\t\tconst v = vObj(o);\n\t\t\treturn () => v;\n\t\t}\n\t\tcase 'hostGlobal': {\n\t\t\tconst o = services.host.globals.get(b.name.toLowerCase());\n\t\t\tif (!o) return fail(424);\n\t\t\tconst v = vObj(o);\n\t\t\treturn () => v;\n\t\t}\n\t\tcase 'documentObject': {\n\t\t\tconst o = services.host.documentObjects.get(b.module.name.toLowerCase());\n\t\t\treturn o ? () => vObj(o) : fail(424);\n\t\t}\n\t\tcase 'class': {\n\t\t\tconst m = b.module;\n\t\t\tif (!m.predeclared) return fail(424);\n\t\t\treturn (f) => services.defaultInstance(m, f.run);\n\t\t}\n\t\tcase 'me':\n\t\t\treturn (f) => (f.me ? vObj(f.me) : NOTHING);\n\t\tcase 'dynamic': {\n\t\t\tconst n = x.dynamics.of(b.name, b.document, b.fallback);\n\t\t\treturn (f) => x.dynamics.access(n, f, access, [], undefined);\n\t\t}\n\t\tcase 'member':\n\t\tcase 'errMember':\n\t\tcase 'debugMember':\n\t\tcase 'udtField':\n\t\t\tif (node.kind === 'MemberAccess' || node.kind === 'DictionaryAccess')\n\t\t\t\treturn memberValue(x, node, access);\n\t\t\treturn fail(51);\n\t\tcase 'unresolved':\n\t\t\treturn fail(\n\t\t\t\tb.number,\n\t\t\t\tb.number === 35 ? `Sub, Function or variable not defined: ${b.name}` : undefined,\n\t\t\t);\n\t\tcase 'module':\n\t\tcase 'enum':\n\t\t\treturn fail(424);\n\t\tdefault:\n\t\t\treturn fail(51, 'Internal error: an unbound name');\n\t}\n}\n\nexport function nameValue(x: Compiler, e: NameExpression, access: Access): Eval {\n\treturn bindingValue(x, e, x.ctx.binding(e), access);\n}\n\n/** `object.member`, `.member` in a With block, `object!key`. */\nexport function memberValue(x: Compiler, e: MemberAccess | DictionaryAccess, access: Access): Eval {\n\tconst b = x.ctx.binding(e);\n\tswitch (b?.kind) {\n\t\tcase 'udtField': {\n\t\t\tconst object = x.qualifier(e);\n\t\t\tconst i = b.index;\n\t\t\treturn (f) => {\n\t\t\t\tconst u = object(f);\n\t\t\t\tif (u instanceof Promise) return u.then((y) => udtField(y, i));\n\t\t\t\treturn udtField(u, i);\n\t\t\t};\n\t\t}\n\t\tcase 'member':\n\t\tcase 'errMember':\n\t\tcase 'debugMember': {\n\t\t\tconst object = x.qualifier(e);\n\t\t\tif (e.kind === 'DictionaryAccess' || (b.kind === 'member' && b.dictionary)) {\n\t\t\t\tconst key = vStr(e.kind === 'DictionaryAccess' ? e.key.name : b.name);\n\t\t\t\treturn (f) => {\n\t\t\t\t\tconst o = object(f);\n\t\t\t\t\tconst read = (v: Value) =>\n\t\t\t\t\t\tmember(objectOf(v), '', 'get', [new TempCell(key)], undefined, f.run);\n\t\t\t\t\treturn o instanceof Promise ? o.then(read) : read(o);\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst name = b.name;\n\t\t\tconst how = access === 'call' ? 'call' : 'get';\n\t\t\treturn (f: Frame) => {\n\t\t\t\tconst o = object(f);\n\t\t\t\tif (o instanceof Promise)\n\t\t\t\t\treturn o.then((v) => member(objectOf(v), name, how, [], undefined, f.run));\n\t\t\t\treturn member(objectOf(o), name, how, [], undefined, f.run);\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn bindingValue(x, e, b, access);\n\t}\n}\n\nfunction udtField(v: Value, i: number): Value {\n\tif (v.vt !== 36) throw new VbaRuntimeError(13);\n\treturn v.v.values[i] as Value;\n}\n","// References for ByRef arguments ([MS-VBAL] 5.3.1.11): a variable, an array element or a UDT field\n// the callee writes through; anything else is a temporary holding the value.\nimport type { Expression } from '../../lang/index';\nimport { VbaRuntimeError, type Ref, type Value } from '../../runtime/index';\nimport type { MaybePromise } from '../async';\nimport type { Frame } from '../frame';\nimport { indexOf } from '../objects/members';\nimport { scalarOf } from '../ops';\nimport { ElementRef, FieldRef } from '../storage';\nimport { collect } from './args';\nimport type { Compiler, RefEval } from './types';\nimport { temp, variableRef } from './variables';\n\n/** Satisfied by `ExpressionCompiler`; named here so the expression module can import this one. */\nexport type RefCompiler = Compiler;\n\nfunction valueTemp(x: Compiler, e: Expression): RefEval {\n\tconst v = x.value(e);\n\treturn (f) => {\n\t\tconst r = v(f);\n\t\treturn r instanceof Promise ? r.then(temp) : temp(r);\n\t};\n}\n\nexport function referenceOf(x: Compiler, e: Expression): RefEval {\n\tconst b = x.ctx.binding(e);\n\tswitch (e.kind) {\n\t\tcase 'Name':\n\t\t\tif (\n\t\t\t\tb?.kind === 'variable' ||\n\t\t\t\tb?.kind === 'param' ||\n\t\t\t\tb?.kind === 'implicit' ||\n\t\t\t\tb?.kind === 'result'\n\t\t\t)\n\t\t\t\treturn variableRef(x.ctx, b.symbol);\n\t\t\tif (b?.kind === 'dynamic' && b.fallback) {\n\t\t\t\tconst n = x.dynamics.of(b.name, b.document, b.fallback);\n\t\t\t\tconst v = x.value(e);\n\t\t\t\treturn (f) => {\n\t\t\t\t\tconst r = v(f);\n\t\t\t\t\tconst pick = (value: Value): Ref =>\n\t\t\t\t\t\tn.isLocal(f.run) && n.local ? n.local(f) : temp(value);\n\t\t\t\t\treturn r instanceof Promise ? r.then(pick) : pick(r);\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn valueTemp(x, e);\n\t\tcase 'CallOrIndex': {\n\t\t\tconst inv = x.ctx.invocation(e);\n\t\t\tif (inv?.kind !== 'index' && inv?.kind !== 'dynamic') return valueTemp(x, e);\n\t\t\tconst base = x.ref(e.target);\n\t\t\tconst parts = e.args.map((a) => (a.value ? x.value(a.value) : () => ({ vt: 0 }) as Value));\n\t\t\tconst whole = x.value(e);\n\t\t\treturn (f) => {\n\t\t\t\tconst r = base(f);\n\t\t\t\tconst go = (ref: Ref): MaybePromise<Ref> => {\n\t\t\t\t\tconst v = ref.get();\n\t\t\t\t\tif (v.vt !== 8192) {\n\t\t\t\t\t\tconst w = whole(f);\n\t\t\t\t\t\treturn w instanceof Promise ? w.then(temp) : temp(w);\n\t\t\t\t\t}\n\t\t\t\t\tconst list = collect(parts, f);\n\t\t\t\t\tconst at = (vals: Value[]): MaybePromise<Ref> => {\n\t\t\t\t\t\tconst idx: number[] = [];\n\t\t\t\t\t\tfor (const a of vals) {\n\t\t\t\t\t\t\tconst s = scalarOf(a);\n\t\t\t\t\t\t\tif (s instanceof Promise) return s.then(() => at(vals));\n\t\t\t\t\t\t\tidx.push(indexOf(s, f.session));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tv.v.offset(idx);\n\t\t\t\t\t\treturn new ElementRef(v.v, idx);\n\t\t\t\t\t};\n\t\t\t\t\treturn list instanceof Promise ? list.then(at) : at(list);\n\t\t\t\t};\n\t\t\t\treturn r instanceof Promise ? r.then(go) : go(r);\n\t\t\t};\n\t\t}\n\t\tcase 'MemberAccess': {\n\t\t\tif (b?.kind !== 'udtField') return valueTemp(x, e);\n\t\t\tconst object = x.qualifier(e);\n\t\t\tconst i = b.index;\n\t\t\treturn (f: Frame) => {\n\t\t\t\tconst o = object(f);\n\t\t\t\tconst field = (v: Value): Ref => {\n\t\t\t\t\tif (v.vt !== 36) throw new VbaRuntimeError(13);\n\t\t\t\t\treturn new FieldRef(v.v, i);\n\t\t\t\t};\n\t\t\t\treturn o instanceof Promise ? o.then(field) : field(o);\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn valueTemp(x, e);\n\t}\n}\n","// Names declared nowhere in the project, resolved at run time ([MS-VBAL] 5.6.10 with the host's\n// global object): a member of the document module's host object, then a member of the host's\n// global object, then (without Option Explicit) an implicit local. A 438 from an object is\n// remembered per name for the rest of the run, so a local used in a loop asks the host once per\n// run; the next run asks again (the host may have gained the member).\nimport {\n\tVbaRuntimeError,\n\ttype NamedArgs,\n\ttype Ref,\n\ttype Value,\n\ttype VbaObject,\n} from '../../runtime/index';\nimport type { VariableSymbol } from '../../semantic/index';\nimport { andThen, type MaybeValue } from '../async';\nimport type { Frame } from '../frame';\nimport { indexValue, member } from '../objects/members';\nimport type { CompileContext } from './context';\nimport type { Access } from './types';\nimport { variableRef, type RefAt } from './variables';\n\nconst is438 = (e: unknown): boolean => e instanceof VbaRuntimeError && e.number === 438;\n\n/** What is known about one undeclared name in one procedure. */\nclass DynamicName {\n\tprivate readonly onDocument: boolean;\n\tprivate readonly onGlobal: boolean;\n\t/** The run in which the document object, or the global object, answered 438 for the name. */\n\tdocumentMiss: object | null = null;\n\tglobalMiss: object | null = null;\n\treadonly local: RefAt | null;\n\n\tconstructor(\n\t\tctx: CompileContext,\n\t\treadonly name: string,\n\t\tdocument: boolean,\n\t\tfallback: VariableSymbol | null,\n\t) {\n\t\tthis.onDocument = document;\n\t\tthis.onGlobal = ctx.services.host.globalObject !== undefined;\n\t\tthis.local = fallback ? variableRef(ctx, fallback) : null;\n\t}\n\n\t/** Whether to look on the document's host object in `run`. */\n\tdocument(run: object): boolean {\n\t\treturn this.onDocument && this.documentMiss !== run;\n\t}\n\n\tglobal(run: object): boolean {\n\t\treturn this.onGlobal && this.globalMiss !== run;\n\t}\n\n\t/** Whether the name is the implicit local in `run` (no host object has it). */\n\tisLocal(run: object): boolean {\n\t\treturn !this.document(run) && !this.global(run) && this.local !== null;\n\t}\n}\n\nexport class DynamicNames {\n\tprivate readonly names = new Map<string, DynamicName>();\n\n\tconstructor(private readonly ctx: CompileContext) {}\n\n\tof(name: string, document: boolean, fallback: VariableSymbol | null): DynamicName {\n\t\tconst key = name.toLowerCase();\n\t\tlet n = this.names.get(key);\n\t\tif (!n) {\n\t\t\tn = new DynamicName(this.ctx, name, document, fallback);\n\t\t\tthis.names.set(key, n);\n\t\t}\n\t\treturn n;\n\t}\n\n\t/** Reads, calls or assigns the name, with arguments (`Range(\"A1\")`) or without. */\n\taccess(\n\t\tn: DynamicName,\n\t\tf: Frame,\n\t\taccess: Access,\n\t\trefs: readonly (Ref | null)[],\n\t\tnamed: NamedArgs | undefined,\n\t\tvalue?: Value,\n\t): MaybeValue {\n\t\treturn this.attempt(n, f, access, refs, named, value, 0);\n\t}\n\n\tprivate attempt(\n\t\tn: DynamicName,\n\t\tf: Frame,\n\t\taccess: Access,\n\t\trefs: readonly (Ref | null)[],\n\t\tnamed: NamedArgs | undefined,\n\t\tvalue: Value | undefined,\n\t\tstage: number,\n\t): MaybeValue {\n\t\tconst host = this.ctx.services.host;\n\t\tif (stage === 0 && n.document(f.run) && f.me) {\n\t\t\tconst r = this.tryOn(f.me, n, f, access, refs, named, value, () => (n.documentMiss = f.run));\n\t\t\tif (r !== MISS)\n\t\t\t\treturn r instanceof Promise\n\t\t\t\t\t? r.then((v) => (v === MISS ? this.attempt(n, f, access, refs, named, value, 1) : v))\n\t\t\t\t\t: r;\n\t\t}\n\t\tif (stage <= 1 && n.global(f.run) && host.globalObject) {\n\t\t\tconst r = this.tryOn(\n\t\t\t\thost.globalObject,\n\t\t\t\tn,\n\t\t\t\tf,\n\t\t\t\taccess,\n\t\t\t\trefs,\n\t\t\t\tnamed,\n\t\t\t\tvalue,\n\t\t\t\t() => (n.globalMiss = f.run),\n\t\t\t);\n\t\t\tif (r !== MISS)\n\t\t\t\treturn r instanceof Promise\n\t\t\t\t\t? r.then((v) => (v === MISS ? this.local(n, f, access, refs, value) : v))\n\t\t\t\t\t: r;\n\t\t}\n\t\treturn this.local(n, f, access, refs, value);\n\t}\n\n\tprivate tryOn(\n\t\to: VbaObject,\n\t\tn: DynamicName,\n\t\tf: Frame,\n\t\taccess: Access,\n\t\trefs: readonly (Ref | null)[],\n\t\tnamed: NamedArgs | undefined,\n\t\tvalue: Value | undefined,\n\t\tmiss: () => void,\n\t): MaybeValue | typeof MISS {\n\t\ttry {\n\t\t\tconst r = member(o, n.name, access, refs, named, f.run, value);\n\t\t\tif (r instanceof Promise)\n\t\t\t\treturn r.catch((e: unknown) => {\n\t\t\t\t\tif (!is438(e)) throw e;\n\t\t\t\t\tmiss();\n\t\t\t\t\treturn MISS as unknown as Value;\n\t\t\t\t});\n\t\t\treturn r;\n\t\t} catch (e) {\n\t\t\tif (!is438(e)) throw e;\n\t\t\tmiss();\n\t\t\treturn MISS;\n\t\t}\n\t}\n\n\tprivate local(\n\t\tn: DynamicName,\n\t\tf: Frame,\n\t\taccess: Access,\n\t\trefs: readonly (Ref | null)[],\n\t\tvalue: Value | undefined,\n\t): MaybeValue {\n\t\tif (!n.local) throw new VbaRuntimeError(438, `Variable not defined (${n.name})`);\n\t\tconst cell = n.local(f);\n\t\tif (access === 'let' || access === 'set') {\n\t\t\tif (refs.length > 0) {\n\t\t\t\tconst target = cell.get();\n\t\t\t\treturn andThen(\n\t\t\t\t\tindexValue(\n\t\t\t\t\t\ttarget,\n\t\t\t\t\t\trefs.map((r) => r?.get() ?? { vt: 0 }),\n\t\t\t\t\t\trefs,\n\t\t\t\t\t\tf,\n\t\t\t\t\t\taccess,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t),\n\t\t\t\t\t(v) => v,\n\t\t\t\t);\n\t\t\t}\n\t\t\tcell.set(value ?? { vt: 0 });\n\t\t\treturn { vt: 0 };\n\t\t}\n\t\tconst v = cell.get();\n\t\tif (refs.length === 0) return v;\n\t\treturn indexValue(\n\t\t\tv,\n\t\t\trefs.map((r) => r?.get() ?? { vt: 0 }),\n\t\t\trefs,\n\t\t\tf,\n\t\t);\n\t}\n}\n\nconst MISS = Object.freeze({ vt: -1 }) as unknown as Value;\n","// Compiles expressions ([MS-VBAL] 5.6) into closures over a `Frame`: one handler per expression\n// kind in a dispatch table. Names, member accesses and calls delegate to `names.ts` and\n// `calls.ts`; every closure stays synchronous until a host answers with a Promise.\nimport type {\n\tArgument,\n\tDictionaryAccess,\n\tExpression,\n\tMemberAccess,\n\tNumberLiteral,\n\tStatement,\n} from '../../lang/index';\nimport {\n\tEMPTY,\n\tNOTHING,\n\tNULL,\n\tVbaRuntimeError,\n\tcurFromNumber,\n\tnotSupported,\n\tvBool,\n\tvCur,\n\tvDate,\n\tvDbl,\n\tvInt,\n\tvLLng,\n\tvLng,\n\tvSng,\n\tvStr,\n\ttype Ref,\n\ttype Value,\n\ttype VbaSession,\n} from '../../runtime/index';\nimport { isVariant, type StaticType } from '../../semantic/index';\nimport type { MaybeValue } from '../async';\nimport { binaryOperator, scalarOf, unaryOperator } from '../ops';\nimport { typeOfTest } from '../objects/type-of';\nimport { invocationValue } from './calls';\nimport type { CompileContext } from './context';\nimport { memberValue, nameValue } from './names';\nimport { referenceOf, type RefCompiler } from './refs';\nimport { DynamicNames } from './dynamic';\nimport type { Access, Eval, RefEval } from './types';\n\ntype Handler<K extends Expression['kind']> = (\n\tx: ExpressionCompiler,\n\te: Extract<Expression, { kind: K }>,\n) => Eval;\ntype Table = { readonly [K in Expression['kind']]: Handler<K> };\n\nconst constant =\n\t(v: Value): Eval =>\n\t() =>\n\t\tv;\n\nfunction numberValue(e: NumberLiteral): Value {\n\tswitch (e.literalType) {\n\t\tcase 'Integer':\n\t\t\treturn vInt(e.value);\n\t\tcase 'Long':\n\t\t\treturn vLng(e.value);\n\t\tcase 'LongLong':\n\t\t\treturn vLLng(BigInt(e.bigValue ?? Math.trunc(e.value)));\n\t\tcase 'Single':\n\t\t\treturn vSng(e.value);\n\t\tcase 'Currency':\n\t\t\treturn vCur(e.exact ? BigInt(e.exact.mantissa) : curFromNumber(e.value));\n\t\tdefault:\n\t\t\treturn vDbl(e.value);\n\t}\n}\n\n/** The simple value of an operand: an object's default member (`Is` keeps the object). */\nfunction operand(ev: Eval): Eval {\n\treturn (f) => {\n\t\tconst v = ev(f);\n\t\tif (v instanceof Promise) return v.then((x) => (x.vt === 9 ? scalarOf(x) : x));\n\t\treturn v.vt === 9 ? scalarOf(v) : v;\n\t};\n}\n\nconst HANDLERS: Table = {\n\tNumberLiteral: (_x, e) => constant(numberValue(e)),\n\tStringLiteral: (_x, e) => constant(vStr(e.value)),\n\tDateLiteral: (_x, e) => constant(vDate(e.value)),\n\tBooleanLiteral: (_x, e) => constant(vBool(e.value)),\n\tNothingLiteral: () => constant(NOTHING),\n\tEmptyLiteral: () => constant(EMPTY),\n\tNullLiteral: () => constant(NULL),\n\tName: (x, e) => nameValue(x, e, 'get'),\n\tMe: () => (f) => (f.me ? { vt: 9, v: f.me } : NOTHING),\n\tMemberAccess: (x, e) => memberValue(x, e, 'get'),\n\tDictionaryAccess: (x, e) => memberValue(x, e, 'get'),\n\tCallOrIndex: (x, e) => invocationValue(x, e, e.target, e.args, 'get'),\n\tParen: (x, e) => x.value(e.expression),\n\tUnary: (x, e) => {\n\t\tconst strict = !isVariant(x.ctx.typeOf(e.operand));\n\t\tconst op = unaryOperator(e.operator, strict);\n\t\tconst a = operand(x.value(e.operand));\n\t\treturn (f) => {\n\t\t\tconst v = a(f);\n\t\t\treturn v instanceof Promise ? v.then((y) => op(y, f.session)) : op(v, f.session);\n\t\t};\n\t},\n\tBinary: (x, e) => {\n\t\tconst lt = x.ctx.typeOf(e.left);\n\t\tconst rt = x.ctx.typeOf(e.right);\n\t\tconst op = binaryOperator(e.operator, {\n\t\t\tstrict: !isVariant(lt) && !isVariant(rt),\n\t\t\tcompareText: x.ctx.compareText,\n\t\t\ttyped: x.ctx.program.isTypedOperand(e.left) || x.ctx.program.isTypedOperand(e.right),\n\t\t});\n\t\tconst raw = e.operator === 'Is';\n\t\tconst l = raw ? x.value(e.left) : operand(x.value(e.left));\n\t\tconst r = raw ? x.value(e.right) : operand(x.value(e.right));\n\t\treturn (f) => {\n\t\t\tconst a = l(f);\n\t\t\tif (a instanceof Promise) return a.then((av) => binaryRest(av, r, op, f));\n\t\t\treturn binaryRest(a, r, op, f);\n\t\t};\n\t},\n\tTypeOf: (x, e) => {\n\t\tconst test = typeOfTest(x.ctx, e.type);\n\t\tconst v = x.value(e.expression);\n\t\treturn (f) => {\n\t\t\tconst o = v(f);\n\t\t\treturn o instanceof Promise ? o.then((y) => vBool(test(y))) : vBool(test(o));\n\t\t};\n\t},\n\tNew: (x, e) => {\n\t\tconst type = x.ctx.typeOf(e);\n\t\treturn (f) => x.ctx.services.createObject(type, f.run);\n\t},\n\tAddressOf: () => () => notSupported('AddressOf'),\n\tFileNumber: () => () => notSupported('File I/O'),\n\tInvalidExpression: () => () => {\n\t\tthrow new VbaRuntimeError(5, 'Syntax error');\n\t},\n};\n\nfunction binaryRest(\n\ta: Value,\n\tr: Eval,\n\top: (a: Value, b: Value, s: VbaSession) => Value,\n\tf: Parameters<Eval>[0],\n): MaybeValue {\n\tconst b = r(f);\n\treturn b instanceof Promise ? b.then((bv) => op(a, bv, f.session)) : op(a, b, f.session);\n}\n\nexport class ExpressionCompiler implements RefCompiler {\n\treadonly dynamics: DynamicNames;\n\n\tconstructor(readonly ctx: CompileContext) {\n\t\tthis.dynamics = new DynamicNames(ctx);\n\t}\n\n\t/** The value of an expression. */\n\tvalue(e: Expression): Eval {\n\t\treturn (HANDLERS[e.kind] as Handler<Expression['kind']>)(this, e as never);\n\t}\n\n\t/** The simple data value (an object's default member). */\n\tscalar(e: Expression): Eval {\n\t\treturn operand(this.value(e));\n\t}\n\n\t/** A reference to the storage an expression names, or a temporary holding its value. */\n\tref(e: Expression): RefEval {\n\t\treturn referenceOf(this, e);\n\t}\n\n\tisVariable(e: Expression): boolean {\n\t\tif (e.kind !== 'Name') return false;\n\t\tconst k = this.ctx.binding(e)?.kind;\n\t\treturn k === 'variable' || k === 'param' || k === 'implicit' || k === 'result';\n\t}\n\n\tinvoke(\n\t\tnode: Expression | Statement,\n\t\ttarget: Expression,\n\t\targs: readonly Argument[],\n\t\taccess: Access,\n\t): Eval {\n\t\treturn invocationValue(this, node, target, args, access);\n\t}\n\n\t/** A name or member standing alone as a statement (`DoIt`, `obj.Refresh`). */\n\tstatement(e: Expression): Eval {\n\t\tif (e.kind === 'Name') return nameValue(this, e, 'call');\n\t\tif (e.kind === 'MemberAccess' || e.kind === 'DictionaryAccess')\n\t\t\treturn memberValue(this, e, 'call');\n\t\treturn this.value(e);\n\t}\n\n\t/**\n\t * The object of a member access, seen through its static type: an object declared as an\n\t * interface the class implements is viewed through that interface, wherever it came from (an\n\t * array element, a field, a function result).\n\t */\n\tqualifier(e: MemberAccess | DictionaryAccess): Eval {\n\t\tlet raw: Eval;\n\t\tlet type: StaticType;\n\t\tif (e.object) {\n\t\t\traw = this.value(e.object);\n\t\t\ttype = this.ctx.typeOf(e.object);\n\t\t} else {\n\t\t\tconst block = this.ctx.withBlock(e);\n\t\t\tif (!block)\n\t\t\t\treturn () => {\n\t\t\t\t\tthrow new VbaRuntimeError(91);\n\t\t\t\t};\n\t\t\tconst id = block.id;\n\t\t\ttype = block.subjectType;\n\t\t\traw =\n\t\t\t\ttype.kind === 'udt' ? (f) => (f.withRefs[id] as Ref).get() : (f) => f.with[id] ?? NOTHING;\n\t\t}\n\t\tif (type.kind !== 'object' || !type.classModule) return raw;\n\t\tconst cast = this.ctx.services.castObject(type);\n\t\treturn (f) => {\n\t\t\tconst v = raw(f);\n\t\t\treturn v instanceof Promise ? v.then(cast) : cast(v);\n\t\t};\n\t}\n}\n","// The instruction list of one procedure: statements compile to instructions that return the next\n// instruction (or undefined to fall through). Jump targets are filled in once the code after them\n// is emitted, so forward jumps (loop exits, labels below) work.\nimport type { Eval, Instr, Step } from './types';\n\n/** A jump target: its instruction index is known once `mark` is called. */\nexport class Target {\n\tpc = -1;\n}\n\nexport interface LoopFrame {\n\treadonly kind: 'For' | 'Do';\n\treadonly exit: Target;\n\t/** For Each: the block id of its cursor, closed when an Exit leaves the loop. */\n\treadonly cursor?: number;\n}\n\nexport class CodeBuilder {\n\treadonly code: Instr[] = [];\n\treadonly labels = new Map<string, Target>();\n\treadonly loops: LoopFrame[] = [];\n\t/** The end of the procedure (Exit Sub/Function/Property). */\n\treadonly end = new Target();\n\t/** The 1-based line of the statement being compiled. */\n\tline = 0;\n\t/** The 1-based column where that statement starts. */\n\tcolumn = 0;\n\tprivate nextLoop = 0;\n\n\tget pc(): number {\n\t\treturn this.code.length;\n\t}\n\n\temit(run: Step): number {\n\t\tthis.code.push({ run, line: this.line, column: this.column });\n\t\treturn this.code.length - 1;\n\t}\n\n\t/** An instruction that evaluates an expression for its effect. */\n\teffect(ev: Eval): number {\n\t\treturn this.emit((f) => {\n\t\t\tconst r = ev(f);\n\t\t\treturn r instanceof Promise ? r.then(() => undefined) : undefined;\n\t\t});\n\t}\n\n\tjump(t: Target): number {\n\t\treturn this.emit(() => t.pc);\n\t}\n\n\tmark(t: Target): void {\n\t\tt.pc = this.code.length;\n\t}\n\n\tlabel(name: string): Target {\n\t\tconst key = name.toLowerCase();\n\t\tlet t = this.labels.get(key);\n\t\tif (!t) {\n\t\t\tt = new Target();\n\t\t\tthis.labels.set(key, t);\n\t\t}\n\t\treturn t;\n\t}\n\n\t/** A new id for a loop, Select Case or With: its slot in the frame's per-block state. */\n\tblock(): number {\n\t\treturn this.nextLoop++;\n\t}\n\n\t/**\n\t * The innermost open loop of a kind (`Exit For` also leaves a For Each), with the For Each\n\t * cursors the exit leaves (that loop's own, and those of loops nested inside it).\n\t */\n\tloop(kind: 'For' | 'Do'): { loop: LoopFrame; cursors: number[] } | undefined {\n\t\tconst cursors: number[] = [];\n\t\tfor (let i = this.loops.length - 1; i >= 0; i--) {\n\t\t\tconst l = this.loops[i] as LoopFrame;\n\t\t\tif (l.cursor !== undefined) cursors.push(l.cursor);\n\t\t\tif (l.kind === kind) return { loop: l, cursors };\n\t\t}\n\t\treturn undefined;\n\t}\n}\n","// Assignments ([MS-VBAL] 5.4.3.8 Let, 5.4.3.9 Set): to a variable, element or field; to a Property\n// Let/Set of the project; to a member or default member of a run-time object; to a name resolved\n// at run time. Let assigns the simple value of the right-hand side (an object's default member),\n// Set requires an object.\nimport type { Expression, DictionaryAccess, MemberAccess } from '../../lang/index';\nimport { EMPTY, VbaRuntimeError, vStr, type Ref, type Value } from '../../runtime/index';\nimport type { VariableSymbol, ParamSymbol } from '../../semantic/index';\nimport type { MaybeValue } from '../async';\nimport type { Frame } from '../frame';\nimport { member, objectOf } from '../objects/members';\nimport { scalarOf } from '../ops';\nimport { TempCell } from '../storage';\nimport { invocationValue } from './calls';\nimport type { Compiler, Eval, RefEval } from './types';\nimport { variableRef } from './variables';\n\n/** The right-hand side as Let or Set sees it. */\nexport function rhs(x: Compiler, e: Expression, kind: 'let' | 'set'): Eval {\n\tconst v = x.value(e);\n\tif (kind === 'let')\n\t\treturn (f) => {\n\t\t\tconst r = v(f);\n\t\t\tif (r instanceof Promise) return r.then((y) => (y.vt === 9 ? scalarOf(y) : y));\n\t\t\treturn r.vt === 9 ? scalarOf(r) : r;\n\t\t};\n\treturn (f) => {\n\t\tconst r = v(f);\n\t\tif (r instanceof Promise) return r.then(requireObject);\n\t\treturn requireObject(r);\n\t};\n}\n\nfunction requireObject(v: Value): Value {\n\tif (v.vt !== 9) throw new VbaRuntimeError(424);\n\treturn v;\n}\n\n/** Stores into a reference once the value is known. */\nfunction storeRef(ref: RefEval, value: Eval): Eval {\n\treturn (f) => {\n\t\tconst v = value(f);\n\t\tconst put = (val: Value): MaybeValue => {\n\t\t\tconst r = ref(f);\n\t\t\tif (r instanceof Promise)\n\t\t\t\treturn r.then((cell) => {\n\t\t\t\t\tcell.set(val);\n\t\t\t\t\treturn EMPTY;\n\t\t\t\t});\n\t\t\tr.set(val);\n\t\t\treturn EMPTY;\n\t\t};\n\t\treturn v instanceof Promise ? v.then(put) : put(v);\n\t};\n}\n\nfunction variableStore(\n\tx: Compiler,\n\tsym: VariableSymbol | ParamSymbol,\n\tkind: 'let' | 'set',\n\tvalue: Eval,\n): Eval {\n\tconst ref = variableRef(x.ctx, sym);\n\tif (kind === 'let' && sym.type.kind === 'object')\n\t\treturn (f) => {\n\t\t\tconst v = value(f);\n\t\t\tconst put = (val: Value) =>\n\t\t\t\tmember(objectOf(ref(f).get()), '', 'let', [], undefined, f.run, val);\n\t\t\treturn v instanceof Promise ? v.then(put) : put(v);\n\t\t};\n\treturn (f) => {\n\t\tconst v = value(f);\n\t\tif (v instanceof Promise)\n\t\t\treturn v.then((val) => {\n\t\t\t\tref(f).set(val);\n\t\t\t\treturn EMPTY;\n\t\t\t});\n\t\tref(f).set(v);\n\t\treturn EMPTY;\n\t};\n}\n\n/** Compiles `target = value` (kind `let`) or `Set target = value` (kind `set`). */\nexport function assignment(\n\tx: Compiler,\n\ttarget: Expression,\n\tkind: 'let' | 'set',\n\tsource: Expression,\n): Eval {\n\treturn assignTo(x, target, kind, rhs(x, source, kind));\n}\n\n/** Compiles a store of an already prepared value (a For counter, a For Each element). */\nexport function assignTo(x: Compiler, target: Expression, kind: 'let' | 'set', value: Eval): Eval {\n\tconst b = x.ctx.binding(target);\n\tswitch (target.kind) {\n\t\tcase 'Name':\n\t\t\tswitch (b?.kind) {\n\t\t\t\tcase 'variable':\n\t\t\t\tcase 'param':\n\t\t\t\tcase 'implicit':\n\t\t\t\tcase 'result':\n\t\t\t\t\treturn variableStore(x, b.symbol, kind, value);\n\t\t\t\tcase 'procedure':\n\t\t\t\t\treturn invocationValue(x, target, target, [], kind, value);\n\t\t\t\tcase 'dynamic': {\n\t\t\t\t\tconst n = x.dynamics.of(b.name, b.document, b.fallback);\n\t\t\t\t\treturn (f) => {\n\t\t\t\t\t\tconst v = value(f);\n\t\t\t\t\t\tif (v instanceof Promise)\n\t\t\t\t\t\t\treturn v.then((val) => x.dynamics.access(n, f, kind, [], undefined, val));\n\t\t\t\t\t\treturn x.dynamics.access(n, f, kind, [], undefined, v);\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\tcase 'unresolved':\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tthrow new VbaRuntimeError(b.number);\n\t\t\t\t\t};\n\t\t\t\tdefault:\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\tthrow new VbaRuntimeError(5, 'Invalid assignment target');\n\t\t\t\t\t};\n\t\t\t}\n\t\tcase 'CallOrIndex': {\n\t\t\tconst inv = x.ctx.invocation(target);\n\t\t\tif (inv?.kind === 'library' || inv?.kind === 'declare')\n\t\t\t\treturn () => {\n\t\t\t\t\tthrow new VbaRuntimeError(5, 'Function call on left-hand side of assignment');\n\t\t\t\t};\n\t\t\treturn invocationValue(x, target, target.target, target.args, kind, value);\n\t\t}\n\t\tcase 'MemberAccess':\n\t\tcase 'DictionaryAccess':\n\t\t\treturn memberStore(x, target, kind, value);\n\t\tdefault:\n\t\t\treturn storeRef(x.ref(target), value);\n\t}\n}\n\nfunction memberStore(\n\tx: Compiler,\n\ttarget: MemberAccess | DictionaryAccess,\n\tkind: 'let' | 'set',\n\tvalue: Eval,\n): Eval {\n\tconst b = x.ctx.binding(target);\n\tswitch (b?.kind) {\n\t\tcase 'variable':\n\t\t\treturn variableStore(x, b.symbol, kind, value);\n\t\tcase 'udtField':\n\t\t\treturn storeRef(x.ref(target), value);\n\t\tcase 'procedure':\n\t\t\treturn invocationValue(x, target, target, [], kind, value);\n\t\tcase 'member':\n\t\tcase 'errMember':\n\t\tcase 'debugMember': {\n\t\t\tconst object = x.qualifier(target);\n\t\t\tconst dictionary =\n\t\t\t\ttarget.kind === 'DictionaryAccess' || (b.kind === 'member' && b.dictionary);\n\t\t\tconst name = dictionary ? '' : b.name;\n\t\t\tconst key = target.kind === 'DictionaryAccess' ? target.key.name : b.name;\n\t\t\treturn (f: Frame) => {\n\t\t\t\tconst o = object(f);\n\t\t\t\tconst put = (ov: Value): MaybeValue => {\n\t\t\t\t\tconst v = value(f);\n\t\t\t\t\tconst refs: Ref[] = dictionary ? [new TempCell(vStr(key))] : [];\n\t\t\t\t\tconst go = (val: Value) => member(objectOf(ov), name, kind, refs, undefined, f.run, val);\n\t\t\t\t\treturn v instanceof Promise ? v.then(go) : go(v);\n\t\t\t\t};\n\t\t\t\treturn o instanceof Promise ? o.then(put) : put(o);\n\t\t\t};\n\t\t}\n\t\tdefault:\n\t\t\treturn () => {\n\t\t\t\tthrow new VbaRuntimeError(b?.kind === 'unresolved' ? b.number : 5);\n\t\t\t};\n\t}\n}\n","// `For Each element In group` ([MS-VBAL] 5.4.2.4) over the runtime's shared cursor: an array's\n// elements in storage order (locked against ReDim until the loop ends), or what an object\n// enumerates (a Collection, a host collection, a class with a NewEnum member).\nimport type { ForEachStatement } from '../../lang/index';\nimport { ForEachCursor, type Value } from '../../runtime/index';\nimport type { MaybePromise } from '../async';\nimport { closeCursor, type Frame } from '../frame';\nimport type { Target } from './builder';\nimport type { StatementCompilerLike } from './statement-types';\nimport { assignTo } from './stores';\n\nexport function forEachInit(c: StatementCompilerLike, s: ForEachStatement, id: number): void {\n\tconst group = c.x.value(s.collection);\n\tc.at(s);\n\tc.b.emit((f) => {\n\t\tcloseCursor(f, id);\n\t\tconst v = group(f);\n\t\tconst begin = (g: Value) => {\n\t\t\ttry {\n\t\t\t\tf.loops[id] = new ForEachCursor(g);\n\t\t\t} catch (e) {\n\t\t\t\t// Under Resume Next the body runs once without an element (as in Office).\n\t\t\t\tf.loops[id] = ForEachCursor.broken();\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t};\n\t\treturn v instanceof Promise ? v.then(begin) : begin(v);\n\t});\n}\n\nexport function forEachNext(\n\tc: StatementCompilerLike,\n\ts: ForEachStatement,\n\tid: number,\n\texit: Target,\n): void {\n\tconst current = (f: Frame) => (f.loops[id] as ForEachCursor).current;\n\tconst asObject = assignTo(c.x, s.element, 'set', current);\n\tconst asValue = assignTo(c.x, s.element, 'let', current);\n\tconst store = (f: Frame, cursor: ForEachCursor): MaybePromise<number | undefined> => {\n\t\tif (cursor.broken) return undefined;\n\t\tconst r = (cursor.current.vt === 9 ? asObject : asValue)(f);\n\t\treturn r instanceof Promise ? r.then(() => undefined) : undefined;\n\t};\n\tc.b.emit((f) => {\n\t\tconst cursor = f.loops[id] as ForEachCursor | undefined;\n\t\tif (!cursor) return exit.pc;\n\t\tconst r = cursor.next();\n\t\tconst step = (more: boolean) => (more ? store(f, cursor) : exit.pc);\n\t\treturn r instanceof Promise ? r.then(step) : step(r);\n\t});\n}\n","// `For counter = start To end [Step step]` ([MS-VBAL] 5.4.2.3). Start, end and step are evaluated\n// once; the counter is stored through its declared type each round. Integer and Long counters with\n// integral steps take a fast path that falls back to the runtime's operators on overflow.\nimport type { ForStatement } from '../../lang/index';\nimport { add, cmp, toDbl, vInt, vLng, type Value, type VbaSession } from '../../runtime/index';\nimport { isVariant } from '../../semantic/index';\nimport type { MaybePromise } from '../async';\nimport type { Frame } from '../frame';\nimport { collect } from './args';\nimport type { Target } from './builder';\nimport type { StatementCompilerLike } from './statement-types';\nimport { assignTo } from './stores';\nimport type { Eval } from './types';\nimport { variableRef } from './variables';\n\nclass ForState {\n\t/** The value being stored into the counter. */\n\tvalue: Value;\n\treadonly up: boolean;\n\treadonly endNum: number | null;\n\treadonly stepNum: number | null;\n\n\tconstructor(\n\t\tstart: Value,\n\t\treadonly end: Value,\n\t\treadonly step: Value,\n\t\ts: VbaSession,\n\t) {\n\t\tthis.value = start;\n\t\tthis.up = toDbl(step, s) >= 0;\n\t\tthis.endNum = end.vt === 2 || end.vt === 3 || end.vt === 5 ? end.v : null;\n\t\tthis.stepNum = step.vt === 2 || step.vt === 3 ? step.v : null;\n\t}\n\n\t/** True once the counter has passed the end. */\n\tdone(v: Value, s: VbaSession): boolean {\n\t\tconst c = cmp(v, this.end, 0, true, s);\n\t\tif (c === null) return true;\n\t\treturn this.up ? c > 0 : c < 0;\n\t}\n}\n\nconst ONE: Eval = () => vInt(1);\n\nfunction readBack(\n\tcounter: Eval,\n\tf: Frame,\n\tthen: (v: Value) => number | undefined,\n): MaybePromise<number | undefined> {\n\tconst v = counter(f);\n\treturn v instanceof Promise ? v.then(then) : then(v);\n}\n\nexport function forInit(c: StatementCompilerLike, s: ForStatement, id: number, exit: Target): void {\n\tconst parts = [c.x.scalar(s.start), c.x.scalar(s.end), s.step ? c.x.scalar(s.step) : ONE];\n\tconst counter = c.x.value(s.counter);\n\tconst store = assignTo(c.x, s.counter, 'let', (f) => (f.loops[id] as ForState).value);\n\tc.at(s);\n\tc.b.emit((f) => {\n\t\tconst list = collect(parts, f);\n\t\tconst begin = (vals: Value[]): MaybePromise<number | undefined> => {\n\t\t\tconst st = new ForState(vals[0] as Value, vals[1] as Value, vals[2] as Value, f.session);\n\t\t\tf.loops[id] = st;\n\t\t\tconst check = (v: Value) => (st.done(v, f.session) ? exit.pc : undefined);\n\t\t\tconst r = store(f);\n\t\t\treturn r instanceof Promise\n\t\t\t\t? r.then(() => readBack(counter, f, check))\n\t\t\t\t: readBack(counter, f, check);\n\t\t};\n\t\treturn list instanceof Promise ? list.then(begin) : begin(list);\n\t});\n}\n\nexport function forNext(c: StatementCompilerLike, s: ForStatement, id: number, body: Target): void {\n\tconst counter = c.x.value(s.counter);\n\tconst strict = !isVariant(c.x.ctx.typeOf(s.counter));\n\tconst store = assignTo(c.x, s.counter, 'let', (f) => (f.loops[id] as ForState).value);\n\tconst b = c.x.ctx.binding(s.counter);\n\tconst local =\n\t\ts.counter.kind === 'Name' &&\n\t\t(b?.kind === 'variable' || b?.kind === 'implicit' || b?.kind === 'param')\n\t\t\t? variableRef(c.x.ctx, b.symbol)\n\t\t\t: null;\n\tconst slow = (f: Frame, st: ForState, cur: Value): MaybePromise<number | undefined> => {\n\t\tst.value = add(cur, st.step, strict, f.session);\n\t\tconst check = (v: Value) => (st.done(v, f.session) ? undefined : body.pc);\n\t\tconst r = store(f);\n\t\treturn r instanceof Promise\n\t\t\t? r.then(() => readBack(counter, f, check))\n\t\t\t: readBack(counter, f, check);\n\t};\n\tc.b.emit((f) => {\n\t\tconst st = f.loops[id] as ForState;\n\t\tif (local && st.stepNum !== null && st.endNum !== null) {\n\t\t\tconst cell = local(f);\n\t\t\tconst cur = cell.get();\n\t\t\tif (cur.vt === 3 || cur.vt === 2) {\n\t\t\t\tconst next = cur.v + st.stepNum;\n\t\t\t\tconst long = cur.vt === 3 || st.step.vt === 3;\n\t\t\t\tif (long ? next >= -2147483648 && next <= 2147483647 : next >= -32768 && next <= 32767) {\n\t\t\t\t\tcell.set(long ? vLng(next) : vInt(next));\n\t\t\t\t\tconst now = cell.get();\n\t\t\t\t\tif (now.vt === 2 || now.vt === 3) {\n\t\t\t\t\t\tconst over = st.up ? now.v > st.endNum : now.v < st.endNum;\n\t\t\t\t\t\treturn over ? undefined : body.pc;\n\t\t\t\t\t}\n\t\t\t\t\treturn st.done(now, f.session) ? undefined : body.pc;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn slow(f, st, cur);\n\t\t}\n\t\tconst cur = counter(f);\n\t\treturn cur instanceof Promise ? cur.then((v) => slow(f, st, v)) : slow(f, st, cur);\n\t});\n}\n","// Conditions ([MS-VBAL] 5.4.2.5 If, 5.4.2.x loops): the simple value Let-coerced to Boolean, with\n// Null counting as False.\nimport { toBool, type Value, type VbaSession } from '../../runtime/index';\nimport type { MaybePromise } from '../async';\nimport type { Frame } from '../frame';\nimport type { Eval } from './types';\n\nexport const isTrue = (v: Value, s: VbaSession): boolean =>\n\tv.vt === 11 ? v.v : v.vt === 1 ? false : toBool(v, s);\n\n/** A condition: `scalar` must already give the simple value. */\nexport function condition(scalar: Eval): (f: Frame) => MaybePromise<boolean> {\n\treturn (f) => {\n\t\tconst v = scalar(f);\n\t\treturn v instanceof Promise ? v.then((y) => isTrue(y, f.session)) : isTrue(v, f.session);\n\t};\n}\n","// Structured statements ([MS-VBAL] 5.4.2): If, Select Case, For, For Each, Do, While and With,\n// laid out as conditional jumps around their bodies.\nimport type {\n\tCaseTest,\n\tForEachStatement,\n\tForStatement,\n\tIfStatement,\n\tSelectCaseStatement,\n\tExpression,\n} from '../../lang/index';\nimport {\n\tEMPTY,\n\teq,\n\tge,\n\tgt,\n\tle,\n\tlt,\n\tne,\n\ttype CompareMode,\n\ttype Ref,\n\ttype Value,\n} from '../../runtime/index';\nimport type { MaybePromise } from '../async';\nimport { closeCursor, type Frame } from '../frame';\nimport { release, retain } from '../objects/lifetime';\nimport { CodeBuilder, Target } from './builder';\nimport { forEachInit, forEachNext } from './for-each';\nimport { forInit, forNext } from './for-loop';\nimport type { StatementHandlers, StatementCompilerLike } from './statement-types';\nimport type { Instr } from './types';\nimport { condition, isTrue } from './truth';\n\n/** Emits `if not cond goto target`. */\nfunction jumpUnless(\n\tb: CodeBuilder,\n\tcond: (f: Frame) => MaybePromise<boolean>,\n\ttarget: Target,\n): void {\n\tb.emit((f) => {\n\t\tconst r = cond(f);\n\t\treturn r instanceof Promise\n\t\t\t? r.then((ok) => (ok ? undefined : target.pc))\n\t\t\t: r\n\t\t\t\t? undefined\n\t\t\t\t: target.pc;\n\t});\n}\n\nfunction jumpIf(b: CodeBuilder, cond: (f: Frame) => MaybePromise<boolean>, target: Target): void {\n\tb.emit((f) => {\n\t\tconst r = cond(f);\n\t\treturn r instanceof Promise\n\t\t\t? r.then((ok) => (ok ? target.pc : undefined))\n\t\t\t: r\n\t\t\t\t? target.pc\n\t\t\t\t: undefined;\n\t});\n}\n\ntype Compare = typeof eq;\nconst COMPARE: Record<string, Compare> = {\n\t'=': eq,\n\t'<>': ne,\n\t'<': lt,\n\t'>': gt,\n\t'<=': le,\n\t'>=': ge,\n};\n\nexport const CONTROL: Pick<\n\tStatementHandlers,\n\t'If' | 'SelectCase' | 'For' | 'ForEach' | 'DoLoop' | 'While' | 'With'\n> = {\n\tIf: (c, s: IfStatement) => {\n\t\tconst end = new Target();\n\t\tfor (const branch of s.branches) {\n\t\t\tconst next = new Target();\n\t\t\tc.at(branch);\n\t\t\tjumpUnless(c.b, condition(c.x.scalar(branch.condition)), next);\n\t\t\tc.block(branch.body);\n\t\t\tc.b.jump(end);\n\t\t\tc.b.mark(next);\n\t\t}\n\t\tif (s.elseBody) c.block(s.elseBody);\n\t\tc.b.mark(end);\n\t},\n\tSelectCase: (c, s: SelectCaseStatement) => {\n\t\tconst id = c.b.block();\n\t\tconst subject = c.x.scalar(s.subject);\n\t\tconst subjectTyped = c.x.ctx.program.isTypedOperand(s.subject);\n\t\tconst evaluate = c.b.effect((f) => {\n\t\t\tconst v = subject(f);\n\t\t\tif (v instanceof Promise)\n\t\t\t\treturn v.then((y) => {\n\t\t\t\t\tf.loops[id] = y;\n\t\t\t\t\treturn y;\n\t\t\t\t});\n\t\t\tf.loops[id] = v;\n\t\t\treturn v;\n\t\t});\n\t\tconst end = new Target();\n\t\tfor (const clause of s.cases) {\n\t\t\tconst next = new Target();\n\t\t\tc.at(clause);\n\t\t\tconst tests = clause.tests.map((t) => caseTest(c, t, id, subjectTyped));\n\t\t\tjumpUnless(c.b, anyOf(tests), next);\n\t\t\tc.block(clause.body);\n\t\t\tc.b.jump(end);\n\t\t\tc.b.mark(next);\n\t\t}\n\t\tif (s.elseBody) c.block(s.elseBody);\n\t\tc.b.mark(end);\n\t\t// Resume Next after an error in the subject skips the whole Select Case, as Excel does.\n\t\t(c.b.code[evaluate] as Instr).skip = end;\n\t},\n\tFor: (c, s: ForStatement) => {\n\t\tconst exit = new Target();\n\t\tconst body = new Target();\n\t\tconst id = c.b.block();\n\t\tforInit(c, s, id, exit);\n\t\tc.b.mark(body);\n\t\tc.b.loops.push({ kind: 'For', exit });\n\t\tc.block(s.body);\n\t\tc.b.loops.pop();\n\t\tc.at(s);\n\t\tforNext(c, s, id, body);\n\t\tc.b.mark(exit);\n\t},\n\tForEach: (c, s: ForEachStatement) => {\n\t\tconst exit = new Target();\n\t\tconst fetch = new Target();\n\t\tconst id = c.b.block();\n\t\tforEachInit(c, s, id);\n\t\tc.b.mark(fetch);\n\t\tforEachNext(c, s, id, exit);\n\t\tc.b.loops.push({ kind: 'For', exit, cursor: id });\n\t\tc.block(s.body);\n\t\tc.b.loops.pop();\n\t\tc.b.jump(fetch);\n\t\tc.b.mark(exit);\n\t\tc.b.emit((f) => {\n\t\t\tcloseCursor(f, id);\n\t\t\treturn undefined;\n\t\t});\n\t},\n\tDoLoop: (c, s) => {\n\t\tconst top = new Target();\n\t\tconst exit = new Target();\n\t\tconst cond = s.condition;\n\t\tconst test = cond ? condition(c.x.scalar(cond.expression)) : null;\n\t\tc.b.mark(top);\n\t\tif (cond && test && cond.position === 'pre') {\n\t\t\tc.at(cond);\n\t\t\tif (cond.mode === 'While') jumpUnless(c.b, test, exit);\n\t\t\telse jumpIf(c.b, test, exit);\n\t\t}\n\t\tc.b.loops.push({ kind: 'Do', exit });\n\t\tc.block(s.body);\n\t\tc.b.loops.pop();\n\t\tif (cond && test && cond.position === 'post') {\n\t\t\tc.at(cond);\n\t\t\tif (cond.mode === 'While') jumpIf(c.b, test, top);\n\t\t\telse jumpUnless(c.b, test, top);\n\t\t} else c.b.jump(top);\n\t\tc.b.mark(exit);\n\t},\n\tWhile: (c, s) => {\n\t\tconst top = new Target();\n\t\tconst exit = new Target();\n\t\tc.b.mark(top);\n\t\tjumpUnless(c.b, condition(c.x.scalar(s.condition)), exit);\n\t\tc.block(s.body);\n\t\tc.b.jump(top);\n\t\tc.b.mark(exit);\n\t},\n\tWith: (c, s) => {\n\t\tconst block = c.x.ctx.procedure?.withBlocks.find((w) => w.statement === s);\n\t\tconst id = block?.id ?? -1;\n\t\tif (block?.subjectType.kind === 'udt') {\n\t\t\t// A With over a UDT binds its storage: assigning the whole variable inside the block\n\t\t\t// does not detach `.field` from it.\n\t\t\tconst storage = c.x.ref(s.object);\n\t\t\tc.b.effect((f) => {\n\t\t\t\tconst r = storage(f);\n\t\t\t\tconst keep = (ref: Ref): Value => {\n\t\t\t\t\tf.withRefs[id] = ref;\n\t\t\t\t\treturn EMPTY;\n\t\t\t\t};\n\t\t\t\treturn r instanceof Promise ? r.then(keep) : keep(r);\n\t\t\t});\n\t\t\tc.block(s.body);\n\t\t\treturn;\n\t\t}\n\t\tconst subject = c.x.value(s.object);\n\t\tc.b.effect((f) => {\n\t\t\tconst v = subject(f);\n\t\t\t// Entering the block again (GoTo) replaces the subject; leaving it by Exit For, Exit Do\n\t\t\t// or GoTo keeps it until then or until the procedure ends, as in Office.\n\t\t\tconst keep = (y: Value): Value => {\n\t\t\t\tretain(y);\n\t\t\t\tconst old = f.with[id];\n\t\t\t\tf.with[id] = y;\n\t\t\t\tif (old) release(old);\n\t\t\t\treturn y;\n\t\t\t};\n\t\t\treturn v instanceof Promise ? v.then(keep) : keep(v);\n\t\t});\n\t\tc.block(s.body);\n\t\tc.b.emit((f) => {\n\t\t\tconst v = f.with[id];\n\t\t\tf.with[id] = EMPTY;\n\t\t\tif (v) release(v);\n\t\t\treturn undefined;\n\t\t});\n\t},\n};\n\nfunction anyOf(\n\ttests: ((f: Frame) => MaybePromise<boolean>)[],\n): (f: Frame) => MaybePromise<boolean> {\n\treturn (f) => {\n\t\tfor (let i = 0; i < tests.length; i++) {\n\t\t\tconst r = (tests[i] as (f: Frame) => MaybePromise<boolean>)(f);\n\t\t\tif (r instanceof Promise) return r.then((ok) => (ok ? true : anyOf(tests.slice(i + 1))(f)));\n\t\t\tif (r) return true;\n\t\t}\n\t\treturn false;\n\t};\n}\n\nfunction caseTest(\n\tc: StatementCompilerLike,\n\tt: CaseTest,\n\tid: number,\n\tsubjectTyped: boolean,\n): (f: Frame) => MaybePromise<boolean> {\n\tconst compare: CompareMode = c.x.ctx.compareText ? 1 : 0;\n\tconst test = (e: Expression, op: Compare) => {\n\t\tconst v = c.x.scalar(e);\n\t\tconst typed = subjectTyped || c.x.ctx.program.isTypedOperand(e);\n\t\treturn (f: Frame): MaybePromise<boolean> => {\n\t\t\tconst r = v(f);\n\t\t\tconst check = (y: Value) =>\n\t\t\t\tisTrue(op(f.loops[id] as Value, y, compare, typed, f.session), f.session);\n\t\t\treturn r instanceof Promise ? r.then(check) : check(r);\n\t\t};\n\t};\n\tswitch (t.kind) {\n\t\tcase 'CaseValue':\n\t\t\treturn test(t.value, eq);\n\t\tcase 'CaseIs':\n\t\t\treturn test(t.value, COMPARE[t.operator] as Compare);\n\t\tcase 'CaseRange': {\n\t\t\tconst from = test(t.from, ge);\n\t\t\tconst to = test(t.to, le);\n\t\t\treturn (f) => {\n\t\t\t\tconst a = from(f);\n\t\t\t\tif (a instanceof Promise) return a.then((ok) => (ok ? to(f) : false));\n\t\t\t\treturn a ? to(f) : false;\n\t\t\t};\n\t\t}\n\t}\n}\n","// Jumps and error handling ([MS-VBAL] 5.4.2.x, 5.4.4): labels and line numbers, GoTo, GoSub and\n// Return, On...GoTo, Exit, End, Stop, On Error and Resume.\nimport { VbaAbort, VbaRuntimeError, scalar, toLng, type Value } from '../../runtime/index';\nimport { nextOf } from '../error-handler';\nimport { VbaStop } from '../../exec/index';\nimport { closeCursor, type Frame } from '../frame';\nimport type { StatementHandlers } from './statement-types';\n\n/**\n * Pushes a GoSub return point. Recursive GoSub runs out of stack space (error 28) at the call\n * depth limit; the procedure's own On Error cannot trap it (its callers can), as in Office.\n */\nfunction pushReturn(f: Frame, back: number): void {\n\tif (f.gosub.length >= f.run.guard.limits.maxCallDepth) {\n\t\tconst e = new VbaRuntimeError(28);\n\t\tf.run.untrappable.set(e, f);\n\t\tthrow e;\n\t}\n\tf.gosub.push(back);\n}\n\nexport const FLOW: Pick<\n\tStatementHandlers,\n\t'Label' | 'GoTo' | 'GoSub' | 'Return' | 'OnGoTo' | 'Exit' | 'End' | 'Stop' | 'OnError' | 'Resume'\n> = {\n\tLabel: (c, s) => {\n\t\tc.b.mark(c.b.label(s.label.name));\n\t\tif (s.label.isLineNumber) {\n\t\t\tconst n = Number(s.label.name);\n\t\t\tc.b.emit((f) => {\n\t\t\t\tf.line = n;\n\t\t\t\treturn undefined;\n\t\t\t});\n\t\t}\n\t},\n\tGoTo: (c, s) => {\n\t\tconst t = c.b.label(s.label.name);\n\t\tif (s.kind === 'GoSub') {\n\t\t\tconst back = c.b.pc + 1;\n\t\t\tc.b.emit((f) => {\n\t\t\t\tpushReturn(f, back);\n\t\t\t\treturn t.pc;\n\t\t\t});\n\t\t} else c.b.jump(t);\n\t},\n\tGoSub: (c, s) => FLOW.GoTo(c, s),\n\tReturn: (c) => {\n\t\tc.b.emit((f) => {\n\t\t\tconst back = f.gosub.pop();\n\t\t\tif (back === undefined) throw new VbaRuntimeError(3);\n\t\t\treturn back;\n\t\t});\n\t},\n\tOnGoTo: (c, s) => {\n\t\tconst selector = c.x.scalar(s.selector);\n\t\tconst targets = s.labels.map((l) => c.b.label(l.name));\n\t\tconst gosub = s.gosub;\n\t\tconst back = c.b.pc + 1;\n\t\tc.b.emit((f) => {\n\t\t\tconst pick = (v: Value) => {\n\t\t\t\tconst n = toLng(scalar(v), f.session);\n\t\t\t\tif (n < 0 || n > 255) throw new VbaRuntimeError(5);\n\t\t\t\tconst t = targets[n - 1];\n\t\t\t\tif (n === 0 || !t) return undefined;\n\t\t\t\tif (gosub) pushReturn(f, back);\n\t\t\t\treturn t.pc;\n\t\t\t};\n\t\t\tconst v = selector(f);\n\t\t\treturn v instanceof Promise ? v.then(pick) : pick(v);\n\t\t});\n\t},\n\tExit: (c, s) => {\n\t\tif (s.target === 'For' || s.target === 'Do') {\n\t\t\tconst found = c.b.loop(s.target);\n\t\t\tif (!found) return; // The binder reports Exit outside its loop as a compile error.\n\t\t\tconst { loop, cursors } = found;\n\t\t\tif (cursors.length > 0)\n\t\t\t\tc.b.emit((f) => {\n\t\t\t\t\tfor (const id of cursors) closeCursor(f, id);\n\t\t\t\t\treturn loop.exit.pc;\n\t\t\t\t});\n\t\t\telse c.b.jump(loop.exit);\n\t\t\treturn;\n\t\t}\n\t\tconst end = c.b.end;\n\t\tc.b.emit((f) => {\n\t\t\tif (f.handler.handling) f.session.err.clear();\n\t\t\treturn end.pc;\n\t\t});\n\t},\n\tEnd: (c) => {\n\t\tc.b.emit(() => {\n\t\t\tthrow new VbaAbort('end', 'End statement');\n\t\t});\n\t},\n\tStop: (c) => {\n\t\tc.b.emit(() => {\n\t\t\tthrow new VbaStop();\n\t\t});\n\t},\n\tOnError: (c, s) => {\n\t\tswitch (s.action) {\n\t\t\tcase 'goto': {\n\t\t\t\tconst label = s.label;\n\t\t\t\tif (!label || (label.isLineNumber && label.name === '0')) {\n\t\t\t\t\tc.b.emit((f) => {\n\t\t\t\t\t\tf.handler.set('goto0', -1, f.session.err);\n\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst t = c.b.label(label.name);\n\t\t\t\tc.b.emit((f) => {\n\t\t\t\t\tf.handler.set('label', t.pc, f.session.err);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase 'resumeNext':\n\t\t\t\tc.b.emit((f) => {\n\t\t\t\t\tf.handler.set('next', -1, f.session.err);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\tcase 'disable':\n\t\t\t\tc.b.emit((f) => {\n\t\t\t\t\tf.handler.set('goto0', -1, f.session.err);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\tcase 'clear':\n\t\t\t\tc.b.emit((f) => {\n\t\t\t\t\tf.handler.reset(f.session.err);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t}\n\t},\n\tResume: (c, s) => {\n\t\tconst t = s.action === 'label' && s.label ? c.b.label(s.label.name) : null;\n\t\tconst kind = s.action;\n\t\tc.b.emit((f) => {\n\t\t\tconst pc = f.handler.resume(kind, t ? t.pc : -1, f.session.err, (at) =>\n\t\t\t\tnextOf(f.code.code, at),\n\t\t\t);\n\t\t\tf.erl = 0;\n\t\t\treturn pc;\n\t\t});\n\t},\n};\n","// The remaining statements: assignments and calls, ReDim and Erase, RaiseEvent, Mid/LSet/RSet,\n// Error, Debug.Print, declarations (which do their work when the frame starts), and the file\n// statements, which this environment refuses honestly.\nimport type { ReDimClause, Expression } from '../../lang/index';\nimport {\n\tMISSING,\n\tlsetRecord,\n\tVbaArray,\n\tVbaRuntimeError,\n\tdebugPrint,\n\tfixLen,\n\tmidAssign,\n\tnotSupported,\n\tscalar,\n\ttoLng,\n\ttoStr,\n\tvArr,\n\tvStr,\n\ttype PrintPart,\n\ttype Ref,\n\ttype Value,\n} from '../../runtime/index';\nimport type { StaticType } from '../../semantic/index';\nimport type { MaybePromise } from '../async';\nimport type { Frame } from '../frame';\nimport { ArrayCell, TempCell, VariantCell } from '../storage';\nimport { collect, type Part } from './args';\nimport { elementVt } from './cells';\nimport type { StatementCompilerLike, StatementHandlers } from './statement-types';\nimport { assignment } from './stores';\n\nconst unsupported = (what: string) => (c: StatementCompilerLike) => {\n\tc.b.emit(() => notSupported(what));\n};\n\nfunction redimClause(c: StatementCompilerLike, clause: ReDimClause, preserve: boolean): void {\n\tconst ref = c.x.ref(clause.target);\n\tconst base = c.x.ctx.module.options.base;\n\tconst bounds: Part<Value>[] = [];\n\tfor (const b of clause.bounds) {\n\t\tbounds.push(b.lower ? c.x.scalar(b.lower) : () => ({ vt: 3, v: base }) as Value);\n\t\tbounds.push(c.x.scalar(b.upper));\n\t}\n\tconst t = c.x.ctx.typeOf(clause.target);\n\tconst element: StaticType = t.kind === 'array' ? t.element : { kind: 'variant' };\n\tconst vt = elementVt(element);\n\tconst init = c.x.ctx.cells.elementInit(element);\n\tc.b.emit((f) => {\n\t\tconst list = collect(bounds, f);\n\t\tconst apply = (vals: Value[]): MaybePromise<number | undefined> => {\n\t\t\tconst dims: { lo: number; hi: number }[] = [];\n\t\t\tfor (let i = 0; i < vals.length; i += 2)\n\t\t\t\tdims.push({\n\t\t\t\t\tlo: toLng(scalar(vals[i] as Value), f.session),\n\t\t\t\t\thi: toLng(scalar(vals[i + 1] as Value), f.session),\n\t\t\t\t});\n\t\t\tconst r = ref(f);\n\t\t\tconst put = (cell: Ref) => {\n\t\t\t\tconst cur = cell.get();\n\t\t\t\tif (cur.vt === 8192 && (preserve || cell instanceof ArrayCell))\n\t\t\t\t\tcur.v.redim(dims, preserve, !(cell instanceof ArrayCell));\n\t\t\t\telse {\n\t\t\t\t\tconst a = new VbaArray(cur.vt === 8192 ? cur.v.elemVt : vt, dims, {\n\t\t\t\t\t\tenv: f.session,\n\t\t\t\t\t\t...(init ? { init } : {}),\n\t\t\t\t\t});\n\t\t\t\t\tif (cell instanceof VariantCell) cell.value = vArr(a);\n\t\t\t\t\telse cell.set(vArr(a));\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t};\n\t\t\treturn r instanceof Promise ? r.then(put) : put(r);\n\t\t};\n\t\treturn list instanceof Promise ? list.then(apply) : apply(list);\n\t});\n}\n\nexport const SIMPLE: Omit<\n\tStatementHandlers,\n\t| 'If'\n\t| 'SelectCase'\n\t| 'For'\n\t| 'ForEach'\n\t| 'DoLoop'\n\t| 'While'\n\t| 'With'\n\t| 'Label'\n\t| 'GoTo'\n\t| 'GoSub'\n\t| 'Return'\n\t| 'OnGoTo'\n\t| 'Exit'\n\t| 'End'\n\t| 'Stop'\n\t| 'OnError'\n\t| 'Resume'\n> = {\n\tAssignment: (c, s) => {\n\t\tc.b.effect(assignment(c.x, s.target, s.assignment === 'Set' ? 'set' : 'let', s.value));\n\t},\n\tCall: (c, s) => {\n\t\tc.b.effect(c.x.invoke(s, s.callee, s.args, 'call'));\n\t},\n\tReDim: (c, s) => {\n\t\tfor (const clause of s.clauses) redimClause(c, clause, s.preserve);\n\t},\n\tErase: (c, s) => {\n\t\tfor (const target of s.targets) {\n\t\t\tconst ref = c.x.ref(target);\n\t\t\tc.b.emit((f) => {\n\t\t\t\tconst erase = (cell: Ref) => {\n\t\t\t\t\tconst v = cell.get();\n\t\t\t\t\tif (v.vt !== 8192) throw new VbaRuntimeError(13);\n\t\t\t\t\tv.v.erase();\n\t\t\t\t\treturn undefined;\n\t\t\t\t};\n\t\t\t\tconst r = ref(f);\n\t\t\t\treturn r instanceof Promise ? r.then(erase) : erase(r);\n\t\t\t});\n\t\t}\n\t},\n\tRaiseEvent: (c, s) => {\n\t\tconst name = s.name.name;\n\t\tconst parts: Part<Ref>[] = s.args.map((a) => {\n\t\t\tif (!a.value) return () => new TempCell(MISSING);\n\t\t\treturn c.x.ref(a.value);\n\t\t});\n\t\tc.b.emit((f) => {\n\t\t\tconst instance = f.instance;\n\t\t\tif (!instance) throw new VbaRuntimeError(91);\n\t\t\tconst list = collect(parts, f);\n\t\t\tconst raise = (refs: Ref[]) => {\n\t\t\t\tconst r = instance.raise(name, refs);\n\t\t\t\treturn r instanceof Promise ? r.then(() => undefined) : undefined;\n\t\t\t};\n\t\t\treturn list instanceof Promise ? list.then(raise) : raise(list);\n\t\t});\n\t},\n\tMidAssignment: (c, s) => {\n\t\tif (s.function === 'MidB') return unsupported('MidB statement')(c);\n\t\tconst ref = c.x.ref(s.target);\n\t\tconst parts: Part<Value>[] = [\n\t\t\tc.x.scalar(s.start),\n\t\t\ts.length ? c.x.scalar(s.length) : () => MISSING,\n\t\t\tc.x.scalar(s.value),\n\t\t];\n\t\tc.b.emit((f) => {\n\t\t\tconst list = collect(parts, f);\n\t\t\tconst apply = (vals: Value[]) => {\n\t\t\t\tconst r = ref(f);\n\t\t\t\tconst put = (cell: Ref) => {\n\t\t\t\t\tconst [start, length, value] = vals as [Value, Value, Value];\n\t\t\t\t\tcell.set(midAssign(cell.get(), start, length, value, f.session));\n\t\t\t\t\treturn undefined;\n\t\t\t\t};\n\t\t\t\treturn r instanceof Promise ? r.then(put) : put(r);\n\t\t\t};\n\t\t\treturn list instanceof Promise ? list.then(apply) : apply(list);\n\t\t});\n\t},\n\tLSet: (c, s) => padStatement(c, s.target, s.value, 'left'),\n\tRSet: (c, s) => padStatement(c, s.target, s.value, 'right'),\n\tName: unsupported('Name (renaming files)'),\n\tError: (c, s) => {\n\t\tconst n = c.x.scalar(s.number);\n\t\tc.b.emit((f) => {\n\t\t\tconst raise = (v: Value): never => {\n\t\t\t\tthrow new VbaRuntimeError(toLng(v, f.session));\n\t\t\t};\n\t\t\tconst v = n(f);\n\t\t\treturn v instanceof Promise ? v.then(raise) : raise(v);\n\t\t});\n\t},\n\tPrint: (c, s) => {\n\t\tif (s.channel === 'file') return unsupported('File I/O (Print #)')(c);\n\t\tconst parts: Part<PrintPart[]>[] = s.items.map((item) => {\n\t\t\tconst value = item.value ? c.x.scalar(item.value) : null;\n\t\t\tconst sep: PrintPart[] = item.separator ? [{ sep: item.separator }] : [];\n\t\t\treturn (f: Frame) => {\n\t\t\t\tconst make = (v: Value | null): PrintPart[] => {\n\t\t\t\t\tif (item.form === 'spc') return [{ spc: v ? toLng(v, f.session) : 0 }, ...sep];\n\t\t\t\t\tif (item.form === 'tab') return [{ tab: v ? toLng(v, f.session) : undefined }, ...sep];\n\t\t\t\t\treturn v ? [{ value: v }, ...sep] : sep;\n\t\t\t\t};\n\t\t\t\tif (!value) return make(null);\n\t\t\t\tconst v = value(f);\n\t\t\t\treturn v instanceof Promise ? v.then(make) : make(v);\n\t\t\t};\n\t\t});\n\t\tc.b.emit((f) => {\n\t\t\tconst list = collect(parts, f);\n\t\t\tconst print = (groups: PrintPart[][]) => {\n\t\t\t\tdebugPrint(f.session, groups.flat());\n\t\t\t\treturn undefined;\n\t\t\t};\n\t\t\treturn list instanceof Promise ? list.then(print) : print(list);\n\t\t});\n\t},\n\tOpen: unsupported('File I/O (Open)'),\n\tClose: unsupported('File I/O (Close)'),\n\tInput: unsupported('File I/O (Input #)'),\n\tLineInput: unsupported('File I/O (Line Input #)'),\n\tWrite: unsupported('File I/O (Write #)'),\n\tGet: unsupported('File I/O (Get #)'),\n\tPut: unsupported('File I/O (Put #)'),\n\tSeek: unsupported('File I/O (Seek)'),\n\tLock: unsupported('File I/O (Lock)'),\n\tUnlock: unsupported('File I/O (Unlock)'),\n\tWidth: unsupported('File I/O (Width #)'),\n\tVariableDeclaration: () => undefined,\n\tConstDeclaration: () => undefined,\n\tAttributeStatement: () => undefined,\n\tInvalidStatement: (c) => {\n\t\tc.b.emit(() => {\n\t\t\tthrow new VbaRuntimeError(5, 'Syntax error');\n\t\t});\n\t},\n};\n\n/** `LSet s = v` / `RSet s = v`: the value padded or cut to the target's current length. */\nfunction padStatement(\n\tc: StatementCompilerLike,\n\ttarget: Expression,\n\tsource: Expression,\n\tside: 'left' | 'right',\n): void {\n\tconst ref = c.x.ref(target);\n\tconst value = c.x.scalar(source);\n\tc.b.emit((f) => {\n\t\tconst apply = (v: Value) => {\n\t\t\tconst r = ref(f);\n\t\t\tconst put = (cell: Ref) => {\n\t\t\t\tconst cur = cell.get();\n\t\t\t\tif (cur.vt === 36) {\n\t\t\t\t\tlsetRecord(cur.v, v);\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t\tconst n = toStr(scalar(cur), f.session).length;\n\t\t\t\tconst s = toStr(v, f.session);\n\t\t\t\tcell.set(\n\t\t\t\t\tvStr(side === 'left' ? fixLen(s, n) : s.length >= n ? s.slice(0, n) : s.padStart(n, ' ')),\n\t\t\t\t);\n\t\t\t\treturn undefined;\n\t\t\t};\n\t\t\treturn r instanceof Promise ? r.then(put) : put(r);\n\t\t};\n\t\tconst v = value(f);\n\t\treturn v instanceof Promise ? v.then(apply) : apply(v);\n\t});\n}\n","// Compiles a procedure body into its instruction list: one handler per statement kind, merged from\n// the structured (control), jump and error (flow) and remaining (simple) tables.\nimport type { Span, Statement } from '../../lang/index';\nimport { CodeBuilder } from './builder';\nimport { CONTROL } from './control';\nimport type { ExpressionCompiler } from './expressions';\nimport { FLOW } from './flow';\nimport { SIMPLE } from './simple';\nimport type { StatementCompilerLike, StatementHandler, StatementHandlers } from './statement-types';\n\nconst HANDLERS: StatementHandlers = { ...SIMPLE, ...CONTROL, ...FLOW };\n\nexport class StatementCompiler implements StatementCompilerLike {\n\treadonly b = new CodeBuilder();\n\n\tconstructor(readonly x: ExpressionCompiler) {}\n\n\tblock(body: readonly Statement[]): void {\n\t\tfor (const s of body) this.statement(s);\n\t}\n\n\tstatement(s: Statement): void {\n\t\tthis.at(s);\n\t\t(HANDLERS[s.kind] as StatementHandler<Statement['kind']>)(this, s as never);\n\t}\n\n\tat(node: { readonly span: Span }): void {\n\t\tthis.b.line = node.span.start.line;\n\t\tthis.b.column = node.span.start.column;\n\t}\n\n\t/** Compiles a body and closes it: the procedure end is the instruction after the last. */\n\tbody(body: readonly Statement[]): CodeBuilder {\n\t\tthis.block(body);\n\t\tthis.b.mark(this.b.end);\n\t\tfor (const [name, t] of this.b.labels)\n\t\t\tif (t.pc < 0) throw new Error(`label ${name} was never placed`);\n\t\treturn this.b;\n\t}\n}\n","// Compiles one procedure: its body to instructions, and the storage plans of its parameters,\n// result, locals and Static locals.\nimport { MISSING, type Value } from '../../runtime/index';\nimport type { ParamSymbol, StaticType } from '../../semantic/index';\nimport type { CompileContext } from './context';\nimport { ExpressionCompiler } from './expressions';\nimport { StatementCompiler } from './statements';\nimport type { CompiledProcedure, ParamPlan } from './types';\nimport type { ArrayBound } from '../../lang/index';\n\nfunction paramPlan(ctx: CompileContext, p: ParamSymbol): ParamPlan {\n\tlet omitted: Value | null = null;\n\tif (p.optional) {\n\t\tif (p.defaultValue) omitted = ctx.consts.value(p.defaultValue);\n\t\telse if (p.type.kind === 'variant') omitted = MISSING;\n\t}\n\treturn {\n\t\tbyRef: p.passing === 'ByRef',\n\t\toptional: p.optional,\n\t\tparamArray: p.paramArray,\n\t\tcell: ctx.cells.make(p.type, { bounds: null, isNew: false, base: ctx.module.options.base }),\n\t\tomitted,\n\t};\n}\n\nexport function compileProcedure(ctx: CompileContext): CompiledProcedure {\n\tconst p = ctx.procedure;\n\tif (!p) throw new Error('compileProcedure needs a procedure');\n\tconst base = ctx.module.options.base;\n\tconst builder = new StatementCompiler(new ExpressionCompiler(ctx)).body(p.declaration.body);\n\tconst make = (v: { type: StaticType; bounds: readonly ArrayBound[] | null; isNew: boolean }) =>\n\t\tctx.cells.make(v.type, { bounds: v.bounds, isNew: v.isNew, base });\n\treturn {\n\t\tbound: p,\n\t\tcode: builder.code,\n\t\tlocals: p.locals.map(make),\n\t\tstatics: p.statics.map(make),\n\t\tresult: p.result ? make(p.result) : null,\n\t\tparams: p.params.map((param) => paramPlan(ctx, param)),\n\t};\n}\n","// `WithEvents` variables ([MS-VBAL] 5.2.3.1.4): storing an object connects the module's\n// `<variable>_<event>` handlers to it, and replacing it disconnects them.\nimport type { EventSink, Ref, Value } from '../../runtime/index';\nimport type { BoundProcedure } from '../../semantic/index';\nimport { isTrappable } from '../../exec/outcome';\nimport type { Services } from '../services';\nimport { ObjectCell } from '../storage';\nimport type { ClassInstance } from './class-instance';\n\nexport class WithEventsCell extends ObjectCell {\n\tprivate disconnect: (() => void) | null = null;\n\n\tconstructor(\n\t\tcast: (v: Value) => Value,\n\t\tprivate readonly sink: EventSink,\n\t\t/** Every connected WithEvents variable of the program, for `End`, Reset and dispose. */\n\t\tprivate readonly connections: Set<{ detach(): void }>,\n\t) {\n\t\tsuper(cast);\n\t}\n\n\toverride set(v: Value): void {\n\t\tsuper.set(v);\n\t\tthis.detach();\n\t\tconst o = this.value.v;\n\t\tif (o && o.connect) {\n\t\t\tthis.disconnect = o.connect(this.sink);\n\t\t\tthis.connections.add(this);\n\t\t}\n\t}\n\n\t/** Disconnects without changing the value. */\n\tdetach(): void {\n\t\tthis.disconnect?.();\n\t\tthis.disconnect = null;\n\t\tthis.connections.delete(this);\n\t}\n}\n\n/** The sink that runs `handlers` (by lower-case event name) on `owner` (null in a module). */\nexport function handlerSink(\n\tservices: Services,\n\thandlers: ReadonlyMap<string, BoundProcedure>,\n\towner: ClassInstance | null,\n): EventSink {\n\treturn {\n\t\tfire(_source, event, args: readonly Ref[]) {\n\t\t\tconst h = handlers.get(event.toLowerCase());\n\t\t\tif (!h) return undefined;\n\t\t\tconst params = args.slice(0, h.params.length);\n\t\t\treturn services.enter((run) => {\n\t\t\t\t// An error that leaves an event handler is unhandled: no On Error of the code that\n\t\t\t\t// raised the event traps it, as in Office.\n\t\t\t\tconst unhandled = (e: unknown): never => {\n\t\t\t\t\tif (isTrappable(e) && typeof e === 'object' && e !== null) run.untrappable.set(e, null);\n\t\t\t\t\tthrow e;\n\t\t\t\t};\n\t\t\t\tlet r;\n\t\t\t\ttry {\n\t\t\t\t\tr = services.invoke(h, params, [], owner, run);\n\t\t\t\t} catch (e) {\n\t\t\t\t\treturn unhandled(e);\n\t\t\t\t}\n\t\t\t\treturn r instanceof Promise ? r.then(() => undefined, unhandled) : undefined;\n\t\t\t}, undefined);\n\t\t},\n\t};\n}\n","// Per-module compile support: the module-level expression compiler (for constant expressions),\n// its constant evaluator and storage factories, and the factories of the module's variables.\nimport type { Ref } from '../runtime/index';\nimport type { BoundModule, BoundProcedure, VariableSymbol } from '../semantic/index';\nimport { CellFactories } from './compile/cells';\nimport { CompileContext } from './compile/context';\nimport { ConstEvaluator } from './compile/const-eval';\nimport { ExpressionCompiler } from './compile/expressions';\nimport { compileProcedure } from './compile/procedure';\nimport type { CompiledProcedure } from './compile/types';\nimport { Frame } from './frame';\nimport { WithEventsCell, handlerSink } from './objects/events';\nimport type { ClassInstance } from './objects/class-instance';\nimport type { Services } from './services';\n\nexport class ModuleRuntime {\n\treadonly consts: ConstEvaluator;\n\treadonly cells: CellFactories;\n\treadonly ctx: CompileContext;\n\tprivate readonly compiler: ExpressionCompiler;\n\tprivate factories: (() => Ref)[] | null = null;\n\n\tconstructor(\n\t\tprivate readonly services: Services,\n\t\treadonly module: BoundModule,\n\t) {\n\t\tthis.consts = new ConstEvaluator((e) => {\n\t\t\tconst ev = this.compiler.value(e);\n\t\t\treturn ev(this.constFrame());\n\t\t}, services.session);\n\t\tthis.cells = new CellFactories(services, this.consts);\n\t\tthis.ctx = new CompileContext(services, module, null, this.consts, this.cells);\n\t\tthis.compiler = new ExpressionCompiler(this.ctx);\n\t}\n\n\t/** A frame without a procedure, for constant expressions. */\n\tprivate constFrame(): Frame {\n\t\treturn new Frame(EMPTY_CODE, this.services.activeRun(), [], null, null, []);\n\t}\n\n\tcompile(p: BoundProcedure): CompiledProcedure {\n\t\treturn compileProcedure(\n\t\t\tnew CompileContext(this.services, this.module, p, this.consts, this.cells),\n\t\t);\n\t}\n\n\t/** A fresh variable of the module (or of an instance, for a class), with its events connected. */\n\tvariable(v: VariableSymbol, owner: ClassInstance | null): Ref {\n\t\tif (v.withEvents) {\n\t\t\tconst handlers = this.module.eventHandlers.get(v.name.toLowerCase()) ?? new Map();\n\t\t\treturn new WithEventsCell(\n\t\t\t\tthis.services.castObject(v.type),\n\t\t\t\thandlerSink(this.services, handlers, owner),\n\t\t\t\tthis.services.connections,\n\t\t\t);\n\t\t}\n\t\treturn this.factory(v)();\n\t}\n\n\tprivate factory(v: VariableSymbol): () => Ref {\n\t\tthis.factories ??= this.module.variables.map((s) =>\n\t\t\tthis.cells.make(s.type, { bounds: s.bounds, isNew: s.isNew, base: this.module.options.base }),\n\t\t);\n\t\treturn this.factories[v.slot] as () => Ref;\n\t}\n\n\t/** Every variable of the module, for its module state or a new instance. */\n\tvariables(owner: ClassInstance | null): Ref[] {\n\t\treturn this.module.variables.map((v) => this.variable(v, owner));\n\t}\n}\n\nconst EMPTY_CODE = {\n\tbound: null,\n\tcode: [],\n\tlocals: [],\n\tstatics: [],\n\tresult: null,\n\tparams: [],\n} as unknown as CompiledProcedure;\n","// The variables of a standard or document module, and the Static locals of its procedures. They\n// live for the life of the program and are cleared by `End` ([MS-VBAL] 5.4.2.18).\nimport type { Ref } from '../runtime/index';\nimport type { BoundModule, BoundProcedure } from '../semantic/index';\n\nexport class ModuleState {\n\tvars: Ref[] = [];\n\treadonly statics = new Map<BoundProcedure, Ref[]>();\n\tprivate initialized = false;\n\n\tconstructor(\n\t\treadonly module: BoundModule,\n\t\tprivate readonly init: () => Ref[],\n\t) {}\n\n\t/** Creates the variables on first use (array bounds may name constants of other modules). */\n\tensure(): this {\n\t\tif (!this.initialized) {\n\t\t\tthis.initialized = true;\n\t\t\tthis.vars = this.init();\n\t\t}\n\t\treturn this;\n\t}\n\n\treset(): void {\n\t\tthis.initialized = false;\n\t\tthis.vars = [];\n\t\tthis.statics.clear();\n\t}\n}\n","// The `Err` and `Debug` objects of VBA's library as host objects, so `Err.Number`, `With Err`,\n// `Err.Raise Number:=5` and `Debug.Assert` go through the same member access as any object.\nimport {\n\tEMPTY,\n\tVbaRuntimeError,\n\tdebugAssert,\n\tgiven,\n\tnoMember,\n\tscalar,\n\ttoBool,\n\ttoLng,\n\ttoStr,\n\tvLng,\n\tvStr,\n\ttype NamedArgs,\n\ttype Value,\n\ttype VbaObject,\n\ttype VbaSession,\n} from '../../runtime/index';\n\nconst RAISE_PARAMS = ['number', 'source', 'description', 'helpfile', 'helpcontext'];\n\n/** Positional and named arguments placed on a parameter list (named by lower-case name). */\nfunction placed(\n\tparams: readonly string[],\n\targs: readonly Value[],\n\tnamed?: NamedArgs,\n): (Value | undefined)[] {\n\tconst out: (Value | undefined)[] = params.map((_, i) => args[i]);\n\tif (named)\n\t\tfor (const [n, v] of named) {\n\t\t\tconst i = params.indexOf(n.toLowerCase());\n\t\t\tif (i < 0) throw new VbaRuntimeError(448);\n\t\t\tout[i] = v;\n\t\t}\n\treturn out.map((v) => (v && given(v) ? v : undefined));\n}\n\nexport function errObject(s: VbaSession): VbaObject {\n\tconst err = s.err;\n\tconst read = (name: string): Value => {\n\t\tswitch (name.toLowerCase()) {\n\t\t\tcase '':\n\t\t\tcase 'number':\n\t\t\t\treturn vLng(err.number);\n\t\t\tcase 'description':\n\t\t\t\treturn vStr(err.description);\n\t\t\tcase 'source':\n\t\t\t\treturn vStr(err.source);\n\t\t\tcase 'helpfile':\n\t\t\t\treturn vStr(err.helpFile);\n\t\t\tcase 'helpcontext':\n\t\t\t\treturn vLng(err.helpContext);\n\t\t\tcase 'lastdllerror':\n\t\t\t\treturn vLng(err.lastDllError);\n\t\t\tdefault:\n\t\t\t\treturn noMember(name);\n\t\t}\n\t};\n\tconst invoke = (name: string, args: readonly Value[], named?: NamedArgs): Value => {\n\t\tswitch (name.toLowerCase()) {\n\t\t\tcase 'raise': {\n\t\t\t\tconst [n, source, description, helpFile, helpContext] = placed(RAISE_PARAMS, args, named);\n\t\t\t\tif (n === undefined) throw new VbaRuntimeError(449);\n\t\t\t\treturn err.raise(n, source, description, helpFile, helpContext, s);\n\t\t\t}\n\t\t\tcase 'clear':\n\t\t\t\terr.clear();\n\t\t\t\treturn EMPTY;\n\t\t\tdefault:\n\t\t\t\tif (args.length > 0) throw new VbaRuntimeError(450);\n\t\t\t\treturn read(name);\n\t\t}\n\t};\n\treturn {\n\t\ttypeName: () => 'ErrObject',\n\t\tget: invoke,\n\t\tcall: invoke,\n\t\tlet: (name, args, value) => {\n\t\t\tif (args.length > 0) throw new VbaRuntimeError(450);\n\t\t\tconst v = scalar(value);\n\t\t\tswitch (name.toLowerCase()) {\n\t\t\t\tcase '':\n\t\t\t\tcase 'number':\n\t\t\t\t\terr.number = toLng(v, s);\n\t\t\t\t\tif (!err.description) err.description = new VbaRuntimeError(err.number).description;\n\t\t\t\t\treturn;\n\t\t\t\tcase 'description':\n\t\t\t\t\terr.description = toStr(v, s);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'source':\n\t\t\t\t\terr.source = toStr(v, s);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'helpfile':\n\t\t\t\t\terr.helpFile = toStr(v, s);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'helpcontext':\n\t\t\t\t\terr.helpContext = toLng(v, s);\n\t\t\t\t\treturn;\n\t\t\t\tdefault:\n\t\t\t\t\tnoMember(name);\n\t\t\t}\n\t\t},\n\t\tset: (name) => noMember(name),\n\t};\n}\n\nexport function debugObject(s: VbaSession): VbaObject {\n\tconst call = (name: string, args: readonly Value[]): Value => {\n\t\tif (name.toLowerCase() !== 'assert') return noMember(name);\n\t\tconst v = args[0];\n\t\tif (v === undefined) throw new VbaRuntimeError(449);\n\t\tdebugAssert(s, toBool(scalar(v), s));\n\t\treturn EMPTY;\n\t};\n\treturn {\n\t\ttypeName: () => 'Debug',\n\t\tget: call,\n\t\tcall,\n\t\tlet: (name) => noMember(name),\n\t\tset: (name) => noMember(name),\n\t};\n}\n","// What one `run` or `fireEvent` shares across its frames: the session, the limit guard, the\n// interpreter's services, the objects waiting for Class_Terminate, and where errors came from.\nimport type { VbaStackFrame } from '../exec/contract';\nimport { TerminationQueue, type VbaSession } from '../runtime/index';\nimport type { LimitGuard } from '../exec/limit-guard';\nimport type { Services } from './services';\n\n/** An object whose last counted reference went (or a new one nobody holds yet). */\nexport interface Terminable {\n\tterminate(run: RunContext): unknown;\n}\n\nexport class RunContext {\n\t/** Objects to check for Class_Terminate at the end of the statement that dropped them. */\n\treadonly terminations = new TerminationQueue<Terminable>();\n\t/** The procedures each unhandled error left, innermost first. */\n\treadonly stacks = new WeakMap<object, VbaStackFrame[]>();\n\t/**\n\t * Errors a handler may not trap: `null` for every frame (an error that left an event handler),\n\t * else only the frame that raised it (recursive GoSub out of stack space).\n\t */\n\treadonly untrappable = new WeakMap<object, unknown>();\n\t/**\n\t * True while the run is parked: waiting on its host or yielding (`yieldMillis`). A call into\n\t * the program then queues behind the run; a call made while the run computes (synchronously,\n\t * from a host member it called) runs inside it.\n\t */\n\tsuspended = false;\n\n\t/** Awaits `p` with the run marked suspended. */\n\tasync park<T>(p: Promise<T>): Promise<T> {\n\t\tthis.suspended = true;\n\t\ttry {\n\t\t\treturn await p;\n\t\t} finally {\n\t\t\tthis.suspended = false;\n\t\t}\n\t}\n\n\tconstructor(\n\t\treadonly session: VbaSession,\n\t\treadonly guard: LimitGuard,\n\t\treadonly services: Services,\n\t) {}\n\n\t/** Queues an object to be checked when the current statement ends. */\n\tqueue(o: Terminable): void {\n\t\tthis.terminations.push(o, this.guard.depth);\n\t}\n}\n","// One run at a time: program runs, events and host callbacks into objects the program made go\n// through one queue, each with its own limit guard, and each ends the same way (Terminate queue\n// collected, guard closed, outcome mapped). A call that arrives while a run is computing (a\n// runtime operation reading a default member, a host member the macro called calling back\n// synchronously) runs inside that run instead, as VBA does. A call that arrives while the run is\n// parked (waiting on its host, or yielding) queues behind it, so runs never interleave.\nimport type { VbaRunResult } from '../exec/contract';\nimport type { CancelSources } from '../exec/limit-guard';\nimport { VbaCallbackFailure, completed, notRun, outcomeOf } from '../exec/outcome';\nimport { VbaAbort, type Value } from '../runtime/index';\nimport { type MaybePromise } from './async';\nimport type { InterpreterCore } from './core';\nimport { collectGarbage } from './executor';\nimport { escape } from './objects/lifetime';\nimport type { RunContext } from './run-context';\n\nconst isValue = (v: unknown): v is Value =>\n\ttypeof v === 'object' && v !== null && 'vt' in v && (v as { vt: unknown }).vt === 9;\n\nexport class RunScheduler {\n\tprivate queue: Promise<unknown> = Promise.resolve();\n\t/** Queued or running work. */\n\tprivate pending = 0;\n\tdisposed = false;\n\n\tconstructor(\n\t\tprivate readonly core: InterpreterCore,\n\t\tprivate readonly cancel: CancelSources,\n\t) {}\n\n\tget isRunning(): boolean {\n\t\treturn this.pending > 0 || this.core.current !== null;\n\t}\n\n\t/** The run a newcomer joins: the one computing now (the newcomer is on its stack). */\n\tget joinable(): RunContext | null {\n\t\tconst cur = this.core.current;\n\t\treturn cur && !cur.suspended ? cur : null;\n\t}\n\n\t/** Runs `work` after everything queued before it. */\n\tserial<T>(work: () => MaybePromise<T>): Promise<T> {\n\t\tthis.pending++;\n\t\tconst next = this.queue.then(work);\n\t\tconst settled = next.finally(() => this.pending--);\n\t\tthis.queue = settled.catch(() => undefined);\n\t\treturn settled;\n\t}\n\n\t/** A program run: `body` in a run of its own, its ending mapped to a result. */\n\tasync execute(\n\t\tbody: (run: RunContext) => MaybePromise<Value>,\n\t\tisFunction: boolean,\n\t): Promise<VbaRunResult> {\n\t\tif (this.disposed) return notRun(51, 'The program was disposed');\n\t\tconst run = this.start();\n\t\ttry {\n\t\t\trun.guard.checkCancel();\n\t\t\tthis.core.ensureModules();\n\t\t\tconst value = await body(run);\n\t\t\t// The host holds what it receives: it never terminates behind the host's back.\n\t\t\tif (isFunction) escape(value);\n\t\t\tawait collectGarbage(run);\n\t\t\treturn completed(isFunction ? value : undefined, run.guard.executed);\n\t\t} catch (e) {\n\t\t\treturn this.outcome(e, run);\n\t\t} finally {\n\t\t\tthis.finish(run);\n\t\t}\n\t}\n\n\t/** `run` called from inside a run (as `Application.Run`): runs in that run. */\n\tasync nested(\n\t\trun: RunContext,\n\t\tbody: (run: RunContext) => MaybePromise<Value>,\n\t\tisFunction: boolean,\n\t): Promise<VbaRunResult> {\n\t\ttry {\n\t\t\tconst value = await body(run);\n\t\t\tif (isFunction) escape(value);\n\t\t\treturn completed(isFunction ? value : undefined, run.guard.executed);\n\t\t} catch (e) {\n\t\t\treturn this.outcome(e, run);\n\t\t}\n\t}\n\n\t/**\n\t * A host's call into an object of the program (a member of a class instance it holds, a\n\t * WithEvents handler): inside the current run when it can join it, else a run of its own,\n\t * queued behind the work in progress. Failures of a run of its own reach the host as a\n\t * `VbaCallbackFailure`; `halted` is what the call answers after `End` or `Stop`.\n\t */\n\tenter<T>(work: (run: RunContext) => MaybePromise<T>, halted: T): MaybePromise<T> {\n\t\tconst cur = this.joinable;\n\t\tif (cur) return work(cur);\n\t\tif (this.disposed) throw new VbaCallbackFailure(notRun(51, 'The program was disposed'));\n\t\tif (this.pending === 0 && this.core.current === null) return this.callback(work, halted);\n\t\treturn this.serial(() => this.callback(work, halted));\n\t}\n\n\tprivate callback<T>(work: (run: RunContext) => MaybePromise<T>, halted: T): MaybePromise<T> {\n\t\tconst run = this.start();\n\t\tthis.pending++;\n\t\tconst done = (value: T): MaybePromise<T> => {\n\t\t\tif (isValue(value)) escape(value);\n\t\t\tconst g = collectGarbage(run);\n\t\t\tif (g instanceof Promise)\n\t\t\t\treturn g.then(\n\t\t\t\t\t() => this.close(run, value),\n\t\t\t\t\t(e: unknown) => this.fail(run, e, halted),\n\t\t\t\t);\n\t\t\treturn this.close(run, value);\n\t\t};\n\t\tlet r: MaybePromise<T>;\n\t\ttry {\n\t\t\trun.guard.checkCancel();\n\t\t\tthis.core.ensureModules();\n\t\t\tr = work(run);\n\t\t} catch (e) {\n\t\t\treturn this.fail(run, e, halted);\n\t\t}\n\t\tif (r instanceof Promise) return r.then(done, (e: unknown) => this.fail(run, e, halted));\n\t\ttry {\n\t\t\treturn done(r);\n\t\t} catch (e) {\n\t\t\treturn this.fail(run, e, halted);\n\t\t}\n\t}\n\n\tprivate close<T>(run: RunContext, value: T): T {\n\t\tthis.finish(run);\n\t\tthis.pending--;\n\t\treturn value;\n\t}\n\n\tprivate fail<T>(run: RunContext, e: unknown, halted: T): T {\n\t\tconst result = this.outcome(e, run);\n\t\tthis.close(run, undefined);\n\t\tif (result.ok) return halted;\n\t\tthrow new VbaCallbackFailure(result);\n\t}\n\n\tprivate start(): RunContext {\n\t\tconst run = this.core.newRun(this.cancel);\n\t\tthis.core.current = run;\n\t\treturn run;\n\t}\n\n\tprivate finish(run: RunContext): void {\n\t\trun.guard.close();\n\t\tif (this.core.current === run) this.core.current = null;\n\t}\n\n\tprivate outcome(e: unknown, run: RunContext): VbaRunResult {\n\t\tif (e instanceof VbaAbort && e.reason === 'end') this.core.reset();\n\t\tconst stack = typeof e === 'object' && e !== null ? run.stacks.get(e) : undefined;\n\t\treturn outcomeOf(e, {\n\t\t\tsteps: run.guard.executed,\n\t\t\tprojectName: this.core.session.projectName,\n\t\t\tstack,\n\t\t});\n\t}\n}\n","// The interpreter's services: module state, compiled procedures (compiled on first call),\n// procedure activation, constants, user-defined types, and object creation and conversion.\nimport {\n\tVT,\n\tVbaArray,\n\tVbaRuntimeError,\n\tarrayOf,\n\tcollectionObject,\n\tdefineUdt,\n\tletAs,\n\tscalar,\n\ttoLng,\n\tvArr,\n\tvLng,\n\tvObj,\n\ttype Ref,\n\ttype UdtField,\n\ttype UdtType,\n\ttype Value,\n\ttype VbaObject,\n\ttype VbaSession,\n} from '../runtime/index';\nimport type {\n\tBoundModule,\n\tBoundProcedure,\n\tBoundProgram,\n\tConstSymbol,\n\tEnumMemberSymbol,\n\tStaticType,\n\tUdtSymbol,\n} from '../semantic/index';\nimport { andThen, type MaybePromise, type MaybeValue } from './async';\nimport type { CompiledProcedure } from './compile/types';\nimport { collectGarbage, execute } from './executor';\nimport { Frame, closeCursors } from './frame';\nimport { LibraryDispatch } from './library';\nimport { LimitGuard, type CancelSources } from '../exec/limit-guard';\nimport { ModuleRuntime } from './module-runtime';\nimport { ModuleState } from './module-state';\nimport { ClassInstance, classInstanceOf } from './objects/class-instance';\nimport { InterfaceView } from './objects/interface-view';\nimport { defaultInterface, release, retain } from './objects/lifetime';\nimport { debugObject, errObject } from './objects/library-objects';\nimport { RunContext, type Terminable } from './run-context';\nimport { RunScheduler } from './scheduler';\nimport type { CompileGate } from '../exec/compile-gate';\nimport { VbaCompileError } from '../exec/outcome';\nimport type { HostScope, Services } from './services';\nimport { ArrayCell, ElementRef, TempCell, VariantCell } from './storage';\nimport type { VbaExecLimits } from '../exec/contract';\nimport type { ArrayBound } from '../lang/index';\n\nexport class InterpreterCore implements Services {\n\treadonly library = new LibraryDispatch();\n\treadonly err: VbaObject;\n\treadonly debug: VbaObject;\n\t/** The run in progress (runs are serialised by the scheduler). */\n\tcurrent: RunContext | null = null;\n\treadonly scheduler: RunScheduler;\n\t/** Connected WithEvents variables, disconnected by `End`, Reset and dispose. */\n\treadonly connections = new Set<{ detach(): void }>();\n\tprivate readonly runtimes = new Map<BoundModule, ModuleRuntime>();\n\tprivate readonly states = new Map<BoundModule, ModuleState>();\n\tprivate readonly code = new Map<BoundProcedure, CompiledProcedure>();\n\tprivate readonly constants = new Map<ConstSymbol, Value>();\n\tprivate readonly enums = new Map<EnumMemberSymbol, Value>();\n\tprivate readonly udts = new Map<UdtSymbol, UdtType>();\n\tprivate readonly defaults = new Map<BoundModule, Value>();\n\n\tconstructor(\n\t\treadonly program: BoundProgram,\n\t\treadonly session: VbaSession,\n\t\treadonly host: HostScope,\n\t\tprivate readonly limits: VbaExecLimits,\n\t\tcancel: CancelSources = {},\n\t\tprivate readonly gate: CompileGate | null = null,\n\t) {\n\t\tthis.scheduler = new RunScheduler(this, cancel);\n\t\tthis.err = errObject(session);\n\t\tthis.debug = debugObject(session);\n\t}\n\n\truntime(m: BoundModule): ModuleRuntime {\n\t\tlet r = this.runtimes.get(m);\n\t\tif (!r) {\n\t\t\tr = new ModuleRuntime(this, m);\n\t\t\tthis.runtimes.set(m, r);\n\t\t}\n\t\treturn r;\n\t}\n\n\tmoduleState(m: BoundModule): ModuleState {\n\t\tlet s = this.states.get(m);\n\t\tif (!s) {\n\t\t\ts = new ModuleState(m, () => this.runtime(m).variables(null));\n\t\t\tthis.states.set(m, s);\n\t\t}\n\t\treturn s;\n\t}\n\n\t/** Creates every module's variables (after a reset, before a run). */\n\tensureModules(): void {\n\t\tfor (const m of this.program.modules) if (!m.perInstance) this.moduleState(m).ensure();\n\t}\n\n\t/**\n\t * `End` and the VBE's Reset: every module variable and Static local back to its initial value,\n\t * default instances dropped, WithEvents disconnected. No Class_Terminate runs.\n\t */\n\treset(): void {\n\t\tfor (const c of [...this.connections]) c.detach();\n\t\tthis.connections.clear();\n\t\tfor (const s of this.states.values()) s.reset();\n\t\tthis.defaults.clear();\n\t}\n\n\tcompiled(p: BoundProcedure): CompiledProcedure {\n\t\tlet c = this.code.get(p);\n\t\tif (!c) {\n\t\t\tc = this.runtime(p.module).compile(p);\n\t\t\tthis.code.set(p, c);\n\t\t}\n\t\treturn c;\n\t}\n\n\tnewRun(cancel: CancelSources = {}): RunContext {\n\t\treturn new RunContext(this.session, new LimitGuard(this.limits, cancel), this);\n\t}\n\n\tactiveRun(): RunContext {\n\t\treturn this.current ?? this.newRun();\n\t}\n\n\tenter<T>(work: (run: RunContext) => MaybePromise<T>, halted: T): MaybePromise<T> {\n\t\treturn this.scheduler.enter(work, halted);\n\t}\n\n\tlastReleased(o: Terminable): void {\n\t\tif (this.current) {\n\t\t\tthis.current.queue(o);\n\t\t\treturn;\n\t\t}\n\t\t// The host dropped the last reference outside a run: Class_Terminate runs as a callback.\n\t\tconst r = this.scheduler.enter((run) => run.queue(o), undefined);\n\t\tif (r instanceof Promise) r.catch(() => undefined);\n\t}\n\n\tinvoke(\n\t\tp: BoundProcedure,\n\t\targs: readonly (Ref | null)[],\n\t\trest: readonly Value[],\n\t\tinstance: ClassInstance | null,\n\t\trun: RunContext,\n\t): MaybeValue {\n\t\tconst broken = this.gate?.moduleError(p.module);\n\t\tif (broken) throw new VbaCompileError(broken);\n\t\tconst code = this.compiled(p);\n\t\trun.guard.enter();\n\t\tconst n = p.params.length;\n\t\tconst slots: Ref[] = new Array<Ref>(p.frameSize);\n\t\tconst owned: Ref[] = [];\n\t\t// A caller's temporary object argument lives until the call ends; an array whose element\n\t\t// is passed ByRef cannot be resized while the callee holds the element (error 10).\n\t\tconst held: Value[] = [];\n\t\tconst locks: VbaArray[] = [];\n\t\tconst unhold = () => {\n\t\t\tfor (const v of held) release(v);\n\t\t\tfor (const a of locks) a.locked--;\n\t\t};\n\t\ttry {\n\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\tconst plan = code.params[i] as CompiledProcedure['params'][number];\n\t\t\t\tconst a = args[i] ?? null;\n\t\t\t\tlet cell: Ref;\n\t\t\t\tif (plan.paramArray) cell = new VariantCell(vArr(arrayOf(rest, 0, this.session)));\n\t\t\t\telse if (a === null) {\n\t\t\t\t\tif (!plan.optional) throw new VbaRuntimeError(449);\n\t\t\t\t\tcell = plan.cell();\n\t\t\t\t\tif (plan.omitted) cell.set(plan.omitted);\n\t\t\t\t} else if (plan.byRef && !(a instanceof TempCell)) cell = a;\n\t\t\t\telse {\n\t\t\t\t\tcell = plan.cell();\n\t\t\t\t\tcell.set(a.get());\n\t\t\t\t}\n\t\t\t\tif (cell !== a) owned.push(cell);\n\t\t\t\tif (a instanceof TempCell && a.value.vt === 9) {\n\t\t\t\t\tretain(a.value);\n\t\t\t\t\theld.push(a.value);\n\t\t\t\t} else if (cell === a && a instanceof ElementRef) {\n\t\t\t\t\ta.array.locked++;\n\t\t\t\t\tlocks.push(a.array);\n\t\t\t\t}\n\t\t\t\tslots[i] = cell;\n\t\t\t}\n\t\t\tconst result = code.result ? code.result() : new VariantCell();\n\t\t\tslots[n] = result;\n\t\t\towned.push(result);\n\t\t\tfor (let j = 0; j < code.locals.length; j++) {\n\t\t\t\tconst cell = (code.locals[j] as () => Ref)();\n\t\t\t\tslots[n + 1 + j] = cell;\n\t\t\t\towned.push(cell);\n\t\t\t}\n\t\t} catch (e) {\n\t\t\tunhold();\n\t\t\trun.guard.leave();\n\t\t\tthrow e;\n\t\t}\n\t\tconst statics = code.statics.length > 0 ? this.statics(p, code, instance) : [];\n\t\tconst me =\n\t\t\tinstance ??\n\t\t\t(p.module.kind === 'document'\n\t\t\t\t? (this.host.documentObjects.get(p.module.name.toLowerCase()) ?? null)\n\t\t\t\t: null);\n\t\tconst f = new Frame(code, run, slots, me, instance, statics);\n\t\tinstance?.retain();\n\t\tconst leave = (): Value => {\n\t\t\tif (f.handler.handling) this.session.err.clear();\n\t\t\tconst value = (slots[n] as Ref).get();\n\t\t\t// Locals, With subjects and Me go at the callee's depth, so an error exit can collect them.\n\t\t\t// Locals go in reverse order of declaration, as in Office.\n\t\t\tfor (let i = owned.length - 1; i >= 0; i--) {\n\t\t\t\tconst cell = owned[i] as Ref;\n\t\t\t\tconst v = cell instanceof ArrayCell ? cell.value : cell.get();\n\t\t\t\tif (v.vt === 9) release(v);\n\t\t\t\telse if (v.vt === 8192 && cell instanceof ArrayCell) v.v.releaseAll();\n\t\t\t}\n\t\t\tfor (const v of f.with) if (v) release(v);\n\t\t\tcloseCursors(f);\n\t\t\tunhold();\n\t\t\tinstance?.release();\n\t\t\trun.guard.leave();\n\t\t\treturn value;\n\t\t};\n\t\t/** An error leaves the procedure: its locals terminate before any caller's handler runs. */\n\t\tconst fail = (e: unknown): MaybePromise<never> => {\n\t\t\tleave();\n\t\t\tconst g = collectGarbage(run, f.depth, f.since);\n\t\t\tif (g instanceof Promise)\n\t\t\t\treturn g.then(() => {\n\t\t\t\t\tthrow e;\n\t\t\t\t});\n\t\t\tthrow e;\n\t\t};\n\t\tlet r;\n\t\ttry {\n\t\t\tr = execute(f);\n\t\t} catch (e) {\n\t\t\treturn fail(e);\n\t\t}\n\t\tif (r instanceof Promise) return r.then(leave, fail);\n\t\treturn leave();\n\t}\n\n\tprivate statics(\n\t\tp: BoundProcedure,\n\t\tcode: CompiledProcedure,\n\t\tinstance: ClassInstance | null,\n\t): Ref[] {\n\t\tconst store = instance ? instance.statics : this.moduleState(p.module).statics;\n\t\tlet s = store.get(p);\n\t\tif (!s) {\n\t\t\ts = code.statics.map((make) => make());\n\t\t\tstore.set(p, s);\n\t\t}\n\t\treturn s;\n\t}\n\n\tconstValue(c: ConstSymbol): Value {\n\t\tlet v = this.constants.get(c);\n\t\tif (!v) {\n\t\t\tconst m = this.program.module(c.module);\n\t\t\tif (!m) throw new VbaRuntimeError(51);\n\t\t\tv = this.runtime(m).consts.value(c.value);\n\t\t\tif (c.type?.kind === 'scalar') v = letAs(c.type.vt, scalar(v), this.session);\n\t\t\tthis.constants.set(c, v);\n\t\t}\n\t\treturn v;\n\t}\n\n\tenumValue(e: EnumMemberSymbol): Value {\n\t\tlet v = this.enums.get(e);\n\t\tif (!v) {\n\t\t\tconst m = this.program.module(e.module);\n\t\t\tif (!m) throw new VbaRuntimeError(51);\n\t\t\tif (e.value) v = vLng(this.runtime(m).consts.number(e.value));\n\t\t\telse if (e.previous) v = vLng(toLng(this.enumValue(e.previous)) + 1);\n\t\t\telse v = vLng(0);\n\t\t\tthis.enums.set(e, v);\n\t\t}\n\t\treturn v;\n\t}\n\n\tudtType(u: UdtSymbol): UdtType {\n\t\tlet t = this.udts.get(u);\n\t\tif (t) return t;\n\t\tconst m = this.program.module(u.module);\n\t\tif (!m) throw new VbaRuntimeError(51);\n\t\tconst rt = this.runtime(m);\n\t\tconst fields: UdtField[] = u.fields.map((f) => this.udtField(rt, f.name, f.type, f.bounds));\n\t\tt = defineUdt(u.name, fields);\n\t\tthis.udts.set(u, t);\n\t\treturn t;\n\t}\n\n\tprivate udtField(\n\t\trt: ModuleRuntime,\n\t\tname: string,\n\t\ttype: StaticType,\n\t\tbounds: readonly ArrayBound[] | null,\n\t): UdtField {\n\t\tswitch (type.kind) {\n\t\t\tcase 'scalar':\n\t\t\t\treturn type.fixedLength\n\t\t\t\t\t? { name, vt: type.vt, fixedLength: rt.consts.number(type.fixedLength) }\n\t\t\t\t\t: { name, vt: type.vt };\n\t\t\tcase 'object':\n\t\t\t\treturn { name, vt: VT.Object };\n\t\t\tcase 'udt':\n\t\t\t\treturn { name, vt: VT.UserDefinedType, type: this.udtType(type.udt) };\n\t\t\tcase 'array': {\n\t\t\t\tconst make = rt.cells.make(type, { bounds, isNew: false, base: rt.module.options.base });\n\t\t\t\treturn { name, vt: VT.Array, array: () => (make().get() as { v: VbaArray }).v };\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn { name, vt: VT.Variant };\n\t\t}\n\t}\n\n\tcreateObject(type: StaticType, run: RunContext): MaybeValue {\n\t\tif (type.kind !== 'object') throw new VbaRuntimeError(429);\n\t\tconst cls = type.classModule ? this.program.module(type.classModule) : undefined;\n\t\tif (cls && cls.kind === 'class') return this.instantiate(cls, run);\n\t\tif ((type.className ?? '').toLowerCase().replace(/^vba\\./, '') === 'collection')\n\t\t\treturn vObj(collectionObject(this.session));\n\t\tthrow new VbaRuntimeError(\n\t\t\t429,\n\t\t\t`ActiveX component can't create object (${type.className ?? 'Object'})`,\n\t\t);\n\t}\n\n\tprivate instantiate(m: BoundModule, run: RunContext): MaybeValue {\n\t\tconst instance = new ClassInstance(m, this);\n\t\tinstance.vars.push(...this.runtime(m).variables(instance));\n\t\trun.queue(instance);\n\t\tconst init = m.groups.get('class_initialize')?.method;\n\t\tconst value = vObj(instance);\n\t\tif (!init) return value;\n\t\treturn andThen(this.invoke(init, [], [], instance, run), () => value);\n\t}\n\n\tdefaultInstance(m: BoundModule, run: RunContext): MaybeValue {\n\t\tconst known = this.defaults.get(m);\n\t\tif (known) return known;\n\t\treturn andThen(this.instantiate(m, run), (v) => {\n\t\t\tclassInstanceOf(v)?.escape();\n\t\t\tthis.defaults.set(m, v);\n\t\t\treturn v;\n\t\t});\n\t}\n\n\tcastObject(type: StaticType): (v: Value) => Value {\n\t\tif (type.kind !== 'object' || !type.classModule) return defaultInterface;\n\t\tconst target = this.program.module(type.classModule);\n\t\tif (!target) return defaultInterface;\n\t\treturn (v) => {\n\t\t\tif (v.vt !== 9 || v.v === null) return v;\n\t\t\tconst o = v.v;\n\t\t\tconst instance = classInstanceOf(v);\n\t\t\tif (!instance) throw new VbaRuntimeError(13);\n\t\t\tif (instance.module === target) return vObj(instance);\n\t\t\tif (!instance.module.implements.includes(target)) throw new VbaRuntimeError(13);\n\t\t\tif (o instanceof InterfaceView && o.iface === target) return v;\n\t\t\treturn vObj(new InterfaceView(instance, target));\n\t\t};\n\t}\n}\n","// The interpreter as a `VbaProgram` (exec/contract.ts): binds the project once, then runs\n// procedures and event handlers through the run scheduler, which turns each ending into a\n// `VbaRunResult`.\nimport type {\n\tVbaExecLimits,\n\tVbaProcedure,\n\tVbaProgram,\n\tVbaProgramDiagnostic,\n\tVbaProgramOptions,\n\tVbaRunResult,\n} from '../exec/contract';\nimport { DEFAULT_EXEC_LIMITS } from '../exec/contract';\nimport { normalizeDocumentObjects } from '../exec/host-scope';\nimport { compileFailure, notRun } from '../exec/outcome';\nimport { listProcedures } from '../lang/index';\nimport { createSession, type Ref, type Value } from '../runtime/index';\nimport { bindProgram, type BoundProcedure, type BoundProgram } from '../semantic/index';\nimport { CompileGate } from '../exec/compile-gate';\nimport { InterpreterCore } from './core';\nimport type { RunContext } from './run-context';\nimport type { RunScheduler } from './scheduler';\nimport { TempCell } from './storage';\n\nconst DEFAULT_YIELD_MILLIS = 100;\n\nclass Interpreter implements VbaProgram {\n\treadonly diagnostics: readonly VbaProgramDiagnostic[];\n\tprivate readonly bound: BoundProgram;\n\tprivate readonly core: InterpreterCore;\n\tprivate readonly gate: CompileGate;\n\n\tconstructor(options: VbaProgramOptions) {\n\t\tconst limits: VbaExecLimits = { ...DEFAULT_EXEC_LIMITS, ...options.limits };\n\t\tthis.bound = bindProgram(options.modules, {\n\t\t\t...(options.constants ? { constants: options.constants } : {}),\n\t\t\tglobals: Object.keys(options.globals ?? {}),\n\t\t\tglobalObject: options.globalObject !== undefined,\n\t\t\tdocumentObjects: Object.keys(options.documentObjects ?? {}),\n\t\t});\n\t\tthis.diagnostics = this.bound.diagnostics.map((d) => ({ ...d }));\n\t\tthis.gate = new CompileGate(this.bound, this.diagnostics);\n\t\tconst s = options.session ?? {};\n\t\t// The meter reports big runtime operations to the guard of the run in progress.\n\t\tconst meter = { charge: (work: number) => this.core.current?.guard.charge(work) };\n\t\tconst session = createSession({\n\t\t\tlimits,\n\t\t\tmeter,\n\t\t\t...(s.locale ? { locale: s.locale } : {}),\n\t\t\t...(s.ui ? { ui: s.ui } : {}),\n\t\t\t...(s.debug ? { debug: s.debug } : {}),\n\t\t\t...(s.environ ? { environ: s.environ } : {}),\n\t\t\t...(s.clock ? { clock: s.clock } : {}),\n\t\t\t...(s.projectName ? { projectName: s.projectName } : {}),\n\t\t});\n\t\tthis.core = new InterpreterCore(\n\t\t\tthis.bound,\n\t\t\tsession,\n\t\t\t{\n\t\t\t\tglobals: normalizeDocumentObjects(options.globals),\n\t\t\t\tglobalObject: options.globalObject,\n\t\t\t\tdocumentObjects: normalizeDocumentObjects(options.documentObjects),\n\t\t\t},\n\t\t\tlimits,\n\t\t\t{\n\t\t\t\tsignal: options.signal,\n\t\t\t\tisCancelled: options.isCancelled,\n\t\t\t\tyieldMillis: options.yieldMillis ?? DEFAULT_YIELD_MILLIS,\n\t\t\t},\n\t\t\tthis.gate,\n\t\t);\n\t}\n\n\tprivate get scheduler(): RunScheduler {\n\t\treturn this.core.scheduler;\n\t}\n\n\tget isRunning(): boolean {\n\t\treturn this.scheduler.isRunning;\n\t}\n\n\tprocedures(): VbaProcedure[] {\n\t\treturn this.bound.modules.flatMap((m) =>\n\t\t\tlistProcedures(m.ast, { moduleKind: m.kind, moduleName: m.name }).map((p) => {\n\t\t\t\tconst bound = m.procedures.find(\n\t\t\t\t\t(b) => b.name.toLowerCase() === p.name.toLowerCase() && b.kind === p.kind,\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\t...p,\n\t\t\t\t\tmodule: m.name,\n\t\t\t\t\tmoduleKind: m.kind,\n\t\t\t\t\tcanRun: bound ? this.gate.blocking(bound) === null : this.gate.moduleError(m) === null,\n\t\t\t\t};\n\t\t\t}),\n\t\t);\n\t}\n\n\trun(name: string, args: readonly Value[] = []): Promise<VbaRunResult> {\n\t\tconst found = this.bound.findGroup(name);\n\t\tif (found === 'ambiguous')\n\t\t\treturn Promise.resolve(notRun(35, `Ambiguous name detected: ${name}`));\n\t\tconst proc = found ? (found.method ?? found.get) : null;\n\t\tif (!proc || proc.module.perInstance)\n\t\t\treturn Promise.resolve(notRun(35, `Sub or Function not defined: ${name}`));\n\t\treturn this.start(proc, () => args.map((v) => new TempCell(v)), proc.kind !== 'Sub');\n\t}\n\n\tfireEvent(objectName: string, event: string, args: readonly Ref[]): Promise<VbaRunResult> {\n\t\tconst m = this.bound.module(objectName);\n\t\tconst host = this.core.host.documentObjects.get(objectName.toLowerCase());\n\t\tconst proc = m && host ? m.handler(host.typeName(), event) : null;\n\t\tif (!proc) return Promise.resolve({ status: 'completed', ok: true, steps: 0 });\n\t\treturn this.start(proc, () => args.slice(0, proc.params.length), false);\n\t}\n\n\treset(): Promise<void> {\n\t\treturn this.scheduler.serial(() => this.core.reset());\n\t}\n\n\tdispose(): void {\n\t\tthis.scheduler.disposed = true;\n\t\tthis.core.reset();\n\t}\n\n\t/** Runs `proc` in a run of its own, or inside the run in progress when called from it. */\n\tprivate start(\n\t\tproc: BoundProcedure,\n\t\targs: () => Ref[],\n\t\tisFunction: boolean,\n\t): Promise<VbaRunResult> {\n\t\tconst blocked = this.gate.blocking(proc);\n\t\tif (blocked) return Promise.resolve(compileFailure(blocked));\n\t\tconst body = (run: RunContext) => this.core.invoke(proc, args(), [], null, run);\n\t\tconst joined = this.scheduler.joinable;\n\t\tif (joined) return this.scheduler.nested(joined, body, isFunction);\n\t\treturn this.scheduler.serial(() => this.scheduler.execute(body, isFunction));\n\t}\n}\n\n/** The tree-walking interpreter: binds `options.modules` and returns the runnable program. */\nexport function createInterpreter(options: VbaProgramOptions): VbaProgram {\n\treturn new Interpreter(options);\n}\n"],"mappings":";;;;;;;;;AAgBA,SAAgB,QACf,GACA,GACkB;CAClB,OAAO,aAAa,UAAU,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;AAC9C;;AChBA,IAAa,oBAAb,MAA+B;;CAE9B,OAAmC;;CAEnC,SAAS;;CAET,WAAW;;CAEX,UAAU;;CAGV,IAAI,MAAkC,QAAgB,KAAsB;EAC3E,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,IAAI,MAAM;CACX;;CAGA,MAAM,KAAsB;EAC3B,KAAK,WAAW;EAChB,IAAI,MAAM;CACX;;;;;CAMA,KAAK,GAAY,IAAY,KAAgB,OAAe,KAAK,GAAW;EAC3E,IAAI,CAAC,YAAY,CAAC,KAAK,KAAK,SAAS,WAAW,KAAK,UAAU,MAAM;EACrE,IAAI,QAAQ,CAAC;EACb,IAAI,KAAK,SAAS,QAAQ,OAAO;EACjC,KAAK,WAAW;EAChB,KAAK,UAAU;EACf,OAAO,KAAK;CACb;;CAGA,OACC,MACA,OACA,KACA,UAAkC,OAAO,KAAK,GACrC;EACT,IAAI,CAAC,KAAK,UAAU,MAAM,IAAI,gBAAgB,EAAE;EAChD,KAAK,WAAW;EAChB,IAA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