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,111 @@
|
|
|
1
|
+
import { i as VbaExecLimits, m as VbaStackFrame, s as VbaProgramDiagnostic, u as VbaRunResult } from "./contract-CBGNXslV.js";
|
|
2
|
+
import { u as BoundProgram, w as BoundProcedure, x as BoundModule } from "./index-zKYgEJdV.js";
|
|
3
|
+
import { Qs as WorkMeter, Yo as Value, ys as VbaObject } from "./index-DnrotnmB.js";
|
|
4
|
+
declare class CompileGate {
|
|
5
|
+
private readonly broken;
|
|
6
|
+
private readonly verdicts;
|
|
7
|
+
constructor(program: BoundProgram, diagnostics: readonly VbaProgramDiagnostic[]);
|
|
8
|
+
/** The first compile error of the module, if any (raised when the module is used). */
|
|
9
|
+
moduleError(m: BoundModule): VbaProgramDiagnostic | null;
|
|
10
|
+
/** The compile error that keeps `p` from running: its module's, or a callee's module's. */
|
|
11
|
+
blocking(p: BoundProcedure): VbaProgramDiagnostic | null;
|
|
12
|
+
}
|
|
13
|
+
/** `options.globals` / `options.documentObjects` keyed by lower-cased name. */
|
|
14
|
+
declare function normalizeDocumentObjects(r: Readonly<Record<string, VbaObject>> | undefined): ReadonlyMap<string, VbaObject>;
|
|
15
|
+
/** How a run is cancelled from outside: an AbortSignal, and a callback read synchronously. */
|
|
16
|
+
interface CancelSources {
|
|
17
|
+
readonly signal?: AbortSignal | undefined;
|
|
18
|
+
/** Read at every check: lets a host stop a loop that never waits (an `Atomics.load`). */
|
|
19
|
+
readonly isCancelled?: (() => boolean) | undefined;
|
|
20
|
+
/** Yield to the event loop after this much uninterrupted computing (0: never). */
|
|
21
|
+
readonly yieldMillis?: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Enforces one run's step, time and call depth limits and its cancel sources. An executor creates
|
|
25
|
+
* one per run, calls it at every statement and procedure entry, and passes it to the runtime as
|
|
26
|
+
* the environment's work meter.
|
|
27
|
+
*/
|
|
28
|
+
declare class LimitGuard implements WorkMeter {
|
|
29
|
+
readonly limits: VbaExecLimits;
|
|
30
|
+
private readonly cancel;
|
|
31
|
+
private readonly now;
|
|
32
|
+
depth: number;
|
|
33
|
+
private steps;
|
|
34
|
+
private interval;
|
|
35
|
+
private untilCheck;
|
|
36
|
+
private lastCheck;
|
|
37
|
+
private nextYield;
|
|
38
|
+
private readonly deadline;
|
|
39
|
+
/**
|
|
40
|
+
* Rejects when the run is cancelled or out of time; every wait on a host races it, so a host
|
|
41
|
+
* that never answers cannot hang the run. One per run, made on the first wait.
|
|
42
|
+
*/
|
|
43
|
+
private abortPromise;
|
|
44
|
+
private release;
|
|
45
|
+
constructor(limits: VbaExecLimits, cancel?: CancelSources, now?: () => number);
|
|
46
|
+
/**
|
|
47
|
+
* Counts one statement. True when the run should yield to the event loop before the next
|
|
48
|
+
* statement (only ever at a check).
|
|
49
|
+
*/
|
|
50
|
+
step(): boolean;
|
|
51
|
+
/** A big operation's work: the next statement checks the clock. */
|
|
52
|
+
charge(_work: number): void;
|
|
53
|
+
private check;
|
|
54
|
+
/** Raises the cancel abort when the signal or the host's callback says so. */
|
|
55
|
+
checkCancel(): void;
|
|
56
|
+
/** Waits for a host's Promise, racing the run's cancel and time limit. */
|
|
57
|
+
wait<T>(pending: Promise<T>): Promise<T>;
|
|
58
|
+
/** Yields to the event loop (a `yieldMillis` slice is over), racing cancel and the time limit. */
|
|
59
|
+
pause(): Promise<void>;
|
|
60
|
+
private aborted;
|
|
61
|
+
/** Ends the run: stops the abort timer and listener. */
|
|
62
|
+
close(): void;
|
|
63
|
+
/** Statements executed so far. */
|
|
64
|
+
get executed(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Enters a procedure: error 28 (Out of stack space) past the call depth limit, as VBA. An
|
|
67
|
+
* aborted signal is seen here too (reading it is cheap); `isCancelled` waits for the next check.
|
|
68
|
+
*/
|
|
69
|
+
enter(): void;
|
|
70
|
+
leave(): void;
|
|
71
|
+
}
|
|
72
|
+
/** `Stop`: halts the run (there is no debugger to break into). On Error never traps it. */
|
|
73
|
+
declare class VbaStop extends Error {
|
|
74
|
+
readonly name = "VbaStop";
|
|
75
|
+
constructor();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A procedure of a module with a compile error was reached (VBA compiles a module when it is first
|
|
79
|
+
* used): the run ends with status `compile`. On Error never traps it.
|
|
80
|
+
*/
|
|
81
|
+
declare class VbaCompileError extends Error {
|
|
82
|
+
readonly diagnostic: VbaProgramDiagnostic;
|
|
83
|
+
readonly name = "VbaCompileError";
|
|
84
|
+
constructor(diagnostic: VbaProgramDiagnostic);
|
|
85
|
+
}
|
|
86
|
+
/** False for what `On Error` must let through: `End`, limits, cancel, `Stop`, compile errors. */
|
|
87
|
+
declare const isTrappable: (e: unknown) => boolean;
|
|
88
|
+
/** What the executor knows about the run that ended. */
|
|
89
|
+
interface RunFacts {
|
|
90
|
+
/** Statements executed (the `LimitGuard`'s count). */
|
|
91
|
+
readonly steps: number;
|
|
92
|
+
/** `Err.Source` when the error has none. */
|
|
93
|
+
readonly projectName: string;
|
|
94
|
+
/** The procedures the error left, innermost first. */
|
|
95
|
+
readonly stack?: readonly VbaStackFrame[] | undefined;
|
|
96
|
+
}
|
|
97
|
+
/** The result of a run that returned (`value` is a Function's result, if any). */
|
|
98
|
+
declare function completed(value: Value | undefined, steps: number): VbaRunResult;
|
|
99
|
+
/** The result of a run that ended by throwing `e`. */
|
|
100
|
+
declare function outcomeOf(e: unknown, facts: RunFacts): VbaRunResult;
|
|
101
|
+
/** The result of running a procedure that cannot run because of a compile error. */
|
|
102
|
+
declare function compileFailure(d: VbaProgramDiagnostic): VbaRunResult;
|
|
103
|
+
/** A failure before anything ran (an unknown procedure, a disposed program). */
|
|
104
|
+
declare function notRun(number: number, description: string): VbaRunResult;
|
|
105
|
+
/** The Error a host receives when its call into a program object fails outside a run. */
|
|
106
|
+
declare class VbaCallbackFailure extends Error {
|
|
107
|
+
readonly result: VbaRunResult;
|
|
108
|
+
readonly name = "VbaCallbackFailure";
|
|
109
|
+
constructor(result: VbaRunResult);
|
|
110
|
+
}
|
|
111
|
+
export { compileFailure as a, notRun as c, LimitGuard as d, normalizeDocumentObjects as f, VbaStop as i, outcomeOf as l, VbaCallbackFailure as n, completed as o, CompileGate as p, VbaCompileError as r, isTrappable as s, RunFacts as t, CancelSources as u };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { c as VbaProgramOptions, o as VbaProgram } from "./contract-CBGNXslV.js";
|
|
2
|
+
/** The tree-walking interpreter: binds `options.modules` and returns the runnable program. */
|
|
3
|
+
declare function createInterpreter(options: VbaProgramOptions): VbaProgram;
|
|
4
|
+
export { createInterpreter as t };
|