@eagleoutice/flowr 2.17.4 → 2.17.5

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 (544) hide show
  1. package/README.md +13 -52
  2. package/abstract-interpretation/absint-inference.js +1 -2
  3. package/abstract-interpretation/data-frame/arguments.d.ts +14 -3
  4. package/abstract-interpretation/data-frame/arguments.js +34 -0
  5. package/abstract-interpretation/data-frame/dataframe-semantics.js +7 -15
  6. package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -2
  7. package/abstract-interpretation/data-frame/semantics.d.ts +8 -1
  8. package/abstract-interpretation/data-frame/semantics.js +14 -6
  9. package/abstract-interpretation/domains/state-abstract-domain.js +28 -18
  10. package/abstract-interpretation/domains/state-map.d.ts +43 -0
  11. package/abstract-interpretation/domains/state-map.js +147 -0
  12. package/benchmark/slicer.d.ts +1 -1
  13. package/benchmark/slicer.js +8 -7
  14. package/cli/repl/commands/repl-dataflow.js +5 -5
  15. package/cli/repl/commands/repl-execute.js +3 -2
  16. package/cli/repl/commands/repl-parse.js +2 -1
  17. package/cli/repl/print-version.d.ts +1 -1
  18. package/cli/repl/print-version.js +2 -1
  19. package/cli/repl/server/connection.d.ts +1 -1
  20. package/cli/repl/server/connection.js +7 -9
  21. package/cli/slicer-app.js +2 -1
  22. package/clones/algorithms/baxter-ast.d.ts +33 -0
  23. package/clones/algorithms/baxter-ast.js +70 -0
  24. package/clones/algorithms/greedy-string-tiling.d.ts +17 -0
  25. package/clones/algorithms/greedy-string-tiling.js +56 -0
  26. package/clones/algorithms/winnowing.d.ts +27 -0
  27. package/clones/algorithms/winnowing.js +66 -0
  28. package/clones/clone-ast.d.ts +75 -0
  29. package/clones/clone-ast.js +174 -0
  30. package/clones/clone-dataflow.d.ts +11 -0
  31. package/clones/clone-dataflow.js +83 -0
  32. package/clones/clone-detector.d.ts +116 -0
  33. package/clones/clone-detector.js +200 -0
  34. package/clones/clone-index.d.ts +54 -0
  35. package/clones/clone-index.js +56 -0
  36. package/config.d.ts +21 -2
  37. package/config.js +7 -1
  38. package/control-flow/basic-cfg-guided-visitor.js +1 -2
  39. package/control-flow/happens-before.d.ts +2 -0
  40. package/control-flow/happens-before.js +15 -9
  41. package/control-flow/simple-visitor.js +2 -4
  42. package/core/steps/all/core/00-parse.js +2 -1
  43. package/core/steps/all/core/01-parse-tree-sitter.js +2 -1
  44. package/core/steps/all/core/10-normalize.js +2 -1
  45. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -1
  46. package/core/steps/all/static-slicing/00-slice.js +2 -1
  47. package/core/steps/all/static-slicing/10-reconstruct.js +2 -1
  48. package/core/steps/pipeline/create-pipeline.js +1 -2
  49. package/core/steps/pipeline/default-pipelines.d.ts +1 -1
  50. package/core/steps/pipeline/default-pipelines.js +5 -4
  51. package/core/steps/pipeline-step.d.ts +3 -1
  52. package/core/steps/pipeline-step.js +5 -0
  53. package/data/r-base-primitives.generated.d.ts +2 -1
  54. package/dataflow/cluster.js +1 -2
  55. package/dataflow/environments/ambient-state-name.d.ts +14 -22
  56. package/dataflow/environments/ambient-state-name.js +4 -18
  57. package/dataflow/environments/apply-kill.d.ts +9 -20
  58. package/dataflow/environments/apply-kill.js +51 -25
  59. package/dataflow/environments/built-in-config.d.ts +7 -15
  60. package/dataflow/environments/built-in-config.js +15 -16
  61. package/dataflow/environments/built-in-eval-name.d.ts +5 -6
  62. package/dataflow/environments/built-in-eval-name.js +4 -5
  63. package/dataflow/environments/built-in-kinds.d.ts +111 -0
  64. package/dataflow/environments/built-in-kinds.js +35 -0
  65. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  66. package/dataflow/environments/built-in-proc-name.js +11 -0
  67. package/dataflow/environments/built-in-props.d.ts +62 -175
  68. package/dataflow/environments/built-in-props.js +42 -154
  69. package/dataflow/environments/built-in.d.ts +37 -73
  70. package/dataflow/environments/built-in.js +41 -62
  71. package/dataflow/environments/data-masking-functions.d.ts +2 -2
  72. package/dataflow/environments/default-builtin-config/base-functions.d.ts +7 -0
  73. package/dataflow/environments/default-builtin-config/base-functions.js +339 -0
  74. package/dataflow/environments/default-builtin-config/base-language.d.ts +3 -0
  75. package/dataflow/environments/default-builtin-config/base-language.js +66 -0
  76. package/dataflow/environments/default-builtin-config/base-operators.d.ts +58 -0
  77. package/dataflow/environments/default-builtin-config/base-operators.js +169 -0
  78. package/dataflow/environments/default-builtin-config/database-access.d.ts +3 -0
  79. package/dataflow/environments/default-builtin-config/database-access.js +16 -0
  80. package/dataflow/environments/default-builtin-config/define-helpers.d.ts +45 -0
  81. package/dataflow/environments/default-builtin-config/define-helpers.js +50 -0
  82. package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +3 -0
  83. package/dataflow/environments/default-builtin-config/dev-tooling.js +63 -0
  84. package/dataflow/environments/default-builtin-config/file-io.d.ts +3 -0
  85. package/dataflow/environments/default-builtin-config/file-io.js +81 -0
  86. package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +3 -0
  87. package/dataflow/environments/default-builtin-config/graphics-devices.js +57 -0
  88. package/dataflow/environments/default-builtin-config/index.d.ts +18 -0
  89. package/dataflow/environments/default-builtin-config/index.js +114 -0
  90. package/dataflow/environments/default-builtin-config/media-formats.d.ts +3 -0
  91. package/dataflow/environments/default-builtin-config/media-formats.js +41 -0
  92. package/dataflow/environments/default-builtin-config/misc-packages.d.ts +3 -0
  93. package/dataflow/environments/default-builtin-config/misc-packages.js +18 -0
  94. package/dataflow/environments/default-builtin-config/network-access.d.ts +3 -0
  95. package/dataflow/environments/default-builtin-config/network-access.js +47 -0
  96. package/dataflow/environments/default-builtin-config/object-systems.d.ts +3 -0
  97. package/dataflow/environments/default-builtin-config/object-systems.js +39 -0
  98. package/dataflow/environments/default-builtin-config/package-data-table.d.ts +3 -0
  99. package/dataflow/environments/default-builtin-config/package-data-table.js +18 -0
  100. package/dataflow/environments/default-builtin-config/package-spatial.d.ts +3 -0
  101. package/dataflow/environments/default-builtin-config/package-spatial.js +32 -0
  102. package/dataflow/environments/default-builtin-config/package-tidyverse.d.ts +3 -0
  103. package/dataflow/environments/default-builtin-config/package-tidyverse.js +96 -0
  104. package/dataflow/environments/default-builtin-config/package-utils.d.ts +3 -0
  105. package/dataflow/environments/default-builtin-config/package-utils.js +35 -0
  106. package/dataflow/environments/default-builtin-config/package-withr.d.ts +3 -0
  107. package/dataflow/environments/default-builtin-config/package-withr.js +41 -0
  108. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +3 -0
  109. package/dataflow/environments/default-builtin-config/parallel-execution.js +31 -0
  110. package/dataflow/environments/default-builtin-config/session-interactive.d.ts +3 -0
  111. package/dataflow/environments/default-builtin-config/session-interactive.js +31 -0
  112. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +267 -0
  113. package/dataflow/environments/default-builtin-config/shared-configs.js +483 -0
  114. package/dataflow/environments/default-builtin-config/shared-signatures.d.ts +21 -0
  115. package/dataflow/environments/default-builtin-config/shared-signatures.js +32 -0
  116. package/dataflow/environments/default-builtin-config/statistics.d.ts +3 -0
  117. package/dataflow/environments/default-builtin-config/statistics.js +32 -0
  118. package/dataflow/environments/default-builtin-config/unit-testing.d.ts +3 -0
  119. package/dataflow/environments/default-builtin-config/unit-testing.js +13 -0
  120. package/dataflow/environments/environment.d.ts +28 -52
  121. package/dataflow/environments/environment.js +24 -71
  122. package/dataflow/environments/group-generics.d.ts +12 -19
  123. package/dataflow/environments/group-generics.js +17 -14
  124. package/dataflow/environments/identifier.d.ts +72 -427
  125. package/dataflow/environments/identifier.js +34 -145
  126. package/dataflow/environments/pkg-name.d.ts +197 -0
  127. package/dataflow/environments/pkg-name.js +3 -0
  128. package/dataflow/environments/query-fn-props.d.ts +27 -76
  129. package/dataflow/environments/query-fn-props.js +34 -95
  130. package/dataflow/environments/resolve-by-name.d.ts +6 -16
  131. package/dataflow/environments/resolve-by-name.js +23 -35
  132. package/dataflow/environments/scoping.d.ts +5 -5
  133. package/dataflow/environments/scoping.js +13 -5
  134. package/dataflow/eval/resolve/alias-tracking.d.ts +31 -68
  135. package/dataflow/eval/resolve/alias-tracking.js +611 -126
  136. package/dataflow/eval/resolve/match-arguments.d.ts +5 -3
  137. package/dataflow/eval/resolve/resolve-argument.d.ts +11 -11
  138. package/dataflow/eval/resolve/resolve-argument.js +25 -30
  139. package/dataflow/eval/resolve/resolve-field.d.ts +10 -0
  140. package/dataflow/eval/resolve/resolve-field.js +127 -0
  141. package/dataflow/eval/resolve/resolve-replacement.d.ts +10 -0
  142. package/dataflow/eval/resolve/resolve-replacement.js +80 -0
  143. package/dataflow/eval/resolve/resolve-strings.d.ts +2 -2
  144. package/dataflow/eval/resolve/resolve.d.ts +13 -10
  145. package/dataflow/eval/resolve/resolve.js +81 -32
  146. package/dataflow/eval/values/general.d.ts +6 -24
  147. package/dataflow/eval/values/general.js +12 -29
  148. package/dataflow/eval/values/lists/list-constants.d.ts +11 -0
  149. package/dataflow/eval/values/lists/list-constants.js +65 -0
  150. package/dataflow/eval/values/r-value.d.ts +20 -23
  151. package/dataflow/eval/values/r-value.js +22 -17
  152. package/dataflow/extractor.d.ts +2 -10
  153. package/dataflow/extractor.js +100 -46
  154. package/dataflow/fn/argument-roles.d.ts +2 -4
  155. package/dataflow/fn/argument-roles.js +49 -23
  156. package/dataflow/fn/class-declaration.d.ts +36 -52
  157. package/dataflow/fn/class-declaration.js +22 -56
  158. package/dataflow/fn/condition-handlers.d.ts +2 -1
  159. package/dataflow/fn/dispatch.d.ts +70 -0
  160. package/dataflow/fn/dispatch.js +434 -0
  161. package/dataflow/fn/exceptions-of-function.d.ts +1 -2
  162. package/dataflow/fn/exceptions-of-function.js +36 -106
  163. package/dataflow/fn/frame-reflection.d.ts +1 -3
  164. package/dataflow/fn/frame-reflection.js +8 -16
  165. package/dataflow/fn/function-props.d.ts +2 -5
  166. package/dataflow/fn/function-props.js +27 -36
  167. package/dataflow/fn/function-semantics.d.ts +14 -26
  168. package/dataflow/fn/function-semantics.js +4 -18
  169. package/dataflow/fn/higher-order-function.js +2 -4
  170. package/dataflow/fn/strict-function.d.ts +10 -35
  171. package/dataflow/fn/strict-function.js +126 -138
  172. package/dataflow/graph/ambient-access.d.ts +51 -0
  173. package/dataflow/graph/ambient-access.js +80 -0
  174. package/dataflow/graph/call-graph.d.ts +9 -29
  175. package/dataflow/graph/call-graph.js +17 -41
  176. package/dataflow/graph/closure-frames.d.ts +46 -0
  177. package/dataflow/graph/closure-frames.js +225 -0
  178. package/dataflow/graph/dataflowgraph-builder.d.ts +25 -96
  179. package/dataflow/graph/dataflowgraph-builder.js +29 -97
  180. package/dataflow/graph/df-helper.d.ts +48 -188
  181. package/dataflow/graph/df-helper.js +107 -208
  182. package/dataflow/graph/diff-dataflow-graph.d.ts +5 -15
  183. package/dataflow/graph/diff-dataflow-graph.js +25 -25
  184. package/dataflow/graph/edge.js +1 -1
  185. package/dataflow/graph/graph-helper.d.ts +10 -46
  186. package/dataflow/graph/graph-helper.js +16 -50
  187. package/dataflow/graph/graph.d.ts +44 -97
  188. package/dataflow/graph/graph.js +83 -79
  189. package/dataflow/graph/match-args.d.ts +21 -88
  190. package/dataflow/graph/match-args.js +284 -97
  191. package/dataflow/graph/vertex.d.ts +101 -128
  192. package/dataflow/graph/vertex.js +23 -20
  193. package/dataflow/hooks.d.ts +7 -14
  194. package/dataflow/hooks.js +15 -13
  195. package/dataflow/info.d.ts +2 -17
  196. package/dataflow/internal/dispatch-linking.d.ts +71 -0
  197. package/dataflow/internal/dispatch-linking.js +332 -0
  198. package/dataflow/internal/linker.d.ts +48 -50
  199. package/dataflow/internal/linker.js +457 -155
  200. package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
  201. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -14
  202. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -46
  203. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +7 -6
  204. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +10 -9
  205. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +23 -75
  206. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +263 -97
  207. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +10 -7
  208. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +66 -45
  209. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +15 -19
  210. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +82 -62
  211. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -4
  212. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -2
  213. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +2 -2
  214. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +3 -2
  215. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +15 -0
  216. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +416 -0
  217. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +37 -54
  218. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +192 -111
  219. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +4 -3
  220. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +60 -13
  221. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -3
  222. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +80 -76
  223. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.d.ts +1 -7
  224. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -13
  225. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +4 -8
  226. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +436 -140
  227. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +18 -10
  228. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +90 -12
  229. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -5
  230. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -14
  231. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +9 -8
  232. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -7
  233. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -2
  234. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +3 -5
  235. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -6
  236. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +9 -24
  237. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +10 -6
  238. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +5 -6
  239. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -4
  240. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -4
  241. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +8 -11
  242. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -5
  243. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +20 -28
  244. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +17 -4
  245. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +117 -4
  246. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +5 -3
  247. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  248. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +8 -4
  249. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +18 -29
  250. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -25
  251. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +31 -35
  252. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +4 -18
  253. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +13 -19
  254. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +18 -16
  255. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +130 -65
  256. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -1
  257. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +38 -30
  258. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +584 -114
  259. package/dataflow/internal/process/functions/call/common.d.ts +8 -24
  260. package/dataflow/internal/process/functions/call/common.js +24 -24
  261. package/dataflow/internal/process/functions/call/deferred.d.ts +7 -27
  262. package/dataflow/internal/process/functions/call/deferred.js +6 -27
  263. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -26
  264. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -16
  265. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -4
  266. package/dataflow/internal/process/functions/call/named-call-handling.js +14 -35
  267. package/dataflow/internal/process/functions/call/nse.d.ts +2 -9
  268. package/dataflow/internal/process/functions/call/nse.js +6 -13
  269. package/dataflow/internal/process/functions/call/quoted.d.ts +4 -15
  270. package/dataflow/internal/process/functions/call/quoted.js +26 -62
  271. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +3 -6
  272. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +29 -11
  273. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  274. package/dataflow/internal/program-order.d.ts +3 -10
  275. package/dataflow/internal/program-order.js +19 -10
  276. package/dataflow/origin/dfg-get-origin.js +2 -1
  277. package/documentation/data/faq/faqs.js +16 -1
  278. package/documentation/data/interface/doc-writing-code.js +5 -7
  279. package/documentation/doc-capabilities.js +3 -3
  280. package/documentation/doc-readme.js +1 -1
  281. package/documentation/doc-util/doc-code.d.ts +0 -5
  282. package/documentation/doc-util/doc-code.js +2 -22
  283. package/documentation/doc-util/doc-query.d.ts +1 -2
  284. package/documentation/doc-util/doc-query.js +4 -5
  285. package/documentation/doc-util/doc-search.js +1 -1
  286. package/documentation/wiki-analyzer.js +4 -3
  287. package/documentation/wiki-core.js +5 -5
  288. package/documentation/wiki-dataflow-graph.js +6 -0
  289. package/documentation/wiki-interface.js +2 -1
  290. package/documentation/wiki-linter.js +15 -3
  291. package/documentation/wiki-linting-and-testing.js +15 -2
  292. package/documentation/wiki-query.js +111 -29
  293. package/index.d.ts +3 -1
  294. package/index.js +6 -3
  295. package/linter/linter-executor.js +1 -1
  296. package/linter/linter-rules.d.ts +37 -8
  297. package/linter/linter-rules.js +8 -1
  298. package/linter/linter-util.d.ts +3 -3
  299. package/linter/linter-util.js +1 -1
  300. package/linter/rules/cmd-check/bogus-return.d.ts +2 -1
  301. package/linter/rules/cmd-check/call-arguments.d.ts +3 -2
  302. package/linter/rules/cmd-check/call-arguments.js +5 -5
  303. package/linter/rules/cmd-check/cmd-check-util.d.ts +9 -8
  304. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -1
  305. package/linter/rules/cmd-check/dependency-declaration.js +1 -1
  306. package/linter/rules/cmd-check/documentation-mismatch.d.ts +3 -2
  307. package/linter/rules/cmd-check/documentation-mismatch.js +2 -1
  308. package/linter/rules/cmd-check/file-checks.d.ts +2 -2
  309. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -1
  310. package/linter/rules/cmd-check/global-environment-modification.d.ts +6 -5
  311. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -1
  312. package/linter/rules/cmd-check/non-ascii-code.js +1 -1
  313. package/linter/rules/cmd-check/package-files.d.ts +2 -2
  314. package/linter/rules/cmd-check/package-hooks.d.ts +5 -4
  315. package/linter/rules/cmd-check/package-runtime.js +2 -2
  316. package/linter/rules/cmd-check/rd-files.js +2 -1
  317. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +3 -2
  318. package/linter/rules/cmd-check/s-three-method-consistency.js +2 -1
  319. package/linter/rules/code-clones.d.ts +57 -0
  320. package/linter/rules/code-clones.js +53 -0
  321. package/linter/rules/deprecated-functions.js +3 -6
  322. package/linter/rules/file-path-validity.js +6 -4
  323. package/linter/rules/function-finder-util.d.ts +4 -2
  324. package/linter/rules/naming-convention.d.ts +6 -5
  325. package/linter/rules/naming-convention.js +2 -3
  326. package/linter/rules/no-leaked-credentials.d.ts +2 -1
  327. package/linter/rules/no-leaked-credentials.js +1 -1
  328. package/linter/rules/overwritten-file.d.ts +2 -1
  329. package/linter/rules/problematic-inputs.d.ts +2 -1
  330. package/linter/rules/problematic-inputs.js +3 -3
  331. package/linter/rules/process-state-in-session.d.ts +7 -6
  332. package/linter/rules/process-state-in-session.js +1 -1
  333. package/linter/rules/roxygen-arguments.d.ts +1 -1
  334. package/linter/rules/secret-exfiltration.js +1 -1
  335. package/linter/rules/seeded-randomness.d.ts +3 -3
  336. package/linter/rules/unclosed-connection.js +1 -2
  337. package/linter/rules/undefined-symbol-util.d.ts +3 -2
  338. package/linter/rules/undefined-symbol.d.ts +3 -2
  339. package/linter/rules/unescaped-arguments.d.ts +1 -1
  340. package/linter/rules/unescaped-arguments.js +6 -8
  341. package/linter/rules/unused-definition.d.ts +4 -3
  342. package/linter/rules/unused-definition.js +10 -12
  343. package/linter/rules/unused-import.d.ts +6 -5
  344. package/package.json +1 -1
  345. package/project/attached-packages.d.ts +5 -4
  346. package/project/cache/flowr-analyzer-cache.d.ts +14 -1
  347. package/project/cache/flowr-analyzer-cache.js +40 -3
  348. package/project/context/flowr-analyzer-dependencies-context.d.ts +12 -12
  349. package/project/context/flowr-analyzer-environment-context.d.ts +3 -3
  350. package/project/context/flowr-analyzer-environment-context.js +3 -3
  351. package/project/context/flowr-analyzer-functions-context.d.ts +9 -7
  352. package/project/context/flowr-analyzer-gas-context.d.ts +25 -0
  353. package/project/context/flowr-analyzer-gas-context.js +34 -4
  354. package/project/dependency-version-space.d.ts +30 -29
  355. package/project/dependency-version-space.js +1 -2
  356. package/project/flowr-analyzer-builder.d.ts +2 -3
  357. package/project/flowr-analyzer.d.ts +35 -3
  358. package/project/flowr-analyzer.js +11 -5
  359. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +15 -14
  360. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +5 -4
  361. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +1 -1
  362. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -1
  363. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -3
  364. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +2 -1
  365. package/project/plugins/package-version-plugins/package.d.ts +6 -5
  366. package/project/sigdb/build.js +1 -1
  367. package/project/sigdb/decode.d.ts +8 -7
  368. package/project/sigdb/decode.js +1 -2
  369. package/project/sigdb/dict.d.ts +2 -1
  370. package/project/sigdb/dict.js +2 -2
  371. package/project/sigdb/index-format.d.ts +2 -1
  372. package/project/sigdb/manifest.d.ts +1 -1
  373. package/project/sigdb/memory-source.d.ts +18 -17
  374. package/project/sigdb/on-demand/package-sources.d.ts +4 -3
  375. package/project/sigdb/on-demand/recoverer.d.ts +2 -1
  376. package/project/sigdb/on-demand/remote-sources.d.ts +2 -1
  377. package/project/sigdb/reader.d.ts +85 -80
  378. package/project/sigdb/reader.js +0 -4
  379. package/project/sigdb/schema.d.ts +9 -8
  380. package/project/sigdb/signature-db.d.ts +6 -6
  381. package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +6 -0
  382. package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +50 -0
  383. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +54 -0
  384. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +45 -0
  385. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +2 -1
  386. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  387. package/queries/catalog/call-graph-query/expand-library-internals.d.ts +3 -2
  388. package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +6 -0
  389. package/queries/catalog/code-clones-query/code-clones-query-executor.js +38 -0
  390. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +54 -0
  391. package/queries/catalog/code-clones-query/code-clones-query-format.js +73 -0
  392. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +3 -3
  393. package/queries/catalog/dependencies-query/data-flow.d.ts +5 -4
  394. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +5 -2
  395. package/queries/catalog/dependencies-query/dependencies-query-executor.js +5 -5
  396. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -2
  397. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  398. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -4
  399. package/queries/catalog/dependencies-query/implicit-echo.js +2 -1
  400. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -0
  401. package/queries/catalog/dice-query/dice-query-format.js +1 -0
  402. package/queries/catalog/does-call-query/does-call-query-executor.js +1 -2
  403. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -0
  404. package/queries/catalog/does-call-query/does-call-query-format.js +1 -0
  405. package/queries/catalog/function-info-query/function-info-query-format.d.ts +2 -1
  406. package/queries/catalog/function-info-query/function-origin.d.ts +3 -2
  407. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -3
  408. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +5 -4
  409. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
  410. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
  411. package/queries/catalog/input-sources-query/input-sources-query-executor.js +7 -3
  412. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +9 -9
  413. package/queries/catalog/input-sources-query/simple-input-classifier.js +1 -1
  414. package/queries/catalog/linter-query/linter-query-executor.js +4 -1
  415. package/queries/catalog/linter-query/linter-query-format.js +3 -2
  416. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -0
  417. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  418. package/queries/catalog/project-query/project-query-format.d.ts +2 -1
  419. package/queries/catalog/provenance-query/provenance-query-format.d.ts +1 -0
  420. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  421. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -0
  422. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  423. package/queries/catalog/signature-query/signature-query-executor.d.ts +9 -6
  424. package/queries/catalog/signature-query/signature-query-executor.js +14 -15
  425. package/queries/catalog/signature-query/signature-query-format.d.ts +21 -20
  426. package/queries/catalog/signature-query/signature-query-render.js +1 -1
  427. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  428. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +9 -5
  429. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  430. package/queries/query-function-filter.d.ts +1 -1
  431. package/queries/query.d.ts +59 -8
  432. package/queries/query.js +59 -37
  433. package/r-bridge/data/data.d.ts +39 -28
  434. package/r-bridge/data/data.js +37 -28
  435. package/r-bridge/lang-4.x/ast/model/model.d.ts +10 -1
  436. package/r-bridge/lang-4.x/ast/model/model.js +30 -0
  437. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +21 -0
  438. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +25 -2
  439. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
  440. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -2
  441. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +2 -2
  442. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  443. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  444. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  445. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  446. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -3
  447. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  448. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  449. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  450. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  451. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  452. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  453. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  454. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  455. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  456. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +5 -6
  457. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +2 -7
  458. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  459. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -2
  460. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +2 -2
  461. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  462. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -5
  463. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +7 -2
  464. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +14 -6
  465. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +1 -1
  466. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +2 -2
  467. package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -1
  468. package/r-bridge/lang-4.x/ast/model/type.js +1 -1
  469. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -2
  470. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -2
  471. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  472. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +3 -2
  473. package/r-bridge/parser.d.ts +8 -2
  474. package/r-bridge/parser.js +6 -0
  475. package/r-bridge/shell-executor.d.ts +2 -2
  476. package/r-bridge/shell-executor.js +3 -2
  477. package/r-bridge/shell.d.ts +2 -2
  478. package/r-bridge/shell.js +3 -2
  479. package/reconstruct/auto-select/magic-comments.js +1 -1
  480. package/reconstruct/reconstruct.d.ts +0 -5
  481. package/reconstruct/reconstruct.js +6 -5
  482. package/search/flowr-search-builder.d.ts +14 -0
  483. package/search/flowr-search-builder.js +7 -0
  484. package/search/flowr-search-executor.js +2 -2
  485. package/search/flowr-search-filters.js +8 -9
  486. package/search/flowr-search.js +1 -1
  487. package/search/search-executor/search-enrichers.d.ts +2 -0
  488. package/search/search-executor/search-enrichers.js +6 -1
  489. package/search/search-executor/search-generators.d.ts +2 -2
  490. package/search/search-executor/search-generators.js +13 -8
  491. package/search/search-executor/search-mappers.js +1 -1
  492. package/search/search-executor/search-transformer.d.ts +2 -2
  493. package/search/search-executor/search-transformer.js +6 -6
  494. package/slicing/criterion/parse.d.ts +2 -1
  495. package/slicing/criterion/parse.js +2 -1
  496. package/slicing/static/removal-slice.js +2 -1
  497. package/slicing/static/slice-call.d.ts +30 -4
  498. package/slicing/static/slice-call.js +74 -9
  499. package/slicing/static/slicer-types.d.ts +2 -1
  500. package/slicing/static/static-slicer.js +66 -11
  501. package/slicing/static/visiting-queue.d.ts +2 -0
  502. package/slicing/static/visiting-queue.js +4 -0
  503. package/taint-analysis/builder/report-template.d.ts +3 -3
  504. package/util/arg-matching.d.ts +1 -1
  505. package/util/collections/relation.d.ts +23 -0
  506. package/util/collections/relation.js +63 -0
  507. package/util/fixpoint.d.ts +65 -0
  508. package/util/fixpoint.js +216 -0
  509. package/util/flowr-version.d.ts +1 -1
  510. package/util/flowr-version.js +2 -2
  511. package/util/json.d.ts +4 -0
  512. package/util/json.js +12 -3
  513. package/util/mermaid/cfg.js +1 -2
  514. package/util/mermaid/dfg.d.ts +1 -1
  515. package/util/mermaid/dfg.js +1 -1
  516. package/util/mermaid/mermaid.d.ts +2 -1
  517. package/util/monoid.d.ts +26 -0
  518. package/util/monoid.js +31 -0
  519. package/util/prefix.d.ts +1 -1
  520. package/util/r-base-packages.d.ts +10 -7
  521. package/util/r-base-packages.js +11 -6
  522. package/util/r-package-urls.d.ts +10 -9
  523. package/util/r-value.js +2 -1
  524. package/util/r-version-order.d.ts +2 -0
  525. package/util/r-version-order.js +19 -0
  526. package/util/r-version.d.ts +2 -1
  527. package/util/r-version.js +2 -14
  528. package/util/range.d.ts +38 -29
  529. package/util/range.js +10 -5
  530. package/util/simple-df/dfg-ascii.js +2 -2
  531. package/util/text/ansi.d.ts +13 -9
  532. package/util/text/ansi.js +4 -6
  533. package/util/text/strings.d.ts +10 -3
  534. package/util/text/strings.js +10 -1
  535. package/util/version.d.ts +1 -1
  536. package/util/version.js +2 -1
  537. package/dataflow/environments/default-builtin-config.d.ts +0 -8874
  538. package/dataflow/environments/default-builtin-config.js +0 -1737
  539. package/r-bridge/lang-4.x/ast/model/operators.d.ts +0 -33
  540. package/r-bridge/lang-4.x/ast/model/operators.js +0 -54
  541. package/taint-analysis/eval/eval.d.ts +0 -1
  542. package/taint-analysis/eval/eval.js +0 -124
  543. package/taint-analysis/eval/instrumentation.d.ts +0 -59
  544. package/taint-analysis/eval/instrumentation.js +0 -124
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.strictnessOfEach = strictnessOfEach;
4
4
  exports.promiseDependencies = promiseDependencies;
