@eagleoutice/flowr 2.14.0 → 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 (461) hide show
  1. package/README.md +169 -91
  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 +18 -11
  21. package/benchmark/calibration.js +37 -27
  22. package/benchmark/slicer.d.ts +9 -2
  23. package/benchmark/slicer.js +44 -37
  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/benchmark-app.js +4 -1
  34. package/cli/benchmark-helper-app.d.ts +1 -0
  35. package/cli/benchmark-helper-app.js +2 -2
  36. package/cli/common/options.d.ts +5 -0
  37. package/cli/common/options.js +1 -0
  38. package/cli/common/scripts-info.d.ts +5 -0
  39. package/cli/repl/commands/repl-dataflow.js +70 -27
  40. package/cli/repl/core.d.ts +1 -1
  41. package/cli/repl/core.js +1 -1
  42. package/cli/repl/execute.d.ts +2 -2
  43. package/cli/repl/execute.js +2 -2
  44. package/cli/repl/parser/slice-query-parser.js +2 -1
  45. package/cli/repl/server/connection.d.ts +4 -0
  46. package/cli/repl/server/connection.js +19 -16
  47. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  48. package/config.d.ts +6 -0
  49. package/config.js +12 -9
  50. package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
  51. package/control-flow/basic-cfg-guided-visitor.js +37 -24
  52. package/control-flow/cfg-dead-code.js +44 -33
  53. package/control-flow/cfg-properties.js +2 -2
  54. package/control-flow/cfg-simplification.js +6 -5
  55. package/control-flow/cfg-to-basic-blocks.js +11 -13
  56. package/control-flow/control-flow-graph.d.ts +179 -189
  57. package/control-flow/control-flow-graph.js +400 -263
  58. package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
  59. package/control-flow/dfg-cfg-guided-visitor.js +17 -13
  60. package/control-flow/diff-cfg.js +6 -14
  61. package/control-flow/happens-before.js +5 -4
  62. package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
  63. package/control-flow/semantic-cfg-guided-visitor.js +6 -26
  64. package/control-flow/simple-visitor.js +14 -15
  65. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
  66. package/control-flow/useless-loop.js +18 -14
  67. package/core/steps/all/core/20-dataflow.d.ts +1 -3
  68. package/core/steps/pipeline/default-pipelines.d.ts +141 -157
  69. package/dataflow/cluster.js +7 -0
  70. package/dataflow/environments/apply-kill.d.ts +6 -0
  71. package/dataflow/environments/apply-kill.js +64 -32
  72. package/dataflow/environments/built-in-props.d.ts +10 -2
  73. package/dataflow/environments/built-in-props.js +9 -1
  74. package/dataflow/environments/built-in.d.ts +6 -3
  75. package/dataflow/environments/built-in.js +8 -5
  76. package/dataflow/environments/clone.d.ts +3 -3
  77. package/dataflow/environments/clone.js +5 -5
  78. package/dataflow/environments/default-builtin-config.d.ts +188 -8
  79. package/dataflow/environments/default-builtin-config.js +112 -39
  80. package/dataflow/environments/environment.d.ts +9 -1
  81. package/dataflow/environments/environment.js +25 -7
  82. package/dataflow/environments/identifier.d.ts +12 -1
  83. package/dataflow/environments/identifier.js +4 -1
  84. package/dataflow/environments/query-fn-props.d.ts +6 -0
  85. package/dataflow/environments/query-fn-props.js +20 -0
  86. package/dataflow/environments/resolve-by-name.d.ts +7 -0
  87. package/dataflow/environments/resolve-by-name.js +26 -2
  88. package/dataflow/environments/resolve-helper.d.ts +3 -1
  89. package/dataflow/environments/resolve-helper.js +2 -0
  90. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
  91. package/dataflow/eval/resolve/alias-tracking.js +2 -2
  92. package/dataflow/eval/resolve/match-arguments.js +7 -5
  93. package/dataflow/eval/resolve/node-value.d.ts +3 -1
  94. package/dataflow/eval/resolve/node-value.js +12 -0
  95. package/dataflow/eval/resolve/resolve-argument.js +5 -4
  96. package/dataflow/eval/resolve/resolve-operators.js +10 -7
  97. package/dataflow/eval/resolve/resolve-strings.js +2 -2
  98. package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
  99. package/dataflow/eval/resolve/resolve-working-directory.js +5 -5
  100. package/dataflow/eval/resolve/resolve.js +3 -2
  101. package/dataflow/eval/values/general.js +8 -5
  102. package/dataflow/extractor.d.ts +1 -4
  103. package/dataflow/extractor.js +11 -10
  104. package/dataflow/fn/exceptions-of-function.d.ts +6 -2
  105. package/dataflow/fn/exceptions-of-function.js +85 -38
  106. package/dataflow/fn/strict-function.d.ts +40 -0
  107. package/dataflow/fn/strict-function.js +339 -0
  108. package/dataflow/graph/call-graph.js +2 -2
  109. package/dataflow/graph/df-helper.d.ts +17 -2
  110. package/dataflow/graph/df-helper.js +19 -3
  111. package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
  112. package/dataflow/graph/diff-dataflow-graph.js +19 -2
  113. package/dataflow/graph/edge.d.ts +38 -2
  114. package/dataflow/graph/edge.js +32 -2
  115. package/dataflow/graph/graph.d.ts +32 -5
  116. package/dataflow/graph/graph.js +65 -4
  117. package/dataflow/graph/match-args.d.ts +69 -0
  118. package/dataflow/graph/match-args.js +167 -0
  119. package/dataflow/info.d.ts +40 -0
  120. package/dataflow/info.js +28 -1
  121. package/dataflow/internal/control-flow.d.ts +102 -0
  122. package/dataflow/internal/control-flow.js +200 -0
  123. package/dataflow/internal/linker.d.ts +6 -31
  124. package/dataflow/internal/linker.js +24 -81
  125. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  126. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
  127. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
  128. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
  129. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  130. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
  131. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
  132. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
  133. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  134. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
  135. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
  136. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
  137. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  138. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  139. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
  140. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
  142. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  143. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
  144. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
  145. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  146. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
  147. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  148. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
  149. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  150. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
  151. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
  152. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
  153. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
  154. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
  155. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  156. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
  157. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
  158. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
  160. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
  161. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  162. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
  163. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
  164. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
  165. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
  166. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
  167. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
  168. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +97 -33
  169. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
  170. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
  171. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  172. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -12
  173. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
  174. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  175. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
  176. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
  177. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  178. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
  179. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  180. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
  181. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
  182. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
  183. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
  184. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -8
  185. package/dataflow/internal/process/functions/call/common.js +5 -6
  186. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  187. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
  188. package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
  189. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
  190. package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
  191. package/dataflow/internal/process/functions/call/nse.js +6 -1
  192. package/dataflow/internal/process/functions/call/quoted.js +2 -2
  193. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
  194. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  195. package/dataflow/internal/process/functions/process-argument.js +12 -4
  196. package/dataflow/internal/process/functions/process-parameter.js +13 -0
  197. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  198. package/dataflow/internal/process/process-named-call.js +9 -7
  199. package/documentation/data/server/doc-data-server-messages.js +4 -4
  200. package/documentation/doc-readme.js +45 -0
  201. package/documentation/doc-util/doc-cfg.d.ts +8 -7
  202. package/documentation/doc-util/doc-cfg.js +10 -10
  203. package/documentation/doc-util/doc-playground.d.ts +12 -0
  204. package/documentation/doc-util/doc-playground.js +21 -0
  205. package/documentation/doc-util/doc-query.d.ts +4 -1
  206. package/documentation/doc-util/doc-query.js +4 -2
  207. package/documentation/wiki-absint.d.ts +3 -4
  208. package/documentation/wiki-absint.js +12 -5
  209. package/documentation/wiki-analyzer.js +2 -2
  210. package/documentation/wiki-cfg.js +101 -106
  211. package/documentation/wiki-core.js +1 -1
  212. package/documentation/wiki-dataflow-graph.js +85 -53
  213. package/documentation/wiki-linter.js +16 -1
  214. package/documentation/wiki-linting-and-testing.js +1 -16
  215. package/documentation/wiki-mk/doc-maker.js +6 -4
  216. package/documentation/wiki-query.js +67 -4
  217. package/documentation/wiki-signature-database.js +28 -2
  218. package/linter/linter-fix.d.ts +16 -0
  219. package/linter/linter-fix.js +104 -0
  220. package/linter/linter-format.d.ts +18 -1
  221. package/linter/linter-format.js +31 -1
  222. package/linter/linter-output.js +47 -11
  223. package/linter/linter-rules.d.ts +64 -9
  224. package/linter/linter-rules.js +5 -1
  225. package/linter/rules/absolute-path.js +4 -2
  226. package/linter/rules/dataframe-access-validation.js +6 -7
  227. package/linter/rules/deprecated-functions.d.ts +107 -10
  228. package/linter/rules/deprecated-functions.js +309 -23
  229. package/linter/rules/file-path-validity.js +5 -4
  230. package/linter/rules/function-finder-util.d.ts +6 -0
  231. package/linter/rules/function-finder-util.js +21 -13
  232. package/linter/rules/naming-convention.js +1 -1
  233. package/linter/rules/network-functions.d.ts +3 -3
  234. package/linter/rules/stop-with-call-arg.js +2 -2
  235. package/linter/rules/unclosed-connection.d.ts +44 -0
  236. package/linter/rules/unclosed-connection.js +200 -0
  237. package/linter/rules/undefined-symbol-util.js +6 -4
  238. package/linter/rules/undefined-symbol.js +2 -2
  239. package/linter/rules/unused-definition.js +8 -4
  240. package/linter/rules/unused-import.d.ts +60 -0
  241. package/linter/rules/unused-import.js +179 -0
  242. package/package.json +5 -8
  243. package/project/attached-packages.js +2 -1
  244. package/project/cache/flowr-analyzer-cache.d.ts +2 -5
  245. package/project/cache/flowr-analyzer-cache.js +4 -7
  246. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
  247. package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
  248. package/project/cache/flowr-cache.d.ts +9 -0
  249. package/project/cache/flowr-cache.js +19 -0
  250. package/project/context/flowr-analyzer-context.d.ts +7 -3
  251. package/project/context/flowr-analyzer-context.js +15 -9
  252. package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
  253. package/project/context/flowr-analyzer-dependencies-context.js +9 -14
  254. package/project/context/flowr-analyzer-files-context.js +15 -17
  255. package/project/context/flowr-analyzer-meta-context.js +2 -12
  256. package/project/dependency-version-space.d.ts +3 -10
  257. package/project/dependency-version-space.js +10 -9
  258. package/project/flowr-analyzer.d.ts +4 -6
  259. package/project/flowr-analyzer.js +4 -5
  260. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
  261. package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
  262. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
  263. package/project/plugins/file-plugins/files/flowr-namespace-file.js +23 -35
  264. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
  265. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
  266. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
  267. package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
  268. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
  269. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
  270. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
  271. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
  272. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
  273. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
  274. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
  275. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
  276. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
  277. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
  278. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
  279. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
  280. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
  281. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
  282. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
  283. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
  284. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
  285. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
  286. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
  287. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
  288. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
  289. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
  290. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
  291. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
  292. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
  293. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
  294. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
  295. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
  296. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
  297. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
  298. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
  299. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
  300. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
  301. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
  302. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +33 -6
  303. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  304. package/project/sigdb/build.d.ts +2 -2
  305. package/project/sigdb/decode.d.ts +0 -5
  306. package/project/sigdb/decode.js +0 -8
  307. package/project/sigdb/index-format.d.ts +4 -4
  308. package/project/sigdb/manifest.d.ts +5 -3
  309. package/project/sigdb/manifest.js +50 -9
  310. package/project/sigdb/reader.d.ts +48 -13
  311. package/project/sigdb/reader.js +3 -2
  312. package/project/sigdb/schema.d.ts +5 -3
  313. package/project/sigdb/schema.js +2 -2
  314. package/project/sigdb/signature-db.d.ts +69 -0
  315. package/project/sigdb/signature-db.js +54 -0
  316. package/project/sigdb/signature-match.d.ts +10 -5
  317. package/project/sigdb/signature-match.js +13 -8
  318. package/queries/catalog/absint-query/absint-query-executor.js +1 -2
  319. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
  320. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  321. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
  322. package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
  323. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  324. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
  325. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
  326. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
  327. package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
  328. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
  329. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
  330. package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
  331. package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
  332. package/queries/catalog/dependencies-query/link-devices.js +2 -8
  333. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  334. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
  335. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
  336. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
  337. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
  338. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
  339. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
  340. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
  341. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
  342. package/queries/catalog/signature-query/signature-query-executor.js +4 -3
  343. package/queries/catalog/slice-query-options.d.ts +1 -1
  344. package/queries/catalog/slice-query-options.js +1 -1
  345. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  346. package/queries/query-function-filter.d.ts +8 -2
  347. package/queries/query-function-filter.js +11 -1
  348. package/queries/query.d.ts +11 -1
  349. package/queries/query.js +2 -0
  350. package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
  351. package/r-bridge/lang-4.x/ast/model/model.js +4 -4
  352. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  355. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  356. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
  357. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
  358. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  359. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  360. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  361. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  362. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  363. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  364. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  365. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  366. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  367. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  368. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
  369. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
  370. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  371. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  372. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  373. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  374. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  375. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  376. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  377. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  378. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  379. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  380. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
  381. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
  382. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  383. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
  384. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  385. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  386. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
  387. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
  388. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  389. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  390. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  391. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
  392. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  393. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  394. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  395. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  396. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  397. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  398. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
  399. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  400. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
  401. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
  402. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
  403. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  404. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
  405. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
  406. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
  407. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
  408. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
  409. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
  410. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
  411. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
  412. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
  413. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
  414. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
  415. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
  416. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
  417. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
  418. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
  419. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
  420. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
  421. package/reconstruct/inline/source-inline-map.js +3 -3
  422. package/reconstruct/reconstruct.js +6 -4
  423. package/search/flowr-search-builder.d.ts +8 -8
  424. package/search/flowr-search-builder.js +4 -4
  425. package/search/flowr-search-filters.d.ts +2 -2
  426. package/search/flowr-search-filters.js +4 -15
  427. package/search/search-executor/search-enrichers.d.ts +6 -4
  428. package/search/search-executor/search-enrichers.js +44 -5
  429. package/slicing/criterion/filters/all-variables.js +2 -1
  430. package/slicing/criterion/parse.d.ts +2 -2
  431. package/slicing/criterion/parse.js +10 -8
  432. package/slicing/static/fingerprint.js +1 -1
  433. package/slicing/static/slice-call.js +2 -2
  434. package/util/arg-matching.d.ts +3 -0
  435. package/util/arg-matching.js +12 -1
  436. package/util/collections/arrays.d.ts +0 -4
  437. package/util/collections/arrays.js +4 -26
  438. package/util/diff-graph.d.ts +1 -1
  439. package/util/diff-graph.js +17 -3
  440. package/util/diff.d.ts +6 -0
  441. package/util/mermaid/ast.d.ts +1 -1
  442. package/util/mermaid/ast.js +5 -4
  443. package/util/mermaid/cfg.js +130 -24
  444. package/util/mermaid/dfg.js +31 -10
  445. package/util/mermaid/mermaid.js +2 -0
  446. package/util/objects.d.ts +21 -0
  447. package/util/objects.js +60 -0
  448. package/util/prefix.d.ts +1 -1
  449. package/util/simple-df/dfg-ascii.js +14 -3
  450. package/util/text/name-rank.d.ts +1 -1
  451. package/util/text/name-rank.js +1 -1
  452. package/util/text/playground-link.d.ts +131 -0
  453. package/util/text/playground-link.js +214 -0
  454. package/util/text/strings.js +7 -3
  455. package/util/version.js +1 -1
  456. package/control-flow/cfg-builder.d.ts +0 -30
  457. package/control-flow/cfg-builder.js +0 -79
  458. package/control-flow/extract-cfg.d.ts +0 -36
  459. package/control-flow/extract-cfg.js +0 -693
  460. package/project/cfg-kind.d.ts +0 -21
  461. package/project/cfg-kind.js +0 -26
