@eagleoutice/flowr 2.15.9 → 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 (244) hide show
  1. package/README.md +47 -41
  2. package/abstract-interpretation/absint-inference.d.ts +2 -2
  3. package/abstract-interpretation/absint-inference.js +32 -79
  4. package/abstract-interpretation/data-frame/arguments.js +11 -7
  5. package/benchmark/slicer.d.ts +0 -1
  6. package/benchmark/slicer.js +1 -2
  7. package/cli/repl/commands/repl-signature.js +12 -3
  8. package/config.d.ts +5 -1
  9. package/control-flow/cfg-properties.js +0 -22
  10. package/control-flow/happens-before.d.ts +7 -2
  11. package/control-flow/happens-before.js +55 -31
  12. package/control-flow/useless-loop.d.ts +1 -1
  13. package/control-flow/useless-loop.js +29 -42
  14. package/dataflow/environments/apply-kill.js +6 -2
  15. package/dataflow/environments/built-in-config.d.ts +2 -0
  16. package/dataflow/environments/built-in-props.d.ts +16 -1
  17. package/dataflow/environments/built-in-props.js +33 -20
  18. package/dataflow/environments/built-in.d.ts +8 -3
  19. package/dataflow/environments/built-in.js +52 -82
  20. package/dataflow/environments/default-builtin-config.d.ts +551 -21
  21. package/dataflow/environments/default-builtin-config.js +121 -45
  22. package/dataflow/environments/define.d.ts +3 -2
  23. package/dataflow/environments/define.js +4 -3
  24. package/dataflow/environments/deprecation-info.d.ts +45 -0
  25. package/dataflow/environments/deprecation-info.js +13 -0
  26. package/dataflow/environments/environment.d.ts +7 -5
  27. package/dataflow/environments/environment.js +55 -121
  28. package/dataflow/environments/identifier.d.ts +6 -2
  29. package/dataflow/environments/identifier.js +23 -69
  30. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  31. package/dataflow/environments/reference-to-maybe.js +23 -51
  32. package/dataflow/environments/resolve-by-name.js +37 -76
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  34. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  35. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  36. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  37. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  38. package/dataflow/eval/resolve/resolve.js +23 -14
  39. package/dataflow/extractor.js +180 -58
  40. package/dataflow/fn/class-declaration.d.ts +8 -13
  41. package/dataflow/fn/class-declaration.js +95 -116
  42. package/dataflow/fn/exceptions-of-function.js +68 -37
  43. package/dataflow/fn/frame-reflection.d.ts +12 -4
  44. package/dataflow/fn/frame-reflection.js +51 -41
  45. package/dataflow/fn/function-props.js +15 -33
  46. package/dataflow/fn/function-semantics.d.ts +11 -3
  47. package/dataflow/fn/function-semantics.js +6 -0
  48. package/dataflow/fn/higher-order-function.d.ts +9 -1
  49. package/dataflow/fn/higher-order-function.js +27 -24
  50. package/dataflow/fn/strict-function.d.ts +13 -0
  51. package/dataflow/fn/strict-function.js +291 -123
  52. package/dataflow/graph/call-graph.d.ts +7 -6
  53. package/dataflow/graph/call-graph.js +35 -46
  54. package/dataflow/graph/graph.d.ts +13 -1
  55. package/dataflow/graph/graph.js +74 -66
  56. package/dataflow/graph/vertex.d.ts +1 -1
  57. package/dataflow/info.d.ts +8 -1
  58. package/dataflow/info.js +24 -30
  59. package/dataflow/internal/control-flow.d.ts +31 -4
  60. package/dataflow/internal/control-flow.js +61 -39
  61. package/dataflow/internal/linker.d.ts +17 -8
  62. package/dataflow/internal/linker.js +286 -213
  63. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
  65. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
  69. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  70. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
  72. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
  75. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
  76. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  79. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  84. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  85. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
  91. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
  93. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  94. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  97. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  98. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
  99. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  101. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  102. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  103. package/dataflow/internal/process/functions/call/common.d.ts +4 -4
  104. package/dataflow/internal/process/functions/call/common.js +49 -71
  105. package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
  106. package/dataflow/internal/process/functions/call/deferred.js +81 -63
  107. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  108. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  109. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  110. package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
  111. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  112. package/dataflow/internal/process/functions/call/quoted.js +257 -154
  113. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  114. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  115. package/dataflow/internal/process/process-symbol.js +4 -3
  116. package/dataflow/internal/program-order.d.ts +26 -0
  117. package/dataflow/internal/program-order.js +49 -0
  118. package/documentation/data/faq/faqs.js +3 -3
  119. package/documentation/data/interface/doc-writing-code.js +1 -2
  120. package/documentation/data/server/doc-data-server-messages.js +7 -7
  121. package/documentation/doc-capabilities.js +80 -34
  122. package/documentation/doc-util/doc-query.d.ts +0 -3
  123. package/documentation/doc-util/doc-query.js +4 -3
  124. package/documentation/wiki-analyzer.js +1 -1
  125. package/documentation/wiki-cfg.js +5 -6
  126. package/documentation/wiki-core.js +8 -8
  127. package/documentation/wiki-dataflow-graph.js +10 -11
  128. package/documentation/wiki-interface.js +2 -2
  129. package/documentation/wiki-linting-and-testing.js +3 -3
  130. package/documentation/wiki-overview.js +6 -6
  131. package/documentation/wiki-query.js +9 -101
  132. package/documentation/wiki-setup.js +23 -0
  133. package/documentation/wiki-signature-database.js +1 -1
  134. package/linter/linter-rules.d.ts +18 -9
  135. package/linter/rules/absolute-path.js +63 -87
  136. package/linter/rules/deprecated-functions.d.ts +1 -45
  137. package/linter/rules/deprecated-functions.js +24 -33
  138. package/linter/rules/file-path-validity.d.ts +4 -2
  139. package/linter/rules/file-path-validity.js +114 -80
  140. package/linter/rules/namespace-access.js +21 -33
  141. package/linter/rules/naming-convention.d.ts +1 -1
  142. package/linter/rules/naming-convention.js +60 -48
  143. package/linter/rules/network-functions.js +11 -7
  144. package/linter/rules/no-leaked-credentials.js +15 -18
  145. package/linter/rules/problematic-inputs.d.ts +2 -1
  146. package/linter/rules/problematic-inputs.js +39 -59
  147. package/linter/rules/roxygen-arguments.d.ts +9 -4
  148. package/linter/rules/roxygen-arguments.js +29 -48
  149. package/linter/rules/seeded-randomness.d.ts +7 -4
  150. package/linter/rules/seeded-randomness.js +128 -89
  151. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  152. package/linter/rules/stop-with-call-arg.js +25 -22
  153. package/linter/rules/unclosed-connection.js +31 -24
  154. package/linter/rules/undefined-symbol.d.ts +4 -6
  155. package/linter/rules/undefined-symbol.js +58 -75
  156. package/linter/rules/unescaped-arguments.js +18 -44
  157. package/linter/rules/unused-definition.d.ts +6 -0
  158. package/linter/rules/unused-definition.js +105 -145
  159. package/linter/rules/unused-import.d.ts +3 -0
  160. package/linter/rules/unused-import.js +25 -43
  161. package/package.json +5 -2
  162. package/project/flowr-analyzer.d.ts +2 -0
  163. package/project/flowr-analyzer.js +28 -1
  164. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  165. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  166. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
  167. package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
  168. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  169. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  170. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
  171. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
  172. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  173. package/project/sigdb/build.js +4 -0
  174. package/project/sigdb/manifest.d.ts +2 -0
  175. package/project/sigdb/manifest.js +10 -1
  176. package/project/sigdb/reader.js +23 -61
  177. package/project/sigdb/sigdb-download.d.ts +29 -6
  178. package/project/sigdb/sigdb-download.js +212 -64
  179. package/queries/base-query-format.js +1 -2
  180. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  181. package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
  182. package/queries/catalog/call-context-query/cascade-action.js +2 -0
  183. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
  184. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  185. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  186. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  187. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  188. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  189. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  190. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  191. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  192. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  193. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  194. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
  195. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  196. package/queries/catalog/origin-query/origin-query-executor.js +2 -2
  197. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
  198. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  199. package/queries/query.d.ts +1 -1
  200. package/r-bridge/data/data.d.ts +21 -14
  201. package/r-bridge/data/data.js +28 -20
  202. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  203. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  204. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  205. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  208. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  209. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  212. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  213. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  214. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  215. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  216. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  217. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  218. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  219. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  220. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  221. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  222. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  223. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  224. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  225. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  226. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  227. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
  228. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  229. package/r-bridge/shell.js +6 -0
  230. package/search/search-executor/search-enrichers.js +25 -37
  231. package/slicing/static/slice-call.d.ts +4 -3
  232. package/slicing/static/slice-call.js +56 -88
  233. package/slicing/static/static-slicer.js +115 -79
  234. package/slicing/static/visiting-queue.d.ts +4 -6
  235. package/slicing/static/visiting-queue.js +9 -13
  236. package/util/files.d.ts +2 -0
  237. package/util/files.js +3 -1
  238. package/util/mermaid/mermaid.js +6 -2
  239. package/util/proc.js +2 -1
  240. package/util/r-base-packages.d.ts +2 -0
  241. package/util/r-base-packages.js +23 -13
  242. package/util/text/playground-link.d.ts +12 -3
  243. package/util/text/playground-link.js +18 -27
  244. package/util/version.js +4 -10
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.edgeTargets = edgeTargets;
4
+ exports.calledDefinitions = calledDefinitions;
5
+ exports.edgeSources = edgeSources;
6
+ exports.definitionsByName = definitionsByName;
7
+ exports.hasEdgeOfType = hasEdgeOfType;
4
8
  exports.callsIn = callsIn;