5
5
  exports.promiseForcing = promiseForcing;
6
+ exports.settleDefinitionsInPromises = settleDefinitionsInPromises;
6
7
  exports.settleJumpsInPromises = settleJumpsInPromises;
7
8
  /**
8
- * The `FunctionSemantics` facade wires these together, so a sibling here has to call the backing function
9
- * directly; going through `FunctionSemantics` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
9
+ * The `FunctionSemantics` facade wires these together, so a sibling here has to call the backing function directly; going through `FunctionSemantics` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
10
10
  * @lintIgnore use-instead
11
11
  */
12
12
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
@@ -18,6 +18,7 @@ const node_value_1 = require("../eval/resolve/node-value");
18
18
  const resolve_helper_1 = require("../environments/resolve-helper");
19
19
  const call_graph_1 = require("../graph/call-graph");
20
20
  const vertex_1 = require("../graph/vertex");
21
+ const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
21
22
  const built_in_proc_name_1 = require("../environments/built-in-proc-name");
22
23
  const built_in_props_1 = require("../environments/built-in-props");
23
24
  const frame_reflection_1 = require("./frame-reflection");
@@ -30,29 +31,19 @@ const r_parameter_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-paramet
30
31
  const assert_1 = require("../../util/assert");
31
32
  const defaultmap_1 = require("../../util/collections/defaultmap");
