@mark1russell7/vex-compiler 0.0.0-stage → 0.7.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 +21 -0
- package/README.md +73 -2
- package/build/index.d.ts +297 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3315 -0
- package/build/index.js.map +1 -0
- package/package.json +60 -3
- package/src/facts.ts +182 -0
- package/src/index.ts +8 -0
- package/src/js.ts +324 -0
- package/src/loop.ts +138 -0
- package/src/lower.ts +662 -0
- package/src/memo.ts +223 -0
- package/src/module.ts +1437 -0
- package/src/runtime.ts +332 -0
- package/src/tiers.ts +102 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Mark Russell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,74 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @mark1russell7/vex-compiler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@mark1russell7/vex-compiler) [](https://github.com/mark1russell7/vex/blob/main/LICENSE)
|
|
4
|
+
|
|
5
|
+
The compiler of [Vex](https://mark1russell7.github.io/vex/), the typed spreadsheet formulas over TypeScript objects. It turns a Vex program into JavaScript source, and the result of each run is the result of the interpreter.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @mark1russell7/vex @mark1russell7/vex-compiler
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
The distance from each box to the nearest other box. `tiered` gives a program with the interface of `compile`.
|
|
16
|
+
|
|
17
|
+
```ts doctest
|
|
18
|
+
import { space, vex } from "@mark1russell7/vex";
|
|
19
|
+
import { tiered } from "@mark1russell7/vex-compiler";
|
|
20
|
+
import { Vec2, Vec2Domain } from "@mark1russell7/vex-domains";
|
|
21
|
+
|
|
22
|
+
const root = vex(Vec2Domain).over(space.record({ A: { position: new Vec2(0, 0) }, B: { position: new Vec2(3, 4) } }));
|
|
23
|
+
const nearest = root.from("position").others((e) => e._.subtract("position")._.length()).min();
|
|
24
|
+
const program = tiered(nearest.program, { domains: [Vec2Domain] });
|
|
25
|
+
program.tier; // => 2
|
|
26
|
+
program.run({ space: root.space, origin: "A" }); // => { ok: true, value: 5 }
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## The tiers
|
|
30
|
+
|
|
31
|
+
| Tier | What | When |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| 1 | The closure compiler of the core (`compile`) | The fallback, each trace, and each page without `new Function` |
|
|
34
|
+
| 2 | Generated JavaScript, made with `new Function` | Each other run |
|
|
35
|
+
|
|
36
|
+
The generated code expects the usual case. A check guards each fact that it expects: each field exists, each value has the expected kind, and no op fails. When a check fails, tier 1 does that run again. Thus each error value comes from the interpreter, with its message and its location.
|
|
37
|
+
|
|
38
|
+
A list op skips an error item, as the interpreter does, and `ifError` gives its second argument. These cases stay in tier 2.
|
|
39
|
+
|
|
40
|
+
`program.stats` counts the runs and the fallbacks. `program.reason` tells why a program has no generated code.
|
|
41
|
+
|
|
42
|
+
## The same results
|
|
43
|
+
|
|
44
|
+
Property P17 compares `tiered` with `evaluate` on random programs, random spaces and the programs of the builder. The property also measures the share of the values that tier 2 gives. Thus a fallback cannot hide a gap.
|
|
45
|
+
|
|
46
|
+
These cases operate in tier 1:
|
|
47
|
+
|
|
48
|
+
- A list value with an error item, because generated code makes no error values.
|
|
49
|
+
- A list op on a list value from a binding or a variable. A list op over an axis is one loop in tier 2.
|
|
50
|
+
- An error of an extension, and each exception that is not an error of an op.
|
|
51
|
+
|
|
52
|
+
A program keeps the value of each node that depends only on the space, for each space (COMPILE.MEMO). Thus a run at each key of a space computes such a node once, for example a total of a column. A node that reads the origin only through a few values, its keys, has an entry for each value of its keys (COMPILE.GROUP). Thus "the largest width in the column of the origin" evaluates once for each column. A space does not change, so the values stay correct.
|
|
53
|
+
|
|
54
|
+
The compiler reads the op tables of the domains when it loads a program. A program keeps the method of each op site for the next receiver. A property read of the receiver must give the same function, so a getter that gives the method is not a method.
|
|
55
|
+
|
|
56
|
+
## Safety
|
|
57
|
+
|
|
58
|
+
The source has no name and no literal of the program. It reads each one from a list of constants, by its index. The same program always gives the same source.
|
|
59
|
+
|
|
60
|
+
## API
|
|
61
|
+
|
|
62
|
+
| Function | What it does |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `tiered(expr, options)` | A program of tier 2 if it can, and else of tier 1 |
|
|
65
|
+
| `generate(expr, options)` | The loop IR and the source of a program for the options, or the reason that it has none |
|
|
66
|
+
| `load(generated)` | The function of tier 2. It gives the value, or `FALLBACK`. |
|
|
67
|
+
|
|
68
|
+
## Speed
|
|
69
|
+
|
|
70
|
+
The speed gate compares tier 2 with hand-written loops. On 2026-10-13, the nearest other box was 1.0 to 1.1 times the loops, and the Game of Life was 1.05 to 1.13 times. Tier 1 was 80 and 120 times. The plan of the compiler is in [`docs/COMPILER.md`](https://github.com/mark1russell7/vex/blob/main/docs/COMPILER.md).
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { Addr, AnyDomain, Axis, CompileOptions, Expr, ExtHandler, FreeFn, PrimitiveKind, Program, Space } from "@mark1russell7/vex";
|
|
2
|
+
//#region src/facts.d.ts
|
|
3
|
+
/** The function of an op of a domain, or a method. */
|
|
4
|
+
type Method = (...args: unknown[]) => unknown;
|
|
5
|
+
/**
|
|
6
|
+
* The kind of a value that the compiler knows: a primitive type, or `domain:Name`. The second kind is for a value of
|
|
7
|
+
* the domain `Name` without a primitive type (KIND.DOMAIN).
|
|
8
|
+
*/
|
|
9
|
+
type Kind = PrimitiveKind | `domain:${string}`;
|
|
10
|
+
/**
|
|
11
|
+
* The kinds that a host declares (docs/COMPILER.md §3.2): the kind of each field of the records, and of each variable of
|
|
12
|
+
* the run. A read of a declared field or variable checks the kind. When the check fails, tier 1 evaluates the program.
|
|
13
|
+
*/
|
|
14
|
+
interface Schema {
|
|
15
|
+
readonly fields?: Readonly<Record<string, Kind>>;
|
|
16
|
+
readonly vars?: Readonly<Record<string, Kind>>;
|
|
17
|
+
}
|
|
18
|
+
/** The options of a program: the domains, the free functions and the extension handlers, and the schema of the host. */
|
|
19
|
+
interface Options {
|
|
20
|
+
readonly domains?: readonly AnyDomain[];
|
|
21
|
+
readonly fns?: Readonly<Record<string, FreeFn>>;
|
|
22
|
+
readonly extensions?: Readonly<Record<string, ExtHandler>>;
|
|
23
|
+
readonly schema?: Schema;
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/loop.d.ts
|
|
27
|
+
/** The functions of the runtime that generated code calls. Each one gives `FALLBACK` for a value it cannot give. */
|
|
28
|
+
type RuntimeFn = "has" | "addr" | "table" | "keys" | "step" | "result" | "opts" | "rec" | "list" | "frozen" | "ext" | "var";
|
|
29
|
+
/** The primitive operations of the loop IR. They copy no arithmetic of a domain (§4.2). */
|
|
30
|
+
type PrimOp = "+" | "/" | "===" | "!==" | "!" | "||" | "&&" | "min" | "max" | "isNumber" | "isBoolean" | "isString" | "isValue" | "isObject" | "get" | "member" | "records" | "recordAt" | "keysOf" | "idxOf" | "memoGet" | "memoPut" | "entryValue" | "entryOk";
|
|
31
|
+
/** A value of the loop IR. */
|
|
32
|
+
type LExpr = {
|
|
33
|
+
readonly t: "const";
|
|
34
|
+
readonly i: number;
|
|
35
|
+
} | {
|
|
36
|
+
readonly t: "local";
|
|
37
|
+
readonly n: number;
|
|
38
|
+
} | {
|
|
39
|
+
readonly t: "num";
|
|
40
|
+
readonly v: number;
|
|
41
|
+
} | {
|
|
42
|
+
readonly t: "bool";
|
|
43
|
+
readonly v: boolean;
|
|
44
|
+
} | {
|
|
45
|
+
readonly t: "fallback";
|
|
46
|
+
} | {
|
|
47
|
+
readonly t: "array";
|
|
48
|
+
readonly items: readonly LExpr[];
|
|
49
|
+
} | {
|
|
50
|
+
readonly t: "prim";
|
|
51
|
+
readonly op: PrimOp;
|
|
52
|
+
readonly args: readonly LExpr[];
|
|
53
|
+
} | {
|
|
54
|
+
readonly t: "call";
|
|
55
|
+
readonly fn: RuntimeFn;
|
|
56
|
+
readonly args: readonly LExpr[];
|
|
57
|
+
} | {
|
|
58
|
+
readonly t: "op";
|
|
59
|
+
readonly name: number;
|
|
60
|
+
readonly args: readonly LExpr[];
|
|
61
|
+
readonly kinds: readonly (PrimitiveKind | undefined)[];
|
|
62
|
+
} | {
|
|
63
|
+
readonly t: "memo";
|
|
64
|
+
readonly id: number;
|
|
65
|
+
} | {
|
|
66
|
+
readonly t: "targets";
|
|
67
|
+
readonly axis: number;
|
|
68
|
+
readonly args: readonly [LExpr, LExpr, LExpr];
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* What a failed check does. The interpreter gives an error value at the node of the check, and the context of the node
|
|
72
|
+
* decides what happens to that error:
|
|
73
|
+
*
|
|
74
|
+
* - `return`: the program stops with `FALLBACK`, and tier 1 evaluates it again.
|
|
75
|
+
* - `continue`: the item of a list op is an error item. The list op skips it, as the interpreter does. With the option
|
|
76
|
+
* `strict`, the list op fails instead, and `strict.else` tells what that failure does.
|
|
77
|
+
* - `break`: the first argument of `ifError` failed, so the block ends, and the second argument gives the value.
|
|
78
|
+
*/
|
|
79
|
+
type Fail = {
|
|
80
|
+
readonly t: "return";
|
|
81
|
+
} | {
|
|
82
|
+
readonly t: "continue";
|
|
83
|
+
readonly label: number;
|
|
84
|
+
readonly strict?: {
|
|
85
|
+
readonly cond: LExpr;
|
|
86
|
+
readonly else: Fail;
|
|
87
|
+
};
|
|
88
|
+
} | {
|
|
89
|
+
readonly t: "break";
|
|
90
|
+
readonly label: number;
|
|
91
|
+
};
|
|
92
|
+
/** A statement of the loop IR. */
|
|
93
|
+
type LStmt = {
|
|
94
|
+
readonly t: "let";
|
|
95
|
+
readonly n: number;
|
|
96
|
+
readonly value: LExpr;
|
|
97
|
+
} | {
|
|
98
|
+
readonly t: "set";
|
|
99
|
+
readonly n: number;
|
|
100
|
+
readonly value: LExpr;
|
|
101
|
+
} | {
|
|
102
|
+
readonly t: "check";
|
|
103
|
+
readonly ok: LExpr;
|
|
104
|
+
readonly reason: string;
|
|
105
|
+
readonly fail: Fail;
|
|
106
|
+
} | {
|
|
107
|
+
readonly t: "fail";
|
|
108
|
+
readonly fail: Fail;
|
|
109
|
+
} | {
|
|
110
|
+
readonly t: "if";
|
|
111
|
+
readonly cond: LExpr;
|
|
112
|
+
readonly yes: readonly LStmt[];
|
|
113
|
+
readonly no: readonly LStmt[];
|
|
114
|
+
} | {
|
|
115
|
+
readonly t: "loop";
|
|
116
|
+
readonly label: number;
|
|
117
|
+
readonly item: number;
|
|
118
|
+
readonly index: number;
|
|
119
|
+
readonly array: number;
|
|
120
|
+
readonly over: LExpr;
|
|
121
|
+
readonly body: readonly LStmt[];
|
|
122
|
+
} | {
|
|
123
|
+
readonly t: "block";
|
|
124
|
+
readonly label: number;
|
|
125
|
+
readonly body: readonly LStmt[];
|
|
126
|
+
} | {
|
|
127
|
+
readonly t: "repeat";
|
|
128
|
+
readonly label: number;
|
|
129
|
+
readonly body: readonly LStmt[];
|
|
130
|
+
} | {
|
|
131
|
+
readonly t: "next";
|
|
132
|
+
} | {
|
|
133
|
+
readonly t: "push";
|
|
134
|
+
readonly n: number;
|
|
135
|
+
readonly value: LExpr;
|
|
136
|
+
} | {
|
|
137
|
+
readonly t: "return";
|
|
138
|
+
readonly value: LExpr;
|
|
139
|
+
};
|
|
140
|
+
/** A program of the loop IR: its statements, the number of its locals and its constants. Each local is a name in the function. */
|
|
141
|
+
interface LoopProgram {
|
|
142
|
+
readonly body: readonly LStmt[];
|
|
143
|
+
readonly locals: number;
|
|
144
|
+
/** The constants, by index: literals, paths, addresses, axes and names. Generated code reads them by index (§5). */
|
|
145
|
+
readonly constants: readonly unknown[];
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region src/tiers.d.ts
|
|
149
|
+
/** The options of the compiler: the options of `compile`, and the schema of the host (docs/COMPILER.md §3.2). */
|
|
150
|
+
type GenerateOptions = CompileOptions & {
|
|
151
|
+
readonly schema?: Schema;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* The output of `generate`: the loop IR and the source of a program, and the options that the source is for. Or else
|
|
155
|
+
* the reason that the compiler cannot lower the program.
|
|
156
|
+
*/
|
|
157
|
+
type Generated = {
|
|
158
|
+
readonly ok: true;
|
|
159
|
+
readonly program: LoopProgram;
|
|
160
|
+
readonly source: string;
|
|
161
|
+
readonly options: GenerateOptions;
|
|
162
|
+
} | {
|
|
163
|
+
readonly ok: false;
|
|
164
|
+
readonly reason: string;
|
|
165
|
+
};
|
|
166
|
+
/** A function of tier 2. It gives the value of the program, or `FALLBACK`. */
|
|
167
|
+
type Tier2 = (space: Space, origin: string, vars: Readonly<Record<string, unknown>> | undefined, tables: Readonly<Record<string, Space>> | undefined) => unknown;
|
|
168
|
+
/**
|
|
169
|
+
* This function lowers an expression and prints its source for the options. The op tables of the domains give the
|
|
170
|
+
* fast path of each op site. It is pure, so a build can use it.
|
|
171
|
+
*/
|
|
172
|
+
export declare function generate(expr: Expr, options?: GenerateOptions): Generated;
|
|
173
|
+
/**
|
|
174
|
+
* This function makes the function of tier 2 with `new Function`, with the options of the source. It throws on a page
|
|
175
|
+
* that does not permit `new Function`.
|
|
176
|
+
*/
|
|
177
|
+
export declare function load(generated: Extract<Generated, {
|
|
178
|
+
readonly ok: true;
|
|
179
|
+
}>): Tier2;
|
|
180
|
+
/** The counts of the runs of a tiered program. */
|
|
181
|
+
interface TierStats {
|
|
182
|
+
/** The number of runs. */
|
|
183
|
+
readonly runs: number;
|
|
184
|
+
/** The number of runs where tier 2 gave `FALLBACK`, so tier 1 gave the result. */
|
|
185
|
+
readonly fallbacks: number;
|
|
186
|
+
}
|
|
187
|
+
/** A program with tiers. It has the interface `Program` of the core, so it can replace a compiled program. */
|
|
188
|
+
interface TieredProgram extends Program {
|
|
189
|
+
/** The tier of the program: 2 when it has generated code, and else 1. */
|
|
190
|
+
readonly tier: 1 | 2;
|
|
191
|
+
/** The reason that the program has no generated code. */
|
|
192
|
+
readonly reason?: string;
|
|
193
|
+
readonly stats: TierStats;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* This function compiles an expression into tier 2 if it can, and else into tier 1. After a failed check of tier 2,
|
|
197
|
+
* tier 1 does that evaluation again. A run with a trace and `explain` always use tier 1, because tier 2 makes no trace.
|
|
198
|
+
*/
|
|
199
|
+
export declare function tiered(expr: Expr, options?: GenerateOptions): TieredProgram;
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/module.d.ts
|
|
202
|
+
/** The options of a standalone module. */
|
|
203
|
+
interface ModuleOptions {
|
|
204
|
+
readonly domains?: readonly AnyDomain[];
|
|
205
|
+
/** The kinds of the fields of the records and of the variables. A module reads only the names of its schema. */
|
|
206
|
+
readonly schema: Schema;
|
|
207
|
+
/** The name of the function that the module exports. The default is `run`. */
|
|
208
|
+
readonly name?: string;
|
|
209
|
+
}
|
|
210
|
+
/** The source of a standalone module, or the reason that the program cannot be one. */
|
|
211
|
+
type Emitted = {
|
|
212
|
+
readonly ok: true;
|
|
213
|
+
readonly source: string;
|
|
214
|
+
} | {
|
|
215
|
+
readonly ok: false;
|
|
216
|
+
readonly reason: string;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* This function prints a program as a standalone ES module. The module exports `VexContractError`, `VEX_ERROR` and a
|
|
220
|
+
* function that takes the records and the variables and gives the value at each key. It is pure, so a build can use it.
|
|
221
|
+
*/
|
|
222
|
+
export declare function emitModule(expr: Expr, options: ModuleOptions): Emitted;
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region src/runtime.d.ts
|
|
225
|
+
/** The value of a program that stops at a failed check. */
|
|
226
|
+
export declare const FALLBACK: unique symbol;
|
|
227
|
+
type Fallback = typeof FALLBACK;
|
|
228
|
+
/** The options that a runtime keeps: the domains, the free functions and the extension handlers. */
|
|
229
|
+
type RuntimeOptions = Options;
|
|
230
|
+
/**
|
|
231
|
+
* The dispatch of one op name and one number of arguments. With up to 3 arguments, it takes the values themselves, the
|
|
232
|
+
* receiver first. With more, it takes an array of the values. Generated code also reads its fields: the method of the
|
|
233
|
+
* last receiver, the function of the op of the first domain, and the free function.
|
|
234
|
+
*/
|
|
235
|
+
interface Site {
|
|
236
|
+
(...values: never[]): unknown;
|
|
237
|
+
m: Method | undefined;
|
|
238
|
+
readonly fn: Method | undefined;
|
|
239
|
+
readonly free: FreeFn | undefined;
|
|
240
|
+
}
|
|
241
|
+
/** A base axis: an axis that is not `where`. */
|
|
242
|
+
type BaseAxis = Exclude<Axis, {
|
|
243
|
+
readonly t: "where";
|
|
244
|
+
}>;
|
|
245
|
+
/** The targets of an axis at a focus: the keys, and the index of each key in `keys` of the space. */
|
|
246
|
+
interface Targets {
|
|
247
|
+
readonly keys: readonly string[];
|
|
248
|
+
readonly idx: readonly (number | undefined)[];
|
|
249
|
+
}
|
|
250
|
+
/** An entry of a memo: the value of a node for one space, or no value after an error. */
|
|
251
|
+
interface MemoEntry {
|
|
252
|
+
readonly v: unknown;
|
|
253
|
+
readonly ok: boolean;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The memo of one node: an entry for each space and each value of the keys (docs/COMPILER.md §7.2 and §7.3). An entry
|
|
257
|
+
* with an object or a function in its keys is not kept, because each run can make a new one.
|
|
258
|
+
*/
|
|
259
|
+
interface Memo {
|
|
260
|
+
get(s: Space, keys: readonly unknown[]): MemoEntry | undefined;
|
|
261
|
+
put(s: Space, keys: readonly unknown[], v: unknown, ok: boolean): MemoEntry;
|
|
262
|
+
}
|
|
263
|
+
/** The functions of the runtime. The names are the names of `RuntimeFn` in the loop IR. */
|
|
264
|
+
interface Runtime {
|
|
265
|
+
readonly F: Fallback;
|
|
266
|
+
has(s: Space, key: string): boolean;
|
|
267
|
+
/** This function gives the key of an address. `values` has the values of its computed moves (NAV.COMPUTED). */
|
|
268
|
+
addr(s: Space, origin: string, focus: string, at: Addr, values?: readonly unknown[]): unknown;
|
|
269
|
+
/**
|
|
270
|
+
* This function gives the function of the targets of one base axis. A space does not change, so the targets stay in
|
|
271
|
+
* a cache for each space and focus. Generated code gets it once, when it loads.
|
|
272
|
+
*/
|
|
273
|
+
axis(axis: BaseAxis): (s: Space, origin: string, focus: string) => Targets | Fallback;
|
|
274
|
+
table(tables: Readonly<Record<string, Space>> | undefined, name: string): unknown;
|
|
275
|
+
keys(s: Space): readonly string[];
|
|
276
|
+
/** This function gives the dispatch of an op name with `arity` arguments. Generated code gets it once, when it loads. */
|
|
277
|
+
site(name: string, arity: number): Site;
|
|
278
|
+
/** This function gives a new memo. Generated code gets one for each node of the memo, when it loads. */
|
|
279
|
+
memo(): Memo;
|
|
280
|
+
/** This function gives the domain at an index of the options. */
|
|
281
|
+
domain(index: number): AnyDomain | undefined;
|
|
282
|
+
/** An exception of an op is the error #CALC! of that op, so this function gives `FALLBACK`. A full call stack goes on. */
|
|
283
|
+
threw(thrown: unknown): Fallback;
|
|
284
|
+
step(name: string, acc: unknown, value: unknown): unknown;
|
|
285
|
+
result(value: unknown): unknown;
|
|
286
|
+
opts(value: unknown): unknown;
|
|
287
|
+
rec(names: readonly string[], values: readonly unknown[]): unknown;
|
|
288
|
+
list(keys: readonly string[], values: readonly unknown[]): unknown;
|
|
289
|
+
frozen(values: readonly unknown[]): unknown;
|
|
290
|
+
ext(kind: string, data: unknown, s: Space, origin: string, focus: string, path: readonly number[]): unknown;
|
|
291
|
+
var(vars: Readonly<Record<string, unknown>> | undefined, name: string): unknown;
|
|
292
|
+
}
|
|
293
|
+
/** This function makes the runtime of one set of options. */
|
|
294
|
+
export declare function createRuntime(options: RuntimeOptions): Runtime;
|
|
295
|
+
//#endregion
|
|
296
|
+
export type { Emitted, Fallback, GenerateOptions, Generated, LExpr, LStmt, LoopProgram, ModuleOptions, PrimOp, Runtime, RuntimeFn, RuntimeOptions, Schema, Tier2, TierStats, TieredProgram };
|
|
297
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/facts.ts","../src/loop.ts","../src/tiers.ts","../src/module.ts","../src/runtime.ts"],"mappings":";;;KAQY,aAAa;;;;;KAMb,OAAO;;;;;UAYF;WACN,SAAS,SAAS,eAAe;WACjC,OAAO,SAAS,eAAe;;;UAIzB;WACN,mBAAmB;WACnB,MAAM,SAAS,eAAe;WAC9B,aAAa,SAAS,eAAe;WACrC,SAAS;;;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