@eagleoutice/flowr 2.13.9 → 2.13.11
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 +40 -40
- package/config.d.ts +50 -2
- package/config.js +37 -6
- package/dataflow/environments/apply-kill.js +4 -4
- package/dataflow/environments/built-in-props.d.ts +28 -4
- package/dataflow/environments/built-in-props.js +31 -8
- package/dataflow/environments/built-in.d.ts +7 -2
- package/dataflow/environments/built-in.js +10 -12
- package/dataflow/environments/default-builtin-config.d.ts +46 -6
- package/dataflow/environments/default-builtin-config.js +30 -16
- package/dataflow/environments/environment.d.ts +16 -0
- package/dataflow/environments/environment.js +114 -26
- package/dataflow/environments/identifier.d.ts +6 -0
- package/dataflow/environments/identifier.js +18 -5
- package/dataflow/environments/query-fn-props.js +34 -2
- package/dataflow/environments/reference-to-maybe.js +1 -1
- package/dataflow/environments/resolve-by-name.js +16 -6
- package/dataflow/environments/resolve-helper.d.ts +43 -0
- package/dataflow/environments/resolve-helper.js +47 -0
- package/dataflow/eval/resolve/alias-tracking.js +45 -1
- package/dataflow/eval/resolve/resolve-argument.js +25 -17
- package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
- package/dataflow/eval/resolve/resolve-strings.js +16 -9
- package/dataflow/eval/resolve/resolve.js +3 -1
- package/dataflow/graph/call-graph.d.ts +7 -0
- package/dataflow/graph/call-graph.js +103 -0
- package/dataflow/graph/df-helper.d.ts +50 -1
- package/dataflow/graph/df-helper.js +63 -0
- package/dataflow/graph/graph.d.ts +5 -8
- package/dataflow/graph/graph.js +24 -13
- package/dataflow/internal/linker.d.ts +5 -5
- package/dataflow/internal/linker.js +31 -92
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
- package/documentation/data/faq/faqs.js +1 -1
- package/documentation/data/faq/wiki-faq-store.js +3 -2
- package/documentation/data/server/doc-data-server-messages.js +1 -1
- package/documentation/doc-readme.js +1 -1
- package/documentation/doc-util/doc-files.d.ts +5 -0
- package/documentation/doc-util/doc-files.js +13 -3
- package/documentation/doc-util/doc-sigdb.d.ts +9 -0
- package/documentation/doc-util/doc-sigdb.js +32 -0
- package/documentation/wiki-analyzer.js +10 -10
- package/documentation/wiki-core.js +1 -1
- package/documentation/wiki-dataflow-graph.js +3 -3
- package/documentation/wiki-interface.js +13 -2
- package/documentation/wiki-linting-and-testing.js +13 -13
- package/documentation/wiki-mk/doc-context.d.ts +1 -1
- package/documentation/wiki-mk/doc-context.js +9 -5
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-overview.js +2 -2
- package/documentation/wiki-query.js +4 -1
- package/documentation/wiki-setup.js +3 -3
- package/documentation/wiki-signature-database.js +2 -5
- package/gas.d.ts +6 -0
- package/gas.js +7 -1
- package/linter/linter-rules.d.ts +1 -1
- package/linter/rules/syntactically-valid.d.ts +12 -1
- package/linter/rules/syntactically-valid.js +88 -17
- package/package.json +7 -8
- package/project/attached-packages.d.ts +13 -0
- package/project/attached-packages.js +30 -0
- package/project/context/flowr-analyzer-context.d.ts +15 -0
- package/project/context/flowr-analyzer-context.js +14 -3
- package/project/context/flowr-analyzer-files-context.d.ts +11 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
- package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
- package/project/context/flowr-analyzer-loading-order-context.js +23 -2
- package/project/dependency-version-space.d.ts +33 -11
- package/project/dependency-version-space.js +58 -32
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/manifest.js +9 -5
- package/project/sigdb/reader.d.ts +20 -0
- package/project/sigdb/reader.js +93 -10
- package/project/sigdb/signature-match.d.ts +5 -18
- package/project/sigdb/signature-match.js +5 -18
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
- package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
- package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
- package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
- package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
- package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
- package/queries/catalog/dependencies-query/link-devices.js +104 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
- package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
- package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
- package/queries/catalog/input-sources-query/input-types.js +10 -0
- package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
- package/queries/catalog/signature-query/signature-query-executor.js +3 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
- package/queries/catalog/slice-query-options.d.ts +11 -1
- package/queries/catalog/slice-query-options.js +8 -4
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
- package/queries/query.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
- package/r-bridge/lang-4.x/ast/model/model.js +44 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
- package/reconstruct/reconstruct.d.ts +9 -0
- package/reconstruct/reconstruct.js +1 -0
- package/search/flowr-search-filters.d.ts +25 -1
- package/search/flowr-search-filters.js +42 -7
- package/search/search-executor/search-generators.js +7 -2
- package/search/search-executor/search-transformer.js +4 -1
- package/slicing/criterion/parse.d.ts +5 -25
- package/slicing/criterion/parse.js +15 -20
- package/slicing/static/fingerprint.js +18 -6
- package/slicing/static/slice-call.js +2 -2
- package/slicing/static/slicer-types.d.ts +10 -0
- package/slicing/static/static-slicer.d.ts +1 -1
- package/slicing/static/static-slicer.js +29 -6
- package/slicing/static/visiting-queue.d.ts +12 -2
- package/slicing/static/visiting-queue.js +28 -3
- package/util/arg-matching.d.ts +18 -0
- package/util/arg-matching.js +70 -0
- package/util/collections/bimap.d.ts +21 -1
- package/util/collections/bimap.js +43 -7
- package/util/r-regex.js +19 -1
- package/util/range.d.ts +7 -8
- package/util/range.js +10 -11
- package/util/version.js +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
2
2
|
import type { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
|
|
3
3
|
import type { BuiltInEvalHandlerArgs } from '../../environments/built-in';
|
|
4
|
+
import { PkgName } from '../../environments/identifier';
|
|
4
5
|
import { type Value } from '../values/r-value';
|
|
5
6
|
/** everything after the last separator, with trailing separators dropped first (`a/b/` is `b`, `/` is the empty string) */
|
|
6
7
|
declare function basename(path: string): string;
|
|
@@ -14,6 +15,8 @@ declare function dirname(path: string): string;
|
|
|
14
15
|
* returns `undefined` for, which keeps the call `Top`.
|
|
15
16
|
*/
|
|
16
17
|
export interface StringFn {
|
|
18
|
+
/** the package declaring it, so another package's function of that name does not fold */
|
|
19
|
+
readonly pkg: PkgName;
|
|
17
20
|
/** the parameter names, in the order R declares them; `...` collects the arguments naming no other parameter */
|
|
18
21
|
readonly params: readonly string[];
|
|
19
22
|
/** what a parameter R gives a default stands for, so `paste(a, b)` folds like `paste(a, b, sep = ' ')` */
|
|
@@ -33,6 +36,7 @@ export interface StringFn {
|
|
|
33
36
|
*/
|
|
34
37
|
export declare const StringFns: {
|
|
35
38
|
readonly paste: {
|
|
39
|
+
readonly pkg: PkgName.Base;
|
|
36
40
|
readonly params: readonly ["...", "sep"];
|
|
37
41
|
readonly defaults: {
|
|
38
42
|
readonly sep: " ";
|
|
@@ -41,6 +45,7 @@ export declare const StringFns: {
|
|
|
41
45
|
readonly fold: (parts: string[], sep: string) => string;
|
|
42
46
|
};
|
|
43
47
|
readonly paste0: {
|
|
48
|
+
readonly pkg: PkgName.Base;
|
|
44
49
|
readonly params: readonly ["...", "sep"];
|
|
45
50
|
readonly defaults: {
|
|
46
51
|
readonly sep: "";
|
|
@@ -49,34 +54,46 @@ export declare const StringFns: {
|
|
|
49
54
|
readonly fold: (parts: string[], sep: string) => string;
|
|
50
55
|
};
|
|
51
56
|
readonly 'file.path': {
|
|
57
|
+
readonly pkg: PkgName.Base;
|
|
52
58
|
readonly params: readonly ["...", "fsep"];
|
|
53
59
|
readonly defaults: {
|
|
54
60
|
readonly fsep: "/";
|
|
55
61
|
};
|
|
56
62
|
readonly fold: (parts: string[], fsep: string) => string;
|
|
57
63
|
};
|
|
64
|
+
readonly here: {
|
|
65
|
+
readonly pkg: PkgName.Here;
|
|
66
|
+
readonly params: readonly ["..."];
|
|
67
|
+
readonly fold: (parts: string[]) => string;
|
|
68
|
+
};
|
|
58
69
|
readonly basename: {
|
|
70
|
+
readonly pkg: PkgName.Base;
|
|
59
71
|
readonly params: readonly ["path"];
|
|
60
72
|
readonly fold: typeof basename;
|
|
61
73
|
};
|
|
62
74
|
readonly dirname: {
|
|
75
|
+
readonly pkg: PkgName.Base;
|
|
63
76
|
readonly params: readonly ["path"];
|
|
64
77
|
readonly fold: typeof dirname;
|
|
65
78
|
};
|
|
66
79
|
readonly toupper: {
|
|
80
|
+
readonly pkg: PkgName.Base;
|
|
67
81
|
readonly params: readonly ["x"];
|
|
68
82
|
readonly fold: (s: string) => string;
|
|
69
83
|
};
|
|
70
84
|
readonly tolower: {
|
|
85
|
+
readonly pkg: PkgName.Base;
|
|
71
86
|
readonly params: readonly ["x"];
|
|
72
87
|
readonly fold: (s: string) => string;
|
|
73
88
|
};
|
|
74
89
|
readonly trimws: {
|
|
90
|
+
readonly pkg: PkgName.Base;
|
|
75
91
|
readonly params: readonly ["x"];
|
|
76
92
|
readonly fold: (s: string) => string;
|
|
77
93
|
};
|
|
78
94
|
/** R counts characters, so we count code points rather than UTF-16 units */
|
|
79
95
|
readonly nchar: {
|
|
96
|
+
readonly pkg: PkgName.Base;
|
|
80
97
|
readonly params: readonly ["x"];
|
|
81
98
|
readonly fold: (s: string) => number;
|
|
82
99
|
};
|
|
@@ -38,18 +38,20 @@ function dirname(path) {
|
|
|
38
38
|
*/
|
|
39
39
|
exports.StringFns = {
|
|
40
40
|
/* the joining calls, which differ only in their separator and what the argument overriding it is called */
|
|
41
|
-
paste: { params: ['...', 'sep'], defaults: { sep: ' ' }, ignored: ['collapse'], fold: (parts, sep) => parts.join(sep) },
|
|
42
|
-
paste0: { params: ['...', 'sep'], defaults: { sep: '' }, ignored: ['collapse'], fold: (parts, sep) => parts.join(sep) },
|
|
43
|
-
'file.path': { params: ['...', 'fsep'], defaults: { fsep: '/' }, fold: (parts, fsep) => parts.join(fsep) },
|
|
41
|
+
paste: { pkg: "base" /* PkgName.Base */, params: ['...', 'sep'], defaults: { sep: ' ' }, ignored: ['collapse'], fold: (parts, sep) => parts.join(sep) },
|
|
42
|
+
paste0: { pkg: "base" /* PkgName.Base */, params: ['...', 'sep'], defaults: { sep: '' }, ignored: ['collapse'], fold: (parts, sep) => parts.join(sep) },
|
|
43
|
+
'file.path': { pkg: "base" /* PkgName.Base */, params: ['...', 'fsep'], defaults: { fsep: '/' }, fold: (parts, fsep) => parts.join(fsep) },
|
|
44
|
+
/* the project root stays implicit, so the fold yields the path below it */
|
|
45
|
+
here: { pkg: "here" /* PkgName.Here */, params: ['...'], fold: (parts) => parts.length > 0 ? parts.join('/') : '.' },
|
|
44
46
|
/* the path splits, which only ever treat `/` as a separator, so a Windows path keeps its non-`\` parts */
|
|
45
|
-
basename: { params: ['path'], fold: basename },
|
|
46
|
-
dirname: { params: ['path'], fold: dirname },
|
|
47
|
+
basename: { pkg: "base" /* PkgName.Base */, params: ['path'], fold: basename },
|
|
48
|
+
dirname: { pkg: "base" /* PkgName.Base */, params: ['path'], fold: dirname },
|
|
47
49
|
/* whole-string transformations */
|
|
48
|
-
toupper: { params: ['x'], fold: (s) => s.toUpperCase() },
|
|
49
|
-
tolower: { params: ['x'], fold: (s) => s.toLowerCase() },
|
|
50
|
-
trimws: { params: ['x'], fold: (s) => s.trim() },
|
|
50
|
+
toupper: { pkg: "base" /* PkgName.Base */, params: ['x'], fold: (s) => s.toUpperCase() },
|
|
51
|
+
tolower: { pkg: "base" /* PkgName.Base */, params: ['x'], fold: (s) => s.toLowerCase() },
|
|
52
|
+
trimws: { pkg: "base" /* PkgName.Base */, params: ['x'], fold: (s) => s.trim() },
|
|
51
53
|
/** R counts characters, so we count code points rather than UTF-16 units */
|
|
52
|
-
nchar: { params: ['x'], fold: (s) => [...s].length }
|
|
54
|
+
nchar: { pkg: "base" /* PkgName.Base */, params: ['x'], fold: (s) => [...s].length }
|
|
53
55
|
};
|
|
54
56
|
/** the entries that join what they are handed, the ones a name at construction time may be built from */
|
|
55
57
|
exports.PasteLikeCalls = new Set(Object.entries(exports.StringFns).filter(([, fn]) => fn.params.includes('...')).map(([name]) => name));
|
|
@@ -63,6 +65,11 @@ function foldStringCall(node, resolveArg) {
|
|
|
63
65
|
if (known === undefined) {
|
|
64
66
|
return undefined;
|
|
65
67
|
}
|
|
68
|
+
/* `dplyr::paste` is not `base::paste`; a bare call has already been resolved */
|
|
69
|
+
const ns = identifier_1.Identifier.getNamespace(node.functionName.content);
|
|
70
|
+
if (ns !== undefined && ns !== known.pkg) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
66
73
|
const matched = (0, match_arguments_1.matchCallArguments)(node, known.params, known.ignored);
|
|
67
74
|
if (matched === undefined) {
|
|
68
75
|
return undefined;
|
|
@@ -49,7 +49,9 @@ function evalNameOf({ node, graph }) {
|
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
51
|
/* an alias like `f <- c` keeps the built-in it stands for in `proc`, a direct call names itself */
|
|
52
|
-
const
|
|
52
|
+
const pkgFn = node_id_1.NodeId.toPkgFn(origin.proc);
|
|
53
|
+
const named = pkgFn !== undefined ? identifier_1.Identifier.make(pkgFn[1], pkgFn[0])
|
|
54
|
+
: node_id_1.NodeId.isBuiltIn(origin.proc) ? node_id_1.NodeId.fromBuiltIn(origin.proc) : origin.fn.name;
|
|
53
55
|
if (name !== undefined && identifier_1.Identifier.getName(name) !== identifier_1.Identifier.getName(named)) {
|
|
54
56
|
return undefined;
|
|
55
57
|
}
|
|
@@ -24,6 +24,13 @@ export declare const CallGraph: {
|
|
|
24
24
|
* Extracts the sub call graph from the given call graph, starting from the given entry points.
|
|
25
25
|
*/
|
|
26
26
|
readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph;
|
|
27
|
+
/** The calls the program makes on its own: those outside of any function definition. */
|
|
28
|
+
readonly entryPoints: (this: void, graph: CallGraph) => Set<NodeId>;
|
|
29
|
+
/**
|
|
30
|
+
* The calls no execution starting at the top level reaches: those in a function nothing (transitively) calls.
|
|
31
|
+
* What {@link mayRunAnyway} may still run is left out, so a call reported here really does not run.
|
|
32
|
+
*/
|
|
33
|
+
readonly unreachableCalls: (this: void, graph: CallGraph) => NodeId[];
|
|
27
34
|
/**
|
|
28
35
|
* Reduces the call graph by dropping all transitive edges.
|
|
29
36
|
*/
|
|
@@ -9,6 +9,11 @@ const edge_1 = require("./edge");
|
|
|
9
9
|
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
10
10
|
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
11
11
|
const graph_helper_1 = require("./graph-helper");
|
|
12
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
13
|
+
const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
14
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
15
|
+
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
16
|
+
const identifier_1 = require("../environments/identifier");
|
|
12
17
|
function processCds(vtx, graph, result, state) {
|
|
13
18
|
for (const tar of vtx.cds ?? []) {
|
|
14
19
|
const targetVtx = graph.getVertex(tar.id);
|
|
@@ -154,6 +159,74 @@ function processFunctionDefinition(vtx, from, graph, result, state) {
|
|
|
154
159
|
}
|
|
155
160
|
}
|
|
156
161
|
}
|
|
162
|
+
/** Follows the `Calls` edges from `seeds`, collecting everything they reach in `reached`. */
|
|
163
|
+
function followCalls(graph, seeds, reached) {
|
|
164
|
+
const toVisit = Array.from(seeds);
|
|
165
|
+
while (toVisit.length > 0) {
|
|
166
|
+
const current = toVisit.pop();
|
|
167
|
+
if (reached.has(current)) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
reached.add(current);
|
|
171
|
+
for (const [target, edge] of graph.outgoingEdges(current) ?? []) {
|
|
172
|
+
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
173
|
+
toVisit.push(target);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** The names the reached calls go by, which are the generics a method of the program may be dispatched to for. */
|
|
179
|
+
function reachedCallNames(graph, reached) {
|
|
180
|
+
const names = new Set();
|
|
181
|
+
for (const id of reached) {
|
|
182
|
+
const vertex = graph.getVertex(id);
|
|
183
|
+
if (vertex?.tag === vertex_1.VertexType.FunctionCall) {
|
|
184
|
+
names.add(identifier_1.Identifier.getName(vertex.name));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return names;
|
|
188
|
+
}
|
|
189
|
+
/** Whether `name` is a `<generic>.<class>` of a generic that is called, as `print.foo` is when `print` is. */
|
|
190
|
+
function mayBeDispatchedTo(name, generics) {
|
|
191
|
+
for (let dot = name.indexOf('.'); dot > 0; dot = name.indexOf('.', dot + 1)) {
|
|
192
|
+
if (generics.has(name.slice(0, dot))) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The unreached function definitions that may still run: one the code hands to another call (a callback, an
|
|
200
|
+
* S4 method, a shiny handler), and one bound to a `<generic>.<class>` name of a generic the program calls.
|
|
201
|
+
*/
|
|
202
|
+
function mayRunAnyway(graph, reached) {
|
|
203
|
+
const idMap = graph.idMap;
|
|
204
|
+
if (idMap === undefined) {
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
const seeds = [];
|
|
208
|
+
let generics;
|
|
209
|
+
for (const [id, vertex] of graph.vertices(true)) {
|
|
210
|
+
if (vertex.tag !== vertex_1.VertexType.FunctionDefinition || reached.has(id)) {
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const node = idMap.get(id);
|
|
214
|
+
if (node === undefined) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
const parent = model_1.RNode.directParent(node, idMap);
|
|
218
|
+
if (parent?.type === type_1.RType.Argument) {
|
|
219
|
+
seeds.push(id);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const bound = r_binary_op_1.RBinaryOp.is(parent) ? model_1.RNode.lexeme(parent.lhs) : undefined;
|
|
223
|
+
generics ??= reachedCallNames(graph, reached);
|
|
224
|
+
if (bound !== undefined && mayBeDispatchedTo(bound, generics)) {
|
|
225
|
+
seeds.push(id);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return seeds;
|
|
229
|
+
}
|
|
157
230
|
/**
|
|
158
231
|
* Helper object for call-graphs, you can compute new call graphs based on {@link CallGraph.compute}.
|
|
159
232
|
* @see {@link Dataflow}
|
|
@@ -189,6 +262,36 @@ exports.CallGraph = {
|
|
|
189
262
|
}
|
|
190
263
|
return result;
|
|
191
264
|
},
|
|
265
|
+
/** The calls the program makes on its own: those outside of any function definition. */
|
|
266
|
+
entryPoints(graph) {
|
|
267
|
+
const entries = new Set();
|
|
268
|
+
const idMap = graph.idMap;
|
|
269
|
+
if (idMap === undefined) {
|
|
270
|
+
return entries;
|
|
271
|
+
}
|
|
272
|
+
for (const [id, vertex] of graph.vertices(true)) {
|
|
273
|
+
const node = vertex.tag === vertex_1.VertexType.FunctionCall ? idMap.get(id) : undefined;
|
|
274
|
+
if (node !== undefined && r_function_definition_1.RFunctionDefinition.wrappingFunctionDefinition(node, idMap) === undefined) {
|
|
275
|
+
entries.add(id);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return entries;
|
|
279
|
+
},
|
|
280
|
+
/**
|
|
281
|
+
* The calls no execution starting at the top level reaches: those in a function nothing (transitively) calls.
|
|
282
|
+
* What {@link mayRunAnyway} may still run is left out, so a call reported here really does not run.
|
|
283
|
+
*/
|
|
284
|
+
unreachableCalls(graph) {
|
|
285
|
+
const reached = new Set();
|
|
286
|
+
followCalls(graph, exports.CallGraph.entryPoints(graph), reached);
|
|
287
|
+
for (let seeds = mayRunAnyway(graph, reached); seeds.length > 0; seeds = mayRunAnyway(graph, reached)) {
|
|
288
|
+
followCalls(graph, seeds, reached);
|
|
289
|
+
}
|
|
290
|
+
return graph.vertices(true)
|
|
291
|
+
.filter(([id, vertex]) => vertex.tag === vertex_1.VertexType.FunctionCall && !reached.has(id))
|
|
292
|
+
.map(([id]) => id)
|
|
293
|
+
.toArray();
|
|
294
|
+
},
|
|
192
295
|
/**
|
|
193
296
|
* Reduces the call graph by dropping all transitive edges.
|
|
194
297
|
*/
|
|
@@ -4,7 +4,7 @@ import { emptyGraph } from './dataflowgraph-builder';
|
|
|
4
4
|
import { getOriginInDfg } from '../origin/dfg-get-origin';
|
|
5
5
|
import { CallGraph } from './call-graph';
|
|
6
6
|
import { computeCallGraphSummaries, propagateTransitiveSideEffects } from '../internal/process/functions/call/built-in/transitive-side-effects';
|
|
7
|
-
import
|
|
7
|
+
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
8
8
|
import type { REnvironmentInformation } from '../environments/environment';
|
|
9
9
|
import type { DataflowGraphVertexInfo } from './vertex';
|
|
10
10
|
import { Identifier } from '../environments/identifier';
|
|
@@ -15,6 +15,9 @@ import { Identifier } from '../environments/identifier';
|
|
|
15
15
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
16
16
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
17
17
|
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call from its id and graph,
|
|
18
|
+
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
19
|
+
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
20
|
+
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
18
21
|
*/
|
|
19
22
|
export declare const Dataflow: {
|
|
20
23
|
/**
|
|
@@ -45,6 +48,8 @@ export declare const Dataflow: {
|
|
|
45
48
|
*/
|
|
46
49
|
readonly callGraph: {
|
|
47
50
|
readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph;
|
|
51
|
+
readonly entryPoints: (this: void, graph: CallGraph) => Set<NodeId>;
|
|
52
|
+
readonly unreachableCalls: (this: void, graph: CallGraph) => NodeId[];
|
|
48
53
|
readonly dropTransitiveEdges: (this: void, graph: CallGraph) => CallGraph;
|
|
49
54
|
readonly compute: (this: void, graph: DataflowGraph) => CallGraph;
|
|
50
55
|
readonly visualize: {
|
|
@@ -83,6 +88,26 @@ export declare const Dataflow: {
|
|
|
83
88
|
* @see {@link getOriginInDfg} - for the underlying function
|
|
84
89
|
*/
|
|
85
90
|
readonly origin: typeof getOriginInDfg;
|
|
91
|
+
/**
|
|
92
|
+
* Name and value resolution.
|
|
93
|
+
* @see {@link Resolve} - the helper object itself, which documents which entry point to reach for
|
|
94
|
+
*/
|
|
95
|
+
readonly resolve: {
|
|
96
|
+
readonly name: "Resolve";
|
|
97
|
+
readonly byName: typeof import("../environments/resolve-by-name").resolveByNameAnyType;
|
|
98
|
+
readonly byNameAndType: typeof import("../environments/resolve-by-name").resolveByName;
|
|
99
|
+
readonly toBuiltIn: typeof import("../environments/resolve-by-name").resolvesToBuiltInConstant;
|
|
100
|
+
readonly toConstants: typeof import("../eval/resolve/alias-tracking").resolveToConstants;
|
|
101
|
+
readonly toValue: typeof import("../eval/resolve/alias-tracking").resolveIdToValue;
|
|
102
|
+
readonly toSingleString: typeof import("../eval/resolve/alias-tracking").resolveIdToSingleString;
|
|
103
|
+
readonly argument: {
|
|
104
|
+
readonly name: typeof import("../../abstract-interpretation/data-frame/resolve-args").resolveIdToArgName;
|
|
105
|
+
readonly value: typeof import("../../abstract-interpretation/data-frame/resolve-args").resolveIdToArgValue;
|
|
106
|
+
readonly stringVector: typeof import("../../abstract-interpretation/data-frame/resolve-args").resolveIdToArgStringVector;
|
|
107
|
+
readonly symbolName: typeof import("../../abstract-interpretation/data-frame/resolve-args").resolveIdToArgValueSymbolName;
|
|
108
|
+
readonly vectorLength: typeof import("../../abstract-interpretation/data-frame/resolve-args").resolveIdToArgVectorLength;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
86
111
|
/**
|
|
87
112
|
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
88
113
|
* export and is not itself already namespaced (with `purrr` loaded, a `map()` call yields
|
|
@@ -97,6 +122,30 @@ export declare const Dataflow: {
|
|
|
97
122
|
* Set this to `false` to only qualify what the origins resolve to (or what is already namespaced).
|
|
98
123
|
*/
|
|
99
124
|
readonly qualify: (this: void, id: NodeId, graph: DataflowGraph, qualifyBaseR?: boolean) => Identifier | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* The packages the given nodes call into, as {@link Dataflow.qualify} resolves every call among them.
|
|
127
|
+
* This is what a selection needs, which is not what the program loads: a `library()` whose exports the
|
|
128
|
+
* selection never calls does not make the package needed. Base R is left out unless `includeBaseR`.
|
|
129
|
+
* @param nodes - the ids to consider, e.g. the result of a slice
|
|
130
|
+
* @param graph - the graph the ids belong to
|
|
131
|
+
* @param includeBaseR - whether to also report base-R packages
|
|
132
|
+
*/
|
|
133
|
+
readonly packagesOf: (this: void, nodes: Iterable<NodeId>, graph: DataflowGraph, includeBaseR?: boolean) => Set<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the call's result is passed on -- assigned, handed to another call, returned -- rather than left
|
|
136
|
+
* for R to auto-print. A bare `anova(a, b)` is an output the program reports; the `summary(m)` of
|
|
137
|
+
* `x <- summary(m)` is not.
|
|
138
|
+
*
|
|
139
|
+
* Only an edge that carries the value counts. A plain {@link EdgeType.Reads} does not: it also chains the
|
|
140
|
+
* calls that share a side effect, which would report `plot(x)` as consumed by the `lines(y)` drawn after it.
|
|
141
|
+
*/
|
|
142
|
+
readonly valueIsUsed: (this: void, id: NodeId, graph: DataflowGraph) => boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Whether any argument of the call carries a value the program worked out, rather than only literals the
|
|
145
|
+
* author typed: `cat("starting\n")` is a log line, `cat("n =", length(m))` is a finding.
|
|
146
|
+
* A call among the arguments counts as computed, even one over literals such as `paste("a", "b")`.
|
|
147
|
+
*/
|
|
148
|
+
readonly hasComputedArguments: (this: void, id: NodeId, graph: DataflowGraph) => boolean;
|
|
100
149
|
/**
|
|
101
150
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
102
151
|
*/
|
|
@@ -8,9 +8,12 @@ const dfg_get_origin_1 = require("../origin/dfg-get-origin");
|
|
|
8
8
|
const graph_helper_1 = require("./graph-helper");
|
|
9
9
|
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
|
+
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
11
12
|
const vertex_1 = require("./vertex");
|
|
12
13
|
const identifier_1 = require("../environments/identifier");
|
|
14
|
+
const resolve_helper_1 = require("../environments/resolve-helper");
|
|
13
15
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
16
|
+
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
14
17
|
/**
|
|
15
18
|
* This is the root helper object to work with the {@link DataflowGraph}.
|
|
16
19
|
*
|
|
@@ -18,6 +21,9 @@ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
|
18
21
|
* - {@link Dataflow.views} - for working with specific views of the dataflow graph (e.g., the call graph),
|
|
19
22
|
* - {@link Dataflow.edge} - for working with the edges in the dataflow graph,
|
|
20
23
|
* - {@link Dataflow.qualify} - for the package-qualified `pkg::fn` identifier of a call from its id and graph,
|
|
24
|
+
* - {@link Dataflow.resolve} - for resolving a name against an environment,
|
|
25
|
+
* - {@link Dataflow.packagesOf} - for the packages a set of nodes (e.g. a slice) calls into,
|
|
26
|
+
* - {@link Dataflow.valueIsUsed}/{@link Dataflow.hasComputedArguments} - for what a call does with, and gets as, values,
|
|
21
27
|
*/
|
|
22
28
|
exports.Dataflow = {
|
|
23
29
|
name: 'Dataflow',
|
|
@@ -55,6 +61,11 @@ exports.Dataflow = {
|
|
|
55
61
|
* @see {@link getOriginInDfg} - for the underlying function
|
|
56
62
|
*/
|
|
57
63
|
origin: dfg_get_origin_1.getOriginInDfg,
|
|
64
|
+
/**
|
|
65
|
+
* Name and value resolution.
|
|
66
|
+
* @see {@link Resolve} - the helper object itself, which documents which entry point to reach for
|
|
67
|
+
*/
|
|
68
|
+
resolve: resolve_helper_1.Resolve,
|
|
58
69
|
/**
|
|
59
70
|
* The qualified identifier of the call with the given id, or `undefined` if it does not resolve to a package
|
|
60
71
|
* export and is not itself already namespaced (with `purrr` loaded, a `map()` call yields
|
|
@@ -72,6 +83,58 @@ exports.Dataflow = {
|
|
|
72
83
|
const vertex = graph.getVertex(id);
|
|
73
84
|
return identifier_1.Identifier.toQualified((0, dfg_get_origin_1.getOriginInDfg)(graph, id), vertex_1.FunctionCallVertex.is(vertex) ? vertex.name : undefined, qualifyBaseR);
|
|
74
85
|
},
|
|
86
|
+
/**
|
|
87
|
+
* The packages the given nodes call into, as {@link Dataflow.qualify} resolves every call among them.
|
|
88
|
+
* This is what a selection needs, which is not what the program loads: a `library()` whose exports the
|
|
89
|
+
* selection never calls does not make the package needed. Base R is left out unless `includeBaseR`.
|
|
90
|
+
* @param nodes - the ids to consider, e.g. the result of a slice
|
|
91
|
+
* @param graph - the graph the ids belong to
|
|
92
|
+
* @param includeBaseR - whether to also report base-R packages
|
|
93
|
+
*/
|
|
94
|
+
packagesOf(nodes, graph, includeBaseR = false) {
|
|
95
|
+
const packages = new Set();
|
|
96
|
+
for (const id of nodes) {
|
|
97
|
+
if (!vertex_1.FunctionCallVertex.is(graph.getVertex(id))) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const qualified = exports.Dataflow.qualify(id, graph, includeBaseR);
|
|
101
|
+
const pkg = qualified === undefined ? undefined : identifier_1.Identifier.getNamespace(qualified);
|
|
102
|
+
if (pkg !== undefined && (includeBaseR || !(0, r_base_packages_1.isBaseRPackage)(pkg))) {
|
|
103
|
+
packages.add(pkg);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return packages;
|
|
107
|
+
},
|
|
108
|
+
/**
|
|
109
|
+
* Whether the call's result is passed on -- assigned, handed to another call, returned -- rather than left
|
|
110
|
+
* for R to auto-print. A bare `anova(a, b)` is an output the program reports; the `summary(m)` of
|
|
111
|
+
* `x <- summary(m)` is not.
|
|
112
|
+
*
|
|
113
|
+
* Only an edge that carries the value counts. A plain {@link EdgeType.Reads} does not: it also chains the
|
|
114
|
+
* calls that share a side effect, which would report `plot(x)` as consumed by the `lines(y)` drawn after it.
|
|
115
|
+
*/
|
|
116
|
+
valueIsUsed(id, graph) {
|
|
117
|
+
const consuming = edge_1.EdgeType.Argument | edge_1.EdgeType.Returns | edge_1.EdgeType.DefinedBy;
|
|
118
|
+
for (const [, edge] of graph.ingoingEdges(id) ?? []) {
|
|
119
|
+
if ((edge.types & consuming) !== 0) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Whether any argument of the call carries a value the program worked out, rather than only literals the
|
|
127
|
+
* author typed: `cat("starting\n")` is a log line, `cat("n =", length(m))` is a finding.
|
|
128
|
+
* A call among the arguments counts as computed, even one over literals such as `paste("a", "b")`.
|
|
129
|
+
*/
|
|
130
|
+
hasComputedArguments(id, graph) {
|
|
131
|
+
for (const [target] of graph.outgoingEdges(id) ?? []) {
|
|
132
|
+
if (!node_id_1.NodeId.isBuiltIn(target) && graph.getVertex(target)?.tag !== vertex_1.VertexType.Value) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return false;
|
|
137
|
+
},
|
|
75
138
|
/**
|
|
76
139
|
* Interprocedural propagation of escaped side effects (attached packages, `<<-` definitions) to their callers.
|
|
77
140
|
*/
|
|
@@ -156,15 +156,12 @@ export interface DataflowGraphJson {
|
|
|
156
156
|
* Linked side effects are used whenever we know that a call may be affected by another one in a way that we cannot
|
|
157
157
|
* grasp from the dataflow perspective (e.g., an indirect dependency based on the currently active graphic device).
|
|
158
158
|
*/
|
|
159
|
-
export type UnknownSideEffect = NodeId |
|
|
160
|
-
id: NodeId;
|
|
161
|
-
linkTo: LinkTo<RegExp>;
|
|
162
|
-
};
|
|
159
|
+
export type UnknownSideEffect = NodeId | LinkedUnknownSideEffect;
|
|
163
160
|
/** A {@link UnknownSideEffect} that carries a {@link LinkTo} target. */
|
|
164
|
-
export
|
|
165
|
-
id: NodeId;
|
|
166
|
-
linkTo: LinkTo<RegExp>;
|
|
167
|
-
}
|
|
161
|
+
export interface LinkedUnknownSideEffect {
|
|
162
|
+
readonly id: NodeId;
|
|
163
|
+
readonly linkTo: LinkTo<RegExp>;
|
|
164
|
+
}
|
|
168
165
|
/**
|
|
169
166
|
* Helpers for the {@link UnknownSideEffect} union, which is either a plain {@link NodeId} or a
|
|
170
167
|
* `{ id, linkTo }` object. Use these instead of hand-rolling `typeof x === 'object' ? x.id : x`
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -178,8 +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
|
|
182
|
-
* lookup made every caller asking for the ingoing
|
|
181
|
+
/* the reverse of `edgeInformation`, built on demand, then kept up to date by `addEdge` and dropped only on a
|
|
182
|
+
* bulk write (`mergeEdges`, `fromJson`): rebuilding it per lookup made every caller asking for the ingoing
|
|
183
|
+
* edges of many nodes scan the whole graph once per node */
|
|
183
184
|
incomingIndex;
|
|
184
185
|
types = new Map();
|
|
185
186
|
toJSON() {
|
|
@@ -362,20 +363,30 @@ class DataflowGraph {
|
|
|
362
363
|
if (fromId === toId) {
|
|
363
364
|
return this;
|
|
364
365
|
}
|
|
365
|
-
|
|
366
|
-
|
|
366
|
+
const fromEdges = this.edgeInformation.get(fromId);
|
|
367
|
+
const existing = fromEdges?.get(toId);
|
|
368
|
+
if (existing !== undefined) {
|
|
369
|
+
/* the reverse index holds this very object, so a widened type is already visible through it */
|
|
370
|
+
existing.types |= type;
|
|
371
|
+
return this;
|
|
372
|
+
}
|
|
373
|
+
const added = { types: type };
|
|
367
374
|
if (fromEdges === undefined) {
|
|
368
|
-
|
|
369
|
-
this.edgeInformation.set(fromId, fromEdges);
|
|
375
|
+
this.edgeInformation.set(fromId, new Map([[toId, added]]));
|
|
370
376
|
}
|
|
371
377
|
else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
378
|
+
fromEdges.set(toId, added);
|
|
379
|
+
}
|
|
380
|
+
/*
|
|
381
|
+
* carry the new edge into the reverse index rather than dropping it: construction interleaves `addEdge`
|
|
382
|
+
* with `ingoingEdges`, and rebuilding costs a pass over every edge in the graph each time
|
|
383
|
+
*/
|
|
384
|
+
const into = this.incomingIndex?.get(toId);
|
|
385
|
+
if (into !== undefined) {
|
|
386
|
+
into.set(fromId, added);
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
this.incomingIndex?.set(toId, new Map([[fromId, added]]));
|
|
379
390
|
}
|
|
380
391
|
return this;
|
|
381
392
|
}
|
|
@@ -18,15 +18,15 @@ export declare function findNonLocalReads(graph: DataflowGraph, ignores?: Readon
|
|
|
18
18
|
*/
|
|
19
19
|
export declare function produceNameSharedIdMap(references: IdentifierReference[]): NameIdMap;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching
|
|
24
|
-
* This returns the resolved map from argument ids to parameter ids.
|
|
21
|
+
* {@link matchArgumentsToParameters|Matches} the arguments to the parameters and links them in the graph,
|
|
22
|
+
* returning the resolved map from argument ids to parameter ids.
|
|
25
23
|
* If you just want to match by name, use {@link pMatch}.
|
|
26
24
|
*/
|
|
27
25
|
export declare function linkArgumentsOnCall(args: readonly FunctionArgument[], params: readonly RParameter<ParentInformation>[], graph: DataflowGraph): Map<NodeId, NodeId>;
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
27
|
+
* {@link matchArgumentsToParameters|Matches} the arguments against a parameter specification, returning the
|
|
28
|
+
* arguments bound to each target. Unlike {@link linkArgumentsOnCall} this touches no graph, so it also works
|
|
29
|
+
* for a specification without parameters in the AST.
|
|
30
30
|
* @example
|
|
31
31
|
* ```ts
|
|
32
32
|
* const parameterSpec = {
|