eliscript 0.0.2 → 0.0.3

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.
@@ -97,6 +97,7 @@ const __eliscript_numeric_relation = (operator, left, right) => {
97
97
  };
98
98
 
99
99
  import {readFile, writeFile, mkdir, realpath} from "node:fs/promises";
100
+ import {existsSync} from "node:fs";
100
101
  import {resolve, dirname, relative} from "node:path";
101
102
  import {isDeepStrictEqual} from "node:util";
102
103
  import {root} from "./build.mjs";
@@ -170,121 +171,127 @@ async function progress(callback, event) {
170
171
  }
171
172
  async function authenticateStage3Targets(input) {
172
173
  return (await (async (options) => {
173
- return (await (async (manifest_path) => {
174
- return (await (async (base) => {
175
- return (await (async (manifest) => {
176
- return (await (async (stages) => {
177
- return (((manifest)["format"] === "eliscript-stage3-release") ? (await (async () => {
178
- if ((!__eliscript_truthy(((__eliscript_value_6) => (__eliscript_truthy(__eliscript_value_6) ? ((__eliscript_value_7) => (__eliscript_truthy(__eliscript_value_7) ? ((__eliscript_value_8) => (__eliscript_truthy(__eliscript_value_8) ? ((__eliscript_value_9) => (__eliscript_truthy(__eliscript_value_9) ? __eliscript_numeric_relation(">", (manifest)["fixedPointFileCount"], 0) : __eliscript_value_9))(Number.isInteger((manifest)["fixedPointFileCount"])) : __eliscript_value_8))(((manifest)["verification"] === "identical")) : __eliscript_value_7))(((manifest)["status"] === "accepted")) : __eliscript_value_6))(((manifest)["version"] === 1))))) {
179
- fail("an accepted stage3 release receipt is required");
180
- }
181
- return (await (async (path3) => {
182
- return (await (async (supplied) => {
183
- return (await (async (artifact) => {
184
- return (await (async (directory) => {
185
- return (await (async (declared_files) => {
186
- return (await (async (verified_files) => {
187
- return (await (async (index) => {
188
- return (await (async () => {
189
- ((!(supplied === undefined)) ? ((!(await (realpath(required_path(supplied, "stage3MetadataPath"))) === path3)) ? fail("the requested compiler is not the designated final stage3") : null) : null);
190
- identical((artifact)["sourceIdentity"], (manifest)["artifactSourceIdentity"], "stage3 source identity");
191
- identical((artifact)["stage3FullProductIdentity"], (manifest)["stage3ProductIdentity"], "stage3 product identity");
192
- if ((!__eliscript_truthy(((__eliscript_value_10) => (__eliscript_truthy(__eliscript_value_10) ? __eliscript_numeric_relation(">", ((declared_files) ?? []).length, 0) : __eliscript_value_10))(Array.isArray(declared_files))))) {
193
- fail("packaged stage3 artifact requires declared files");
194
- }
195
- (await (async () => {
196
- while (__eliscript_numeric_relation("<", index, ((declared_files) ?? []).length)) {
197
- (await (async (entry) => {
198
- return (await (async (rel_path) => {
199
- return ((bytes) => {
200
- return ((actual_sha) => {
201
- return (() => {
202
- if ((!((((bytes) ?? []).length === (entry)["bytes"]) && (actual_sha === (entry)["sha256"])))) {
203
- fail(("packaged stage3 file changed after emission: " + rel_path));
204
- }
205
- return (verified_files)["push"](({"path": rel_path, "bytes": ((bytes) ?? []).length, "sha256": actual_sha}));
206
- })();
207
- })(compilerDigest(bytes));
208
- })(await (readFile(resolve(directory, rel_path))));
209
- })((entry)["path"]));
210
- })((declared_files)[index]));
211
- ((index = (index + 1)));
212
- }
213
- return null;
214
- })());
215
- {
216
- const __eliscript_value_11 = independentCompilerProductIdentity(({"host": (artifact)["host"], "nativeTarget": (artifact)["nativeTarget"], "files": verified_files, "descriptor": (artifact)["descriptor"], "typed": (artifact)["typed"]}));
217
- {
218
- let actual_packaged = __eliscript_value_11;
219
- identical(actual_packaged, (artifact)["productIdentity"], "packaged stage3 artifact product identity");
220
- identical(actual_packaged, (manifest)["packagedProductIdentity"], "packaged stage3 release product identity");
221
- return ({"scope": "stage3-identity", "verification": "authenticated", "bootstrapManifestPath": manifest_path, "stage3MetadataPath": path3, "stage2MetadataPath": path3, "stage2ProductIdentity": (manifest)["stage2ProductIdentity"], "fixedPointFileCount": (manifest)["fixedPointFileCount"], "sourceIdentity": (manifest)["formalSourceIdentity"], "productIdentity": (manifest)["stage3ProductIdentity"]});
222
- }
223
- }
224
- })());
225
- })(0));
226
- })([]));
227
- })(((artifact)["artifactIdentity"])["files"]));
228
- })(dirname(path3)));
229
- })(await (readCompilerMetadata(path3))));
230
- })((options)["stage3MetadataPath"]));
231
- })(await (realpath(resolve(base, (manifest)["metadataPath"])))));
232
- })()) : (await (async () => {
233
- if ((!__eliscript_truthy(((__eliscript_value_12) => (__eliscript_truthy(__eliscript_value_12) ? ((__eliscript_value_13) => (__eliscript_truthy(__eliscript_value_13) ? ((__eliscript_value_14) => (__eliscript_truthy(__eliscript_value_14) ? ((__eliscript_value_15) => (__eliscript_truthy(__eliscript_value_15) ? (((stages) ?? []).length === 4) : __eliscript_value_15))(Array.isArray(stages)) : __eliscript_value_14))(((manifest)["status"] === "accepted")) : __eliscript_value_13))(((manifest)["version"] === 1)) : __eliscript_value_12))(((manifest)["format"] === "eliscript-js-bootstrap"))))) {
234
- fail("an accepted JavaScript stage0-stage3 bootstrap is required");
235
- }
236
- {
237
- const __eliscript_value_16 = 0;
238
- {
239
- let index = __eliscript_value_16;
240
- while (__eliscript_numeric_relation("<", index, 4)) {
174
+ return (await (async (requested_path) => {
175
+ return (await (async (default_bootstrap) => {
176
+ return (await (async (default_release) => {
177
+ return (await (async (manifest_path) => {
178
+ return (await (async (base) => {
179
+ return (await (async (manifest) => {
180
+ return (await (async (stages) => {
181
+ return (((manifest)["format"] === "eliscript-stage3-release") ? (await (async () => {
182
+ if ((!__eliscript_truthy(((__eliscript_value_8) => (__eliscript_truthy(__eliscript_value_8) ? ((__eliscript_value_9) => (__eliscript_truthy(__eliscript_value_9) ? ((__eliscript_value_10) => (__eliscript_truthy(__eliscript_value_10) ? ((__eliscript_value_11) => (__eliscript_truthy(__eliscript_value_11) ? __eliscript_numeric_relation(">", (manifest)["fixedPointFileCount"], 0) : __eliscript_value_11))(Number.isInteger((manifest)["fixedPointFileCount"])) : __eliscript_value_10))(((manifest)["verification"] === "identical")) : __eliscript_value_9))(((manifest)["status"] === "accepted")) : __eliscript_value_8))(((manifest)["version"] === 1))))) {
183
+ fail("an accepted stage3 release receipt is required");
184
+ }
185
+ return (await (async (path3) => {
186
+ return (await (async (supplied) => {
187
+ return (await (async (artifact) => {
188
+ return (await (async (directory) => {
189
+ return (await (async (declared_files) => {
190
+ return (await (async (verified_files) => {
191
+ return (await (async (index) => {
192
+ return (await (async () => {
193
+ ((!(supplied === undefined)) ? ((!(await (realpath(required_path(supplied, "stage3MetadataPath"))) === path3)) ? fail("the requested compiler is not the designated final stage3") : null) : null);
194
+ identical((artifact)["sourceIdentity"], (manifest)["artifactSourceIdentity"], "stage3 source identity");
195
+ identical((artifact)["stage3FullProductIdentity"], (manifest)["stage3ProductIdentity"], "stage3 product identity");
196
+ if ((!__eliscript_truthy(((__eliscript_value_12) => (__eliscript_truthy(__eliscript_value_12) ? __eliscript_numeric_relation(">", ((declared_files) ?? []).length, 0) : __eliscript_value_12))(Array.isArray(declared_files))))) {
197
+ fail("packaged stage3 artifact requires declared files");
198
+ }
199
+ (await (async () => {
200
+ while (__eliscript_numeric_relation("<", index, ((declared_files) ?? []).length)) {
201
+ (await (async (entry) => {
202
+ return (await (async (rel_path) => {
203
+ return ((bytes) => {
204
+ return ((actual_sha) => {
205
+ return (() => {
206
+ if ((!((((bytes) ?? []).length === (entry)["bytes"]) && (actual_sha === (entry)["sha256"])))) {
207
+ fail(("packaged stage3 file changed after emission: " + rel_path));
208
+ }
209
+ return (verified_files)["push"](({"path": rel_path, "bytes": ((bytes) ?? []).length, "sha256": actual_sha}));
210
+ })();
211
+ })(compilerDigest(bytes));
212
+ })(await (readFile(resolve(directory, rel_path))));
213
+ })((entry)["path"]));
214
+ })((declared_files)[index]));
215
+ ((index = (index + 1)));
216
+ }
217
+ return null;
218
+ })());
219
+ {
220
+ const __eliscript_value_13 = independentCompilerProductIdentity(({"host": (artifact)["host"], "nativeTarget": (artifact)["nativeTarget"], "files": verified_files, "descriptor": (artifact)["descriptor"], "typed": (artifact)["typed"]}));
221
+ {
222
+ let actual_packaged = __eliscript_value_13;
223
+ identical(actual_packaged, (artifact)["productIdentity"], "packaged stage3 artifact product identity");
224
+ identical(actual_packaged, (manifest)["packagedProductIdentity"], "packaged stage3 release product identity");
225
+ return ({"scope": "stage3-identity", "verification": "authenticated", "bootstrapManifestPath": manifest_path, "stage3MetadataPath": path3, "stage2MetadataPath": path3, "stage2ProductIdentity": (manifest)["stage2ProductIdentity"], "fixedPointFileCount": (manifest)["fixedPointFileCount"], "sourceIdentity": (manifest)["formalSourceIdentity"], "productIdentity": (manifest)["stage3ProductIdentity"]});
226
+ }
227
+ }
228
+ })());
229
+ })(0));
230
+ })([]));
231
+ })(((artifact)["artifactIdentity"])["files"]));
232
+ })(dirname(path3)));
233
+ })(await (readCompilerMetadata(path3))));
234
+ })((options)["stage3MetadataPath"]));
235
+ })(await (realpath(resolve(base, (manifest)["metadataPath"])))));
236
+ })()) : (await (async () => {
237
+ if ((!__eliscript_truthy(((__eliscript_value_14) => (__eliscript_truthy(__eliscript_value_14) ? ((__eliscript_value_15) => (__eliscript_truthy(__eliscript_value_15) ? ((__eliscript_value_16) => (__eliscript_truthy(__eliscript_value_16) ? ((__eliscript_value_17) => (__eliscript_truthy(__eliscript_value_17) ? (((stages) ?? []).length === 4) : __eliscript_value_17))(Array.isArray(stages)) : __eliscript_value_16))(((manifest)["status"] === "accepted")) : __eliscript_value_15))(((manifest)["version"] === 1)) : __eliscript_value_14))(((manifest)["format"] === "eliscript-js-bootstrap"))))) {
238
+ fail("an accepted JavaScript stage0-stage3 bootstrap is required");
239
+ }
241
240
  {
242
- const __eliscript_value_17 = (stages)[index];
241
+ const __eliscript_value_18 = 0;
243
242
  {
244
- let stage = __eliscript_value_17;
245
- if ((!(((stage)["stage"] === index) && ((stage)["host"] === "javascript") && ((stage)["target"] === "javascript") && ((stage)["status"] === "built") && ((stage)["producer"] === ((index === 0) ? "emacs-lisp" : ("stage" + __eliscript_numeric_decrement(index))))))) {
246
- fail("bootstrap stage provenance is invalid");
243
+ let index = __eliscript_value_18;
244
+ while (__eliscript_numeric_relation("<", index, 4)) {
245
+ {
246
+ const __eliscript_value_19 = (stages)[index];
247
+ {
248
+ let stage = __eliscript_value_19;
249
+ if ((!(((stage)["stage"] === index) && ((stage)["host"] === "javascript") && ((stage)["target"] === "javascript") && ((stage)["status"] === "built") && ((stage)["producer"] === ((index === 0) ? "emacs-lisp" : ("stage" + __eliscript_numeric_decrement(index))))))) {
250
+ fail("bootstrap stage provenance is invalid");
251
+ }
252
+ identical((stage)["inputIdentity"], (manifest)["formalSourceIdentity"], "stage source identity");
253
+ }
254
+ }
255
+ ((index = (index + 1)));
247
256
  }
248
- identical((stage)["inputIdentity"], (manifest)["formalSourceIdentity"], "stage source identity");
249
257
  }
250
258
  }
251
- ((index = (index + 1)));
252
- }
253
- }
254
- }
255
- if ((!((((manifest)["fixedPoint"])["from"] === 2) && (((manifest)["fixedPoint"])["to"] === 3) && (((manifest)["fixedPoint"])["status"] === "identical")))) {
256
- fail("stage2-stage3 fixed point is not identical");
257
- }
258
- return (await (async (stage2) => {
259
- return (await (async (stage3) => {
260
- return (await (async (path2) => {
261
- return (await (async (path3) => {
262
- return (await (async (supplied) => {
263
- return (await (async (receipt_path) => {
264
- return (await (async () => {
265
- ((!(supplied === undefined)) ? ((!(await (realpath(required_path(supplied, "stage3MetadataPath"))) === path3)) ? fail("the requested compiler is not the designated final stage3") : null) : null);
266
- return (await (async (receipt) => {
267
- return ((actual) => {
268
- return (() => {
269
- identical(actual, receipt, "fixed-point receipt");
270
- identical((actual)["stage2ProductIdentity"], (stage2)["productIdentity"], "stage2 product identity");
271
- identical((actual)["stage3ProductIdentity"], (stage3)["productIdentity"], "stage3 product identity");
272
- return ({"scope": "stage3-identity", "verification": "authenticated", "bootstrapManifestPath": manifest_path, "stage3MetadataPath": path3, "stage2MetadataPath": path2, "stage2ProductIdentity": (actual)["stage2ProductIdentity"], "fixedPointFileCount": (((actual)["files"]) ?? []).length, "sourceIdentity": (manifest)["formalSourceIdentity"], "productIdentity": (actual)["stage3ProductIdentity"]});
273
- })();
274
- })(await (compareJsFixedPoint(({"stage2": path2, "stage3": path3, "sourceIdentity": (manifest)["formalSourceIdentity"]}))));
275
- })(await (readCompilerMetadata(receipt_path))));
276
- })());
277
- })(resolve(base, ((manifest)["fixedPoint"])["comparisonPath"])));
278
- })((options)["stage3MetadataPath"]));
279
- })(await (realpath(resolve(base, (stage3)["metadataPath"])))));
280
- })(await (realpath(resolve(base, (stage2)["metadataPath"])))));
281
- })((stages)[3]));
282
- })((stages)[2]));
283
- })()));
284
- })((manifest)["stages"]));
285
- })(await (readCompilerMetadata(manifest_path))));
286
- })(dirname(manifest_path)));
287
- })(await (realpath(required_path((options)["bootstrapManifestPath"], "bootstrapManifestPath")))));
259
+ if ((!((((manifest)["fixedPoint"])["from"] === 2) && (((manifest)["fixedPoint"])["to"] === 3) && (((manifest)["fixedPoint"])["status"] === "identical")))) {
260
+ fail("stage2-stage3 fixed point is not identical");
261
+ }
262
+ return (await (async (stage2) => {
263
+ return (await (async (stage3) => {
264
+ return (await (async (path2) => {
265
+ return (await (async (path3) => {
266
+ return (await (async (supplied) => {
267
+ return (await (async (receipt_path) => {
268
+ return (await (async () => {
269
+ ((!(supplied === undefined)) ? ((!(await (realpath(required_path(supplied, "stage3MetadataPath"))) === path3)) ? fail("the requested compiler is not the designated final stage3") : null) : null);
270
+ return (await (async (receipt) => {
271
+ return ((actual) => {
272
+ return (() => {
273
+ identical(actual, receipt, "fixed-point receipt");
274
+ identical((actual)["stage2ProductIdentity"], (stage2)["productIdentity"], "stage2 product identity");
275
+ identical((actual)["stage3ProductIdentity"], (stage3)["productIdentity"], "stage3 product identity");
276
+ return ({"scope": "stage3-identity", "verification": "authenticated", "bootstrapManifestPath": manifest_path, "stage3MetadataPath": path3, "stage2MetadataPath": path2, "stage2ProductIdentity": (actual)["stage2ProductIdentity"], "fixedPointFileCount": (((actual)["files"]) ?? []).length, "sourceIdentity": (manifest)["formalSourceIdentity"], "productIdentity": (actual)["stage3ProductIdentity"]});
277
+ })();
278
+ })(await (compareJsFixedPoint(({"stage2": path2, "stage3": path3, "sourceIdentity": (manifest)["formalSourceIdentity"]}))));
279
+ })(await (readCompilerMetadata(receipt_path))));
280
+ })());
281
+ })(resolve(base, ((manifest)["fixedPoint"])["comparisonPath"])));
282
+ })((options)["stage3MetadataPath"]));
283
+ })(await (realpath(resolve(base, (stage3)["metadataPath"])))));
284
+ })(await (realpath(resolve(base, (stage2)["metadataPath"])))));
285
+ })((stages)[3]));
286
+ })((stages)[2]));
287
+ })()));
288
+ })((manifest)["stages"]));
289
+ })(await (readCompilerMetadata(manifest_path))));
290
+ })(dirname(manifest_path)));
291
+ })(await (realpath((__eliscript_truthy(((__eliscript_value_6) => (__eliscript_truthy(__eliscript_value_6) ? ((__eliscript_value_7) => (__eliscript_truthy(__eliscript_value_7) ? existsSync(default_release) : __eliscript_value_7))((!__eliscript_truthy(existsSync(default_bootstrap)))) : __eliscript_value_6))((requested_path === default_bootstrap))) ? default_release : requested_path)))));
292
+ })(resolve(root, "dist/stage3-release.json")));
293
+ })(resolve(root, "dist/bootstrap-release/bootstrap.json")));
294
+ })(required_path((options)["bootstrapManifestPath"], "bootstrapManifestPath")));
288
295
  })(snapshot(object_options(input))));
289
296
  }
290
297
  function cancel_target_entry(result, entry, signal) {
@@ -316,9 +323,9 @@ async function run_target_entry(options, run_cell, result, entry) {
316
323
  }
317
324
  if (__eliscript_truthy((metadata)["corpusSelection"])) {
318
325
  {
319
- const __eliscript_value_18 = (metadata)["corpusSelection"];
326
+ const __eliscript_value_20 = (metadata)["corpusSelection"];
320
327
  {
321
- let selection = __eliscript_value_18;
328
+ let selection = __eliscript_value_20;
322
329
  ((entry)["corpusSelection"] = selection);
323
330
  ((entry)["effectiveCount"] = (((selection)["effectiveIds"]) ?? []).length);
324
331
  ((entry)["cancelledCount"] = (((selection)["cancelled"]) ?? []).length);
@@ -336,7 +343,7 @@ async function run_target_entry(options, run_cell, result, entry) {
336
343
  }
337
344
  }
338
345
  if (((entry)["status"] === "failed")) {
339
- return ((__eliscript_value_19) => { throw __eliscript_value_19; })(new (globalThis.Error)(("stage3 " + target + " output acceptance failed; see " + (entry)["manifestPath"])));
346
+ return ((__eliscript_value_21) => { throw __eliscript_value_21; })(new (globalThis.Error)(("stage3 " + target + " output acceptance failed; see " + (entry)["manifestPath"])));
340
347
  } else {
341
348
  return null;
342
349
  }
@@ -457,7 +464,7 @@ async function runStage3Targets(input) {
457
464
  ((summary)["functionalVerification"] = (((summary)["verification"] === "equivalent") ? "passed" : "unverified"));
458
465
  await (saveCompilerMetadata(summary_path, summary));
459
466
  if (__eliscript_truthy((result)["hasFailure"])) {
460
- ((__eliscript_value_20) => { throw __eliscript_value_20; })((result)["failure"]);
467
+ ((__eliscript_value_22) => { throw __eliscript_value_22; })((result)["failure"]);
461
468
  }
462
469
  return summary_path;
463
470
  })(await (run_stage3_target_schedule(schedule_options, (async (call) => {
@@ -1,37 +0,0 @@
1
- #!/usr/bin/env node
2
- //
3
- // Node entry point for the packaged command line.
4
- //
5
- // The shell wrappers beside this file locate the checkout through their own
6
- // path and default to Bun. An installed package has neither a checkout URL nor
7
- // a guaranteed Bun, so this entry derives the package root from its own
8
- // location, defaults to the Node runtime it is already running under, and
9
- // dispatches on the name the command was invoked as. Every name in `bin` points
10
- // here.
11
-
12
- import { basename, dirname, resolve } from "node:path";
13
- import { fileURLToPath } from "node:url";
14
-
15
- const here = dirname(fileURLToPath(import.meta.url));
16
- const root = resolve(here, "../..");
17
-
18
- // The generated compiler sits beside the package. The shell wrappers read the
19
- // same variable, so both entry points agree on one location.
20
- process.env.ELISCRIPT_BOOTSTRAP_MODULE_DIR ??= resolve(root, "dist/bootstrap");
21
-
22
- const commands = {
23
- "eliscript": ["bun.mjs", "eliscript"],
24
- "eliscript-build": ["project-cli.mjs", "eliscript-build"],
25
- "eliscript-check": ["check-cli.mjs", "eliscript-check"],
26
- "eliscript-format": ["format-cli.mjs", "eliscript-format"],
27
- "eliscript-eval": ["evaluation-cli.mjs", "eliscript-eval"],
28
- "eliscript-watch": ["watch-cli.mjs", "eliscript-watch"],
29
- "eliscript-compiler": ["../../tools/backends/compiler-cli.mjs", "eliscript-compiler"],
30
- };
31
-
32
- const invoked = basename(process.argv[1] ?? "");
33
- const [entry, commandName] = commands[invoked] ?? commands.eliscript;
34
- process.env.ELISCRIPT_COMMAND_NAME ??= commandName;
35
-
36
- const { main } = await import(new URL(`./${entry}`, import.meta.url));
37
- await main(process.argv.slice(2));