@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
@@ -140,6 +140,7 @@ function summarizeAllSummarizedStats(stats) {
140
140
  numberOfFunctionDefinitions: (0, summarizer_1.summarizeMeasurement)(dataflows.map(d => d.numberOfFunctionDefinitions)),
141
141
  numberOfCalls: (0, summarizer_1.summarizeMeasurement)(dataflows.map(d => d.numberOfCalls)),
142
142
  numberOfEdges: (0, summarizer_1.summarizeMeasurement)(dataflows.map(d => d.numberOfEdges)),
143
+ numberOfControlFlowEdges: (0, summarizer_1.summarizeMeasurement)(dataflows.map(d => d.numberOfControlFlowEdges ?? 0)),
143
144
  sizeOfObject: (0, summarizer_1.summarizeMeasurement)(dataflows.map(d => d.sizeOfObject)),
144
145
  },
145
146
  controlFlow: stats.some(s => s.controlFlow !== undefined) ? {
@@ -240,6 +241,7 @@ function summarizeAllUltimateStats(stats) {
240
241
  numberOfFunctionDefinitions: (0, process_1.summarizeSummarizedMeasurement)(stats.map(s => s.dataflow.numberOfFunctionDefinitions)),
241
242
  numberOfCalls: (0, process_1.summarizeSummarizedMeasurement)(stats.map(s => s.dataflow.numberOfCalls)),
242
243
  numberOfEdges: (0, process_1.summarizeSummarizedMeasurement)(stats.map(s => s.dataflow.numberOfEdges)),
244
+ numberOfControlFlowEdges: (0, process_1.summarizeSummarizedMeasurement)(stats.map(s => s.dataflow.numberOfControlFlowEdges)),
243
245
  sizeOfObject: (0, process_1.summarizeSummarizedMeasurement)(stats.map(s => s.dataflow.sizeOfObject)),
244
246
  },
245
247
  controlFlow: stats.some(s => s.controlFlow !== undefined) ? {
@@ -13,33 +13,76 @@ const range_1 = require("../../../util/range");
13
13
  function formatInfo(out, type, meta) {
14
14
  return out.formatter.format(`Copied ${type} to clipboard (dataflow: ${meta['.meta'].timing + 'ms'}).`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ });
15
15
  }
16
- function formatReference(output, ref, idMap) {
17
- const id = output.formatter.format(`$${ref.nodeId}`, { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground });
16
+ function referenceRow(ref, idMap) {
18
17
  const name = ref.name === undefined ? '<anonymous>' : identifier_1.Identifier.toString(ref.name);
19
18
  const node = idMap.get(ref.nodeId);
20
19
  const sl = range_1.SourceLocation.fromNode(node);
21
20
  const loc = sl ? ` [${range_1.SourceLocation.format(sl)}]` : '';
22
- const detail = node ? ` "${node.lexeme ?? name}"${loc}` : '';
23
- return `${id} ${name} (${identifier_1.ReferenceType[ref.type]})${detail}`;
21
+ return {
22
+ id: `$${ref.nodeId}`,
23
+ name,
24
+ type: identifier_1.ReferenceType[ref.type],
25
+ detail: node ? `"${node.lexeme ?? name}"${loc}` : ''
26
+ };
24
27
  }
25
- /** Formats a single {@link KillReference}, which unlike a plain reference may kill the whole (or an unknown part of the) scope */
26
- function formatKill(output, kill, idMap) {
28
+ function killRow(kill, idMap) {
27
29
  switch (kill.kind) {
28
- case 'named': return formatReference(output, kill.reference, idMap);
30
+ case 'named': return referenceRow(kill.reference, idMap);
29
31
  case 'all': return 'kills entire scope';
30
32
  case 'unknown': return 'kills unknown, not statically resolvable references';
31
33
  }
32
34
  }
33
- /**
34
- * Prints the reference sets, listing each non-empty one and collapsing all empty ones into a single trailing
35
- * line, as a screen full of `(0):` headers says nothing.
36
- */
35
+ function printCounts(output, rows) {
36
+ const labels = rows.map(r => `${r.indent ? ' - ' : ''}${r.label}:`);
37
+ const labelWidth = Math.max(...labels.map(l => l.length));
38
+ const valueWidth = Math.max(...rows.map(r => String(r.value).length));
39
+ rows.forEach((r, i) => {
40
+ const value = output.formatter.format(String(r.value).padStart(valueWidth), { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground });
41
+ output.stdout(`${labels[i].padEnd(labelWidth)} ${value}`);
42
+ });
43
+ }
44
+ const MaxDetailedReferences = 4;
45
+ const MaxCompactReferences = 12;
46
+ const MaxIdsPerName = 3;
47
+ /** Lists each non-empty reference set and collapses all empty ones into a single trailing line */
37
48
  function printReferenceSections(output, sections) {
38
49
  const count = (n) => output.formatter.format(String(n), { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground });
50
+ const rows = sections.flatMap(s => s.lines.slice(0, MaxDetailedReferences)).filter(l => typeof l !== 'string');
51
+ const width = (get) => Math.max(0, ...rows.map(r => get(r).length));
52
+ const idWidth = width(r => r.id);
53
+ const nameWidth = width(r => r.name);
54
+ const typeWidth = width(r => r.type);
55
+ const line = (l) => {
56
+ if (typeof l === 'string') {
57
+ return l;
58
+ }
59
+ const id = output.formatter.format(l.id.padStart(idWidth), { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground });
60
+ const type = output.formatter.format(l.type.padEnd(typeWidth), { color: 5 /* Colors.Magenta */, effect: ansi_1.ColorEffect.Foreground });
61
+ return `${id} ${l.name.padEnd(nameWidth)} ${type} ${l.detail}`.trimEnd();
62
+ };
63
+ const compact = (lines) => {
64
+ const byName = new Map();
65
+ for (const l of lines) {
66
+ const name = typeof l === 'string' ? l : l.name;
67
+ const ids = byName.get(name) ?? [];
68
+ if (typeof l !== 'string') {
69
+ ids.push(l.id);
70
+ }
71
+ byName.set(name, ids);
72
+ }
73
+ return Array.from(byName, ([name, ids]) => ids.length === 0 ? name :
74
+ `${name} (${ids.slice(0, MaxIdsPerName).join(', ')}${ids.length > MaxIdsPerName ? ', ...' : ''})`);
75
+ };
39
76
  for (const { title, lines } of sections.filter(s => s.lines.length > 0)) {
40
77
  output.stdout(`${title} (${count(lines.length)}):`);
41
- for (const line of lines) {
42
- output.stdout(' - ' + line);
78
+ for (const l of lines.slice(0, MaxDetailedReferences)) {
79
+ output.stdout(' - ' + line(l));
80
+ }
81
+ const rest = lines.slice(MaxDetailedReferences);
82
+ if (rest.length > 0) {
83
+ const shown = rest.slice(0, MaxCompactReferences);
84
+ const hidden = rest.length - shown.length;
85
+ output.stdout(' - ' + output.formatter.format(compact(shown).join(', ') + (hidden > 0 ? `, ... ${hidden} more` : ''), { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ }));
43
86
  }
44
87
  }
45
88
  const empty = sections.filter(s => s.lines.length === 0);
@@ -96,22 +139,22 @@ exports.dataflowSilentCommand = {
96
139
  const result = await analyzer.dataflow();
97
140
  const numOfEdges = Array.from(result.graph.edges().flatMap(e => e[1].entries())).length;
98
141
  const numOfVertices = Array.from(result.graph.vertices(true)).length;
99
- output.stdout(output.formatter.format(`Dataflow calculated in ${result['.meta'].timing}ms.`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ }) + '\n' +
100
- 'Edges: ' + output.formatter.format(`${String(numOfEdges).padStart(12)}`, { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground }) + '\n' +
101
- // number of vertices and edges
102
- 'Vertices: ' + output.formatter.format(`${String(numOfVertices).padStart(12)}`, { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground }));
103
- const longestVertexType = Math.max(...Object.keys(vertex_1.VertexType).map(vt => vt.length));
104
- for (const vertType of Object.values(vertex_1.VertexType)) {
105
- const vertsOfType = Array.from(result.graph.verticesOfType(vertType));
106
- const longVertexName = Object.entries(vertex_1.VertexType).find(([, v]) => v === vertType)?.[0] ?? vertType;
107
- output.stdout(` - ${(longVertexName + ':').padEnd(longestVertexType + 1)} ` + output.formatter.format(`${String(vertsOfType.length).padStart(8)}`, { color: 6 /* Colors.Cyan */, effect: ansi_1.ColorEffect.Foreground }).padStart(9, ' '));
108
- }
142
+ output.stdout(output.formatter.format(`Dataflow calculated in ${result['.meta'].timing}ms.`, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 3 /* FontStyles.Italic */ }));
143
+ printCounts(output, [
144
+ { label: 'Edges', value: numOfEdges },
145
+ { label: 'Vertices', value: numOfVertices },
146
+ ...Object.entries(vertex_1.VertexType).map(([name, vertType]) => ({
147
+ label: name,
148
+ value: Array.from(result.graph.verticesOfType(vertType)).length,
149
+ indent: true
150
+ }))
151
+ ]);
109
152
  const { idMap } = await analyzer.normalize();
110
153
  printReferenceSections(output, [
111
- { title: 'In', lines: result.in.map(r => formatReference(output, r, idMap)) },
112
- { title: 'Out', lines: result.out.map(r => formatReference(output, r, idMap)) },
113
- { title: 'Unknown References', lines: result.unknownReferences.map(r => formatReference(output, r, idMap)) },
114
- { title: 'Kill', lines: (result.kill ?? []).map(k => formatKill(output, k, idMap)) }
154
+ { title: 'In', lines: result.in.map(r => referenceRow(r, idMap)) },
155
+ { title: 'Out', lines: result.out.map(r => referenceRow(r, idMap)) },
156
+ { title: 'Unknown References', lines: result.unknownReferences.map(r => referenceRow(r, idMap)) },
157
+ { title: 'Kill', lines: (result.kill ?? []).map(k => killRow(k, idMap)) }
115
158
  ]);
116
159
  }
117
160
  };
@@ -91,8 +91,8 @@ export interface FlowrReplOptions extends MergeableRecord {
91
91
  * The repl allows for two kinds of inputs:
92
92
  * - Starting with a colon `:`, indicating a command (probe `:help`, and refer to {@link commands}) </li>
93
93
  * - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li>
94
- * @param options - The options for the repl. See {@link FlowrReplOptions} for more information.
95
94
  *
95
+ * It takes a single {@link FlowrReplOptions} object, which it destructures; see there for what each option does.
96
96
  * For the execution, this function makes use of {@link replProcessAnswer}.
97
97
  */
98
98
  export declare function repl({ analyzer, historyFile, rl, output, allowRSessionAccess }: FlowrReplOptions): Promise<void>;
package/cli/repl/core.js CHANGED
@@ -375,8 +375,8 @@ async function replProcessAnswer(analyzer, output, expr, allowRSessionAccess) {
375
375
  * The repl allows for two kinds of inputs:
376
376
  * - Starting with a colon `:`, indicating a command (probe `:help`, and refer to {@link commands}) </li>
377
377
  * - Starting with anything else, indicating default R code to be directly executed. If you kill the underlying shell, that is on you! </li>
378
- * @param options - The options for the repl. See {@link FlowrReplOptions} for more information.
379
378
  *
379
+ * It takes a single {@link FlowrReplOptions} object, which it destructures; see there for what each option does.
380
380
  * For the execution, this function makes use of {@link replProcessAnswer}.
381
381
  */
382
382
  async function repl({ analyzer, historyFile = defaultHistoryFile, rl = readline.createInterface(makeDefaultReplReadline(analyzer.flowrConfig, historyFile)), output = repl_main_1.standardReplOutput, allowRSessionAccess = false }) {
@@ -14,6 +14,7 @@ exports.diceCriteriaParser = diceCriteriaParser;
14
14
  const slice_direction_1 = require("../../../util/slice-direction");
15
15
  const core_1 = require("../core");
16
16
  const ansi_1 = require("../../../util/text/ansi");
17
+ const arrays_1 = require("../../../util/collections/arrays");
17
18
  /**
18
19
  * Splits `(criteria)flags` into its two parts, matching the closing bracket by depth: a criterion may well
19
20
  * carry brackets of its own (the `(file-regex)` suffix of e.g. `2@x(tmp/.*)`), so the first `)` is not it.
@@ -76,7 +77,7 @@ function warn(output, message) {
76
77
  * {@link SliceFlag#conflicts|conflict} with each other, as they are applied silently otherwise.
77
78
  */
78
79
  function warnAboutSliceFlags(output, argument, flags) {
79
- const given = [...new Set(sliceFlagSuffix(argument))];
80
+ const given = (0, arrays_1.uniqueArray)(sliceFlagSuffix(argument));
80
81
  const known = new Map(flags.map(f => [f.flag, f]));
81
82
  const unknown = given.filter(f => !known.has(f));
82
83
  if (unknown.length > 0) {
@@ -28,6 +28,10 @@ export declare class FlowRServerConnection {
28
28
  private invalidateTokens;
29
29
  private sendFileAnalysisResponse;
30
30
  private createAnalyzerForRequest;
31
+ /**
32
+ * Looks up the analysis stored for the given file token, answering with an error message if there is none.
33
+ */
34
+ private getAnalyzedFile;
31
35
  private handleSliceRequest;
32
36
  private handleRepl;
33
37
  private handleQueryRequest;
@@ -45,7 +45,7 @@ const message_slice_1 = require("./messages/message-slice");
45
45
  const server_1 = require("./server");
46
46
  const message_repl_1 = require("./messages/message-repl");
47
47
  const core_1 = require("../core");
48
- const extract_cfg_1 = require("../../../control-flow/extract-cfg");
48
+ const control_flow_graph_1 = require("../../../control-flow/control-flow-graph");
49
49
  const quads_1 = require("../../../util/quads");
50
50
  const print_1 = require("../../../core/print/print");
51
51
  const _00_parse_1 = require("../../../core/steps/all/core/00-parse");
@@ -199,7 +199,7 @@ class FlowRServerConnection {
199
199
  type: 'response-file-analysis',
200
200
  format: 'n-quads',
201
201
  id: message.id,
202
- cfg: cfg ? (0, extract_cfg_1.cfg2quads)(cfg, config()) : undefined,
202
+ cfg: cfg ? (0, control_flow_graph_1.cfg2quads)(cfg, config()) : undefined,
203
203
  results: {
204
204
  parse: await (0, print_1.printStepResult)(_00_parse_1.PARSE_WITH_R_SHELL_STEP, await analyzer.parse(), 5 /* StepOutputFormat.RdfQuads */, config()),
205
205
  normalize: await (0, print_1.printStepResult)(_10_normalize_1.NORMALIZE, await analyzer.normalize(), 5 /* StepOutputFormat.RdfQuads */, config()),
@@ -261,6 +261,21 @@ class FlowRServerConnection {
261
261
  }
262
262
  return analyzer;
263
263
  }
264
+ /**
265
+ * Looks up the analysis stored for the given file token, answering with an error message if there is none.
266
+ */
267
+ getAnalyzedFile(request) {
268
+ const fileInformation = this.fileMap.get(request.filetoken);
269
+ if (!fileInformation) {
270
+ (0, send_1.sendMessage)(this.socket, {
271
+ id: request.id,
272
+ type: 'error',
273
+ fatal: false,
274
+ reason: `The file token ${request.filetoken} has never been analyzed.`
275
+ });
276
+ }
277
+ return fileInformation;
278
+ }
264
279
  async handleSliceRequest(base) {
265
280
  const requestResult = (0, validate_1.validateMessage)(base, message_slice_1.requestSliceMessage);
266
281
  if (requestResult.type === 'error') {
@@ -269,14 +284,8 @@ class FlowRServerConnection {
269
284
  }
270
285
  const request = requestResult.message;
271
286
  this.logger.info(`[${request.filetoken}] Received ${request.direction ?? slice_direction_1.SliceDirection.Backward} slice request with criteria ${JSON.stringify(request.criterion)}`);
272
- const fileInformation = this.fileMap.get(request.filetoken);
287
+ const fileInformation = this.getAnalyzedFile(request);
273
288
  if (!fileInformation) {
274
- (0, send_1.sendMessage)(this.socket, {
275
- id: request.id,
276
- type: 'error',
277
- fatal: false,
278
- reason: `The file token ${request.filetoken} has never been analyzed.`
279
- });
280
289
  return;
281
290
  }
282
291
  try {
@@ -340,14 +349,8 @@ class FlowRServerConnection {
340
349
  }
341
350
  const request = requestResult.message;
342
351
  this.logger.info(`[${this.name}] Received query request`);
343
- const fileInformation = this.fileMap.get(request.filetoken);
352
+ const fileInformation = this.getAnalyzedFile(request);
344
353
  if (!fileInformation) {
345
- (0, send_1.sendMessage)(this.socket, {
346
- id: request.id,
347
- type: 'error',
348
- fatal: false,
349
- reason: `The file token ${request.filetoken} has never been analyzed.`
350
- });
351
354
  return;
352
355
  }
353
356
  try {
@@ -30,7 +30,7 @@ export interface FileAnalysisRequestMessage extends IdMessageBase {
30
30
  * If you want to load multiple R files as one, either use this or concatenate the file-contents for the `content`.
31
31
  */
32
32
  filepath?: string | readonly string[];
33
- /** Can be used to additionally extract the {@link ControlFlowInformation} of the file, which is not exposed (and not fully calculated) by default. */
33
+ /** Can be used to additionally extract the {@link ControlFlowInformation} of the file, which is not exposed by default. */
34
34
  cfg?: boolean;
35
35
  /** Controls the serialization of the `results` (and the {@link ControlFlowGraph} if the corresponding flag is set). If missing, we assume _json_. */
36
36
  format?: 'compact' | 'json' | 'n-quads';
package/config.d.ts CHANGED
@@ -161,6 +161,12 @@ export interface FlowrConfig extends MergeableRecord {
161
161
  failOnInaccessiblePath?: boolean;
162
162
  /** Overwrite the {@link ProjectKind} flowR would otherwise infer from the analyzed files, e.g. when auto-detection guesses wrong. */
163
163
  useProjectType?: ProjectKind;
164
+ /**
165
+ * Whether the top level of the analyzed code is echoed, so that every visible result printed there counts as an
166
+ * output (the `print` category of the dependencies query). Defaults to `true` and is set to `false` for a
167
+ * {@link ProjectKind.Package}, whose top-level code runs at install time.
168
+ */
169
+ assumeImplicitEcho?: boolean;
164
170
  /**
165
171
  * The packages considered part of R itself, used e.g. by the project query to classify dependencies. If
166
172
  * unset, flowR derives them (for the assumed R version) from the signature database via `baseRPackages`.
package/config.js CHANGED
@@ -18,6 +18,7 @@ const joi_1 = __importDefault(require("joi"));
18
18
  const project_kind_1 = require("./project/context/project-kind");
19
19
  const gas_1 = require("./gas");
20
20
  const input_types_1 = require("./queries/catalog/input-sources-query/input-types");
21
+ const arrays_1 = require("./util/collections/arrays");
21
22
  var VariableResolve;
22
23
  (function (VariableResolve) {
23
24
  /** Don't resolve constants at all */
@@ -249,13 +250,15 @@ exports.FlowrConfig = {
249
250
  },
250
251
  project: {
251
252
  resolveUnknownPathsOnDisk: true,
252
- failOnInaccessiblePath: false
253
+ failOnInaccessiblePath: false,
254
+ assumeImplicitEcho: true
253
255
  },
254
256
  linter: {
255
257
  disabledRules: []
256
258
  },
257
259
  specializeConfig: {
258
- [project_kind_1.ProjectKind.Package]: { solver: { resolveSource: { assumeFilesExist: true } } },
260
+ /* a package's top-level code runs at install time, its results are not echoed to anyone */
261
+ [project_kind_1.ProjectKind.Package]: { project: { assumeImplicitEcho: false }, solver: { resolveSource: { assumeFilesExist: true } } },
259
262
  [project_kind_1.ProjectKind.Project]: { solver: { resolveSource: { assumeFilesExist: true } } },
260
263
  [project_kind_1.ProjectKind.ShinyApp]: {
261
264
  /* shiny evaluates global.R before the supporting files in R/, and the app itself last */
@@ -354,6 +357,7 @@ exports.FlowrConfig = {
354
357
  basePackages: joi_1.default.array().items(joi_1.default.string()).optional().description('The packages considered part of R itself (base and recommended); if unset, flowR uses its built-in list.'),
355
358
  implicitSources: joi_1.default.array().items(joi_1.default.string()).optional().description('Files a framework loads on its own, without any source() call (e.g. global.R in a shiny app), in the order they are loaded; flowR orders the matching project files accordingly and analyzes them as one program. Entries are case-insensitive globs matched against the file path, a plain name matches any file with that name, and entries matching no project file are warned about. Usually set per project kind via specializeConfig.'),
356
359
  useProjectType: joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)).optional().description('Overwrite the project kind flowR would otherwise infer from the analyzed files, e.g. when auto-detection guesses wrong.'),
360
+ assumeImplicitEcho: joi_1.default.boolean().optional().description('Whether the top level of the analyzed code is echoed, so that every visible result printed there is collected as an output by the dependencies query (default true, false for a package).'),
357
361
  discovery: joi_1.default.object({
358
362
  full: joi_1.default.boolean().optional().description('Collect every file below the project root (greedy) instead of only the files the detected project kind needs (default false).'),
359
363
  perKind: joi_1.default.object().pattern(joi_1.default.string().valid(...Object.values(project_kind_1.ProjectKind)), joi_1.default.object({
@@ -581,7 +585,7 @@ exports.FlowrConfig = {
581
585
  const walk = (current, base, path, siblings) => {
582
586
  if (current !== null && base !== null && typeof current === 'object' && typeof base === 'object'
583
587
  && !Array.isArray(current) && !Array.isArray(base)) {
584
- const keys = [...new Set([...Object.keys(current), ...Object.keys(base)])];
588
+ const keys = (0, arrays_1.uniqueArray)([...Object.keys(current), ...Object.keys(base)]);
585
589
  for (const key of keys) {
586
590
  walk(current[key], base[key], [...path, key], [...siblings, keys]);
587
591
  }
@@ -657,7 +661,7 @@ function persistSigDbPathToGlobalConfig(dbPath) {
657
661
  }
658
662
  const current = (0, objects_1.getOnPath)(raw, 'solver.sigdb.additionalPaths');
659
663
  const paths = Array.isArray(current) ? current : [];
660
- (0, objects_1.setOnPath)(raw, 'solver.sigdb.additionalPaths', [...new Set([...paths, dbPath])]);
664
+ (0, objects_1.setOnPath)(raw, 'solver.sigdb.additionalPaths', (0, arrays_1.uniqueArray)([...paths, dbPath]));
661
665
  fs_1.default.mkdirSync(path_1.default.dirname(file), { recursive: true });
662
666
  fs_1.default.writeFileSync(file, JSON.stringify(raw, null, '\t') + '\n');
663
667
  return file;
@@ -1,4 +1,4 @@
1
- import { type CfgBasicBlockVertex, type CfgMarkerVertex, type CfgExpressionVertex, CfgVertex, type CfgStatementVertex, type ControlFlowInformation } from './control-flow-graph';
1
+ import { type CfgBasicBlockVertex, type CfgExpressionVertex, CfgVertex, type CfgStatementVertex, type ControlFlowInformation } from './control-flow-graph';
2
2
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  export interface BasicCfgGuidedVisitorConfiguration<ControlFlow extends ControlFlowInformation = ControlFlowInformation> {
4
4
  readonly controlFlow: ControlFlow;
@@ -29,9 +29,14 @@ export declare class BasicCfgGuidedVisitor<ControlFlow extends ControlFlowInform
29
29
  * Get the control flow vertex for the given node id or fail if it does not exist.
30
30
  */
31
31
  protected getCfgVertex(id: NodeId): CfgVertex | undefined;
32
+ /**
33
+ * The constructs whose outcome the given vertex decides, e.g. the `if` a condition belongs to.
34
+ * This is what tells you, standing on `u` in `if(u) a else b`, that you are evaluating the condition of that `if`.
35
+ * @see {@link ReadOnlyControlFlowGraph#decides|decides()} - for the underlying query
36
+ */
37
+ protected getDecidedConstructs(id: NodeId): readonly NodeId[];
32
38
  protected onVisitNode(node: NodeId): void;
33
39
  protected onBasicBlockNode(node: CfgBasicBlockVertex): void;
34
40
  protected onStatementNode(_node: CfgStatementVertex): void;
35
41
  protected onExpressionNode(_node: CfgExpressionVertex): void;
36
- protected onEndMarkerNode(_node: CfgMarkerVertex): void;
37
42
  }
@@ -31,21 +31,38 @@ class BasicCfgGuidedVisitor {
31
31
  }
32
32
  startVisitor(start) {
33
33
  const graph = this.config.controlFlow.graph;
34
- let getNext;
35
- if (this.config.defaultVisitingOrder === 'forward') {
36
- getNext = (node) => graph.ingoingEdges(node)?.keys().toArray().reverse();
37
- }
38
- else {
39
- getNext = (node) => graph.outgoingEdges(node)?.keys();
40
- }
34
+ const forward = this.config.defaultVisitingOrder === 'forward';
41
35
  const stack = Array.from(start);
42
36
  while (stack.length > 0) {
43
37
  const current = stack.pop();
44
38
  if (!this.visitNode(current)) {
45
39
  continue;
46
40
  }
47
- for (const next of getNext(current) ?? []) {
48
- stack.push(next);
41
+ const block = graph.mayHaveBasicBlocks() ? graph.getVertex(current) : undefined;
42
+ if (control_flow_graph_1.CfgVertex.isBlock(block)) {
43
+ /* a block holds the vertices themselves, so the function bodies to step into sit inside it */
44
+ for (const elem of control_flow_graph_1.CfgVertex.getBasicBlockElements(block)) {
45
+ for (const child of control_flow_graph_1.CfgVertex.getChildren(elem) ?? []) {
46
+ stack.push(child);
47
+ }
48
+ }
49
+ }
50
+ else {
51
+ for (const child of graph.childrenOf(current) ?? []) {
52
+ stack.push(child);
53
+ }
54
+ }
55
+ if (forward) {
56
+ /* reversed so that the first successor is the one visited next */
57
+ const next = [...graph.successors(current)];
58
+ for (let i = next.length - 1; i >= 0; i--) {
59
+ stack.push(next[i]);
60
+ }
61
+ }
62
+ else {
63
+ for (const next of graph.predecessors(current)) {
64
+ stack.push(next);
65
+ }
49
66
  }
50
67
  }
51
68
  }
@@ -61,6 +78,14 @@ class BasicCfgGuidedVisitor {
61
78
  getCfgVertex(id) {
62
79
  return this.config.controlFlow.graph.getVertex(id);
63
80
  }
81
+ /**
82
+ * The constructs whose outcome the given vertex decides, e.g. the `if` a condition belongs to.
83
+ * This is what tells you, standing on `u` in `if(u) a else b`, that you are evaluating the condition of that `if`.
84
+ * @see {@link ReadOnlyControlFlowGraph#decides|decides()} - for the underlying query
85
+ */
86
+ getDecidedConstructs(id) {
87
+ return this.config.controlFlow.graph.decides(id);
88
+ }
64
89
  onVisitNode(node) {
65
90
  const vertex = this.getCfgVertex(node);
66
91
  if (vertex === undefined) {
@@ -74,9 +99,6 @@ class BasicCfgGuidedVisitor {
74
99
  case control_flow_graph_1.CfgVertexType.Expression:
75
100
  this.onExpressionNode(vertex);
76
101
  break;
77
- case control_flow_graph_1.CfgVertexType.Marker:
78
- this.onEndMarkerNode(vertex);
79
- break;
80
102
  case control_flow_graph_1.CfgVertexType.Block:
81
103
  this.onBasicBlockNode(vertex);
82
104
  break;
@@ -86,15 +108,9 @@ class BasicCfgGuidedVisitor {
86
108
  }
87
109
  onBasicBlockNode(node) {
88
110
  const elems = control_flow_graph_1.CfgVertex.getBasicBlockElements(node);
89
- if (this.config.defaultVisitingOrder === 'forward') {
90
- for (const elem of elems.toReversed()) {
91
- this.visitNode(control_flow_graph_1.CfgVertex.getId(elem));
92
- }
93
- }
94
- else {
95
- for (const elem of elems) {
96
- this.visitNode(control_flow_graph_1.CfgVertex.getId(elem));
97
- }
111
+ /* the elements of a block are stored in the order they run */
112
+ for (const elem of this.config.defaultVisitingOrder === 'forward' ? elems : elems.toReversed()) {
113
+ this.visitNode(control_flow_graph_1.CfgVertex.getId(elem));
98
114
  }
99
115
  }
100
116
  onStatementNode(_node) {
@@ -103,9 +119,6 @@ class BasicCfgGuidedVisitor {
103
119
  onExpressionNode(_node) {
104
120
  /* does nothing by default */
105
121
  }
106
- onEndMarkerNode(_node) {
107
- /* does nothing by default */
108
- }
109
122
  }
110
123
  exports.BasicCfgGuidedVisitor = BasicCfgGuidedVisitor;
111
124
  //# sourceMappingURL=basic-cfg-guided-visitor.js.map
@@ -11,14 +11,15 @@ const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-nam
11
11
  const log_1 = require("../util/log");
12
12
  const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
13
13
  const r_value_1 = require("../dataflow/eval/values/r-value");
14
- const simple_visitor_1 = require("./simple-visitor");
15
14
  const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
16
- const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
15
+ const r_function_definition_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
16
+ const r_if_then_else_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else");
17
+ const r_parameter_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
17
18
  class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
18
19
  cachedConditions = new Map();
19
20
  cachedStatements = new Map();
20
21
  cachedSwitch = new Map();
21
- jumpIsolated = new Set();
22
+ caught = new Map();
22
23
  getValue(id) {
23
24
  const has = this.cachedConditions.get(id);
24
25
  if (has) {
@@ -28,7 +29,7 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
28
29
  return this.cachedConditions.get(id) ?? logic_1.Ternary.Maybe;
29
30
  }
30
31
  isUnconditionalJump(id) {
31
- if (this.jumpIsolated.has(id)) {
32
+ if (this.isCaught(id)) {
32
33
  return false;
33
34
  }
34
35
  const has = this.cachedStatements.get(id);
@@ -43,10 +44,10 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
43
44
  /** a parameter default is forced on access if at all, so a jump within it must not cut the function body */
44
45
  inParameterDefault(id) {
45
46
  for (let node = this.getNormalizedAst(id); node !== undefined; node = this.getNormalizedAst(node.info.parent)) {
46
- if (node.type === type_1.RType.Parameter) {
47
+ if (r_parameter_1.RParameter.is(node)) {
47
48
  return true;
48
49
  }
49
- else if (node.type === type_1.RType.FunctionDefinition) {
50
+ else if (r_function_definition_1.RFunctionDefinition.is(node)) {
50
51
  return false;
51
52
  }
52
53
  }
@@ -64,7 +65,7 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
64
65
  for (const [target, edge] of targets) {
65
66
  if (control_flow_graph_1.CfgEdge.isControlDependency(edge)) {
66
67
  const cause = control_flow_graph_1.CfgEdge.unpackCause(edge);
67
- if (this.switchArmDefinitelyNotTaken(cause, from)) {
68
+ if (this.switchArmDefinitelyNotTaken(cause, target)) {
68
69
  cfg.removeEdge(from, target);
69
70
  continue;
70
71
  }
@@ -77,15 +78,9 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
77
78
  cfg.removeEdge(from, target);
78
79
  }
79
80
  }
80
- else if (control_flow_graph_1.CfgEdge.isFlowDependency(edge) && this.isUnconditionalJump(target)) {
81
- // for each unconditional jump, we find the corresponding end/exit nodes and remove any flow edges
82
- for (const end of control_flow_graph_1.CfgVertex.getEnd(this.getCfgVertex(target)) ?? []) {
83
- for (const [target, edge] of cfg.ingoingEdges(end) ?? []) {
84
- if (control_flow_graph_1.CfgEdge.isFlowDependency(edge)) {
85
- cfg.removeEdge(target, end);
86
- }
87
- }
88
- }
81
+ else if (control_flow_graph_1.CfgEdge.isFlowDependency(edge) && this.isUnconditionalJump(from)) {
82
+ /* what follows an unconditional jump is never reached through it */
83
+ cfg.removeEdge(from, target);
89
84
  }
90
85
  }
91
86
  }
@@ -111,6 +106,14 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
111
106
  this.handleValuesFor(id, typeof data.condition === 'object' ? data.condition.nodeId : data.condition);
112
107
  }
113
108
  onIfThenElseCall(data) {
109
+ /*
110
+ * Only the `if` keyword leaves a branch unevaluated; `ifelse` and its relatives are ordinary functions
111
+ * whose arguments R evaluates whatever the condition says, so their arms are never dead.
112
+ */
113
+ if (!r_if_then_else_1.RIfThenElse.is(this.getNormalizedAst(data.call.id))) {
114
+ this.unableToCalculateValue(data.call.id);
115
+ return;
116
+ }
114
117
  this.handleWithCondition(data);
115
118
  }
116
119
  onWhileLoopCall(data) {
@@ -128,24 +131,27 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
128
131
  this.cachedStatements.set(data.call.id, !arg);
129
132
  }
130
133
  }
131
- protectSubgraph(nodeId) {
132
- const start = this.getCfgVertex(nodeId);
133
- if (!start) {
134
- return;
134
+ /**
135
+ * Whether an error raised here is caught before it can cut the flow, which is what `try` and `tryCatch`
136
+ * do to a `stop()` nested in them. The enclosing calls come from the AST: in the control flow graph a
137
+ * construct is where its parts join again, so there is no edge that would delimit it on its own.
138
+ */
139
+ isCaught(id) {
140
+ const cached = this.caught.get(id);
141
+ if (cached !== undefined) {
142
+ return cached;
135
143
  }
136
- (0, simple_visitor_1.visitCfgInOrder)(this.config.controlFlow.graph, [control_flow_graph_1.CfgVertex.getId(start)], n => {
137
- if (control_flow_graph_1.CfgVertex.getEnd(start)?.includes(n)) {
138
- return true;
144
+ let result = false;
145
+ for (let node = this.getNormalizedAst(id)?.info.parent; node !== undefined;) {
146
+ const vertex = this.getDataflowGraph(node);
147
+ if (vertex_1.FunctionCallVertex.is(vertex) && Array.isArray(vertex.origin) && vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.Try)) {
148
+ result = true;
149
+ break;
139
150
  }
140
- this.jumpIsolated.add(n);
141
- return false;
142
- });
143
- }
144
- onTryCall(data) {
145
- if (data.call.args.length < 1 || data.call.args[0] === r_function_call_1.EmptyArgument) {
146
- return;
151
+ node = this.getNormalizedAst(node)?.info.parent;
147
152
  }
148
- this.protectSubgraph(data.call.args[0].nodeId);
153
+ this.caught.set(id, result);
154
+ return result;
149
155
  }
150
156
  switchArmDefinitelyNotTaken(cause, from) {
151
157
  const v = this.config.dfg.getVertex(cause);
@@ -156,8 +162,13 @@ class CfgConditionalDeadCodeRemoval extends semantic_cfg_guided_visitor_1.Semant
156
162
  if (selected === 'unknown') {
157
163
  return false;
158
164
  }
159
- const isArm = v.args.slice(1).some(a => graph_1.FunctionArgument.getReference(a) !== undefined && graph_1.FunctionArgument.getId(a) === from);
160
- return isArm && from !== selected.id;
165
+ /*
166
+ * The control flow enters an arm at what it evaluates first, which for a named arm (`a = 1`) is its
167
+ * value rather than the argument that binds it.
168
+ */
169
+ const arm = v.args.slice(1).find(a => graph_1.FunctionArgument.getReference(a) !== undefined
170
+ && (graph_1.FunctionArgument.getId(a) === from || graph_1.FunctionArgument.getReference(a) === from));
171
+ return arm !== undefined && graph_1.FunctionArgument.getId(arm) !== selected.id;
161
172
  }
162
173
  selectedSwitchArm(v) {
163
174
  const cached = this.cachedSwitch.get(v.id);
@@ -19,8 +19,8 @@ const CfgProperties = {
19
19
  'at-most-one-out-fd': c => checkFdIOCount(c, 'out', 'at-most', 1),
20
20
  'exactly-one-out-fd': c => checkFdIOCount(c, 'out', 'exact', 1),
21
21
  */
22
- 'no-direct-fd-cycles': c => checkNoDirectCycles(c, 0 /* CfgEdgeType.Fd */),
23
- 'no-direct-cd-cycles': c => checkNoDirectCycles(c, 1 /* CfgEdgeType.Cd */),
22
+ 'no-direct-fd-cycles': c => checkNoDirectCycles(c, 0 /* CfgEdgeType.Flow */),
23
+ 'no-direct-cd-cycles': c => checkNoDirectCycles(c, 1 /* CfgEdgeType.Control */),
24
24
  };
25
25
  function checkSingleEntryAndExit(cfg) {
26
26
  return new Set(cfg.entryPoints).size === 1 && new Set(cfg.exitPoints).size === 1 && new Set(cfg.breaks).size === 0 &&