@eagleoutice/flowr 2.13.7 → 2.13.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/README.md +23 -23
- package/dataflow/cluster.js +48 -24
- package/dataflow/environments/default-builtin-config.d.ts +30 -0
- package/dataflow/environments/default-builtin-config.js +9 -0
- package/dataflow/graph/df-helper.d.ts +13 -0
- package/dataflow/graph/df-helper.js +21 -0
- package/dataflow/graph/graph.d.ts +1 -0
- package/dataflow/graph/graph.js +21 -6
- package/linter/rules/undefined-symbol-util.d.ts +4 -1
- package/linter/rules/undefined-symbol-util.js +6 -3
- package/package.json +2 -2
- package/project/dependency-version-space.d.ts +18 -3
- package/project/dependency-version-space.js +40 -6
- package/project/plugins/package-version-plugins/package.d.ts +2 -0
- package/project/plugins/package-version-plugins/package.js +4 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +1 -9
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +4 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +25 -0
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +11 -1
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +3 -2
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -0
- package/queries/catalog/dependencies-query/dependencies-query-format.js +47 -5
- package/queries/catalog/dependencies-query/function-info/library-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +26 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +33 -31
- package/queries/catalog/dependencies-query/function-info/write-functions.js +20 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +3 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/r-bridge/data/data.d.ts +1 -1
- package/r-bridge/data/data.js +1 -1
- package/slicing/criterion/parse.d.ts +2 -1
- package/slicing/criterion/parse.js +37 -1
- package/slicing/static/fingerprint.d.ts +1 -1
- package/slicing/static/fingerprint.js +40 -8
- package/slicing/static/static-slicer.js +1 -1
- package/slicing/static/visiting-queue.d.ts +4 -2
- package/slicing/static/visiting-queue.js +10 -1
- package/util/version.js +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ It offers a wide variety of features, for example:
|
|
|
43
43
|
|
|
44
44
|
```shell
|
|
45
45
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
46
|
-
flowR repl v2.13.
|
|
46
|
+
flowR repl v2.13.7, R grammar v14 (tree-sitter engine)
|
|
47
47
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -52,7 +52,7 @@ It offers a wide variety of features, for example:
|
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
```text
|
|
55
|
-
Query: linter (
|
|
55
|
+
Query: linter (6 ms)
|
|
56
56
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
57
57
|
╰ File Path Validity (file-path-validity):
|
|
58
58
|
╰ certain:
|
|
@@ -62,7 +62,7 @@ It offers a wide variety of features, for example:
|
|
|
62
62
|
╰ Absolute Paths (absolute-file-paths):
|
|
63
63
|
╰ certain:
|
|
64
64
|
╰ Path `/root/x.txt` at 1.1-23
|
|
65
|
-
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs:
|
|
65
|
+
╰ Metadata: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 1, processTimeMs: 0
|
|
66
66
|
╰ Unused Definitions (unused-definitions): no findings
|
|
67
67
|
╰ Network Functions (network-functions): no findings
|
|
68
68
|
╰ Dataframe Access Validation (dataframe-access-validation): no findings
|
|
@@ -73,7 +73,7 @@ It offers a wide variety of features, for example:
|
|
|
73
73
|
╰ Roxygen Arguments (roxygen-arguments): no findings
|
|
74
74
|
╰ No Leaked Credentials (no-leaked-credentials): no findings
|
|
75
75
|
╰ Undefined Symbol (undefined-symbol): no findings
|
|
76
|
-
All queries together required ≈
|
|
76
|
+
All queries together required ≈6 ms (1ms accuracy, total 6 ms)
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
|
|
@@ -95,7 +95,7 @@ It offers a wide variety of features, for example:
|
|
|
95
95
|
|
|
96
96
|
_Results (prettified and summarized):_
|
|
97
97
|
|
|
98
|
-
Query: **linter** (
|
|
98
|
+
Query: **linter** (8 ms)\
|
|
99
99
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
100
100
|
╰ **File Path Validity** (file-path-validity):\
|
|
101
101
|
╰ certain:\
|
|
@@ -105,7 +105,7 @@ It offers a wide variety of features, for example:
|
|
|
105
105
|
╰ **Absolute Paths** (absolute-file-paths):\
|
|
106
106
|
╰ certain:\
|
|
107
107
|
╰ Path `/root/x.txt` at 1.1-23\
|
|
108
|
-
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs:
|
|
108
|
+
╰ _Metadata_: totalConsidered: 1, totalUnknown: 0, searchTimeMs: 0, processTimeMs: 1\
|
|
109
109
|
╰ **Unused Definitions** (unused-definitions): _no findings_\
|
|
110
110
|
╰ **Network Functions** (network-functions): _no findings_\
|
|
111
111
|
╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
|
|
@@ -116,11 +116,11 @@ It offers a wide variety of features, for example:
|
|
|
116
116
|
╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
|
|
117
117
|
╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
|
|
118
118
|
╰ **Undefined Symbol** (undefined-symbol): _no findings_\
|
|
119
|
-
_All queries together required ≈
|
|
119
|
+
_All queries together required ≈8 ms (1ms accuracy, total 8 ms)_
|
|
120
120
|
|
|
121
121
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
122
122
|
|
|
123
|
-
The analysis required
|
|
123
|
+
The analysis required _8.4 ms_ (including parsing and normalization and the query) within the generation environment.
|
|
124
124
|
|
|
125
125
|
In general, the JSON contains the Ids of the nodes in question as they are present in the normalized AST or the dataflow graph of flowR.
|
|
126
126
|
Please consult the [Interface](https://github.com/flowr-analysis/flowr/wiki/Interface) wiki page for more information on how to get those.
|
|
@@ -137,8 +137,8 @@ It offers a wide variety of features, for example:
|
|
|
137
137
|
".meta": {
|
|
138
138
|
"totalCalls": 0,
|
|
139
139
|
"totalFunctionDefinitions": 0,
|
|
140
|
-
"searchTimeMs":
|
|
141
|
-
"processTimeMs":
|
|
140
|
+
"searchTimeMs": 2,
|
|
141
|
+
"processTimeMs": 0
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
"file-path-validity": {
|
|
@@ -173,7 +173,7 @@ It offers a wide variety of features, for example:
|
|
|
173
173
|
"callsWithNonConstantProducers": 0,
|
|
174
174
|
"callsWithOtherBranchProducers": 0,
|
|
175
175
|
"searchTimeMs": 0,
|
|
176
|
-
"processTimeMs":
|
|
176
|
+
"processTimeMs": 0
|
|
177
177
|
}
|
|
178
178
|
},
|
|
179
179
|
"absolute-file-paths": {
|
|
@@ -193,7 +193,7 @@ It offers a wide variety of features, for example:
|
|
|
193
193
|
"totalConsidered": 1,
|
|
194
194
|
"totalUnknown": 0,
|
|
195
195
|
"searchTimeMs": 0,
|
|
196
|
-
"processTimeMs":
|
|
196
|
+
"processTimeMs": 1
|
|
197
197
|
}
|
|
198
198
|
},
|
|
199
199
|
"unused-definitions": {
|
|
@@ -209,7 +209,7 @@ It offers a wide variety of features, for example:
|
|
|
209
209
|
".meta": {
|
|
210
210
|
"totalCalls": 0,
|
|
211
211
|
"totalFunctionDefinitions": 0,
|
|
212
|
-
"searchTimeMs":
|
|
212
|
+
"searchTimeMs": 0,
|
|
213
213
|
"processTimeMs": 0
|
|
214
214
|
}
|
|
215
215
|
},
|
|
@@ -220,7 +220,7 @@ It offers a wide variety of features, for example:
|
|
|
220
220
|
"numAccesses": 0,
|
|
221
221
|
"totalAccessed": 0,
|
|
222
222
|
"searchTimeMs": 0,
|
|
223
|
-
"processTimeMs":
|
|
223
|
+
"processTimeMs": 0
|
|
224
224
|
}
|
|
225
225
|
},
|
|
226
226
|
"dead-code": {
|
|
@@ -256,7 +256,7 @@ It offers a wide variety of features, for example:
|
|
|
256
256
|
"roxygen-arguments": {
|
|
257
257
|
"results": [],
|
|
258
258
|
".meta": {
|
|
259
|
-
"searchTimeMs":
|
|
259
|
+
"searchTimeMs": 0,
|
|
260
260
|
"processTimeMs": 0
|
|
261
261
|
}
|
|
262
262
|
},
|
|
@@ -281,16 +281,16 @@ It offers a wide variety of features, for example:
|
|
|
281
281
|
"subscript": 0
|
|
282
282
|
},
|
|
283
283
|
"searchTimeMs": 0,
|
|
284
|
-
"processTimeMs":
|
|
284
|
+
"processTimeMs": 2
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
},
|
|
288
288
|
".meta": {
|
|
289
|
-
"timing":
|
|
289
|
+
"timing": 8
|
|
290
290
|
}
|
|
291
291
|
},
|
|
292
292
|
".meta": {
|
|
293
|
-
"timing":
|
|
293
|
+
"timing": 8
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
296
|
```
|
|
@@ -354,7 +354,7 @@ It offers a wide variety of features, for example:
|
|
|
354
354
|
|
|
355
355
|
```shell
|
|
356
356
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
357
|
-
flowR repl v2.13.
|
|
357
|
+
flowR repl v2.13.7, R grammar v14 (tree-sitter engine)
|
|
358
358
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
359
359
|
```
|
|
360
360
|
|
|
@@ -368,7 +368,7 @@ It offers a wide variety of features, for example:
|
|
|
368
368
|
N <- 10
|
|
369
369
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
370
370
|
sum
|
|
371
|
-
All queries together required ≈
|
|
371
|
+
All queries together required ≈4 ms (1ms accuracy, total 4 ms)
|
|
372
372
|
```
|
|
373
373
|
|
|
374
374
|
|
|
@@ -383,7 +383,7 @@ It offers a wide variety of features, for example:
|
|
|
383
383
|
</details>
|
|
384
384
|
|
|
385
385
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
386
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
386
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">105.1 ms</span></i> (as of Aug 1, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
387
387
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
388
388
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/dataflow-graph#perspectives-cg).
|
|
389
389
|
|
|
@@ -419,7 +419,7 @@ It offers a wide variety of features, for example:
|
|
|
419
419
|
|
|
420
420
|
```shell
|
|
421
421
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
422
|
-
flowR repl v2.13.
|
|
422
|
+
flowR repl v2.13.7, R grammar v14 (tree-sitter engine)
|
|
423
423
|
R> :dataflow* test/testfiles/example.R
|
|
424
424
|
```
|
|
425
425
|
|
|
@@ -692,7 +692,7 @@ It offers a wide variety of features, for example:
|
|
|
692
692
|
```
|
|
693
693
|
|
|
694
694
|
|
|
695
|
-
(The analysis required
|
|
695
|
+
(The analysis required _2.0 ms_ (including parse and normalize, using the [tree-sitter](https://github.com/flowr-analysis/flowr/wiki/Engines) engine) within the generation environment. No [signature database](https://github.com/flowr-analysis/flowr/wiki/Signature-Database) is mounted for these generated graphs, so `library()` calls attach no package exports; base-R names are still qualified via the generated base-package store (e.g. `acf` as `stats::acf`).)
|
|
696
696
|
|
|
697
697
|
|
|
698
698
|
|
package/dataflow/cluster.js
CHANGED
|
@@ -10,41 +10,65 @@ const assert_1 = require("../util/assert");
|
|
|
10
10
|
function findAllClusters(graph) {
|
|
11
11
|
const clusters = [];
|
|
12
12
|
// we reverse the vertices since dependencies usually point "backwards" from later nodes
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const ids = graph.vertices(true).map(([id]) => id).toArray().reverse();
|
|
14
|
+
/* walking the ids picks the same start nodes in the same order as draining the set did, without re-opening an
|
|
15
|
+
* iterator over the shrinking set for every cluster */
|
|
16
|
+
const notReached = new Set(ids);
|
|
17
|
+
/* `graph.ingoingEdges` rebuilds the reverse adjacency by scanning every edge of the graph, and clustering asks
|
|
18
|
+
* for it once per node; building it a single time turns that quadratic sweep into one pass */
|
|
19
|
+
const incoming = new Map();
|
|
20
|
+
for (const [source, outgoing] of graph.edges()) {
|
|
21
|
+
for (const [target, edge] of outgoing) {
|
|
22
|
+
const into = incoming.get(target);
|
|
23
|
+
if (into === undefined) {
|
|
24
|
+
incoming.set(target, new Map([[source, edge]]));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
into.set(source, edge);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
for (const startNode of ids) {
|
|
32
|
+
if (!notReached.delete(startNode)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
17
35
|
clusters.push({
|
|
18
36
|
startNode: startNode,
|
|
19
|
-
members: Array.from(makeCluster(graph, startNode, notReached)),
|
|
37
|
+
members: Array.from(makeCluster(graph, startNode, notReached, incoming)),
|
|
20
38
|
hasUnknownSideEffects: graph.unknownSideEffects.has(startNode)
|
|
21
39
|
});
|
|
22
40
|
}
|
|
23
41
|
return clusters;
|
|
24
42
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
43
|
+
/* one shared accumulator, filled iteratively: merging a set per node cost a copy of the whole cluster per member
|
|
44
|
+
* (quadratic in the cluster size), and the recursion ran as deep as the cluster was large */
|
|
45
|
+
function makeCluster(graph, from, notReached, incoming) {
|
|
28
46
|
const nodes = new Set([from]);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
const pending = [from];
|
|
48
|
+
while (pending.length > 0) {
|
|
49
|
+
const current = pending.pop();
|
|
50
|
+
const info = graph.getVertex(current);
|
|
51
|
+
(0, assert_1.guard)(info !== undefined, () => `Vertex ${current} not found in graph`);
|
|
52
|
+
function reach(dest) {
|
|
53
|
+
if (notReached.delete(dest)) {
|
|
54
|
+
nodes.add(dest);
|
|
55
|
+
pending.push(dest);
|
|
36
56
|
}
|
|
37
57
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// don't cluster for function content if it isn't returned
|
|
43
|
-
if (edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Returns) && info.onlyBuiltin && info.name === '{') {
|
|
44
|
-
continue;
|
|
58
|
+
// cluster function def exit points
|
|
59
|
+
if (info.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
60
|
+
for (const { nodeId } of info.exitPoints) {
|
|
61
|
+
reach(nodeId);
|
|
45
62
|
}
|
|
46
|
-
|
|
47
|
-
|
|
63
|
+
}
|
|
64
|
+
// cluster adjacent edges
|
|
65
|
+
for (const edges of [graph.outgoingEdges(current), incoming.get(current)]) {
|
|
66
|
+
for (const [dest, e] of edges ?? []) {
|
|
67
|
+
// don't cluster for function content if it isn't returned
|
|
68
|
+
if (edge_1.DfEdge.doesNotIncludeType(e, edge_1.EdgeType.Returns) && info.onlyBuiltin && info.name === '{') {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
reach(dest);
|
|
48
72
|
}
|
|
49
73
|
}
|
|
50
74
|
}
|
|
@@ -2221,6 +2221,36 @@ export declare const WrittenBuiltinDefinitions: [{
|
|
|
2221
2221
|
};
|
|
2222
2222
|
};
|
|
2223
2223
|
readonly assumePrimitive: true;
|
|
2224
|
+
}, {
|
|
2225
|
+
readonly type: "function";
|
|
2226
|
+
readonly names: [Identifier];
|
|
2227
|
+
readonly processor: BuiltInProcName.Default;
|
|
2228
|
+
readonly config: {
|
|
2229
|
+
readonly libFn: true;
|
|
2230
|
+
readonly props: number;
|
|
2231
|
+
readonly sig: [["expr", ArgProp.Forced], ["env", ArgProp.Value], ["ns", ArgProp.Value]];
|
|
2232
|
+
};
|
|
2233
|
+
readonly assumePrimitive: false;
|
|
2234
|
+
}, {
|
|
2235
|
+
readonly type: "function";
|
|
2236
|
+
readonly names: [Identifier];
|
|
2237
|
+
readonly processor: BuiltInProcName.Default;
|
|
2238
|
+
readonly config: {
|
|
2239
|
+
readonly libFn: true;
|
|
2240
|
+
readonly props: number;
|
|
2241
|
+
readonly sig: [["pkg", ArgProp.Value], ["expr", ArgProp.Forced], ["env", ArgProp.Value]];
|
|
2242
|
+
};
|
|
2243
|
+
readonly assumePrimitive: false;
|
|
2244
|
+
}, {
|
|
2245
|
+
readonly type: "function";
|
|
2246
|
+
readonly names: [Identifier];
|
|
2247
|
+
readonly processor: BuiltInProcName.Default;
|
|
2248
|
+
readonly config: {
|
|
2249
|
+
readonly libFn: true;
|
|
2250
|
+
readonly props: number;
|
|
2251
|
+
readonly sig: [["ns", ArgProp.Value]];
|
|
2252
|
+
};
|
|
2253
|
+
readonly assumePrimitive: false;
|
|
2224
2254
|
}, {
|
|
2225
2255
|
readonly type: "function";
|
|
2226
2256
|
readonly names: [Identifier];
|
|
@@ -990,6 +990,15 @@ exports.WrittenBuiltinDefinitions = [
|
|
|
990
990
|
},
|
|
991
991
|
assumePrimitive: true
|
|
992
992
|
},
|
|
993
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['on_load', "rlang" /* PkgName.Rlang */])],
|
|
994
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
995
|
+
config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['expr', built_in_props_1.ArgProp.Forced], ['env', built_in_props_1.ArgProp.Value], ['ns', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
996
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['on_package_load', "rlang" /* PkgName.Rlang */])],
|
|
997
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
998
|
+
config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['pkg', built_in_props_1.ArgProp.Value], ['expr', built_in_props_1.ArgProp.Forced], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
999
|
+
{ type: 'function', names: [identifier_1.Identifier.from(['run_on_load', "rlang" /* PkgName.Rlang */])],
|
|
1000
|
+
processor: built_in_proc_name_1.BuiltInProcName.Default,
|
|
1001
|
+
config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['ns', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
|
|
993
1002
|
/* `parse(text=)` turns text into an expression, with `file=` it reads that file */
|
|
994
1003
|
{ type: 'function', names: [identifier_1.Identifier.from(['parse', "base" /* PkgName.Base */])],
|
|
995
1004
|
processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', props: built_in_props_1.CallProp.Pure }, assumePrimitive: false },
|
|
@@ -119,6 +119,19 @@ export declare const Dataflow: {
|
|
|
119
119
|
* Use this when you need the reduced-and-inverted graph for a forward traversal within a restriction set.
|
|
120
120
|
*/
|
|
121
121
|
readonly reduceAndInvertGraph: <G extends DataflowGraph>(this: void, graph: G, select: ReadonlySet<NodeId>, cleanEnv: REnvironmentInformation) => G;
|
|
122
|
+
/**
|
|
123
|
+
* Whether the node is quoted, i.e., affected by a {@link EdgeType.NonStandardEvaluation} edge that actually
|
|
124
|
+
* keeps it from being evaluated (as `quote` and `substitute` do).
|
|
125
|
+
*
|
|
126
|
+
* Loops mark their body as non-standard-evaluated as well, yet that body really is evaluated (and its symbols
|
|
127
|
+
* really are read), so such an edge does not quote. Use this instead of testing for the edge type directly
|
|
128
|
+
* whenever you want to know whether something is evaluated at all.
|
|
129
|
+
* @param id - The id of the node to check
|
|
130
|
+
* @param graph - The graph the node is part of
|
|
131
|
+
* @param withOutgoing - Whether to also consider the outgoing edges of the node (i.e., whether the node itself
|
|
132
|
+
* quotes something), and not just the ingoing ones (i.e., whether it is quoted)
|
|
133
|
+
*/
|
|
134
|
+
readonly isQuoted: (this: void, id: NodeId, graph: DataflowGraph, withOutgoing?: boolean) => boolean;
|
|
122
135
|
/**
|
|
123
136
|
* Given the id of a vertex (usually a variable use),
|
|
124
137
|
* this returns a reachable provenance set by calculating a non-interprocedural and non-context sensitive backward slice, but stopping at the given ids!
|
|
@@ -10,6 +10,7 @@ const call_graph_1 = require("./call-graph");
|
|
|
10
10
|
const transitive_side_effects_1 = require("../internal/process/functions/call/built-in/transitive-side-effects");
|
|
11
11
|
const vertex_1 = require("./vertex");
|
|
12
12
|
const identifier_1 = require("../environments/identifier");
|
|
13
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
13
14
|
/**
|
|
14
15
|
* This is the root helper object to work with the {@link DataflowGraph}.
|
|
15
16
|
*
|
|
@@ -147,6 +148,26 @@ exports.Dataflow = {
|
|
|
147
148
|
}
|
|
148
149
|
return df;
|
|
149
150
|
},
|
|
151
|
+
/**
|
|
152
|
+
* Whether the node is quoted, i.e., affected by a {@link EdgeType.NonStandardEvaluation} edge that actually
|
|
153
|
+
* keeps it from being evaluated (as `quote` and `substitute` do).
|
|
154
|
+
*
|
|
155
|
+
* Loops mark their body as non-standard-evaluated as well, yet that body really is evaluated (and its symbols
|
|
156
|
+
* really are read), so such an edge does not quote. Use this instead of testing for the edge type directly
|
|
157
|
+
* whenever you want to know whether something is evaluated at all.
|
|
158
|
+
* @param id - The id of the node to check
|
|
159
|
+
* @param graph - The graph the node is part of
|
|
160
|
+
* @param withOutgoing - Whether to also consider the outgoing edges of the node (i.e., whether the node itself
|
|
161
|
+
* quotes something), and not just the ingoing ones (i.e., whether it is quoted)
|
|
162
|
+
*/
|
|
163
|
+
isQuoted(id, graph, withOutgoing = false) {
|
|
164
|
+
/* an nse edge quotes iff it does not originate from a loop marking its body */
|
|
165
|
+
const quotes = (source, e) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.NonStandardEvaluation) && !model_1.RLoopConstructs.is(graph.idMap?.get(source));
|
|
166
|
+
if (graph.ingoingEdges(id)?.entries().some(([source, e]) => quotes(source, e))) {
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return withOutgoing && (graph.outgoingEdges(id)?.values().some(e => quotes(id, e)) ?? false);
|
|
170
|
+
},
|
|
150
171
|
/**
|
|
151
172
|
* Given the id of a vertex (usually a variable use),
|
|
152
173
|
* this returns a reachable provenance set by calculating a non-interprocedural and non-context sensitive backward slice, but stopping at the given ids!
|
|
@@ -210,6 +210,7 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
210
210
|
private vertexInformation;
|
|
211
211
|
/** All edges in the complete graph (including those nested in function definition) */
|
|
212
212
|
private edgeInformation;
|
|
213
|
+
private incomingIndex?;
|
|
213
214
|
private readonly types;
|
|
214
215
|
toJSON(): DataflowGraphJson;
|
|
215
216
|
/**
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -178,6 +178,9 @@ class DataflowGraph {
|
|
|
178
178
|
vertexInformation = new Map();
|
|
179
179
|
/** All edges in the complete graph (including those nested in function definition) */
|
|
180
180
|
edgeInformation = new Map();
|
|
181
|
+
/* the reverse of `edgeInformation`, built on demand and dropped whenever an edge is added: rebuilding it per
|
|
182
|
+
* lookup made every caller asking for the ingoing edges of many nodes scan the whole graph once per node */
|
|
183
|
+
incomingIndex;
|
|
181
184
|
types = new Map();
|
|
182
185
|
toJSON() {
|
|
183
186
|
return {
|
|
@@ -226,14 +229,23 @@ class DataflowGraph {
|
|
|
226
229
|
return this.edgeInformation.get(id);
|
|
227
230
|
}
|
|
228
231
|
ingoingEdges(id) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
if (this.incomingIndex === undefined) {
|
|
233
|
+
const index = new Map();
|
|
234
|
+
for (const [source, outgoing] of this.edgeInformation.entries()) {
|
|
235
|
+
for (const [target, edge] of outgoing) {
|
|
236
|
+
const into = index.get(target);
|
|
237
|
+
if (into === undefined) {
|
|
238
|
+
index.set(target, new Map([[source, edge]]));
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
into.set(source, edge);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
234
244
|
}
|
|
245
|
+
this.incomingIndex = index;
|
|
235
246
|
}
|
|
236
|
-
|
|
247
|
+
/* the historic contract is an (possibly empty) map for every id, never `undefined` */
|
|
248
|
+
return this.incomingIndex.get(id) ?? new Map();
|
|
237
249
|
}
|
|
238
250
|
/**
|
|
239
251
|
* Given a node in the normalized AST this either:
|
|
@@ -350,6 +362,7 @@ class DataflowGraph {
|
|
|
350
362
|
if (fromId === toId) {
|
|
351
363
|
return this;
|
|
352
364
|
}
|
|
365
|
+
this.incomingIndex = undefined;
|
|
353
366
|
let fromEdges = this.edgeInformation.get(fromId);
|
|
354
367
|
if (fromEdges === undefined) {
|
|
355
368
|
fromEdges = new Map([[toId, { types: type }]]);
|
|
@@ -409,6 +422,7 @@ class DataflowGraph {
|
|
|
409
422
|
}
|
|
410
423
|
}
|
|
411
424
|
mergeEdges(otherGraph) {
|
|
425
|
+
this.incomingIndex = undefined;
|
|
412
426
|
for (const [id, edges] of otherGraph.edgeInformation.entries()) {
|
|
413
427
|
let existing = this.edgeInformation.get(id);
|
|
414
428
|
if (existing === undefined) {
|
|
@@ -530,6 +544,7 @@ class DataflowGraph {
|
|
|
530
544
|
}
|
|
531
545
|
}
|
|
532
546
|
graph.edgeInformation = new Map(data.edgeInformation.map(([id, edges]) => [id, new Map(edges)]));
|
|
547
|
+
graph.incomingIndex = undefined;
|
|
533
548
|
for (const unknown of data._unknownSideEffects) {
|
|
534
549
|
graph._unknownSideEffects.add(unknown);
|
|
535
550
|
}
|
|
@@ -10,7 +10,10 @@ export declare function isInstalledResourceFile(file: string | undefined): boole
|
|
|
10
10
|
* constant such as `T`, `pi`). Broader than `getOriginInDfg`, which misses built-in constants.
|
|
11
11
|
*/
|
|
12
12
|
export declare function useResolvesToDefinitionOrBuiltin(graph: DataflowGraph, id: NodeId): boolean;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Whether any edge incident to `id` marks it as non-standard-evaluated (quoted), e.g. `quote`/`substitute`.
|
|
15
|
+
* A loop body is marked as non-standard-evaluated too, but it is evaluated, so it does not count here.
|
|
16
|
+
*/
|
|
14
17
|
export declare function isNonStandardEvaluated(graph: DataflowGraph, id: NodeId): boolean;
|
|
15
18
|
/**
|
|
16
19
|
* Whether the use `id` sits inside a `[`/`[[` subscript (not the accessed object). `data.table`'s
|
|
@@ -7,6 +7,7 @@ exports.isInSubscript = isInSubscript;
|
|
|
7
7
|
exports.collectScopeDefinedNames = collectScopeDefinedNames;
|
|
8
8
|
exports.isDefinedInEnclosingScope = isDefinedInEnclosingScope;
|
|
9
9
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
10
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
10
11
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
12
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
12
13
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
@@ -37,10 +38,12 @@ function useResolvesToDefinitionOrBuiltin(graph, id) {
|
|
|
37
38
|
}
|
|
38
39
|
return false;
|
|
39
40
|
}
|
|
40
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Whether any edge incident to `id` marks it as non-standard-evaluated (quoted), e.g. `quote`/`substitute`.
|
|
43
|
+
* A loop body is marked as non-standard-evaluated too, but it is evaluated, so it does not count here.
|
|
44
|
+
*/
|
|
41
45
|
function isNonStandardEvaluated(graph, id) {
|
|
42
|
-
|
|
43
|
-
return (graph.outgoingEdges(id)?.values().some(nse) ?? false) || (graph.ingoingEdges(id)?.values().some(nse) ?? false);
|
|
46
|
+
return df_helper_1.Dataflow.isQuoted(id, graph, true);
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
46
49
|
* Whether the use `id` sits inside a `[`/`[[` subscript (not the accessed object). `data.table`'s
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.9",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"types": "dist/src/index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
"eslint-plugin-jsdoc": "^62.9.0",
|
|
209
209
|
"eslint-plugin-tsdoc": "^0.5.2",
|
|
210
210
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
211
|
-
"license-checker-rseidelsohn": "^
|
|
211
|
+
"license-checker-rseidelsohn": "^4.4.2",
|
|
212
212
|
"release-it": "^20.0.0",
|
|
213
213
|
"ts-node": "^10.9.2",
|
|
214
214
|
"typedoc": "^0.28.17",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { type Range } from 'semver';
|
|
9
9
|
import { type VersionString } from '../util/r-version';
|
|
10
10
|
import { type PackageSignatureSource } from './sigdb/reader';
|
|
11
|
-
import type { DecodedFunction } from './sigdb/decode';
|
|
11
|
+
import type { DecodedFunction, ResolvedDependency } from './sigdb/decode';
|
|
12
12
|
import { FunctionArgument, type DataflowGraph } from '../dataflow/graph/graph';
|
|
13
13
|
import type { ReadOnlyFlowrAnalyzerDependenciesContext } from './context/flowr-analyzer-dependencies-context';
|
|
14
14
|
import type { ReadonlyFlowrAnalysisProvider } from './flowr-analyzer';
|
|
@@ -284,8 +284,23 @@ export declare function timelinePackageKey(name: string, sources: readonly Packa
|
|
|
284
284
|
export declare function orderedCandidatesOf(src: PackageSignatureSource | undefined, name: string, surviving: SurvivingEntries, prefer: string | undefined, order: 'newest' | 'oldest'): OrderedCandidates | undefined;
|
|
285
285
|
/** the default explosion targets: every declared and used dependency (excluding `current`, the analyzed package's own namespace) */
|
|
286
286
|
export declare function defaultTargets(deps: ReadOnlyFlowrAnalyzerDependenciesContext, usage: ReadonlyMap<string, PackageUsage>): string[];
|
|
287
|
-
/**
|
|
288
|
-
export
|
|
287
|
+
/** the requirements one concrete version declares, as {@link isCoInstallable} reads them */
|
|
288
|
+
export type DependencyResolver = (pkg: string, version: VersionString) => readonly ResolvedDependency[] | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* Whether the chosen versions can be loaded together. The per-package candidates are narrowed by requirements
|
|
291
|
+
* merged over *all* versions of the requiring package, so a combination can still pair a version with one that
|
|
292
|
+
* the version it was actually chosen alongside rules out (`library()` then reports the conflict). Packages
|
|
293
|
+
* outside the assignment and requirements without a version qualifier constrain nothing.
|
|
294
|
+
*/
|
|
295
|
+
export declare function isCoInstallable(versions: ReadonlyMap<string, VersionString>, declares: DependencyResolver): boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Lazily yield concrete version assignments (one version per package) in odometer order over the per-package lists.
|
|
298
|
+
* With `declares`, a combination whose versions cannot be loaded together is skipped rather than proposed; `limit`
|
|
299
|
+
* bounds the combinations *considered* either way, so fewer than `limit` assignments may come out.
|
|
300
|
+
*/
|
|
301
|
+
export declare function assignmentsOf(perPackage: readonly OrderedCandidates[], limit: number, declares?: DependencyResolver): Generator<VersionAssignment>;
|
|
302
|
+
/** the {@link DependencyResolver} backed by the signature database a version space resolves each package in */
|
|
303
|
+
export declare function declaredDependenciesOf(space: VersionSpace): DependencyResolver;
|
|
289
304
|
/**
|
|
290
305
|
* Explode the guessed constraint space into concrete, signature-database-available version assignments: a lazy
|
|
291
306
|
* iterator over one chosen version per resolvable dependency. Each package's versions are ordered by preference
|
|
@@ -14,7 +14,9 @@ exports.survivingEntries = survivingEntries;
|
|
|
14
14
|
exports.timelinePackageKey = timelinePackageKey;
|
|
15
15
|
exports.orderedCandidatesOf = orderedCandidatesOf;
|
|
16
16
|
exports.defaultTargets = defaultTargets;
|
|
17
|
+
exports.isCoInstallable = isCoInstallable;
|
|
17
18
|
exports.assignmentsOf = assignmentsOf;
|
|
19
|
+
exports.declaredDependenciesOf = declaredDependenciesOf;
|
|
18
20
|
exports.explodeDependencyVersions = explodeDependencyVersions;
|
|
19
21
|
/**
|
|
20
22
|
* The dependency version space: for each dependency, the set of signature-database versions that survive the
|
|
@@ -854,8 +856,33 @@ function orderedCandidatesOf(src, name, surviving, prefer, order) {
|
|
|
854
856
|
function defaultTargets(deps, usage) {
|
|
855
857
|
return [...new Set([...deps.getDependencies().map(d => d.name), ...usage.keys()])].filter(name => name !== exports.ProjectPackage);
|
|
856
858
|
}
|
|
857
|
-
/**
|
|
858
|
-
|
|
859
|
+
/**
|
|
860
|
+
* Whether the chosen versions can be loaded together. The per-package candidates are narrowed by requirements
|
|
861
|
+
* merged over *all* versions of the requiring package, so a combination can still pair a version with one that
|
|
862
|
+
* the version it was actually chosen alongside rules out (`library()` then reports the conflict). Packages
|
|
863
|
+
* outside the assignment and requirements without a version qualifier constrain nothing.
|
|
864
|
+
*/
|
|
865
|
+
function isCoInstallable(versions, declares) {
|
|
866
|
+
for (const [pkg, version] of versions) {
|
|
867
|
+
for (const dep of declares(pkg, version) ?? []) {
|
|
868
|
+
const chosen = versions.get(dep.name);
|
|
869
|
+
if (chosen === undefined || dep.constraint === undefined) {
|
|
870
|
+
continue;
|
|
871
|
+
}
|
|
872
|
+
const range = r_version_1.RRange.parse(dep.constraint);
|
|
873
|
+
if (range !== undefined && !r_version_1.RRange.satisfies(chosen, range)) {
|
|
874
|
+
return false;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Lazily yield concrete version assignments (one version per package) in odometer order over the per-package lists.
|
|
882
|
+
* With `declares`, a combination whose versions cannot be loaded together is skipped rather than proposed; `limit`
|
|
883
|
+
* bounds the combinations *considered* either way, so fewer than `limit` assignments may come out.
|
|
884
|
+
*/
|
|
885
|
+
function* assignmentsOf(perPackage, limit, declares) {
|
|
859
886
|
if (perPackage.length === 0 || perPackage.some(p => p.versions.length === 0)) {
|
|
860
887
|
return;
|
|
861
888
|
}
|
|
@@ -865,7 +892,9 @@ function* assignmentsOf(perPackage, limit) {
|
|
|
865
892
|
for (let i = 0; i < perPackage.length; i++) {
|
|
866
893
|
versions.set(perPackage[i].pkg, perPackage[i].versions[idx[i]]);
|
|
867
894
|
}
|
|
868
|
-
|
|
895
|
+
if (declares === undefined || isCoInstallable(versions, declares)) {
|
|
896
|
+
yield { versions };
|
|
897
|
+
}
|
|
869
898
|
// advance the odometer: the last package varies fastest
|
|
870
899
|
let k = perPackage.length - 1;
|
|
871
900
|
for (; k >= 0; k--) {
|
|
@@ -885,7 +914,7 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
885
914
|
const deps = ctx.deps;
|
|
886
915
|
const sources = deps.signatureSources();
|
|
887
916
|
if (sources.length === 0) {
|
|
888
|
-
return [];
|
|
917
|
+
return { candidates: [], declares: () => undefined };
|
|
889
918
|
}
|
|
890
919
|
const cutoff = options.date ? dateCutoff(options.date) : undefined;
|
|
891
920
|
// bound base packages by R only when genuinely known (a config pin, metadata, or detection); `auto` with nothing detected imposes no R ceiling
|
|
@@ -903,7 +932,11 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
903
932
|
out.push(oc);
|
|
904
933
|
}
|
|
905
934
|
}
|
|
906
|
-
return out;
|
|
935
|
+
return { candidates: out, declares: declaredDependenciesOf(space) };
|
|
936
|
+
}
|
|
937
|
+
/** the {@link DependencyResolver} backed by the signature database a version space resolves each package in */
|
|
938
|
+
function declaredDependenciesOf(space) {
|
|
939
|
+
return (pkg, version) => space.resolve(pkg).src?.dependencies(pkg, version);
|
|
907
940
|
}
|
|
908
941
|
/**
|
|
909
942
|
* Explode the guessed constraint space into concrete, signature-database-available version assignments: a lazy
|
|
@@ -913,6 +946,7 @@ async function orderedCandidatesFor(analyzer, options) {
|
|
|
913
946
|
* {@link VersionExplodeOptions.limit} so an enormous product cannot run away.
|
|
914
947
|
*/
|
|
915
948
|
async function* explodeDependencyVersions(analyzer, options = {}) {
|
|
916
|
-
|
|
949
|
+
const { candidates, declares } = await orderedCandidatesFor(analyzer, options);
|
|
950
|
+
yield* assignmentsOf(candidates, options.limit ?? exports.DefaultExplodeLimit, declares);
|
|
917
951
|
}
|
|
918
952
|
//# sourceMappingURL=dependency-version-space.js.map
|