gdp-wired 0.54.1 → 0.54.2
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/core/c/reader.js +68 -9
- package/package.json +1 -1
package/dist/core/c/reader.js
CHANGED
|
@@ -143,10 +143,16 @@ function locate(root) {
|
|
|
143
143
|
}
|
|
144
144
|
// (doc comments, FullComment and its parts, are no code)
|
|
145
145
|
// (a for's absent parts are empty objects, kind-less)
|
|
146
|
-
else if (k === 'inner') {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
else if (k === 'inner' || k === 'array_filler') {
|
|
147
|
+
const val = n[k];
|
|
148
|
+
if (Array.isArray(val)) {
|
|
149
|
+
const filtered = val.filter(c => !(c.kind ?? '').endsWith('Comment'));
|
|
150
|
+
n[k] = filtered;
|
|
151
|
+
for (const c of filtered)
|
|
152
|
+
walk(c);
|
|
153
|
+
}
|
|
154
|
+
else if (val && typeof val === 'object')
|
|
155
|
+
walk(val);
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
158
|
n.$at ??= n.$b;
|
|
@@ -680,6 +686,42 @@ export function readC(file, entry, tu, target, cpp = false, root, picks = {}, pi
|
|
|
680
686
|
// (a float's value: left out, a value nothing the rule keeps may read; one read into an integer, a condition or a
|
|
681
687
|
// comparison is refused there. Its operands are the code's measurements: an assignment or a call of the file's own
|
|
682
688
|
// inside it is refused, its effect would be lost.)
|
|
689
|
+
// Clang's JSON AST emits array_filler as [filler, ...semanticInits] with no inner key when an
|
|
690
|
+
// InitListExpr has an array filler (partial or designated initializers). Handle both that form
|
|
691
|
+
// and a separated array_filler + inner form, and refuse unknown/union shapes.
|
|
692
|
+
const initListChildren = (n) => {
|
|
693
|
+
if (n.kind !== 'InitListExpr' || 'field' in n)
|
|
694
|
+
return undefined;
|
|
695
|
+
const rawFiller = n.array_filler;
|
|
696
|
+
if (rawFiller === undefined)
|
|
697
|
+
return { elems: n.inner ?? [] };
|
|
698
|
+
if (Array.isArray(rawFiller)) {
|
|
699
|
+
if (!rawFiller.length)
|
|
700
|
+
return undefined;
|
|
701
|
+
if (n.inner === undefined)
|
|
702
|
+
return { filler: rawFiller[0], elems: rawFiller.slice(1) };
|
|
703
|
+
if (rawFiller.length === 1)
|
|
704
|
+
return { filler: rawFiller[0], elems: n.inner };
|
|
705
|
+
return undefined;
|
|
706
|
+
}
|
|
707
|
+
if (typeof rawFiller === 'object' && rawFiller !== null && 'kind' in rawFiller && n.inner !== undefined)
|
|
708
|
+
return { filler: rawFiller, elems: n.inner };
|
|
709
|
+
return undefined;
|
|
710
|
+
};
|
|
711
|
+
const isAllZeroInit = (n0) => {
|
|
712
|
+
const n = strip(n0);
|
|
713
|
+
if (n.kind === 'ImplicitValueInitExpr')
|
|
714
|
+
return true;
|
|
715
|
+
if (n.kind === 'InitListExpr') {
|
|
716
|
+
const il = initListChildren(n);
|
|
717
|
+
if (!il)
|
|
718
|
+
return false;
|
|
719
|
+
if (il.filler && strip(il.filler).kind !== 'ImplicitValueInitExpr')
|
|
720
|
+
return false;
|
|
721
|
+
return il.elems.every(isAllZeroInit);
|
|
722
|
+
}
|
|
723
|
+
return fold(n) === 0;
|
|
724
|
+
};
|
|
683
725
|
// A constant table read at indices (a transition table, a lookup; a const or constexpr array, a class's static one):
|
|
684
726
|
// its entry by cases on the indices, each index outside its dimension undefined behavior, the step's failure (checked
|
|
685
727
|
// before the statement, so the index must be free of side effects and read where the statement surely reads it).
|
|
@@ -707,12 +749,27 @@ export function readC(file, entry, tu, target, cpp = false, root, picks = {}, pi
|
|
|
707
749
|
if (dims.length !== idx.length || !['int', 'bool'].includes(T(t).k))
|
|
708
750
|
return no(n, `${text(n)}: a table read other than at every one of its dimensions`);
|
|
709
751
|
const val = (v, path, k) => {
|
|
752
|
+
if (!v)
|
|
753
|
+
return NaN;
|
|
754
|
+
const s0 = strip(v);
|
|
755
|
+
if (s0.kind === 'ImplicitValueInitExpr')
|
|
756
|
+
return 0;
|
|
710
757
|
if (k === dims.length) {
|
|
711
|
-
const f =
|
|
758
|
+
const f = fold(s0);
|
|
712
759
|
return f ?? NaN;
|
|
713
760
|
}
|
|
714
|
-
const
|
|
715
|
-
|
|
761
|
+
const il = initListChildren(s0);
|
|
762
|
+
if (!il)
|
|
763
|
+
return NaN;
|
|
764
|
+
const { elems, filler } = il;
|
|
765
|
+
if (elems.length > dims[k] || elems.some(c => c.kind === 'DesignatedInitExpr' || c.kind === 'DesignatedInitUpdateExpr' || c.kind === 'NoInitExpr'))
|
|
766
|
+
return NaN;
|
|
767
|
+
if (filler && strip(filler).kind !== 'ImplicitValueInitExpr')
|
|
768
|
+
return NaN;
|
|
769
|
+
if (elems.length < dims[k] && !filler)
|
|
770
|
+
return NaN;
|
|
771
|
+
const i = path[k];
|
|
772
|
+
return val(i < elems.length ? elems[i] : filler, path, k + 1);
|
|
716
773
|
};
|
|
717
774
|
if (idx.some(effects))
|
|
718
775
|
return no(n, `${text(n)}: a table read at an index with a side effect`);
|
|
@@ -881,6 +938,8 @@ export function readC(file, entry, tu, target, cpp = false, root, picks = {}, pi
|
|
|
881
938
|
case 'CompoundLiteralExpr': return x(kids[0]);
|
|
882
939
|
case 'InitListExpr': {
|
|
883
940
|
// A struct's initializer: clang's semantic form lists every field, one not given an implicit zero.
|
|
941
|
+
if (n.array_filler !== undefined)
|
|
942
|
+
return no(n, `${text(n)}: an array initializer of a ${n.type.qualType}`);
|
|
884
943
|
const tt = T(t);
|
|
885
944
|
// (a scalar's braces, C++'s {v} and {})
|
|
886
945
|
if ((tt.k === 'int' || tt.k === 'bool') && kids.length <= 1)
|
|
@@ -1199,7 +1258,7 @@ export function readC(file, entry, tu, target, cpp = false, root, picks = {}, pi
|
|
|
1199
1258
|
const pre = [];
|
|
1200
1259
|
for (const g of gnodes) {
|
|
1201
1260
|
const v = g.init ? (g.inner ?? []).find(c => !c.kind.endsWith('Attr')) : undefined, t = tyOf(g.type);
|
|
1202
|
-
const empty = !v || (
|
|
1261
|
+
const empty = !v || isAllZeroInit(v);
|
|
1203
1262
|
// (C's zero, leaf by leaf: each integer and boolean of it 0, an array a list of zeros already)
|
|
1204
1263
|
const zeros = (tt, place) => {
|
|
1205
1264
|
const k = T(tt).k;
|
|
@@ -1234,7 +1293,7 @@ export function readC(file, entry, tu, target, cpp = false, root, picks = {}, pi
|
|
|
1234
1293
|
const pre = [];
|
|
1235
1294
|
for (const [id, v0] of inits) {
|
|
1236
1295
|
const f = fieldNode.get(id), ft = T(tyOf(f.type)), v = strip(v0);
|
|
1237
|
-
if (ft.mutex || (v.kind === 'InitListExpr' && (v
|
|
1296
|
+
if (ft.mutex || (v.kind === 'InitListExpr' && isAllZeroInit(v)))
|
|
1238
1297
|
continue;
|
|
1239
1298
|
if (v.kind === 'CXXConstructExpr' && !v.inner?.length)
|
|
1240
1299
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdp-wired",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.2",
|
|
4
4
|
"description": "An automatic prover for stateful rules (budgets, caps, windows, workflows, policies): laws proven with no proof to write, checked again in Lean, counterexamples found on the GPU, the rule shipped as code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"verification",
|