@@ -52,7 +52,7 @@ interface EdgeIndexedGraph<EdgeMap> {
52
52
  export declare const GraphDiff: {
53
53
  readonly name: "GraphDiff";
54
54
  /** Compares all edges of both graphs vertex by vertex, handing each pair to `diffEdges`. */
55
- readonly outgoingEdges: <EdgeMap, Graph extends EdgeIndexedGraph<EdgeMap>>(this: void, ctx: GraphDiffContext<Graph>, diffEdges: (ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: EdgeMap | undefined, rEdges: EdgeMap | undefined) => void) => void;
55
+ readonly outgoingEdges: <EdgeMap, Graph extends EdgeIndexedGraph<EdgeMap>>(this: void, ctx: GraphDiffContext<Graph>, diffEdges: (ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: EdgeMap | undefined, rEdges: EdgeMap | undefined) => void, project?: (edges: EdgeMap) => EdgeMap | undefined) => void;
56
56
  /** Compares the outgoing edges of a single vertex, handing each pair of edges to `diffEdge`. */
57
57
  readonly edges: <Edge, Graph>(this: void, ctx: GraphDiffContext<Graph>, id: NodeId, lEdges: ReadonlyMap<NodeId, Edge> | undefined, rEdges: ReadonlyMap<NodeId, Edge> | undefined, diffEdge: (edge: Edge, otherEdge: Edge, ctx: GraphDiffContext<Graph>, id: NodeId, target: NodeId) => void) => void;
58
58
  };
@@ -58,13 +58,27 @@ function initDiffContext(left, right, config) {
58
58
  }
59
59
  };
