@eagleoutice/flowr 2.17.7 → 2.17.8
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/abstract-interpretation/branch-paths.d.ts +10 -0
- package/abstract-interpretation/branch-paths.js +104 -10
- package/config.js +3 -1
- package/control-flow/control-flow-graph.js +18 -2
- package/data/r-base-guards.generated.js +2 -2
- package/dataflow/environments/ambient-effect.js +4 -1
- package/dataflow/environments/built-in-props.d.ts +8 -2
- package/dataflow/environments/built-in-props.js +16 -5
- package/dataflow/environments/default-builtin-config/base-functions.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +28 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +8 -4
- package/dataflow/environments/default-builtin-config/index.js +9 -5
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +25 -0
- package/dataflow/environments/guard-facts.d.ts +28 -1
- package/dataflow/environments/pkg-name.d.ts +2 -0
- package/dataflow/environments/query-fn-props.d.ts +19 -15
- package/dataflow/environments/query-fn-props.js +46 -36
- package/dataflow/environments/removal-marker.d.ts +1 -1
- package/dataflow/environments/removal-marker.js +18 -3
- package/dataflow/environments/reserved-names.d.ts +6 -0
- package/dataflow/environments/reserved-names.js +14 -0
- package/dataflow/environments/resolve-by-name.js +5 -10
- package/dataflow/eval/resolve/alias-tracking.js +23 -6
- package/dataflow/extractor.js +103 -28
- package/dataflow/fn/argument-roles.d.ts +3 -0
- package/dataflow/fn/argument-roles.js +5 -5
- package/dataflow/fn/exceptions-of-function.d.ts +7 -0
- package/dataflow/fn/exceptions-of-function.js +15 -2
- package/dataflow/fn/function-props.d.ts +1 -1
- package/dataflow/fn/function-props.js +40 -18
- package/dataflow/fn/function-semantics.d.ts +3 -1
- package/dataflow/fn/function-semantics.js +2 -0
- package/dataflow/fn/guards/built-in-guards.js +2 -1
- package/dataflow/fn/guards/condition-grouping.d.ts +11 -0
- package/dataflow/fn/guards/condition-grouping.js +50 -3
- package/dataflow/fn/guards/function-guards.d.ts +10 -0
- package/dataflow/fn/guards/function-guards.js +130 -14
- package/dataflow/fn/guards/guard-claims.d.ts +2 -0
- package/dataflow/fn/guards/guard-claims.js +42 -2
- package/dataflow/fn/guards/guard-knowledge.d.ts +7 -1
- package/dataflow/fn/guards/guard-knowledge.js +50 -4
- package/dataflow/fn/guards/guard-term.js +10 -1
- package/dataflow/fn/higher-order-function.d.ts +15 -1
- package/dataflow/fn/higher-order-function.js +54 -10
- package/dataflow/graph/call-graph.d.ts +5 -0
- package/dataflow/graph/call-graph.js +51 -15
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +4 -2
- package/dataflow/graph/graph.d.ts +21 -0
- package/dataflow/graph/graph.js +63 -2
- package/dataflow/internal/linker.d.ts +20 -0
- package/dataflow/internal/linker.js +190 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +20 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +12 -5
- package/dataflow/internal/process/functions/call/deferred.d.ts +7 -2
- package/dataflow/internal/process/functions/call/deferred.js +63 -28
- package/dataflow/internal/process/functions/call/quoted.js +33 -7
- package/documentation/data/dfg/doc-ambient.js +3 -1
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-query.js +9 -3
- package/package.json +5 -3
- package/project/context/flowr-analyzer-context.d.ts +7 -4
- package/project/context/flowr-analyzer-context.js +8 -3
- package/project/context/flowr-analyzer-files-context.js +1 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +2 -1
- package/project/context/flowr-analyzer-functions-context.js +9 -8
- package/project/flowr-analyzer.d.ts +7 -4
- package/project/flowr-analyzer.js +37 -8
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +22 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +34 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -1
- package/project/sigdb/build.js +41 -2
- package/project/sigdb/decode.d.ts +3 -1
- package/project/sigdb/decode.js +45 -1
- package/project/sigdb/decompress.d.ts +5 -0
- package/project/sigdb/decompress.js +17 -1
- package/project/sigdb/manifest.d.ts +2 -1
- package/project/sigdb/manifest.js +12 -5
- package/project/sigdb/native-routines.d.ts +82 -0
- package/project/sigdb/native-routines.js +178 -0
- package/project/sigdb/reader.d.ts +21 -3
- package/project/sigdb/reader.js +35 -3
- package/project/sigdb/schema.d.ts +107 -3
- package/project/sigdb/schema.js +8 -2
- package/project/sigdb/sigdb-download.js +1 -1
- package/project/sigdb/sigdb-version.d.ts +7 -1
- package/project/sigdb/sigdb-version.js +12 -9
- package/project/sigdb/spec-query.d.ts +9 -4
- package/project/sigdb/spec-query.js +71 -45
- package/queries/catalog/call-context-query/call-context-query-executor.js +76 -29
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -12
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +3 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +4 -2
- package/queries/catalog/signature-query/signature-query-executor.js +6 -2
- package/queries/catalog/signature-query/signature-query-format.d.ts +4 -0
- package/util/collections/bounded-map.d.ts +9 -0
- package/util/collections/bounded-map.js +22 -0
- package/util/collections/defaultmap.d.ts +5 -0
- package/util/collections/defaultmap.js +10 -0
- package/util/fixpoint.d.ts +6 -1
- package/util/fixpoint.js +45 -3
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/global-caches.d.ts +26 -0
- package/util/global-caches.js +43 -0
- package/util/monoid.js +2 -2
- package/util/quads.js +11 -3
- package/util/r-package-urls.d.ts +19 -0
- package/util/r-package-urls.js +41 -0
|
@@ -20,6 +20,16 @@ export declare class BranchPathDomain extends BoundedSetDomain<string> {
|
|
|
20
20
|
constructor(value: BoundedSetLift<string> | string[], limit?: number);
|
|
21
21
|
/** Past the limit, the paths are the one path of the steps all of them take, which still holds whichever way the node was reached. */
|
|
22
22
|
create(value: BoundedSetLift<string> | string[]): this;
|
|
23
|
+
/**
|
|
24
|
+
* the steps all paths take, as each join past the limit needs them of both sides: carried along by the operations
|
|
25
|
+
* when known, which is cheap (see {@link withCommon}), else worked out once per value
|
|
26
|
+
*/
|
|
27
|
+
private common;
|
|
28
|
+
private commonSteps;
|
|
29
|
+
/** The domain, knowing that its paths all take the `common` steps (if given) and no other step all of them take. */
|
|
30
|
+
private static withCommon;
|
|
31
|
+
/** Past the limit, the joined paths are the one path of the steps both sides' paths all take, so only those are intersected. */
|
|
32
|
+
protected joinValue(this: this & BranchPathDomain, other: BoundedSetDomain<string>): this;
|
|
23
33
|
/** Reached without any branch, as the start of a function body is. */
|
|
24
34
|
static start(): BranchPathDomain;
|
|
25
35
|
protected meetValue(this: this & BranchPathDomain, other: BoundedSetDomain<string>): this;
|
|
@@ -5,6 +5,8 @@ const assert_1 = require("../util/assert");
|
|
|
5
5
|
const lattice_1 = require("./domains/lattice");
|
|
6
6
|
const bounded_set_domain_1 = require("./domains/bounded-set-domain");
|
|
7
7
|
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
8
|
+
const global_caches_1 = require("../util/global-caches");
|
|
9
|
+
const defaultmap_1 = require("../util/collections/defaultmap");
|
|
8
10
|
/** How many paths are told apart before nothing is known about how a node is reached. */
|
|
9
11
|
const MaxPaths = 64;
|
|
10
12
|
const StepSeparator = '\u0002';
|
|
@@ -20,8 +22,60 @@ function decodeStep(step) {
|
|
|
20
22
|
function encodePath(steps) {
|
|
21
23
|
return [...steps].sort().join(StepSeparator);
|
|
22
24
|
}
|
|
25
|
+
/* both memos hold node ids of the analyzed code, so a reset releases them, and are bounded, so a large package does not hold every path it saw */
|
|
26
|
+
const MaxParsedPaths = 100_000;
|
|
27
|
+
/** the sorted steps of each path seen lately: the same paths flow through the whole interpretation, so they are split once */
|
|
28
|
+
const parsedPaths = global_caches_1.GlobalCaches.map('branch-paths', global_caches_1.CacheScope.Analysis, MaxParsedPaths);
|
|
29
|
+
/** per path and step, the path taking it: a loop is interpreted until nothing changes, so the same continuations come up again */
|
|
30
|
+
const continued = global_caches_1.GlobalCaches.map('branch-path-steps', global_caches_1.CacheScope.Analysis, MaxParsedPaths);
|
|
31
|
+
/** The steps of the path, sorted as {@link encodePath} sorts them. */
|
|
32
|
+
function sortedSteps(path) {
|
|
33
|
+
return (0, defaultmap_1.getOrSet)(parsedPaths, path, () => path === '' ? [] : path.split(StepSeparator));
|
|
34
|
+
}
|
|
23
35
|
function stepsOf(path) {
|
|
24
|
-
return new Set(path
|
|
36
|
+
return new Set(sortedSteps(path));
|
|
37
|
+
}
|
|
38
|
+
/** The path with `step` taken as well, the same string as `encodePath(stepsOf(path).add(step))` without splitting and sorting again. */
|
|
39
|
+
function withStep(path, step) {
|
|
40
|
+
return (0, defaultmap_1.getOrSet)((0, defaultmap_1.getOrSet)(continued, path, () => new Map()), step, () => insertStep(path, step));
|
|
41
|
+
}
|
|
42
|
+
/** Where `step` is or belongs in the sorted `steps`. */
|
|
43
|
+
function positionOf(steps, step) {
|
|
44
|
+
let low = 0;
|
|
45
|
+
let high = steps.length;
|
|
46
|
+
while (low < high) {
|
|
47
|
+
const mid = (low + high) >>> 1;
|
|
48
|
+
if (steps[mid] < step) {
|
|
49
|
+
low = mid + 1;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
high = mid;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return low;
|
|
56
|
+
}
|
|
57
|
+
function insertStep(path, step) {
|
|
58
|
+
const steps = sortedSteps(path);
|
|
59
|
+
const low = positionOf(steps, step);
|
|
60
|
+
return steps[low] === step ? path : [...steps.slice(0, low), step, ...steps.slice(low)].join(StepSeparator);
|
|
61
|
+
}
|
|
62
|
+
/** Whether the sorted `steps` have `step`. */
|
|
63
|
+
function hasStep(steps, step) {
|
|
64
|
+
return steps[positionOf(steps, step)] === step;
|
|
65
|
+
}
|
|
66
|
+
/** The steps all of the paths take: what is common shrinks fast, so each further path is only searched for what is left, never split into a set. */
|
|
67
|
+
function stepsInAll(paths) {
|
|
68
|
+
let common;
|
|
69
|
+
for (const path of paths) {
|
|
70
|
+
const steps = sortedSteps(path);
|
|
71
|
+
common = common === undefined ? [...steps] : common.filter(step => hasStep(steps, step));
|
|
72
|
+
}
|
|
73
|
+
return common ?? [];
|
|
74
|
+
}
|
|
75
|
+
/** The steps all of the paths take, encoded as a path. */
|
|
76
|
+
function commonPath(paths) {
|
|
77
|
+
/* the steps stay sorted, so they already are the path */
|
|
78
|
+
return stepsInAll(paths).join(StepSeparator);
|
|
25
79
|
}
|
|
26
80
|
/** The other way the step goes, the same branch taken the other way. */
|
|
27
81
|
function flipped(step) {
|
|
@@ -65,23 +119,62 @@ class BranchPathDomain extends bounded_set_domain_1.BoundedSetDomain {
|
|
|
65
119
|
create(value) {
|
|
66
120
|
const paths = value === lattice_1.Top ? undefined : [...value];
|
|
67
121
|
if (paths !== undefined && paths.length > this.limit) {
|
|
68
|
-
|
|
69
|
-
|
|
122
|
+
return new BranchPathDomain([commonPath(paths)], this.limit);
|
|
123
|
+
}
|
|
124
|
+
/* a domain never changes its paths, so a copy of the same ones (as a product copies its entries) is the domain itself */
|
|
125
|
+
return value === this.value ? this : new BranchPathDomain(value, this.limit);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* the steps all paths take, as each join past the limit needs them of both sides: carried along by the operations
|
|
129
|
+
* when known, which is cheap (see {@link withCommon}), else worked out once per value
|
|
130
|
+
*/
|
|
131
|
+
common;
|
|
132
|
+
commonSteps() {
|
|
133
|
+
this.common ??= new Set(stepsInAll(this.value));
|
|
134
|
+
return this.common;
|
|
135
|
+
}
|
|
136
|
+
/** The domain, knowing that its paths all take the `common` steps (if given) and no other step all of them take. */
|
|
137
|
+
static withCommon(domain, common) {
|
|
138
|
+
if (common !== undefined && domain.isValue()) {
|
|
139
|
+
domain.common ??= common;
|
|
70
140
|
}
|
|
71
|
-
return
|
|
141
|
+
return domain;
|
|
142
|
+
}
|
|
143
|
+
/** Past the limit, the joined paths are the one path of the steps both sides' paths all take, so only those are intersected. */
|
|
144
|
+
joinValue(other) {
|
|
145
|
+
if (!other.isValue() || !(other instanceof BranchPathDomain)) {
|
|
146
|
+
return super.joinValue(other);
|
|
147
|
+
}
|
|
148
|
+
const union = this.value.union(other.value);
|
|
149
|
+
if (union.size <= this.limit) {
|
|
150
|
+
/* the steps all paths of either side take */
|
|
151
|
+
return BranchPathDomain.withCommon(this.create(union), this.common !== undefined && other.common !== undefined ? this.common.intersection(other.common) : undefined);
|
|
152
|
+
}
|
|
153
|
+
const common = this.commonSteps().intersection(other.commonSteps());
|
|
154
|
+
const collapsed = new BranchPathDomain([encodePath(common)], this.limit);
|
|
155
|
+
/* its one path is these steps, so its own next join past the limit need not split it again */
|
|
156
|
+
collapsed.common = common;
|
|
157
|
+
return collapsed;
|
|
72
158
|
}
|
|
73
159
|
/** Reached without any branch, as the start of a function body is. */
|
|
74
160
|
static start() {
|
|
75
|
-
return new BranchPathDomain(['']);
|
|
161
|
+
return BranchPathDomain.withCommon(new BranchPathDomain(['']), new Set());
|
|
76
162
|
}
|
|
77
163
|
meetValue(other) {
|
|
78
164
|
if (!other.isValue()) {
|
|
79
165
|
return this.create(other.value);
|
|
80
166
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
167
|
+
/*
|
|
168
|
+
* past the limit, `create` keeps only the steps every pair takes, which are the steps all of mine take together with the steps
|
|
169
|
+
* all of theirs take, as `(a1 | b1) & (a1 | b2) & ... = (a1 & a2 ...) | (b1 & b2 ...)`; so the pairs are not built at all
|
|
170
|
+
*/
|
|
171
|
+
if (this.value.size * other.value.size > this.limit) {
|
|
172
|
+
const common = new Set(stepsInAll(this.value)).union(new Set(stepsInAll(other.value)));
|
|
173
|
+
return new BranchPathDomain([encodePath(common)], this.limit);
|
|
174
|
+
}
|
|
175
|
+
const theirs = [...other.value].map(stepsOf);
|
|
176
|
+
const mine = [...this.value].map(stepsOf);
|
|
177
|
+
return this.create(mine.flatMap(a => theirs.map(b => encodePath(a.union(b)))));
|
|
85
178
|
}
|
|
86
179
|
/** Every path continued by taking the branch. */
|
|
87
180
|
taking(step) {
|
|
@@ -89,7 +182,8 @@ class BranchPathDomain extends bounded_set_domain_1.BoundedSetDomain {
|
|
|
89
182
|
return this;
|
|
90
183
|
}
|
|
91
184
|
const taken = encodeStep(step);
|
|
92
|
-
|
|
185
|
+
const common = this.common;
|
|
186
|
+
return BranchPathDomain.withCommon(this.create([...this.value].map(path => withStep(path, taken))), common === undefined ? undefined : new Set(common).add(taken));
|
|
93
187
|
}
|
|
94
188
|
/**
|
|
95
189
|
* The paths, each a list of the branches it takes, `undefined` for Top. Two paths that only differ in which way one branch
|
package/config.js
CHANGED
|
@@ -21,6 +21,7 @@ const gas_1 = require("./gas");
|
|
|
21
21
|
const input_types_1 = require("./queries/catalog/input-sources-query/input-types");
|
|
22
22
|
const arrays_1 = require("./util/collections/arrays");
|
|
23
23
|
const secure_mode_1 = require("./util/secure-mode");
|
|
24
|
+
const global_caches_1 = require("./util/global-caches");
|
|
24
25
|
/** Marks an option that decides what flowR executes or loads, it is dropped from untrusted configs (see {@link FlowrConfig.fromFile}). */
|
|
25
26
|
function securitySensitive(schema) {
|
|
26
27
|
return schema.meta({ securitySensitive: true });
|
|
@@ -763,7 +764,8 @@ function persistSigDbPathToGlobalConfig(dbPath) {
|
|
|
763
764
|
fs_1.default.writeFileSync(file, JSON.stringify(raw, null, '\t') + '\n');
|
|
764
765
|
return file;
|
|
765
766
|
}
|
|
766
|
-
|
|
767
|
+
/** per schema meta tag, of which there are a handful */
|
|
768
|
+
const taggedPathsCache = global_caches_1.GlobalCaches.map('config-tagged-paths', global_caches_1.CacheScope.Process, 64);
|
|
767
769
|
function taggedPaths(meta) {
|
|
768
770
|
let paths = taggedPathsCache.get(meta);
|
|
769
771
|
if (paths === undefined) {
|
|
@@ -415,10 +415,10 @@ class ControlFlowGraph {
|
|
|
415
415
|
return this.revEdgeInfos;
|
|
416
416
|
}
|
|
417
417
|
outgoingEdges(node) {
|
|
418
|
-
return this.isView ?
|
|
418
|
+
return this.isView ? viewEdges(this.dfg, ViewOutgoing, node, dfg => dfg.outgoingEdges(node)) : this.edgeInfos.get(node);
|
|
419
419
|
}
|
|
420
420
|
ingoingEdges(node) {
|
|
421
|
-
return this.isView ?
|
|
421
|
+
return this.isView ? viewEdges(this.dfg, ViewIngoing, node, dfg => dfg.ingoingEdges(node)) : this.reverse().get(node);
|
|
422
422
|
}
|
|
423
423
|
/** @see {@link ReadOnlyControlFlowGraph#edgesFrom|edgesFrom()} */
|
|
424
424
|
edgesFrom(node) {
|
|
@@ -618,6 +618,22 @@ function deleteNestedEdge(map, from, to) {
|
|
|
618
618
|
map.delete(from);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
+
/** the keys under which a view keeps the control flow part of each vertex's edges with the dataflow graph, see {@link viewEdges} */
|
|
622
|
+
const ViewOutgoing = Symbol('cfg-view-outgoing');
|
|
623
|
+
const ViewIngoing = Symbol('cfg-view-ingoing');
|
|
624
|
+
/**
|
|
625
|
+
* The control flow part of the edges `edgesOf` gives for `node`, filtered once per vertex until the graph changes:
|
|
626
|
+
* a vertex read from many places has thousands of dataflow edges, and walks over the control flow ask for them again and again.
|
|
627
|
+
*/
|
|
628
|
+
function viewEdges(dfg, key, node, edgesOf) {
|
|
629
|
+
const known = dfg.derivedUntilChanged(key, () => new Map());
|
|
630
|
+
if (known.has(node)) {
|
|
631
|
+
return known.get(node);
|
|
632
|
+
}
|
|
633
|
+
const edges = controlFlowEdges(edgesOf(dfg));
|
|
634
|
+
known.set(node, edges);
|
|
635
|
+
return edges;
|
|
636
|
+
}
|
|
621
637
|
/** The control flow part of the given edges, or `undefined` if none of them carries any. */
|
|
622
638
|
function controlFlowEdges(edges) {
|
|
623
639
|
let result = undefined;
|