@eagleoutice/flowr 2.13.9 → 2.13.10
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/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 +70 -18
- 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/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 +2 -0
- package/dataflow/graph/graph.d.ts +5 -8
- 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/doc-util/doc-sigdb.d.ts +9 -0
- package/documentation/doc-util/doc-sigdb.js +32 -0
- package/documentation/wiki-interface.js +13 -2
- package/documentation/wiki-query.js +3 -0
- package/documentation/wiki-signature-database.js +2 -5
- package/gas.d.ts +6 -0
- package/gas.js +7 -1
- package/package.json +1 -1
- 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/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/signature-match.d.ts +5 -18
- package/project/sigdb/signature-match.js +5 -18
- 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 +10 -3
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +19 -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 +12 -0
- package/queries/catalog/dependencies-query/link-devices.js +58 -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/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/query.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/model.d.ts +14 -2
- package/r-bridge/lang-4.x/ast/model/model.js +32 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +7 -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 +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -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/search/flowr-search-filters.d.ts +17 -1
- package/search/flowr-search-filters.js +23 -0
- 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/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/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
|
*/
|
|
@@ -45,6 +45,8 @@ export declare const Dataflow: {
|
|
|
45
45
|
*/
|
|
46
46
|
readonly callGraph: {
|
|
47
47
|
readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph;
|
|
48
|
+
readonly entryPoints: (this: void, graph: CallGraph) => Set<NodeId>;
|
|
49
|
+
readonly unreachableCalls: (this: void, graph: CallGraph) => NodeId[];
|
|
48
50
|
readonly dropTransitiveEdges: (this: void, graph: CallGraph) => CallGraph;
|
|
49
51
|
readonly compute: (this: void, graph: DataflowGraph) => CallGraph;
|
|
50
52
|
readonly visualize: {
|
|
@@ -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`
|
|
@@ -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 = {
|
|
@@ -23,7 +23,7 @@ const edge_1 = require("../graph/edge");
|
|
|
23
23
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
24
24
|
const vertex_1 = require("../graph/vertex");
|
|
25
25
|
const resolve_by_name_1 = require("../environments/resolve-by-name");
|
|
26
|
-
const
|
|
26
|
+
const arg_matching_1 = require("../../util/arg-matching");
|
|
27
27
|
const info_1 = require("../info");
|
|
28
28
|
const unnamed_call_handling_1 = require("./process/functions/call/unnamed-call-handling");
|
|
29
29
|
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
@@ -71,72 +71,40 @@ function produceNameSharedIdMap(references) {
|
|
|
71
71
|
}
|
|
72
72
|
return nameIdShares;
|
|
73
73
|
}
|
|
74
|
+
/** the argument names as {@link matchArgumentsToParameters} wants them */
|
|
75
|
+
function argumentNames(args) {
|
|
76
|
+
return args.map(a => graph_1.FunctionArgument.isNamed(a) ? a.name : undefined);
|
|
77
|
+
}
|
|
74
78
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching
|
|
78
|
-
* This returns the resolved map from argument ids to parameter ids.
|
|
79
|
+
* {@link matchArgumentsToParameters|Matches} the arguments to the parameters and links them in the graph,
|
|
80
|
+
* returning the resolved map from argument ids to parameter ids.
|
|
79
81
|
* If you just want to match by name, use {@link pMatch}.
|
|
80
82
|
*/
|
|
81
83
|
function linkArgumentsOnCall(args, params, graph) {
|
|
82
|
-
const
|
|
83
|
-
const nameParamMap = new Map(params.filter(p => p?.name?.content !== undefined)
|
|
84
|
-
.map(p => [p.name.content, p]));
|
|
84
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(argumentNames(args), params.map(p => p?.special ? arg_matching_1.DotsParameterName : p?.name?.content));
|
|
85
85
|
const maps = new Map();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
// all parameters matched by name
|
|
89
|
-
const matchedParameters = new Set();
|
|
90
|
-
const paramNames = nameParamMap.keys().toArray();
|
|
91
|
-
// first map names
|
|
92
|
-
for (const [name, { nodeId: argId }] of nameArgMap) {
|
|
93
|
-
const pmatchName = (0, prefix_1.findByPrefixIfUnique)(name, paramNames) ?? name;
|
|
94
|
-
const param = nameParamMap.get(pmatchName);
|
|
95
|
-
if (param?.name) {
|
|
96
|
-
const pid = param.name.info.id;
|
|
97
|
-
graph.addEdge(argId, pid, edge_1.EdgeType.DefinesOnCall);
|
|
98
|
-
graph.addEdge(pid, argId, edge_1.EdgeType.DefinedByOnCall);
|
|
99
|
-
maps.set(argId, pid);
|
|
100
|
-
matchedParameters.add(name);
|
|
101
|
-
}
|
|
102
|
-
else if (sid) {
|
|
103
|
-
graph.addEdge(argId, sid, edge_1.EdgeType.DefinesOnCall);
|
|
104
|
-
graph.addEdge(sid, argId, edge_1.EdgeType.DefinedByOnCall);
|
|
105
|
-
maps.set(argId, sid);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
const remainingParameter = params.filter(p => !p?.name || !matchedParameters.has(p.name.content));
|
|
109
|
-
const remainingArguments = args.filter(graph_1.FunctionArgument.isUnnamed);
|
|
110
|
-
for (let i = 0; i < remainingArguments.length; i++) {
|
|
111
|
-
const arg = remainingArguments[i];
|
|
86
|
+
for (let i = 0; i < args.length; i++) {
|
|
87
|
+
const arg = args[i];
|
|
112
88
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
113
89
|
continue;
|
|
114
90
|
}
|
|
91
|
+
const param = matched[i];
|
|
92
|
+
const pid = param === undefined ? undefined : params[param].name?.info.id;
|
|
115
93
|
const aid = arg.nodeId;
|
|
116
|
-
if (
|
|
117
|
-
|
|
118
|
-
graph.addEdge(aid, sid, edge_1.EdgeType.DefinesOnCall);
|
|
119
|
-
graph.addEdge(sid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
120
|
-
maps.set(aid, sid);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
logger_1.dataflowLogger.warn(`skipping argument ${i} as there is no corresponding parameter - R should block that`);
|
|
124
|
-
}
|
|
94
|
+
if (pid === undefined) {
|
|
95
|
+
logger_1.dataflowLogger.warn(`skipping argument ${i} (id: ${aid}) as there is no corresponding parameter - R should block that`);
|
|
125
96
|
continue;
|
|
126
97
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const pid = param.name.info.id;
|
|
131
|
-
graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
|
|
132
|
-
graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
133
|
-
maps.set(aid, pid);
|
|
134
|
-
}
|
|
98
|
+
graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
|
|
99
|
+
graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
|
|
100
|
+
maps.set(aid, pid);
|
|
135
101
|
}
|
|
136
102
|
return maps;
|
|
137
103
|
}
|
|
138
104
|
/**
|
|
139
|
-
*
|
|
105
|
+
* {@link matchArgumentsToParameters|Matches} the arguments against a parameter specification, returning the
|
|
106
|
+
* arguments bound to each target. Unlike {@link linkArgumentsOnCall} this touches no graph, so it also works
|
|
107
|
+
* for a specification without parameters in the AST.
|
|
140
108
|
* @example
|
|
141
109
|
* ```ts
|
|
142
110
|
* const parameterSpec = {
|
|
@@ -155,50 +123,21 @@ function linkArgumentsOnCall(args, params, graph) {
|
|
|
155
123
|
* or convert them with {@link convertFnArguments}.
|
|
156
124
|
*/
|
|
157
125
|
function pMatch(args, params) {
|
|
158
|
-
const nameArgMap = new Map(args.filter(graph_1.FunctionArgument.isNamed).map(a => [a.name, a]));
|
|
159
|
-
const maps = new Map();
|
|
160
|
-
function addToMaps(key, value) {
|
|
161
|
-
const e = maps.get(key);
|
|
162
|
-
if (e) {
|
|
163
|
-
e.push(value);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
maps.set(key, [value]);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
const sid = params['...'];
|
|
170
126
|
const paramNames = Object.keys(params);
|
|
171
|
-
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const param = params[pmatchName];
|
|
177
|
-
if (param) {
|
|
178
|
-
addToMaps(param, argId);
|
|
179
|
-
matchedParameters.add(name);
|
|
180
|
-
}
|
|
181
|
-
else if (sid) {
|
|
182
|
-
addToMaps(sid, argId);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
const remainingParameter = paramNames.filter(p => !matchedParameters.has(p));
|
|
186
|
-
const remainingArguments = args.filter(graph_1.FunctionArgument.isUnnamed);
|
|
187
|
-
for (let i = 0; i < remainingArguments.length; i++) {
|
|
188
|
-
const arg = remainingArguments[i];
|
|
189
|
-
if (arg === r_function_call_1.EmptyArgument) {
|
|
127
|
+
const matched = (0, arg_matching_1.matchArgumentsToParameters)(argumentNames(args), paramNames);
|
|
128
|
+
const maps = new Map();
|
|
129
|
+
for (let i = 0; i < args.length; i++) {
|
|
130
|
+
const arg = args[i], param = matched[i];
|
|
131
|
+
if (arg === r_function_call_1.EmptyArgument || param === undefined) {
|
|
190
132
|
continue;
|
|
191
133
|
}
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
continue;
|
|
134
|
+
const target = params[paramNames[param]];
|
|
135
|
+
const known = maps.get(target);
|
|
136
|
+
if (known) {
|
|
137
|
+
known.push(arg.nodeId);
|
|
198
138
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
addToMaps(param, aid);
|
|
139
|
+
else {
|
|
140
|
+
maps.set(target, [arg.nodeId]);
|
|
202
141
|
}
|
|
203
142
|
}
|
|
204
143
|
return maps;
|
|
@@ -117,7 +117,7 @@ function processNumberBasedAccess(data, name, args, rootId, config, head) {
|
|
|
117
117
|
const existing = data.environment.current.memory.get(':=');
|
|
118
118
|
const outInfo = { definitionRootNodes: [] };
|
|
119
119
|
const tableAssignId = node_id_1.NodeId.toBuiltIn(':=-table');
|
|
120
|
-
data.environment.current.
|
|
120
|
+
data.environment.current.writableMemory.set(':=', [{
|
|
121
121
|
type: identifier_1.ReferenceType.BuiltInFunction,
|
|
122
122
|
definedAt: tableAssignId,
|
|
123
123
|
cds: undefined,
|
|
@@ -128,7 +128,7 @@ function processNumberBasedAccess(data, name, args, rootId, config, head) {
|
|
|
128
128
|
const fnCall = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: built_in_proc_name_1.BuiltInProcName.Access });
|
|
129
129
|
/* recover the environment */
|
|
130
130
|
if (existing !== undefined) {
|
|
131
|
-
data.environment.current.
|
|
131
|
+
data.environment.current.writableMemory.set(':=', existing);
|
|
132
132
|
}
|
|
133
133
|
if (head.value && outInfo.definitionRootNodes.length > 0) {
|
|
134
134
|
(0, built_in_assignment_1.markAsAssignment)(fnCall.information, { type: identifier_1.ReferenceType.Variable, name: head.value.lexeme ?? '', nodeId: head.value.info.id, definedAt: rootId, cds: [] }, outInfo.definitionRootNodes, rootId, data);
|
|
@@ -21,12 +21,6 @@ export interface EnvirResolution<OtherInfo> {
|
|
|
21
21
|
/** `true` when this resolves to a real stack environment (`globalenv()`/`.GlobalEnv`), not a tracked custom env. */
|
|
22
22
|
readonly isStackEnv?: boolean;
|
|
23
23
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
|
|
26
|
-
* Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
|
|
27
|
-
* Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
|
|
28
|
-
*/
|
|
29
|
-
export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], paramNames: readonly string[]): ReadonlyMap<string, PotentiallyEmptyRArgument<OtherInfo & ParentInformation>>;
|
|
30
24
|
/**
|
|
31
25
|
* The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
|
|
32
26
|
* database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
|
|
@@ -38,10 +32,10 @@ export declare function signatureParamNames<OtherInfo>(data: DataflowProcessorIn
|
|
|
38
32
|
export declare function resolveConstantString<OtherInfo>(node: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): string | undefined;
|
|
39
33
|
/** The `returnsEnvState` of the first reaching definition that carries one, else `undefined`. */
|
|
40
34
|
export declare function findReturnsEnvState(defs: readonly IdentifierDefinition[] | undefined): REnvironmentInformation | undefined;
|
|
41
|
-
/** Resolves a single already-found argument (e.g. from {@link
|
|
35
|
+
/** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
|
|
42
36
|
export declare function resolveArgToEnvir<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
|
|
43
|
-
/** Resolves the `argName` argument (default `'envir'
|
|
44
|
-
export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string
|
|
37
|
+
/** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
|
|
38
|
+
export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string): EnvirResolution<OtherInfo> | undefined;
|
|
45
39
|
/** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
|
|
46
40
|
export declare function resolveSymbolToEnvir<OtherInfo>(symbolName: Identifier, nodeId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
|
|
47
41
|
/** Moves definitions written into a custom environment from the caller's scope into `envDef`'s tracked `envState`, re-defining the holder variable. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bindArgs = bindArgs;
|
|
4
3
|
exports.signatureParamNames = signatureParamNames;
|
|
5
4
|
exports.resolveConstantString = resolveConstantString;
|
|
6
5
|
exports.findReturnsEnvState = findReturnsEnvState;
|
|
@@ -61,14 +60,6 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
|
|
|
61
60
|
};
|
|
62
61
|
return { envirData: { ...data, environment: mergedEnvState }, envDef, envirNodeId: nodeId };
|
|
63
62
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
|
|
66
|
-
* Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
|
|
67
|
-
* Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
|
|
68
|
-
*/
|
|
69
|
-
function bindArgs(args, paramNames) {
|
|
70
|
-
return r_function_call_1.RFunctionCall.matchArgsToParams(args, paramNames);
|
|
71
|
-
}
|
|
72
63
|
/**
|
|
73
64
|
* The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
|
|
74
65
|
* database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
|
|
@@ -107,7 +98,7 @@ function resolveConstantString(node, data) {
|
|
|
107
98
|
function findReturnsEnvState(defs) {
|
|
108
99
|
return defs?.find((d) => d.returnsEnvState !== undefined)?.returnsEnvState;
|
|
109
100
|
}
|
|
110
|
-
/** Resolves a single already-found argument (e.g. from {@link
|
|
101
|
+
/** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
|
|
111
102
|
function resolveArgToEnvir(arg, data) {
|
|
112
103
|
if (arg === r_function_call_1.EmptyArgument) {
|
|
113
104
|
return undefined;
|
|
@@ -135,30 +126,13 @@ function stackEnvirResolution(envState, nodeId, lexeme, data) {
|
|
|
135
126
|
};
|
|
136
127
|
return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, isStackEnv: true };
|
|
137
128
|
}
|
|
138
|
-
/** Resolves the `argName` argument (default `'envir'
|
|
139
|
-
function resolveEnvirArg(args, data, argName = 'envir'
|
|
140
|
-
/* named pass: pmatch against the full parameter list */
|
|
129
|
+
/** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
|
|
130
|
+
function resolveEnvirArg(args, data, argName = 'envir') {
|
|
141
131
|
for (const arg of args) {
|
|
142
|
-
if (arg
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if ((0, prefix_1.findByPrefixIfUnique)(arg.name.content, allParamNames) === argName) {
|
|
132
|
+
if (arg !== r_function_call_1.EmptyArgument && arg.name !== undefined && (0, prefix_1.findByPrefixIfUnique)(arg.name.content, [argName]) === argName) {
|
|
146
133
|
return resolveArgToEnvir(arg, data);
|
|
147
134
|
}
|
|
148
135
|
}
|
|
149
|
-
/* positional fallback (only when no named match existed) */
|
|
150
|
-
if (positionalFallbackIndex !== undefined) {
|
|
151
|
-
let pos = 0;
|
|
152
|
-
for (const arg of args) {
|
|
153
|
-
if (arg === r_function_call_1.EmptyArgument || arg.name !== undefined) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
if (pos === positionalFallbackIndex) {
|
|
157
|
-
return resolveArgToEnvir(arg, data);
|
|
158
|
-
}
|
|
159
|
-
pos++;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
136
|
return undefined;
|
|
163
137
|
}
|
|
164
138
|
/** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
|
|
@@ -47,7 +47,8 @@ function processForLoop(name, args, rootId, data) {
|
|
|
47
47
|
const writtenIds = new Set();
|
|
48
48
|
for (const write of writtenVariable) {
|
|
49
49
|
writtenIds.add(write.nodeId);
|
|
50
|
-
headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, type: identifier_1.ReferenceType.Variable
|
|
50
|
+
headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, type: identifier_1.ReferenceType.Variable,
|
|
51
|
+
value: [vectorArg.info.id], iterated: true }, false, headEnvironments);
|
|
51
52
|
}
|
|
52
53
|
data.environment = headEnvironments;
|
|
53
54
|
const body = (0, processor_1.processDataflowFor)(bodyArg, data);
|
|
@@ -484,7 +484,7 @@ function groupBodyWrites(out) {
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
for (const writes of byName.values()) {
|
|
487
|
-
writes.sort((a, b) => String(
|
|
487
|
+
writes.sort((a, b) => String(b.nodeId).localeCompare(String(a.nodeId)));
|
|
488
488
|
}
|
|
489
489
|
return byName;
|
|
490
490
|
}
|