60
60
  }
61
+ /**
62
+ * Index the edges of a graph, optionally narrowing every entry to the part the comparison cares about.
63
+ * Sources whose edges the projection drops entirely do not take part in the comparison.
64
+ */
65
+ function collectEdges(graph, project) {
66
+ const result = new Map();
67
+ for (const [id, edges] of graph.edges()) {
68
+ const projected = project ? project(edges) : edges;
69
+ if (projected !== undefined) {
70
+ result.set(id, projected);
71
+ }
72
+ }
73
+ return result;
74
+ }
61
75
  /** The edge-differencing steps shared by the dataflow and the control flow graph diff. */
62
76
  exports.GraphDiff = {
63
77
  name: 'GraphDiff',
64
78
  /** Compares all edges of both graphs vertex by vertex, handing each pair to `diffEdges`. */
65
- outgoingEdges(ctx, diffEdges) {
66
- const lEdges = new Map(ctx.left.edges());
67
- const rEdges = new Map(ctx.right.edges());
79
+ outgoingEdges(ctx, diffEdges, project) {
80
+ const lEdges = collectEdges(ctx.left, project);
81
+ const rEdges = collectEdges(ctx.right, project);
68
82
  if (lEdges.size < rEdges.size && !ctx.config.leftIsSubgraph || lEdges.size > rEdges.size && !ctx.config.rightIsSubgraph) {
69
83
  ctx.report.addComment(`Detected different number of edges! ${ctx.leftname} has ${lEdges.size} (${JSON.stringify(lEdges, json_1.jsonReplacer)}). ${ctx.rightname} has ${rEdges.size} ${JSON.stringify(rEdges, json_1.jsonReplacer)}`);
70
84
  }
package/util/diff.d.ts CHANGED
@@ -50,6 +50,12 @@ export interface GenericDiffConfiguration {
50
50
  * Similar to {@link rightIsSubgraph}, but for the left/first graph.
51
51
  */
52
52
  readonly leftIsSubgraph?: boolean;
53
+ /**
54
+ * Compare the control flow a dataflow graph carries as well.
55
+ * Off by default: the control flow is compared through the control flow graph, so a dataflow comparison
56
+ * that included it would only be repeating that check on a less readable representation.
57
+ */
58
+ readonly compareControlFlow?: boolean;
53
59
  }
54
60
  /**
55
61
  * Computes the difference of two sets and adds human-readable information to the current report
@@ -1,5 +1,5 @@
1
1
  import type { ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
2
- import type { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
2
+ import { RProject } from '../../r-bridge/lang-4.x/ast/model/nodes/r-project';
3
3
  import type { MermaidGraphPrinterInfo } from './info';
4
4
  /**
5
5
  * Serialize the normalized AST to mermaid format
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizedAstToMermaid = normalizedAstToMermaid;
4
4
  exports.normalizedAstToMermaidUrl = normalizedAstToMermaidUrl;
5
- const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
6
- const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
5
+ const r_project_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-project");
7
6
  const flowr_file_1 = require("../../project/context/flowr-file");
8
7
  const info_1 = require("./info");
9
8
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
10
9
  const mermaid_1 = require("./mermaid");
10
+ const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
11
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
11
12
  function identifyMermaidDirection(prefix) {
12
13
  const directionMatch = prefix.match(/flowchart (TD|LR|RL|BT)/);
13
14
  if (directionMatch) {
@@ -34,7 +35,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
34
35
  const roleSuffix = context.role === "el-c" /* RoleInParent.ExpressionListChild */ || context.role === "call-arg" /* RoleInParent.FunctionCallArgument */ || context.role === "param" /* RoleInParent.FunctionDefinitionParameter */ ? `-${context.index}` : '';
35
36
  output += ` n${n.info.parent} -->|"${context.role}${roleSuffix}"| n${n.info.id}\n`;
36
37
  }
37
- if (n.type === type_1.RType.ExpressionList && n.grouping !== undefined) {
38
+ if (r_expression_list_1.RExpressionList.is(n) && n.grouping !== undefined) {
38
39
  output += ` n${n.info.id} -.-|"group-open"| n${n.grouping[0].info.id}\n`;
39
40
  output += ` n${n.info.id} -.-|"group-close"| n${n.grouping[1].info.id}\n`;
40
41
  }
@@ -52,7 +53,7 @@ function normalizedAstToMermaid(ast, { prefix = 'flowchart TD\n', markStyle = in
52
53
  return false;
53
54
  });
54
55
  }
55
- if (ast.type === type_1.RType.Project) {
56
+ if (r_project_1.RProject.is(ast)) {
56
57
  for (const f of ast.files) {
57
58
  // add a subgraph for each file
58
59
  if (ast.files.length !== 1 || (f.filePath && f.filePath !== flowr_file_1.FlowrFile.INLINE_PATH)) {
@@ -9,6 +9,8 @@ const auto_select_defaults_1 = require("../../reconstruct/auto-select/auto-selec
9
9
  const info_1 = require("./info");
10
10
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
11
11
  const mermaid_1 = require("./mermaid");
12
+ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
13
+ const convert_values_1 = require("../../r-bridge/lang-4.x/convert-values");
12
14
  exports.MermaidEntryPointDefaultMarkStyle = 'stroke:cyan,stroke-width:6.5px;';
13
15
  exports.MermaidExitPointDefaultMarkStyle = 'stroke:green,stroke-width:6.5px;';
14
16
  function getLexeme(n) {
@@ -18,28 +20,107 @@ function cfgOfNode(vert, normalizedVertex, id, content, output) {
18
20
  if (normalizedVertex && content !== undefined) {
19
21
  const start = control_flow_graph_1.CfgVertex.isExpression(vert) ? '([' : '[';
20
22
  const end = control_flow_graph_1.CfgVertex.isExpression(vert) ? '])' : ']';
21
- const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${content ? '\n' + mermaid_1.Mermaid.escape(JSON.stringify(content)) : ''}${control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : ''}\`"`;
23
+ /* the code is set in bold so it stands out from the type and id above it */
24
+ const code = content ? `\n**${mermaid_1.Mermaid.escape(content.replaceAll(/\s+/gu, ' '))}**` : '';
25
+ const calls = control_flow_graph_1.CfgVertex.getCallTargets(vert) ? '\n calls:' + mermaid_1.Mermaid.escape(JSON.stringify([...control_flow_graph_1.CfgVertex.getCallTargets(vert)])) : '';
26
+ const name = `"\`${mermaid_1.Mermaid.escape(normalizedVertex.type)} (${id})${code}${calls}\`"`;
22
27
  output += ` n${id}${start}${name}${end}\n`;
23
28
  }
24
29
  else {
25
- output += String(id).endsWith('-exit') ? ` n${id}((${id}))\n` : ` n${id}[[${id}]]\n`;
30
+ output += ` n${id}[[${id}]]\n`;
26
31
  }
27
32
  return output;
28
33
  }
29
34
  const getDirRegex = /flowchart\s+([A-Za-z]+)/;
35
+ /**
36
+ * The vertices that make up each function body, keyed by the definition that holds it.
37
+ * Nothing flows into such a region, so it is reachable only from the entry the definition points at.
38
+ */
39
+ function collectBodies(graph) {
40
+ const bodies = new Map();
41
+ for (const [id] of graph.vertices(false)) {
42
+ const children = graph.childrenOf(id);
43
+ if (children === undefined || children.length === 0) {
44
+ continue;
45
+ }
46
+ const body = new Set();
47
+ const stack = [...children];
48
+ while (stack.length > 0) {
49
+ const current = stack.pop();
50
+ if (body.has(current)) {
51
+ continue;
52
+ }
53
+ body.add(current);
54
+ for (const next of graph.successors(current)) {
55
+ stack.push(next);
56
+ }
57
+ }
58
+ bodies.set(id, [...body]);
59
+ }
60
+ return bodies;
61
+ }
62
+ /**
63
+ * The region a vertex belongs to: the function definition it is part of and whether it sits in its parameter list.
64
+ * A definition itself belongs to the region it is written in, not to the one it opens.
65
+ */
66
+ function regionOf(id, normalizedAst) {
67
+ let current = normalizedAst.idMap.get(id);
68
+ current = current?.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
69
+ let inParameters = false;
70
+ while (current !== undefined) {
71
+ inParameters ||= current.info.role === "param" /* RoleInParent.FunctionDefinitionParameter */;
72
+ if (r_function_definition_1.RFunctionDefinition.is(current)) {
73
+ return `${current.info.id}-${inParameters ? 'parameters' : 'body'}`;
74
+ }
75
+ current = current.info.parent === undefined ? undefined : normalizedAst.idMap.get(current.info.parent);
76
+ }
77
+ return 'top-level';
78
+ }
79
+ /**
80
+ * The code a simplified basic block stands for.
81
+ * Its elements are reconstructed per region, so the parameters of a function do not end up looking like its body,
82
+ * and a run that reconstructs to nothing but braces is named by its vertices instead.
83
+ */
84
+ function blockCode(elems, normalizedAst) {
85
+ const runs = [];
86
+ let lastRegion = undefined;
87
+ for (const elem of elems) {
88
+ const region = regionOf(control_flow_graph_1.CfgVertex.getId(elem), normalizedAst);
89
+ if (region !== lastRegion) {
90
+ runs.push([]);
91
+ lastRegion = region;
92
+ }
93
+ runs[runs.length - 1].push(elem);
94
+ }
95
+ return runs.map(run => {
96
+ const code = (0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(run.map(control_flow_graph_1.CfgVertex.getId)) }, auto_select_defaults_1.doNotAutoSelect).code;
97
+ if (/[\p{L}\p{N}]/u.test(code)) {
98
+ return code;
99
+ }
100
+ /* nothing but braces means these vertices are where a structure is over, so we name them as the graph does */
101
+ return run.map(elem => `${normalizedAst.idMap.get(control_flow_graph_1.CfgVertex.getId(elem))?.type} (${control_flow_graph_1.CfgVertex.getId(elem)})`).join('\n');
102
+ }).join('\n');
103
+ }
104
+ /**
105
+ * Name the condition a branch is decided by, which is where the branch starts from.
106
+ * Within a basic block that is its last element, so an edge still tells what triggers it.
107
+ */
108
+ function conditionName(cfg, normalizedAst, from) {
109
+ const vertex = cfg.graph.getVertex(from);
110
+ const condition = control_flow_graph_1.CfgVertex.isBlock(vertex) ? control_flow_graph_1.CfgVertex.getId(control_flow_graph_1.CfgVertex.getBasicBlockElements(vertex).at(-1)) ?? from : from;
111
+ const lexeme = getLexeme(normalizedAst.idMap.get(condition));
112
+ return lexeme ? `${lexeme} (${condition})` : String(condition);
113
+ }
30
114
  function shouldIncludeNode(simplify, v, include) {
31
115
  if (simplify) {
32
116
  // Only basic blocks are shown, so include the BB, if at least one child is selected
33
117
  return control_flow_graph_1.CfgVertex.isBlock(v) && control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
34
- .filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
35
118
  .some(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)));
36
119
  }
37
120
  else {
38
121
  // Basic blocks and vertices are shown, include the BB, if all children are highlighted
39
122
  return control_flow_graph_1.CfgVertex.isBlock(v)
40
- ? control_flow_graph_1.CfgVertex.getBasicBlockElements(v)
41
- .filter(elem => !control_flow_graph_1.CfgVertex.isMarker(elem))
42
- .every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
123
+ ? control_flow_graph_1.CfgVertex.getBasicBlockElements(v).every(elem => include.has(control_flow_graph_1.CfgVertex.getId(elem)))
43
124
  : include.has(control_flow_graph_1.CfgVertex.getId(v));
44
125
  }
45
126
  }
@@ -47,7 +128,7 @@ function shouldIncludeNode(simplify, v, include) {
47
128
  * Convert the control flow graph to a mermaid string.
48
129
  * @see {@link MermaidCfgGraphPrinterInfo} for additional options.
49
130
  */
50
- function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, entryPointStyle = exports.MermaidEntryPointDefaultMarkStyle, exitPointStyle = exports.MermaidExitPointDefaultMarkStyle, includeOnlyIds, mark, includeBasicBlockLabel = true, basicBlockCharacterLimit = 100 } = {}) {
131
+ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart TD\n', simplify = false, markStyle = info_1.MermaidDefaultMarkStyle, entryPointStyle = exports.MermaidEntryPointDefaultMarkStyle, exitPointStyle = exports.MermaidExitPointDefaultMarkStyle, includeOnlyIds, mark, includeBasicBlockLabel = true, basicBlockCharacterLimit = 100 } = {}) {
51
132
  const hasBbandSimplify = simplify && cfg.graph.mayHaveBasicBlocks();
52
133
  let output = prefix;
53
134
  if (includeOnlyIds) {
@@ -62,16 +143,33 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
62
143
  completed.add(childId);
63
144
  }
64
145
  }
65
- // if we have a filter, we automatically add all vertices in the cfg that are *markers* for these ids and
66
- for (const [id, v] of cfg.graph.vertices()) {
67
- if (control_flow_graph_1.CfgVertex.isMarker(v) && completed.has(control_flow_graph_1.CfgVertex.unpackRootId(v))) {
68
- completed.add(id);
69
- }
70
- }
71
146
  includeOnlyIds = completed;
72
147
  }
73
148
  const dirIs = getDirRegex.exec(prefix)?.at(1) ?? 'LR';
74
149
  const diagramIncludedIds = new Set();
150
+ /* a function body runs when the function is called, so it is drawn as a region of its own instead of floating free */
151
+ const bodies = cfg.graph.mayHaveBasicBlocks() ? new Map() : collectBodies(cfg.graph);
152
+ const partOfBody = new Set(bodies.values().flatMap(body => body));
153
+ const emitBody = (defId) => {
154
+ const body = bodies.get(defId)?.filter(v => !includeOnlyIds || includeOnlyIds.has(v));
155
+ if (body === undefined || body.length === 0) {
156
+ return;
157
+ }
158
+ const definition = normalizedAst.idMap.get(defId);
159
+ output += ` subgraph n${defId}-body ["body of ${mermaid_1.Mermaid.escape(limitTo(getLexeme(definition) ?? String(defId), 40))}"]\n`;
160
+ output += ` direction ${dirIs}\n`;
161
+ for (const vertexId of body) {
162
+ const vertex = cfg.graph.getVertex(vertexId);
163
+ if (vertex === undefined || control_flow_graph_1.CfgVertex.isBlock(vertex)) {
164
+ continue;
165
+ }
166
+ const node = normalizedAst.idMap.get(vertexId);
167
+ output = cfgOfNode(vertex, node, vertexId, getLexeme(node), output);
168
+ diagramIncludedIds.add(vertexId);
169
+ emitBody(vertexId);
170
+ }
171
+ output += ' end\n';
172
+ };
75
173
  for (const [id, vertex] of cfg.graph.vertices(false)) {
76
174
  const normalizedVertex = normalizedAst?.idMap.get(id);
77
175
  const content = getLexeme(normalizedVertex);
@@ -81,9 +179,8 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
81
179
  if (includeOnlyIds && !elems.some(elem => includeOnlyIds.has(control_flow_graph_1.CfgVertex.getId(elem)))) {
82
180
  continue;
83
181
  }
84
- const ids = elems?.map(control_flow_graph_1.CfgVertex.getId) ?? [];
85
- const reconstruct = limitTo((0, reconstruct_1.reconstructToCode)(normalizedAst, { nodes: new Set(ids) }, auto_select_defaults_1.doNotAutoSelect).code, basicBlockCharacterLimit);
86
- const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(reconstruct)}\`"`;
182
+ const code = limitTo(blockCode(elems, normalizedAst), basicBlockCharacterLimit);
183
+ const name = `"\`${includeBasicBlockLabel ? `Basic Block (${id})\n` : ''}${mermaid_1.Mermaid.escape(code)}\`"`;
87
184
  output += ` n${id}[[${name}]]\n`;
88
185
  diagramIncludedIds.add(control_flow_graph_1.CfgVertex.getId(vertex));
89
186
  }
@@ -103,20 +200,21 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
103
200
  const eid = control_flow_graph_1.CfgVertex.getId(element);
104
201
  const childNormalizedVertex = normalizedAst?.idMap.get(eid);
105
202
  const childContent = getLexeme(childNormalizedVertex);
106
- output = cfgOfNode(vertex, childNormalizedVertex, eid, childContent, output);
203
+ output = cfgOfNode(element, childNormalizedVertex, eid, childContent, output);
107
204
  diagramIncludedIds.add(eid);
108
- // just to keep the order
205
+ /* everything in a block runs one after the other, which is what these arrows show */
109
206
  if (last) {
110
- output += ` ${last} -.-> n${eid}\n`;
207
+ output += ` ${last} --> n${eid}\n`;
111
208
  }
112
209
  last = `n${eid}`;
113
210
  }
114
211
  output += ' end\n';
115
212
  }
