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,306 @@
|
|
|
1
|
+
import { Cs as toVbaError, Eo as DEFAULT_LIMITS, _s as VbaRuntimeError, gs as VbaAbort } from "./runtime-C8-PPxmH.js";
|
|
2
|
+
// src/exec/contract.ts
|
|
3
|
+
/** The default limits: the runtime's `DEFAULT_LIMITS`, 50 million steps and 30 seconds. */
|
|
4
|
+
const DEFAULT_EXEC_LIMITS = Object.freeze({
|
|
5
|
+
...DEFAULT_LIMITS,
|
|
6
|
+
maxCallDepth: 1e3,
|
|
7
|
+
maxSteps: 5e7,
|
|
8
|
+
maxMillis: 3e4
|
|
9
|
+
});
|
|
10
|
+
/** References for `fireEvent`: read `refs[i].get()` after the handler to see what it set. */
|
|
11
|
+
function refsOf(values) {
|
|
12
|
+
return values.map((initial) => {
|
|
13
|
+
let value = initial;
|
|
14
|
+
return {
|
|
15
|
+
get: () => value,
|
|
16
|
+
set: (v) => {
|
|
17
|
+
value = v;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// src/exec/compile-gate.ts
|
|
23
|
+
var CompileGate = class {
|
|
24
|
+
broken = /* @__PURE__ */ new Map();
|
|
25
|
+
verdicts = /* @__PURE__ */ new Map();
|
|
26
|
+
constructor(program, diagnostics) {
|
|
27
|
+
for (const d of diagnostics) {
|
|
28
|
+
if (d.severity !== "error") continue;
|
|
29
|
+
const m = program.module(d.module);
|
|
30
|
+
if (m && !this.broken.has(m)) this.broken.set(m, d);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** The first compile error of the module, if any (raised when the module is used). */
|
|
34
|
+
moduleError(m) {
|
|
35
|
+
return this.broken.get(m) ?? null;
|
|
36
|
+
}
|
|
37
|
+
/** The compile error that keeps `p` from running: its module's, or a callee's module's. */
|
|
38
|
+
blocking(p) {
|
|
39
|
+
if (this.broken.size === 0) return null;
|
|
40
|
+
const known = this.verdicts.get(p);
|
|
41
|
+
if (known !== void 0) return known;
|
|
42
|
+
const seen = /* @__PURE__ */ new Set();
|
|
43
|
+
const stack = [p];
|
|
44
|
+
let found = null;
|
|
45
|
+
while (stack.length > 0 && !found) {
|
|
46
|
+
const q = stack.pop();
|
|
47
|
+
if (seen.has(q)) continue;
|
|
48
|
+
seen.add(q);
|
|
49
|
+
found = this.broken.get(q.module) ?? null;
|
|
50
|
+
for (const c of q.facts.callees) stack.push(c);
|
|
51
|
+
}
|
|
52
|
+
this.verdicts.set(p, found);
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
// src/exec/host-scope.ts
|
|
57
|
+
/** `options.globals` / `options.documentObjects` keyed by lower-cased name. */
|
|
58
|
+
function normalizeDocumentObjects(r) {
|
|
59
|
+
const out = /* @__PURE__ */ new Map();
|
|
60
|
+
if (r) for (const k of Object.keys(r)) out.set(k.toLowerCase(), r[k]);
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
// src/exec/limit-guard.ts
|
|
64
|
+
const MAX_INTERVAL = 2048;
|
|
65
|
+
const MIN_INTERVAL = 16;
|
|
66
|
+
const CHECK_TARGET_MS = 4;
|
|
67
|
+
const limitHit = (limits) => new VbaAbort("limit", `Time limit exceeded (${limits.maxMillis} ms)`);
|
|
68
|
+
const cancelled = () => new VbaAbort("cancel", "The run was cancelled");
|
|
69
|
+
/**
|
|
70
|
+
* Enforces one run's step, time and call depth limits and its cancel sources. An executor creates
|
|
71
|
+
* one per run, calls it at every statement and procedure entry, and passes it to the runtime as
|
|
72
|
+
* the environment's work meter.
|
|
73
|
+
*/
|
|
74
|
+
var LimitGuard = class {
|
|
75
|
+
limits;
|
|
76
|
+
cancel;
|
|
77
|
+
now;
|
|
78
|
+
depth = 0;
|
|
79
|
+
steps = 0;
|
|
80
|
+
interval = MAX_INTERVAL;
|
|
81
|
+
untilCheck = MAX_INTERVAL;
|
|
82
|
+
lastCheck;
|
|
83
|
+
nextYield;
|
|
84
|
+
deadline;
|
|
85
|
+
/**
|
|
86
|
+
* Rejects when the run is cancelled or out of time; every wait on a host races it, so a host
|
|
87
|
+
* that never answers cannot hang the run. One per run, made on the first wait.
|
|
88
|
+
*/
|
|
89
|
+
abortPromise;
|
|
90
|
+
release;
|
|
91
|
+
constructor(limits, cancel = {}, now = Date.now) {
|
|
92
|
+
this.limits = limits;
|
|
93
|
+
this.cancel = cancel;
|
|
94
|
+
this.now = now;
|
|
95
|
+
const start = now();
|
|
96
|
+
this.lastCheck = start;
|
|
97
|
+
this.deadline = start + limits.maxMillis;
|
|
98
|
+
this.nextYield = cancel.yieldMillis ? start + cancel.yieldMillis : 1e400;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Counts one statement. True when the run should yield to the event loop before the next
|
|
102
|
+
* statement (only ever at a check).
|
|
103
|
+
*/
|
|
104
|
+
step() {
|
|
105
|
+
if (--this.untilCheck > 0) return false;
|
|
106
|
+
return this.check();
|
|
107
|
+
}
|
|
108
|
+
/** A big operation's work: the next statement checks the clock. */
|
|
109
|
+
charge(_work) {
|
|
110
|
+
this.steps += this.interval - this.untilCheck;
|
|
111
|
+
this.interval = this.untilCheck = 1;
|
|
112
|
+
}
|
|
113
|
+
check() {
|
|
114
|
+
this.steps += this.interval - this.untilCheck;
|
|
115
|
+
if (this.steps > this.limits.maxSteps) throw new VbaAbort("limit", `Step limit exceeded (${this.limits.maxSteps} statements)`);
|
|
116
|
+
const t = this.now();
|
|
117
|
+
if (t > this.deadline) throw limitHit(this.limits);
|
|
118
|
+
this.checkCancel();
|
|
119
|
+
const elapsed = t - this.lastCheck;
|
|
120
|
+
this.lastCheck = t;
|
|
121
|
+
if (elapsed > CHECK_TARGET_MS) this.interval = Math.max(MIN_INTERVAL, this.interval >> 1);
|
|
122
|
+
else if (elapsed < CHECK_TARGET_MS / 4) this.interval = Math.min(MAX_INTERVAL, this.interval * 2);
|
|
123
|
+
this.untilCheck = this.interval;
|
|
124
|
+
return t >= this.nextYield;
|
|
125
|
+
}
|
|
126
|
+
/** Raises the cancel abort when the signal or the host's callback says so. */
|
|
127
|
+
checkCancel() {
|
|
128
|
+
if (this.cancel.signal?.aborted || this.cancel.isCancelled?.()) throw cancelled();
|
|
129
|
+
}
|
|
130
|
+
/** Waits for a host's Promise, racing the run's cancel and time limit. */
|
|
131
|
+
wait(pending) {
|
|
132
|
+
this.checkCancel();
|
|
133
|
+
if (this.now() > this.deadline) throw limitHit(this.limits);
|
|
134
|
+
return Promise.race([pending, this.aborted()]);
|
|
135
|
+
}
|
|
136
|
+
/** Yields to the event loop (a `yieldMillis` slice is over), racing cancel and the time limit. */
|
|
137
|
+
pause() {
|
|
138
|
+
this.nextYield = this.now() + (this.cancel.yieldMillis ?? 0);
|
|
139
|
+
return this.wait(new Promise((resolve) => setTimeout(resolve, 0)));
|
|
140
|
+
}
|
|
141
|
+
aborted() {
|
|
142
|
+
if (this.abortPromise) return this.abortPromise;
|
|
143
|
+
let reject = () => void 0;
|
|
144
|
+
const p = new Promise((_, r) => {
|
|
145
|
+
reject = r;
|
|
146
|
+
});
|
|
147
|
+
p.catch(() => void 0);
|
|
148
|
+
const timer = setTimeout(() => reject(limitHit(this.limits)), Math.max(0, this.deadline - this.now()));
|
|
149
|
+
timer.unref?.();
|
|
150
|
+
const signal = this.cancel.signal;
|
|
151
|
+
const onAbort = () => reject(cancelled());
|
|
152
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
153
|
+
this.release = () => {
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
signal?.removeEventListener("abort", onAbort);
|
|
156
|
+
};
|
|
157
|
+
this.abortPromise = p;
|
|
158
|
+
return p;
|
|
159
|
+
}
|
|
160
|
+
/** Ends the run: stops the abort timer and listener. */
|
|
161
|
+
close() {
|
|
162
|
+
this.release?.();
|
|
163
|
+
this.release = void 0;
|
|
164
|
+
}
|
|
165
|
+
/** Statements executed so far. */
|
|
166
|
+
get executed() {
|
|
167
|
+
return this.steps + (this.interval - this.untilCheck);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Enters a procedure: error 28 (Out of stack space) past the call depth limit, as VBA. An
|
|
171
|
+
* aborted signal is seen here too (reading it is cheap); `isCancelled` waits for the next check.
|
|
172
|
+
*/
|
|
173
|
+
enter() {
|
|
174
|
+
if (this.cancel.signal?.aborted) throw cancelled();
|
|
175
|
+
if (++this.depth > this.limits.maxCallDepth) {
|
|
176
|
+
this.depth--;
|
|
177
|
+
throw new VbaRuntimeError(28);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
leave() {
|
|
181
|
+
this.depth--;
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
// src/exec/outcome.ts
|
|
185
|
+
/** `Stop`: halts the run (there is no debugger to break into). On Error never traps it. */
|
|
186
|
+
var VbaStop = class extends Error {
|
|
187
|
+
name = "VbaStop";
|
|
188
|
+
constructor() {
|
|
189
|
+
super("Stop statement");
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* A procedure of a module with a compile error was reached (VBA compiles a module when it is first
|
|
194
|
+
* used): the run ends with status `compile`. On Error never traps it.
|
|
195
|
+
*/
|
|
196
|
+
var VbaCompileError = class extends Error {
|
|
197
|
+
diagnostic;
|
|
198
|
+
name = "VbaCompileError";
|
|
199
|
+
constructor(diagnostic) {
|
|
200
|
+
super(diagnostic.message);
|
|
201
|
+
this.diagnostic = diagnostic;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
/** False for what `On Error` must let through: `End`, limits, cancel, `Stop`, compile errors. */
|
|
205
|
+
const isTrappable = (e) => !(e instanceof VbaAbort) && !(e instanceof VbaStop) && !(e instanceof VbaCompileError);
|
|
206
|
+
/** The result of a run that returned (`value` is a Function's result, if any). */
|
|
207
|
+
function completed(value, steps) {
|
|
208
|
+
return {
|
|
209
|
+
status: "completed",
|
|
210
|
+
ok: true,
|
|
211
|
+
...value !== void 0 ? { value } : {},
|
|
212
|
+
steps
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/** The result of a run that ended by throwing `e`. */
|
|
216
|
+
function outcomeOf(e, facts) {
|
|
217
|
+
const steps = facts.steps;
|
|
218
|
+
if (e instanceof VbaStop) return {
|
|
219
|
+
status: "stop",
|
|
220
|
+
ok: true,
|
|
221
|
+
steps
|
|
222
|
+
};
|
|
223
|
+
if (e instanceof VbaCompileError) return {
|
|
224
|
+
...compileFailure(e.diagnostic),
|
|
225
|
+
steps
|
|
226
|
+
};
|
|
227
|
+
const err = e instanceof VbaAbort ? e : toVbaError(e);
|
|
228
|
+
if (err instanceof VbaAbort) switch (err.reason) {
|
|
229
|
+
case "end": return {
|
|
230
|
+
status: "end",
|
|
231
|
+
ok: true,
|
|
232
|
+
steps
|
|
233
|
+
};
|
|
234
|
+
case "limit":
|
|
235
|
+
case "cancel": return {
|
|
236
|
+
status: err.reason,
|
|
237
|
+
ok: false,
|
|
238
|
+
message: err.message,
|
|
239
|
+
steps
|
|
240
|
+
};
|
|
241
|
+
default: return runtimeFailure(new VbaRuntimeError(51, err.message), facts);
|
|
242
|
+
}
|
|
243
|
+
return runtimeFailure(err, facts);
|
|
244
|
+
}
|
|
245
|
+
function runtimeFailure(err, facts) {
|
|
246
|
+
const stack = (facts.stack ?? []).slice(0, 64);
|
|
247
|
+
const at = stack[0];
|
|
248
|
+
return {
|
|
249
|
+
status: "runtime",
|
|
250
|
+
ok: false,
|
|
251
|
+
error: {
|
|
252
|
+
number: err.number,
|
|
253
|
+
description: err.description,
|
|
254
|
+
source: err.source || facts.projectName,
|
|
255
|
+
...at ? {
|
|
256
|
+
module: at.module,
|
|
257
|
+
procedure: at.procedure,
|
|
258
|
+
line: at.line,
|
|
259
|
+
column: at.column
|
|
260
|
+
} : {},
|
|
261
|
+
stack
|
|
262
|
+
},
|
|
263
|
+
steps: facts.steps
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/** The result of running a procedure that cannot run because of a compile error. */
|
|
267
|
+
function compileFailure(d) {
|
|
268
|
+
return {
|
|
269
|
+
status: "compile",
|
|
270
|
+
ok: false,
|
|
271
|
+
error: {
|
|
272
|
+
number: 0,
|
|
273
|
+
description: `Compile error: ${d.message}`,
|
|
274
|
+
module: d.module,
|
|
275
|
+
line: d.span.start.line,
|
|
276
|
+
column: d.span.start.column,
|
|
277
|
+
stack: []
|
|
278
|
+
},
|
|
279
|
+
steps: 0
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
/** A failure before anything ran (an unknown procedure, a disposed program). */
|
|
283
|
+
function notRun(number, description) {
|
|
284
|
+
return {
|
|
285
|
+
status: "runtime",
|
|
286
|
+
ok: false,
|
|
287
|
+
error: {
|
|
288
|
+
number,
|
|
289
|
+
description,
|
|
290
|
+
stack: []
|
|
291
|
+
},
|
|
292
|
+
steps: 0
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
/** The Error a host receives when its call into a program object fails outside a run. */
|
|
296
|
+
var VbaCallbackFailure = class extends Error {
|
|
297
|
+
result;
|
|
298
|
+
name = "VbaCallbackFailure";
|
|
299
|
+
constructor(result) {
|
|
300
|
+
super(result.error?.description ?? result.message ?? result.status);
|
|
301
|
+
this.result = result;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
export { completed as a, outcomeOf as c, CompileGate as d, DEFAULT_EXEC_LIMITS as f, compileFailure as i, LimitGuard as l, VbaCompileError as n, isTrappable as o, refsOf as p, VbaStop as r, notRun as s, VbaCallbackFailure as t, normalizeDocumentObjects as u };
|
|
305
|
+
|
|
306
|
+
//# sourceMappingURL=exec-DYWJe-eU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exec-DYWJe-eU.js","names":[],"sources":["../src/exec/contract.ts","../src/exec/compile-gate.ts","../src/exec/host-scope.ts","../src/exec/limit-guard.ts","../src/exec/outcome.ts"],"sourcesContent":["// The executor contract: what a host (ooxml-core's VBA area, a Worker, a test) codes against, and\n// what both VBA executors implement. The tree-walking interpreter (`createInterpreter`,\n// `vba-interpreter/interp`) and the VBA-to-JavaScript compiler (`compileProgram`, private\n// `vba-to-js`) are both a `CompileVba`; they share the `lang` AST, the `runtime` values and host\n// object protocol, and the conformance corpus (`src/conformance/`). This file holds the types,\n// the default limits and two small helpers.\nimport type { ModuleKind, ProcedureInfo, VbaDiagnostic } from '../lang/index';\nimport type {\n\tDebugSink,\n\tRef,\n\tValue,\n\tVbaLimits,\n\tVbaLocale,\n\tVbaObject,\n\tVbaUi,\n} from '../runtime/index';\nimport { DEFAULT_LIMITS } from '../runtime/limits';\n\n/** One module of a project, as source text (a decompressed module stream or an exported file). */\nexport interface VbaSourceModule {\n\t/** The module name (`Module1`, `ThisWorkbook`, `Class1`); `VB_Name` in the source is ignored. */\n\treadonly name: string;\n\t/** Standard, class or document module (form modules run as class code). */\n\treadonly kind: ModuleKind;\n\t/** The module's source text, with or without its `Attribute` lines. */\n\treadonly source: string;\n}\n\n/**\n * The session a run uses: everything outside the program that VBA's library reads. Missing fields\n * take safe defaults: no UI (MsgBox and InputBox raise error 445), Debug.Print discarded, en-US,\n * the real clock, no environment variables, project name \"VBAProject\".\n */\nexport interface VbaSessionOptions {\n\t/** Shows `MsgBox` and `InputBox`; without it both raise error 445. */\n\treadonly ui: VbaUi;\n\t/** Receives `Debug.Print` lines and failed `Debug.Assert`s. */\n\treadonly debug: DebugSink;\n\t/** Regional settings for conversions, `Format`, dates and `Option Compare Text`. */\n\treadonly locale: VbaLocale;\n\t/** The current instant, read by `Now`, `Date`, `Time` and `Timer`. */\n\treadonly clock: () => Date;\n\t/** Answers `Environ(name)`; undefined reads as an empty string. */\n\treadonly environ: (name: string) => string | undefined;\n\t/** The project name, the default `Err.Source`. */\n\treadonly projectName: string;\n}\n\n/**\n * Execution bounds on top of the runtime's allocation limits. Every run (and every host callback,\n * see `VbaProgram`) gets the whole budget. `maxCallDepth` (error 28 beyond it) defaults to 1000\n * here, under the runtime's 2000: an interpreter frame takes several JavaScript frames, and Node's\n * default stack holds about 900 of them. An executor also reports a JavaScript stack overflow as\n * error 28, so a deep recursion on a small stack ends the same way, only earlier.\n */\nexport interface VbaExecLimits extends VbaLimits {\n\t/** Most statements (and loop iterations) one run may execute. */\n\treadonly maxSteps: number;\n\t/**\n\t * Wall-clock budget of one run, in milliseconds. Checked every few milliseconds and after\n\t * every big runtime operation, so a run overshoots it by about one operation at most.\n\t */\n\treadonly maxMillis: number;\n}\n\n/** The default limits: the runtime's `DEFAULT_LIMITS`, 50 million steps and 30 seconds. */\nexport const DEFAULT_EXEC_LIMITS: VbaExecLimits = Object.freeze({\n\t...DEFAULT_LIMITS,\n\tmaxCallDepth: 1_000,\n\tmaxSteps: 50_000_000,\n\tmaxMillis: 30_000,\n});\n\n/** Everything a `CompileVba` needs: the source, the host's objects, the session and limits. */\nexport interface VbaProgramOptions {\n\t/** The project's modules, as source text. */\n\treadonly modules: readonly VbaSourceModule[];\n\t/** Host objects by name (`Application`, `ThisWorkbook`, `Sheet1`): readable from every module. */\n\treadonly globals?: Readonly<Record<string, VbaObject>>;\n\t/**\n\t * An object whose members resolve as unqualified names (Excel's `Range(\"A1\")`, `Cells`,\n\t * `ActiveSheet`). Names declared in the project or VBA's library come first; an undeclared name\n\t * is looked up on this object at run time (error 438 there means an undeclared variable).\n\t */\n\treadonly globalObject?: VbaObject;\n\t/**\n\t * Document module name -> the host object it extends (`ThisWorkbook` -> the Workbook). In that\n\t * module `Me` is the host object and its members resolve as unqualified names before the\n\t * `globalObject`'s, and its public procedures are reachable as `ThisWorkbook.Foo`.\n\t */\n\treadonly documentObjects?: Readonly<Record<string, VbaObject>>;\n\t/** The UI, debug sink, locale, clock and environment; missing fields take safe defaults. */\n\treadonly session?: Partial<VbaSessionOptions>;\n\t/** Overrides of `DEFAULT_EXEC_LIMITS`. */\n\treadonly limits?: Partial<VbaExecLimits>;\n\t/** `#Const` values for conditional compilation, merged over the lang defaults. */\n\treadonly constants?: Readonly<Record<string, number | string | boolean>>;\n\t/**\n\t * Cancels every run of the program: a running macro stops with status `cancel`. A loop that\n\t * never waits on its host sees the signal only when it yields (`yieldMillis`); use\n\t * `isCancelled` to stop it at once from another thread.\n\t */\n\treadonly signal?: AbortSignal;\n\t/**\n\t * Read synchronously every few milliseconds while a run computes: return true to cancel it.\n\t * For a host whose controller is on another thread (`() => Atomics.load(flags, 0) !== 0`).\n\t * The hard stop for a runaway macro is still the host's `Worker.terminate()`.\n\t */\n\treadonly isCancelled?: () => boolean;\n\t/**\n\t * A run that computes this long without waiting yields to the event loop once (so timers,\n\t * messages and an AbortSignal of the same thread are seen). 0 never yields. Default 100.\n\t */\n\treadonly yieldMillis?: number;\n}\n\n/**\n * A compile error or warning, with the module it was found in. `code` is a parser code\n * (`VbaDiagnostic['code']`) or a binder code (`SemanticDiagnosticCode` of vba-interpreter/semantic).\n */\nexport interface VbaProgramDiagnostic extends Omit<VbaDiagnostic, 'code'> {\n\t/** The parser or binder code, for example `variable-not-defined`. */\n\treadonly code: string;\n\t/** The name of the module the diagnostic was found in. */\n\treadonly module: string;\n}\n\n/** A procedure of the project, as the Macros dialog and `run` see it. */\nexport interface VbaProcedure extends ProcedureInfo {\n\t/** The name of the module that declares the procedure. */\n\treadonly module: string;\n\t/** The kind of that module. */\n\treadonly moduleKind: ModuleKind;\n\t/**\n\t * False when the procedure's module, or a module whose procedures it calls, has compile\n\t * errors: running it gives status `compile` (VBA compiles a module when it is first used).\n\t */\n\treadonly canRun: boolean;\n}\n\n/** One procedure an error passed through, innermost first. */\nexport interface VbaStackFrame {\n\t/** The module of the procedure. */\n\treadonly module: string;\n\t/** The procedure's name. */\n\treadonly procedure: string;\n\t/** 1-based source line and column of the statement running in that procedure. */\n\treadonly line: number;\n\t/** 1-based source column of that statement. */\n\treadonly column: number;\n}\n\n/** An error that ended a run: a compile error or an unhandled run-time error. */\nexport interface VbaRunError {\n\t/** The VBA error number (`Err.Number`); 0 for a compile error, which has none. */\n\treadonly number: number;\n\t/** `Err.Description`, or the compile error's message. */\n\treadonly description: string;\n\t/** `Err.Source`. */\n\treadonly source?: string;\n\t/** Where the error was raised (the innermost entry of `stack`), when known. */\n\treadonly module?: string;\n\t/** The procedure where the error was raised, when known. */\n\treadonly procedure?: string;\n\t/** The 1-based source line where the error was raised, when known. */\n\treadonly line?: number;\n\t/** The 1-based source column where the error was raised, when known. */\n\treadonly column?: number;\n\t/** The procedures the error left, innermost first, at most 64 (empty for a compile error). */\n\treadonly stack?: readonly VbaStackFrame[];\n}\n\n/**\n * How a run ended:\n * - `completed`: the procedure returned;\n * - `end`: an `End` statement (every module variable is reset);\n * - `stop`: a `Stop` statement (there is no debugger, so the run halts);\n * - `compile`: the procedure cannot run because of a compile error (`error`);\n * - `runtime`: an unhandled run-time error (`error`), including error 28 at the call depth limit;\n * - `limit`: the step or time budget ran out (`message`);\n * - `cancel`: the signal or `isCancelled` stopped it (`message`).\n */\nexport type VbaRunStatus =\n\t| 'completed'\n\t| 'end'\n\t| 'stop'\n\t| 'compile'\n\t| 'runtime'\n\t| 'limit'\n\t| 'cancel';\n\n/** How a `run`, `fireEvent` or host callback ended. */\nexport interface VbaRunResult {\n\t/** How the run ended. */\n\treadonly status: VbaRunStatus;\n\t/** True for `completed`, `end` and `stop`. */\n\treadonly ok: boolean;\n\t/** A Function's or Property Get's result (`completed` only; absent for a Sub). */\n\treadonly value?: Value;\n\t/** For `compile` and `runtime`. */\n\treadonly error?: VbaRunError;\n\t/** For `limit` and `cancel`: what ran out or who cancelled. */\n\treadonly message?: string;\n\t/** Statements executed, for diagnostics and benchmarks. */\n\treadonly steps?: number;\n}\n\n/**\n * What a host receives when it calls a member of an object the program made (a class instance it\n * kept, a WithEvents handler it fired) outside a run and the call fails: an Error whose `result`\n * says how. Inside a run, the program's own errors reach the host as `VbaRuntimeError`s.\n */\nexport interface VbaCallbackError extends Error {\n\t/** How the failed callback ended. */\n\treadonly result: VbaRunResult;\n}\n\n/**\n * A compiled VBA project, ready to run its procedures and event handlers. Module variables live\n * as long as the program, so successive runs share them. Not here yet: an Immediate-window\n * `evaluate`/`execute` of a statement typed against the running project (it needs a binder for\n * one statement in a chosen scope); hosts run a generated module instead.\n */\nexport interface VbaProgram {\n\t/** Compile errors in VBA's wording. A module with errors (or that uses one) cannot run. */\n\treadonly diagnostics: readonly VbaProgramDiagnostic[];\n\t/** True while a run or a host callback is in progress. */\n\treadonly isRunning: boolean;\n\t/** Every procedure of every module; filter on `isMacro` for the Macros dialog. */\n\tprocedures(): VbaProcedure[];\n\t/**\n\t * Runs a procedure: `Module1.Foo` or an unambiguous `Foo` (`Sheet1.Foo` for a document\n\t * module). Arguments are passed ByVal. Module variables keep their values between runs, as in\n\t * VBA, until `End`, `reset` or `dispose`.\n\t *\n\t * Runs, events and host callbacks are serialised: one waits for the one in progress. A call\n\t * made while a run computes (synchronously, from a host member the macro called, as\n\t * `Application.Run` or an event the host raises at once) runs inside that run instead.\n\t *\n\t * Objects the program made (class instances, WithEvents handlers) can be called by the host\n\t * at any time through the host object protocol, under the same rule: inside the computing\n\t * run, else as a run of its own with the same limits, cancel and queue, whose failure reaches\n\t * the host as a `VbaCallbackError`. While a run waits on its host (a member returned a\n\t * Promise), every call into the program queues behind it: a host member that must call back\n\t * into the program does so before it returns its Promise, or does not wait for the callback.\n\t */\n\trun(name: string, args?: readonly Value[]): Promise<VbaRunResult>;\n\t/**\n\t * Runs a document module's event handler: `fireEvent('ThisWorkbook', 'Open', [])` runs\n\t * `Workbook_Open` (the prefix is the host object's `typeName()`). `args` are references, so a\n\t * handler can set `Cancel = True` (`refsOf` makes them). A missing handler is not an error.\n\t */\n\tfireEvent(objectName: string, event: string, args: readonly Ref[]): Promise<VbaRunResult>;\n\t/**\n\t * The VBE's Reset: module variables and Static locals back to their initial values, default\n\t * instances dropped, WithEvents disconnected. Waits for the run in progress.\n\t */\n\treset(): Promise<void>;\n\t/** Resets and disconnects everything. Later calls fail with error 51. */\n\tdispose(): void;\n}\n\n/** Builds a runnable program from source modules (the interpreter's `createInterpreter`). */\nexport type CompileVba = (options: VbaProgramOptions) => VbaProgram;\n\n/** References for `fireEvent`: read `refs[i].get()` after the handler to see what it set. */\nexport function refsOf(values: readonly Value[]): Ref[] {\n\treturn values.map((initial) => {\n\t\tlet value = initial;\n\t\treturn {\n\t\t\tget: () => value,\n\t\t\tset: (v: Value) => {\n\t\t\t\tvalue = v;\n\t\t\t},\n\t\t};\n\t});\n}\n","// Which procedures can run: VBA compiles a module when one of its procedures is first used, so a\n// compile error blocks the procedures of its module and every procedure that calls into it, and\n// nothing else.\nimport type { VbaProgramDiagnostic } from './contract';\nimport type { BoundModule, BoundProcedure, BoundProgram } from '../semantic/index';\n\nexport class CompileGate {\n\tprivate readonly broken = new Map<BoundModule, VbaProgramDiagnostic>();\n\tprivate readonly verdicts = new Map<BoundProcedure, VbaProgramDiagnostic | null>();\n\n\tconstructor(program: BoundProgram, diagnostics: readonly VbaProgramDiagnostic[]) {\n\t\tfor (const d of diagnostics) {\n\t\t\tif (d.severity !== 'error') continue;\n\t\t\tconst m = program.module(d.module);\n\t\t\tif (m && !this.broken.has(m)) this.broken.set(m, d);\n\t\t}\n\t}\n\n\t/** The first compile error of the module, if any (raised when the module is used). */\n\tmoduleError(m: BoundModule): VbaProgramDiagnostic | null {\n\t\treturn this.broken.get(m) ?? null;\n\t}\n\n\t/** The compile error that keeps `p` from running: its module's, or a callee's module's. */\n\tblocking(p: BoundProcedure): VbaProgramDiagnostic | null {\n\t\tif (this.broken.size === 0) return null;\n\t\tconst known = this.verdicts.get(p);\n\t\tif (known !== undefined) return known;\n\t\tconst seen = new Set<BoundProcedure>();\n\t\tconst stack = [p];\n\t\tlet found: VbaProgramDiagnostic | null = null;\n\t\twhile (stack.length > 0 && !found) {\n\t\t\tconst q = stack.pop() as BoundProcedure;\n\t\t\tif (seen.has(q)) continue;\n\t\t\tseen.add(q);\n\t\t\tfound = this.broken.get(q.module) ?? null;\n\t\t\tfor (const c of q.facts.callees) stack.push(c);\n\t\t}\n\t\tthis.verdicts.set(p, found);\n\t\treturn found;\n\t}\n}\n","// The host objects of `VbaProgramOptions` as executors look them up: by lower-case name (VBA names\n// are case-insensitive), own entries only.\nimport type { VbaObject } from '../runtime/index';\n\n/** `options.globals` / `options.documentObjects` keyed by lower-cased name. */\nexport function normalizeDocumentObjects(\n\tr: Readonly<Record<string, VbaObject>> | undefined,\n): ReadonlyMap<string, VbaObject> {\n\tconst out = new Map<string, VbaObject>();\n\tif (r) for (const k of Object.keys(r)) out.set(k.toLowerCase(), r[k] as VbaObject);\n\treturn out;\n}\n","// Execution bounds of one run: statements executed, wall-clock time, call depth and cancellation.\n// The hot path is one decrement per statement. The clock, the signal and the host's cancel\n// callback are read at a check, whose interval adapts to time: checks come about every\n// CHECK_TARGET_MS whatever a statement costs, and a big runtime operation (reported through the\n// environment's `WorkMeter`) forces a check after it. A run that has computed for `yieldMillis`\n// without waiting yields to the event loop, so a signal aborted by the same thread is seen.\nimport type { VbaExecLimits } from './contract';\nimport { VbaAbort, VbaRuntimeError, type WorkMeter } from '../runtime/index';\n\nconst MAX_INTERVAL = 2048;\nconst MIN_INTERVAL = 16;\nconst CHECK_TARGET_MS = 4;\n\n/** How a run is cancelled from outside: an AbortSignal, and a callback read synchronously. */\nexport interface CancelSources {\n\treadonly signal?: AbortSignal | undefined;\n\t/** Read at every check: lets a host stop a loop that never waits (an `Atomics.load`). */\n\treadonly isCancelled?: (() => boolean) | undefined;\n\t/** Yield to the event loop after this much uninterrupted computing (0: never). */\n\treadonly yieldMillis?: number | undefined;\n}\n\nconst limitHit = (limits: VbaExecLimits) =>\n\tnew VbaAbort('limit', `Time limit exceeded (${limits.maxMillis} ms)`);\nconst cancelled = () => new VbaAbort('cancel', 'The run was cancelled');\n\n/**\n * Enforces one run's step, time and call depth limits and its cancel sources. An executor creates\n * one per run, calls it at every statement and procedure entry, and passes it to the runtime as\n * the environment's work meter.\n */\nexport class LimitGuard implements WorkMeter {\n\tdepth = 0;\n\tprivate steps = 0;\n\tprivate interval = MAX_INTERVAL;\n\tprivate untilCheck = MAX_INTERVAL;\n\tprivate lastCheck: number;\n\tprivate nextYield: number;\n\tprivate readonly deadline: number;\n\t/**\n\t * Rejects when the run is cancelled or out of time; every wait on a host races it, so a host\n\t * that never answers cannot hang the run. One per run, made on the first wait.\n\t */\n\tprivate abortPromise: Promise<never> | undefined;\n\tprivate release: (() => void) | undefined;\n\n\tconstructor(\n\t\treadonly limits: VbaExecLimits,\n\t\tprivate readonly cancel: CancelSources = {},\n\t\tprivate readonly now: () => number = Date.now,\n\t) {\n\t\tconst start = now();\n\t\tthis.lastCheck = start;\n\t\tthis.deadline = start + limits.maxMillis;\n\t\tthis.nextYield = cancel.yieldMillis ? start + cancel.yieldMillis : Infinity;\n\t}\n\n\t/**\n\t * Counts one statement. True when the run should yield to the event loop before the next\n\t * statement (only ever at a check).\n\t */\n\tstep(): boolean {\n\t\tif (--this.untilCheck > 0) return false;\n\t\treturn this.check();\n\t}\n\n\t/** A big operation's work: the next statement checks the clock. */\n\tcharge(_work: number): void {\n\t\tthis.steps += this.interval - this.untilCheck;\n\t\tthis.interval = this.untilCheck = 1;\n\t}\n\n\tprivate check(): boolean {\n\t\tthis.steps += this.interval - this.untilCheck;\n\t\tif (this.steps > this.limits.maxSteps)\n\t\t\tthrow new VbaAbort('limit', `Step limit exceeded (${this.limits.maxSteps} statements)`);\n\t\tconst t = this.now();\n\t\tif (t > this.deadline) throw limitHit(this.limits);\n\t\tthis.checkCancel();\n\t\tconst elapsed = t - this.lastCheck;\n\t\tthis.lastCheck = t;\n\t\tif (elapsed > CHECK_TARGET_MS) this.interval = Math.max(MIN_INTERVAL, this.interval >> 1);\n\t\telse if (elapsed < CHECK_TARGET_MS / 4)\n\t\t\tthis.interval = Math.min(MAX_INTERVAL, this.interval * 2);\n\t\tthis.untilCheck = this.interval;\n\t\treturn t >= this.nextYield;\n\t}\n\n\t/** Raises the cancel abort when the signal or the host's callback says so. */\n\tcheckCancel(): void {\n\t\tif (this.cancel.signal?.aborted || this.cancel.isCancelled?.()) throw cancelled();\n\t}\n\n\t/** Waits for a host's Promise, racing the run's cancel and time limit. */\n\twait<T>(pending: Promise<T>): Promise<T> {\n\t\tthis.checkCancel();\n\t\tif (this.now() > this.deadline) throw limitHit(this.limits);\n\t\treturn Promise.race([pending, this.aborted()]);\n\t}\n\n\t/** Yields to the event loop (a `yieldMillis` slice is over), racing cancel and the time limit. */\n\tpause(): Promise<void> {\n\t\tthis.nextYield = this.now() + (this.cancel.yieldMillis ?? 0);\n\t\treturn this.wait(new Promise<void>((resolve) => setTimeout(resolve, 0)));\n\t}\n\n\tprivate aborted(): Promise<never> {\n\t\tif (this.abortPromise) return this.abortPromise;\n\t\tlet reject: (e: VbaAbort) => void = () => undefined;\n\t\tconst p = new Promise<never>((_, r) => {\n\t\t\treject = r;\n\t\t});\n\t\tp.catch(() => undefined);\n\t\tconst timer = setTimeout(\n\t\t\t() => reject(limitHit(this.limits)),\n\t\t\tMath.max(0, this.deadline - this.now()),\n\t\t);\n\t\t(timer as { unref?: () => void }).unref?.();\n\t\tconst signal = this.cancel.signal;\n\t\tconst onAbort = () => reject(cancelled());\n\t\tsignal?.addEventListener('abort', onAbort, { once: true });\n\t\tthis.release = () => {\n\t\t\tclearTimeout(timer);\n\t\t\tsignal?.removeEventListener('abort', onAbort);\n\t\t};\n\t\tthis.abortPromise = p;\n\t\treturn p;\n\t}\n\n\t/** Ends the run: stops the abort timer and listener. */\n\tclose(): void {\n\t\tthis.release?.();\n\t\tthis.release = undefined;\n\t}\n\n\t/** Statements executed so far. */\n\tget executed(): number {\n\t\treturn this.steps + (this.interval - this.untilCheck);\n\t}\n\n\t/**\n\t * Enters a procedure: error 28 (Out of stack space) past the call depth limit, as VBA. An\n\t * aborted signal is seen here too (reading it is cheap); `isCancelled` waits for the next check.\n\t */\n\tenter(): void {\n\t\tif (this.cancel.signal?.aborted) throw cancelled();\n\t\tif (++this.depth > this.limits.maxCallDepth) {\n\t\t\tthis.depth--;\n\t\t\tthrow new VbaRuntimeError(28);\n\t\t}\n\t}\n\n\tleave(): void {\n\t\tthis.depth--;\n\t}\n}\n","// How a run's ending becomes a `VbaRunResult`, shared by every executor so they report the same\n// status, error and step count for the same ending.\nimport { VbaAbort, VbaRuntimeError, toVbaError, type Value } from '../runtime/index';\nimport type { VbaProgramDiagnostic, VbaRunError, VbaRunResult, VbaStackFrame } from './contract';\n\n/** `Stop`: halts the run (there is no debugger to break into). On Error never traps it. */\nexport class VbaStop extends Error {\n\toverride readonly name = 'VbaStop';\n\tconstructor() {\n\t\tsuper('Stop statement');\n\t}\n}\n\n/**\n * A procedure of a module with a compile error was reached (VBA compiles a module when it is first\n * used): the run ends with status `compile`. On Error never traps it.\n */\nexport class VbaCompileError extends Error {\n\toverride readonly name = 'VbaCompileError';\n\tconstructor(readonly diagnostic: VbaProgramDiagnostic) {\n\t\tsuper(diagnostic.message);\n\t}\n}\n\n/** False for what `On Error` must let through: `End`, limits, cancel, `Stop`, compile errors. */\nexport const isTrappable = (e: unknown): boolean =>\n\t!(e instanceof VbaAbort) && !(e instanceof VbaStop) && !(e instanceof VbaCompileError);\n\n/** What the executor knows about the run that ended. */\nexport interface RunFacts {\n\t/** Statements executed (the `LimitGuard`'s count). */\n\treadonly steps: number;\n\t/** `Err.Source` when the error has none. */\n\treadonly projectName: string;\n\t/** The procedures the error left, innermost first. */\n\treadonly stack?: readonly VbaStackFrame[] | undefined;\n}\n\n/** The result of a run that returned (`value` is a Function's result, if any). */\nexport function completed(value: Value | undefined, steps: number): VbaRunResult {\n\treturn { status: 'completed', ok: true, ...(value !== undefined ? { value } : {}), steps };\n}\n\n/** The result of a run that ended by throwing `e`. */\nexport function outcomeOf(e: unknown, facts: RunFacts): VbaRunResult {\n\tconst steps = facts.steps;\n\tif (e instanceof VbaStop) return { status: 'stop', ok: true, steps };\n\tif (e instanceof VbaCompileError) return { ...compileFailure(e.diagnostic), steps };\n\tconst err = e instanceof VbaAbort ? e : toVbaError(e);\n\tif (err instanceof VbaAbort) {\n\t\tswitch (err.reason) {\n\t\t\tcase 'end':\n\t\t\t\treturn { status: 'end', ok: true, steps };\n\t\t\tcase 'limit':\n\t\t\tcase 'cancel':\n\t\t\t\treturn { status: err.reason, ok: false, message: err.message, steps };\n\t\t\tdefault:\n\t\t\t\t// An executor fault (a Promise where none may be): reported as error 51.\n\t\t\t\treturn runtimeFailure(new VbaRuntimeError(51, err.message), facts);\n\t\t}\n\t}\n\treturn runtimeFailure(err, facts);\n}\n\n/** At most this many procedures are listed in an error's stack (the innermost ones). */\nexport const MAX_STACK_FRAMES = 64;\n\nfunction runtimeFailure(err: VbaRuntimeError, facts: RunFacts): VbaRunResult {\n\tconst stack = (facts.stack ?? []).slice(0, MAX_STACK_FRAMES);\n\tconst at = stack[0];\n\tconst error: VbaRunError = {\n\t\tnumber: err.number,\n\t\tdescription: err.description,\n\t\tsource: err.source || facts.projectName,\n\t\t...(at ? { module: at.module, procedure: at.procedure, line: at.line, column: at.column } : {}),\n\t\tstack,\n\t};\n\treturn { status: 'runtime', ok: false, error, steps: facts.steps };\n}\n\n/** The result of running a procedure that cannot run because of a compile error. */\nexport function compileFailure(d: VbaProgramDiagnostic): VbaRunResult {\n\treturn {\n\t\tstatus: 'compile',\n\t\tok: false,\n\t\terror: {\n\t\t\tnumber: 0,\n\t\t\tdescription: `Compile error: ${d.message}`,\n\t\t\tmodule: d.module,\n\t\t\tline: d.span.start.line,\n\t\t\tcolumn: d.span.start.column,\n\t\t\tstack: [],\n\t\t},\n\t\tsteps: 0,\n\t};\n}\n\n/** A failure before anything ran (an unknown procedure, a disposed program). */\nexport function notRun(number: number, description: string): VbaRunResult {\n\treturn { status: 'runtime', ok: false, error: { number, description, stack: [] }, steps: 0 };\n}\n\n/** The Error a host receives when its call into a program object fails outside a run. */\nexport class VbaCallbackFailure extends Error {\n\toverride readonly name = 'VbaCallbackFailure';\n\tconstructor(readonly result: VbaRunResult) {\n\t\tsuper(result.error?.description ?? result.message ?? result.status);\n\t}\n}\n"],"mappings":";;;AAkEA,MAAa,sBAAqC,OAAO,OAAO;CAC/D,GAAG;CACH,cAAc;CACd,UAAU;CACV,WAAW;AACZ,CAAC;;AAmMD,SAAgB,OAAO,QAAiC;CACvD,OAAO,OAAO,KAAK,YAAY;EAC9B,IAAI,QAAQ;EACZ,OAAO;GACN,WAAW;GACX,MAAM,MAAa;IAClB,QAAQ;GACT;EACD;CACD,CAAC;AACF;;AC9QA,IAAa,cAAb,MAAyB;CACP,yBAAS,IAAI,IAAuC;CACpD,2BAAW,IAAI,IAA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