@mark1russell7/vex-compiler 0.11.1 → 0.12.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/README.md +2 -0
- package/build/index.d.ts +37 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +792 -88
- package/build/index.js.map +1 -1
- package/package.json +4 -4
- package/src/facts.ts +2 -2
- package/src/index.ts +1 -1
- package/src/js.ts +4 -2
- package/src/lower.ts +1 -0
- package/src/module.ts +639 -69
- package/src/runtime.ts +2 -7
- package/src/sheet-order.ts +123 -0
package/README.md
CHANGED
|
@@ -64,6 +64,8 @@ The source has no name and no literal of the program. It reads each one from a l
|
|
|
64
64
|
| `tiered(expr, options)` | A program of tier 2 if it can, and else of tier 1 |
|
|
65
65
|
| `generate(expr, options)` | The loop IR and the source of a program for the options, or the reason that it has none |
|
|
66
66
|
| `load(generated)` | The function of tier 2. It gives the value, or `FALLBACK`. |
|
|
67
|
+
| `emitModule(expr, options)` | The source of a standalone ES module of a program over an array or a tree, or the reason that it has none |
|
|
68
|
+
| `emitSheetModule(columns, options)` | The source of a standalone ES module of the formula columns of a sheet, with the results of `SheetRun` |
|
|
67
69
|
|
|
68
70
|
`tiered`, `generate` and `emitModule` take an expression or a document of coeval, as `toDocument` of `@mark1russell7/vex` gives it.
|
|
69
71
|
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Addr, AnyDomain, Axis, CompileOptions, Envelope, Expr, ExtHandler, FreeFn, PrimitiveKind, Program, Space } from "@mark1russell7/vex";
|
|
1
|
+
import { Addr, AnyDomain, Axis, CellFormulas, CompileOptions, Envelope, Expr, ExtHandler, FreeFn, PrimitiveKind, Program, Space } from "@mark1russell7/vex";
|
|
2
2
|
//#region src/facts.d.ts
|
|
3
3
|
/** The function of an op of a domain, or a method. */
|
|
4
4
|
type Method = (...args: unknown[]) => unknown;
|
|
@@ -205,8 +205,29 @@ interface ModuleOptions {
|
|
|
205
205
|
readonly domains?: readonly AnyDomain[];
|
|
206
206
|
/** The kinds of the fields of the records and of the variables. A module reads only the names of its schema. */
|
|
207
207
|
readonly schema: Schema;
|
|
208
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* The name of the function that the module exports. The default is `run`. A reserved word, a name that the module
|
|
210
|
+
* declares and a global that a module reads (`MODULE_GLOBALS`) are not names of the run (V-060).
|
|
211
|
+
*/
|
|
209
212
|
readonly name?: string;
|
|
213
|
+
/**
|
|
214
|
+
* The space of the records. In both spaces, the key of a record is the text of its position. The default `array`
|
|
215
|
+
* has no parents. A `tree` takes the parents as the third argument of the run (COMPILE.MODULE.TREE). Each entry
|
|
216
|
+
* is the position of the parent of its record, or -1 for a root.
|
|
217
|
+
*/
|
|
218
|
+
readonly space?: "array" | "tree";
|
|
219
|
+
}
|
|
220
|
+
/** The options of a module of a sheet (COMPILE.MODULE.SHEET): the options of a module, and the parts of a sheet. */
|
|
221
|
+
interface SheetModuleOptions extends ModuleOptions {
|
|
222
|
+
/** The cells with their own formula (SHEET.CELL.FORMULA). The formula of a cell replaces the formula of its column at its key. */
|
|
223
|
+
readonly cells?: CellFormulas;
|
|
224
|
+
/**
|
|
225
|
+
* The kind of the values of each column. The printer prints each column after the columns that it reads. A column
|
|
226
|
+
* that a formula reads before its own formula prints needs its kind here, for example a column that reads itself.
|
|
227
|
+
*/
|
|
228
|
+
readonly kinds?: Readonly<Record<string, Kind>>;
|
|
229
|
+
/** The budget of the stack of the search of a run, in estimated frames, as in `SheetRun`. The default is 3000. */
|
|
230
|
+
readonly budget?: number;
|
|
210
231
|
}
|
|
211
232
|
/** The source of a standalone module, or the reason that the program cannot be one. */
|
|
212
233
|
type Emitted = {
|
|
@@ -218,10 +239,21 @@ type Emitted = {
|
|
|
218
239
|
};
|
|
219
240
|
/**
|
|
220
241
|
* This function prints a program as a standalone ES module. The module exports `VexContractError`, `VEX_ERROR` and a
|
|
221
|
-
* function that takes the records and the variables and gives the value at each key.
|
|
222
|
-
* The program can be an expression or a document
|
|
242
|
+
* function that takes the records and the variables and gives the value at each key. A module of a tree space takes
|
|
243
|
+
* the parents too. The function is pure, so a build can use it. The program can be an expression or a document
|
|
244
|
+
* (DOC.ENTRY).
|
|
223
245
|
*/
|
|
224
246
|
export declare function emitModule(source: Expr | Envelope, options: ModuleOptions): Emitted;
|
|
247
|
+
/**
|
|
248
|
+
* This function prints the formula columns of a sheet as a standalone ES module (COMPILE.MODULE.SHEET). The function of
|
|
249
|
+
* the module takes the records and the variables, and the parents for a tree. It gives an object with an array for
|
|
250
|
+
* each column: the result of the column at each key, or `VEX_ERROR`. The results are the results of `SheetRun`.
|
|
251
|
+
*
|
|
252
|
+
* The run fills the columns in the order of `SheetRun.fill`. A read of a finished cell is the read of an array. A read
|
|
253
|
+
* of a cell that is not finished starts the search of `SheetRun`, with the same budget of the stack. Each cell on a
|
|
254
|
+
* cycle of reads gives `VEX_ERROR`.
|
|
255
|
+
*/
|
|
256
|
+
export declare function emitSheetModule(columns: ReadonlyMap<string, Expr>, options: SheetModuleOptions): Emitted;
|
|
225
257
|
//#endregion
|
|
226
258
|
//#region src/runtime.d.ts
|
|
227
259
|
/** The value of a program that stops at a failed check. */
|
|
@@ -295,5 +327,5 @@ interface Runtime {
|
|
|
295
327
|
/** This function makes the runtime of one set of options. */
|
|
296
328
|
export declare function createRuntime(options: RuntimeOptions): Runtime;
|
|
297
329
|
//#endregion
|
|
298
|
-
export type { Emitted, Fallback, GenerateOptions, Generated, LExpr, LStmt, LoopProgram, ModuleOptions, PrimOp, Runtime, RuntimeFn, RuntimeOptions, Schema, Tier2, TierStats, TieredProgram };
|
|
330
|
+
export type { Emitted, Fallback, GenerateOptions, Generated, LExpr, LStmt, LoopProgram, ModuleOptions, PrimOp, Runtime, RuntimeFn, RuntimeOptions, Schema, SheetModuleOptions, Tier2, TierStats, TieredProgram };
|
|
299
331
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 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