@eagleoutice/flowr 2.14.1 → 2.14.3

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 (419) hide show
  1. package/README.md +142 -87
  2. package/abstract-interpretation/absint-visitor.d.ts +132 -25
  3. package/abstract-interpretation/absint-visitor.js +459 -99
  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 +21 -8
  41. package/config.js +12 -5
  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 -3
  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 +114 -3
  71. package/dataflow/environments/default-builtin-config.js +137 -35
  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 +3 -3
  81. package/dataflow/eval/resolve/alias-tracking.js +3 -3
  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 +15 -6
  106. package/dataflow/info.js +0 -17
  107. package/dataflow/internal/control-flow.d.ts +114 -0
  108. package/dataflow/internal/control-flow.js +224 -0
  109. package/dataflow/internal/linker.d.ts +6 -31
  110. package/dataflow/internal/linker.js +24 -81
  111. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  112. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
  113. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
  114. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
  115. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  116. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
  117. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
  118. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
  119. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  120. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
  121. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
  122. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
  123. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  124. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  125. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
  126. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +18 -2
  127. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +12 -1
  128. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  129. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +38 -30
  130. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
  131. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  132. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +36 -8
  133. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  134. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
  135. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  136. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
  137. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
  138. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +9 -4
  139. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
  140. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
  141. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  142. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
  143. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
  144. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  145. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
  146. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  147. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +11 -2
  148. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  149. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
  150. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
  151. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
  152. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
  153. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
  154. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -2
  155. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +71 -33
  156. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
  157. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +13 -14
  158. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +14 -11
  160. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
  161. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  162. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
  163. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
  164. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  165. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
  166. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  167. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +50 -10
  168. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
  169. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +20 -4
  170. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
  171. package/dataflow/internal/process/functions/call/common.js +5 -6
  172. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  173. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
  174. package/dataflow/internal/process/functions/call/known-call-handling.js +41 -15
  175. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
  176. package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
  177. package/dataflow/internal/process/functions/call/nse.js +6 -1
  178. package/dataflow/internal/process/functions/call/quoted.js +2 -2
  179. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
  180. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  181. package/dataflow/internal/process/functions/process-argument.js +12 -4
  182. package/dataflow/internal/process/functions/process-parameter.js +13 -0
  183. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  184. package/dataflow/internal/process/process-named-call.js +9 -7
  185. package/documentation/data/server/doc-data-server-messages.js +4 -4
  186. package/documentation/doc-readme.js +33 -0
  187. package/documentation/doc-util/doc-cfg.d.ts +8 -7
  188. package/documentation/doc-util/doc-cfg.js +10 -10
  189. package/documentation/doc-util/doc-playground.d.ts +12 -0
  190. package/documentation/doc-util/doc-playground.js +21 -0
  191. package/documentation/doc-util/doc-query.d.ts +4 -1
  192. package/documentation/doc-util/doc-query.js +4 -2
  193. package/documentation/wiki-absint.d.ts +3 -4
  194. package/documentation/wiki-absint.js +17 -5
  195. package/documentation/wiki-analyzer.js +2 -2
  196. package/documentation/wiki-cfg.js +101 -106
  197. package/documentation/wiki-dataflow-graph.js +84 -53
  198. package/documentation/wiki-interface.js +1 -0
  199. package/documentation/wiki-linter.js +15 -1
  200. package/documentation/wiki-linting-and-testing.js +1 -16
  201. package/documentation/wiki-mk/doc-maker.js +6 -4
  202. package/documentation/wiki-query.js +14 -4
  203. package/documentation/wiki-signature-database.js +28 -2
  204. package/linter/linter-fix.d.ts +16 -0
  205. package/linter/linter-fix.js +104 -0
  206. package/linter/linter-format.d.ts +18 -1
  207. package/linter/linter-format.js +31 -1
  208. package/linter/linter-output.js +46 -10
  209. package/linter/linter-rules.d.ts +40 -9
  210. package/linter/linter-rules.js +2 -0
  211. package/linter/rules/absolute-path.js +4 -2
  212. package/linter/rules/dataframe-access-validation.js +6 -7
  213. package/linter/rules/deprecated-functions.d.ts +107 -10
  214. package/linter/rules/deprecated-functions.js +311 -23
  215. package/linter/rules/file-path-validity.js +5 -4
  216. package/linter/rules/function-finder-util.d.ts +6 -0
  217. package/linter/rules/function-finder-util.js +21 -13
  218. package/linter/rules/naming-convention.js +1 -1
  219. package/linter/rules/network-functions.d.ts +2 -2
  220. package/linter/rules/stop-with-call-arg.js +2 -2
  221. package/linter/rules/unclosed-connection.js +2 -2
  222. package/linter/rules/undefined-symbol-util.js +6 -4
  223. package/linter/rules/undefined-symbol.js +2 -2
  224. package/linter/rules/unused-definition.js +8 -4
  225. package/linter/rules/unused-import.d.ts +60 -0
  226. package/linter/rules/unused-import.js +179 -0
  227. package/package.json +2 -2
  228. package/project/attached-packages.js +2 -1
  229. package/project/cache/flowr-analyzer-cache.d.ts +2 -5
  230. package/project/cache/flowr-analyzer-cache.js +4 -7
  231. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
  232. package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
  233. package/project/cache/flowr-cache.d.ts +9 -0
  234. package/project/cache/flowr-cache.js +19 -0
  235. package/project/context/flowr-analyzer-context.d.ts +7 -3
  236. package/project/context/flowr-analyzer-context.js +15 -9
  237. package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
  238. package/project/context/flowr-analyzer-dependencies-context.js +9 -14
  239. package/project/context/flowr-analyzer-files-context.js +15 -17
  240. package/project/context/flowr-analyzer-meta-context.js +2 -12
  241. package/project/dependency-version-space.d.ts +1 -7
  242. package/project/dependency-version-space.js +9 -8
  243. package/project/flowr-analyzer-builder.d.ts +4 -4
  244. package/project/flowr-analyzer.d.ts +4 -6
  245. package/project/flowr-analyzer.js +4 -5
  246. package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -34
  247. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
  248. package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
  249. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
  250. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
  251. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
  252. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
  253. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
  254. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
  255. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
  256. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
  257. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
  258. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
  259. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
  260. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
  261. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
  262. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
  263. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
  264. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
  265. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
  266. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
  267. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
  268. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
  269. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
  270. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
  271. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
  272. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
  273. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
  274. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
  275. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
  276. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
  277. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
  278. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
  279. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
  280. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
  281. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
  282. package/project/sigdb/build.d.ts +2 -2
  283. package/project/sigdb/decode.d.ts +0 -5
  284. package/project/sigdb/decode.js +0 -8
  285. package/project/sigdb/index-format.d.ts +4 -4
  286. package/project/sigdb/manifest.d.ts +2 -2
  287. package/project/sigdb/reader.d.ts +54 -13
  288. package/project/sigdb/reader.js +4 -3
  289. package/project/sigdb/schema.d.ts +3 -1
  290. package/project/sigdb/signature-db.d.ts +69 -0
  291. package/project/sigdb/signature-db.js +54 -0
  292. package/project/sigdb/signature-match.d.ts +10 -5
  293. package/project/sigdb/signature-match.js +13 -8
  294. package/queries/catalog/absint-query/absint-query-executor.js +1 -2
  295. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
  296. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  297. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
  298. package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
  299. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  300. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
  301. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
  302. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
  303. package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
  304. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
  305. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
  306. package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
  307. package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
  308. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  309. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
  310. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
  311. package/queries/catalog/signature-query/signature-query-executor.js +4 -3
  312. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  313. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  314. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  315. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  316. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  317. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
  318. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
  319. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  320. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  321. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  322. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  323. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  324. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  325. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  326. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  327. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  328. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  329. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
  330. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
  331. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  332. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  333. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  334. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  335. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  336. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  337. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  338. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  339. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  340. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  341. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
  342. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
  343. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +8 -0
  344. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +8 -0
  345. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  346. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  347. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  350. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  352. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  355. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  356. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  357. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  358. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  359. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
  360. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +5 -1
  361. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +0 -5
  362. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  363. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
  364. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
  365. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
  366. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  367. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
  368. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
  369. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
  370. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
  371. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
  372. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
  373. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
  374. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
  375. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
  376. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
  377. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
  378. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
  379. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
  380. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
  381. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
  382. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
  383. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
  384. package/reconstruct/inline/source-inline-map.js +3 -3
  385. package/reconstruct/reconstruct.js +6 -4
  386. package/search/flowr-search-builder.d.ts +8 -8
  387. package/search/flowr-search-builder.js +4 -4
  388. package/search/flowr-search-filters.d.ts +2 -2
  389. package/search/flowr-search-filters.js +3 -2
  390. package/search/search-executor/search-enrichers.d.ts +6 -0
  391. package/search/search-executor/search-enrichers.js +44 -5
  392. package/slicing/criterion/filters/all-variables.js +2 -1
  393. package/slicing/criterion/parse.js +8 -6
  394. package/slicing/static/slice-call.js +2 -2
  395. package/util/arg-matching.d.ts +3 -0
  396. package/util/arg-matching.js +12 -1
  397. package/util/collections/arrays.d.ts +0 -4
  398. package/util/collections/arrays.js +4 -26
  399. package/util/diff-graph.d.ts +1 -1
  400. package/util/diff-graph.js +17 -3
  401. package/util/diff.d.ts +6 -0
  402. package/util/mermaid/ast.d.ts +1 -1
  403. package/util/mermaid/ast.js +5 -4
  404. package/util/mermaid/cfg.js +130 -24
  405. package/util/mermaid/dfg.js +31 -10
  406. package/util/mermaid/mermaid.js +2 -0
  407. package/util/objects.d.ts +24 -4
  408. package/util/objects.js +12 -0
  409. package/util/prefix.d.ts +1 -1
  410. package/util/text/playground-link.d.ts +131 -0
  411. package/util/text/playground-link.js +214 -0
  412. package/util/text/strings.js +7 -3
  413. package/util/version.js +1 -1
  414. package/control-flow/cfg-builder.d.ts +0 -30
  415. package/control-flow/cfg-builder.js +0 -79
  416. package/control-flow/extract-cfg.d.ts +0 -36
  417. package/control-flow/extract-cfg.js +0 -693
  418. package/project/cfg-kind.d.ts +0 -21
  419. package/project/cfg-kind.js +0 -26
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processWithEnv = processWithEnv;
4
+ const match_args_1 = require("../../../../../graph/match-args");
4
5
  const processor_1 = require("../../../../../processor");
