@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.
Files changed (213) hide show
  1. package/README.md +23 -26
  2. package/abstract-interpretation/data-frame/arguments.js +11 -7
  3. package/cli/flowr-main-options.d.ts +15 -0
  4. package/cli/flowr-main-options.js +18 -0
  5. package/cli/flowr.d.ts +18 -0
  6. package/cli/flowr.js +13 -2
  7. package/cli/repl/commands/repl-clipboard.js +2 -1
  8. package/cli/repl/commands/repl-commands.js +2 -0
  9. package/cli/repl/commands/repl-main.d.ts +5 -0
  10. package/cli/repl/commands/repl-signature.js +2 -0
  11. package/cli/repl/core.d.ts +7 -1
  12. package/cli/repl/core.js +17 -8
  13. package/cli/repl/execute.js +2 -0
  14. package/cli/repl/server/connection.js +2 -1
  15. package/cli/repl/server/net.d.ts +10 -0
  16. package/cli/repl/server/net.js +34 -1
  17. package/cli/slicer-app.js +2 -1
  18. package/config.d.ts +12 -2
  19. package/config.js +91 -14
  20. package/control-flow/happens-before.d.ts +5 -0
  21. package/control-flow/happens-before.js +48 -34
  22. package/control-flow/useless-loop.d.ts +1 -1
  23. package/control-flow/useless-loop.js +29 -42
  24. package/dataflow/environments/built-in-props.d.ts +9 -0
  25. package/dataflow/environments/built-in-props.js +25 -19
  26. package/dataflow/environments/built-in.d.ts +2 -2
  27. package/dataflow/environments/built-in.js +41 -77
  28. package/dataflow/environments/default-builtin-config.d.ts +181 -29
  29. package/dataflow/environments/default-builtin-config.js +38 -24
  30. package/dataflow/environments/environment.d.ts +6 -4
  31. package/dataflow/environments/environment.js +54 -121
  32. package/dataflow/environments/identifier.d.ts +4 -2
  33. package/dataflow/environments/identifier.js +23 -69
  34. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  35. package/dataflow/environments/reference-to-maybe.js +23 -51
  36. package/dataflow/environments/resolve-by-name.js +37 -76
  37. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  38. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  39. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  40. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  41. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  42. package/dataflow/eval/resolve/resolve.js +23 -14
  43. package/dataflow/extractor.js +185 -59
  44. package/dataflow/fn/class-declaration.d.ts +8 -2
  45. package/dataflow/fn/class-declaration.js +96 -97
  46. package/dataflow/fn/exceptions-of-function.js +68 -37
  47. package/dataflow/fn/frame-reflection.d.ts +12 -4
  48. package/dataflow/fn/frame-reflection.js +64 -42
  49. package/dataflow/fn/function-props.js +15 -33
  50. package/dataflow/fn/function-semantics.d.ts +11 -3
  51. package/dataflow/fn/function-semantics.js +6 -0
  52. package/dataflow/fn/higher-order-function.js +13 -17
  53. package/dataflow/fn/strict-function.d.ts +13 -0
  54. package/dataflow/fn/strict-function.js +285 -122
  55. package/dataflow/graph/call-graph.d.ts +7 -6
  56. package/dataflow/graph/call-graph.js +35 -46
  57. package/dataflow/graph/graph.d.ts +6 -1
  58. package/dataflow/graph/graph.js +57 -66
  59. package/dataflow/info.d.ts +8 -1
  60. package/dataflow/info.js +24 -30
  61. package/dataflow/internal/control-flow.d.ts +42 -4
  62. package/dataflow/internal/control-flow.js +76 -39
  63. package/dataflow/internal/linker.d.ts +15 -9
  64. package/dataflow/internal/linker.js +253 -241
  65. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
  66. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
  67. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  68. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
  69. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
  70. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
  71. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  72. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
  74. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
  75. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
  76. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  78. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
  80. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
  82. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  84. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  85. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  86. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
  91. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  92. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  93. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  94. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  95. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
  97. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  98. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  99. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
  101. package/dataflow/internal/process/functions/call/common.d.ts +1 -3
  102. package/dataflow/internal/process/functions/call/common.js +36 -76
  103. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
  104. package/dataflow/internal/process/functions/call/deferred.js +60 -58
  105. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  106. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  107. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  108. package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
  109. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  110. package/dataflow/internal/process/functions/call/quoted.js +162 -172
  111. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  112. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  113. package/dataflow/internal/process/process-symbol.js +3 -6
  114. package/dataflow/internal/program-order.d.ts +26 -0
  115. package/dataflow/internal/program-order.js +49 -0
  116. package/documentation/doc-capabilities.js +4 -1
  117. package/documentation/wiki-interface.js +4 -0
  118. package/documentation/wiki-setup.js +23 -0
  119. package/engines.js +11 -3
  120. package/linter/linter-executor.js +19 -1
  121. package/linter/linter-rules.d.ts +17 -8
  122. package/linter/rules/absolute-path.js +63 -87
  123. package/linter/rules/file-path-validity.d.ts +4 -2
  124. package/linter/rules/file-path-validity.js +117 -80
  125. package/linter/rules/namespace-access.js +21 -33
  126. package/linter/rules/naming-convention.d.ts +1 -1
  127. package/linter/rules/naming-convention.js +60 -48
  128. package/linter/rules/network-functions.js +11 -7
  129. package/linter/rules/no-leaked-credentials.js +15 -18
  130. package/linter/rules/problematic-inputs.d.ts +2 -1
  131. package/linter/rules/problematic-inputs.js +39 -59
  132. package/linter/rules/roxygen-arguments.d.ts +9 -4
  133. package/linter/rules/roxygen-arguments.js +29 -48
  134. package/linter/rules/seeded-randomness.d.ts +7 -4
  135. package/linter/rules/seeded-randomness.js +130 -89
  136. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  137. package/linter/rules/stop-with-call-arg.js +25 -22
  138. package/linter/rules/unclosed-connection.js +31 -24
  139. package/linter/rules/undefined-symbol.d.ts +4 -6
  140. package/linter/rules/undefined-symbol.js +58 -75
  141. package/linter/rules/unescaped-arguments.js +18 -44
  142. package/linter/rules/unused-definition.d.ts +6 -0
  143. package/linter/rules/unused-definition.js +105 -145
  144. package/linter/rules/unused-import.d.ts +3 -0
  145. package/linter/rules/unused-import.js +25 -43
  146. package/package.json +5 -2
  147. package/project/flowr-analyzer.js +6 -2
  148. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  149. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  150. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
  151. package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
  152. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  153. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  154. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
  155. package/project/sigdb/decompress.js +3 -1
  156. package/project/sigdb/sigdb-download.js +9 -6
  157. package/queries/base-query-format.js +1 -2
  158. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  159. package/queries/catalog/config-query/config-query-executor.js +9 -2
  160. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  161. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  162. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  163. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  164. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  165. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  166. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  167. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  168. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  169. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  170. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  171. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  172. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  173. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  174. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  175. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  176. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  177. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  178. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  179. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  180. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  181. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  182. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  183. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  184. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  185. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  186. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  187. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  188. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  189. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  190. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  191. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  192. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  193. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  194. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  195. package/r-bridge/shell-executor.js +2 -0
  196. package/r-bridge/shell.js +8 -0
  197. package/search/search-executor/search-enrichers.js +25 -37
  198. package/slicing/static/slice-call.d.ts +4 -3
  199. package/slicing/static/slice-call.js +56 -88
  200. package/slicing/static/static-slicer.js +120 -79
  201. package/slicing/static/visiting-queue.d.ts +4 -6
  202. package/slicing/static/visiting-queue.js +9 -13
  203. package/util/files.d.ts +6 -0
  204. package/util/files.js +12 -0
  205. package/util/parallel.js +2 -0
  206. package/util/proc.js +2 -1
  207. package/util/r-base-packages.d.ts +2 -0
  208. package/util/r-base-packages.js +23 -13
  209. package/util/secure-mode.d.ts +42 -0
  210. package/util/secure-mode.js +70 -0
  211. package/util/text/playground-link.d.ts +12 -3
  212. package/util/text/playground-link.js +18 -27
  213. 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,34 @@ 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 r_function_definition_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