116
213
  }
117
- else if (!includeOnlyIds || includeOnlyIds.has(id)) {
214
+ else if ((!includeOnlyIds || includeOnlyIds.has(id)) && !partOfBody.has(id)) {
118
215
  output = cfgOfNode(vertex, normalizedVertex, id, content, output);
119
216
  diagramIncludedIds.add(id);
217
+ emitBody(id);
120
218
  }
121
219
  }
122
220
  for (const [from, targets] of cfg.graph.edges()) {
@@ -127,10 +225,18 @@ function cfgToMermaid(cfg, normalizedAst, { prefix = 'flowchart BT\n', simplify
127
225
  if (!diagramIncludedIds.has(to)) {
128
226
  continue;
129
227
  }
130
- const isCd = control_flow_graph_1.CfgEdge.isControlDependency(edge);
131
- const edgeType = isCd ? '-->' : '-.->';
132
- const edgeSuffix = isCd ? ` (${control_flow_graph_1.CfgEdge.unpackWhen(edge)})` : '';
133
- output += ` n${from} ${edgeType}|"${mermaid_1.Mermaid.escape(control_flow_graph_1.CfgEdge.typeToString(edge))}${edgeSuffix}"| n${to}\n`;
228
+ /* a branch is drawn dashed, so what always runs stands out from what only runs under a condition */
229
+ const isBranch = control_flow_graph_1.CfgEdge.isControlDependency(edge);
230
+ const arrow = isBranch ? '-.->' : '-->';
231
+ const label = isBranch ? `branch on ${conditionName(cfg, normalizedAst, from)} if ${control_flow_graph_1.CfgEdge.unpackWhen(edge) === convert_values_1.RTrue ? 'T' : 'F'}` : control_flow_graph_1.CfgEdge.typeToString(edge);
232
+ output += ` n${from} ${arrow}|"${mermaid_1.Mermaid.escape(label)}"| n${to}\n`;
233
+ }
234
+ }
235
+ for (const [defId] of bodies) {
236
+ const entry = cfg.graph.childrenOf(defId)?.[0];
237
+ /* no arrow head: the definition does not run its body, it only holds it */
238
+ if (entry !== undefined && diagramIncludedIds.has(defId) && diagramIncludedIds.has(entry)) {
239
+ output += ` n${defId} -. holds .- n${entry}\n`;
134
240
  }
135
241
  }
136
242
  for (const entryPoint of cfg.entryPoints) {
@@ -12,12 +12,12 @@ const identifier_1 = require("../../dataflow/environments/identifier");
12
12
  const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
13
13
  const edge_1 = require("../../dataflow/graph/edge");
14
14
  const vertex_1 = require("../../dataflow/graph/vertex");
15
- const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
16
15
  const info_1 = require("./info");
17
16
  const range_1 = require("../range");
18
17
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
19
18
  const info_2 = require("../../dataflow/info");
20
19
  const df_helper_1 = require("../../dataflow/graph/df-helper");
20
+ const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
21
21
  function subflowToMermaid(nodeId, subflow, mermaid, idPrefix = '') {
22
22
  if (subflow === undefined) {
23
23
  return;
@@ -181,7 +181,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
181
181
  }
182
182
  }
183
183
  const node = mermaid.rootGraph.idMap?.get(info.id);
184
- const lexeme = node?.lexeme ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0]?.lexeme : '') ?? '??';
184
+ const lexeme = node?.lexeme ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0]?.lexeme : '') ?? '??';
185
185
  let display = lexeme;
