@eagleoutice/flowr 2.15.10 → 2.16.0

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.
Files changed (181) hide show
  1. package/README.md +23 -26
  2. package/abstract-interpretation/data-frame/arguments.js +11 -7
  3. package/control-flow/happens-before.d.ts +5 -0
  4. package/control-flow/happens-before.js +48 -34
  5. package/control-flow/useless-loop.d.ts +1 -1
  6. package/control-flow/useless-loop.js +29 -42
  7. package/dataflow/environments/built-in-props.d.ts +9 -0
  8. package/dataflow/environments/built-in-props.js +25 -19
  9. package/dataflow/environments/built-in.d.ts +2 -2
  10. package/dataflow/environments/built-in.js +41 -77
  11. package/dataflow/environments/default-builtin-config.d.ts +181 -29
  12. package/dataflow/environments/default-builtin-config.js +38 -24
  13. package/dataflow/environments/environment.d.ts +6 -4
  14. package/dataflow/environments/environment.js +54 -121
  15. package/dataflow/environments/identifier.d.ts +4 -2
  16. package/dataflow/environments/identifier.js +23 -69
  17. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  18. package/dataflow/environments/reference-to-maybe.js +23 -51
  19. package/dataflow/environments/resolve-by-name.js +37 -76
  20. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  22. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  23. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  24. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  25. package/dataflow/eval/resolve/resolve.js +23 -14
  26. package/dataflow/extractor.js +176 -59
  27. package/dataflow/fn/class-declaration.d.ts +8 -2
  28. package/dataflow/fn/class-declaration.js +96 -97
  29. package/dataflow/fn/exceptions-of-function.js +68 -37
  30. package/dataflow/fn/frame-reflection.d.ts +12 -4
  31. package/dataflow/fn/frame-reflection.js +51 -41
  32. package/dataflow/fn/function-props.js +15 -33
  33. package/dataflow/fn/function-semantics.d.ts +11 -3
  34. package/dataflow/fn/function-semantics.js +6 -0
  35. package/dataflow/fn/higher-order-function.js +13 -17
  36. package/dataflow/fn/strict-function.d.ts +13 -0
  37. package/dataflow/fn/strict-function.js +285 -122
  38. package/dataflow/graph/call-graph.d.ts +7 -6
  39. package/dataflow/graph/call-graph.js +35 -46
  40. package/dataflow/graph/graph.d.ts +6 -1
  41. package/dataflow/graph/graph.js +57 -66
  42. package/dataflow/info.d.ts +8 -1
  43. package/dataflow/info.js +24 -30
  44. package/dataflow/internal/control-flow.d.ts +31 -4
  45. package/dataflow/internal/control-flow.js +61 -39
  46. package/dataflow/internal/linker.d.ts +15 -9
  47. package/dataflow/internal/linker.js +253 -241
  48. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
  49. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
  50. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
  52. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
  54. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  55. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  56. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
  57. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
  58. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
  59. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  61. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  62. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
  63. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  64. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
  65. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  66. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  67. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  68. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
  70. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
  72. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  73. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
  74. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  76. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  77. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  78. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  79. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
  80. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  81. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  83. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  84. package/dataflow/internal/process/functions/call/common.d.ts +1 -3
  85. package/dataflow/internal/process/functions/call/common.js +36 -76
  86. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
  87. package/dataflow/internal/process/functions/call/deferred.js +54 -57
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  90. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  91. package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
  92. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  93. package/dataflow/internal/process/functions/call/quoted.js +162 -172
  94. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  95. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  96. package/dataflow/internal/process/process-symbol.js +3 -6
  97. package/dataflow/internal/program-order.d.ts +26 -0
  98. package/dataflow/internal/program-order.js +49 -0
  99. package/documentation/wiki-setup.js +23 -0
  100. package/linter/linter-rules.d.ts +17 -8
  101. package/linter/rules/absolute-path.js +63 -87
  102. package/linter/rules/file-path-validity.d.ts +4 -2
  103. package/linter/rules/file-path-validity.js +114 -80
  104. package/linter/rules/namespace-access.js +21 -33
  105. package/linter/rules/naming-convention.d.ts +1 -1
  106. package/linter/rules/naming-convention.js +60 -48
  107. package/linter/rules/network-functions.js +11 -7
  108. package/linter/rules/no-leaked-credentials.js +15 -18
  109. package/linter/rules/problematic-inputs.d.ts +2 -1
  110. package/linter/rules/problematic-inputs.js +39 -59
  111. package/linter/rules/roxygen-arguments.d.ts +9 -4
  112. package/linter/rules/roxygen-arguments.js +29 -48
  113. package/linter/rules/seeded-randomness.d.ts +7 -4
  114. package/linter/rules/seeded-randomness.js +128 -89
  115. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  116. package/linter/rules/stop-with-call-arg.js +25 -22
  117. package/linter/rules/unclosed-connection.js +31 -24
  118. package/linter/rules/undefined-symbol.d.ts +4 -6
  119. package/linter/rules/undefined-symbol.js +58 -75
  120. package/linter/rules/unescaped-arguments.js +18 -44
  121. package/linter/rules/unused-definition.d.ts +6 -0
  122. package/linter/rules/unused-definition.js +105 -145
  123. package/linter/rules/unused-import.d.ts +3 -0
  124. package/linter/rules/unused-import.js +25 -43
  125. package/package.json +5 -2
  126. package/project/flowr-analyzer.js +6 -2
  127. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  128. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  129. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  130. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  131. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
  132. package/queries/base-query-format.js +1 -2
  133. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  134. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  135. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  136. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  137. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  138. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  139. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  140. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  141. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  142. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  143. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  144. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  145. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  156. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  157. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  158. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  159. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  160. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  161. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  162. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  163. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  164. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  165. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  166. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  167. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  168. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  169. package/r-bridge/shell.js +6 -0
  170. package/search/search-executor/search-enrichers.js +25 -37
  171. package/slicing/static/slice-call.d.ts +4 -3
  172. package/slicing/static/slice-call.js +56 -88
  173. package/slicing/static/static-slicer.js +115 -79
  174. package/slicing/static/visiting-queue.d.ts +4 -6
  175. package/slicing/static/visiting-queue.js +9 -13
  176. package/util/proc.js +2 -1
  177. package/util/r-base-packages.d.ts +2 -0
  178. package/util/r-base-packages.js +23 -13
  179. package/util/text/playground-link.d.ts +12 -3
  180. package/util/text/playground-link.js +18 -27
  181. package/util/version.js +4 -10
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Deferred = void 0;
4
+ exports.verticesByName = verticesByName;
4
5
  const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