5
9
  exports.propagateToFixpoint = propagateToFixpoint;
6
10
  exports.reflectiveRolesOf = reflectiveRolesOf;
@@ -10,11 +14,36 @@ const edge_1 = require("../graph/edge");
10
14
  const df_helper_1 = require("../graph/df-helper");
11
15
  const vertex_1 = require("../graph/vertex");
12
16
  const built_in_props_1 = require("../environments/built-in-props");
17
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
18
+ const retriever_1 = require("../../r-bridge/retriever");
13
19
  const defaultmap_1 = require("../../util/collections/defaultmap");
14
20
  /** The nodes at the far end of `node`'s outgoing edges of any of `types`, shared by every walk here and in the sibling analyses that follow specific edge kinds. */
15
21
  function edgeTargets(graph, node, types) {
16
22
  return [...graph.edgesFrom(node)].filter(([, edge]) => edge_1.DfEdge.includesType(edge, types)).map(([target]) => target);
17
23
  }
24
+ /** The function-definition vertices a `call` resolves to (via {@link EdgeType.Calls}). */
25
+ function calledDefinitions(graph, call) {
26
+ return edgeTargets(graph, call, edge_1.EdgeType.Calls).filter(t => vertex_1.DfgVertex.isFunctionDefinition(graph.getVertex(t)));
27
+ }
28
+ /** The nodes at the near end of `node`'s incoming edges of any of `types`, see {@link edgeTargets}. */
29
+ function edgeSources(graph, node, types) {
30
+ return [...graph.edgesTo(node)].filter(([, edge]) => edge_1.DfEdge.includesType(edge, types)).map(([source]) => source);
31
+ }
32
+ /** Every variable definition by its unquoted name, in a single pass. */
33
+ function definitionsByName(graph) {
34
+ const byName = new defaultmap_1.DefaultMap(() => []);
35
+ for (const [id] of graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
36
+ const name = node_id_1.NodeId.recoverName(id, graph.idMap);
37
+ if (name !== undefined) {
38
+ byName.get((0, retriever_1.removeRQuotes)(name)).push(id);
39
+ }
40
+ }
41
+ return byName;
42
+ }
43
+ /** Whether an edge from `from` to `to` carries any of `types`. */
44
+ function hasEdgeOfType(graph, from, to, types) {
45
+ return edge_1.DfEdge.includesType(graph.outgoingEdges(from)?.get(to) ?? { types: 0 }, types);
46
+ }
18
47
  /** The calls a definition's body reaches, id and vertex paired; shared by every walk here and in the sibling analyses that visit them all. */
