@tsplc/compiler 0.5.8 → 0.5.9

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/dist/ir.js CHANGED
@@ -2290,6 +2290,9 @@ function pathConditions(routine, variables) {
2290
2290
  sequence(routine.body, [], null, job ? "jobDispatcher" : "plain");
2291
2291
  return { statements, loops, reconstruct };
2292
2292
  }
2293
+ // packages/compiler/src/ir/identity.ts
2294
+ import { createHash } from "node:crypto";
2295
+ var identityDigest = (identity) => createHash("sha256").update(identity).digest("hex").slice(0, 8);
2293
2296
  // packages/compiler/src/ir/job-errors.ts
2294
2297
  var jobError = {
2295
2298
  cancelled: 1,
@@ -2298,9 +2301,11 @@ var jobError = {
2298
2301
  malformedResponse: 4,
2299
2302
  network: 5,
2300
2303
  tls: 6,
2301
- noRequestSlot: 7
2304
+ noRequestSlot: 7,
2305
+ codeChanged: 11001
2302
2306
  };
2303
2307
  var httpErrors = { base: 1e4, last: 10999 };
2308
+ var reservedErrors = { first: 11000, last: 11099 };
2304
2309
  var jobErrors = {
2305
2310
  [jobError.cancelled]: "cancelled",
2306
2311
  [jobError.timeout]: "timeout",
@@ -2309,12 +2314,16 @@ var jobErrors = {
2309
2314
  [jobError.network]: "network error or server restarted",
2310
2315
  [jobError.tls]: "TLS error",
2311
2316
  [jobError.noRequestSlot]: "no free request slot",
2317
+ [jobError.codeChanged]: "an online change replaced the job's code while it ran",
2312
2318
  [httpErrors.base]: "HTTP status: 10000 + status code"
2313
2319
  };
2314
2320
  var errorName = (code) => {
2315
2321
  if (code > httpErrors.base && code <= httpErrors.last) {
2316
2322
  return `HTTP ${code - httpErrors.base}`;
2317
2323
  }
2324
+ if (code >= reservedErrors.first && code <= reservedErrors.last) {
2325
+ return jobErrors[code];
2326
+ }
2318
2327
  return code < httpErrors.base ? jobErrors[code] : undefined;
2319
2328
  };
2320
2329
  // packages/compiler/src/ir/layouts.ts
@@ -3409,45 +3418,6 @@ function rewriteStatement(item, rewrite, expression, statements) {
3409
3418
  return item;
3410
3419
  }
3411
3420
  }
3412
- var returns = (items) => items.some((item) => item.kind === "return" || nestedBodies(item).some(returns));
3413
- function joinPrograms(core, groups) {
3414
- const functions = new Map(core.functions.map((fn) => [fn.id, fn]));
3415
- const programs = new Map(core.programs.map((item) => [item.name, item]));
3416
- const joined = new Map;
3417
- const routines = new Map;
3418
- const removed = new Set;
3419
- for (const group of groups) {
3420
- const members = group.flatMap((name) => {
3421
- const program = programs.get(name);
3422
- const entry = program && functions.get(program.entry);
3423
- return program && entry && !returns(entry.body) ? [{ program, entry }] : [];
3424
- });
3425
- const [first, ...rest] = members;
3426
- if (!first || !rest.length) {
3427
- continue;
3428
- }
3429
- joined.set(first.entry.id, {
3430
- ...first.entry,
3431
- locals: members.flatMap(({ entry }) => entry.locals),
3432
- body: members.flatMap(({ entry }) => entry.body)
3433
- });
3434
- for (const { program, entry } of rest) {
3435
- removed.add(program.name);
3436
- routines.set(entry.id, first.entry.id);
3437
- }
3438
- }
3439
- if (!routines.size) {
3440
- return { core, routines };
3441
- }
3442
- return {
3443
- core: admitCore({
3444
- ...core,
3445
- functions: core.functions.flatMap((fn) => routines.has(fn.id) ? [] : [joined.get(fn.id) ?? fn]),
3446
- programs: core.programs.filter((item) => !removed.has(item.name))
3447
- }),
3448
- routines
3449
- };
3450
- }
3451
3421
  function constantResult(fn) {
3452
3422
  const [only, ...rest] = fn.body;
3453
3423
  if (rest.length || fn.owner) {
@@ -3734,6 +3704,7 @@ export {
3734
3704
  forwardTemporaries,
3735
3705
  hasErrors,
3736
3706
  httpErrors,
3707
+ identityDigest,
3737
3708
  instancedBlock,
3738
3709
  integerRange,
3739
3710
  integerType,
@@ -3741,7 +3712,6 @@ export {
3741
3712
  isVerifiedCore,
3742
3713
  jobError,
3743
3714
  jobErrors,
3744
- joinPrograms,
3745
3715
  layoutIssue,
3746
3716
  loopBounds,
3747
3717
  maxLoopIterations,
@@ -3757,6 +3727,7 @@ export {
3757
3727
  placeType,
3758
3728
  primitiveTypes,
3759
3729
  projectReconstruction,
3730
+ reservedErrors,
3760
3731
  scalarIssue,
3761
3732
  shareRoutines,
3762
3733
  standardBlocks,
@@ -3768,5 +3739,5 @@ export {
3768
3739
  wrapsNatively
3769
3740
  };
3770
3741
 
3771
- //# debugId=1D832A6B2CC6ECA364756E2164756E21
3742
+ //# debugId=90C65AB54AB03BAA64756E2164756E21
3772
3743
  //# sourceMappingURL=ir.js.map