@eagleoutice/flowr 2.15.10 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/cli/flowr-main-options.d.ts +15 -0
- package/cli/flowr-main-options.js +18 -0
- package/cli/flowr.d.ts +18 -0
- package/cli/flowr.js +13 -2
- package/cli/repl/commands/repl-clipboard.js +2 -1
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-main.d.ts +5 -0
- package/cli/repl/commands/repl-signature.js +2 -0
- package/cli/repl/core.d.ts +7 -1
- package/cli/repl/core.js +17 -8
- package/cli/repl/execute.js +2 -0
- package/cli/repl/server/connection.js +2 -1
- package/cli/repl/server/net.d.ts +10 -0
- package/cli/repl/server/net.js +34 -1
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +12 -2
- package/config.js +91 -14
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +185 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +64 -42
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +42 -4
- package/dataflow/internal/control-flow.js +76 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +60 -58
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/doc-capabilities.js +4 -1
- package/documentation/wiki-interface.js +4 -0
- package/documentation/wiki-setup.js +23 -0
- package/engines.js +11 -3
- package/linter/linter-executor.js +19 -1
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +117 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +130 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
- package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
- package/project/sigdb/decompress.js +3 -1
- package/project/sigdb/sigdb-download.js +9 -6
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +9 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -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-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell-executor.js +2 -0
- package/r-bridge/shell.js +8 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +120 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +6 -0
- package/util/files.js +12 -0
- package/util/parallel.js +2 -0
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/secure-mode.d.ts +42 -0
- package/util/secure-mode.js +70 -0
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -10,19 +10,13 @@ const environment_1 = require("../../../../../environments/environment");
|
|
|
10
10
|
const built_in_library_1 = require("./built-in-library");
|
|
11
11
|
const define_1 = require("../../../../../environments/define");
|
|
12
12
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
13
|
+
const program_order_1 = require("../../../../program-order");
|
|
13
14
|
const resolve_helper_1 = require("../../../../../environments/resolve-helper");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
for (const [target, edge] of graph.edgesFrom(call)) {
|
|
20
|
-
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls) && vertex_1.DfgVertex.isFunctionDefinition(graph.getVertex(target))) {
|
|
21
|
-
targets.push(target);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return targets;
|
|
25
|
-
}
|
|
15
|
+
const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
|
|
16
|
+
const identifier_1 = require("../../../../../environments/identifier");
|
|
17
|
+
const built_in_ambient_state_1 = require("./built-in-ambient-state");
|
|
18
|
+
const defaultmap_1 = require("../../../../../../util/collections/defaultmap");
|
|
19
|
+
const frame_reflection_1 = require("../../../../../fn/frame-reflection");
|
|
26
20
|
/**
|
|
27
21
|
* Computes, for every function-definition vertex `F`, `summary(F) = own(F)` unioned with `summary(G)` over every transitive callee `G`.
|
|
28
22
|
* @param graph - the fully linked dataflow graph
|
|
@@ -34,59 +28,22 @@ function computeCallGraphSummaries(graph, own) {
|
|
|
34
28
|
const summary = new Map();
|
|
35
29
|
const callees = new Map();
|
|
36
30
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
37
|
-
if (
|
|
38
|
-
|
|
31
|
+
if (vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
|
|
32
|
+
summary.set(id, new Set(own(id, vertex)));
|
|
33
|
+
callees.set(id, (0, frame_reflection_1.callsIn)(vertex, graph).flatMap(([node]) => (0, frame_reflection_1.calledDefinitions)(graph, node)).toArray());
|
|
39
34
|
}
|
|
40
|
-
summary.set(id, new Set(own(id, vertex)));
|
|
41
|
-
const targets = [];
|
|
42
|
-
for (const node of vertex.subflow.graph) {
|
|
43
|
-
if (vertex_1.DfgVertex.isFunctionCall(graph.getVertex(node))) {
|
|
44
|
-
targets.push(...calledDefinitions(graph, node));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
callees.set(id, targets);
|
|
48
|
-
}
|
|
49
|
-
if (summary.size === 0) {
|
|
50
|
-
return summary;
|
|
51
35
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
for (const [id, targets] of callees) {
|
|
55
|
-
for (const callee of targets) {
|
|
56
|
-
const existing = callers.get(callee);
|
|
57
|
-
if (existing === undefined) {
|
|
58
|
-
callers.set(callee, [id]);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
existing.push(id);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// worklist fixpoint: pull each callee's summary, re-enqueue callers when a function grew
|
|
66
|
-
const queue = [...summary.keys()];
|
|
67
|
-
const queued = new Set(queue);
|
|
68
|
-
while (queue.length > 0) {
|
|
69
|
-
const id = queue.pop();
|
|
70
|
-
queued.delete(id);
|
|
36
|
+
/* pull each callee's summary, its callers are revisited whenever a function grew */
|
|
37
|
+
(0, frame_reflection_1.propagateToFixpoint)(summary.keys(), callees, id => {
|
|
71
38
|
const effects = summary.get(id);
|
|
72
|
-
|
|
39
|
+
const before = effects.size;
|
|
73
40
|
for (const callee of callees.get(id) ?? []) {
|
|
74
41
|
for (const effect of summary.get(callee) ?? []) {
|
|
75
|
-
|
|
76
|
-
effects.add(effect);
|
|
77
|
-
grew = true;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (grew) {
|
|
82
|
-
for (const caller of callers.get(id) ?? []) {
|
|
83
|
-
if (!queued.has(caller)) {
|
|
84
|
-
queued.add(caller);
|
|
85
|
-
queue.push(caller);
|
|
86
|
-
}
|
|
42
|
+
effects.add(effect);
|
|
87
43
|
}
|
|
88
44
|
}
|
|
89
|
-
|
|
45
|
+
return effects.size > before;
|
|
46
|
+
});
|
|
90
47
|
return summary;
|
|
91
48
|
}
|
|
92
49
|
/**
|
|
@@ -98,10 +55,7 @@ function linkMaterializedExportsToLoaders(graph, environment) {
|
|
|
98
55
|
/* the attached namespaces hold every export of every package, far more than the graph ever materializes, so the
|
|
99
56
|
* cheap direction is to ask the graph first: an export earns an edge only if it is a vertex or the target of a
|
|
100
57
|
* `calls` edge. Both are read off the graph once here instead of per export binding. */
|
|
101
|
-
const called = new Set();
|
|
102
|
-
for (const [id] of graph.vertices(true)) {
|
|
103
|
-
called.add(id);
|
|
104
|
-
}
|
|
58
|
+
const called = new Set(graph.vertices(true).map(([id]) => id));
|
|
105
59
|
for (const [, outgoing] of graph.edges()) {
|
|
106
60
|
for (const [target, edge] of outgoing) {
|
|
107
61
|
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Calls)) {
|
|
@@ -109,7 +63,7 @@ function linkMaterializedExportsToLoaders(graph, environment) {
|
|
|
109
63
|
}
|
|
110
64
|
}
|
|
111
65
|
}
|
|
112
|
-
|
|
66
|
+
/* export node id -> its loading `library()`/`use()` call, from the final environment */
|
|
113
67
|
const loaders = new Map();
|
|
114
68
|
for (let e = environment.current; e !== undefined && !e.builtInEnv; e = e.parent) {
|
|
115
69
|
if (e.t !== environment_1.EnvType.Namespace) {
|
|
@@ -134,7 +88,7 @@ function attachedPackages(_id, fdef) {
|
|
|
134
88
|
const packages = [];
|
|
135
89
|
for (let e = fdef.subflow.environment.current; e !== undefined && !e.builtInEnv; e = e.parent) {
|
|
136
90
|
if (e.t === environment_1.EnvType.Namespace && e.n !== undefined) {
|
|
137
|
-
|
|
91
|
+
/* an export binding carries the loading `library()` call in `definedAt` */
|
|
138
92
|
let definedAt = node_id_1.NodeId.toBuiltIn(e.n);
|
|
139
93
|
for (const defs of e.memory.values()) {
|
|
140
94
|
const real = defs.find(d => !node_id_1.NodeId.isBuiltIn(d.definedAt));
|
|
@@ -159,10 +113,10 @@ function* escapeTargetFrames(fdef) {
|
|
|
159
113
|
* as a callback for {@link computeCallGraphSummaries}. Nested definitions share their outer frames, and a frame is
|
|
160
114
|
* dominated by the built-ins it holds, so filtering each frame once per pass saves the bulk of the work.
|
|
161
115
|
*/
|
|
162
|
-
function escapedDefinitions() {
|
|
116
|
+
function escapedDefinitions(hidden) {
|
|
163
117
|
const perFrame = new Map();
|
|
164
118
|
return (_id, fdef) => {
|
|
165
|
-
const defs =
|
|
119
|
+
const defs = hidden.keys().filter(call => fdef.subflow.graph.has(call)).toArray();
|
|
166
120
|
for (const e of escapeTargetFrames(fdef)) {
|
|
167
121
|
let escaped = perFrame.get(e.memory);
|
|
168
122
|
if (escaped === undefined) {
|
|
@@ -187,15 +141,14 @@ function escapedDefinitions() {
|
|
|
187
141
|
};
|
|
188
142
|
}
|
|
189
143
|
/** Emits {@link EdgeType.SideEffectOnCall} edges for definitions that escape a function transitively. */
|
|
190
|
-
function propagateTransitiveDefinitions(graph, environment, ctx) {
|
|
191
|
-
const summary = computeCallGraphSummaries(graph, escapedDefinitions());
|
|
144
|
+
function propagateTransitiveDefinitions(graph, environment, ctx, summary) {
|
|
192
145
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
193
146
|
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
194
147
|
continue;
|
|
195
148
|
}
|
|
196
|
-
for (const target of calledDefinitions(graph, id)) {
|
|
149
|
+
for (const target of (0, frame_reflection_1.calledDefinitions)(graph, id)) {
|
|
197
150
|
for (const def of summary.get(target) ?? []) {
|
|
198
|
-
|
|
151
|
+
/* an escaping package export is only in the environment; materialize its vertex on demand */
|
|
199
152
|
if (node_id_1.NodeId.isBuiltIn(def)) {
|
|
200
153
|
(0, built_in_library_1.attachExportVertex)(graph, def, environment, ctx);
|
|
201
154
|
}
|
|
@@ -216,7 +169,7 @@ function propagateTransitivePackages(graph, environment, ctx) {
|
|
|
216
169
|
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !graph.isRoot(id)) {
|
|
217
170
|
continue;
|
|
218
171
|
}
|
|
219
|
-
for (const target of calledDefinitions(graph, id)) {
|
|
172
|
+
for (const target of (0, frame_reflection_1.calledDefinitions)(graph, id)) {
|
|
220
173
|
for (const { pack, definedAt } of summary.get(target) ?? []) {
|
|
221
174
|
if (!reachable.has(pack)) {
|
|
222
175
|
reachable.set(pack, definedAt);
|
|
@@ -238,23 +191,78 @@ function propagateTransitivePackages(graph, environment, ctx) {
|
|
|
238
191
|
}
|
|
239
192
|
return { environment, grew };
|
|
240
193
|
}
|
|
241
|
-
/**
|
|
242
|
-
function
|
|
243
|
-
const
|
|
194
|
+
/** The ambient writes of body calls only linking resolved to a built-in (see {@link writesOfHiddenBuiltIn}), linking their reads as well. */
|
|
195
|
+
function hiddenBuiltInWrites(graph, environment) {
|
|
196
|
+
const builtIns = environment_1.REnvironment.findBuiltIn(environment.current);
|
|
197
|
+
const writes = new Map();
|
|
198
|
+
const reads = new Map();
|
|
199
|
+
const writesOf = new defaultmap_1.DefaultMap(() => [], writes);
|
|
200
|
+
const readsOf = new defaultmap_1.DefaultMap(() => [], reads);
|
|
201
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
202
|
+
if (graph.isRoot(id)) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const own = vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Function) ? undefined : vertex.name;
|
|
206
|
+
for (const target of (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Calls)) {
|
|
207
|
+
if (node_id_1.NodeId.isBuiltIn(target) && (own === undefined || node_id_1.NodeId.toBuiltIn(identifier_1.Identifier.getName(own)) !== target)) {
|
|
208
|
+
const targets = resolve_helper_1.Resolve.byNameAndType(node_id_1.NodeId.fromBuiltIn(target), { current: builtIns, level: 0 }, identifier_1.ReferenceType.Function) ?? [];
|
|
209
|
+
const defs = targets.flatMap(d => (0, built_in_ambient_state_1.writesOfHiddenBuiltIn)(d, id));
|
|
210
|
+
if (defs.length > 0) {
|
|
211
|
+
writesOf.get(id).push(...defs);
|
|
212
|
+
}
|
|
213
|
+
const names = targets.flatMap(built_in_ambient_state_1.readsOfHiddenBuiltIn);
|
|
214
|
+
if (names.length > 0) {
|
|
215
|
+
readsOf.get(id).push(...names);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
linkHiddenReads(graph, reads);
|
|
221
|
+
return writes;
|
|
222
|
+
}
|
|
223
|
+
/** A hidden call reads the state where the functions running it are called. */
|
|
224
|
+
function linkHiddenReads(graph, reads) {
|
|
225
|
+
if (reads.size === 0) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const summary = computeCallGraphSummaries(graph, (_id, fdef) => reads.keys().filter(call => fdef.subflow.graph.has(call)));
|
|
229
|
+
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
|
|
230
|
+
if (vertex.environment === undefined) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
for (const target of (0, frame_reflection_1.calledDefinitions)(graph, id)) {
|
|
234
|
+
for (const call of summary.get(target) ?? []) {
|
|
235
|
+
for (const name of reads.get(call) ?? []) {
|
|
236
|
+
for (const def of resolve_helper_1.Resolve.byName(name, vertex.environment) ?? []) {
|
|
237
|
+
if (def.nodeId !== call && graph.hasVertex(def.nodeId)) {
|
|
238
|
+
graph.addEdge(call, def.nodeId, edge_1.EdgeType.Reads);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Maps each definition escaping into the global frame to its full (name-carrying) definitions, one node may define several names
|
|
248
|
+
* (`options(digits = 3)`); a write from a function defined within another one may be caught by that function's frame instead.
|
|
249
|
+
*/
|
|
250
|
+
function escapedDefinitionMap(graph, hidden) {
|
|
251
|
+
const map = new Map(hidden.entries().map(([id, defs]) => [id, [...defs]]));
|
|
252
|
+
const definitionsOf = new defaultmap_1.DefaultMap(() => [], map);
|
|
244
253
|
const seen = new Set();
|
|
245
254
|
for (const [, vertex] of graph.vertices(true)) {
|
|
246
255
|
if (!vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
|
|
247
256
|
continue;
|
|
248
257
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
for (const definitions of e.memory.values()) {
|
|
258
|
+
const global = escapeTargetFrames(vertex).filter(e => e.t === undefined).reduce((_, e) => e, undefined);
|
|
259
|
+
/* a frame shared with an already-visited definition contributes the same entries */
|
|
260
|
+
if (global !== undefined && !seen.has(global.memory)) {
|
|
261
|
+
seen.add(global.memory);
|
|
262
|
+
for (const definitions of global.memory.values()) {
|
|
255
263
|
for (const def of definitions) {
|
|
256
264
|
if (!node_id_1.NodeId.isBuiltIn(def.nodeId) && def.name !== undefined) {
|
|
257
|
-
|
|
265
|
+
definitionsOf.get(def.nodeId).push(def);
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
268
|
}
|
|
@@ -267,21 +275,19 @@ function escapedDefinitionMap(graph) {
|
|
|
267
275
|
* `f <- function() x <<- 1; g <- function() f(); g(); print(x)` makes `x` resolvable.
|
|
268
276
|
* @returns the enriched environment and whether it grew (so the extractor can re-resolve open reads and re-run).
|
|
269
277
|
*/
|
|
270
|
-
function propagateTransitiveEscapedDefinitions(graph, environment, defined) {
|
|
271
|
-
const
|
|
272
|
-
const defs = escapedDefinitionMap(graph);
|
|
278
|
+
function propagateTransitiveEscapedDefinitions(graph, environment, defined, hidden, summary, open) {
|
|
279
|
+
const defs = escapedDefinitionMap(graph, hidden);
|
|
273
280
|
const names = new Set();
|
|
281
|
+
let byName;
|
|
282
|
+
const definitionsNamed = (name) => (byName ??= (0, frame_reflection_1.definitionsByName)(graph)).get(name);
|
|
274
283
|
let grew = false;
|
|
275
284
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
276
285
|
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || !graph.isRoot(id)) {
|
|
277
286
|
continue;
|
|
278
287
|
}
|
|
279
|
-
for (const target of calledDefinitions(graph, id)) {
|
|
280
|
-
for (const
|
|
281
|
-
const
|
|
282
|
-
if (def === undefined) {
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
288
|
+
for (const target of (0, frame_reflection_1.calledDefinitions)(graph, id)) {
|
|
289
|
+
for (const def of (summary.get(target) ?? []).values().flatMap(nodeId => defs.get(nodeId) ?? [])) {
|
|
290
|
+
const nodeId = def.nodeId;
|
|
285
291
|
names.add(def.name);
|
|
286
292
|
/* a name may hold several definitions while a lookup answers with one, so asking the environment
|
|
287
293
|
* would call every shadowed one missing and define it again on every round; what this fixpoint
|
|
@@ -295,12 +301,30 @@ function propagateTransitiveEscapedDefinitions(graph, environment, defined) {
|
|
|
295
301
|
continue;
|
|
296
302
|
}
|
|
297
303
|
environment = (0, define_1.define)(def, false, environment);
|
|
304
|
+
linkReadsAfter(graph, id, def, open, definitionsNamed);
|
|
298
305
|
grew = true;
|
|
299
306
|
}
|
|
300
307
|
}
|
|
301
308
|
}
|
|
302
309
|
return { environment, grew, names };
|
|
303
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* A read that may run after `call` and sees a definition the call may replace (or nothing, as with the `open` reads) may see `def`
|
|
313
|
+
* instead, as with a callee only the call binds: `g <- function(f) f(); x <- 1; g(function() x <<- 2); print(x)`, or `g(runif)`.
|
|
314
|
+
*/
|
|
315
|
+
function linkReadsAfter(graph, call, def, open, definitionsNamed) {
|
|
316
|
+
const before = graph.getVertex(call)?.environment;
|
|
317
|
+
const visible = before === undefined ? definitionsNamed(def.name) : resolve_helper_1.Resolve.byName(def.name, before)?.map(d => d.nodeId) ?? [];
|
|
318
|
+
const replaced = new Set([...visible, ...(0, frame_reflection_1.edgeSources)(graph, call, edge_1.EdgeType.SideEffectOnCall)]);
|
|
319
|
+
const readers = new Set(open.filter(r => r.name === def.name).map(r => r.nodeId));
|
|
320
|
+
for (const [id] of graph.vertices(true)) {
|
|
321
|
+
/* an argument reads the value of a call, not a name the call may define (an ambient state is defined at its call) */
|
|
322
|
+
if ((readers.has(id) || graph.edgesFrom(id).entries().some(([target, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && edge_1.DfEdge.doesNotIncludeType(edge, edge_1.EdgeType.Argument) && replaced.has(target)))
|
|
323
|
+
&& !program_order_1.ProgramOrder.definedLater(call, program_order_1.ProgramOrder.runsOnceAt(id, graph), graph)) {
|
|
324
|
+
graph.addEdge(id, def.nodeId, edge_1.EdgeType.Reads);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
304
328
|
/** Re-resolves still-open reads whose name is one of the transitively escaped `<<-` definitions in `escapedNames`, adding {@link EdgeType.Reads} edges. */
|
|
305
329
|
function reResolveOpenReferences(graph, environment, references, escapedNames) {
|
|
306
330
|
for (const ref of references) {
|
|
@@ -319,10 +343,13 @@ function reResolveOpenReferences(graph, environment, references, escapedNames) {
|
|
|
319
343
|
* @returns the enriched top-level environment and whether it grew (so the extractor can re-link and re-run to a fixpoint).
|
|
320
344
|
* @useInstead {@link Dataflow.sideEffects.propagateTransitive}
|
|
321
345
|
*/
|
|
322
|
-
function propagateTransitiveSideEffects(graph, environment, ctx, defined = new Set()) {
|
|
323
|
-
|
|
346
|
+
function propagateTransitiveSideEffects(graph, environment, ctx, defined = new Set(), open = []) {
|
|
347
|
+
const hidden = hiddenBuiltInWrites(graph, environment);
|
|
348
|
+
/* both passes ask what escapes each function, and neither changes a body or a call target in between */
|
|
349
|
+
const escapes = computeCallGraphSummaries(graph, escapedDefinitions(hidden));
|
|
350
|
+
propagateTransitiveDefinitions(graph, environment, ctx, escapes);
|
|
324
351
|
const packages = propagateTransitivePackages(graph, environment, ctx);
|
|
325
|
-
const escaped = propagateTransitiveEscapedDefinitions(graph, packages.environment, defined);
|
|
352
|
+
const escaped = propagateTransitiveEscapedDefinitions(graph, packages.environment, defined, hidden, escapes, open);
|
|
326
353
|
return { environment: escaped.environment, grew: packages.grew || escaped.grew, escapedNames: escaped.names };
|
|
327
354
|
}
|
|
328
355
|
//# sourceMappingURL=transitive-side-effects.js.map
|
|
@@ -55,9 +55,7 @@ export declare function convertFnArgument<OtherInfo>(this: void, arg: typeof Emp
|
|
|
55
55
|
* would duplicate it.
|
|
56
56
|
*/
|
|
57
57
|
export declare function isPipedArgument<OtherInfo>(arg: unknown, functionRootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Processes all arguments for a function call, updating the given final graph and environment.
|
|
60
|
-
*/
|
|
58
|
+
/** Processes all arguments for a function call, updating the given final graph and environment. */
|
|
61
59
|
export declare function processAllArguments<OtherInfo>({ functionName, args, data, finalGraph, functionRootId, forced, patchData, nonFunction, alternativesFrom }: ProcessAllArgumentInput<OtherInfo>): ProcessAllArgumentResult;
|
|
62
60
|
export interface PatchFunctionCallInput<OtherInfo> {
|
|
63
61
|
readonly nextGraph: DataflowGraph;
|
|
@@ -30,7 +30,7 @@ function forceVertexArgumentValueReferences(rootId, value, graph, env) {
|
|
|
30
30
|
if (!valueVertex) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
/* link read if it is function definition directly and reference the exit point */
|
|
34
34
|
if (vertex_2.DfgVertex.isFunctionDefinition(valueVertex)) {
|
|
35
35
|
for (const exit of valueVertex.exitPoints) {
|
|
36
36
|
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
@@ -41,18 +41,11 @@ function forceVertexArgumentValueReferences(rootId, value, graph, env) {
|
|
|
41
41
|
graph.addEdge(rootId, exit.nodeId, edge_1.EdgeType.Reads);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const containedSubflowIn = graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (ref.name) {
|
|
50
|
-
const refId = ref.nodeId;
|
|
51
|
-
const resolved = (0, resolve_by_name_1.resolveByName)(ref.name, env, ref.type) ?? [];
|
|
52
|
-
for (const resolve of resolved) {
|
|
53
|
-
graph.addEdge(refId, resolve.nodeId, edge_1.EdgeType.Reads);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
44
|
+
const containedSubflowIn = graph.verticesOfType(vertex_1.VertexType.FunctionDefinition).flatMap(([, info]) => info.subflow.in);
|
|
45
|
+
/* try to resolve them against the current environment */
|
|
46
|
+
for (const ref of [...value.in, ...containedSubflowIn]) {
|
|
47
|
+
for (const resolved of ref.name ? (0, resolve_by_name_1.resolveByName)(ref.name, env, ref.type) ?? [] : []) {
|
|
48
|
+
graph.addEdge(ref.nodeId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
56
49
|
}
|
|
57
50
|
}
|
|
58
51
|
}
|
|
@@ -76,15 +69,7 @@ function convertFnArgument(arg) {
|
|
|
76
69
|
else if (!arg.name || !r_argument_1.RArgument.is(arg)) {
|
|
77
70
|
return { nodeId: arg.info.id, cds: undefined, type: identifier_1.ReferenceType.Argument };
|
|
78
71
|
}
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
nodeId: arg.info.id,
|
|
82
|
-
valueId: arg.value?.info.id,
|
|
83
|
-
name: arg.name.content,
|
|
84
|
-
cds: undefined,
|
|
85
|
-
type: identifier_1.ReferenceType.Argument
|
|
86
|
-
};
|
|
87
|
-
}
|
|
72
|
+
return { nodeId: arg.info.id, valueId: arg.value?.info.id, name: arg.name.content, cds: undefined, type: identifier_1.ReferenceType.Argument };
|
|
88
73
|
}
|
|
89
74
|
/**
|
|
90
75
|
* Whether `arg` is the value the pipe handed to the call `functionRootId`, which {@link processNamedCall}
|
|
@@ -94,49 +79,36 @@ function convertFnArgument(arg) {
|
|
|
94
79
|
function isPipedArgument(arg, functionRootId, data) {
|
|
95
80
|
return data.pipedArgument?.rootId === functionRootId && data.pipedArgument.argument === arg;
|
|
96
81
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Processes all arguments for a function call, updating the given final graph and environment.
|
|
99
|
-
*/
|
|
82
|
+
/** Processes all arguments for a function call, updating the given final graph and environment. */
|
|
100
83
|
function processAllArguments({ functionName, args, data, finalGraph, functionRootId, forced = [], patchData, nonFunction, alternativesFrom }) {
|
|
101
84
|
let finalEnv = functionName.environment;
|
|
102
85
|
const callArgs = [];
|
|
103
86
|
const processedArguments = [];
|
|
104
87
|
const remainingReadInArgs = [];
|
|
105
|
-
let i = -1;
|
|
106
88
|
/* each alternative starts from what holds before all of them, and what one of them defines only may hold afterward */
|
|
107
89
|
let beforeAlternatives;
|
|
108
90
|
let afterAlternatives;
|
|
109
|
-
for (const arg of args) {
|
|
110
|
-
i++;
|
|
91
|
+
for (const [i, arg] of args.entries()) {
|
|
111
92
|
if (alternativesFrom !== undefined && i >= alternativesFrom) {
|
|
112
93
|
beforeAlternatives ??= finalEnv;
|
|
113
94
|
finalEnv = beforeAlternatives;
|
|
114
95
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
data = { ...data, cds: [...data.cds ?? [], { id: functionRootId, when: true }] };
|
|
119
|
-
}
|
|
96
|
+
/* whether an alternative runs depends on what the call picks */
|
|
97
|
+
data = beforeAlternatives === undefined ? { ...data, environment: finalEnv }
|
|
98
|
+
: { ...data, environment: finalEnv, cds: [...data.cds ?? [], { id: functionRootId, when: true }] };
|
|
120
99
|
data = patchData?.(data, i) ?? data;
|
|
121
100
|
if (r_argument_1.RArgument.isEmpty(arg)) {
|
|
122
101
|
callArgs.push(r_function_call_1.EmptyArgument);
|
|
123
102
|
processedArguments.push(undefined);
|
|
124
103
|
continue;
|
|
125
104
|
}
|
|
126
|
-
if (isPipedArgument(arg, functionRootId, data)) {
|
|
105
|
+
else if (isPipedArgument(arg, functionRootId, data)) {
|
|
127
106
|
processedArguments.push(undefined);
|
|
128
107
|
continue;
|
|
129
108
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (i === 0 && data.precomputedFirstArg?.rootId === functionRootId) {
|
|
134
|
-
processed = data.precomputedFirstArg.info;
|
|
135
|
-
ownsGraph = false;
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
processed = r_argument_1.RArgument.is(arg) ? (0, process_argument_1.processFunctionArgument)(arg, data) : (0, processor_1.processDataflowFor)(arg, data);
|
|
139
|
-
}
|
|
109
|
+
/* a precomputed argument stays alive where it was handed in from, only a freshly built one dies here */
|
|
110
|
+
const precomputed = i === 0 && data.precomputedFirstArg?.rootId === functionRootId ? data.precomputedFirstArg.info : undefined;
|
|
111
|
+
const processed = precomputed ?? (r_argument_1.RArgument.is(arg) ? (0, process_argument_1.processFunctionArgument)(arg, data) : (0, processor_1.processDataflowFor)(arg, data));
|
|
140
112
|
if (r_argument_1.RArgument.isWithValue(arg) && forced[i] && !model_1.RConstant.is(arg.value)) {
|
|
141
113
|
forceVertexArgumentValueReferences(functionRootId, processed, processed.graph, data.environment);
|
|
142
114
|
}
|
|
@@ -146,40 +118,28 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
|
|
|
146
118
|
afterAlternatives = (0, append_1.appendEnvironment)(afterAlternatives ?? beforeAlternatives, finalEnv);
|
|
147
119
|
}
|
|
148
120
|
/* nothing reads the argument's own graph past this point, only its entry point and references */
|
|
149
|
-
finalGraph.mergeWith(processed.graph, true,
|
|
150
|
-
|
|
151
|
-
for (const
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
else {
|
|
167
|
-
/* maybe all targets are not definitely of the current scope and should be still kept */
|
|
168
|
-
let assumeItMayHaveAHigherTarget = true;
|
|
169
|
-
for (const resolved of tryToResolve) {
|
|
170
|
-
if ((0, identifier_1.isReferenceType)(resolved.type, identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.BuiltInConstant)) {
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
else if ((0, info_1.happensInEveryBranch)(resolved.cds)) {
|
|
174
|
-
assumeItMayHaveAHigherTarget = false;
|
|
175
|
-
}
|
|
176
|
-
finalGraph.addEdge(inId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
177
|
-
}
|
|
178
|
-
if (assumeItMayHaveAHigherTarget) {
|
|
179
|
-
remainingReadInArgs.push(ingoing);
|
|
180
|
-
}
|
|
121
|
+
finalGraph.mergeWith(processed.graph, true, precomputed === undefined);
|
|
122
|
+
/* resolve reads within argument, we resolve before adding the `processed.environment` to avoid cyclic dependencies */
|
|
123
|
+
for (const original of [...processed.in, ...processed.unknownReferences]) {
|
|
124
|
+
const inId = original.nodeId;
|
|
125
|
+
/* a data argument holds a value, so a function of that name is not what it reads; the narrowed type stays on the reference */
|
|
126
|
+
const ingoing = nonFunction?.has(inId) ? { ...original, type: identifier_1.ReferenceType.NonFunction } : original;
|
|
127
|
+
/* a call reading the options or graphics state (`#...`, see AmbientStateName) reads a variable, not itself */
|
|
128
|
+
const refType = built_in_ambient_state_1.AmbientStateName.is(ingoing.name) ? identifier_1.ReferenceType.Variable
|
|
129
|
+
: vertex_2.DfgVertex.isFunctionCall(finalGraph.getVertex(inId)) ? identifier_1.ReferenceType.Function
|
|
130
|
+
: ingoing.type === identifier_1.ReferenceType.NonFunction ? identifier_1.ReferenceType.NonFunction : identifier_1.ReferenceType.Unknown;
|
|
131
|
+
const tryToResolve = ingoing.name ? (0, resolve_by_name_1.resolveByName)(ingoing.name, data.environment, refType) : undefined;
|
|
132
|
+
/* unless one target is certainly of the current scope, a higher one may still be meant */
|
|
133
|
+
let mayHaveHigherTarget = true;
|
|
134
|
+
for (const resolved of tryToResolve ?? []) {
|
|
135
|
+
if (!(0, identifier_1.isReferenceType)(resolved.type, identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.BuiltInConstant)) {
|
|
136
|
+
mayHaveHigherTarget &&= !(0, info_1.happensInEveryBranch)(resolved.cds);
|
|
137
|
+
finalGraph.addEdge(inId, resolved.nodeId, edge_1.EdgeType.Reads);
|
|
181
138
|
}
|
|
182
139
|
}
|
|
140
|
+
if (mayHaveHigherTarget) {
|
|
141
|
+
remainingReadInArgs.push(ingoing);
|
|
142
|
+
}
|
|
183
143
|
}
|
|
184
144
|
if (!r_argument_1.RArgument.is(arg) || !arg.name) {
|
|
185
145
|
callArgs.push({ nodeId: processed.entryPoint, cds: undefined, type: identifier_1.ReferenceType.Argument });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AstIdMap, ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
2
2
|
import { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { DataflowGraph } from '../../../../graph/graph';
|
|
4
|
+
import { VertexType } from '../../../../graph/vertex';
|
|
4
5
|
import type { ControlFlowGraph } from '../../../../../control-flow/control-flow-graph';
|
|
5
6
|
/** The reads that may force the expression, and the control flow deciding what they can see. */
|
|
6
7
|
export interface ForceSites {
|
|
@@ -20,6 +21,8 @@ export interface NameIndex {
|
|
|
20
21
|
readonly definitions: ReadonlyMap<string, NodeId[]>;
|
|
21
22
|
readonly uses: ReadonlyMap<string, NodeId[]>;
|
|
22
23
|
}
|
|
24
|
+
/** The vertices of `type` by their unquoted name. */
|
|
25
|
+
export declare function verticesByName<Info>(graph: DataflowGraph, type: VertexType, idMap: AstIdMap<Info & ParentInformation>): Map<string, NodeId[]>;
|
|
23
26
|
/**
|
|
24
27
|
* An expression R evaluates at a time we cannot pin down: the body a `delayedAssign` binds, forced at some
|
|
25
28
|
* later read of the name, or a promise a closure carries past the call that created it.
|
|
@@ -35,14 +38,15 @@ export declare const Deferred: {
|
|
|
35
38
|
/**
|
|
36
39
|
* The reads that may be the one forcing `binding`: every read of it that no other read always precedes,
|
|
37
40
|
* since an earlier read would already have forced it and cached the value.
|
|
41
|
+
* With `viaClosures`, a closure reading a `delayedAssign` binding forces it when called.
|
|
38
42
|
*/
|
|
39
|
-
readonly forcedAt: (this: void, graph: DataflowGraph, binding: NodeId, cfg: ControlFlowGraph) => readonly NodeId[];
|
|
43
|
+
readonly forcedAt: (this: void, graph: DataflowGraph, binding: NodeId, cfg: ControlFlowGraph, viaClosures?: boolean) => readonly NodeId[];
|
|
40
44
|
/**
|
|
41
45
|
* Links the writes an expression performs to the uses that may observe them, for a call evaluating the
|
|
42
46
|
* expression at a point control flow can pin down (`eval`). The reads are settled by the evaluating call
|
|
43
47
|
* itself, against the environment in effect there, so only this direction is left open.
|
|
44
48
|
*/
|
|
45
|
-
readonly publish: <Info>(this: void, graph: DataflowGraph, expr: NodeId, index: NameIndex, idMap: AstIdMap<Info & ParentInformation>, at: NodeId, cfg?: ControlFlowGraph) => void;
|
|
49
|
+
readonly publish: <Info>(this: void, graph: DataflowGraph, expr: NodeId, index: NameIndex, idMap: AstIdMap<Info & ParentInformation>, at: NodeId, sites: readonly NodeId[], cfg?: ControlFlowGraph) => void;
|
|
46
50
|
/**
|
|
47
51
|
* Links the expression rooted at `expr` to the bindings it may meet when it is evaluated. Given the reads
|
|
48
52
|
* that may force it, control flow rules out what no force can reach; without them every binding stays a
|