32
33
  const df_helper_1 = require("../graph/df-helper");
33
- /**
34
- * What an argument is used for when the call never evaluates it: quoted or read in another frame
35
- * ({@link ArgProp.Nse}), or looked at only for having been supplied ({@link ArgProp.Presence}).
36
- */
34
+ const fixpoint_1 = require("../../util/fixpoint");
35
+ const program_order_1 = require("../internal/program-order");
36
+ /** What an argument is used for when the call never evaluates it: quoted or read in another frame ({@link ArgProp.Nse}), or looked at only for having been supplied ({@link ArgProp.Presence}). */
37
37
  const NotEvaluated = built_in_props_1.ArgProp.Nse | built_in_props_1.ArgProp.Presence;
38
38
  /** What reflection has to reach for a parameter to be evaluated by it (`as.list(environment())`, not `match.call()`/`nargs()`). */
39
39
  const MayEvaluate = built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced;
40
- /**
41
- * The processors whose calls reach their first argument and the rest only on the way the run happens to
42
- * take: `switch` picks one of its branches, and `try`/`tryCatch` reach a handler only when one is needed.
43
- */
40
+ /** The processors whose calls reach their first argument and the rest only on the way the run happens to take: `switch` picks one of its branches, and `try`/`tryCatch` reach a handler only when one is needed. */
44
41
  const LazyAfterFirst = [built_in_proc_name_1.BuiltInProcName.Switch, built_in_proc_name_1.BuiltInProcName.Try];
