@eagleoutice/flowr 2.14.1 → 2.14.2

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 (413) hide show
  1. package/README.md +154 -87
  2. package/abstract-interpretation/absint-visitor.d.ts +91 -25
  3. package/abstract-interpretation/absint-visitor.js +235 -74
  4. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +1 -1
  5. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
  6. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
  7. package/abstract-interpretation/data-frame/mappers/arguments.js +1 -1
  8. package/abstract-interpretation/data-frame/mappers/function-mapper.js +107 -254
  9. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +5 -5
  10. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
  11. package/abstract-interpretation/data-frame/resolve-args.js +6 -4
  12. package/abstract-interpretation/data-frame/shape-inference.d.ts +4 -9
  13. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -0
  14. package/abstract-interpretation/domains/bounded-set-domain.js +1 -0
  15. package/abstract-interpretation/domains/partial-product-domain.js +1 -1
  16. package/abstract-interpretation/domains/set-range-domain.d.ts +3 -2
  17. package/abstract-interpretation/domains/set-range-domain.js +3 -2
  18. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +3 -2
  19. package/abstract-interpretation/domains/set-upper-bound-domain.js +3 -2
  20. package/benchmark/calibration.d.ts +11 -6
  21. package/benchmark/calibration.js +19 -8
  22. package/benchmark/slicer.d.ts +7 -1
  23. package/benchmark/slicer.js +38 -34
  24. package/benchmark/stats/count-comments.d.ts +16 -0
  25. package/benchmark/stats/count-comments.js +30 -0
  26. package/benchmark/stats/print.js +2 -0
  27. package/benchmark/stats/size-of.d.ts +7 -3
  28. package/benchmark/stats/size-of.js +7 -3
  29. package/benchmark/stats/stats.d.ts +7 -0
  30. package/benchmark/summarizer/first-phase/process.js +2 -19
  31. package/benchmark/summarizer/second-phase/graph.js +13 -3
  32. package/benchmark/summarizer/second-phase/process.js +2 -0
  33. package/cli/repl/commands/repl-dataflow.js +70 -27
  34. package/cli/repl/core.d.ts +1 -1
  35. package/cli/repl/core.js +1 -1
  36. package/cli/repl/parser/slice-query-parser.js +2 -1
  37. package/cli/repl/server/connection.d.ts +4 -0
  38. package/cli/repl/server/connection.js +19 -16
  39. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  40. package/config.d.ts +6 -0
  41. package/config.js +8 -4
  42. package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
  43. package/control-flow/basic-cfg-guided-visitor.js +37 -24
  44. package/control-flow/cfg-dead-code.js +44 -33
  45. package/control-flow/cfg-properties.js +2 -2
  46. package/control-flow/cfg-simplification.js +6 -5
  47. package/control-flow/cfg-to-basic-blocks.js +11 -13
  48. package/control-flow/control-flow-graph.d.ts +179 -189
  49. package/control-flow/control-flow-graph.js +400 -263
  50. package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
  51. package/control-flow/dfg-cfg-guided-visitor.js +17 -13
  52. package/control-flow/diff-cfg.js +6 -14
  53. package/control-flow/happens-before.js +5 -4
  54. package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
  55. package/control-flow/semantic-cfg-guided-visitor.js +6 -26
  56. package/control-flow/simple-visitor.js +14 -15
  57. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
  58. package/control-flow/useless-loop.js +18 -14
  59. package/core/steps/all/core/20-dataflow.d.ts +1 -3
  60. package/core/steps/pipeline/default-pipelines.d.ts +141 -157
  61. package/dataflow/cluster.js +7 -0
  62. package/dataflow/environments/apply-kill.d.ts +6 -0
  63. package/dataflow/environments/apply-kill.js +63 -31
  64. package/dataflow/environments/built-in-props.d.ts +5 -1
  65. package/dataflow/environments/built-in-props.js +4 -0
  66. package/dataflow/environments/built-in.d.ts +6 -3
  67. package/dataflow/environments/built-in.js +8 -5
  68. package/dataflow/environments/clone.d.ts +3 -3
  69. package/dataflow/environments/clone.js +5 -5
  70. package/dataflow/environments/default-builtin-config.d.ts +112 -7
  71. package/dataflow/environments/default-builtin-config.js +82 -34
  72. package/dataflow/environments/environment.d.ts +5 -5
  73. package/dataflow/environments/environment.js +5 -5
  74. package/dataflow/environments/identifier.d.ts +11 -1
  75. package/dataflow/environments/identifier.js +4 -1
  76. package/dataflow/environments/resolve-by-name.d.ts +7 -0
  77. package/dataflow/environments/resolve-by-name.js +12 -0
  78. package/dataflow/environments/resolve-helper.d.ts +3 -1
  79. package/dataflow/environments/resolve-helper.js +2 -0
  80. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
  81. package/dataflow/eval/resolve/alias-tracking.js +2 -2
  82. package/dataflow/eval/resolve/match-arguments.js +7 -5
  83. package/dataflow/eval/resolve/node-value.d.ts +3 -1
  84. package/dataflow/eval/resolve/node-value.js +12 -0
  85. package/dataflow/eval/resolve/resolve-argument.js +5 -4
  86. package/dataflow/eval/resolve/resolve-operators.js +9 -6
  87. package/dataflow/eval/resolve/resolve-strings.js +2 -2
  88. package/dataflow/eval/resolve/resolve-working-directory.js +4 -3
  89. package/dataflow/eval/resolve/resolve.js +3 -2
  90. package/dataflow/eval/values/general.js +8 -5
  91. package/dataflow/extractor.d.ts +1 -4
  92. package/dataflow/extractor.js +11 -10
  93. package/dataflow/fn/exceptions-of-function.d.ts +3 -1
  94. package/dataflow/fn/strict-function.js +7 -5
  95. package/dataflow/graph/call-graph.js +2 -2
  96. package/dataflow/graph/df-helper.d.ts +8 -1
  97. package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
  98. package/dataflow/graph/diff-dataflow-graph.js +19 -2
  99. package/dataflow/graph/edge.d.ts +38 -2
  100. package/dataflow/graph/edge.js +32 -2
  101. package/dataflow/graph/graph.d.ts +4 -3
  102. package/dataflow/graph/graph.js +6 -2
  103. package/dataflow/graph/match-args.d.ts +69 -0
  104. package/dataflow/graph/match-args.js +167 -0
  105. package/dataflow/info.d.ts +14 -0
  106. package/dataflow/internal/control-flow.d.ts +102 -0
  107. package/dataflow/internal/control-flow.js +200 -0
  108. package/dataflow/internal/linker.d.ts +6 -31
  109. package/dataflow/internal/linker.js +24 -81
  110. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  111. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
  112. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
  113. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
  114. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  115. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
  116. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
  117. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
  118. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
  120. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
  121. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
  122. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  123. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  124. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
  125. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
  126. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
  127. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  128. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
  129. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
  130. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  131. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
  132. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  133. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
  134. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  135. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
  136. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
  137. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
  138. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
  139. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
  140. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
  142. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
  143. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  144. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
  145. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
  146. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  147. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
  148. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
  149. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
  150. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
  151. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
  152. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -2
  153. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +71 -33
  154. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
  155. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
  156. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  157. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +14 -11
  158. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  160. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
  161. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
  162. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  163. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
  164. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  165. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
  166. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
  167. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
  168. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
  169. package/dataflow/internal/process/functions/call/common.js +5 -6
  170. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  171. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
  172. package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
  173. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
  174. package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
  175. package/dataflow/internal/process/functions/call/nse.js +6 -1
  176. package/dataflow/internal/process/functions/call/quoted.js +2 -2
  177. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
  178. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  179. package/dataflow/internal/process/functions/process-argument.js +12 -4
  180. package/dataflow/internal/process/functions/process-parameter.js +13 -0
  181. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  182. package/dataflow/internal/process/process-named-call.js +9 -7
  183. package/documentation/data/server/doc-data-server-messages.js +4 -4
  184. package/documentation/doc-readme.js +45 -0
  185. package/documentation/doc-util/doc-cfg.d.ts +8 -7
  186. package/documentation/doc-util/doc-cfg.js +10 -10
  187. package/documentation/doc-util/doc-playground.d.ts +12 -0
  188. package/documentation/doc-util/doc-playground.js +21 -0
  189. package/documentation/doc-util/doc-query.d.ts +4 -1
  190. package/documentation/doc-util/doc-query.js +4 -2
  191. package/documentation/wiki-absint.d.ts +3 -4
  192. package/documentation/wiki-absint.js +12 -5
  193. package/documentation/wiki-analyzer.js +2 -2
  194. package/documentation/wiki-cfg.js +101 -106
  195. package/documentation/wiki-dataflow-graph.js +84 -53
  196. package/documentation/wiki-linter.js +15 -1
  197. package/documentation/wiki-linting-and-testing.js +1 -16
  198. package/documentation/wiki-mk/doc-maker.js +6 -4
  199. package/documentation/wiki-query.js +14 -4
  200. package/documentation/wiki-signature-database.js +28 -2
  201. package/linter/linter-fix.d.ts +16 -0
  202. package/linter/linter-fix.js +104 -0
  203. package/linter/linter-format.d.ts +18 -1
  204. package/linter/linter-format.js +31 -1
  205. package/linter/linter-output.js +46 -10
  206. package/linter/linter-rules.d.ts +40 -9
  207. package/linter/linter-rules.js +2 -0
  208. package/linter/rules/absolute-path.js +4 -2
  209. package/linter/rules/dataframe-access-validation.js +6 -7
  210. package/linter/rules/deprecated-functions.d.ts +107 -10
  211. package/linter/rules/deprecated-functions.js +309 -23
  212. package/linter/rules/file-path-validity.js +5 -4
  213. package/linter/rules/function-finder-util.d.ts +6 -0
  214. package/linter/rules/function-finder-util.js +21 -13
  215. package/linter/rules/naming-convention.js +1 -1
  216. package/linter/rules/network-functions.d.ts +2 -2
  217. package/linter/rules/stop-with-call-arg.js +2 -2
  218. package/linter/rules/unclosed-connection.js +2 -2
  219. package/linter/rules/undefined-symbol-util.js +6 -4
  220. package/linter/rules/undefined-symbol.js +2 -2
  221. package/linter/rules/unused-definition.js +8 -4
  222. package/linter/rules/unused-import.d.ts +60 -0
  223. package/linter/rules/unused-import.js +179 -0
  224. package/package.json +2 -2
  225. package/project/attached-packages.js +2 -1
  226. package/project/cache/flowr-analyzer-cache.d.ts +2 -5
  227. package/project/cache/flowr-analyzer-cache.js +4 -7
  228. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
  229. package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
  230. package/project/cache/flowr-cache.d.ts +9 -0
  231. package/project/cache/flowr-cache.js +19 -0
  232. package/project/context/flowr-analyzer-context.d.ts +7 -3
  233. package/project/context/flowr-analyzer-context.js +15 -9
  234. package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
  235. package/project/context/flowr-analyzer-dependencies-context.js +9 -14
  236. package/project/context/flowr-analyzer-files-context.js +15 -17
  237. package/project/context/flowr-analyzer-meta-context.js +2 -12
  238. package/project/dependency-version-space.d.ts +0 -7
  239. package/project/dependency-version-space.js +8 -7
  240. package/project/flowr-analyzer.d.ts +4 -6
  241. package/project/flowr-analyzer.js +4 -5
  242. package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -34
  243. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
  244. package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
  245. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
  246. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
  247. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
  248. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
  249. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
  250. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
  251. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
  252. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
  253. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
  254. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
  255. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
  256. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
  257. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
  258. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
  259. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
  260. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
  261. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
  262. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
  263. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
  264. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
  265. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
  266. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
  267. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
  268. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
  269. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
  270. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
  271. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
  272. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
  273. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
  274. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
  275. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
  276. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
  277. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
  278. package/project/sigdb/build.d.ts +2 -2
  279. package/project/sigdb/decode.d.ts +0 -5
  280. package/project/sigdb/decode.js +0 -8
  281. package/project/sigdb/index-format.d.ts +4 -4
  282. package/project/sigdb/manifest.d.ts +2 -2
  283. package/project/sigdb/reader.d.ts +48 -13
  284. package/project/sigdb/reader.js +2 -1
  285. package/project/sigdb/schema.d.ts +3 -1
  286. package/project/sigdb/signature-db.d.ts +69 -0
  287. package/project/sigdb/signature-db.js +54 -0
  288. package/project/sigdb/signature-match.d.ts +10 -5
  289. package/project/sigdb/signature-match.js +13 -8
  290. package/queries/catalog/absint-query/absint-query-executor.js +1 -2
  291. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
  292. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  293. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
  294. package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
  295. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  296. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
  297. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
  298. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
  299. package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
  300. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
  301. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
  302. package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
  303. package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
  304. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  305. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
  306. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
  307. package/queries/catalog/signature-query/signature-query-executor.js +4 -3
  308. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  309. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  310. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  311. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  312. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  313. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
  314. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
  315. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  316. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  317. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  318. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  319. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  320. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  321. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  322. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  323. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  324. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  325. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
  326. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
  327. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  328. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  329. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  330. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  331. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  332. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  333. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  334. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  335. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  336. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  337. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
  338. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
  339. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  340. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
  341. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  342. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  343. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
  344. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
  345. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  346. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  347. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  350. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  352. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  355. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
  356. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  357. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
  358. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
  359. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
  360. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  361. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
  362. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
  363. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
  364. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
  365. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
  366. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
  367. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
  368. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
  369. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
  370. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
  371. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
  372. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
  373. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
  374. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
  375. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
  376. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
  377. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
  378. package/reconstruct/inline/source-inline-map.js +3 -3
  379. package/reconstruct/reconstruct.js +6 -4
  380. package/search/flowr-search-builder.d.ts +8 -8
  381. package/search/flowr-search-builder.js +4 -4
  382. package/search/flowr-search-filters.d.ts +2 -2
  383. package/search/flowr-search-filters.js +3 -2
  384. package/search/search-executor/search-enrichers.d.ts +6 -4
  385. package/search/search-executor/search-enrichers.js +44 -5
  386. package/slicing/criterion/filters/all-variables.js +2 -1
  387. package/slicing/criterion/parse.js +8 -6
  388. package/slicing/static/slice-call.js +2 -2
  389. package/util/arg-matching.d.ts +3 -0
  390. package/util/arg-matching.js +12 -1
  391. package/util/collections/arrays.d.ts +0 -4
  392. package/util/collections/arrays.js +4 -26
  393. package/util/diff-graph.d.ts +1 -1
  394. package/util/diff-graph.js +17 -3
  395. package/util/diff.d.ts +6 -0
  396. package/util/mermaid/ast.d.ts +1 -1
  397. package/util/mermaid/ast.js +5 -4
  398. package/util/mermaid/cfg.js +130 -24
  399. package/util/mermaid/dfg.js +31 -10
  400. package/util/mermaid/mermaid.js +2 -0
  401. package/util/objects.d.ts +9 -0
  402. package/util/objects.js +12 -0
  403. package/util/prefix.d.ts +1 -1
  404. package/util/text/playground-link.d.ts +131 -0
  405. package/util/text/playground-link.js +214 -0
  406. package/util/text/strings.js +7 -3
  407. package/util/version.js +1 -1
  408. package/control-flow/cfg-builder.d.ts +0 -30
  409. package/control-flow/cfg-builder.js +0 -79
  410. package/control-flow/extract-cfg.d.ts +0 -36
  411. package/control-flow/extract-cfg.js +0 -693
  412. package/project/cfg-kind.d.ts +0 -21
  413. package/project/cfg-kind.js +0 -26
