lemmascript 0.5.1 → 0.5.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.
- package/README.md +13 -4
- package/package.json +3 -2
- package/tools/dist/autohavoc.js +536 -0
- package/tools/dist/dafny-emit.js +87 -13
- package/tools/dist/extract.js +175 -16
- package/tools/dist/lean-emit.js +69 -9
- package/tools/dist/lsc.js +5 -1
- package/tools/dist/narrow.js +32 -4
- package/tools/dist/peephole.js +3 -0
- package/tools/dist/resolve.js +103 -10
- package/tools/dist/transform.js +99 -10
- package/tools/dist/typedir.js +4 -1
- package/tools/dist/types.js +12 -2
package/tools/dist/typedir.js
CHANGED
|
@@ -4,4 +4,7 @@
|
|
|
4
4
|
* Produced by the resolve pass. Consumed by the transform.
|
|
5
5
|
* Still TS-shaped (not Lean-shaped).
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
/** True for an int/nat that came from a TS `bigint` (integer division semantics). */
|
|
8
|
+
export function isBigInt(ty) {
|
|
9
|
+
return (ty.kind === "int" || ty.kind === "nat") && !!ty.big;
|
|
10
|
+
}
|
package/tools/dist/types.js
CHANGED
|
@@ -32,6 +32,11 @@ export function parseTsType(tsType) {
|
|
|
32
32
|
function tyFromTypeNode(tn) {
|
|
33
33
|
if (Node.isParenthesizedTypeNode(tn))
|
|
34
34
|
return tyFromTypeNode(tn.getTypeNode());
|
|
35
|
+
// `readonly T[]` / `readonly [A, B]` — the modifier is a TypeOperator wrapping
|
|
36
|
+
// the array/tuple; verification treats it identically to the mutable form.
|
|
37
|
+
if (Node.isTypeOperatorTypeNode(tn) && tn.getOperator() === SyntaxKind.ReadonlyKeyword) {
|
|
38
|
+
return tyFromTypeNode(tn.getTypeNode());
|
|
39
|
+
}
|
|
35
40
|
if (Node.isUnionTypeNode(tn)) {
|
|
36
41
|
const arms = tn.getTypeNodes();
|
|
37
42
|
const isBoolLit = (a) => Node.isLiteralTypeNode(a) && (a.getLiteral().getKind() === SyntaxKind.TrueKeyword || a.getLiteral().getKind() === SyntaxKind.FalseKeyword);
|
|
@@ -91,8 +96,9 @@ function tyFromTypeNode(tn) {
|
|
|
91
96
|
}
|
|
92
97
|
switch (tn.getKind()) {
|
|
93
98
|
case SyntaxKind.NumberKeyword:
|
|
94
|
-
case SyntaxKind.BigIntKeyword:
|
|
95
99
|
return { kind: "int" };
|
|
100
|
+
case SyntaxKind.BigIntKeyword:
|
|
101
|
+
return { kind: "int", big: true };
|
|
96
102
|
case SyntaxKind.BooleanKeyword:
|
|
97
103
|
return { kind: "bool" };
|
|
98
104
|
case SyntaxKind.StringKeyword:
|
|
@@ -109,7 +115,11 @@ function tyFromTypeNode(tn) {
|
|
|
109
115
|
const args = tn.getTypeArguments();
|
|
110
116
|
if (name === "nat" && args.length === 0)
|
|
111
117
|
return { kind: "nat" };
|
|
112
|
-
if (name === "
|
|
118
|
+
if (name === "real" && args.length === 0)
|
|
119
|
+
return { kind: "real" };
|
|
120
|
+
if (name === "int" && args.length === 0)
|
|
121
|
+
return { kind: "int" };
|
|
122
|
+
if ((name === "Array" || name === "ReadonlyArray") && args.length === 1)
|
|
113
123
|
return { kind: "array", elem: tyFromTypeNode(args[0]) };
|
|
114
124
|
if (name === "Set" && args.length === 1)
|
|
115
125
|
return { kind: "set", elem: tyFromTypeNode(args[0]) };
|