17
+ const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
18
+ /** The vertices of `type` by their unquoted name. */
19
+ function verticesByName(graph, type, idMap) {
20
+ const named = graph.vertexIdsOfType(type).filter(id => node_id_1.NodeId.recoverName(id, idMap) !== undefined);
21
+ return Map.groupBy(named, id => (0, retriever_1.removeRQuotes)(node_id_1.NodeId.recoverName(id, idMap)));
26
22
  }
27
23
  /** The names a deferred expression touches, each with the node touching it and whether it is written. */
28
24
  function namesWithin(expr, graph, idMap) {
29
- const node = idMap.get(expr);
30
25
  const names = [];
31
- if (node === undefined) {
32
- return names;
33
- }
34
26
  const callees = new Set();
35
- model_1.RNode.visitAst(node, inner => {
36
- if (r_function_call_1.RFunctionCall.isNamed(inner)) {
27
+ model_1.RNode.visitAst(idMap.get(expr), inner => {
28
+ /* a definition only creates its closure, the body runs when it is called and that call carries its effects */
29
+ if (r_function_definition_1.RFunctionDefinition.is(inner)) {
30
+ return true;
31
+ }
32
+ else if (r_function_call_1.RFunctionCall.isNamed(inner)) {
37
33
  callees.add(inner.functionName.info.id);
38
34
  /* a call reads the function it names, so `evalq(f())` needs the definition of `f` */
39
35
  if (vertex_1.DfgVertex.isFunctionCall(graph.getVertex(inner.info.id))) {
40
36
  names.push([inner.info.id, identifier_1.Identifier.getName(inner.functionName.content), false]);
37
+ for (const def of (0, frame_reflection_1.edgeSources)(graph, inner.info.id, edge_1.EdgeType.SideEffectOnCall)) {
38
+ const name = node_id_1.NodeId.recoverName(def, idMap);
39
+ if (name !== undefined) {
40
+ names.push([def, (0, retriever_1.removeRQuotes)(name), true]);
41
+ }
42
+ }
41
43
  }
42
44
  return false;
43
45
  }
@@ -64,57 +66,56 @@ function namesWithin(expr, graph, idMap) {
64
66
  exports.Deferred = {
65
67
  /** Where each name is bound and read, built once and shared by every deferred expression in the graph. */
66
68
  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 };
69
+ return {
70
+ definitions: verticesByName(graph, vertex_1.VertexType.VariableDefinition, idMap),
71
+ uses: verticesByName(graph, vertex_1.VertexType.Use, idMap)
72
+ };
78
73
  },
79
74
  /**
80
75
  * The reads that may be the one forcing `binding`: every read of it that no other read always precedes,
81
76
  * since an earlier read would already have forced it and cached the value.
77
+ * With `viaClosures`, a closure reading a `delayedAssign` binding forces it when called.
82
78
  */
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
- }
79
+ forcedAt(graph, binding, cfg, viaClosures = false) {
80
+ const reads = (0, frame_reflection_1.edgeSources)(graph, binding, edge_1.EdgeType.Reads);
81
+ const readSet = new Set(reads);
82
+ /* a closure reading it and the call of that closure may skip the read, so they never rule out a later force */
83
+ const calls = viaClosures
84
+ ? (0, frame_reflection_1.edgeSources)(graph, binding, edge_1.EdgeType.DefinesOnCall | edge_1.EdgeType.DefinedByOnCall).filter(r => !readSet.has(r))
85
+ : [];
90
86
  if (reads.length < 2) {
91
- return reads;
87
+ return reads.concat(calls);
92
88
  }
93
- const readSet = new Set(reads);
94
- return reads.filter(r => !(0, happens_before_1.someAlwaysBefore)(cfg, readSet, r));
89
+ /* the reads of a parameter all sit in its function, which is where the walk can stay */
90
+ const parameter = graph.idMap?.get(binding)?.info.parent;
91
+ const owner = graph.getVertex(graph.idMap?.get(parameter ?? '')?.info.parent ?? '');
92
+ 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);
93
+ return reads.filter(r => first.has(r)).concat(calls);
95
94
  },
96
95
  /**
97
96
  * Links the writes an expression performs to the uses that may observe them, for a call evaluating the
98
97
  * expression at a point control flow can pin down (`eval`). The reads are settled by the evaluating call
99
98
  * itself, against the environment in effect there, so only this direction is left open.
100
99
  */
101
- publish(graph, expr, index, idMap, at, cfg) {
100
+ publish(graph, expr, index, idMap, at, sites, cfg) {
102
101
  const within = namesWithin(expr, graph, idMap);
103
102
  const own = new Set(within.map(([id]) => id));
104
103
  let reachedFromAt;
105
- for (const [node, name, writes] of within) {
106
- if (!writes) {
107
- continue;
104
+ let reachedFromSites;
105
+ for (const [node, name] of within.filter(([, , writes]) => writes)) {
106
+ /* a write leaving the evaluating frame lands whenever a call of the closure evaluating it does */
107
+ const escapes = vertex_1.DfgVertex.hasOrigin(graph.getVertex(idMap.get(node)?.info.parent ?? ''), built_in_proc_name_1.BuiltInProcName.SuperAssignment);
108
+ for (const site of escapes ? sites : []) {
109
+ if (site !== at) {
110
+ graph.addEdge(node, site, edge_1.EdgeType.SideEffectOnCall);
111
+ }
108
112
  }
109
113
  for (const use of index.uses.get(name) ?? []) {
110
114
  /* 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;
115
+ const reached = cfg === undefined ? undefined : escapes ? reachedFromSites ??= (0, happens_before_1.reachableFrom)(cfg, [at, ...sites]) : reachedFromAt ??= (0, happens_before_1.reachableFrom)(cfg, [at]);
116
+ if (!own.has(use) && (reached === undefined || reached.has(use))) {
117
+ graph.addEdge(use, node, edge_1.EdgeType.Reads);
116
118
  }
117
- graph.addEdge(use, node, edge_1.EdgeType.Reads);
118
119
  }
119
120
  }
120
121
  },
@@ -153,15 +154,16 @@ exports.Deferred = {
153
154
  /* a write of the bound name replaces the binding, so a read it definitely reaches sees only it */
154
155
  const shadows = forces !== undefined && name === bindingName && graph.getVertex(node)?.cds === undefined;
155
156
  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
- }
157
+ if (own.has(use) || !reachedByAForce(use)) {
158
+ continue;
159
+ }
160
+ graph.addEdge(use, node, edge_1.EdgeType.Reads);
161
+ /* the write only happens because a force runs it */
162
+ for (const site of forces?.sites ?? []) {
163
+ graph.addEdge(node, site, edge_1.EdgeType.Reads);
164
+ }
165
+ if (shadows && alwaysAfterAForce(use)) {
166
+ graph.removeEdgeType(use, forces.binding, edge_1.EdgeType.Reads);
165
167
  }
166
168
  }
167
169
  }
@@ -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");
@@ -15,6 +19,8 @@ const built_in_library_1 = require("./built-in/built-in-library");
15
19
  const vertex_1 = require("../../../../graph/vertex");
16
20
  const resolve_helper_1 = require("../../../../environments/resolve-helper");
17
21
  const assert_1 = require("../../../../../util/assert");
22
+ const built_in_props_1 = require("../../../../environments/built-in-props");
23
+ const query_fn_props_1 = require("../../../../environments/query-fn-props");
18
24
  function mergeInformation(info, newInfo) {
19
25
  if (info === undefined) {
20
26
  return newInfo;
@@ -55,9 +61,7 @@ function builtInBehindExport(data, definition) {
55
61
  const attached = definition;
56
62
  return typeof attached.processor === 'function' ? attached : undefined;
57
63
  }
58
- /**
59
- * Marks the given function call node as only calling built-in functions.
60
- */
64
+ /** Marks the given function call node as only calling built-in functions. */
61
65
  function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
62
66
  const v = graph.getVertex(rootId);
63
67
  if (vertex_1.DfgVertex.isFunctionCall(v)) {
@@ -67,6 +71,23 @@ function markAsOnlyBuiltIn(graph, rootId, keepEnvironment = false) {
67
71
  }
68
72
  }
69
73
  }
74
+ const HandedFunction = identifier_1.ReferenceType.Function | identifier_1.ReferenceType.Parameter | identifier_1.ReferenceType.Argument;
75
+ /** Whether `arg` hands over a function that may draw: a symbol bound to data (`d <- read.csv(f)`, `NA`) does not, nor does a built-in stating it does not (`mean`) */
76
+ function handsOverFunction(arg, data) {
77
+ const value = arg === r_function_call_1.EmptyArgument ? undefined : arg.value;
78
+ if (!r_symbol_1.RSymbol.is(value)) {
79
+ return r_function_definition_1.RFunctionDefinition.is(value);
80
+ }
81
+ const defs = resolve_helper_1.Resolve.byNameAndType(value.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
82
+ return defs.some(d => (0, identifier_1.isReferenceType)(d.type, HandedFunction)) || (defs.some(d => d.type === identifier_1.ReferenceType.BuiltInFunction)
83
+ && built_in_props_1.CallProps.hasAny((0, query_fn_props_1.queryFnProps)(value.content, { environment: data.environment }), [built_in_props_1.CallProp.Configures, built_in_props_1.SemanticCallTag.Random]));
84
+ }
85
+ /** Whether a replacement function rewrote the value of `definition`, like `body(f) <- quote(runif(1))`, so its body is unknown. */
86
+ function rewrittenByReplacement(definition, data) {
87
+ const at = definition.definedAt;
88
+ const node = definition.type === identifier_1.ReferenceType.Unknown && at !== undefined ? data.completeAst.idMap.get(at) : undefined;
89
+ return r_function_call_1.RFunctionCall.is(node) || (r_binary_op_1.RBinaryOp.is(node) && r_function_call_1.RFunctionCall.is(node.lhs));
90
+ }
70
91
  /**
71
92
  * Processes a named function call within the dataflow analysis.
72
93
  * For example, `myFunction(arg1, arg2)`, resolves against the environment.
@@ -77,13 +98,13 @@ function processNamedCall(name, callArguments, rootId, data) {
77
98
  let defaultProcessor = resolved.length === 0;
78
99
  /* a call whose meaning a later pass looks up in its environment has to keep it */
79
100
  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 */
101
+ /* a call marked as built-in only (see below) needs no environment snapshot */
81
102
  if (resolved.length > 0 && !keepEnvironment
82
103
  && resolved.every(r => r.type === identifier_1.ReferenceType.BuiltInFunction && typeof r.processor === 'function')
83
104
  && resolved.some(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.config?.libFn !== true)) {
84
105
  data = { ...data, builtInNoEnv: rootId };
85
106
  }
86
- let information = undefined;
107
+ let information;
87
108
  let builtIn = false;
88
109
  /* a set, because an export and the built-in behind it are two ways to the same definition */
89
110
  const toRun = new Set();
@@ -92,13 +113,12 @@ function processNamedCall(name, callArguments, rootId, data) {
92
113
  let unknownBody = resolved.length === 0 && data.environment.level === 0;
93
114
  for (const resolvedFunction of resolved) {
94
115
  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 */
116
+ /* a call through an attached export is not built-in only, but flowR's definition of it processes it */
97
117
  const own = isBuiltIn ? resolvedFunction : builtInBehindExport(data, resolvedFunction);
98
118
  if (own === undefined) {
99
119
  defaultProcessor = true;
100
120
  /* a user function's body states what it reads itself */
101
- unknownBody ||= (0, built_in_ambient_state_1.hidesBody)(resolvedFunction);
121
+ unknownBody ||= (0, built_in_ambient_state_1.hidesBody)(resolvedFunction) || rewrittenByReplacement(resolvedFunction, data);
102
122
  continue;
103
123
  }
104
124
  builtIn ||= isBuiltIn && own.config?.libFn !== true;
@@ -114,20 +134,23 @@ function processNamedCall(name, callArguments, rootId, data) {
114
134
  }
115
135
  if (defaultProcessor) {
116
136
  /* 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' });
137
+ const sig = resolved.length > 0 ? undefined : function_semantics_1.FunctionSemantics.call.signature.every;
138
+ const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, sig, origin: 'default' });
118
139
  information = mergeInformation(information, call.information);
119
140
  }
120
141
  else if (information && builtIn) {
121
- // mark the function call as built in only
122
142
  markAsOnlyBuiltIn(information.graph, rootId, keepEnvironment);
123
143
  }
124
144
  /* a function whose body we do not see may read any option or draw on the device */
125
145
  if (information !== undefined && (unknownBody || packageFn)) {
126
- information = (0, built_in_ambient_state_1.readsAllAmbientState)(information, rootId, data, unknownBody);
146
+ /* a function handed in as a parameter may be anything, `runif` included, and a function handed a function may call it;
147
+ otherwise a package function draws only if flowR states it does */
148
+ 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));
149
+ information = (0, built_in_ambient_state_1.readsAllAmbientState)(information, rootId, data, unknownBody, draws);
127
150
  }
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)
151
+ /* on demand: materialize the built-in vertex for any package export this call resolves to and, when we
152
+ already know the loading call here, link to it (a function-local export is invisible to the later
153
+ top-level linkMaterializedExportsToLoaders pass, so we must catch it at the call site) */
131
154
  if (information) {
132
155
  const sigdb = data.ctx.config.solver.sigdb;
133
156
  for (const r of resolved) {
@@ -136,19 +159,19 @@ function processNamedCall(name, callArguments, rootId, data) {
136
159
  const definedAt = r.definedAt;
137
160
  if (definedAt !== undefined && !node_id_1.NodeId.isBuiltIn(definedAt)) {
138
161
  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
162
+ /* the call itself reads the library() load that made this export resolvable */
140
163
  information.graph.addEdge(rootId, definedAt, edge_1.EdgeType.Reads);
141
164
  }
142
- // opt-in: a lightweight ref edge from the call to its sigdb-backed package function vertex
165
+ /* opt-in: a lightweight ref edge from the call to its sigdb-backed package function vertex */
143
166
  if (sigdb.linkPackageCalls && node_id_1.NodeId.toPkgFn(r.nodeId) !== undefined) {
144
167
  information.graph.addEdge(rootId, r.nodeId, edge_1.EdgeType.Reads);
145
168
  }
146
169
  }
147
170
  }
148
171
  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
172
+ /* a call links to a database-unresolved `library(pkg)` recorded below the global env: `pkg::fn` names
173
+ its package, a bare call takes it from what flowR resolved it to, which is what ties
174
+ `filter(df, id > 2)` to the `library(dplyr)` that made it dplyr's */
152
175
  const owners = ns !== undefined ? [ns] : resolved
153
176
  .map(r => r.type === identifier_1.ReferenceType.BuiltInFunction && r.name !== undefined ? identifier_1.Identifier.getNamespace(r.name) : undefined)
154
177
  .filter(assert_1.isNotUndefined);
@@ -157,8 +180,8 @@ function processNamedCall(name, callArguments, rootId, data) {
157
180
  information.graph.addEdge(rootId, loadNode, edge_1.EdgeType.Reads);
158
181
  }
159
182
  }
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
183
+ /* opt-in: link a bare base-R call to its sigdb function vertex (base-R qualification is edge-free otherwise);
184
+ same guards as Identifier.toQualified: not namespaced, not resolving to a user definition */
162
185
  if (sigdb.linkBaseRCalls && ns === undefined && !resolved.some(r => r.nodeId !== undefined && !node_id_1.NodeId.isBuiltIn(r.nodeId))) {
163
186
  const bare = identifier_1.Identifier.getName(name.content);
164
187
  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
  /**