@@ -0,0 +1,69 @@
1
+ import { type PotentiallyEmptyRArgument, type RFunctionCall } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
2
+ import type { RArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
3
+ import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
4
+ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
+ import type { NoInfo } from '../../r-bridge/lang-4.x/ast/model/model';
6
+ import { type DataflowGraph, FunctionArgument } from './graph';
7
+ import type { SigParameter } from '../../project/sigdb/decode';
8
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
9
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
10
+ /**
11
+ * R's argument matching, as {@link matchArgumentsToParameters} implements it. Pick by what you hold:
12
+ *
13
+ * - {@link MatchArgs.toNames|toNames} - AST arguments and the formal names
14
+ * - {@link MatchArgs.toSpec|toSpec} - graph arguments and the formals (a spec or a database signature)
15
+ * - {@link MatchArgs.onCallAndLink|onCallAndLink} - as `toSpec`, and **adds the argument edges to the graph**
16
+ * - {@link MatchArgs.toDefinition|toDefinition} - only the call, the formals are looked up for you
17
+ * @example
18
+ * ```ts
19
+ * MatchArgs.toNames(call.arguments, ['x', 'value']).get('value');
20
+ * MatchArgs.toSpec(args, { file: 'fileId', '...': '...' }).get('fileId');
21
+ * ```
22
+ */
23
+ export declare const MatchArgs: {
24
+ readonly name: "MatchArgs";
25
+ /**
26
+ * Binds a call's AST `args` to the formal `paramNames`. An empty argument (`f(1, ,3)`) takes its formal but
27
+ * never appears here. Arguments falling to `...` share that key, so only the last survives; use
28
+ * {@link MatchArgs.toSpec} to keep them all.
29
+ * @param args - The arguments as they stand in the normalized AST.
30
+ * @param paramNames - The formals of the called function, in order.
31
+ * @returns Per formal name the argument bound to it.
32
+ */
33
+ readonly toNames: <Info = object>(this: void, args: readonly PotentiallyEmptyRArgument<Info>[], paramNames: readonly string[]) => ReadonlyMap<string, RArgument<Info>>;
34
+ /**
35
+ * Binds a call's graph `args` against the formals, reading nothing from the graph, so it also serves a
36
+ * function whose parameters are not in the AST at all. Name `'...'` in a specification unless the function
37
+ * really has none, as that is what collects arguments finding no formal of their own.
38
+ * @param args - The arguments as the graph holds them, see {@link convertFnArguments}.
39
+ * @param params - Formal name to the target it stands for, or a signature whose names are the targets.
40
+ * @returns Per target the ids bound to it.
41
+ */
42
+ readonly toSpec: <Targets extends NodeId = string>(this: void, args: readonly FunctionArgument[], params: Record<string, Targets> | readonly SigParameter[]) => Map<Targets, NodeId[]>;
43
+ /**
44
+ * Binds a call's graph `args` to the `params` of the definition it calls **and mutates `graph`**, adding an
45
+ * {@link EdgeType.DefinesOnCall} and a {@link EdgeType.DefinedByOnCall} edge per bound pair. It is the only
46
+ * member here that writes anything.
47
+ * @param args - The arguments as the graph holds them.
48
+ * @param params - The parameters of the called definition, in order.
49
+ * @param graph - The graph the edges are added to.
50
+ * @returns The argument id to parameter id mapping the edges were drawn for.
51
+ */
52
+ readonly onCallAndLink: (this: void, args: readonly FunctionArgument[], params: readonly RParameter<ParentInformation>[], graph: DataflowGraph) => Map<NodeId, NodeId>;
53
+ /**
54
+ * Binds a call's arguments to the formals of whatever it calls, looking the formals up itself. It takes them
55
+ * from the {@link RFunctionDefinition} the call resolves to in user code, and from the database signature at
56
+ * the version the analysis assumes otherwise (see {@link SignatureDb}). `undefined` when it resolves to
57
+ * neither, so fall back to a hardcoded list then.
58
+ *
59
+ * `graph` is what says which definition a name reaches here, because scoping, shadowing and control flow
60
+ * decide that and a name alone cannot. It therefore needs a finished graph rather than one under
61
+ * construction. Cost is one {@link Dataflow.origin} lookup plus, for a package call, decoding that one
62
+ * function.
63
+ * @param call - The call whose arguments are to be bound.
64
+ * @param graph - The finished graph the call was analyzed into.
65
+ * @param ctx - The analyzer context the database and the assumed versions come from.
66
+ * @returns Per formal name the argument bound to it, `undefined` if the formals could not be found.
67
+ */
68
+ readonly toDefinition: <Info>(this: void, call: RFunctionCall<Info & ParentInformation>, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext) => ReadonlyMap<string, RArgument<Info & ParentInformation>> | undefined;
69
+ };
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MatchArgs = void 0;
4
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
5
+ const graph_1 = require("./graph");
6
+ const edge_1 = require("./edge");
7
+ const logger_1 = require("../logger");
8
+ const arg_matching_1 = require("../../util/arg-matching");
9
+ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
10
+ const signature_db_1 = require("../../project/sigdb/signature-db");
11
+ const df_helper_1 = require("./df-helper");
12
+ const identifier_1 = require("../environments/identifier");
13
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
14
+ /** the argument names in the shape {@link matchArgumentsToParameters} takes, unnamed arguments as `undefined` */
15
+ function graphArgumentNames(args) {
16
+ return args.map(a => graph_1.FunctionArgument.isNamed(a) ? a.name : undefined);
17
+ }
18
+ /**
19
+ * R's argument matching, as {@link matchArgumentsToParameters} implements it. Pick by what you hold:
20
+ *
21
+ * - {@link MatchArgs.toNames|toNames} - AST arguments and the formal names
22
+ * - {@link MatchArgs.toSpec|toSpec} - graph arguments and the formals (a spec or a database signature)
23
+ * - {@link MatchArgs.onCallAndLink|onCallAndLink} - as `toSpec`, and **adds the argument edges to the graph**
24
+ * - {@link MatchArgs.toDefinition|toDefinition} - only the call, the formals are looked up for you
25
+ * @example
26
+ * ```ts
27
+ * MatchArgs.toNames(call.arguments, ['x', 'value']).get('value');
28
+ * MatchArgs.toSpec(args, { file: 'fileId', '...': '...' }).get('fileId');
29
+ * ```
30
+ */
31
+ exports.MatchArgs = {
32
+ name: 'MatchArgs',
33
+ /**
34
+ * Binds a call's AST `args` to the formal `paramNames`. An empty argument (`f(1, ,3)`) takes its formal but
35
+ * never appears here. Arguments falling to `...` share that key, so only the last survives; use
36
+ * {@link MatchArgs.toSpec} to keep them all.
37
+ * @param args - The arguments as they stand in the normalized AST.
38
+ * @param paramNames - The formals of the called function, in order.
39
+ * @returns Per formal name the argument bound to it.
40
+ */
41
+ toNames(args, paramNames) {
42
+ const matched = (0, arg_matching_1.matchArgumentsToParameters)(args.map(a => a === r_function_call_1.EmptyArgument ? undefined : a.name?.content), paramNames);
43
+ const bound = new Map();
44
+ for (let i = 0; i < args.length; i++) {
45
+ const arg = args[i], param = matched[i];
46
+ if (arg !== r_function_call_1.EmptyArgument && param !== undefined) {
47
+ bound.set(paramNames[param], arg);
48
+ }
49
+ }
50
+ return bound;
51
+ },
52
+ /**
53
+ * Binds a call's graph `args` against the formals, reading nothing from the graph, so it also serves a
54
+ * function whose parameters are not in the AST at all. Name `'...'` in a specification unless the function
55
+ * really has none, as that is what collects arguments finding no formal of their own.
56
+ * @param args - The arguments as the graph holds them, see {@link convertFnArguments}.
57
+ * @param params - Formal name to the target it stands for, or a signature whose names are the targets.
58
+ * @returns Per target the ids bound to it.
59
+ */
60
+ toSpec(args, params) {
61
+ let spec = params;
62
+ if (Array.isArray(params)) {
63
+ spec = {};
64
+ for (const p of params) {
65
+ spec[p.name] = p.name;
66
+ }
67
+ }
68
+ const paramNames = Object.keys(spec);
69
+ const matched = (0, arg_matching_1.matchArgumentsToParameters)(graphArgumentNames(args), paramNames);
70
+ const maps = new Map();
71
+ for (let i = 0; i < args.length; i++) {
72
+ const arg = args[i], param = matched[i];
73
+ if (arg === r_function_call_1.EmptyArgument || param === undefined) {
74
+ continue;
75
+ }
76
+ const target = spec[paramNames[param]];
77
+ const known = maps.get(target);
78
+ if (known) {
79
+ known.push(arg.nodeId);
80
+ }
81
+ else {
82
+ maps.set(target, [arg.nodeId]);
83
+ }
84
+ }
85
+ return maps;
86
+ },
87
+ /**
88
+ * Binds a call's graph `args` to the `params` of the definition it calls **and mutates `graph`**, adding an
89
+ * {@link EdgeType.DefinesOnCall} and a {@link EdgeType.DefinedByOnCall} edge per bound pair. It is the only
90
+ * member here that writes anything.
91
+ * @param args - The arguments as the graph holds them.
92
+ * @param params - The parameters of the called definition, in order.
93
+ * @param graph - The graph the edges are added to.
94
+ * @returns The argument id to parameter id mapping the edges were drawn for.
95
+ */
96
+ onCallAndLink(args, params, graph) {
97
+ const matched = (0, arg_matching_1.matchArgumentsToParameters)(graphArgumentNames(args), params.map(p => p?.special ? arg_matching_1.DotsParameterName : p?.name?.content));
98
+ const maps = new Map();
99
+ for (let i = 0; i < args.length; i++) {
100
+ const arg = args[i];
101
+ if (arg === r_function_call_1.EmptyArgument) {
102
+ continue;
103
+ }
104
+ const param = matched[i];
105
+ const pid = param === undefined ? undefined : params[param].name?.info.id;
106
+ const aid = arg.nodeId;
107
+ if (pid === undefined) {
108
+ logger_1.dataflowLogger.warn(`skipping argument ${i} (id: ${aid}) as there is no corresponding parameter - R should block that`);
109
+ continue;
110
+ }
111
+ graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
112
+ graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
113
+ maps.set(aid, pid);
114
+ }
115
+ return maps;
116
+ },
117
+ /**
118
+ * Binds a call's arguments to the formals of whatever it calls, looking the formals up itself. It takes them
119
+ * from the {@link RFunctionDefinition} the call resolves to in user code, and from the database signature at
120
+ * the version the analysis assumes otherwise (see {@link SignatureDb}). `undefined` when it resolves to
121
+ * neither, so fall back to a hardcoded list then.
122
+ *
123
+ * `graph` is what says which definition a name reaches here, because scoping, shadowing and control flow
124
+ * decide that and a name alone cannot. It therefore needs a finished graph rather than one under
125
+ * construction. Cost is one {@link Dataflow.origin} lookup plus, for a package call, decoding that one
126
+ * function.
127
+ * @param call - The call whose arguments are to be bound.
128
+ * @param graph - The finished graph the call was analyzed into.
129
+ * @param ctx - The analyzer context the database and the assumed versions come from.
130
+ * @returns Per formal name the argument bound to it, `undefined` if the formals could not be found.
131
+ */
132
+ toDefinition(call, graph, ctx) {
133
+ const names = formalsOf(call, graph, ctx);
134
+ return names === undefined ? undefined : exports.MatchArgs.toNames(call.arguments, names);
135
+ }
136
+ };
137
+ /**
138
+ * The formals {@link MatchArgs.toDefinition} binds against. User code is tried first because its parameters are
139
+ * already in the AST, so the common case never touches the signature database.
140
+ */
141
+ function formalsOf(call, graph, ctx) {
142
+ const origins = df_helper_1.Dataflow.origin(graph, call.info.id);
143
+ if (origins === undefined) {
144
+ return undefined;
145
+ }
146
+ for (const origin of origins) {
147
+ if (origin.type === 2 /* OriginType.FunctionCallOrigin */ && !node_id_1.NodeId.isBuiltIn(origin.id)) {
148
+ const definition = graph.idMap?.get(origin.id);
149
+ if (r_function_definition_1.RFunctionDefinition.is(definition)) {
150
+ return definition.parameters.map(p => p.special ? arg_matching_1.DotsParameterName : p.name.content);
151
+ }
152
+ }
153
+ }
154
+ let db;
155
+ for (const origin of origins) {
156
+ if (origin.type !== 3 /* OriginType.BuiltInFunctionOrigin */) {
157
+ continue;
158
+ }
159
+ db ??= (0, signature_db_1.signatureDbOf)(ctx.deps);
160
+ const found = db.parametersOf(identifier_1.Identifier.toQualified([origin], origin.fn.name) ?? origin.fn.name);
161
+ if (found !== undefined && found.length > 0) {
162
+ return found;
163
+ }
164
+ }
165
+ return undefined;
166
+ }
167
+ //# sourceMappingURL=match-args.js.map
@@ -133,6 +133,20 @@ export type KillReference =
133
133
  export interface DataflowCfgInformation {
134
134
  /** The entry node into the subgraph */
135
135
  entryPoint: NodeId;
136
+ /**
137
+ * The node control flow enters this subtree at.
138
+ * Control flow is modeled in post-order (operands are evaluated before the operator that consumes them),
139
+ * so for compound constructs this is not the {@link DataflowCfgInformation#entryPoint|entryPoint}
140
+ * (which names the value-producing node) but the first node that is actually evaluated.
141
+ * Left `undefined` whenever both coincide, which is the case for all leaves.
142
+ */
143
+ cfgEntry?: NodeId;
144
+ /**
145
+ * The node control flow leaves this subtree at, joining the branches of the construct if it has any.
146
+ * Left `undefined` whenever the {@link DataflowCfgInformation#exitPoints|exitPoints} already name it,
147
+ * which is the case whenever the construct has a single point of exit.
148
+ */
149
+ cfgExit?: NodeId;
136
150
  /**
137
151
  * All already identified exit points (active 'return'/'break'/'next'-likes) of the respective structure.
138
152
  * This also tracks (local knowledge of) exceptions thrown within the structure.
@@ -0,0 +1,102 @@
1
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import type { DataflowGraph } from '../graph/graph';
3
+ import type { ControlDependency, DataflowCfgInformation } from '../info';
4
+ import { ExitPointType } from '../info';
5
+ /**
6
+ * Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
7
+ * The {@link ControlFlowGraph} is a view on what is recorded here.
8
+ *
9
+ * The control flow is modeled in post-order: everything a construct is made of runs before the construct
10
+ * itself, so its own vertex is where its parts join again and where it is left.
11
+ */
12
+ export declare const ControlFlow: {
13
+ readonly name: "ControlFlow";
14
+ /**
15
+ * The node control flow enters the given subtree at.
16
+ * @example
17
+ * ```r
18
+ * x + 1 # the `+` is entered at `x`
19
+ * ```
20
+ */
21
+ readonly entryOf: (this: void, info: DataflowCfgInformation) => NodeId;
22
+ /**
23
+ * Whether the node runs as a statement of the program instead of as part of a larger expression.
24
+ * Assignments count as statements wherever they stand.
25
+ * @example
26
+ * ```r
27
+ * print(x + 1) # the call is a statement, `x + 1` and `x` are expressions
28
+ * ```
29
+ * @see {@link ControlFlow#isExpression|isExpression()} - for the other kind
30
+ */
31
+ readonly isStatement: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
32
+ /**
33
+ * Whether the node runs as part of a larger expression instead of as a statement of its own.
34
+ * @example
35
+ * ```r
36
+ * print(x + 1) # `x + 1` and `x` are expressions, the call is a statement
37
+ * ```
38
+ * @see {@link ControlFlow#isStatement|isStatement()} - for the other kind
39
+ */
40
+ readonly isExpression: (this: void, graph: DataflowGraph, id: NodeId) => boolean;
41
+ /**
42
+ * Whether the subtree can be left normally instead of always jumping away.
43
+ * @example
44
+ * ```r
45
+ * { 1 } # can complete
46
+ * { break } # cannot
47
+ * ```
48
+ */
49
+ readonly canComplete: (this: void, info: DataflowCfgInformation) => boolean;
50
+ /**
51
+ * Whatever `from` completes at continues with `next`.
52
+ * @example
53
+ * ```r
54
+ * f(); g() # the call to `g` continues what `f` completes
55
+ * ```
56
+ * @see {@link ControlFlow#branchesTo|branchesTo()} - if it only continues under a condition
57
+ */
58
+ readonly continuesWith: (this: void, graph: DataflowGraph, from: DataflowCfgInformation, next: NodeId) => void;
59
+ /**
60
+ * Whatever `from` completes at continues with `target`, but only under the given control dependency.
61
+ * Hand over the very dependency the vertices behind the branch carry, so both say the same thing.
62
+ * @example
63
+ * ```r
64
+ * if(u) a else b # `a` is reached when `u` holds, `b` when it does not
65
+ * ```
66
+ * @see {@link ControlFlow#continuesWith|continuesWith()} - if it always continues
67
+ */
68
+ readonly branchesTo: (this: void, graph: DataflowGraph, from: DataflowCfgInformation, target: NodeId, cd: ControlDependency) => void;
69
+ /**
70
+ * Every jump of the given kind within `from` lands on `target`.
71
+ * @example
72
+ * ```r
73
+ * while(u) { break } # the `break` lands on the loop it leaves
74
+ * ```
75
+ */
76
+ readonly jumpsTo: (this: void, graph: DataflowGraph, from: DataflowCfgInformation, kind: ExitPointType, target: NodeId) => void;
77
+ /**
78
+ * The parts run one after the other and the last one continues with `last`, if it is given.
79
+ * Parts that are `undefined` are skipped, which keeps optional arguments cheap to handle.
80
+ * @example
81
+ * ```r
82
+ * f(a, b) # `a`, then `b`, then the call
83
+ * ```
84
+ * @returns the node control flow enters the sequence at, or `last` if there is nothing to enter
85
+ */
86
+ readonly inSequence: (this: void, graph: DataflowGraph, parts: readonly (DataflowCfgInformation | undefined)[], last?: NodeId) => NodeId | undefined;
87
+ /**
88
+ * The parts before `from` run in sequence, the ones after it are alternatives of which at most one runs.
89
+ * Whichever one it is, control joins on `joinsAt`.
90
+ * @example
91
+ * ```r
92
+ * switch(k, a = 1, b = 2) # `k`, then one arm, then the switch
93
+ * ```
94
+ * @param graph - the graph to record in
95
+ * @param parts - the arguments of the call, in the order they run
96
+ * @param from - the index the alternatives start at
97
+ * @param joinsAt - the call the alternatives belong to
98
+ * @param hasDefault - whether one alternative runs when none of the others matched
99
+ * @returns the node control flow enters the call at
100
+ */
101
+ readonly picksOneOf: (this: void, graph: DataflowGraph, parts: readonly (DataflowCfgInformation | undefined)[], from: number, joinsAt: NodeId, hasDefault: boolean) => NodeId | undefined;
102
+ };
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ControlFlow = void 0;
4
+ const edge_1 = require("../graph/edge");
5
+ const r_binary_op_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
6
+ /**
7
+ * Records the control flow of a program in the {@link DataflowGraph} while the dataflow analysis walks it.
8
+ * The {@link ControlFlowGraph} is a view on what is recorded here.
9
+ *
10
+ * The control flow is modeled in post-order: everything a construct is made of runs before the construct
11
+ * itself, so its own vertex is where its parts join again and where it is left.
12
+ */
13
+ exports.ControlFlow = {
14
+ name: 'ControlFlow',
15
+ /**
16
+ * The node control flow enters the given subtree at.
17
+ * @example
18
+ * ```r
19
+ * x + 1 # the `+` is entered at `x`
20
+ * ```
21
+ */
22
+ entryOf(info) {
23
+ return info.cfgEntry ?? info.entryPoint;
24
+ },
25
+ /**
26
+ * Whether the node runs as a statement of the program instead of as part of a larger expression.
27
+ * Assignments count as statements wherever they stand.
28
+ * @example
29
+ * ```r
30
+ * print(x + 1) # the call is a statement, `x + 1` and `x` are expressions
31
+ * ```
32
+ * @see {@link ControlFlow#isExpression|isExpression()} - for the other kind
33
+ */
34
+ isStatement(graph, id) {
35
+ const node = graph.idMap?.get(id);
36
+ if (node === undefined) {
37
+ return false;
38
+ }
39
+ return node.info.role === "el-c" /* RoleInParent.ExpressionListChild */
40
+ || (r_binary_op_1.RBinaryOp.is(node) && node.flavor === 'assignment');
41
+ },
42
+ /**
43
+ * Whether the node runs as part of a larger expression instead of as a statement of its own.
44
+ * @example
45
+ * ```r
46
+ * print(x + 1) # `x + 1` and `x` are expressions, the call is a statement
47
+ * ```
48
+ * @see {@link ControlFlow#isStatement|isStatement()} - for the other kind
49
+ */
50
+ isExpression(graph, id) {
51
+ return graph.idMap?.get(id) !== undefined && !exports.ControlFlow.isStatement(graph, id);
52
+ },
53
+ /**
54
+ * Whether the subtree can be left normally instead of always jumping away.
55
+ * @example
56
+ * ```r
57
+ * { 1 } # can complete
58
+ * { break } # cannot
59
+ * ```
60
+ */
61
+ canComplete(info) {
62
+ if (info.cfgExit !== undefined) {
63
+ return true;
64
+ }
65
+ for (const exit of info.exitPoints) {
66
+ if (exit.type === 0 /* ExitPointType.Default */) {
67
+ return true;
68
+ }
69
+ }
70
+ return false;
71
+ },
72
+ /**
73
+ * Whatever `from` completes at continues with `next`.
74
+ * @example
75
+ * ```r
76
+ * f(); g() # the call to `g` continues what `f` completes
77
+ * ```
78
+ * @see {@link ControlFlow#branchesTo|branchesTo()} - if it only continues under a condition
79
+ */
80
+ continuesWith(graph, from, next) {
81
+ if (from.cfgExit !== undefined) {
82
+ graph.addEdge(from.cfgExit, next, edge_1.EdgeType.FlowEdge);
83
+ return;
84
+ }
85
+ for (const exit of from.exitPoints) {
86
+ if (exit.type === 0 /* ExitPointType.Default */) {
87
+ graph.addEdge(exit.nodeId, next, edge_1.EdgeType.FlowEdge);
88
+ }
89
+ }
90
+ },
91
+ /**
92
+ * Whatever `from` completes at continues with `target`, but only under the given control dependency.
93
+ * Hand over the very dependency the vertices behind the branch carry, so both say the same thing.
94
+ * @example
95
+ * ```r
96
+ * if(u) a else b # `a` is reached when `u` holds, `b` when it does not
97
+ * ```
98
+ * @see {@link ControlFlow#continuesWith|continuesWith()} - if it always continues
99
+ */
100
+ branchesTo(graph, from, target, cd) {
101
+ if (from.cfgExit !== undefined) {
102
+ graph.addEdge(from.cfgExit, target, edge_1.EdgeType.ControlEdge, { cd });
103
+ return;
104
+ }
105
+ for (const exit of from.exitPoints) {
106
+ if (exit.type === 0 /* ExitPointType.Default */) {
107
+ graph.addEdge(exit.nodeId, target, edge_1.EdgeType.ControlEdge, { cd });
108
+ }
109
+ }
110
+ },
111
+ /**
112
+ * Every jump of the given kind within `from` lands on `target`.
113
+ * @example
114
+ * ```r
115
+ * while(u) { break } # the `break` lands on the loop it leaves
116
+ * ```
117
+ */
118
+ jumpsTo(graph, from, kind, target) {
119
+ for (const exit of from.exitPoints) {
120
+ if (exit.type === kind) {
121
+ graph.addEdge(exit.nodeId, target, edge_1.EdgeType.FlowEdge);
122
+ }
123
+ }
124
+ },
125
+ /**
126
+ * The parts run one after the other and the last one continues with `last`, if it is given.
127
+ * Parts that are `undefined` are skipped, which keeps optional arguments cheap to handle.
128
+ * @example
129
+ * ```r
130
+ * f(a, b) # `a`, then `b`, then the call
131
+ * ```
132
+ * @returns the node control flow enters the sequence at, or `last` if there is nothing to enter
133
+ */
134
+ inSequence(graph, parts, last) {
135
+ let entry = undefined;
136
+ let previous = undefined;
137
+ for (const part of parts) {
138
+ if (part === undefined) {
139
+ continue;
140
+ }
141
+ if (previous === undefined) {
142
+ entry = exports.ControlFlow.entryOf(part);
143
+ }
144
+ else {
145
+ exports.ControlFlow.continuesWith(graph, previous, exports.ControlFlow.entryOf(part));
146
+ }
147
+ previous = part;
148
+ }
149
+ if (previous !== undefined && last !== undefined) {
150
+ exports.ControlFlow.continuesWith(graph, previous, last);
151
+ }
152
+ return entry ?? last;
153
+ },
154
+ /**
155
+ * The parts before `from` run in sequence, the ones after it are alternatives of which at most one runs.
156
+ * Whichever one it is, control joins on `joinsAt`.
157
+ * @example
158
+ * ```r
159
+ * switch(k, a = 1, b = 2) # `k`, then one arm, then the switch
160
+ * ```
161
+ * @param graph - the graph to record in
162
+ * @param parts - the arguments of the call, in the order they run
163
+ * @param from - the index the alternatives start at
164
+ * @param joinsAt - the call the alternatives belong to
165
+ * @param hasDefault - whether one alternative runs when none of the others matched
166
+ * @returns the node control flow enters the call at
167
+ */
168
+ picksOneOf(graph, parts, from, joinsAt, hasDefault) {
169
+ let entry = undefined;
170
+ let selector = undefined;
171
+ for (let i = 0; i < from; i++) {
172
+ const part = parts[i];
173
+ if (part === undefined) {
174
+ continue;
175
+ }
176
+ if (selector === undefined) {
177
+ entry = exports.ControlFlow.entryOf(part);
178
+ }
179
+ else {
180
+ exports.ControlFlow.continuesWith(graph, selector, exports.ControlFlow.entryOf(part));
181
+ }
182
+ selector = part;
183
+ }
184
+ for (let i = from; i < parts.length; i++) {
185
+ const alternative = parts[i];
186
+ if (alternative === undefined) {
187
+ continue;
188
+ }
189
+ if (selector !== undefined) {
190
+ exports.ControlFlow.branchesTo(graph, selector, exports.ControlFlow.entryOf(alternative), { id: joinsAt, when: true });
191
+ }
192
+ exports.ControlFlow.continuesWith(graph, alternative, joinsAt);
193
+ }
194
+ if (selector !== undefined && !hasDefault) {
195
+ exports.ControlFlow.branchesTo(graph, selector, joinsAt, { id: joinsAt, when: false });
196
+ }
197
+ return entry ?? joinsAt;
198
+ }
199
+ };
200
+ //# sourceMappingURL=control-flow.js.map
@@ -2,7 +2,7 @@ import { DefaultMap } from '../../util/collections/defaultmap';
2
2
  import type { BuiltIn } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
4
  import { Identifier, type IdentifierReference } from '../environments/identifier';
5
- import { type DataflowGraph, FunctionArgument } from '../graph/graph';
5
+ import type { FunctionArgument, DataflowGraph } from '../graph/graph';
6
6
  import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
7
7
  import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
8
8
  import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexInfo } from '../graph/vertex';
@@ -18,31 +18,15 @@ export declare function findNonLocalReads(graph: DataflowGraph, ignores?: Readon
18
18
  */
19
19
  export declare function produceNameSharedIdMap(references: IdentifierReference[]): NameIdMap;
20
20
  /**
21
- * {@link matchArgumentsToParameters|Matches} the arguments to the parameters and links them in the graph,
21
+ * {@link MatchArgs.onCall|Matches} the arguments to the parameters and links them in the graph,
22
22
  * returning the resolved map from argument ids to parameter ids.
23
- * If you just want to match by name, use {@link pMatch}.
23
+ * @useInstead {@link MatchArgs.onCallAndLink}
24
24
  */
25
25
  export declare function linkArgumentsOnCall(args: readonly FunctionArgument[], params: readonly RParameter<ParentInformation>[], graph: DataflowGraph): Map<NodeId, NodeId>;
26
26
  /**
27
- * {@link matchArgumentsToParameters|Matches} the arguments against a parameter specification, returning the
28
- * arguments bound to each target. Unlike {@link linkArgumentsOnCall} this touches no graph, so it also works
29
- * for a specification without parameters in the AST.
30
- * @example
31
- * ```ts
32
- * const parameterSpec = {
33
- * 'paramName': 'paramId',
34
- * 'anotherParamName': 'anotherParamId',
35
- * // we recommend to always add '...' to your specification
36
- * // this way you can collect all arguments that could not be matched!
37
- * '...': '...'
38
- * } as const;
39
- *
40
- * const match = pMatch(convertFnArguments(args), parameterSpec);
41
- * const addParam = match.get('paramId');
42
- * ```
43
- * @note
44
- * To obtain the arguments from a {@link RFunctionCall}[], either use {@link processAllArguments} (also available via {@link processKnownFunctionCall})
45
- * or convert them with {@link convertFnArguments}.
27
+ * {@link MatchArgs.toSpec|Matches} the arguments against a parameter specification, returning the
28
+ * arguments bound to each target.
29
+ * @useInstead {@link MatchArgs.toSpec}
46
30
  */
47
31
  export declare function pMatch<Targets extends NodeId>(args: readonly FunctionArgument[], params: Record<string, Targets>): Map<Targets, NodeId[]>;
48
32
  /**
@@ -81,15 +65,6 @@ export declare function getAllFunctionCallTargets(call: NodeId, graph: DataflowG
81
65
  * To know what fdefs the definition of `x` in the first line links to, you can use {@link getAllLinkedFunctionDefinitions|this function}.
82
66
  */
83
67
  export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadIds: ReadonlySet<NodeId>, dataflowGraph: DataflowGraph): [Set<Required<DataflowGraphVertexFunctionDefinition>>, Set<BuiltIn>];
84
- /**
85
- * This method links a set of read variables to definitions in an environment.
86
- * @param referencesToLinkAgainstEnvironment - The set of references to link against the environment
87
- * @param environmentInformation - The environment information to link against
88
- * @param givenInputs - The existing list of inputs that might be extended
89
- * @param graph - The graph to enter the found links
90
- * @param maybeForRemaining - Each input that can not be linked, will be added to `givenInputs`. If this flag is `true`, it will be marked as `maybe`.
91
- * @returns the given inputs, possibly extended with the remaining inputs (those of `referencesToLinkAgainstEnvironment` that could not be linked against the environment)
92
- */
93
68
  /**
94
69
  * Links every name in the expression rooted at `expr` against `environment`, as if it were written there, and
95
70
  * hands back what stays unresolved. This is how an expression that was captured elsewhere is read here.