19
48
  function* callsIn(definition, graph) {
20
49
  for (const node of definition.subflow.graph) {
@@ -27,9 +56,8 @@ function* callsIn(definition, graph) {
27
56
  /**
28
57
  * Recomputes `recompute(id)` for every node reachable from `seed` along the reverse of `successors`, so a
29
58
  * change at a node is carried on to whatever points at it, until nothing grows anymore. `recompute` updates
30
- * its node's value itself and reports whether it grew; shared by {@link propagateOverCalls} and
31
- * {@link exceptionsOfFunction}, which differ only in what "grew" means for the value they carry, and
32
- * by {@link carriersOf} below, which grows a set rather than a bitfield.
59
+ * its node's value itself and reports whether it grew; shared by {@link propagateOverCalls} and by
60
+ * {@link carriersOf} below, which grows a set rather than a bitfield.
33
61
  */
34
62
  function propagateToFixpoint(seed, successors, recompute) {
35
63
  const callers = new defaultmap_1.DefaultMap(() => []);
@@ -63,8 +91,9 @@ function propagateToFixpoint(seed, successors, recompute) {
63
91
  function reflectiveRolesOf(definition, graph, { known }) {
64
92
  let roles = 0;
65
93
  for (const [node, vertex] of callsIn(definition, graph)) {
66
- const frame = known(vertex.name)?.frame ?? 0;
67
- if (frame === 0 || (roles & frame) === frame || handedAnotherFrame(vertex, known)) {
94
+ const info = known(vertex.name);
95
+ const frame = info?.frame ?? 0;
96
+ if (frame === 0 || (roles & frame) === frame || handedAnotherFrame(vertex, info)) {
68
97
  continue;
69
98
  }
70
99
  if (!resolvedThroughout(node, definition, graph)) {
@@ -74,27 +103,35 @@ function reflectiveRolesOf(definition, graph, { known }) {
74
103
  return roles;
75
104
  }
76
105
  /** Whether the call was handed the frame to look at ({@link ArgProp.Handle}, as in `environment(g)`). */
77
- function handedAnotherFrame(vertex, known) {
78
- const sig = known(vertex.name)?.sig;
79
- return sig !== undefined && built_in_props_1.FnSig.posWith(built_in_props_1.FnSig.layout(sig), vertex.args.length, built_in_props_1.ArgProp.Handle).length > 0;
106
+ function handedAnotherFrame(vertex, info) {
107
+ return info?.sig !== undefined && built_in_props_1.FnSig.posWith(built_in_props_1.FnSig.layout(info.sig), vertex.args.length, built_in_props_1.ArgProp.Handle).length > 0;
80
108
  }
81
109
  /** Whether every consumer of what the reflective call at `frame` handed out resolves to a formal, and there is at least one. */
82
110
  function resolvedThroughout(frame, definition, graph) {
83
111
  const formals = new Set(df_helper_1.Dataflow.parametersOf(definition));
84
112
  const carrying = carriersOf(frame, definition, graph);
85
113
  let consumers = 0;
86
- for (const node of definition.subflow.graph) {
87
- const vertex = graph.getVertex(node);
88
- if (!vertex_1.DfgVertex.isFunctionCall(vertex) || carrying.has(node) || !consumes(vertex, carrying)) {
114
+ for (const [node, vertex] of callsIn(definition, graph)) {
115
+ const args = argumentsOf(vertex);
116
+ if (carrying.has(node) || !args.some(id => carrying.has(id))) {
89
117
  continue;
90
118
  }
91
119
  consumers++;
92
- if (!resolvedToAFormal(vertex, formals, graph)) {
120
+ if (!resolvedToAFormal(node, args, formals, graph)) {
93
121
  return false;
94
122
  }
95
123
  }
96
124
  return consumers > 0;
97
125
  }
126
+ /** Whether the consuming `call` itself, or one of its arguments naming what it looks up by a fixed name, reads a formal. */
127
+ function resolvedToAFormal(call, args, formals, graph) {
128
+ const fixed = args.filter(id => isFixedName(id, graph));
129
+ return [call, ...fixed].some(id => edgeTargets(graph, id, edge_1.EdgeType.Reads).some(to => formals.has(to)));
130
+ }
131
+ function isFixedName(node, graph) {
132
+ const vertex = graph.getVertex(node);
133
+ return vertex_1.DfgVertex.isValue(vertex) || (vertex_1.DfgVertex.isUse(vertex) && vertex.constantFallback === true);
134
+ }
98
135
  /** Every edge kind that carries a value on to whoever reads it next, for {@link carriersOf}. */
99
136
  const CarryingEdges = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Returns | edge_1.EdgeType.Argument;
100
137
  /** The nodes carrying what the reflective call handed out: the call itself, the names stored under it, and reads of them. */
@@ -119,36 +156,9 @@ function carriersOf(frame, definition, graph) {
119
156
  function passesOn(vertex) {
120
157
  return vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Assignment) || vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.ExpressionList);
121
158
  }
122
- /** Whether one of the call's arguments is the value the reflective call handed out. */
123
- function consumes(vertex, carrying) {
124
- return argumentsOf(vertex).some(id => carrying.has(id));
125
- }
126
159
  /** The nodes a call was handed, whatever way the arguments were written. */
127
160
  function argumentsOf(vertex) {
128
- const ids = [];
129
- for (const argument of vertex.args) {
130
- if (typeof argument === 'object' && 'nodeId' in argument) {
131
- ids.push(argument.nodeId);
132
- if (graph_1.FunctionArgument.isNamed(argument) && argument.valueId !== undefined) {
133
- ids.push(argument.valueId);
134
- }
135
- }
136
- }
137
- return ids;
138
- }
139
- function isFixedName(node, graph) {
140
- const vtx = graph.getVertex(node);
141
- return vertex_1.DfgVertex.isValue(vtx) || (vertex_1.DfgVertex.isUse(vtx) && vtx.constantFallback === true);
142
- }
143
- function resolvedToAFormal(vertex, formals, graph) {
144
- for (const node of [vertex.id, ...argumentsOf(vertex)]) {
145
- if (node !== vertex.id && !isFixedName(node, graph)) {
146
- continue;
147
- }
148
- if (edgeTargets(graph, node, edge_1.EdgeType.Reads).some(to => formals.has(to))) {
149
- return true;
150
- }
151
- }
152
- return false;
161
+ return vertex.args.filter(graph_1.FunctionArgument.isNotEmpty)
162
+ .flatMap(a => graph_1.FunctionArgument.isNamed(a) && a.valueId !== undefined ? [a.nodeId, a.valueId] : [a.nodeId]);
153
163
  }
154
164
  //# sourceMappingURL=frame-reflection.js.map
@@ -24,13 +24,13 @@ function inferFunctions(definitions, graph, options = {}) {
24
24
  const { ctx, only } = options;
25
25
  const strict = (0, strict_function_1.strictnessOfEach)(definitions, graph, { ctx });
26
26
  return {
27
- props: only === 'arguments' ? {} : callProps(definitions, graph, strict, ctx),
27
+ props: only === 'arguments' ? {} : callProps(definitions, { graph, info: (0, query_fn_props_1.builtInLookup)(ctx) }, strict),
28
28
  roles: only === 'function' ? {} : argumentProps(definitions, graph, strict, options)
29
29
  };
30
30
  }
31
31
  /** The {@link CallProp} mask of each definition, `Strict` included and what its callees carry mixed in. */
32
- function callProps(definitions, graph, strict, ctx) {
33
- const state = makeState(graph, ctx);
32
+ function callProps(definitions, state, strict) {
33
+ const { join, filter, hasAny } = function_semantics_1.FunctionSemantics.call.props;
34
34
  const props = new Map();
35
35
  const callees = new Map();
36
36
  /* a callee is asked about as well, whether or not it is one of the definitions to answer for */
@@ -41,27 +41,15 @@ function callProps(definitions, graph, strict, ctx) {
41
41
  continue;
42
42
  }
43
43
  const own = propsOf(id, state);
44
- props.set(id, strict[id]?.strict === logic_1.Ternary.Always ? function_semantics_1.FunctionSemantics.call.props.join(own.stated, { props: built_in_props_1.CallProp.Strict }) : own.stated);
44
+ props.set(id, strict[id]?.strict === logic_1.Ternary.Always ? join(own.stated, { props: built_in_props_1.CallProp.Strict }) : own.stated);
45
45
  callees.set(id, own.callees);
46
46
  toVisit.push(...own.callees);
47
47
  }
48
- propagateOverCalls(props, callees);
49
- const all = {};
50
- for (const id of definitions) {
51
- const found = props.get(id);
52
- if (function_semantics_1.FunctionSemantics.call.props.hasAny(found)) {
53
- all[id] = found;
54
- }
55
- }
56
- return all;
57
- }
58
- /** Hands {@link PropagatedProps} on to callers until nothing changes, so a chain of calls carries them however long it is. */
59
- function propagateOverCalls(props, callees) {
60
48
  (0, frame_reflection_1.propagateToFixpoint)(callees.keys(), callees, id => {
61
49
  const before = props.get(id);
62
50
  let grown = before ?? {};
63
51
  for (const callee of callees.get(id) ?? []) {
64
- grown = function_semantics_1.FunctionSemantics.call.props.join(grown, function_semantics_1.FunctionSemantics.call.props.filter(props.get(callee), built_in_props_1.PropagatedProps));
52
+ grown = join(grown, filter(props.get(callee), built_in_props_1.PropagatedProps));
65
53
  }
66
54
  /* joining only ever adds, so nothing new means the same bits and the same number of tags */
67
55
  if ((grown.props ?? 0) === (before?.props ?? 0) && (grown.tags?.length ?? 0) === (before?.tags?.length ?? 0)) {
@@ -70,6 +58,7 @@ function propagateOverCalls(props, callees) {
70
58
  props.set(id, grown);
71
59
  return true;
72
60
  });
61
+ return Object.fromEntries(definitions.filter(id => hasAny(props.get(id))).map(id => [id, props.get(id)]));
73
62
  }
74
63
  /** The {@link ArgProp} mask of each formal, `Forced`/`Lazy` included. */
75
64
  function argumentProps(definitions, graph, strict, options) {
@@ -88,10 +77,8 @@ function argumentProps(definitions, graph, strict, options) {
88
77
  }
89
78
  return all;
90
79
  }
91
- function makeState(graph, ctx) {
92
- return { graph, info: (0, query_fn_props_1.builtInLookup)(ctx) };
93
- }
94
80
  function propsOf(id, state) {
81
+ const { join, filter } = function_semantics_1.FunctionSemantics.call.props;
95
82
  const definition = state.graph.getVertex(id);
96
83
  if (!vertex_1.DfgVertex.isFunctionDefinition(definition)) {
97
84
  return { stated: {}, callees: [] };
@@ -100,25 +87,21 @@ function propsOf(id, state) {
100
87
  const callees = [];
101
88
  for (const [node, vertex] of (0, frame_reflection_1.callsIn)(definition, state.graph)) {
102
89
  const info = state.info(vertex.name);
103
- const carried = function_semantics_1.FunctionSemantics.call.props.filter(info, built_in_props_1.PropagatedProps);
104
- stated = function_semantics_1.FunctionSemantics.call.props.join(stated, {
90
+ const carried = filter(info, built_in_props_1.PropagatedProps);
91
+ stated = join(stated, {
105
92
  props: (carried.props ?? 0) & (bindsOutside(vertex, info) ? ~0 : ~built_in_props_1.CallProp.Scope),
106
93
  tags: carried.tags
107
94
  });
108
95
  if (built_in_props_1.DispatchCallees.has(identifier_1.Identifier.getName(vertex.name))) {
109
- stated = function_semantics_1.FunctionSemantics.call.props.join(stated, { props: built_in_props_1.CallProp.Generic });
96
+ stated = join(stated, { props: built_in_props_1.CallProp.Generic });
110
97
  }
111
- callees.push(...calledDefinitions(node, state));
98
+ callees.push(...(0, frame_reflection_1.calledDefinitions)(state.graph, node));
112
99
  }
113
100
  if (returnsInvisibly(definition, state)) {
114
- stated = function_semantics_1.FunctionSemantics.call.props.join(stated, { props: built_in_props_1.CallProp.Invisible });
101
+ stated = join(stated, { props: built_in_props_1.CallProp.Invisible });
115
102
  }
116
103
  return { stated, callees };
117
104
  }
118
- /** The definitions of the program the call resolved to, which are the ones stating what the call does. */
119
- function calledDefinitions(node, state) {
120
- return (0, frame_reflection_1.edgeTargets)(state.graph, node, edge_1.EdgeType.Calls).filter(target => vertex_1.DfgVertex.isFunctionDefinition(state.graph.getVertex(target)));
121
- }
122
105
  /** the assignments binding in the frame they run in, which is a scope of the function's own */
123
106
  const FrameLocalBinders = new Set(['<-', '=', '->', ':=', 'assign']);
124
107
  /** Whether the name is a replacement function binding in its own frame (`names(x) <- v`); the `<<-` twin does not. */
@@ -131,17 +114,16 @@ function bindsOutside(vertex, info) {
131
114
  if (!FrameLocalBinders.has(name) && !isFrameLocalReplacement(name)) {
132
115
  return true;
133
116
  }
134
- const layout = info?.sig === undefined ? undefined : built_in_props_1.FnSig.layout(info.sig);
135
- return layout !== undefined && built_in_props_1.FnSig.posWith(layout, vertex.args.length, built_in_props_1.ArgProp.Written).length > 0;
117
+ return info?.sig !== undefined && built_in_props_1.FnSig.posWith(built_in_props_1.FnSig.layout(info.sig), vertex.args.length, built_in_props_1.ArgProp.Written).length > 0;
136
118
  }
137
119
  /** Whether every unconditional exit ends in a call returning invisibly; a bare value result (`function() 1`) never does. */
138
120
  function returnsInvisibly(definition, state) {
139
121
  const unconditional = definition.exitPoints.filter(e => (0, info_1.happensInEveryBranch)(e.cds)).map(e => e.nodeId);
140
- return unconditional.length > 0 && unconditional.every(node => yieldsInvisibly(node, state, 0));
122
+ return unconditional.length > 0 && unconditional.every(node => yieldsInvisibly(node, state));
141
123
  }
142
124
  /** How far the result is followed through the blocks and `return`s wrapping it. */
143
125
  const MaxDepth = 6;
144
- function yieldsInvisibly(node, state, depth) {
126
+ function yieldsInvisibly(node, state, depth = 0) {
145
127
  const vertex = state.graph.getVertex(node);
146
128
  if (vertex_1.DfgVertex.isFunctionCall(vertex) && ((state.info(vertex.name)?.props ?? 0) & built_in_props_1.CallProp.Invisible) !== 0) {
147
129
  return true;
@@ -1,6 +1,6 @@
1
1
  import { inferFunctions } from './function-props';
2
2
  import { exceptionsOfFunction } from './exceptions-of-function';
3
- import { strictnessOfEach } from './strict-function';
3
+ import { promiseDependencies, promiseForcing, settleJumpsInPromises, strictnessOfEach } from './strict-function';
4
4
  import { isHigherOrder } from './higher-order-function';
5
5
  import { argumentRolesOfFunctions } from './argument-roles';
6
6
  import { reflectiveRolesOf } from './frame-reflection';
@@ -32,6 +32,12 @@ export declare const FunctionSemantics: {
32
32
  readonly exceptions: typeof exceptionsOfFunction;
33
33
  /** The strictness of several definitions, sharing the work between them. */
34
34
  readonly strictness: typeof strictnessOfEach;
35
+ /** Settles what a jump within a promise does, once the calls are linked. */
36
+ readonly settleJumpsInPromises: typeof settleJumpsInPromises;
37
+ /** What a node within promises depends on for running at all. */
38
+ readonly promiseDependencies: typeof promiseDependencies;
39
+ /** How surely the holder of a promise forces it. */
40
+ readonly promiseForcing: typeof promiseForcing;
35
41
  /** Whether one definition is higher-order, i.e. whether it calls what it is handed. */
36
42
  readonly isHigherOrder: typeof isHigherOrder;
37
43
  /** The roles of several definitions' formals, sharing the built-in lookups. */
@@ -64,6 +70,7 @@ export declare const FunctionSemantics: {
64
70
  readonly propAt: (this: void, { props, rest }: import("../environments/built-in-props").SigLayout, index: number) => ArgProps;
65
71
  readonly posWith: (this: void, layout: import("../environments/built-in-props").SigLayout, count: number, prop: ArgProps) => number[];
66
72
  readonly forced: (this: void, sig: FnSig | undefined, count: number) => readonly boolean[] | undefined;
73
+ readonly forcing: (this: void, sig: FnSig | undefined, count: number) => readonly import("../../util/logic").Ternary[] | undefined;
67
74
  readonly every: FnSig;
68
75
  readonly only: (this: void, index: number, name: string) => FnSig;
69
76
  };
@@ -97,14 +104,15 @@ export declare const FunctionSemantics: {
97
104
  readonly quoted: {
98
105
  readonly capturedBy: (this: void, graph: import("../..").DataflowGraph, id: import("../..").NodeId) => readonly import("../..").NodeId[];
99
106
  readonly sourcesOf: (this: void, graph: import("../..").DataflowGraph, id: import("../..").NodeId) => readonly import("../internal/process/functions/call/quoted").CapturedExpression[];
107
+ readonly evaluationDependencies: (this: void, graph: import("../..").DataflowGraph, id: import("../..").NodeId) => import("../..").NodeId[];
100
108
  readonly evaluateIn: typeof import("../internal/linker").linkExpressionIn;
101
109
  readonly finalize: <Info>(this: void, graph: import("../..").DataflowGraph, environment: import("../environments/environment").REnvironmentInformation, idMap: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap<Info & import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>, controlFlow: () => import("../../control-flow/control-flow-graph").ControlFlowGraph | undefined) => void;
102
110
  };
103
111
  /** The ones it evaluates at a time flowR cannot pin down. */
104
112
  readonly deferred: {
105
113
  readonly indexOf: <Info>(this: void, graph: import("../..").DataflowGraph, idMap: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap<Info & import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>) => import("../internal/process/functions/call/deferred").NameIndex;
106
- readonly forcedAt: (this: void, graph: import("../..").DataflowGraph, binding: import("../..").NodeId, cfg: import("../../control-flow/control-flow-graph").ControlFlowGraph) => readonly import("../..").NodeId[];
107
- readonly publish: <Info>(this: void, graph: import("../..").DataflowGraph, expr: import("../..").NodeId, index: import("../internal/process/functions/call/deferred").NameIndex, idMap: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap<Info & import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>, at: import("../..").NodeId, cfg?: import("../../control-flow/control-flow-graph").ControlFlowGraph) => void;
114
+ readonly forcedAt: (this: void, graph: import("../..").DataflowGraph, binding: import("../..").NodeId, cfg: import("../../control-flow/control-flow-graph").ControlFlowGraph, viaClosures?: boolean) => readonly import("../..").NodeId[];
115
+ readonly publish: <Info>(this: void, graph: import("../..").DataflowGraph, expr: import("../..").NodeId, index: import("../internal/process/functions/call/deferred").NameIndex, idMap: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap<Info & import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>, at: import("../..").NodeId, sites: readonly import("../..").NodeId[], cfg?: import("../../control-flow/control-flow-graph").ControlFlowGraph) => void;
108
116
  readonly link: <Info>(this: void, graph: import("../..").DataflowGraph, expr: import("../..").NodeId, index: import("../internal/process/functions/call/deferred").NameIndex, idMap: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap<Info & import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>, forces?: import("../internal/process/functions/call/deferred").ForceSites) => void;
109
117
  };
110
118
  /** The calls that change the environment in ways flowR cannot follow. */
@@ -40,6 +40,12 @@ exports.FunctionSemantics = {
40
40
  exceptions: exceptions_of_function_1.exceptionsOfFunction,
41
41
  /** The strictness of several definitions, sharing the work between them. */
42
42
  strictness: strict_function_1.strictnessOfEach,
43
+ /** Settles what a jump within a promise does, once the calls are linked. */
44
+ settleJumpsInPromises: strict_function_1.settleJumpsInPromises,
45
+ /** What a node within promises depends on for running at all. */
46
+ promiseDependencies: strict_function_1.promiseDependencies,
47
+ /** How surely the holder of a promise forces it. */
48
+ promiseForcing: strict_function_1.promiseForcing,
43
49
  /** Whether one definition is higher-order, i.e. whether it calls what it is handed. */
44
50
  isHigherOrder: higher_order_function_1.isHigherOrder,
45
51
  /** The roles of several definitions' formals, sharing the built-in lookups. */
@@ -6,16 +6,24 @@
6
6
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { DataflowGraph } from '../graph/graph';
8
8
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
9
+ /** What an argument is, which no definition it is looked at for changes. */
10
+ export interface ArgumentFacts {
11
+ readonly behind: ReadonlySet<NodeId>;
12
+ /** whether it hands over a function, only worked out once something asks */
13
+ carriesFunction?: boolean;
14
+ }
9
15
  /** What to ask for beyond the definition itself, see {@link isHigherOrder}. */
10
16
  export interface HigherOrderFunctionsOptions {
11
17
  /** how to ask what a built-in states, and to resolve the value an argument carries */
12
18
  readonly ctx: ReadOnlyFlowrAnalyzerContext;
13
19
  /** the graph with edges reversed, to speed up repeat queries over the same call sites */
14
20
  readonly invertedGraph?: DataflowGraph;
21
+ /** what is known about the arguments, to share between the definitions asked about in one go; a call site reaching several of them resolves its arguments once */
22
+ readonly argumentFacts?: Map<NodeId, ArgumentFacts>;
15
23
  }
16
24
  /**
17
25
  * Whether the function is higher-order: it takes a function argument, may return one, or calls one of its own
18
26
  * formals as a function. `function(x) x` alone is not higher-order.
19
27
  * @useInstead {@link FunctionSemantics.isHigherOrder}
20
28
  */
21
- export declare function isHigherOrder(this: void, id: NodeId, graph: DataflowGraph, { ctx, invertedGraph }: HigherOrderFunctionsOptions): boolean;
29
+ export declare function isHigherOrder(this: void, id: NodeId, graph: DataflowGraph, { ctx, invertedGraph, argumentFacts }: HigherOrderFunctionsOptions): boolean;
@@ -29,19 +29,12 @@ function isAnyReturnAFunction(def, graph) {
29
29
  if (vertex_1.DfgVertex.isFunctionDefinition(current)) {
30
30
  return true;
31
31
  }
32
- const next = graph.edgesFrom(current.id);
33
- const isCall = vertex_1.DfgVertex.isFunctionCall(current);
34
- for (const [t, e] of next) {
35
- /* a call hands back what its callee returns, which its `returns` edges name, and never the callee itself */
36
- if (isCall && !edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns)) {
37
- continue;
38
- }
39
- /* a returned name is followed to what it holds, as `g <- function() 1; g` hands back that function */
40
- if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy) && !node_id_1.NodeId.isBuiltIn(t)) {
41
- const v = graph.getVertex(t);
42
- if (v) {
43
- workingQueue.push(v);
44
- }
32
+ /* a call hands back what its callee returns, never the callee; a returned name is followed to what it holds */
33
+ const follow = vertex_1.DfgVertex.isFunctionCall(current) ? edge_1.EdgeType.Returns : edge_1.EdgeType.Returns | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy;
34
+ for (const [t, e] of graph.edgesFrom(current.id)) {
35
+ const v = edge_1.DfEdge.includesType(e, follow) && !node_id_1.NodeId.isBuiltIn(t) ? graph.getVertex(t) : undefined;
36
+ if (v) {
37
+ workingQueue.push(v);
45
38
  }
46
39
  }
47
40
  }
@@ -71,26 +64,29 @@ function definitionsBehind(id, graph) {
71
64
  continue;
72
65
  }
73
66
  seen.add(current);
74
- if (vertex_1.DfgVertex.isFunctionDefinition(graph.getVertex(current))) {
67
+ const vertex = graph.getVertex(current);
68
+ if (vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
75
69
  found.add(current);
76
70
  continue;
77
71
  }
72
+ /* what a call reads beyond its arguments (state it depends on, writes it follows) is no value it hands back */
73
+ const isCall = vertex_1.DfgVertex.isFunctionCall(vertex);
78
74
  for (const [t, e] of graph.edgesFrom(current)) {
79
- if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns | edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy)) {
75
+ if (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Returns | edge_1.EdgeType.DefinedBy) || (edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads) && (!isCall || edge_1.DfEdge.includesType(e, edge_1.EdgeType.Argument)))) {
80
76
  workingQueue.push(t);
81
77
  }
82
78
  }
83
79
  }
84
80
  return found;
85
81
  }
86
- function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
82
+ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph, facts) {
87
83
  const callSites = invertedGraph?.outgoingEdges(def.id) ?? graph.ingoingEdges(def.id);
88
84
  for (const [callerId, e] of callSites ?? []) {
89
85
  if (!edge_1.DfEdge.includesType(e, edge_1.EdgeType.Calls)) {
90
86
  continue;
91
87
  }
92
88
  const caller = graph.getVertex(callerId);
93
- if (!caller || !vertex_1.DfgVertex.isFunctionCall(caller)) {
89
+ if (!vertex_1.DfgVertex.isFunctionCall(caller)) {
94
90
  continue;
95
91
  }
96
92
  for (const arg of caller.args) {
@@ -98,12 +94,19 @@ function inspectCallSitesArgumentsFns(def, graph, ctx, invertedGraph) {
98
94
  continue;
99
95
  }
100
96
  /* an apply-family call carries the callback among its arguments, which says nothing about the callback itself */
101
- const behind = definitionsBehind(arg.nodeId, graph);
102
- if (behind.size === 1 && behind.has(def.id)) {
97
+ let known = facts?.get(arg.nodeId);
98
+ if (known === undefined) {
99
+ known = { behind: definitionsBehind(arg.nodeId, graph) };
100
+ facts?.set(arg.nodeId, known);
101
+ }
102
+ if (known.behind.size === 1 && known.behind.has(def.id)) {
103
103
  continue;
104
104
  }
105
- const value = node_value_1.NodeValue.setOf(arg.nodeId, resolve_helper_1.Resolve.info(graph, ctx), { resolve: config_1.VariableResolve.Alias });
106
- if (value?.elements.some(e => e.type === 'function-definition') || readsBuiltInFunction(arg.nodeId, graph, ctx)) {
105
+ if (known.carriesFunction === undefined) {
106
+ const value = node_value_1.NodeValue.setOf(arg.nodeId, resolve_helper_1.Resolve.info(graph, ctx), { resolve: config_1.VariableResolve.Alias });
107
+ known.carriesFunction = value?.elements.some(e => e.type === 'function-definition') || readsBuiltInFunction(arg.nodeId, graph, ctx);
108
+ }
109
+ if (known.carriesFunction) {
107
110
  return true;
108
111
  }
109
112
  }
@@ -120,11 +123,11 @@ function callsAFormal(id, graph, ctx) {
120
123
  * formals as a function. `function(x) x` alone is not higher-order.
121
124
  * @useInstead {@link FunctionSemantics.isHigherOrder}
122
125
  */
123
- function isHigherOrder(id, graph, { ctx, invertedGraph }) {
126
+ function isHigherOrder(id, graph, { ctx, invertedGraph, argumentFacts }) {
124
127
  const vert = graph.getVertex(id);
125
- if (!vert || !vertex_1.DfgVertex.isFunctionDefinition(vert)) {
128
+ if (!vertex_1.DfgVertex.isFunctionDefinition(vert)) {
126
129
  return false;
127
130
  }
128
- return isAnyReturnAFunction(vert, graph) || callsAFormal(id, graph, ctx) || inspectCallSitesArgumentsFns(vert, graph, ctx, invertedGraph);
131
+ return isAnyReturnAFunction(vert, graph) || callsAFormal(id, graph, ctx) || inspectCallSitesArgumentsFns(vert, graph, ctx, invertedGraph, argumentFacts);
129
132
  }
130
133
  //# sourceMappingURL=higher-order-function.js.map
@@ -4,6 +4,7 @@
4
4
  * @lintIgnore use-instead
5
5
  */
6
6
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ import type { ExitPoint } from '../info';
7
8
  import type { DataflowGraph } from '../graph/graph';
8
9
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
9
10
  import { Ternary } from '../../util/logic';
@@ -48,3 +49,15 @@ export interface FunctionStrictnessesOptions {
48
49
  /** how to ask what a built-in states, so a configured or overwritten one answers */
49
50
  readonly ctx?: ReadOnlyFlowrAnalyzerContext;
50
51
  }
52
+ /**
53
+ * What a node within promises depends on to run: the holder of each `byPromise` dependency and where that promise may be forced.
54
+ * @example
55
+ * ```r
56
+ * g(print(1)) # the print runs only when `g` forces its argument, so it depends on `g(...)` and on the reads of `g`'s parameter
57
+ * ```
58
+ */
59
+ export declare function promiseDependencies(this: void, id: NodeId, graph: DataflowGraph): NodeId[];
60
+ /** How surely the holder of a promise forces it, asked for a node `inner` within the promise. */
61
+ export declare function promiseForcing(this: void, graph: DataflowGraph, { ctx }?: FunctionStrictnessesOptions): (holder: NodeId, inner: NodeId) => Ternary;
62
+ /** Drops the resume of a jump within a promise ({@link ControlFlow.promise}) once the linked holder surely forces it. */
63
+ export declare function settleJumpsInPromises(this: void, graph: DataflowGraph, topLevel: readonly ExitPoint[], { ctx }?: FunctionStrictnessesOptions): void;