5
6
  const known_call_handling_1 = require("../known-call-handling");
6
- const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
7
  const identifier_1 = require("../../../../../environments/identifier");
8
8
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
9
9
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
10
10
  const common_1 = require("../common");
11
11
  const edge_1 = require("../../../../../graph/edge");
12
+ const control_flow_1 = require("../../../../control-flow");
12
13
  const linker_1 = require("../../../../linker");
13
14
  /** Fallback formal parameter names for `with(data, expr, ...)` / `within(data, expr, ...)` when the signature database has no `base::with`. */
14
15
  const withParamsFallback = ['data', 'expr'];
@@ -40,7 +41,7 @@ function processWithEnv(name, args, rootId, data) {
40
41
  }
41
42
  // prefer R's real `base::with` signature from the database, falling back to the known formals when it is absent
42
43
  // use the call's own name (`with` or `within`) qualified to base, so each gets its real signature
43
- const bound = r_function_call_1.RFunctionCall.matchArgsToParams(args, (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make(identifier_1.Identifier.getName(name.content), "base" /* PkgName.Base */), withParamsFallback));
44
+ const bound = match_args_1.MatchArgs.toNames(args, (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make(identifier_1.Identifier.getName(name.content), "base" /* PkgName.Base */), withParamsFallback));
44
45
  const dataArg = bound.get('data');
