tla-ts 0.0.10-dev.28c823e4b → 0.0.10-dev.f16792fed
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/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/prove.cjs +47 -47
- package/dist/prove.js +46 -46
- package/dist/run.cjs +30 -30
- package/dist/run.js +28 -28
- package/dist/transfer.cjs +27 -27
- package/dist/transfer.js +27 -27
- package/package.json +1 -1
- package/src/cli/options.ts +1 -1
- package/src/coverage.ts +3 -8
- package/src/java-hash.ts +7 -0
- package/src/sany/nodes.ts +4 -10
- package/src/state-graph.ts +2 -7
- package/src/tlc/order.ts +2 -9
- package/src/tlc/trace-spec.ts +4 -5
- package/src/values.ts +1 -6
package/package.json
CHANGED
package/src/cli/options.ts
CHANGED
|
@@ -60,7 +60,7 @@ export const defineCommand = (usage: string, specs: OptionSpec[]) => {
|
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
const CHECK_COMMAND = defineCommand("tla-ts <Spec.tla|Spec.cfg|spec.ts|glob>... {options}", [
|
|
64
64
|
{ flag: "-config <Spec.cfg>" },
|
|
65
65
|
{ flag: "-continue" },
|
|
66
66
|
{ flag: "-deadlock" },
|
package/src/coverage.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from "./ast";
|
|
9
9
|
import { formatRange } from "./errors";
|
|
10
10
|
import type { Environment, Scope } from "./evaluate";
|
|
11
|
+
import { getJavaHashCode } from "./java-hash";
|
|
11
12
|
import { getTlcFingerprint } from "./tlc/fingerprint";
|
|
12
13
|
import type { Value } from "./values";
|
|
13
14
|
|
|
@@ -204,12 +205,6 @@ const getStartRange = (location: SourceLocation, last: SourceRange | undefined)
|
|
|
204
205
|
end: last.end,
|
|
205
206
|
};
|
|
206
207
|
|
|
207
|
-
const getJavaHashCode = (text: string) =>
|
|
208
|
-
Array.from({ length: text.length }, (_value, index) => text.charCodeAt(index)).reduce(
|
|
209
|
-
(hash, code) => (Math.imul(hash, 31) + code) | 0,
|
|
210
|
-
0,
|
|
211
|
-
) & 0x7fffffff;
|
|
212
|
-
|
|
213
208
|
const getHashtableOrder = (definitions: Definition[]) => {
|
|
214
209
|
let buckets = Array.from({ length: 11 }, (): Definition[] => []);
|
|
215
210
|
definitions.forEach((definition, count) => {
|
|
@@ -217,12 +212,12 @@ const getHashtableOrder = (definitions: Definition[]) => {
|
|
|
217
212
|
const grown = Array.from({ length: buckets.length * 2 + 1 }, (): Definition[] => []);
|
|
218
213
|
for (let index = buckets.length - 1; index >= 0; index--) {
|
|
219
214
|
buckets[index].forEach((entry) =>
|
|
220
|
-
grown[getJavaHashCode(entry.name) % grown.length].unshift(entry),
|
|
215
|
+
grown[(getJavaHashCode(entry.name) & 0x7fffffff) % grown.length].unshift(entry),
|
|
221
216
|
);
|
|
222
217
|
}
|
|
223
218
|
buckets = grown;
|
|
224
219
|
}
|
|
225
|
-
buckets[getJavaHashCode(definition.name) % buckets.length].unshift(definition);
|
|
220
|
+
buckets[(getJavaHashCode(definition.name) & 0x7fffffff) % buckets.length].unshift(definition);
|
|
226
221
|
});
|
|
227
222
|
return buckets.toReversed().flat();
|
|
228
223
|
};
|
package/src/java-hash.ts
ADDED
package/src/sany/nodes.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getJavaHashCode } from "../java-hash";
|
|
2
|
+
|
|
1
3
|
export interface SanyLocation {
|
|
2
4
|
file: string;
|
|
3
5
|
beginLine: number;
|
|
@@ -343,14 +345,6 @@ interface JavaHashtable {
|
|
|
343
345
|
threshold: number;
|
|
344
346
|
}
|
|
345
347
|
|
|
346
|
-
const getJavaHash = (text: string) => {
|
|
347
|
-
let hash = 0;
|
|
348
|
-
for (let index = 0; index < text.length; index++) {
|
|
349
|
-
hash = (Math.imul(hash, 31) + text.charCodeAt(index)) | 0;
|
|
350
|
-
}
|
|
351
|
-
return hash;
|
|
352
|
-
};
|
|
353
|
-
|
|
354
348
|
const createJavaHashtable = (): JavaHashtable => ({
|
|
355
349
|
buckets: Array.from({ length: 11 }, () => []),
|
|
356
350
|
count: 0,
|
|
@@ -372,12 +366,12 @@ const rehash = (table: JavaHashtable) => {
|
|
|
372
366
|
};
|
|
373
367
|
|
|
374
368
|
const getHashtableValue = (table: JavaHashtable, key: string, hashKey = key) =>
|
|
375
|
-
table.buckets[getBucketIndex(
|
|
369
|
+
table.buckets[getBucketIndex(getJavaHashCode(hashKey), table.buckets.length)].find(
|
|
376
370
|
(entry) => entry.key === key,
|
|
377
371
|
)?.value;
|
|
378
372
|
|
|
379
373
|
const putHashtableValue = (table: JavaHashtable, key: string, value: SymbolNode, hashKey = key) => {
|
|
380
|
-
const hash =
|
|
374
|
+
const hash = getJavaHashCode(hashKey);
|
|
381
375
|
const existing = table.buckets[getBucketIndex(hash, table.buckets.length)].find(
|
|
382
376
|
(entry) => entry.key === key,
|
|
383
377
|
);
|
package/src/state-graph.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// A port of TLC's -dump writers, tlc2.util.StateWriter and tlc2.util.DotStateWriter.
|
|
2
2
|
|
|
3
|
+
import { getJavaHashCode } from "./java-hash";
|
|
3
4
|
import type { TlcVersion } from "./tlc/version";
|
|
4
5
|
|
|
5
6
|
export interface StateDump {
|
|
@@ -67,12 +68,6 @@ const getJavaHashOrder = <Key>(keys: Key[], getHash: (key: Key) => number) => {
|
|
|
67
68
|
const getLongHash = (value: bigint) =>
|
|
68
69
|
Number(BigInt.asIntN(32, value ^ (BigInt.asUintN(64, value) >> 32n)));
|
|
69
70
|
|
|
70
|
-
const getStringHash = (text: string) =>
|
|
71
|
-
[...Array(text.length).keys()].reduce(
|
|
72
|
-
(hash, index) => (Math.imul(31, hash) + text.charCodeAt(index)) | 0,
|
|
73
|
-
0,
|
|
74
|
-
);
|
|
75
|
-
|
|
76
71
|
const escapeDotString = (text: string) =>
|
|
77
72
|
text.replaceAll("\\", "\\\\").replaceAll('"', '\\"').trim();
|
|
78
73
|
|
|
@@ -132,7 +127,7 @@ const createDotWriter = (
|
|
|
132
127
|
[
|
|
133
128
|
`subgraph cluster_legend {graph[style=bold];label = "Next State Actions" style="solid"\n`,
|
|
134
129
|
`node [ labeljust="l",colorscheme="${COLOR_SCHEME}",style=filled,shape=record ]\n`,
|
|
135
|
-
...getJavaHashOrder([...colors.keys()],
|
|
130
|
+
...getJavaHashOrder([...colors.keys()], getJavaHashCode).map(
|
|
136
131
|
(name) => `${name.replaceAll("!", ":")} [label="${name}",fillcolor=${colors.get(name)}]\n`,
|
|
137
132
|
),
|
|
138
133
|
"}",
|
package/src/tlc/order.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Module, SourceLocation } from "../ast";
|
|
2
2
|
import type { ConfigValue, ModelConfig } from "../config";
|
|
3
3
|
import { createMissingModuleError } from "../errors";
|
|
4
|
+
import { getJavaHashCode } from "../java-hash";
|
|
4
5
|
import { tokenize, type Token } from "../lexer";
|
|
5
6
|
import { extractModule, parseModule, parseModuleTokens } from "../parser";
|
|
6
7
|
import { isBefore } from "../resolve";
|
|
@@ -55,14 +56,6 @@ const CANONICAL_OPERATORS = new Map(
|
|
|
55
56
|
|
|
56
57
|
const getCanonicalName = (name: string) => CANONICAL_OPERATORS.get(name) ?? name;
|
|
57
58
|
|
|
58
|
-
const getJavaHash = (text: string) => {
|
|
59
|
-
let hash = 0;
|
|
60
|
-
for (let index = 0; index < text.length; index++) {
|
|
61
|
-
hash = (Math.imul(hash, 31) + text.charCodeAt(index)) | 0;
|
|
62
|
-
}
|
|
63
|
-
return hash;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
59
|
const createSymbolTable = (): SymbolTable => {
|
|
67
60
|
let buckets: SymbolEntry[][] = Array.from({ length: 11 }, () => []);
|
|
68
61
|
let threshold = 8;
|
|
@@ -102,7 +95,7 @@ const createSymbolTable = (): SymbolTable => {
|
|
|
102
95
|
const createEntry = (name: string, kind: SymbolKind, isLocal: boolean): SymbolEntry => ({
|
|
103
96
|
key: kind === "module" ? `module ${name}` : name,
|
|
104
97
|
name,
|
|
105
|
-
hash:
|
|
98
|
+
hash: getJavaHashCode(name) & 0x7fffffff,
|
|
106
99
|
kind,
|
|
107
100
|
isLocal,
|
|
108
101
|
});
|
package/src/tlc/trace-spec.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getJavaHashCode } from "../java-hash";
|
|
1
2
|
import { formatValue, type Value } from "../values";
|
|
2
3
|
|
|
3
4
|
interface TraceSpecInput {
|
|
@@ -23,10 +24,8 @@ const CLOSING_TAG = `${"=".repeat(77)}\n`;
|
|
|
23
24
|
const LASSO_START = "_TTraceLassoStart";
|
|
24
25
|
const LASSO_END = "_TTraceLassoEnd";
|
|
25
26
|
|
|
26
|
-
const
|
|
27
|
-
const hash = text
|
|
28
|
-
.split("")
|
|
29
|
-
.reduce((current, unit) => (Math.imul(current, 31) + unit.charCodeAt(0)) | 0, 0);
|
|
27
|
+
const getHashMapHash = (text: string) => {
|
|
28
|
+
const hash = getJavaHashCode(text);
|
|
30
29
|
return hash ^ (hash >>> 16);
|
|
31
30
|
};
|
|
32
31
|
|
|
@@ -34,7 +33,7 @@ const getHashOrder = (names: string[]) => {
|
|
|
34
33
|
const unique = [...new Set(names)];
|
|
35
34
|
const capacity = 2 ** Math.max(4, Math.ceil(Math.log2(unique.length / 0.75)));
|
|
36
35
|
return unique
|
|
37
|
-
.map((name, index) => ({ name, index, bucket:
|
|
36
|
+
.map((name, index) => ({ name, index, bucket: getHashMapHash(name) & (capacity - 1) }))
|
|
38
37
|
.sort((left, right) => left.bucket - right.bucket || left.index - right.index)
|
|
39
38
|
.map((entry) => entry.name);
|
|
40
39
|
};
|
package/src/values.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TlaModuleError,
|
|
7
7
|
TlaSetBoundError,
|
|
8
8
|
} from "./errors";
|
|
9
|
+
import { getJavaHashCode } from "./java-hash";
|
|
9
10
|
import { prettyPrint } from "./pretty-print";
|
|
10
11
|
import { isEvalException } from "./tlc/messages";
|
|
11
12
|
import type { TlcVersion } from "./tlc/version";
|
|
@@ -3123,12 +3124,6 @@ const isUnchanged = (previous: Value | undefined, value: Value) => {
|
|
|
3123
3124
|
|
|
3124
3125
|
const JAVA_FORMAT_SPECIFIER = /%(\d+\$)?([-#+ 0,(<]*)(\d+)?(\.\d+)?(.?)/gs;
|
|
3125
3126
|
|
|
3126
|
-
const getJavaHashCode = (text: string) =>
|
|
3127
|
-
Array.from({ length: text.length }, (_value, index) => text.charCodeAt(index)).reduce(
|
|
3128
|
-
(hash, unit) => (Math.imul(hash, 31) + unit) | 0,
|
|
3129
|
-
0,
|
|
3130
|
-
);
|
|
3131
|
-
|
|
3132
3127
|
const formatJava = (format: string, args: string[]) => {
|
|
3133
3128
|
let nextIndex = 0;
|
|
3134
3129
|
let lastIndex = -1;
|