186
186
  if (fCall && vertex_1.FunctionCallVertex.is(info)) {
187
187
  const q = identifier_1.Identifier.toQualified(df_helper_1.Dataflow.origin(mermaid.rootGraph, origId), info.name, mermaid.qualifyBaseR !== false);
@@ -201,7 +201,7 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
201
201
  const lnks = info.link?.origin ? ', links: ' + info.link.origin.map(o => mermaid_1.Mermaid.escapeId(o)).join(', ') : '';
202
202
  const source = vertex_1.VariableDefinitionVertex.is(info) ? info.source : undefined;
203
203
  const sources = source ? ', v: ' + source.map(s => mermaid_1.Mermaid.escapeId(s)).join(', ') : '';
204
- const n = node?.info.fullRange ?? node?.location ?? (node?.type === type_1.RType.ExpressionList ? node?.grouping?.[0].location : undefined);
204
+ const n = node?.info.fullRange ?? node?.location ?? (r_expression_list_1.RExpressionList.is(node) ? node?.grouping?.[0].location : undefined);
205
205
  mermaid.nodeLines.push(` ${idPrefix}${id}${open}"\`${escapedName}\n *${range_1.SourceRange.format(n)}* (**id: ${id}**${deps}${lnks}${sources})${fCall ? displayFunctionArgMapping(info.args) : '' + (vertex_1.FunctionDefinitionVertex.is(info) && info.mode && info.mode.length > 0 ? mermaid_1.Mermaid.escape(JSON.stringify(info.mode)) : '')}\`"${close}`);
206
206
  }