45
- /**
46
- * The processors putting off what they are given until a moment that may never come: a hook runs when the
47
- * function exits, and `Recall` starts the same function over rather than reading anything itself.
48
- */
42
+ /** The processors putting off what they are given until a moment that may never come: a hook runs when the function exits, and `Recall` starts the same function over rather than reading anything itself. */
49
43
  const LazyThroughout = [built_in_proc_name_1.BuiltInProcName.RegisterHook, built_in_proc_name_1.BuiltInProcName.Recall];
50
44
  /** The processors dispatching to a method chosen at run time. */
51
45
  const DispatchProcessors = [built_in_proc_name_1.BuiltInProcName.S3Dispatch, built_in_proc_name_1.BuiltInProcName.S3DispatchNext, built_in_proc_name_1.BuiltInProcName.S7Dispatch];
52
- /**
53
- * Whether the call hands the work to a method chosen at run time: flowR's own dispatch processors say so for
54
- * `UseMethod` and `NextMethod`, and {@link DispatchCallees} covers the ones it has no processor for.
55
- */
46
+ /** Whether the call hands the work to a method chosen at run time: flowR's own dispatch processors say so for `UseMethod` and `NextMethod`, and {@link DispatchCallees} covers the ones it has no processor for. */
56
47
  function isDispatch(vertex) {
57
48
  return hasProcessor(vertex, DispatchProcessors) || built_in_props_1.DispatchCallees.has(identifier_1.Identifier.getName(vertex.name));
58
49
  }
@@ -109,27 +100,32 @@ function branchOutcomes(graph, ctx) {
109
100
  return outcomes.size === 1 ? [...outcomes][0] : undefined;
110
101
  });
111
102
  }
