tla-ts 0.0.3-dev.52c5b61 → 0.0.3-dev.596cd91
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 +12 -12
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +150 -8
- package/dist/index.d.ts +150 -8
- package/dist/index.js +1 -1
- package/dist/parallel-worker.cjs +1 -1
- package/dist/parallel-worker.js +2 -2
- package/dist/parallel.cjs +1 -1
- package/dist/parallel.js +2 -2
- package/dist/run-cli.cjs +45 -19
- package/dist/run-cli.js +45 -19
- package/dist/transfer.cjs +1391 -28
- package/dist/transfer.js +1391 -28
- package/package.json +5 -1
- package/src/ast.ts +57 -6
- package/src/bags.ts +4 -7
- package/src/builtins.ts +29 -11
- package/src/bundled-modules.ts +3 -3
- package/src/canonical.ts +4 -3
- package/src/check.ts +1396 -227
- package/src/cli.ts +8 -1
- package/src/codegen.ts +68 -18
- package/src/config.ts +254 -181
- package/src/environment.ts +494 -129
- package/src/errors.ts +217 -3
- package/src/evaluate.ts +722 -112
- package/src/exit-codes.ts +5 -4
- package/src/index.ts +1 -0
- package/src/instances.ts +4 -2
- package/src/java-overrides.ts +104 -25
- package/src/levels.ts +183 -37
- package/src/lexer.ts +122 -29
- package/src/live-check.ts +220 -102
- package/src/liveness.ts +216 -52
- package/src/obligation-expression.ts +2 -2
- package/src/obligation-source.ts +2 -0
- package/src/parallel-worker.ts +8 -3
- package/src/parallel.ts +56 -5
- package/src/parser.ts +445 -147
- package/src/pcal-ast.ts +770 -0
- package/src/pcal-parse.ts +1523 -0
- package/src/pcal-tokenize.ts +516 -0
- package/src/pcal-translate.ts +1230 -0
- package/src/pcal-validate.ts +454 -0
- package/src/randomization.ts +24 -7
- package/src/resolve.ts +1465 -411
- package/src/run-cli.ts +1179 -155
- package/src/runtime.ts +18 -0
- package/src/sany-builtins.ts +147 -0
- package/src/sany-generator.ts +3128 -0
- package/src/sany-levels.ts +1208 -0
- package/src/sany-lexer.ts +545 -0
- package/src/sany-linter.ts +122 -0
- package/src/sany-modules.ts +1398 -0
- package/src/sany-nodes.ts +463 -0
- package/src/sany-parse-error.ts +2161 -0
- package/src/sany-report.ts +356 -0
- package/src/sany-selectors.ts +738 -0
- package/src/sany-source.ts +248 -0
- package/src/sany-xml.ts +1017 -0
- package/src/spec-description.ts +26 -7
- package/src/standard-modules.ts +200 -148
- package/src/standard-ranges.ts +116 -0
- package/src/state-graph.ts +29 -6
- package/src/subexpressions.ts +221 -161
- package/src/substitution-levels.ts +38 -17
- package/src/successors.ts +207 -103
- package/src/symmetry.ts +180 -52
- package/src/tableau.ts +54 -25
- package/src/tlc-ext.ts +13 -17
- package/src/tlc-messages.ts +329 -0
- package/src/tlc-module.ts +49 -15
- package/src/tlc-modules.ts +4 -0
- package/src/tlc-order.ts +61 -7
- package/src/tlc-random.ts +37 -9
- package/src/tlc-replay.ts +655 -0
- package/src/tlc-summary.ts +20 -5
- package/src/tlc-version.ts +18 -0
- package/src/transfer.ts +15 -3
- package/src/value-sources.ts +29 -0
- package/src/values.ts +713 -180
package/src/transfer.ts
CHANGED
|
@@ -2,8 +2,11 @@ import {
|
|
|
2
2
|
createModelValue,
|
|
3
3
|
createSortedFunction,
|
|
4
4
|
createSortedSet,
|
|
5
|
+
type FunctionClass,
|
|
5
6
|
getDomainInterval,
|
|
7
|
+
getFunctionClass,
|
|
6
8
|
getFunctionDomain,
|
|
9
|
+
setFunctionClass,
|
|
7
10
|
type Value,
|
|
8
11
|
} from "./values";
|
|
9
12
|
|
|
@@ -16,6 +19,9 @@ const SET = 5;
|
|
|
16
19
|
const FUNCTION = 6;
|
|
17
20
|
const INTERVAL_FUNCTION = 7;
|
|
18
21
|
|
|
22
|
+
// A function's TLC class follows its tag, so a worker words errors about it as TLC does.
|
|
23
|
+
const FUNCTION_CLASSES: (FunctionClass | undefined)[] = [undefined, "lambda", "tuple", "record"];
|
|
24
|
+
|
|
19
25
|
export interface EncodedStates {
|
|
20
26
|
words: Int32Array;
|
|
21
27
|
strings: string[];
|
|
@@ -76,11 +82,13 @@ export const createStateEncoder = (): StateEncoder => {
|
|
|
76
82
|
const interval = getDomainInterval(value.domain);
|
|
77
83
|
if (interval) {
|
|
78
84
|
push(INTERVAL_FUNCTION);
|
|
85
|
+
push(FUNCTION_CLASSES.indexOf(getFunctionClass(value)));
|
|
79
86
|
push(interval.low);
|
|
80
87
|
push(value.range.length);
|
|
81
88
|
return value.range.every(encodeValue);
|
|
82
89
|
}
|
|
83
90
|
push(FUNCTION);
|
|
91
|
+
push(FUNCTION_CLASSES.indexOf(getFunctionClass(value)));
|
|
84
92
|
push(value.domain.length);
|
|
85
93
|
return value.domain.every(encodeValue) && value.range.every(encodeValue);
|
|
86
94
|
}
|
|
@@ -117,16 +125,20 @@ export const createStateDecoder =
|
|
|
117
125
|
if (tag === INTEGER) return words[cursor.index++];
|
|
118
126
|
if (tag === STRING) return encoded.strings[words[cursor.index++]];
|
|
119
127
|
if (tag === MODEL_VALUE) return createModelValue(encoded.strings[words[cursor.index++]]);
|
|
128
|
+
if (tag === SET) return createSortedSet(decodeElements(words[cursor.index++]));
|
|
129
|
+
const functionClass = FUNCTION_CLASSES[words[cursor.index++]];
|
|
120
130
|
if (tag === INTERVAL_FUNCTION) {
|
|
121
131
|
const low = words[cursor.index++];
|
|
122
132
|
const length = words[cursor.index++];
|
|
123
133
|
const domain = getFunctionDomain({ kind: "Interval", low, high: low + length - 1 });
|
|
124
|
-
return
|
|
134
|
+
return setFunctionClass(
|
|
135
|
+
createSortedFunction(domain, decodeElements(length)),
|
|
136
|
+
functionClass,
|
|
137
|
+
);
|
|
125
138
|
}
|
|
126
139
|
const length = words[cursor.index++];
|
|
127
|
-
if (tag === SET) return createSortedSet(decodeElements(length));
|
|
128
140
|
const domain = decodeElements(length);
|
|
129
|
-
return createSortedFunction(domain, decodeElements(length));
|
|
141
|
+
return setFunctionClass(createSortedFunction(domain, decodeElements(length)), functionClass);
|
|
130
142
|
};
|
|
131
143
|
return Array.from({ length: encoded.count }, () =>
|
|
132
144
|
Array.from({ length: width }, () => decodeValue()),
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Expression } from "./ast";
|
|
2
|
+
import { TlaEvaluationError } from "./errors";
|
|
3
|
+
import type { Value } from "./values";
|
|
4
|
+
|
|
5
|
+
// While TLC replays a failure, it gives each set, tuple or record it builds the expression that
|
|
6
|
+
// built it. A method of such a value that fails prepends that expression to the error's trace, and
|
|
7
|
+
// TLC reports the error as one it was unable to fingerprint.
|
|
8
|
+
export const valueSources: { current: WeakMap<object, Expression> | undefined } = {
|
|
9
|
+
current: undefined,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const fingerprintTraces = new WeakMap<TlaEvaluationError, Expression[]>();
|
|
13
|
+
|
|
14
|
+
export const getFingerprintTrace = (error: unknown) =>
|
|
15
|
+
error instanceof TlaEvaluationError ? fingerprintTraces.get(error) : undefined;
|
|
16
|
+
|
|
17
|
+
export const withSource = <T>(value: Value, run: () => T): T => {
|
|
18
|
+
const sources = valueSources.current;
|
|
19
|
+
if (!sources || typeof value !== "object") return run();
|
|
20
|
+
try {
|
|
21
|
+
return run();
|
|
22
|
+
} catch (error) {
|
|
23
|
+
const source = sources.get(value);
|
|
24
|
+
if (source && error instanceof TlaEvaluationError) {
|
|
25
|
+
fingerprintTraces.set(error, [source, ...(fingerprintTraces.get(error) ?? [])]);
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
};
|