207
207
  if (mark?.has(id)) {
@@ -218,25 +218,35 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
218
218
  mermaid.nodeLines.push(' %% No edges found for ' + id);
219
219
  return;
220
220
  }
221
- const artificialCdEdges = (info.cds ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']), file: x.file }]);
222
221
  // eslint-disable-next-line prefer-const
223
- for (let [target, edge] of [...edges, ...artificialCdEdges]) {
222
+ for (let [target, edge] of edges) {
224
223
  if (includeOnlyIds && !includeOnlyIds.has(target)) {
225
224
  continue;
226
225
  }
227
226
  const originalTarget = target;
228
227
  target = mermaid_1.Mermaid.escapeId(target);
229
228
  const edgeTypes = typeof edge.types == 'number' ? new Set(edge_1.DfEdge.splitTypes(edge)) : edge.types;
229
+ const carriesControlFlow = edgeTypes.has(edge_1.EdgeType.FlowEdge) || edgeTypes.has(edge_1.EdgeType.ControlEdge);
230
+ /* an edge that carries dataflow as well stays a dataflow edge, it just says the control flow goes there too */
231
+ const onlyControlFlow = carriesControlFlow && ![...edgeTypes].some(t => typeof t === 'number' && (t & ~edge_1.ControlFlowEdgeTypes) !== 0);
232
+ if (mermaid.simplified && onlyControlFlow) {
233
+ /* a simplified view is about the dataflow, and the control flow is a graph of its own */
234
+ continue;
235
+ }
230
236
  const edgeId = encodeEdge(idPrefix + id, idPrefix + target, edgeTypes);
231
237
  if (!mermaid.presentEdges.has(edgeId)) {
232
238
  mermaid.presentEdges.add(edgeId);
233
- const style = node_id_1.NodeId.isBuiltIn(target) ? '-.->' : '-->';
234
- mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${[...edgeTypes].map(e => typeof e === 'number' ? edge_1.DfEdge.typeToName(e) : e).join(', ')}${'file' in edge && edge.file ? `, from: ${mermaid_1.Mermaid.escape(String(edge.file))}` : ''}"| ${idPrefix}${target}`);
239
+ const style = node_id_1.NodeId.isBuiltIn(target) || onlyControlFlow ? '-.->' : '-->';
240
+ const names = [...edgeTypes].map(e => typeof e === 'number' ? edgeName(e) : e).join(', ');
241
+ const cd = edgeTypes.has(edge_1.EdgeType.ControlEdge) ? edge.cd : undefined;
242
+ const when = cd === undefined ? '' : ` (when: ${cd.when ?? 'any'})`;
243
+ const assumedFile = cd?.file ? `, from: ${mermaid_1.Mermaid.escape(cd.file)}` : '';
244
+ mermaid.edgeLines.push(` ${idPrefix}${id} ${style}|"${names}${when}${assumedFile}"| ${idPrefix}${target}`);
235
245
  if (mermaid.mark?.has(id + '->' + target)) {
236
246
  // who invented this syntax?!
237
247
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} ${mermaid.markStyle.edge}`);
238
248
  }
239
- if (edgeTypes.has('CD-True') || edgeTypes.has('CD-False')) {
249
+ if (onlyControlFlow) {
240
250
  mermaid.edgeLines.push(` linkStyle ${mermaid.presentEdges.size - 1} stroke:gray,color:gray;`);
241
251
  }
242
252
  if (node_id_1.NodeId.isBuiltIn(target)) {
@@ -250,8 +260,19 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark, includeOnlyIds) {
250
260
  }
251
261
  }
252
262
  }
263
+ /** control flow edges are drawn all over the graph, so they get a short name to save space */
264
+ function edgeName(type) {
265
+ switch (type) {
266
+ case edge_1.EdgeType.FlowEdge:
267
+ return 'flow';
268
+ case edge_1.EdgeType.ControlEdge:
269
+ return 'branch';
270
+ default:
271
+ return edge_1.DfEdge.typeToName(type);
272
+ }
273
+ }
253
274
  // make the passing of root ids more performant again
254
- function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart BT', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
275
+ function graphToMermaidGraph(rootIds, { simplified, graph, prefix = 'flowchart TD', idPrefix = '', includeEnvironments = !simplified, mark, rootGraph, presentEdges = new Set(), markStyle = info_1.MermaidDefaultMarkStyle, includeOnlyIds, qualifyBaseR = true }) {
255
276
  const mermaid = { nodeLines: prefix === null ? [] : [prefix], edgeLines: [], presentEdges, presentVertices: new Set(), mark, rootGraph: rootGraph ?? graph, includeEnvironments, markStyle, simplified, qualifyBaseR };
256
277
  for (const [id, info] of graph.vertices(true)) {
257
278
  if (rootIds.has(id)) {
@@ -265,7 +286,7 @@ function diffGraphsToMermaid(left, right, prefix) {
265
286
  // we add the prefix ourselves
266
287
  const { string: leftGraph, mermaid } = exports.DataflowMermaid.convert({ graph: left.graph, prefix: '', idPrefix: `l-${left.label}`, includeEnvironments: true, mark: left.mark });
267
288
  const { string: rightGraph } = exports.DataflowMermaid.convert({ graph: right.graph, prefix: '', idPrefix: `r-${right.label}`, includeEnvironments: true, mark: right.mark, presentEdges: mermaid.presentEdges });
268
- return `${prefix}flowchart BT\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
289
+ return `${prefix}flowchart TD\nsubgraph "${left.label}"\n${leftGraph}\nend\nsubgraph "${right.label}"\n${rightGraph}\nend`;
269
290
  }
270
291
  /**
271
292
  * Converts two dataflow graphs to a mermaid url that visualizes their differences.
@@ -68,6 +68,8 @@ exports.Mermaid = {
68
68
  */
69
69
  escapeId(text) {
70
70
  text = String(text).replace(/[^a-zA-Z0-9:\-./]/g, '_');
71
+ /* a dash before a dash or a dot reads as the start of a link, e.g. the id of `$<-.grouped_df` would cut the line in two */
72
+ text = text.replace(/-(?=[-.])/g, '_');
71
73
  return text.replace(/(^|[:\-./])([a-zA-Z0-9_]+)/g, (_m, sep, tok) => sep + (exports.Mermaid.reservedIds.has(tok) ? tok + '_' : tok));
72
74
  },
73
75
  /**
package/util/objects.d.ts CHANGED
@@ -58,4 +58,25 @@ export declare function deepClonePreserveUnclonable<T>(obj: T): T;
58
58
  * @param logger - The logger to use for trace debugging.
59
59
  */
60
60
  export declare function looselyCompareObjects(obj: Record<string, unknown>, expected: Record<string, unknown>, arrayMatch?: 'some' | 'every', logger?: Logger<ILogObj>): boolean;
61
+ /**
62
+ * Reads the value at the given dot-separated `path` of `obj` (e.g. `solver.sigdb.additionalPaths`),
63
+ * or `undefined` if any segment along the way is missing.
64
+ * @see {@link setOnPath} for the counterpart that writes such a path
65
+ */
66
+ export declare function getOnPath(obj: unknown, path: string): unknown;
67
+ /**
68
+ * Writes `value` at the given dot-separated `path` of `obj`, creating the intermediate steps that do not exist yet.
69
+ * An intermediate is created as an array if the segment indexing it is a number, and as an object otherwise.
70
+ * @see {@link getOnPath} for the counterpart that reads such a path
71
+ */
72
+ export declare function setOnPath(obj: object, path: string, value: unknown): void;
73
+ /**
74
+ * The members of an enum as name-value pairs.
75
+ * A numeric enum maps its values back to their names as well, which this leaves out.
76
+ * @example
77
+ * ```ts
78
+ * enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
79
+ * ```
80
+ */
81
+ export declare function enumMembers<T extends object>(enumObject: T): [name: string, value: T[keyof T]][];
61
82
  export {};
package/util/objects.js CHANGED
@@ -7,6 +7,10 @@ exports.deepMergeObjectInPlace = deepMergeObjectInPlace;
7
7
  exports.compactRecord = compactRecord;
8
8
  exports.deepClonePreserveUnclonable = deepClonePreserveUnclonable;
9
9
  exports.looselyCompareObjects = looselyCompareObjects;
10
+ exports.getOnPath = getOnPath;
11
+ exports.setOnPath = setOnPath;
12
+ exports.enumMembers = enumMembers;
13
+ const assert_1 = require("./assert");
10
14
  const json_1 = require("./json");
11
15
  const log_1 = require("./log");
12
16
  /**
@@ -194,4 +198,60 @@ function looselyCompareObjects(obj, expected, arrayMatch, logger) {
194
198
  (0, log_1.expensiveTrace)(logger, () => `Object ${JSON.stringify(obj)} matches ${JSON.stringify(expected)}`);
195
199
  return true;
196
200
  }
201
+ /** Segments that would let a dotted path reach into the prototype chain. */
202
+ const magicPathSegments = new Set(['__proto__', 'prototype', 'constructor']);
203
+ /**
204
+ * Splits a dot-separated path into its segments, turning integral segments into numbers
205
+ * so that `a.0.b` indexes an array rather than an object with the key `'0'`.
206
+ */
207
+ function pathSegments(path) {
208
+ return path.split('.').map(segment => {
209
+ (0, assert_1.guard)(!magicPathSegments.has(segment), () => `refusing to walk the magic property '${segment}' in path '${path}'`);
210
+ const asInt = parseInt(segment);
211
+ return String(asInt) === segment ? asInt : segment;
212
+ });
213
+ }
214
+ /**
215
+ * Reads the value at the given dot-separated `path` of `obj` (e.g. `solver.sigdb.additionalPaths`),
216
+ * or `undefined` if any segment along the way is missing.
217
+ * @see {@link setOnPath} for the counterpart that writes such a path
218
+ */
219
+ function getOnPath(obj, path) {
220
+ let at = obj;
221
+ for (const segment of pathSegments(path)) {
222
+ if (at === null || typeof at !== 'object' || !Object.prototype.hasOwnProperty.call(at, segment)) {
223
+ return undefined;
224
+ }
225
+ at = at[segment];
226
+ }
227
+ return at;
228
+ }
229
+ /**
230
+ * Writes `value` at the given dot-separated `path` of `obj`, creating the intermediate steps that do not exist yet.
231
+ * An intermediate is created as an array if the segment indexing it is a number, and as an object otherwise.
232
+ * @see {@link getOnPath} for the counterpart that reads such a path
233
+ */
234
+ function setOnPath(obj, path, value) {
235
+ const segments = pathSegments(path);
236
+ let at = obj;
237
+ for (let i = 0; i < segments.length - 1; i++) {
238
+ const segment = segments[i];
239
+ if (at[segment] === undefined) {
240
+ at[segment] = typeof segments[i + 1] === 'number' ? [] : {};
241
+ }
242
+ at = at[segment];
243
+ }
244
+ at[segments[segments.length - 1]] = value;
245
+ }
246
+ /**
247
+ * The members of an enum as name-value pairs.
248
+ * A numeric enum maps its values back to their names as well, which this leaves out.
249
+ * @example
250
+ * ```ts
251
+ * enumMembers(CfgVertexType) // [['Statement', 1], ['Expression', 2], ['Block', 3]]
252
+ * ```
253
+ */
254
+ function enumMembers(enumObject) {
255
+ return Object.entries(enumObject).filter(([name]) => Number.isNaN(Number(name)));
256
+ }
197
257
  //# sourceMappingURL=objects.js.map
package/util/prefix.d.ts CHANGED
@@ -13,4 +13,4 @@
13
13
  * findByPrefixIfUnique('', [ 'hello', 'hell' ]) // => undefined (empty prefix)
14
14
  * ```
15
15
  */
16
- export declare function findByPrefixIfUnique(prefix: string, keys: readonly string[] | MapIterator<string>): string | undefined;
16
+ export declare function findByPrefixIfUnique(prefix: string, keys: Iterable<string>): string | undefined;
@@ -1,10 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dfgToAscii = dfgToAscii;
4
- const dagre_1 = require("dagre");
5
4
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
6
5
  const vertex_1 = require("../../dataflow/graph/vertex");
7
6
  const edge_1 = require("../../dataflow/graph/edge");
7
+ let dagreModule;
8
+ /* type-only import above, `dagre` is optional: the ascii layout is a side feature, so the package is resolved at call time */
9
+ function dagre() {
10
+ try {
11
+ // eslint-disable-next-line @typescript-eslint/no-require-imports -- loaded on demand, see above
12
+ return dagreModule ??= require('dagre');
13
+ }
14
+ catch {
15
+ throw new Error('the optional dependency `dagre` is required to render a dataflow graph as ascii, install it with `npm i dagre`');
16
+ }
17
+ }
8
18
  function combineAscii(has, add) {
9
19
  if (has === ' ' || has === add) {
10
20
  return add;
@@ -72,7 +82,8 @@ class AsciiCanvas {
72
82
  * Converts the given dataflow graph to an ASCII representation.
73
83
  */
74
84
  function dfgToAscii(dfg) {
75
- const g = new dagre_1.graphlib.Graph();
85
+ const { graphlib: dagreGraphlib, layout } = dagre();
86
+ const g = new dagreGraphlib.Graph();
76
87
  const verts = Array.from(dfg.vertices(true));
77
88
  g.setGraph({
78
89
  nodesep: 1,
@@ -106,7 +117,7 @@ function dfgToAscii(dfg) {
106
117
  edgesDone.add(`${from}-${to}`);
107
118
  }
108
119
  }
109
- (0, dagre_1.layout)(g, {
120
+ layout(g, {
110
121
  minlen: 2
111
122
  });
112
123
  const canvas = new AsciiCanvas();
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * What a reader most likely meant when typing a name: a well-used package first, base R ahead of CRAN, and
3
- * the things one rarely reaches for last, which are S3 methods, `%operators%` and names starting with a dot.
3
+ * the things one rarely reaches for last, which are S3 methods, `%operators%`, and names starting with a dot.
4
4
  *
5
5
  * The signature browser and the playground's completion both offer names out of the same database, so they
6
6
  * order them with the same {@link rankName}, and what one of them learns the other one knows.
@@ -22,7 +22,7 @@ const Adjustments = [
22
22
  offer `ggplot` before `plotH`, because one of them is a function people actually call */
23
23
  [500, ({ known }) => known === true],
24
24
  [-30, ({ s3 }) => s3 === true],
25
- /* operators, punctuation and SHOUTING names are rarely what someone is looking for */
25
+ /* operators, punctuation, and SHOUTING names are rarely what someone is looking for */
26
26
  [-60, ({ name }) => /^%.*%$/.test(name) || /^[^\w.]/.test(name)],
27
27
  [-30, ({ name, needle }) => name === name.toUpperCase() && /[A-Z]/.test(name) && name !== needle],
28
28
  [-400, ({ name }) => name.startsWith('.')]