45
46
  const exprArg = bound.get('expr');
46
47
  // when we cannot resolve the data to a tracked environment, `expr` is still data-masked: its symbols name
@@ -77,6 +78,7 @@ function processWithEnv(name, args, rootId, data) {
77
78
  });
78
79
  const merged = dfDataArg.graph.mergeWith(dfExpr.graph);
79
80
  merged.addEdge(rootId, envirResolution.envirNodeId, edge_1.EdgeType.Reads);
81
+ const cfgEntry = control_flow_1.ControlFlow.inSequence(merged, [dfDataArg, dfExpr], rootId);
80
82
  const ingoing = dfDataArg.in.concat(dfExpr.in, dfDataArg.unknownReferences, remainingFromExpr, /* unresolved expr refs propagate to outer scope */ [{ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function }]);
81
83
  /* within routes body writes back into the data environment; with discards them */
82
84
  const isWithin = identifier_1.Identifier.getName(name.content) === 'within';
@@ -91,6 +93,8 @@ function processWithEnv(name, args, rootId, data) {
91
93
  exitPoints: dfDataArg.exitPoints.concat(dfExpr.exitPoints),
92
94
  graph: merged,
93
95
  entryPoint: rootId,
96
+ cfgEntry,
97
+ cfgExit: rootId,
94
98
  in: ingoing,
95
99
  out: [], /* writes are inside envState, not directly in outer scope */
96
100
  unknownReferences: []
@@ -17,7 +17,6 @@ const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/no
17
17
  const identifier_1 = require("../../../../environments/identifier");
18
18
  const overwrite_1 = require("../../../../environments/overwrite");
19
19
  const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
20
- const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
21
20
  const process_argument_1 = require("../process-argument");
22
21
  const vertex_1 = require("../../../../graph/vertex");
23
22
  const edge_1 = require("../../../../graph/edge");
@@ -68,10 +67,10 @@ function convertFnArguments(args) {
68
67
  * Please be aware, that the ids here are those inferred from the AST, not from the dataflow graph!
69
68
  */
70
69
  function convertFnArgument(arg) {
71
- if (arg === r_function_call_1.EmptyArgument) {
70
+ if (r_argument_1.RArgument.isEmpty(arg)) {
72
71
  return r_function_call_1.EmptyArgument;
73
72
  }
74
- else if (!arg.name || arg.type !== type_1.RType.Argument) {
73
+ else if (!arg.name || !r_argument_1.RArgument.is(arg)) {
75
74
  return { nodeId: arg.info.id, cds: undefined, type: identifier_1.ReferenceType.Argument };
76
75
  }
77
76
  else {
@@ -99,7 +98,7 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
99
98
  i++;
100
99
  data = { ...data, environment: argEnv };
101
100
  data = patchData?.(data, i) ?? data;
102
- if (arg === r_function_call_1.EmptyArgument) {
101
+ if (r_argument_1.RArgument.isEmpty(arg)) {
103
102
  callArgs.push(r_function_call_1.EmptyArgument);
104
103
  processedArguments.push(undefined);
105
104
  continue;
@@ -109,7 +108,7 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
109
108
  processed = data.precomputedFirstArg.info;
110
109
  }
111
110
  else {
112
- processed = arg.type === type_1.RType.Argument ? (0, process_argument_1.processFunctionArgument)(arg, data) : (0, processor_1.processDataflowFor)(arg, data);
111
+ processed = r_argument_1.RArgument.is(arg) ? (0, process_argument_1.processFunctionArgument)(arg, data) : (0, processor_1.processDataflowFor)(arg, data);
113
112
  }
114
113
  if (r_argument_1.RArgument.isWithValue(arg) && (forceArgs === 'all' || forceArgs[i]) && !model_1.RConstant.is(arg.value)) {
115
114
  forceVertexArgumentValueReferences(functionRootId, processed, processed.graph, data.environment);
@@ -150,7 +149,7 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
150
149
  }
151
150
  }
152
151
  argEnv = (0, overwrite_1.overwriteEnvironment)(argEnv, processed.environment);
153
- if (arg.type !== type_1.RType.Argument || !arg.name) {
152
+ if (!r_argument_1.RArgument.is(arg) || !arg.name) {
154
153
  callArgs.push({ nodeId: processed.entryPoint, cds: undefined, type: identifier_1.ReferenceType.Argument });
155
154
  }
156
155
  else {
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Deferred = void 0;
4
4
  const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
5
5
  const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
6
- const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
7
6
  const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
8
7
  const identifier_1 = require("../../../../environments/identifier");
9
8
  const retriever_1 = require("../../../../../r-bridge/retriever");
@@ -12,6 +11,7 @@ const vertex_1 = require("../../../../graph/vertex");
12
11
  const happens_before_1 = require("../../../../../control-flow/happens-before");
13
12
  const logic_1 = require("../../../../../util/logic");
14
13
  const graph_1 = require("../../../../graph/graph");
14
+ const r_symbol_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
15
15
  /** Drops the read of `target` from `use`, for a binding another write has replaced. */
16
16
  function dropRead(graph, use, target) {
17
17
  graph.removeEdgeType(use, target, edge_1.EdgeType.Reads);
@@ -38,7 +38,7 @@ function namesWithin(expr, graph, idMap) {
38
38
  callees.add(inner.functionName.info.id);
39
39
  return false;
40
40
  }
41
- else if (inner.type !== type_1.RType.Symbol || callees.has(inner.info.id)) {
41
+ else if (!r_symbol_1.RSymbol.is(inner) || callees.has(inner.info.id)) {
42
42
  return false;
43
43
  }
44
44
  const vertex = graph.getVertex(inner.info.id);
@@ -3,7 +3,7 @@ import type { DataflowInformation } from '../../../../info';
3
3
  import { type ForceArguments } from './common';
4
4
  import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
5
5
  import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
- import type { PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
6
+ import { type PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
7
7
  import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
9
9
  import { type IdentifierReference } from '../../../../environments/identifier';
@@ -31,6 +31,16 @@ export interface ProcessKnownFunctionCallInput<OtherInfo> extends ForceArguments
31
31
  readonly origin: FunctionOriginInformation | 'default';
32
32
  /** see {@link ProcessAllArgumentInput#nonFunction} */
33
33
  readonly nonFunction?: ReadonlySet<NodeId>;
34
+ /**
35
+ * Suppress the default control flow linkage (arguments in order, then the call).
36
+ * Constructs that branch or loop set this and wire their control flow themselves.
37
+ */
38
+ readonly customControlFlow?: boolean;
39
+ /**
40
+ * From this argument index on, the arguments are alternatives of which at most one is evaluated,
41
+ * which is how `switch` picks an arm. The arguments before it are evaluated in order as usual.
42
+ */
43
+ readonly alternativeArgsFrom?: number;
34
44
  }
35
45
  /** The result of processing a known function call. */
36
46
  export interface ProcessKnownFunctionCallResult {
@@ -86,4 +96,4 @@ export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGrap
86
96
  * The main processor for function calls for which we know the target but need not
87
97
  * add any specific handling.
88
98
  */
89
- export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin, nonFunction }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
99
+ export declare function processKnownFunctionCall<OtherInfo>({ name, args, rootId, data, reverseOrder, markAsNSE, forceArgs, patchData, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom }: ProcessKnownFunctionCallInput<OtherInfo>): ProcessKnownFunctionCallResult;
@@ -5,9 +5,12 @@ exports.markArgumentsAsNonStandardEvaluation = markArgumentsAsNonStandardEvaluat
5
5
  exports.processKnownFunctionCall = processKnownFunctionCall;
6
6
  const processor_1 = require("../../../../processor");
7
7
  const common_1 = require("./common");
8
+ const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
+ const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
8
10
  const identifier_1 = require("../../../../environments/identifier");
9
11
  const graph_1 = require("../../../../graph/graph");
10
12
  const edge_1 = require("../../../../graph/edge");
13
+ const control_flow_1 = require("../../../control-flow");
11
14
  const logger_1 = require("../../../../logger");
12
15
  const vertex_1 = require("../../../../graph/vertex");
13
16
  const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
@@ -90,7 +93,7 @@ function markArgument(graph, rootId, arg, kind, evaluated) {
90
93
  * The main processor for function calls for which we know the target but need not
91
94
  * add any specific handling.
92
95
  */
93
- function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, forceArgs, patchData = d => d, hasUnknownSideEffect, origin, nonFunction }) {
96
+ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = false, markAsNSE = undefined, forceArgs, patchData = d => d, hasUnknownSideEffect, origin, nonFunction, customControlFlow, alternativeArgsFrom }) {
94
97
  const functionName = (0, processor_1.processDataflowFor)(name, data);
95
98
  const finalGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
96
99
  const functionCallName = name.content;
@@ -117,22 +120,44 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
117
120
  inIds.push(fnRef);
118
121
  // if force args is not none, we need to collect all non-default exit points from our arguments!
119
122
  let exitPoints = undefined;
120
- if (forceArgs === 'all') {
121
- const nonDefaults = processedArguments.flatMap(p => p ? p.exitPoints.filter(ep => ep.type !== 0 /* ExitPointType.Default */) : []);
122
- if (nonDefaults.length > 0) {
123
- exitPoints = nonDefaults;
123
+ /* a jump that only happens under a condition still lets the call complete, so its default exit has to stay */
124
+ let alwaysJumps = false;
125
+ if (forceArgs) {
126
+ for (let i = 0; i < processedArguments.length; i++) {
127
+ const p = processedArguments[i];
128
+ if (p === undefined || (forceArgs !== 'all' && !forceArgs[i])) {
129
+ continue;
130
+ }
131
+ const before = exitPoints?.length ?? 0;
132
+ for (const exit of p.exitPoints) {
133
+ if (exit.type !== 0 /* ExitPointType.Default */) {
134
+ (exitPoints ??= []).push(exit);
135
+ }
136
+ }
137
+ alwaysJumps ||= (exitPoints?.length ?? 0) > before && control_flow_1.ControlFlow.alwaysExits(p);
138
+ }
139
+ if (exitPoints !== undefined && !alwaysJumps) {
140
+ exitPoints.push({ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds });
124
141
  }
125
142
  }
126
- else if (forceArgs) {
127
- for (let i = 0; i < forceArgs.length; i++) {
128
- if (forceArgs[i]) {
129
- const p = processedArguments[i];
130
- if (p) {
131
- const nonDefaults = p.exitPoints.filter(ep => ep.type !== 0 /* ExitPointType.Default */);
132
- if (nonDefaults.length > 0) {
133
- exitPoints ??= [];
134
- exitPoints.push(...nonDefaults);
135
- }
143
+ /* an alternative without a name is the default arm, which runs when nothing else matched */
144
+ const cfgEntry = customControlFlow ? rootId
145
+ : alternativeArgsFrom === undefined ? control_flow_1.ControlFlow.inSequence(finalGraph, processedArguments, rootId)
146
+ : control_flow_1.ControlFlow.picksOneOf(finalGraph, processedArguments, alternativeArgsFrom, rootId, processArgs.slice(alternativeArgsFrom).some(a => a !== r_function_call_1.EmptyArgument && (!r_argument_1.RArgument.is(a) || a.name === undefined)));
147
+ if (!customControlFlow) {
148
+ /*
149
+ * A jump within an argument that the call does not pass on is caught here (the callee decides whether it
150
+ * ever forces that argument), so control resumes at the call rather than leaving it.
151
+ */
152
+ for (const argument of processedArguments) {
153
+ for (const exit of argument?.exitPoints ?? []) {
154
+ /*
155
+ * A jump within an argument the call does not pass on resumes at the call. A `return` leaves the
156
+ * enclosing function wherever the argument runs at all, so only a call that never evaluates it
157
+ * may catch one (see `processQuote`).
158
+ */
159
+ if (exit.type !== 0 /* ExitPointType.Default */ && exit.type !== 1 /* ExitPointType.Return */ && !exitPoints?.includes(exit)) {
160
+ finalGraph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
136
161
  }
137
162
  }
138
163
  }
@@ -146,6 +171,7 @@ function processKnownFunctionCall({ name, args, rootId, data, reverseOrder = fal
146
171
  graph: finalGraph,
147
172
  environment: finalEnv,
148
173
  entryPoint: rootId,
174
+ cfgEntry: cfgEntry === rootId ? undefined : cfgEntry,
149
175
  exitPoints: exitPoints ?? [{ nodeId: rootId, type: 0 /* ExitPointType.Default */, cds: data.cds }],
150
176
  hooks: functionName.hooks
151
177
  },
@@ -25,6 +25,8 @@ function mergeInformation(info, newInfo) {
25
25
  graph: info.graph.mergeWith(newInfo.graph),
26
26
  environment: (0, append_1.appendEnvironment)(info.environment, newInfo.environment),
27
27
  entryPoint: newInfo.entryPoint,
28
+ cfgEntry: newInfo.cfgEntry,
29
+ cfgExit: newInfo.cfgExit,
28
30
  exitPoints: info.exitPoints.concat(newInfo.exitPoints),
29
31
  hooks: info.hooks.concat(newInfo.hooks)
30
32
  };
@@ -1,5 +1,5 @@
1
1
  import { RNode } from '../../../../../r-bridge/lang-4.x/ast/model/model';
2
- import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import { Identifier } from '../../../../environments/identifier';
5
5
  import { type DataflowGraph } from '../../../../graph/graph';
@@ -4,11 +4,13 @@ exports.Nse = exports.Unquote = void 0;
4
4
  const model_1 = require("../../../../../r-bridge/lang-4.x/ast/model/model");
5
5
  const r_unary_op_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
6
6
  const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
+ const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
7
8
  const identifier_1 = require("../../../../environments/identifier");
8
9
  const data_masking_functions_1 = require("../../../../environments/data-masking-functions");
9
10
  const graph_1 = require("../../../../graph/graph");
10
11
  const vertex_1 = require("../../../../graph/vertex");
11
12
  const edge_1 = require("../../../../graph/edge");
13
+ const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
12
14
  /** The escape a quoting function offers, a property of the function: `quote(!!x)` negates, `expr(!!x)` splices. */
13
15
  var Unquote;
14
16
  (function (Unquote) {
@@ -26,7 +28,7 @@ function unquotedOperandOf(node, style) {
26
28
  return undefined;
27
29
  }
28
30
  const arg = node.arguments[0];
29
- return arg === r_function_call_1.EmptyArgument ? undefined : arg.value;
31
+ return r_argument_1.RArgument.isEmpty(arg) ? undefined : arg.value;
30
32
  }
31
33
  if (!isNegation(node) || !isNegation(node.operand)) {
32
34
  return undefined;
@@ -47,6 +49,9 @@ function isNegation(node) {
47
49
  * tell that it does not. Only where nothing at all can be attached is a function ruled out as an operand.
48
50
  */
49
51
  function definesAFunction(graph, id) {
52
+ if (node_id_1.NodeId.isBuiltIn(id)) {
53
+ return true;
54
+ }
50
55
  const vertex = graph.getVertex(id);
51
56
  if (vertex_1.FunctionDefinitionVertex.is(vertex)) {
52
57
  return true;
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Quoted = void 0;
4
4
  const r_function_call_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
5
- const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
6
5
  const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
7
6
  const identifier_1 = require("../../../../environments/identifier");
8
7
  const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
@@ -13,6 +12,7 @@ const linker_1 = require("../../../linker");
13
12
  const nse_1 = require("./nse");
14
13
  const deferred_1 = require("./deferred");
15
14
  const vertex_2 = require("../../../../graph/vertex");
15
+ const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
16
16
  /** Calls capturing a language object. */
17
17
  const CapturingProcessors = [built_in_proc_name_1.BuiltInProcName.Quote];
18
18
  /** Calls capturing an expression as a promise, forced at some later read of the variable they bind. */
@@ -186,7 +186,7 @@ function* escapingArguments(graph, id) {
186
186
  /** The value an argument reference points at. */
187
187
  function unwrapArgument(reference, idMap) {
188
188
  const node = reference === undefined ? undefined : idMap.get(reference);
189
- return node?.type === type_1.RType.Argument ? node.value?.info.id : reference;
189
+ return r_argument_1.RArgument.is(node) ? node.value?.info.id : reference;
190
190
  }
191
191
  /** `eval(expr, envir)` runs elsewhere, so the bindings here say nothing. */
192
192
  function evaluatesElsewhere(call) {
@@ -2,18 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnnamedFunctionCallPrefix = void 0;
4
4
  exports.processUnnamedFunctionCall = processUnnamedFunctionCall;
5
+ const match_args_1 = require("../../../../graph/match-args");
5
6
  const processor_1 = require("../../../../processor");
7
+ const control_flow_1 = require("../../../control-flow");
6
8
  const common_1 = require("./common");
7
- const linker_1 = require("../../../linker");
8
9
  const edge_1 = require("../../../../graph/edge");
9
10
  const graph_1 = require("../../../../graph/graph");
10
11
  const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
11
12
  const vertex_1 = require("../../../../graph/vertex");
12
- const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
13
13
  const logger_1 = require("../../../../logger");
14
14
  const identifier_1 = require("../../../../environments/identifier");
15
15
  const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
16
16
  const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
17
+ const r_access_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
18
+ const r_function_definition_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
17
19
  exports.UnnamedFunctionCallPrefix = 'unnamed-fc-';
18
20
  /**
19
21
  * Whether a `$`/`[[` access callee resolved a field to a stored function: a resolved dispatch (`dispatch$foo()`)
@@ -48,7 +50,7 @@ function processUnnamedFunctionCall(functionCall, data) {
48
50
  finalGraph.addEdge(functionRootId, calledRootId, edge_1.EdgeType.Reads);
49
51
  // keep the defined function
50
52
  finalGraph.mergeWith(calledFunction.graph);
51
- const { finalEnv, callArgs, remainingReadInArgs } = (0, common_1.processAllArguments)({
53
+ const { finalEnv, callArgs, remainingReadInArgs, processedArguments } = (0, common_1.processAllArguments)({
52
54
  functionName: calledFunction,
53
55
  args: functionCall.arguments,
54
56
  data,
@@ -67,13 +69,22 @@ function processUnnamedFunctionCall(functionCall, data) {
67
69
  args: callArgs, // same reference
68
70
  origin: [built_in_proc_name_1.BuiltInProcName.Unnamed]
69
71
  }, data.ctx.env.makeCleanEnv());
72
+ const cfgEntry = control_flow_1.ControlFlow.inSequence(finalGraph, [calledFunction, ...processedArguments], functionRootId);
73
+ /* a jump within an argument is caught here, just like for a named call */
74
+ for (const argument of processedArguments) {
75
+ for (const exit of argument?.exitPoints ?? []) {
76
+ if (exit.type !== 0 /* ExitPointType.Default */) {
77
+ finalGraph.addEdge(exit.nodeId, functionRootId, edge_1.EdgeType.FlowEdge);
78
+ }
79
+ }
80
+ }
70
81
  let inIds = remainingReadInArgs;
71
82
  inIds.push({ nodeId: functionRootId, name: functionCallName, cds: data.cds, type: identifier_1.ReferenceType.Function });
72
83
  // if we just call a nested fdef
73
- if (functionCall.calledFunction.type === type_1.RType.FunctionDefinition) {
74
- (0, linker_1.linkArgumentsOnCall)(callArgs, functionCall.calledFunction.parameters, finalGraph);
84
+ if (r_function_definition_1.RFunctionDefinition.is(functionCall.calledFunction)) {
85
+ match_args_1.MatchArgs.onCallAndLink(callArgs, functionCall.calledFunction.parameters, finalGraph);
75
86
  }
76
- else if (functionCall.calledFunction.type === type_1.RType.Access && !accessResolvesToField(finalGraph, calledRootId, functionCall.calledFunction.accessed.info.id)) {
87
+ else if (r_access_1.RAccess.is(functionCall.calledFunction) && !accessResolvesToField(finalGraph, calledRootId, functionCall.calledFunction.accessed.info.id)) {
77
88
  // `obj$method()` whose callee did not resolve to a stored function: reached-but-unknown rather than dropped
78
89
  (0, unknown_side_effect_1.handleUnknownSideEffect)(finalGraph, data.environment, functionRootId);
79
90
  }
@@ -87,6 +98,8 @@ function processUnnamedFunctionCall(functionCall, data) {
87
98
  graph: finalGraph,
88
99
  environment: finalEnv,
89
100
  entryPoint: functionCall.info.id,
101
+ cfgEntry: cfgEntry === functionRootId ? undefined : cfgEntry,
102
+ cfgExit: functionRootId,
90
103
  exitPoints: calledFunction.exitPoints,
91
104
  hooks: calledFunction.hooks,
92
105
  };
@@ -4,7 +4,7 @@ import type { ParentInformation } from '../../../../r-bridge/lang-4.x/ast/model/
4
4
  import { RNode } from '../../../../r-bridge/lang-4.x/ast/model/model';
5
5
  import type { IdentifierReference } from '../../../environments/identifier';
6
6
  import { DataflowGraph } from '../../../graph/graph';
7
- import type { RArgument } from '../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
7
+ import { RArgument } from '../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
8
8
  /**
9
9
  * Links all reads that occur before the argument to the argument root node.
10
10
  */
@@ -5,15 +5,17 @@ exports.processFunctionArgument = processFunctionArgument;
5
5
  const processor_1 = require("../../../processor");
6
6
  const model_1 = require("../../../../r-bridge/lang-4.x/ast/model/model");
7
7
  const graph_1 = require("../../../graph/graph");
8
- const type_1 = require("../../../../r-bridge/lang-4.x/ast/model/type");
9
8
  const edge_1 = require("../../../graph/edge");
9
+ const control_flow_1 = require("../../control-flow");
10
+ const r_argument_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
10
11
  const vertex_1 = require("../../../graph/vertex");
12
+ const r_function_definition_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
11
13
  /**
12
14
  * Links all reads that occur before the argument to the argument root node.
13
15
  */
14
16
  function linkReadsForArgument(root, ingoingRefs, graph) {
15
17
  const rid = root.info.id;
16
- const allIdsBeforeArguments = new Set(model_1.RNode.collectAllIdsWithStop(root, n => n.type === type_1.RType.Argument && n.info.id !== rid));
18
+ const allIdsBeforeArguments = new Set(model_1.RNode.collectAllIdsWithStop(root, n => r_argument_1.RArgument.is(n) && n.info.id !== rid));
17
19
  const ingoingBeforeArgs = ingoingRefs.filter(r => allIdsBeforeArguments.has(r.nodeId));
18
20
  for (const ref of ingoingBeforeArgs) {
19
21
  // link against the root reference currently I do not know how to deal with nested function calls otherwise
@@ -50,7 +52,10 @@ function processFunctionArgument(argument, data) {
50
52
  entryPoint = argument.info.id;
51
53
  }
52
54
  const ingoingRefs = value ? value.unknownReferences.concat(value.in, name?.in ?? []) : name?.in;
53
- if (entryPoint && argument.value?.type === type_1.RType.FunctionDefinition) {
55
+ if (argumentName && value) {
56
+ control_flow_1.ControlFlow.continuesWith(graph, value, argument.info.id);
57
+ }
58
+ if (entryPoint && r_function_definition_1.RFunctionDefinition.is(argument.value)) {
54
59
  graph.addEdge(entryPoint, argument.value.info.id, edge_1.EdgeType.Reads);
55
60
  }
56
61
  else if (argumentName && ingoingRefs) {
@@ -65,8 +70,11 @@ function processFunctionArgument(argument, data) {
65
70
  graph: graph,
66
71
  environment: value?.environment ?? data.environment,
67
72
  entryPoint: entryPoint ?? argument.info.id,
73
+ cfgEntry: argumentName ? (value ? control_flow_1.ControlFlow.entryOf(value) : undefined) : value?.cfgEntry,
74
+ cfgExit: argumentName ? argument.info.id : value?.cfgExit,
68
75
  exitPoints: value?.exitPoints ?? name?.exitPoints ?? [{ nodeId: argument.info.id, type: 0 /* ExitPointType.Default */, cds: data.cds }],
69
- hooks: []
76
+ hooks: [],
77
+ kill: value?.kill
70
78
  };
71
79
  }
72
80
  //# sourceMappingURL=process-argument.js.map
@@ -6,6 +6,7 @@ const log_1 = require("../../../../util/log");
6
6
  const identifier_1 = require("../../../environments/identifier");
7
7
  const define_1 = require("../../../environments/define");
8
8
  const edge_1 = require("../../../graph/edge");
9
+ const control_flow_1 = require("../../control-flow");
9
10
  const r_function_definition_1 = require("../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
10
11
  /**
11
12
  *
@@ -38,6 +39,16 @@ function processFunctionParameter(parameter, data) {
38
39
  }
39
40
  }
40
41
  }
42
+ const boundAt = name.entryPoint;
43
+ if (defaultValue !== undefined) {
44
+ control_flow_1.ControlFlow.continuesWith(graph, defaultValue, boundAt);
45
+ for (const exit of defaultValue.exitPoints) {
46
+ /* R only forces a default when the parameter is used, so a jump within one does not cut the binding */
47
+ if (exit.type !== 0 /* ExitPointType.Default */) {
48
+ graph.addEdge(exit.nodeId, boundAt, edge_1.EdgeType.FlowEdge);
49
+ }
50
+ }
51
+ }
41
52
  return {
42
53
  unknownReferences: [],
43
54
  in: defaultValue === undefined ? [] : defaultValue.in.concat(defaultValue.unknownReferences, name.in),
@@ -45,6 +56,8 @@ function processFunctionParameter(parameter, data) {
45
56
  graph: graph,
46
57
  environment: environment,
47
58
  entryPoint: parameter.info.id,
59
+ cfgEntry: defaultValue === undefined ? boundAt : control_flow_1.ControlFlow.entryOf(defaultValue),
60
+ cfgExit: boundAt,
48
61
  exitPoints: [{ nodeId: parameter.info.id, type: 0 /* ExitPointType.Default */, cds: data.cds }],
49
62
  hooks: []
50
63
  };
@@ -4,8 +4,8 @@ import type { RAstNodeBase, RNode, Location } from '../../../r-bridge/lang-4.x/a
4
4
  import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
5
  import { EmptyArgument, type RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
6
6
  import type { Identifier } from '../../environments/identifier';
7
- import type { RBinaryOp } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
8
- import type { RPipe } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe';
7
+ import { RBinaryOp } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
8
+ import { RPipe } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe';
9
9
  /**
10
10
  * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
11
11
  */
@@ -8,6 +8,8 @@ const process_argument_1 = require("./functions/process-argument");
8
8
  const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
9
9
  const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
10
10
  const r_argument_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
11
+ const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
12
+ const r_pipe_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
11
13
  const assert_1 = require("../../../util/assert");
12
14
  /**
13
15
  * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
@@ -22,10 +24,10 @@ function processAsNamedCall({ info, lexeme, location }, data, name, args) {
22
24
  }, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), info.id, data);
23
25
  }
24
26
  function isBinaryOpOrPipe(node) {
25
- return node.type === type_1.RType.BinaryOp || node.type === type_1.RType.Pipe;
27
+ return r_binary_op_1.RBinaryOp.is(node) || r_pipe_1.RPipe.is(node);
26
28
  }
27
29
  function isInfixSpecialCall(node) {
28
- return node.type === type_1.RType.FunctionCall && node.named === true && node.infixSpecial === true && node.arguments.length === 2;
30
+ return r_function_call_1.RFunctionCall.isNamed(node) && node.infixSpecial === true && node.arguments.length === 2;
29
31
  }
30
32
  function isChainNode(node) {
31
33
  return node !== undefined && (isBinaryOpOrPipe(node) || isInfixSpecialCall(node));
@@ -38,15 +40,15 @@ function isChainNode(node) {
38
40
  * {@link RArgument}, so those need unwrapping via `.value` first.
39
41
  */
40
42
  function chainLhsRaw(node) {
41
- if (node.type === type_1.RType.FunctionCall) {
43
+ if (r_function_call_1.RFunctionCall.is(node)) {
42
44
  const arg = node.arguments[0];
43
- return arg === r_function_call_1.EmptyArgument ? undefined : arg.value;
45
+ return r_argument_1.RArgument.isEmpty(arg) ? undefined : arg.value;
44
46
  }
45
47
  return r_argument_1.RArgument.is(node.lhs) ? node.lhs.value : node.lhs;
46
48
  }
47
49
  /** The left operand of a chain node, wrapped as the {@link RArgument} that {@link processAllArguments} would process it as. */
48
50
  function chainLhsArgument(node, idMap) {
49
- if (node.type === type_1.RType.FunctionCall) {
51
+ if (r_function_call_1.RFunctionCall.is(node)) {
50
52
  const arg = node.arguments[0];
51
53
  (0, assert_1.guard)(arg !== r_function_call_1.EmptyArgument, 'an infix-special call always has a non-empty first argument');
52
54
  return arg;
@@ -64,14 +66,14 @@ function chainLhsArgument(node, idMap) {
64
66
  * `data.precomputedFirstArg` (keyed by `node.info.id`) to avoid recursing into it again.
65
67
  */
66
68
  function processSingleChainNode(node, data) {
67
- if (node.type === type_1.RType.FunctionCall) {
69
+ if (r_function_call_1.RFunctionCall.is(node)) {
68
70
  return (0, named_call_handling_1.processNamedCall)(node.functionName, node.arguments, node.info.id, data);
69
71
  }
70
72
  const { info, lexeme, location, lhs, rhs } = node;
71
73
  return (0, named_call_handling_1.processNamedCall)({
72
74
  type: type_1.RType.Symbol,
73
75
  info,
74
- content: node.type === type_1.RType.Pipe ? lexeme : node.operator,
76
+ content: r_pipe_1.RPipe.is(node) ? lexeme : node.operator,
75
77
  lexeme,
76
78
  location,
77
79
  }, (0, make_argument_1.wrapArgumentsUnnamed)([lhs, rhs], data.completeAst.idMap), info.id, data);
@@ -142,9 +142,9 @@ ${await (0, doc_server_message_1.documentServerMessageResponse)({
142
142
  <a id="analysis-include-cfg"></a>
143
143
  **Including the Control Flow Graph**
144
144
 
145
- While _flowR_ does (for the time being) not use an explicit control flow graph but instead relies on control-dependency edges within the dataflow graph,
146
- the respective structure can still be exposed using the server (note that, as this feature is not needed within _flowR_, it is tested significantly less -
147
- so please create a [new issue](${doc_issue_1.NewIssueUrl}) for any bug you may encounter).
145
+ The control flow graph is a view on the dataflow graph: the dataflow analysis records the control flow while it walks
146
+ the program, and the graph projects those edges on demand. The server can expose that structure as well (please create
147
+ a [new issue](${doc_issue_1.NewIssueUrl}) for any bug you may encounter).
148
148
  For this, the analysis request may add \`cfg: true\` to its list of options.
149
149
 
150
150
  ${await (0, doc_server_message_1.documentServerMessageResponse)({
@@ -307,7 +307,7 @@ The \`results\` field of the response contains two keys of importance:
307
307
 
308
308
  - \`slice\`: which contains the result of the slicing (e.g., the ids included in the slice in \`result\`).
309
309
  - \`reconstruct\`: contains the reconstructed code, as well as additional meta information.
310
- The automatically selected lines correspond to additional filters (e.g., magic comments) which force the unconditiojnal inclusion of certain elements.
310
+ The automatically selected lines correspond to additional filters (e.g., magic comments) which force the unconditional inclusion of certain elements.
311
311
  `
312
312
  }]
313
313
  })}