112
- function strictnessStateOf(graph, ctx) {
103
+ function strictnessStateOf(graph, ctx, constantBranches = true, knownOnly = false) {
113
104
  const owner = new Map();
114
105
  for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
115
106
  for (const param of Object.keys(vertex.params)) {
116
107
  owner.set(node_id_1.NodeId.normalize(param), id);
117
108
  }
118
109
  }
119
- return {
110
+ const state = {
120
111
  graph,
121
112
  idMap: graph.idMap,
122
113
  owner,
123
114
  dispatch: dispatchingDefinitions(graph),
124
115
  fnInfo: (0, query_fn_props_1.builtInLookup)(ctx),
125
- branches: branchOutcomes(graph, ctx),
116
+ branches: branchOutcomes(graph, constantBranches ? ctx : undefined),
126
117
  untargeted: new Map(),
127
- known: new Map(),
128
- provisional: new Map(),
129
- assumptions: new Map(),
130
- asking: new Set(),
131
- assumed: false
118
+ knownOnly,
119
+ solver: new fixpoint_1.DemandSolver({
120
+ transfer: id => computeStrictness(id, state),
121
+ equals: sameStrictness,
122
+ /* a cycle starts out assuming every parameter is forced: a run that keeps recursing never returns, so that claims nothing */
123
+ initial: id => uniform(parametersOf(id, graph), logic_1.Ternary.Always),
124
+ rounds: MaxCycleRounds,
125
+ exhausted: id => uniform(parametersOf(id, graph), logic_1.Ternary.Maybe)
126
+ })
132
127
  };
128
+ return state;
133
129
  }
134
130
  /** What is certain becomes a possibility once something may intervene. */
135
131
  function weaken(value) {
@@ -146,11 +142,7 @@ function agree(values) {
146
142
  function conditionsBeyond(cds, definition) {
147
143
  return info_1.ControlDependency.minus(cds ?? [], definition ?? []).filter(c => c.byPromise !== true);
148
144
  }
149
- /**
150
- * Built-ins force what they are given, and the ones that do not (`quote` and its relatives) leave no read of
151
- * the argument in the graph in the first place, so there is nothing to hold back here. A call of something
152
- * the code worked out for itself (`obj$method(...)`) is none of them, whichever way it was written.
153
- */
145
+ /** Built-ins force what they are given, and the ones that do not (`quote` and its relatives) leave no read of the argument in the graph in the first place, so there is nothing to hold back here. */
154
146
  function isBuiltInCall(vertex) {
155
147
  return vertex.origin !== 'unnamed'
156
148
  && !vertex_1.DfgVertex.hasOrigin(vertex, built_in_proc_name_1.BuiltInProcName.Function)
@@ -161,11 +153,7 @@ function argumentValue(id, idMap) {
161
153
  const node = idMap.get(id);
162
154
  return r_argument_1.RArgument.is(node) ? node.value?.info.id ?? id : id;
163
155
  }
164
- /**
165
- * Where the given node stands in the call's arguments. The graph names an argument by the value it wraps,
166
- * while the walk arrives at the argument itself, so both count as a hit; `-1` when neither does, which a
167
- * call whose arguments flowR rewrote (`on.exit` and the other deferred ones) is enough to bring about.
168
- */
156
+ /** Where the given node stands in the call's arguments. */
169
157
  function argumentIndex(call, child, idMap) {
170
158
  const value = argumentValue(child, idMap);
171
159
  return call.args.findIndex(arg => arg !== r_function_call_1.EmptyArgument && (arg.nodeId === child || arg.nodeId === value));
@@ -177,10 +165,7 @@ function isCallee(call, child) {
177
165
  }
178
166
  return (r_function_call_1.RFunctionCall.isNamed(call) ? call.functionName.info.id : call.calledFunction.info.id) === child;
179
167
  }
180
- /**
181
- * What flowR states the argument at `index` of the call is used for. A `...` covers every position from
182
- * where it is declared, which {@link FunctionSemantics.call.signature.propAt} takes care of.
183
- */
168
+ /** What flowR states the argument at `index` of the call is used for. */
184
169
  function argProps(vertex, index, state) {
185
170
  const sig = index < 0 ? undefined : state.fnInfo(vertex.name)?.sig;
186
171
  return sig === undefined ? 0 : built_in_props_1.FnSig.propAt(built_in_props_1.FnSig.layout(sig), index);
@@ -208,10 +193,21 @@ function parameterAt(definition, index, idMap, graph) {
208
193
  const dotsBefore = node.parameters.slice(0, index + 1).some(r_parameter_1.RParameter.isDotDotDotDot);
209
194
  return dotsBefore ? undefined : node.parameters[index]?.name.info.id;
210
195
  }
196
+ /** Whether `id` is the dots handed on as they are (`g(...)`). */
197
+ function handsOnDots(id, idMap) {
198
+ const node = idMap.get(id);
199
+ return r_symbol_1.RSymbol.is(node) && node.content === identifier_1.Identifier.dotdotdot();
200
+ }
201
+ /** Whether `id`, bound to an argument, is a read of the dots by position (`..1`, `...elt(1)`) rather than a parameter. */
202
+ function isElementRead(id, graph) {
203
+ const vertex = graph.getVertex(id);
204
+ return vertex_1.DfgVertex.isUse(vertex) || vertex_1.DfgVertex.isFunctionCall(vertex);
205
+ }
211
206
  /** The parameters an argument of `call` binds to, by position in each definition an unlinked call may reach, `undefined` if unknown. */
212
207
  function boundParameters(call, argument, idMap, graph, origins) {
213
208
  const sources = new Set([argument, argumentValue(argument, idMap)]);
214
- const linked = [...sources].flatMap(from => df_helper_1.Dataflow.targetsOf(graph, from, edge_1.EdgeType.DefinesOnCall));
209
+ /* a call handed as the argument links on call what its own callees read as well, which binds no parameter, an argument to dots read by position only is bound to the reads of its position (`..1`) */
210
+ const linked = [...sources].flatMap(from => df_helper_1.Dataflow.targetsOf(graph, from, edge_1.EdgeType.DefinesOnCall)).filter(p => idMap.get(p)?.info.role === "param-n" /* RoleInParent.ParameterName */ || isElementRead(p, graph));
215
211
  if (linked.length > 0 || df_helper_1.Dataflow.calleeIdsOf(graph, call.id).length > 0) {
216
212
  return linked;
217
213
  }
@@ -225,20 +221,12 @@ function boundParameters(call, argument, idMap, graph, origins) {
225
221
  const params = found.map(definition => parameterAt(definition, index, idMap, graph));
226
222
  return params.length > 0 && params.every(assert_1.isNotUndefined) ? params : undefined;
227
223
  }
228
- /**
229
- * Whether handing `argument` to `call` forces it. An argument the call passes on is forced exactly as the
230
- * function receiving it forces the parameter it binds to; a call flowR cannot resolve, and one whose argument
231
- * it cannot match to a parameter, leave the question open.
232
- */
224
+ /** Whether handing `argument` to `call` forces it. */
233
225
  function forcedByCallee(call, argument, idMap, state) {
234
226
  const bound = boundParameters(call, argument, idMap, state.graph, state.untargeted);
235
227
  return bound === undefined || bound.length === 0 ? logic_1.Ternary.Maybe : agree(bound.map(param => handedTo(param, state)));
236
228
  }
237
- /**
238
- * How far the given read of a parameter is unavoidable: it has to stand under no condition the definition
239
- * does not already stand under, must not sit in a function or a default of its own that may never be
240
- * reached, and must not merely be handed to something that leaves it alone.
241
- */
229
+ /** How far the given read of a parameter is unavoidable: it has to stand under no condition the definition does not already stand under, must not sit in a function or a default of its own that may never be reached, and must not merely be handed to something that leaves it alone. */
242
230
  function forces(read, definition, state) {
243
231
  const idMap = state.idMap;
244
232
  if (idMap === undefined) {
@@ -282,6 +270,10 @@ function forces(read, definition, state) {
282
270
  && (hasProcessor(vertex, LazyThroughout) || (index !== 0 && hasProcessor(vertex, LazyAfterFirst)))) {
283
271
  lazy = true;
284
272
  }
273
+ else if (state.knownOnly && state.fnInfo(vertex.name) === undefined) {
274
+ /* nothing says what the function does with the argument, it may just as well capture it unevaluated */
275
+ lazy = true;
276
+ }
285
277
  }
286
278
  }
287
279
  child = node.info.id;
@@ -327,63 +319,24 @@ function parameterIds(definition, idMap) {
327
319
  /** How many rounds a cycle of definitions gets to settle before all of them answer {@link Ternary#Maybe}. */
328
320
  const MaxCycleRounds = 8;
329
321
  function strictnessOf(id, state) {
330
- const known = state.known.get(id) ?? state.provisional.get(id);
331
- if (known !== undefined) {
332
- return known;
333
- }
334
- const vertex = state.graph.getVertex(id);
335
- if (!vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
336
- return { strict: logic_1.Ternary.Never, parameters: {} };
337
- }
338
- const params = Object.keys(vertex.params);
339
- if (state.asking.has(id)) {
340
- /* a cycle starts out assuming every parameter is forced: a run that keeps recursing never returns, so that claims nothing */
341
- state.assumed = true;
342
- return state.assumptions.get(id) ?? uniform(params, logic_1.Ternary.Always);
343
- }
344
- let result = computeStrictness(id, vertex, params, state);
345
- if (!state.assumed) {
346
- state.known.set(id, result);
347
- }
348
- else if (state.asking.size === 0) {
349
- /* the outermost question of a cycle: recompute it until a round is stable */
350
- state.provisional.set(id, result);
351
- let settled = false;
352
- for (let round = 0; round < MaxCycleRounds && !settled; round++) {
353
- state.assumptions = new Map(state.provisional);
354
- state.provisional.clear();
355
- state.assumed = false;
356
- result = computeStrictness(id, vertex, params, state);
357
- state.provisional.set(id, result);
358
- settled = [...state.provisional].every(([other, r]) => sameStrictness(r, state.assumptions.get(other)));
359
- }
360
- if (settled) {
361
- /* the fixpoint holds for the whole cycle, so none of it has to be worked out again */
362
- for (const [other, r] of state.provisional) {
363
- state.known.set(other, r);
364
- }
365
- }
366
- else {
367
- result = uniform(params, logic_1.Ternary.Maybe);
368
- }
369
- state.known.set(id, result);
370
- state.assumptions = new Map();
371
- state.assumed = false;
372
- state.provisional.clear();
373
- }
374
- else {
375
- state.provisional.set(id, result);
376
- }
377
- return result;
322
+ return state.solver.of(id);
323
+ }
324
+ function parametersOf(id, graph) {
325
+ const vertex = graph.getVertex(id);
326
+ return vertex_1.DfgVertex.isFunctionDefinition(vertex) ? Object.keys(vertex.params) : [];
378
327
  }
379
328
  function uniform(params, value) {
380
329
  return { strict: value, parameters: Object.fromEntries(params.map(param => [param, value])) };
381
330
  }
382
331
  function sameStrictness(a, b) {
383
- return b !== undefined && a.strict === b.strict && Object.entries(a.parameters).every(([param, value]) => b.parameters[param] === value);
332
+ return a.strict === b.strict && Object.entries(a.parameters).every(([param, value]) => b.parameters[param] === value);
384
333
  }
385
- function computeStrictness(id, vertex, params, state) {
386
- state.asking.add(id);
334
+ function computeStrictness(id, state) {
335
+ const vertex = state.graph.getVertex(id);
336
+ if (!vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
337
+ return { strict: logic_1.Ternary.Never, parameters: {} };
338
+ }
339
+ const params = Object.keys(vertex.params);
387
340
  const dispatch = state.dispatch.get(id);
388
341
  /* a dispatch, or reflection flowR could not follow, may read a parameter without any read of it showing in the code */
389
342
  const reflective = ((0, frame_reflection_1.reflectiveRolesOf)(vertex, state.graph, { known: state.fnInfo }) & MayEvaluate) !== 0;
@@ -398,40 +351,20 @@ function computeStrictness(id, vertex, params, state) {
398
351
  if (object !== undefined && parameters[object] !== undefined) {
399
352
  parameters[object] = logic_1.Ternary.Always;
400
353
  }
401
- state.asking.delete(id);
402
354
  return { strict: logic_1.TernaryLogic.and(...Object.values(parameters)), parameters };
403
355
  }
404
356
  /**
405
357
  * Determines whether the function with the given id is strict, i.e., whether calling it forces its arguments.
406
- * {@link Ternary#Always} says every call forces every parameter, {@link Ternary#Never} that no call forces
407
- * all of them, and {@link Ternary#Maybe} that it depends on the path taken, on the caller, or on a function
408
- * flowR could not resolve. A definition without parameters has nothing to leave unforced and is strict.
409
- *
410
- * The analysis follows an argument that is handed on into the function receiving it, and treats a read in a
411
- * default, in a loop, in a branch, or in a nested definition as one that may not happen. What a built-in
412
- * does with an argument is not guessed from its name: an argument stated {@link ArgProp.Nse} or
413
- * {@link ArgProp.Presence} is never evaluated, one stated {@link ArgProp.Forced} always is, and the calls
414
- * reaching an argument only on the way the run takes are the ones flowR hands to the processor that says so
415
- * (`switch` picking a branch, `try` reaching a handler, a hook running at exit).
416
- * A body reading its own call or frame ({@link CallProp.Frame}: `match.call()`, `nargs()`,
417
- * `as.list(environment())`) reaches every parameter without naming one, so none of them is answered `Never`.
418
- * For a generic, the methods reached by S3 dispatch decide: they agree on a parameter or it is left open,
419
- * while the object the dispatch is on is forced by the dispatch itself. A `NextMethod` carries the same
420
- * question on to the methods it reaches, matched by the position the parameter is written in.
421
- * An argument in `...` is followed to the parameter it binds to, whereas the method of an object flowR
422
- * cannot resolve (`obj$m(x)`) is one more thing it cannot claim anything about.
423
- * Cyclic dependencies between functions and calls flowR cannot resolve answer {@link Ternary#Maybe}, so this
424
- * only claims certainty where the code gives it.
425
- * What a built-in does with an argument comes from the {@link ArgProp} bits its signature states, so a
426
- * configured or overwritten built-in is the one that answers when the analyzer context is handed along.
427
358
  * @useInstead {@link FunctionSemantics.strictness}
428
359
  */
429
360
  function strictnessOfEach(ids, graph, { ctx } = {}) {
430
361
  const state = strictnessStateOf(graph, ctx);
431
362
  const result = {};
432
- for (const id of ids) {
433
- result[id] = strictnessOf(id, state);
434
- }
363
+ graph.sharingTargetWalks(() => {
364
+ for (const id of ids) {
365
+ result[id] = strictnessOf(id, state);
366
+ }
367
+ });
435
368
  return result;
436
369
  }
437
370
  /** Where the promises bound to `params` may be forced: their reads, calls of closures capturing them, and the callees they are handed to. */
@@ -442,8 +375,11 @@ function forcingPointsOf(params, graph, idMap, seen = new Set()) {
442
375
  continue;
443
376
  }
444
377
  seen.add(param);
445
- const owner = idMap.get(idMap.get(param)?.info.parent ?? -1)?.info.parent;
446
- for (const read of df_helper_1.Dataflow.sourcesOf(graph, param, edge_1.EdgeType.Reads)) {
378
+ /* a read of the dots by position is bound to the argument itself */
379
+ const element = isElementRead(param, graph);
380
+ const binding = element ? df_helper_1.Dataflow.targetsOf(graph, param, edge_1.EdgeType.Reads).find(t => idMap.get(t)?.info.role === "param-n" /* RoleInParent.ParameterName */) : param;
381
+ const owner = idMap.get(idMap.get(binding ?? -1)?.info.parent ?? -1)?.info.parent;
382
+ for (const read of element ? [param] : df_helper_1.Dataflow.sourcesOf(graph, param, edge_1.EdgeType.Reads)) {
447
383
  found.push(read);
448
384
  /* only a closure within the function owning the parameter captures it, a read elsewhere is no call of one */
449
385
  const closures = [];
@@ -462,18 +398,16 @@ function forcingPointsOf(params, graph, idMap, seen = new Set()) {
462
398
  const bound = boundParameters(call, read, idMap, graph) ?? [];
463
399
  found.push(holder, ...forcingPointsOf(bound, graph, idMap, seen));
464
400
  }
401
+ else if (handsOnDots(read, idMap)) {
402
+ /* the dots are evaluated only by the call they are handed to */
403
+ found.push(holder);
404
+ }
465
405
  }
466
406
  }
467
407
  }
468
408
  return found;
469
409
  }
470
- /**
471
- * What a node within promises depends on to run: the holder of each `byPromise` dependency and where that promise may be forced.
472
- * @example
473
- * ```r
474
- * 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
475
- * ```
476
- */
410
+ /** What a node within promises depends on to run: the holder of each `byPromise` dependency and where that promise may be forced. */
477
411
  function promiseDependencies(id, graph) {
478
412
  const idMap = graph.idMap;
479
413
  const found = [];
@@ -497,14 +431,14 @@ function promiseDependencies(id, graph) {
497
431
  return found;
498
432
  }
499
433
  /** How surely the holder of a promise forces it, asked for a node `inner` within the promise. */
500
- function promiseForcing(graph, { ctx } = {}) {
434
+ function promiseForcing(graph, { ctx, constantBranches, knownOnly } = {}) {
501
435
  const idMap = graph.idMap;
502
436
  let state = undefined;
503
437
  return (holder, inner) => {
504
438
  if (idMap === undefined) {
505
439
  return logic_1.Ternary.Maybe;
506
440
  }
507
- state ??= strictnessStateOf(graph, ctx);
441
+ state ??= strictnessStateOf(graph, ctx, constantBranches, knownOnly);
508
442
  if (state.owner.has(holder)) {
509
443
  return handedTo(holder, state);
510
444
  }
@@ -516,6 +450,60 @@ function promiseForcing(graph, { ctx } = {}) {
516
450
  return argument === undefined ? logic_1.Ternary.Maybe : forcedByCallee(call, argument, idMap, state);
517
451
  };
518
452
  }
453
+ /** Whether nothing can ever evaluate the promise bound to the parameter: the function never reads it, not even through its frame, and calls nothing but built-ins that leave its frame alone, so no callee looks it up either. */
454
+ function neverEvaluated(param, state) {
455
+ const owner = state.owner.get(param);
456
+ const definition = owner === undefined ? undefined : state.graph.getVertex(owner);
457
+ if (!vertex_1.DfgVertex.isFunctionDefinition(definition) || state.dispatch.has(definition.id)
458
+ || df_helper_1.Dataflow.sourcesOf(state.graph, param, edge_1.EdgeType.Reads).length > 0
459
+ || (0, frame_reflection_1.reflectiveRolesOf)(definition, state.graph, { known: state.fnInfo }) !== 0) {
460
+ return false;
461
+ }
462
+ return df_helper_1.Dataflow.callsIn(definition, state.graph).every(([, call]) => call.onlyBuiltin);
463
+ }
464
+ /** The parameters the promise of `holder` holding `inner` is bound to, `undefined` if the holder is no call linked to definitions only. */
465
+ function promisedParameters(holder, inner, state, idMap) {
466
+ if (state.owner.has(holder)) {
467
+ return [holder];
468
+ }
469
+ const call = state.graph.getVertex(holder);
470
+ const targets = df_helper_1.Dataflow.calleeIdsOf(state.graph, holder);
471
+ if (!vertex_1.DfgVertex.isFunctionCall(call) || targets.length === 0 || targets.some(t => node_id_1.NodeId.isBuiltIn(t) || !vertex_1.DfgVertex.isFunctionDefinition(state.graph.getVertex(t)))) {
472
+ return undefined;
473
+ }
474
+ const argument = model_1.RNode.findEnclosing(inner, idMap, n => n.info.parent === holder);
475
+ const bound = argument === undefined ? undefined : boundParameters(call, argument, idMap, state.graph);
476
+ return bound === undefined || bound.length === 0 ? undefined : bound;
477
+ }
478
+ /** Settles what a definition within a promise (`f(x <- 5)`) does once the calls are linked. */
479
+ function settleDefinitionsInPromises(graph, { ctx } = {}) {
480
+ const idMap = graph.idMap;
481
+ if (idMap === undefined) {
482
+ return;
483
+ }
484
+ let state;
485
+ let forcing;
486
+ for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
487
+ const promised = vertex.cds?.filter(cd => cd.byPromise === true) ?? [];
488
+ if (promised.length === 0) {
489
+ continue;
490
+ }
491
+ state ??= strictnessStateOf(graph, ctx);
492
+ const known = state;
493
+ if (promised.some(cd => promisedParameters(cd.id, id, known, idMap)?.every(p => neverEvaluated(p, known)) === true)) {
494
+ for (const reader of df_helper_1.Dataflow.sourcesOf(graph, id, edge_1.EdgeType.Reads)) {
495
+ graph.removeEdgeType(reader, id, edge_1.EdgeType.Reads);
496
+ }
497
+ continue;
498
+ }
499
+ forcing ??= promiseForcing(graph, { ctx, knownOnly: true });
500
+ const statement = program_order_1.ProgramOrder.runsOnceAt(id, graph);
501
+ if (statement === undefined || promised.length !== vertex.cds?.length || !promised.every(cd => forcing?.(cd.id, id) === logic_1.Ternary.Always)) {
502
+ continue;
503
+ }
504
+ program_order_1.ProgramOrder.replaceEarlier(id, statement, graph, false);
505
+ }
506
+ }
519
507
  /** Drops the resume of a jump within a promise ({@link ControlFlow.promise}) once the linked holder surely forces it. */
520
508
  function settleJumpsInPromises(graph, topLevel, { ctx } = {}) {
521
509
  const forcing = promiseForcing(graph, { ctx });
@@ -0,0 +1,51 @@
1
+ import { Relation } from '../../util/collections/relation';
2
+ import type { Monoid } from '../../util/monoid';
3
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
+ import type { AmbientStateName } from '../environments/ambient-state-name';
5
+ import type { BrandedIdentifier } from '../environments/identifier';
6
+ /** How code accesses a part of the global state, see {@link AmbientAccess}. */
7
+ export declare enum AmbientAccessKind {
8
+ /** the code may read the state */
9
+ Read = "reads",
10
+ /** the code may change the state */
11
+ Write = "writes",
12
+ /** the state is only assumed changed by a body flowR cannot see, like `#rng` for `function(f) f()` */
13
+ Assumed = "assumed",
14
+ /** the code changes the state in the current frame only */
15
+ Local = "local"
16
+ }
17
+ /**
18
+ * What code accesses of the global state, for a single call (see {@link DataflowGraph#ambientAccessOf}) just like for a function or any other part of a program (see {@link Dataflow.sideEffects.ambientAccess}).
19
+ * Every kind maps the accessed state to the ids of the calls accessing it.
20
+ */
21
+ export interface AmbientAccess {
22
+ readonly [AmbientAccessKind.Read]: Relation<AmbientStateName, NodeId>;
23
+ readonly [AmbientAccessKind.Write]: Relation<AmbientStateName, NodeId>;
24
+ readonly [AmbientAccessKind.Assumed]: Relation<AmbientStateName, NodeId>;
25
+ readonly [AmbientAccessKind.Local]: Relation<AmbientStateName, NodeId>;
26
+ /** the global variables the functions the code calls may bind, by `x <<- 1` reaching the global frame or `assign("x", 1, envir = .GlobalEnv)`, with the ids of these definitions; the graph does not know them for a single call */
27
+ readonly variables: Relation<BrandedIdentifier, NodeId>;
28
+ /** the calls tagged {@link SemanticCallTag.Graphics} (`plot`, `lines`, `par`, ...), which write the canvas only if `semantics.ambient.drawingWritesDevice` is set; the graph does not know them for a single call */
29
+ readonly draws: ReadonlySet<NodeId>;
30
+ }
31
+ /** The state of each {@link AmbientAccessKind} a call accesses, as it is given to {@link DataflowGraph#recordAmbientAccess} and serialized with the graph (in which the call is the key). */
32
+ export type AmbientAccessNames = {
33
+ readonly [Kind in AmbientAccessKind]?: readonly AmbientStateName[];
34
+ };
35
+ /**
36
+ * Helper functions for the {@link AmbientAccess}.
37
+ * @helper dataflow
38
+ */
39
+ export declare const AmbientAccess: {
40
+ readonly name: "AmbientAccess";
41
+ /** Accesses nothing. */
42
+ readonly empty: AmbientAccess;
43
+ /** What accesses combine to, as what runs in sequence or what a function reaches through its callees. */
44
+ readonly monoid: Monoid<AmbientAccess>;
45
+ /** What the call `id` accesses, given the state it accesses (several times to add them up). All entries of a call share their ids, as the graph keeps this for every call touching global state. */
46
+ readonly ofCall: (this: void, id: NodeId, ...names: readonly AmbientAccessNames[]) => AmbientAccess;
47
+ /** The state of each kind `access` accesses, without who accesses it. Mind that the order of names is not stable, so use {@link AmbientAccess.equals} to compare them. */
48
+ readonly names: (this: void, access: AmbientAccess) => Required<AmbientAccessNames>;
49
+ /** Whether both access the same state in the same way, no matter by which calls. */
50
+ readonly equals: (this: void, a: AmbientAccess, b: AmbientAccess) => boolean;
51
+ };
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AmbientAccess = exports.AmbientAccessKind = void 0;
4
+ const set_1 = require("../../util/collections/set");
5
+ const relation_1 = require("../../util/collections/relation");
6
+ /** How code accesses a part of the global state, see {@link AmbientAccess}. */
7
+ var AmbientAccessKind;
8
+ (function (AmbientAccessKind) {
9
+ /** the code may read the state */
10
+ AmbientAccessKind["Read"] = "reads";
11
+ /** the code may change the state */
12
+ AmbientAccessKind["Write"] = "writes";
13
+ /** the state is only assumed changed by a body flowR cannot see, like `#rng` for `function(f) f()` */
14
+ AmbientAccessKind["Assumed"] = "assumed";
15
+ /** the code changes the state in the current frame only */
16
+ AmbientAccessKind["Local"] = "local";
17
+ })(AmbientAccessKind || (exports.AmbientAccessKind = AmbientAccessKind = {}));
18
+ const Kinds = Object.values(AmbientAccessKind);
19
+ const Empty = {
20
+ [AmbientAccessKind.Read]: relation_1.Relation.empty(),
21
+ [AmbientAccessKind.Write]: relation_1.Relation.empty(),
22
+ [AmbientAccessKind.Assumed]: relation_1.Relation.empty(),
23
+ [AmbientAccessKind.Local]: relation_1.Relation.empty(),
24
+ variables: relation_1.Relation.empty(),
25
+ draws: new Set()
26
+ };
27
+ /** What all of `accesses` together access. What one of them changes is no longer only assumed changed. */
28
+ function concatAll(accesses) {
29
+ const given = accesses.filter(a => a !== Empty);
30
+ if (given.length <= 1) {
31
+ return given[0] ?? Empty;
32
+ }
33
+ const union = (kind) => relation_1.Relation.unionAll(given.map(a => a[kind]));
34
+ const writes = union(AmbientAccessKind.Write);
35
+ return {
36
+ [AmbientAccessKind.Read]: union(AmbientAccessKind.Read),
37
+ [AmbientAccessKind.Write]: writes,
38
+ [AmbientAccessKind.Assumed]: relation_1.Relation.withoutKeysOf(union(AmbientAccessKind.Assumed), writes),
39
+ [AmbientAccessKind.Local]: union(AmbientAccessKind.Local),
40
+ variables: relation_1.Relation.unionAll(given.map(a => a.variables)),
41
+ draws: new Set(given.flatMap(a => [...a.draws]))
42
+ };
43
+ }
44
+ /**
45
+ * Helper functions for the {@link AmbientAccess}.
46
+ * @helper dataflow
47
+ */
48
+ exports.AmbientAccess = {
49
+ name: 'AmbientAccess',
50
+ /** Accesses nothing. */
51
+ empty: Empty,
52
+ /** What accesses combine to, as what runs in sequence or what a function reaches through its callees. */
53
+ monoid: { empty: Empty, concat: (a, b) => concatAll([a, b]), concatAll },
54
+ /** What the call `id` accesses, given the state it accesses (several times to add them up). All entries of a call share their ids, as the graph keeps this for every call touching global state. */
55
+ ofCall(id, ...names) {
56
+ const ids = new Set([id]);
57
+ const ofKind = (kind) => relation_1.Relation.of(names.flatMap(n => n[kind] ?? []), ids);
58
+ return {
59
+ ...Empty,
60
+ [AmbientAccessKind.Read]: ofKind(AmbientAccessKind.Read),
61
+ [AmbientAccessKind.Write]: ofKind(AmbientAccessKind.Write),
62
+ [AmbientAccessKind.Assumed]: ofKind(AmbientAccessKind.Assumed),
63
+ [AmbientAccessKind.Local]: ofKind(AmbientAccessKind.Local)
64
+ };
65
+ },
66
+ /** The state of each kind `access` accesses, without who accesses it. Mind that the order of names is not stable, so use {@link AmbientAccess.equals} to compare them. */
67
+ names(access) {
68
+ return {
69
+ [AmbientAccessKind.Read]: [...access[AmbientAccessKind.Read].keys()],
70
+ [AmbientAccessKind.Write]: [...access[AmbientAccessKind.Write].keys()],
71
+ [AmbientAccessKind.Assumed]: [...access[AmbientAccessKind.Assumed].keys()],
72
+ [AmbientAccessKind.Local]: [...access[AmbientAccessKind.Local].keys()]
73
+ };
74
+ },
75
+ /** Whether both access the same state in the same way, no matter by which calls. */
76
+ equals(a, b) {
77
+ return Kinds.every(kind => (0, set_1.setEquals)(new Set(a[kind].keys()), new Set(b[kind].keys())));
78
+ }
79
+ };
80
+ //# sourceMappingURL=ambient-access.js.map
@@ -1,55 +1,35 @@
1
1
  import { DataflowGraph } from './graph';
2
2
  import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition } from './vertex';
3
- import type { REnvironmentInformation } from '../environments/environment';
4
3
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
4
  import { DefaultMap } from '../../util/collections/defaultmap';
6
- /**
7
- * A call graph is a dataflow graph where all vertices are function calls.
8
- * You can create a call graph from a dataflow graph using {@link CallGraph.compute}.
9
- * If you want to extract a sub call graph, use {@link CallGraph.computeSubCallGraph}.
10
- * @see {@link dropTransitiveEdges} - to reduce the call graph by dropping transitive edges
11
- */
5
+ import { LinkedFunctionResolver } from '../internal/linker';
6
+ /** A call graph is a dataflow graph where all vertices are function calls. */
12
7
  export type CallGraph = DataflowGraph<Required<DataflowGraphVertexFunctionCall | DataflowGraphVertexFunctionDefinition>>;
13
8
  export interface State {
14
9
  visited: Set<NodeId>;
15
10
  potentials: [NodeId, Set<NodeId>][];
11
+ /** shares what the calls of the graph target between them */
12
+ resolver: LinkedFunctionResolver;
16
13
  }
17
- /**
18
- * The origins of what a call flowR found no target for calls, following its name back through reads and
19
- * parameter bindings: `f(x)` within `apply_f <- function(f, x) f(x)` ends at what callers hand in as `f`.
20
- */
14
+ /** The origins of what a call flowR found no target for calls, following its name back through reads and parameter bindings: `f(x)` within `apply_f <- function(f, x) f(x)` ends at what callers hand in as `f`. */
21
15
  export declare function fallbackUntargetedCall(vtx: Pick<DataflowGraphVertexFunctionCall, 'id'>, graph: DataflowGraph): Set<NodeId>;
22
16
  /**
23
17
  * Helper object for call-graphs, you can compute new call graphs based on {@link CallGraph.compute}.
24
18
  * @helper dataflow
25
- * @see {@link Dataflow}
26
- * @see {@link CallGraph}
27
19
  */
28
20
  export declare const CallGraph: {
29
21
  readonly name: "CallGraph";
30
22
  /** Extracts the sub call graph from the given call graph, starting from the given entry points. */
31
23
  readonly computeSubCallGraph: (this: void, graph: CallGraph, entryPoints: Set<NodeId>) => CallGraph;
32
- /**
33
- * Whether the function definition with the given id (transitively) calls itself; `false` for ids that are no function definition.
34
- * @param id - The id of the function definition
35
- * @param graph - The call graph to follow
36
- */
24
+ /** Whether the function definition with the given id (transitively) calls itself; `false` for ids that are no function definition. */
37
25
  readonly isRecursive: (this: void, id: NodeId, graph: CallGraph) => boolean;
38
26
  /** The calls the program makes on its own: those outside of any function definition. */
39
27
  readonly entryPoints: (this: void, graph: CallGraph) => Set<NodeId>;
40
- /**
41
- * The calls no execution starting at the top level reaches: those in a function nothing (transitively) calls.
42
- * What {@link mayRunAnyway} may still run is left out, so a call reported here really does not run.
43
- */
28
+ /** The calls no execution starting at the top level reaches: those in a function nothing (transitively) calls. */
44
29
  readonly unreachableCalls: (this: void, graph: CallGraph) => NodeId[];
45
30
  /** Reduces the call graph by dropping all transitive edges. */
46
31
  readonly dropTransitiveEdges: (this: void, graph: CallGraph) => CallGraph;
47
- /**
48
- * Computes the call graph from the given dataflow graph.
49
- * @see {@link CallGraph} - for details
50
- * @see {@link CallGraph.computeSubCallGraph} - to extract sub call graphs
51
- * @see {@link CallGraph.dropTransitiveEdges} - to reduce the call graph by dropping transitive edges
52
- */
32
+ /** Computes the call graph from the given dataflow graph. */
53
33
  readonly compute: (this: void, graph: DataflowGraph) => CallGraph;
54
34
  readonly visualize: {
55
35
  readonly mermaid: {
@@ -72,7 +52,7 @@ export declare const CallGraph: {
72
52
  readonly edges: <Edge, Graph>(this: void, ctx: import("../../util/diff-graph").GraphDiffContext<Graph>, id: NodeId, lEdges: ReadonlyMap<NodeId, Edge> | undefined, rEdges: ReadonlyMap<NodeId, Edge> | undefined, diffEdge: (edge: Edge, otherEdge: Edge, ctx: import("../../util/diff-graph").GraphDiffContext<Graph>, id: NodeId, target: NodeId) => void) => void;
73
53
  };
74
54
  readonly diffGraphs: <G extends DataflowGraph>(this: void, left: import("../../util/diff-graph").NamedGraph<G>, right: import("../../util/diff-graph").NamedGraph<G>, config?: Partial<import("../../util/diff").GenericDiffConfiguration>) => import("../../util/diff-graph").GraphDifferenceReport;
75
- readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
55
+ readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: import("../environments/environment").REnvironmentInformation) => G;
76
56
  readonly resolveGraphCriteria: <G extends DataflowGraph>(graph: G, ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext, idMap?: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").AstIdMap) => G;
77
57
  readonly parametersOf: (this: void, definition: DataflowGraphVertexFunctionDefinition) => NodeId[];
78
58
  readonly calleesOf: (this: void, graph: DataflowGraph, id: NodeId) => Generator<DataflowGraphVertexFunctionDefinition>;