5
6
  const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
6
7
  const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
@@ -11,33 +12,29 @@ const vertex_1 = require("../../../../graph/vertex");
11
12
  const happens_before_1 = require("../../../../../control-flow/happens-before");
12
13
  const r_symbol_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
13
14
  const linker_1 = require("../../../linker");
14
- /** Drops the read of `target` from `use`, for a binding another write has replaced. */
15
- function dropRead(graph, use, target) {
16
- graph.removeEdgeType(use, target, edge_1.EdgeType.Reads);
17
- }
18
- function add(index, name, id) {
19
- const known = index.get(name);
20
- if (known) {
21
- known.push(id);
22
- }
23
- else {
24
- index.set(name, [id]);
25
- }
15
+ const frame_reflection_1 = require("../../../../fn/frame-reflection");
16
+ const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
17
+ /** The vertices of `type` by their unquoted name. */
18
+ function verticesByName(graph, type, idMap) {
19
+ const named = graph.vertexIdsOfType(type).filter(id => node_id_1.NodeId.recoverName(id, idMap) !== undefined);
20
+ return Map.groupBy(named, id => (0, retriever_1.removeRQuotes)(node_id_1.NodeId.recoverName(id, idMap)));
26
21
  }
27
22
  /** The names a deferred expression touches, each with the node touching it and whether it is written. */
28
23
  function namesWithin(expr, graph, idMap) {
29
- const node = idMap.get(expr);
30
24
  const names = [];
31
- if (node === undefined) {
32
- return names;
33
- }
34
25
  const callees = new Set();
35
- model_1.RNode.visitAst(node, inner => {
26
+ model_1.RNode.visitAst(idMap.get(expr), inner => {
36
27
  if (r_function_call_1.RFunctionCall.isNamed(inner)) {
37
28
  callees.add(inner.functionName.info.id);
38
29
  /* a call reads the function it names, so `evalq(f())` needs the definition of `f` */
39
30
  if (vertex_1.DfgVertex.isFunctionCall(graph.getVertex(inner.info.id))) {
40
31
  names.push([inner.info.id, identifier_1.Identifier.getName(inner.functionName.content), false]);
32
+ for (const def of (0, frame_reflection_1.edgeSources)(graph, inner.info.id, edge_1.EdgeType.SideEffectOnCall)) {
33
+ const name = node_id_1.NodeId.recoverName(def, idMap);
34
+ if (name !== undefined) {
35
+ names.push([def, (0, retriever_1.removeRQuotes)(name), true]);
36
+ }
37
+ }
41
38
  }
42
39
  return false;
43
40
  }
@@ -64,57 +61,56 @@ function namesWithin(expr, graph, idMap) {
64
61
  exports.Deferred = {
65
62
  /** Where each name is bound and read, built once and shared by every deferred expression in the graph. */
66
63
  indexOf(graph, idMap) {
67
- const definitions = new Map();
68
- const uses = new Map();
69
- for (const [type, index] of [[vertex_1.VertexType.VariableDefinition, definitions], [vertex_1.VertexType.Use, uses]]) {
70
- for (const [id] of graph.verticesOfType(type)) {
71
- const name = node_id_1.NodeId.recoverName(id, idMap);
72
- if (name !== undefined) {
73
- add(index, (0, retriever_1.removeRQuotes)(name), id);
74
- }
75
- }
76
- }
77
- return { definitions, uses };
64
+ return {
65
+ definitions: verticesByName(graph, vertex_1.VertexType.VariableDefinition, idMap),
66
+ uses: verticesByName(graph, vertex_1.VertexType.Use, idMap)
67
+ };
78
68
  },
79
69
  /**
80
70
  * The reads that may be the one forcing `binding`: every read of it that no other read always precedes,
81
71
  * since an earlier read would already have forced it and cached the value.
72
+ * With `viaClosures`, a closure reading a `delayedAssign` binding forces it when called.
82
73
  */
83
- forcedAt(graph, binding, cfg) {
84
- const reads = [];
85
- for (const [reader, edge] of graph.edgesTo(binding)) {
86
- if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
87
- reads.push(reader);
88
- }
89
- }
74
+ forcedAt(graph, binding, cfg, viaClosures = false) {
75
+ const reads = (0, frame_reflection_1.edgeSources)(graph, binding, edge_1.EdgeType.Reads);
76
+ const readSet = new Set(reads);
77
+ /* a closure reading it and the call of that closure may skip the read, so they never rule out a later force */
78
+ const calls = viaClosures
79
+ ? (0, frame_reflection_1.edgeSources)(graph, binding, edge_1.EdgeType.DefinesOnCall | edge_1.EdgeType.DefinedByOnCall).filter(r => !readSet.has(r))
80
+ : [];
90
81
  if (reads.length < 2) {
91
- return reads;
82
+ return reads.concat(calls);
92
83
  }
93
- const readSet = new Set(reads);
94
- return reads.filter(r => !(0, happens_before_1.someAlwaysBefore)(cfg, readSet, r));
84
+ /* the reads of a parameter all sit in its function, which is where the walk can stay */
85
+ const parameter = graph.idMap?.get(binding)?.info.parent;
86
+ const owner = graph.getVertex(graph.idMap?.get(parameter ?? '')?.info.parent ?? '');
87
+ const first = (0, happens_before_1.firstOnSomePath)(cfg, readSet, vertex_1.DfgVertex.isFunctionDefinition(owner) && node_id_1.NodeId.normalize(binding) in owner.params ? owner.subflow.graph : undefined);
88
+ return reads.filter(r => first.has(r)).concat(calls);
95
89
  },
96
90
  /**
97
91
  * Links the writes an expression performs to the uses that may observe them, for a call evaluating the
98
92
  * expression at a point control flow can pin down (`eval`). The reads are settled by the evaluating call
99
93
  * itself, against the environment in effect there, so only this direction is left open.
100
94
  */
101
- publish(graph, expr, index, idMap, at, cfg) {
95
+ publish(graph, expr, index, idMap, at, sites, cfg) {
102
96
  const within = namesWithin(expr, graph, idMap);
103
97
  const own = new Set(within.map(([id]) => id));
104
98
  let reachedFromAt;
105
- for (const [node, name, writes] of within) {
106
- if (!writes) {
107
- continue;
99
+ let reachedFromSites;
100
+ for (const [node, name] of within.filter(([, , writes]) => writes)) {
101
+ /* a write leaving the evaluating frame lands whenever a call of the closure evaluating it does */
102
+ const escapes = vertex_1.DfgVertex.hasOrigin(graph.getVertex(idMap.get(node)?.info.parent ?? ''), built_in_proc_name_1.BuiltInProcName.SuperAssignment);
103
+ for (const site of escapes ? sites : []) {
104
+ if (site !== at) {
105
+ graph.addEdge(node, site, edge_1.EdgeType.SideEffectOnCall);
106
+ }
108
107
  }
109
108
  for (const use of index.uses.get(name) ?? []) {
110
109
  /* only a use the evaluation may reach can see what it wrote */
111
- if (cfg !== undefined) {
112
- reachedFromAt ??= (0, happens_before_1.reachableFrom)(cfg, [at]);
113
- }
114
- if (own.has(use) || (reachedFromAt !== undefined && !reachedFromAt.has(use))) {
115
- continue;
110
+ const reached = cfg === undefined ? undefined : escapes ? reachedFromSites ??= (0, happens_before_1.reachableFrom)(cfg, [at, ...sites]) : reachedFromAt ??= (0, happens_before_1.reachableFrom)(cfg, [at]);
111
+ if (!own.has(use) && (reached === undefined || reached.has(use))) {
112
+ graph.addEdge(use, node, edge_1.EdgeType.Reads);
116
113
  }
117
- graph.addEdge(use, node, edge_1.EdgeType.Reads);
118
114
  }
119
115
  }
120
116
  },
@@ -153,15 +149,16 @@ exports.Deferred = {
153
149
  /* a write of the bound name replaces the binding, so a read it definitely reaches sees only it */
154
150
  const shadows = forces !== undefined && name === bindingName && graph.getVertex(node)?.cds === undefined;
155
151
  for (const use of index.uses.get(name) ?? []) {
156
- if (!own.has(use) && reachedByAForce(use)) {
157
- graph.addEdge(use, node, edge_1.EdgeType.Reads);
158
- /* the write only happens because a force runs it */
159
- for (const site of forces?.sites ?? []) {
160
- graph.addEdge(node, site, edge_1.EdgeType.Reads);
161
- }
162
- if (shadows && alwaysAfterAForce(use)) {
163
- dropRead(graph, use, forces.binding);
164
- }
152
+ if (own.has(use) || !reachedByAForce(use)) {
153
+ continue;
154
+ }
155
+ graph.addEdge(use, node, edge_1.EdgeType.Reads);
156
+ /* the write only happens because a force runs it */
157
+ for (const site of forces?.sites ?? []) {
158
+ graph.addEdge(node, site, edge_1.EdgeType.Reads);
159
+ }
160
+ if (shadows && alwaysAfterAForce(use)) {
161
+ graph.removeEdgeType(use, forces.binding, edge_1.EdgeType.Reads);
165
162
  }
166
163
  }
167
164
  }
@@ -3,7 +3,7 @@ import type { FnSig } from '../../../../environments/built-in-props';
3
3
  import type { DataflowInformation } from '../../../../info';
4
4
  import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
5
5
  import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
- import { type PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
6
+ import type { PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
7
7
  import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
9
9
  import { type IdentifierReference } from '../../../../environments/identifier';
@@ -54,7 +54,7 @@ export interface ProcessKnownFunctionCallResult {
54
54
  readonly fnRef: IdentifierReference;
55
55
  /**
56
56
  * The arguments as recorded on the function call vertex.
57
- * They are also part of the information via the function call vertex adde, but sometimes useful separately.
57
+ * They are also part of the information via the function call vertex added, but sometimes useful separately.
58
58
  * For example, together with {@link FunctionSemantics.call.match.toSpec} to do custom parameter matching.
59
59
  */
60
60
  readonly callArgs: readonly FunctionArgument[];
@@ -88,6 +88,8 @@ export interface NseMarkOptions {
88
88
  /** ids an unquote escape splices back in, see {@link FunctionSemantics.call.nse.unquoted} */
89
89
  readonly evaluated?: ReadonlySet<NodeId>;
90
90
  }
91
+ /** The positions of the arguments `which` names among `count` arguments. */
92
+ export declare function nseArgumentPositions(which: NseArguments | readonly number[] | undefined, count: number): readonly number[];
91
93
  /**
92
94
  * Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}: a {@link NseKind.Quoted|quoted} one
93
95
  * entirely, a {@link NseKind.DataMasked|data-masked} one only where {@link FunctionSemantics.call.nse.suppliedByMask} holds, and a
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NseKind = exports.NseArguments = void 0;
4
+ exports.nseArgumentPositions = nseArgumentPositions;
4
5
  exports.markArgumentsAsNonStandardEvaluation = markArgumentsAsNonStandardEvaluation;
5
6
  exports.processKnownFunctionCall = processKnownFunctionCall;
6
7
  const processor_1 = require("../../../../processor");
7
8
  const function_semantics_1 = require("../../../../fn/function-semantics");
9
+ const info_1 = require("../../../../info");
8
10
  const common_1 = require("./common");
9
11
  const apply_kill_1 = require("../../../../environments/apply-kill");
10
- const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
11
12
  const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
13
+ const r_string_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
12
14
  const identifier_1 = require("../../../../environments/identifier");
13
15
  const graph_1 = require("../../../../graph/graph");
14
16
  const edge_1 = require("../../../../graph/edge");
15
17
  const control_flow_1 = require("../../../control-flow");
18
+ const logic_1 = require("../../../../../util/logic");
19
+ const assert_1 = require("../../../../../util/assert");
16
20
  const logger_1 = require("../../../../logger");
17
21
  const vertex_1 = require("../../../../graph/vertex");
18
22
  const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
@@ -43,29 +47,30 @@ var NseKind;
43
47
  /** evaluated, just not exactly once (a loop body), so only the argument itself is marked */
44
48
  NseKind["Reevaluated"] = "reevaluated";
45
49
  })(NseKind || (exports.NseKind = NseKind = {}));
50
+ /** The positions of the arguments `which` names among `count` arguments. */
51
+ function nseArgumentPositions(which, count) {
52
+ if (typeof which !== 'string') {
53
+ return which ?? [];
54
+ }
55
+ const all = Array.from({ length: count }, (_, i) => i);
56
+ if (which === NseArguments.First) {
57
+ return all.slice(0, 1);
58
+ }
59
+ return which === NseArguments.AllButFirst ? all.slice(1) : all;
60
+ }
46
61
  /**
47
62
  * Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}: a {@link NseKind.Quoted|quoted} one
48
63
  * entirely, a {@link NseKind.DataMasked|data-masked} one only where {@link FunctionSemantics.call.nse.suppliedByMask} holds, and a
49
64
  * {@link NseKind.Reevaluated|reevaluated} one as a whole but not within.
50
65
  */
51
66
  function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which, { kind = NseKind.Quoted, evaluated } = {}) {
52
- if (which === undefined) {
53
- return;
54
- }
55
- if (typeof which !== 'string') {
56
- for (const i of which) {
57
- if (i < processedArguments.length) {
58
- markArgument(graph, rootId, processedArguments[i], kind, evaluated);
59
- }
60
- else {
61
- logger_1.dataflowLogger.warn(`Trying to mark argument ${i} as non-standard-evaluation, but only ${processedArguments.length} arguments are available`);
62
- }
67
+ for (const i of nseArgumentPositions(which, processedArguments.length)) {
68
+ if (i < processedArguments.length) {
69
+ markArgument(graph, rootId, processedArguments[i], kind, evaluated);
70
+ }
71
+ else {
72
+ logger_1.dataflowLogger.warn(`Trying to mark argument ${i} as non-standard-evaluation, but only ${processedArguments.length} arguments are available`);
63
73
  }
64
- return;
65
- }
66
- const end = which === NseArguments.First ? 1 : processedArguments.length;
67
- for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
68
- markArgument(graph, rootId, processedArguments[i], kind, evaluated);
69
74
  }
70
75
  }
71
76
  function markArgument(graph, rootId, arg, kind, evaluated) {
@@ -94,13 +99,23 @@ function markArgument(graph, rootId, arg, kind, evaluated) {
94
99
  * The main processor for function calls for which we know the target but need not
95
100
  * add any specific handling.
96
101
  */
97
- function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, sig, patchData = d => d, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom }) {
102
+ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, sig, patchData, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom }) {
98
103
  const functionName = (0, processor_1.processDataflowFor)(name, data);
99
104
  const finalGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
100
105
  const functionCallName = name.content;
101
106
  const processArgs = reverseOrder ? args.toReversed() : args;
102
107
  const forced = function_semantics_1.FunctionSemantics.call.signature.forced(sig, processArgs.length);
103
- const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({ functionName, args: processArgs, data, finalGraph, functionRootId: rootId, patchData, forced, nonFunction, alternativesFrom: reverseOrder ? undefined : alternativeArgsFrom });
108
+ const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({
109
+ functionName,
110
+ args: processArgs,
111
+ data: origin === 'default' ? control_flow_1.ControlFlow.withinPromise(data, rootId) : data,
112
+ finalGraph,
113
+ functionRootId: rootId,
114
+ patchData,
115
+ forced,
116
+ nonFunction,
117
+ alternativesFrom: reverseOrder ? undefined : alternativeArgsFrom
118
+ });
104
119
  markArgumentsAsNonStandardEvaluation(finalGraph, rootId, processedArguments, markAsNSE, { kind: NseKind.Reevaluated });
105
120
  const onlyBuiltin = data.builtInNoEnv === rootId;
106
121
  finalGraph.addVertex({
@@ -117,69 +132,51 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
117
132
  if (hasUnknownSideEffect) {
118
133
  (0, unknown_side_effect_1.handleUnknownSideEffect)(finalGraph, data.environment, rootId);
119
134
  }
120
- const inIds = remainingReadInArgs;
121
135
  const fnRef = { nodeId: rootId, name: functionCallName, cds: data.cds, type: identifier_1.ReferenceType.Function };
122
- inIds.push(fnRef);
123
- // if force args is not none, we need to collect all non-default exit points from our arguments!
136
+ remainingReadInArgs.push(fnRef);
137
+ /* each argument is a promise, and how surely the call forces it decides what a jump within it does */
124
138
  let exitPoints = undefined;
139
+ /* what a function flowR does not know here forces is up to its body, see `FunctionSemantics.settleJumpsInPromises` */
140
+ const forcing = origin === 'default' ? undefined : function_semantics_1.FunctionSemantics.call.signature.forcing(sig, processArgs.length);
141
+ /* exactly one alternative runs when a string selects among them with a default arm, a number past the arms picks none */
142
+ const selector = alternativeArgsFrom === undefined ? undefined : processArgs[alternativeArgsFrom - 1];
143
+ const hasDefaultArm = r_string_1.RString.is(r_argument_1.RArgument.valueOf(selector)) && processArgs.slice(alternativeArgsFrom).some(r_argument_1.RArgument.isUnnamed);
144
+ const alternatives = hasDefaultArm ? processedArguments.slice(alternativeArgsFrom).filter(assert_1.isNotUndefined) : [];
145
+ const allArmsJump = alternatives.length > 0 && alternatives.every(a => control_flow_1.ControlFlow.alwaysExits(a, data.cds));
125
146
  /* a jump that only happens under a condition still lets the call complete, so its default exit has to stay */
126
- let alwaysJumps = false;
127
- if (forced) {
128
- for (let i = 0; i < processedArguments.length; i++) {
129
- const p = processedArguments[i];
130
- if (p === undefined || !forced[i]) {
131
- continue;
132
- }
133
- const before = exitPoints?.length ?? 0;
134
- for (const exit of p.exitPoints) {
135
- if (exit.type !== 0 /* ExitPointType.Default */) {
136
- (exitPoints ??= []).push(exit);
137
- }
138
- }
139
- alwaysJumps ||= (exitPoints?.length ?? 0) > before && control_flow_1.ControlFlow.alwaysExits(p);
147
+ let alwaysJumps = allArmsJump;
148
+ for (const [i, p] of processedArguments.entries()) {
149
+ const isAlternative = alternativeArgsFrom !== undefined && i >= alternativeArgsFrom;
150
+ /* the alternative that is picked runs for sure, the others not at all */
151
+ const f = isAlternative ? logic_1.Ternary.Always : forcing?.[i] ?? logic_1.Ternary.Maybe;
152
+ /* a call with its own control flow wires up what it does not surely force itself */
153
+ if (p === undefined || (customControlFlow && f !== logic_1.Ternary.Always)) {
154
+ continue;
140
155
  }
141
- if (exitPoints !== undefined && !alwaysJumps) {
142
- exitPoints.push({ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds });
156
+ const exits = control_flow_1.ControlFlow.promise(finalGraph, p, f, rootId);
157
+ if (exits.length > 0) {
158
+ /* an arm that is not the only way out leaves only when it is picked */
159
+ const conditional = isAlternative && !allArmsJump;
160
+ (exitPoints ??= []).push(...conditional ? exits.map(e => ({ ...e, cds: (0, info_1.withCds)(e.cds, [{ id: rootId, when: true }]) })) : exits);
161
+ alwaysJumps ||= f === logic_1.Ternary.Always && !isAlternative && control_flow_1.ControlFlow.alwaysExits(p, data.cds);
143
162
  }
144
163
  }
145
- /* an alternative without a name is the default arm, which runs when nothing else matched */
164
+ if (exitPoints !== undefined && !alwaysJumps) {
165
+ exitPoints.push({ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds });
166
+ }
146
167
  const cfgEntry = customControlFlow ? rootId
147
168
  : alternativeArgsFrom === undefined ? control_flow_1.ControlFlow.inSequence(finalGraph, processedArguments, rootId)
148
- : control_flow_1.ControlFlow.picksOneOf(finalGraph, processedArguments, alternativeArgsFrom, rootId, processArgs.slice(alternativeArgsFrom).some(a => a !== r_function_call_1.EmptyArgument && (!r_argument_1.RArgument.is(a) || a.name === undefined)));
149
- if (!customControlFlow) {
150
- /*
151
- * A jump within an argument that the call does not pass on is caught here (the callee decides whether it
152
- * ever forces that argument), so control resumes at the call rather than leaving it.
153
- */
154
- for (const argument of processedArguments) {
155
- for (const exit of argument?.exitPoints ?? []) {
156
- /*
157
- * A jump within an argument the call does not pass on resumes at the call. A `return` leaves the
158
- * enclosing function wherever the argument runs at all, so only a call that never evaluates it
159
- * may catch one (see `processQuote`).
160
- */
161
- if (exit.type !== 0 /* ExitPointType.Default */ && exit.type !== 1 /* ExitPointType.Return */ && !exitPoints?.includes(exit)) {
162
- finalGraph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
163
- }
164
- }
165
- }
166
- }
167
- let kill = undefined;
168
- for (const p of processedArguments) {
169
- const kills = p?.kill;
170
- if (kills !== undefined && kills.length > 0) {
171
- kill = kill === undefined ? kills.slice() : kill.concat(kills);
172
- }
173
- }
174
- const environment = kill ? (0, apply_kill_1.applyKills)(finalEnv, kill) : finalEnv;
169
+ : control_flow_1.ControlFlow.picksOneOf(finalGraph, processedArguments, alternativeArgsFrom, rootId, hasDefaultArm);
170
+ const kills = processedArguments.flatMap(p => p?.kill ?? []);
171
+ const kill = kills.length > 0 ? kills : undefined;
175
172
  return {
176
173
  information: {
177
174
  unknownReferences: [],
178
- in: inIds,
175
+ in: remainingReadInArgs,
179
176
  /* we do not keep the argument out as it has been linked by the function */
180
177
  out: functionName.out,
181
178
  graph: finalGraph,
182
- environment,
179
+ environment: kill ? (0, apply_kill_1.applyKills)(finalEnv, kill) : finalEnv,
183
180
  entryPoint: rootId,
184
181
  cfgEntry: cfgEntry === rootId ? undefined : cfgEntry,
185
182
  exitPoints: exitPoints ?? [{ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds }],
@@ -1,13 +1,11 @@
1
1
  import type { DataflowProcessorInformation } from '../../../../processor';
2
2
  import { DataflowInformation } from '../../../../info';
3
3
  import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
- import type { PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
- import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
4
+ import { type PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
+ import { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
6
  import { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { DataflowGraph } from '../../../../graph/graph';
8
- /**
9
- * Marks the given function call node as only calling built-in functions.
10
- */
8
+ /** Marks the given function call node as only calling built-in functions. */
11
9
  export declare function markAsOnlyBuiltIn(graph: DataflowGraph, rootId: NodeId, keepEnvironment?: boolean): void;
12
10
  /**
13
11
  * Processes a named function call within the dataflow analysis.
@@ -7,6 +7,10 @@ const function_semantics_1 = require("../../../../fn/function-semantics");
7
7
  const info_1 = require("../../../../info");
8
8
  const known_call_handling_1 = require("./known-call-handling");
9
9
  const append_1 = require("../../../../environments/append");
10
+ const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
11
+ const r_binary_op_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
12
+ const r_symbol_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
13
+ const r_function_definition_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
10
14
  const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
11
15
  const identifier_1 = require("../../../../environments/identifier");
12
16
  const r_base_packages_1 = require("../../../../../util/r-base-packages");
@@ -55,9 +59,7 @@ function builtInBehindExport(data, definition) {
55
59
  const attached = definition;
56
60
  return typeof attached.processor === 'function' ? attached : undefined;
57
61
  }
58
- /**
59
- * Marks the given function call node as only calling built-in functions.
60
- */
62
+ /** Marks the given function call node as only calling built-in functions. */
61
63
  function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
62
64
  const v = graph.getVertex(rootId);
63
65
  if (vertex_1.DfgVertex.isFunctionCall(v)) {
@@ -67,6 +69,16 @@ function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
67
69
  }
68
70
  }
69
71
  }
72
+ function handsOverFunction(arg, data) {
73
+ const value = arg === r_function_call_1.EmptyArgument ? undefined : arg.value;
74
+ return r_function_definition_1.RFunctionDefinition.is(value) || (r_symbol_1.RSymbol.is(value) && (resolve_helper_1.Resolve.byNameAndType(value.content, data.environment, identifier_1.ReferenceType.Function)?.length ?? 0) > 0);
75
+ }
76
+ /** Whether a replacement function rewrote the value of `definition`, like `body(f) <- quote(runif(1))`, so its body is unknown. */
77
+ function rewrittenByReplacement(definition, data) {
78
+ const at = definition.definedAt;
79
+ const node = definition.type === identifier_1.ReferenceType.Unknown && at !== undefined ? data.completeAst.idMap.get(at) : undefined;
80
+ return r_function_call_1.RFunctionCall.is(node) || (r_binary_op_1.RBinaryOp.is(node) && r_function_call_1.RFunctionCall.is(node.lhs));
81
+ }
70
82
  /**
71
83
  * Processes a named function call within the dataflow analysis.
72
84
  * For example, `myFunction(arg1, arg2)`, resolves against the environment.
@@ -77,13 +89,13 @@ function processNamedCall(name, callArguments, rootId, data) {
77
89
  let defaultProcessor = resolved.length === 0;
78
90
  /* a call whose meaning a later pass looks up in its environment has to keep it */
79
91
  const keepEnvironment = resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.keepEnvironment === true);
80
- /* if this call will be marked as built-in only (see below), its vertex needs no environment snapshot */
92
+ /* a call marked as built-in only (see below) needs no environment snapshot */
81
93
  if (resolved.length > 0 && !keepEnvironment
82
94
  && resolved.every(r => r.type === identifier_1.ReferenceType.BuiltInFunction && typeof r.processor === 'function')
83
95
  && resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.libFn !== true)) {
84
96
  data = { ...data, builtInNoEnv: rootId };
85
97
  }
86
- let information = undefined;
98
+ let information;
87
99
  let builtIn = false;
88
100
  /* a set, because an export and the built-in behind it are two ways to the same definition */
89
101
  const toRun = new Set();
@@ -92,13 +104,12 @@ function processNamedCall(name, callArguments, rootId, data) {
92
104
  let unknownBody = resolved.length === 0 && data.environment.level === 0;
93
105
  for (const resolvedFunction of resolved) {
94
106
  const isBuiltIn = resolvedFunction.type === identifier_1.ReferenceType.BuiltInFunction && typeof resolvedFunction.processor === 'function';
95
- /* the call goes through the attached export, so it is not built-in only, but flowR's own
96
- definition of that export is what knows how to process it */
107
+ /* a call through an attached export is not built-in only, but flowR's definition of it processes it */
97
108
  const own = isBuiltIn ? resolvedFunction : builtInBehindExport(data, resolvedFunction);
98
109
  if (own === undefined) {
99
110
  defaultProcessor = true;
100
111
  /* a user function's body states what it reads itself */
101
- unknownBody ||= (0, built_in_ambient_state_1.hidesBody)(resolvedFunction);
112
+ unknownBody ||= (0, built_in_ambient_state_1.hidesBody)(resolvedFunction) || rewrittenByReplacement(resolvedFunction, data);
102
113
  continue;
103
114
  }
104
115
  builtIn ||= isBuiltIn && own.config?.libFn !== true;
@@ -114,20 +125,23 @@ function processNamedCall(name, callArguments, rootId, data) {
114
125
  }
115
126
  if (defaultProcessor) {
116
127
  /* if we do not know where we land, we force! reuse `resolved`, data.environment did not change above */
117
- const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, sig: resolved.length > 0 ? undefined : function_semantics_1.FunctionSemantics.call.signature.every, origin: 'default' });
128
+ const sig = resolved.length > 0 ? undefined : function_semantics_1.FunctionSemantics.call.signature.every;
129
+ const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, sig, origin: 'default' });
118
130
  information = mergeInformation(information, call.information);
119
131
  }
120
132
  else if (information && builtIn) {
121
- // mark the function call as built in only
122
133
  markAsOnlyBuiltIn(information.graph, rootId, keepEnvironment);
123
134
  }
124
135
  /* a function whose body we do not see may read any option or draw on the device */
125
136
  if (information !== undefined && (unknownBody || packageFn)) {
126
- information = (0, built_in_ambient_state_1.readsAllAmbientState)(information, rootId, data, unknownBody);
137
+ /* a function handed in as a parameter may be anything, `runif` included, and a function handed a function may call it;
138
+ otherwise a package function draws only if flowR states it does */
139
+ const draws = resolved.some(r => (0, identifier_1.isReferenceType)(r.type, identifier_1.ReferenceType.Parameter | identifier_1.ReferenceType.Argument) || rewrittenByReplacement(r, data)) || args.some(a => handsOverFunction(a, data));
140
+ information = (0, built_in_ambient_state_1.readsAllAmbientState)(information, rootId, data, unknownBody, draws);
127
141
  }
128
- // on demand: materialize the built-in vertex for any package export this call resolves to and, when we
129
- // already know the loading call here, link to it (a function-local export is invisible to the later
130
- // top-level linkMaterializedExportsToLoaders pass, so we must catch it at the call site)
142
+ /* on demand: materialize the built-in vertex for any package export this call resolves to and, when we
143
+ already know the loading call here, link to it (a function-local export is invisible to the later
144
+ top-level linkMaterializedExportsToLoaders pass, so we must catch it at the call site) */
131
145
  if (information) {
132
146
  const sigdb = data.ctx.config.solver.sigdb;
133
147
  for (const r of resolved) {
@@ -136,19 +150,19 @@ function processNamedCall(name, callArguments, rootId, data) {
136
150
  const definedAt = r.definedAt;
137
151
  if (definedAt !== undefined && !node_id_1.NodeId.isBuiltIn(definedAt)) {
138
152
  information.graph.addEdge(r.nodeId, definedAt, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
139
- // the call itself reads the library() load that made this export resolvable
153
+ /* the call itself reads the library() load that made this export resolvable */
140
154
  information.graph.addEdge(rootId, definedAt, edge_1.EdgeType.Reads);
141
155
  }
142
- // opt-in: a lightweight ref edge from the call to its sigdb-backed package function vertex
156
+ /* opt-in: a lightweight ref edge from the call to its sigdb-backed package function vertex */
143
157
  if (sigdb.linkPackageCalls && node_id_1.NodeId.toPkgFn(r.nodeId) !== undefined) {
144
158
  information.graph.addEdge(rootId, r.nodeId, edge_1.EdgeType.Reads);
145
159
  }
146
160
  }
147
161
  }
148
162
  const ns = identifier_1.Identifier.getNamespace(name.content);
149
- // a call links to a database-unresolved `library(pkg)` recorded below the global env: `pkg::fn` names
150
- // its package, a bare call takes it from what flowR resolved it to, which is what ties
151
- // `filter(df, id > 2)` to the `library(dplyr)` that made it dplyr's
163
+ /* a call links to a database-unresolved `library(pkg)` recorded below the global env: `pkg::fn` names
164
+ its package, a bare call takes it from what flowR resolved it to, which is what ties
165
+ `filter(df, id > 2)` to the `library(dplyr)` that made it dplyr's */
152
166
  const owners = ns !== undefined ? [ns] : resolved
153
167
  .map(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.name !== undefined ? identifier_1.Identifier.getNamespace(r.name) : undefined)
154
168
  .filter(assert_1.isNotUndefined);
@@ -157,8 +171,8 @@ function processNamedCall(name, callArguments, rootId, data) {
157
171
  information.graph.addEdge(rootId, loadNode, edge_1.EdgeType.Reads);
158
172
  }
159
173
  }
160
- // opt-in: link a bare base-R call to its sigdb function vertex (base-R qualification is edge-free otherwise);
161
- // same guards as Identifier.toQualified -- not namespaced, not resolving to a user definition
174
+ /* opt-in: link a bare base-R call to its sigdb function vertex (base-R qualification is edge-free otherwise);
175
+ same guards as Identifier.toQualified: not namespaced, not resolving to a user definition */
162
176
  if (sigdb.linkBaseRCalls && ns === undefined && !resolved.some(r => r.nodeId !== undefined && !node_id_1.NodeId.isBuiltIn(r.nodeId))) {
163
177
  const bare = identifier_1.Identifier.getName(name.content);
164
178
  const owner = (0, r_base_packages_1.baseRExportOwner)(bare);
@@ -18,6 +18,8 @@ export declare const Quoted: {
18
18
  readonly capturedBy: (this: void, graph: DataflowGraph, id: NodeId) => readonly NodeId[];
19
19
  /** Every expression the value at `id` may hold, with the call that captured it. Several is normal. */
20
20
  readonly sourcesOf: (this: void, graph: DataflowGraph, id: NodeId) => readonly CapturedExpression[];
21
+ /** What `id` within captured code needs to run at all: the capturing call and every call evaluating it (`eval`, `body(f) <- quote(...)`). */
22
+ readonly evaluationDependencies: (this: void, graph: DataflowGraph, id: NodeId) => NodeId[];
21
23
  /** Links every name in `expr` against `environment` and hands back what stays unresolved. */
22
24
  readonly evaluateIn: typeof linkExpressionIn;
23
25
  /**