@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,693 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResolvedCallSuffix = void 0;
4
- exports.extractCfg = extractCfg;
5
- exports.extractCfgQuick = extractCfgQuick;
6
- exports.getCallsInCfg = getCallsInCfg;
7
- exports.cfg2quads = cfg2quads;
8
- const quads_1 = require("../util/quads");
9
- const r_function_definition_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
10
- const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
11
- const linker_1 = require("../dataflow/internal/linker");
12
- const vertex_1 = require("../dataflow/graph/vertex");
13
- const control_flow_graph_1 = require("./control-flow-graph");
14
- const cfg_simplification_1 = require("./cfg-simplification");
15
- const cfg_builder_1 = require("./cfg-builder");
16
- const assert_1 = require("../util/assert");
17
- const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
18
- const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
19
- const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
20
- const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
21
- const identifier_1 = require("../dataflow/environments/identifier");
22
- function emptyCfgFoldInformation() {
23
- return { graph: new cfg_builder_1.CfgBuilder(), breaks: [], nexts: [], returns: [], exitPoints: [], entryPoints: [] };
24
- }
25
- function materializeCfg(info) {
26
- return { ...info, graph: info.graph.materialize() };
27
- }
28
- const cfgFolds = {
29
- down: (n, down) => {
30
- if (r_function_definition_1.RFunctionDefinition.is(n)) {
31
- return [down[0], true];
32
- }
33
- else if (model_1.RLoopConstructs.is(n)) {
34
- return [true, down[1]];
35
- }
36
- return down;
37
- },
38
- foldNumber: cfgLeaf(control_flow_graph_1.CfgVertexType.Expression),
39
- foldString: cfgLeaf(control_flow_graph_1.CfgVertexType.Expression),
40
- foldLogical: cfgLeaf(control_flow_graph_1.CfgVertexType.Expression),
41
- foldSymbol: cfgLeaf(control_flow_graph_1.CfgVertexType.Expression),
42
- foldAccess: cfgAccess,
43
- foldBinaryOp: cfgBinaryOp,
44
- foldPipe: cfgBinaryOp,
45
- foldUnaryOp: cfgUnaryOp,
46
- other: {
47
- foldComment: cfgIgnore,
48
- foldLineDirective: cfgIgnore
49
- },
50
- loop: {
51
- foldFor: cfgFor,
52
- foldRepeat: cfgRepeat,
53
- foldWhile: cfgWhile,
54
- foldBreak: cfgBreak,
55
- foldNext: cfgNext
56
- },
57
- foldIfThenElse: cfgIfThenElse,
58
- foldExprList: cfgExprList,
59
- functions: {
60
- foldFunctionDefinition: cfgFunctionDefinition,
61
- foldFunctionCall: cfgFunctionCall,
62
- foldParameter: cfgArgumentOrParameter,
63
- foldArgument: cfgArgumentOrParameter
64
- }
65
- };
66
- const ignoreFunctDefCfgFolds = {
67
- ...cfgFolds,
68
- functions: {
69
- ...cfgFolds.functions,
70
- foldFunctionDefinition: cfgLeaf(control_flow_graph_1.CfgVertexType.Expression)
71
- }
72
- };
73
- function dataflowCfgFolds(dataflowGraph) {
74
- const newFolds = {
75
- ...cfgFolds,
76
- };
77
- newFolds.functions = {
78
- ...cfgFolds.functions,
79
- foldFunctionCall: cfgFunctionCallWithDataflow(dataflowGraph, newFolds)
80
- };
81
- return newFolds;
82
- }
83
- /**
84
- * Given a normalized AST, this approximates the control flow graph of the program.
85
- * This view is different from the computation of the dataflow graph and may differ,
86
- * especially because it focuses on intra-procedural analysis.
87
- * @param ast - the normalized AST
88
- * @param ctx - the flowR context
89
- * @param graph - additional dataflow facts to consider by the control flow extraction
90
- * @param simplifications - a list of simplification passes to apply to the control flow graph
91
- * @param ignoreFunctDefs - whether function definition vertices should be ignored
92
- * @see {@link extractCfgQuick} - for a simplified version of this function
93
- */
94
- function extractCfg(ast, ctx, graph, simplifications, ignoreFunctDefs) {
95
- const folds = ignoreFunctDefs ? ignoreFunctDefCfgFolds : (graph ? dataflowCfgFolds(graph) : cfgFolds);
96
- return (0, cfg_simplification_1.simplifyControlFlowInformation)(cfgFoldProject(ast.ast, folds), { ast, dfg: graph, ctx }, simplifications);
97
- }
98
- /**
99
- * A version of {@link extractCfg} that is much quicker and does not apply any simplifications or dataflow information.
100
- */
101
- function extractCfgQuick(ast) {
102
- return cfgFoldProject(ast.ast, cfgFolds);
103
- }
104
- /**
105
- * Extracts all function call vertices from the given control flow information and dataflow graph.
106
- */
107
- function getCallsInCfg(cfg, graph) {
108
- const calls = new Map();
109
- for (const vertexId of cfg.graph.vertices().keys()) {
110
- const vertex = graph.getVertex(vertexId);
111
- if (vertex_1.FunctionCallVertex.is(vertex)) {
112
- calls.set(vertexId, vertex);
113
- }
114
- }
115
- return calls;
116
- }
117
- function cfgFoldProject(proj, folds) {
118
- if (proj.files.length === 0) {
119
- return (0, control_flow_graph_1.emptyControlFlowInformation)();
120
- }
121
- else if (proj.files.length === 1) {
122
- return materializeCfg((0, stateful_fold_1.foldAstStateful)(proj.files[0].root, [false, false], folds));
123
- }
124
- /* for many files, it is too expensive to keep all asts at once, hence we create and merge them incrementally */
125
- let exitPoints;
126
- let finalGraph;
127
- let firstEntryPoints;
128
- let breaks;
129
- let nexts;
130
- let returns;
131
- {
132
- const firstInfo = (0, stateful_fold_1.foldAstStateful)(proj.files[0].root, [false, false], folds);
133
- exitPoints = firstInfo.exitPoints;
134
- finalGraph = firstInfo.graph;
135
- firstEntryPoints = firstInfo.entryPoints;
136
- breaks = firstInfo.breaks;
137
- nexts = firstInfo.nexts;
138
- returns = firstInfo.returns;
139
- }
140
- for (let i = 1; i < proj.files.length; i++) {
141
- const nextInfo = (0, stateful_fold_1.foldAstStateful)(proj.files[i].root, [false, false], folds);
142
- finalGraph.mergeWith(nextInfo.graph);
143
- for (const exitPoint of exitPoints) {
144
- for (const entryPoint of nextInfo.entryPoints) {
145
- finalGraph.addEdge(entryPoint, exitPoint, control_flow_graph_1.CfgEdge.makeFd());
146
- }
147
- }
148
- exitPoints = nextInfo.exitPoints;
149
- breaks.push(...nextInfo.breaks);
150
- nexts.push(...nextInfo.nexts);
151
- returns.push(...nextInfo.returns);
152
- }
153
- return {
154
- breaks,
155
- nexts,
156
- returns,
157
- exitPoints,
158
- entryPoints: firstEntryPoints,
159
- graph: finalGraph.materialize()
160
- };
161
- }
162
- function cfgLeaf(type) {
163
- return type === control_flow_graph_1.CfgVertexType.Expression ? ({ info: { id } }) => {
164
- return { graph: new cfg_builder_1.CfgBuilder().addVertex(control_flow_graph_1.CfgVertex.makeExpression(id)), breaks: [], nexts: [], returns: [], exitPoints: [id], entryPoints: [id] };
165
- } : ({ info: { id } }) => {
166
- return { graph: new cfg_builder_1.CfgBuilder().addVertex(control_flow_graph_1.CfgVertex.makeStatement(id)), breaks: [], nexts: [], returns: [], exitPoints: [id], entryPoints: [id] };
167
- };
168
- }
169
- const cfgLeafStatement = cfgLeaf(control_flow_graph_1.CfgVertexType.Statement);
170
- function cfgBreak(leaf, down) {
171
- if (!down[0]) {
172
- return cfgLeafStatement(leaf);
173
- }
174
- return { ...cfgLeafStatement(leaf), breaks: [leaf.info.id], exitPoints: [] };
175
- }
176
- function cfgNext(leaf, down) {
177
- if (!down[0]) {
178
- return cfgLeafStatement(leaf);
179
- }
180
- return { ...cfgLeafStatement(leaf), nexts: [leaf.info.id], exitPoints: [] };
181
- }
182
- function cfgIgnore(_leaf) {
183
- return { graph: new cfg_builder_1.CfgBuilder(), breaks: [], nexts: [], returns: [], exitPoints: [], entryPoints: [] };
184
- }
185
- function identifyMayStatementType(node) {
186
- return node.info.role === "el-c" /* RoleInParent.ExpressionListChild */ ? control_flow_graph_1.CfgVertexType.Statement : control_flow_graph_1.CfgVertexType.Expression;
187
- }
188
- function cfgIfThenElse(ifNode, condition, then, otherwise) {
189
- const ifId = ifNode.info.id;
190
- const graph = new cfg_builder_1.CfgBuilder();
191
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(ifId, identifyMayStatementType(ifNode), { mid: condition.exitPoints, end: [control_flow_graph_1.CfgVertex.toExitId(ifId)] }));
192
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(ifId));
193
- graph.mergeWith(condition.graph);
194
- graph.mergeWith(then.graph);
195
- if (otherwise) {
196
- graph.mergeWith(otherwise.graph);
197
- }
198
- const cdTrue = control_flow_graph_1.CfgEdge.makeCdTrue(ifId);
199
- const cdFalse = control_flow_graph_1.CfgEdge.makeCdFalse(ifId);
200
- for (const e of condition.exitPoints) {
201
- for (const entryPoint of then.entryPoints) {
202
- graph.addEdge(entryPoint, e, cdTrue);
203
- }
204
- for (const entryPoint of otherwise?.entryPoints ?? []) {
205
- graph.addEdge(entryPoint, e, cdFalse);
206
- }
207
- }
208
- for (const entryPoint of condition.entryPoints) {
209
- graph.addEdge(entryPoint, ifId, control_flow_graph_1.CfgEdge.makeFd());
210
- }
211
- for (const exits of [then.exitPoints, otherwise?.exitPoints ?? []]) {
212
- for (const exit of exits) {
213
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(ifId), exit, control_flow_graph_1.CfgEdge.makeFd());
214
- }
215
- }
216
- if (!otherwise) {
217
- for (const e of condition.exitPoints) {
218
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(ifId), e, control_flow_graph_1.CfgEdge.makeCdFalse(ifId));
219
- }
220
- }
221
- return {
222
- graph,
223
- breaks: then.breaks.concat(otherwise?.breaks ?? []),
224
- nexts: then.nexts.concat(otherwise?.nexts ?? []),
225
- returns: then.returns.concat(otherwise?.returns ?? []),
226
- exitPoints: [control_flow_graph_1.CfgVertex.toExitId(ifId)],
227
- entryPoints: [ifId]
228
- };
229
- }
230
- function cfgRepeat(repeat, body) {
231
- const graph = body.graph;
232
- const rid = repeat.info.id;
233
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(rid, identifyMayStatementType(repeat), { end: [control_flow_graph_1.CfgVertex.toExitId(rid)] }));
234
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(rid));
235
- for (const entryPoint of body.entryPoints) {
236
- graph.addEdge(entryPoint, rid, control_flow_graph_1.CfgEdge.makeFd());
237
- }
238
- // loops automatically
239
- for (const nexts of [body.nexts, body.exitPoints]) {
240
- for (const next of nexts) {
241
- graph.addEdge(rid, next, control_flow_graph_1.CfgEdge.makeFd());
242
- }
243
- }
244
- for (const breakPoint of body.breaks) {
245
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(rid), breakPoint, control_flow_graph_1.CfgEdge.makeFd());
246
- }
247
- return { graph, breaks: [], nexts: [], returns: body.returns, exitPoints: [control_flow_graph_1.CfgVertex.toExitId(rid)], entryPoints: [rid] };
248
- }
249
- function cfgWhile(whileLoop, condition, body) {
250
- const whileId = whileLoop.info.id;
251
- const graph = condition.graph;
252
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(whileId, identifyMayStatementType(whileLoop), { mid: condition.exitPoints, end: [control_flow_graph_1.CfgVertex.toExitId(whileId)] }));
253
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(whileId));
254
- graph.mergeWith(body.graph);
255
- for (const entry of condition.entryPoints) {
256
- graph.addEdge(entry, whileId, control_flow_graph_1.CfgEdge.makeFd());
257
- }
258
- for (const e of condition.exitPoints) {
259
- for (const entry of body.entryPoints) {
260
- graph.addEdge(entry, e, control_flow_graph_1.CfgEdge.makeCdTrue(whileId));
261
- }
262
- }
263
- for (const nexts of [body.nexts, body.exitPoints]) {
264
- for (const next of nexts) {
265
- graph.addEdge(whileId, next, control_flow_graph_1.CfgEdge.makeFd());
266
- }
267
- }
268
- for (const breakPoint of body.breaks) {
269
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(whileId), breakPoint, control_flow_graph_1.CfgEdge.makeFd());
270
- }
271
- // while can break on the condition as well
272
- for (const e of condition.exitPoints) {
273
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(whileId), e, control_flow_graph_1.CfgEdge.makeCdFalse(whileId));
274
- }
275
- return { graph, breaks: [], nexts: [], returns: body.returns, exitPoints: [control_flow_graph_1.CfgVertex.toExitId(whileId)], entryPoints: [whileId] };
276
- }
277
- function cfgFor(forLoop, variable, vector, body) {
278
- const forLoopId = forLoop.info.id;
279
- const graph = variable.graph;
280
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(forLoopId, identifyMayStatementType(forLoop), { mid: variable.exitPoints, end: [control_flow_graph_1.CfgVertex.toExitId(forLoopId)] }));
281
- graph.mergeWith(vector.graph);
282
- graph.mergeWith(body.graph);
283
- for (const entry of vector.entryPoints) {
284
- graph.addEdge(entry, forLoopId, control_flow_graph_1.CfgEdge.makeFd());
285
- }
286
- for (const exit of vector.exitPoints) {
287
- for (const entry of variable.entryPoints) {
288
- graph.addEdge(entry, exit, control_flow_graph_1.CfgEdge.makeFd());
289
- }
290
- }
291
- for (const e of variable.exitPoints) {
292
- for (const entry of body.entryPoints) {
293
- graph.addEdge(entry, e, control_flow_graph_1.CfgEdge.makeCdTrue(forLoopId));
294
- }
295
- }
296
- for (const points of [body.nexts, body.exitPoints]) {
297
- for (const next of points) {
298
- graph.addEdge(forLoopId, next, control_flow_graph_1.CfgEdge.makeFd());
299
- }
300
- }
301
- for (const breakPoint of body.breaks) {
302
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(forLoopId), breakPoint, control_flow_graph_1.CfgEdge.makeFd());
303
- }
304
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(forLoopId));
305
- for (const e of variable.exitPoints) {
306
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(forLoopId), e, control_flow_graph_1.CfgEdge.makeCdFalse(forLoopId));
307
- }
308
- return { graph, breaks: [], nexts: [], returns: body.returns, exitPoints: [control_flow_graph_1.CfgVertex.toExitId(forLoopId)], entryPoints: [forLoopId] };
309
- }
310
- function cfgFunctionDefinition(fn, params, body) {
311
- const fnId = fn.info.id;
312
- const graph = new cfg_builder_1.CfgBuilder();
313
- let paramExits = params.flatMap(e => e.exitPoints);
314
- const children = [...paramExits, control_flow_graph_1.CfgVertex.toExitId(fnId)];
315
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(fnId), false);
316
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(fnId, identifyMayStatementType(fn), { children, mid: paramExits, end: [control_flow_graph_1.CfgVertex.toExitId(fnId)] }));
317
- graph.mergeWith(body.graph, true);
318
- for (const r of body.graph.rootIds()) {
319
- children.push(r);
320
- }
321
- for (const param of params) {
322
- graph.mergeWith(param.graph, true);
323
- for (const r of param.graph.rootIds()) {
324
- children.push(r);
325
- }
326
- for (const entry of param.entryPoints) {
327
- graph.addEdge(entry, fnId, control_flow_graph_1.CfgEdge.makeFd());
328
- }
329
- }
330
- if (paramExits.length === 0) {
331
- paramExits = [fnId];
332
- }
333
- for (const e of paramExits) {
334
- for (const entry of body.entryPoints) {
335
- graph.addEdge(entry, e, control_flow_graph_1.CfgEdge.makeFd());
336
- }
337
- }
338
- // breaks and nexts should be illegal but safe is safe, I guess
339
- for (const next of body.returns.concat(body.breaks, body.nexts, body.exitPoints)) {
340
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(fnId), next, control_flow_graph_1.CfgEdge.makeFd());
341
- }
342
- return { graph: graph, breaks: [], nexts: [], returns: [], exitPoints: [fnId], entryPoints: [fnId] };
343
- }
344
- /** operators whose rhs a driver evaluates as a per-iteration closure, so escapes stay within it */
345
- const ClosureBodyOperators = new Set(['%do%', '%dopar%', '%dofuture%', '%dorng%', '%:%']);
346
- function cfgFunctionCall(call, name, args, down) {
347
- const callId = call.info.id;
348
- const graph = name.graph;
349
- const info = {
350
- graph,
351
- breaks: Array.from(name.breaks),
352
- nexts: Array.from(name.nexts),
353
- returns: Array.from(name.returns),
354
- exitPoints: [control_flow_graph_1.CfgVertex.toExitId(callId)],
355
- entryPoints: [callId]
356
- };
357
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(callId, identifyMayStatementType(call), { mid: name.exitPoints, end: [control_flow_graph_1.CfgVertex.toExitId(callId)] }));
358
- for (const entryPoint of name.entryPoints) {
359
- graph.addEdge(entryPoint, callId, control_flow_graph_1.CfgEdge.makeFd());
360
- }
361
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(callId));
362
- let lastArgExits = name.exitPoints;
363
- for (const arg of args) {
364
- if (arg === r_function_call_1.EmptyArgument) {
365
- continue;
366
- }
367
- graph.mergeWith(arg.graph);
368
- info.breaks = info.breaks.concat(arg.breaks);
369
- info.nexts = info.nexts.concat(arg.nexts);
370
- info.returns = info.returns.concat(arg.returns);
371
- for (const entry of arg.entryPoints) {
372
- for (const exit of lastArgExits) {
373
- graph.addEdge(entry, exit, control_flow_graph_1.CfgEdge.makeFd());
374
- }
375
- }
376
- lastArgExits = arg.exitPoints;
377
- }
378
- for (const exit of lastArgExits) {
379
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(callId), exit, control_flow_graph_1.CfgEdge.makeFd());
380
- }
381
- if (call.named && call.functionName.content === 'return') {
382
- if (down[1]) {
383
- info.returns.push(control_flow_graph_1.CfgVertex.toExitId(callId));
384
- info.exitPoints.length = 0;
385
- }
386
- }
387
- else if (call.named && ClosureBodyOperators.has(identifier_1.Identifier.getName(call.functionName.content))) {
388
- return sealEscapes(info, control_flow_graph_1.CfgVertex.toExitId(callId));
389
- }
390
- // should not contain any breaks, nexts, or returns, (except for the body if something like 'break()')
391
- return info;
392
- }
393
- function cfgSwitch(call, name, args) {
394
- const callId = call.info.id;
395
- const exitId = control_flow_graph_1.CfgVertex.toExitId(callId);
396
- const graph = name.graph;
397
- const info = {
398
- graph,
399
- breaks: Array.from(name.breaks),
400
- nexts: Array.from(name.nexts),
401
- returns: Array.from(name.returns),
402
- exitPoints: [exitId],
403
- entryPoints: [callId]
404
- };
405
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(callId, identifyMayStatementType(call), { mid: name.exitPoints, end: [exitId] }));
406
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(callId));
407
- for (const entry of name.entryPoints) {
408
- graph.addEdge(entry, callId, control_flow_graph_1.CfgEdge.makeFd());
409
- }
410
- let selectorExits = name.exitPoints;
411
- const selector = args[0];
412
- if (selector !== undefined && selector !== r_function_call_1.EmptyArgument) {
413
- graph.mergeWith(selector.graph);
414
- info.breaks = info.breaks.concat(selector.breaks);
415
- info.nexts = info.nexts.concat(selector.nexts);
416
- info.returns = info.returns.concat(selector.returns);
417
- for (const entry of selector.entryPoints) {
418
- for (const exit of name.exitPoints) {
419
- graph.addEdge(entry, exit, control_flow_graph_1.CfgEdge.makeFd());
420
- }
421
- }
422
- selectorExits = selector.exitPoints;
423
- }
424
- const cd = control_flow_graph_1.CfgEdge.makeCdTrue(callId);
425
- for (const arm of args.slice(1)) {
426
- if (arm === r_function_call_1.EmptyArgument) {
427
- continue;
428
- }
429
- graph.mergeWith(arm.graph);
430
- info.breaks = info.breaks.concat(arm.breaks);
431
- info.nexts = info.nexts.concat(arm.nexts);
432
- info.returns = info.returns.concat(arm.returns);
433
- for (const entry of arm.entryPoints) {
434
- for (const exit of selectorExits) {
435
- graph.addEdge(entry, exit, cd);
436
- }
437
- }
438
- for (const exit of arm.exitPoints) {
439
- graph.addEdge(exitId, exit, control_flow_graph_1.CfgEdge.makeFd());
440
- }
441
- }
442
- const hasDefault = call.arguments.slice(1).some(a => a !== r_function_call_1.EmptyArgument && a.name === undefined);
443
- if (!hasDefault) {
444
- for (const exit of selectorExits) {
445
- graph.addEdge(exitId, exit, control_flow_graph_1.CfgEdge.makeCdFalse(callId));
446
- }
447
- }
448
- return info;
449
- }
450
- /** keeps a return/break/next from escaping a deferred body into the enclosing control flow */
451
- function sealEscapes(base, exitId) {
452
- for (const escape of base.returns.concat(base.breaks, base.nexts)) {
453
- base.graph.addEdge(exitId, escape, control_flow_graph_1.CfgEdge.makeFd());
454
- }
455
- return { ...base, returns: [], breaks: [], nexts: [], exitPoints: base.exitPoints.length > 0 ? base.exitPoints : [exitId] };
456
- }
457
- // on.exit defers its expr, so seal a return/break/next inside it from escaping into enclosing control flow
458
- function cfgRegisterHook(call, name, args, down) {
459
- return sealEscapes(cfgFunctionCall(call, name, args, down), control_flow_graph_1.CfgVertex.toExitId(call.info.id));
460
- }
461
- exports.ResolvedCallSuffix = control_flow_graph_1.CfgVertex.toExitId('-resolved-call');
462
- const OriginToFoldTypeMap = {
463
- [built_in_proc_name_1.BuiltInProcName.IfThenElse]: (folds, call, args, down) => {
464
- // arguments are in order!
465
- return folds.foldIfThenElse(call, // we will have to this more sophisticated if we rewrite the dfg based generation
466
- args[0] === r_function_call_1.EmptyArgument ? emptyCfgFoldInformation() : args[0], args[1] === r_function_call_1.EmptyArgument ? emptyCfgFoldInformation() : args[1], args[2] === r_function_call_1.EmptyArgument ? emptyCfgFoldInformation() : args[2], down);
467
- }
468
- };
469
- function cfgFunctionCallWithDataflow(graph, folds) {
470
- return (call, name, args, down) => {
471
- const vtx = graph.getVertex(call.info.id);
472
- if (vertex_1.FunctionCallVertex.is(vtx) && vtx.onlyBuiltin && vtx.origin.length === 1) {
473
- const origin = vtx.origin[0];
474
- const mayMap = OriginToFoldTypeMap[origin];
475
- // ifelse/fifelse/if_else share the IfThenElse origin but are eager calls, so only fold a real `if` node
476
- if (mayMap && call.type === type_1.RType.IfThenElse) {
477
- return mayMap(folds, call, args, down, vtx);
478
- }
479
- if (origin === built_in_proc_name_1.BuiltInProcName.Switch) {
480
- return cfgSwitch(call, name, args);
481
- }
482
- if (origin === built_in_proc_name_1.BuiltInProcName.RegisterHook) {
483
- return cfgRegisterHook(call, name, args, down);
484
- }
485
- }
486
- const baseCfg = cfgFunctionCall(call, name, args, down);
487
- /* try to resolve the call and link the target definitions */
488
- const targets = (0, linker_1.getAllFunctionCallTargets)(call.info.id, graph);
489
- const exits = [];
490
- const callVertex = baseCfg.graph.getVertex(call.info.id);
491
- (0, assert_1.guard)(callVertex !== undefined, 'cfgFunctionCallWithDataflow: call vertex not found');
492
- for (const target of targets) {
493
- // we have to filter out non-func-call targets as the call targets contains names and call ids
494
- if (vertex_1.FunctionDefinitionVertex.is(graph.getVertex(target))) {
495
- const ct = control_flow_graph_1.CfgVertex.getCallTargets(callVertex);
496
- if (!ct) {
497
- control_flow_graph_1.CfgVertex.setCallTargets(callVertex, new Set([target]));
498
- }
499
- else {
500
- ct.add(target);
501
- }
502
- exits.push(control_flow_graph_1.CfgVertex.toExitId(target));
503
- }
504
- }
505
- if (exits.length > 0) {
506
- baseCfg.graph.addVertex(control_flow_graph_1.CfgVertex.makeMarker(call.info.id + exports.ResolvedCallSuffix, call.info.id));
507
- for (const col of [baseCfg.exitPoints, exits]) {
508
- for (const exit of col) {
509
- baseCfg.graph.addEdge(call.info.id + exports.ResolvedCallSuffix, exit, control_flow_graph_1.CfgEdge.makeFd());
510
- }
511
- }
512
- return {
513
- ...baseCfg,
514
- exitPoints: [call.info.id + exports.ResolvedCallSuffix]
515
- };
516
- }
517
- else {
518
- return baseCfg;
519
- }
520
- };
521
- }
522
- function cfgArgumentOrParameter(node, name, value) {
523
- const graph = new cfg_builder_1.CfgBuilder();
524
- const nodeId = node.info.id;
525
- const info = { graph, breaks: [], nexts: [], returns: [], exitPoints: [control_flow_graph_1.CfgVertex.toExitId(nodeId)], entryPoints: [nodeId] };
526
- let currentExitPoints = name?.exitPoints ?? [nodeId];
527
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExpressionWithEnd(nodeId, { mid: currentExitPoints }));
528
- if (name) {
529
- graph.mergeWith(name.graph);
530
- info.breaks = info.breaks.concat(name.breaks);
531
- info.nexts = info.nexts.concat(name.nexts);
532
- info.returns = info.returns.concat(name.returns);
533
- for (const entry of name.entryPoints) {
534
- graph.addEdge(entry, nodeId, control_flow_graph_1.CfgEdge.makeFd());
535
- }
536
- }
537
- if (value) {
538
- graph.mergeWith(value.graph);
539
- info.breaks = info.breaks.concat(value.breaks);
540
- info.nexts = info.nexts.concat(value.nexts);
541
- info.returns = info.returns.concat(value.returns);
542
- for (const exitPoint of currentExitPoints) {
543
- for (const entry of value.entryPoints) {
544
- graph.addEdge(entry, exitPoint, control_flow_graph_1.CfgEdge.makeFd());
545
- }
546
- }
547
- currentExitPoints = value.exitPoints;
548
- }
549
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(nodeId));
550
- for (const exit of currentExitPoints) {
551
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(nodeId), exit, control_flow_graph_1.CfgEdge.makeFd());
552
- }
553
- return info;
554
- }
555
- function cfgBinaryOp(binOp, lhs, rhs) {
556
- const graph = lhs.graph.mergeWith(rhs.graph);
557
- const binId = binOp.info.id;
558
- const binExit = control_flow_graph_1.CfgVertex.toExitId(binId);
559
- const result = { graph, breaks: lhs.breaks.concat(rhs.breaks), nexts: lhs.nexts.concat(rhs.nexts), returns: lhs.returns.concat(rhs.returns), entryPoints: [binId], exitPoints: [binExit] };
560
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(binId, binOp.flavor === 'assignment' ? control_flow_graph_1.CfgVertexType.Statement : control_flow_graph_1.CfgVertexType.Expression, { end: [binExit] }));
561
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(binId));
562
- const fd = control_flow_graph_1.CfgEdge.makeFd();
563
- for (const exitPoint of lhs.exitPoints) {
564
- for (const entryPoint of rhs.entryPoints) {
565
- result.graph.addEdge(entryPoint, exitPoint, fd);
566
- }
567
- }
568
- for (const entryPoint of lhs.entryPoints) {
569
- graph.addEdge(entryPoint, binId, fd);
570
- }
571
- for (const exitPoint of rhs.exitPoints) {
572
- graph.addEdge(binExit, exitPoint, fd);
573
- }
574
- // `&&`/`||` short-circuit: the exit stays reachable via the lhs even when the rhs jumps
575
- if (binOp.type === type_1.RType.BinaryOp && (binOp.operator === '&&' || binOp.operator === '||')) {
576
- for (const exitPoint of lhs.exitPoints) {
577
- graph.addEdge(binExit, exitPoint, fd);
578
- }
579
- }
580
- return result;
581
- }
582
- function cfgAccess(access, name, accessors) {
583
- const result = { ...name };
584
- const graph = result.graph;
585
- const accessId = access.info.id;
586
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExpressionWithEnd(accessId, { mid: name.exitPoints }));
587
- result.entryPoints = [accessId];
588
- for (const entry of name.entryPoints) {
589
- graph.addEdge(entry, accessId, control_flow_graph_1.CfgEdge.makeFd());
590
- }
591
- result.exitPoints = name.exitPoints;
592
- for (const accessor of accessors) {
593
- if (accessor === r_function_call_1.EmptyArgument) {
594
- continue;
595
- }
596
- graph.mergeWith(accessor.graph);
597
- for (const exitPoint of result.exitPoints) {
598
- for (const entry of accessor.entryPoints) {
599
- graph.addEdge(entry, exitPoint, control_flow_graph_1.CfgEdge.makeFd());
600
- }
601
- }
602
- result.exitPoints = accessor.exitPoints;
603
- result.breaks = result.breaks.concat(accessor.breaks);
604
- result.nexts = result.nexts.concat(accessor.nexts);
605
- result.returns = result.returns.concat(accessor.returns);
606
- }
607
- for (const exitPoint of result.exitPoints) {
608
- graph.addEdge(control_flow_graph_1.CfgVertex.toExitId(accessId), exitPoint, control_flow_graph_1.CfgEdge.makeFd());
609
- }
610
- graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(accessId));
611
- result.exitPoints = [control_flow_graph_1.CfgVertex.toExitId(accessId)];
612
- return result;
613
- }
614
- function cfgUnaryOp(unary, operand) {
615
- const graph = operand.graph;
616
- const unaryId = unary.info.id;
617
- graph.addVertex(control_flow_graph_1.CfgVertex.makeMarker(unaryId, unaryId));
618
- const fd = control_flow_graph_1.CfgEdge.makeFd();
619
- for (const entry of operand.exitPoints) {
620
- graph.addEdge(unaryId, entry, fd);
621
- }
622
- return { ...operand, graph, exitPoints: [unaryId] };
623
- }
624
- function cfgExprList(node, _grouping, expressions) {
625
- const nodeId = node.info.id;
626
- const result = {
627
- graph: new cfg_builder_1.CfgBuilder(),
628
- breaks: [],
629
- nexts: [],
630
- returns: [],
631
- exitPoints: [nodeId],
632
- entryPoints: [nodeId]
633
- };
634
- const vtx = control_flow_graph_1.CfgVertex.makeExpression(nodeId);
635
- result.graph.addVertex(vtx);
636
- const fd = control_flow_graph_1.CfgEdge.makeFd();
637
- for (const expression of expressions) {
638
- for (const previousExitPoint of result.exitPoints) {
639
- for (const entryPoint of expression.entryPoints) {
640
- result.graph.addEdge(entryPoint, previousExitPoint, fd);
641
- }
642
- }
643
- result.graph.mergeWith(expression.graph);
644
- for (const b of expression.breaks) {
645
- result.breaks.push(b);
646
- }
647
- for (const n of expression.nexts) {
648
- result.nexts.push(n);
649
- }
650
- for (const r of expression.returns) {
651
- result.returns.push(r);
652
- }
653
- result.exitPoints = expression.exitPoints;
654
- }
655
- const exitId = control_flow_graph_1.CfgVertex.toExitId(nodeId);
656
- if (result.exitPoints.length > 0) {
657
- result.graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(nodeId));
658
- control_flow_graph_1.CfgVertex.setEnd(vtx, [exitId]);
659
- }
660
- for (const exit of result.exitPoints) {
661
- result.graph.addEdge(exitId, exit, fd);
662
- }
663
- result.exitPoints = result.exitPoints.length > 0 ? [exitId] : [];
664
- return result;
665
- }
666
- /**
667
- * Convert a cfg to RDF quads.
668
- * @see {@link df2quads}
669
- * @see {@link serialize2quads}
670
- * @see {@link graph2quads}
671
- */
672
- function cfg2quads(cfg, config) {
673
- return (0, quads_1.graph2quads)({
674
- rootIds: [...cfg.graph.rootIds()],
675
- vertices: [...cfg.graph.vertices().entries()]
676
- .map(([id, v]) => ({
677
- id,
678
- children: control_flow_graph_1.CfgVertex.getChildren(v)
679
- })),
680
- edges: [...cfg.graph.edges()].flatMap(([fromId, targets]) => [...targets].map(([toId, info]) => ({
681
- from: fromId,
682
- to: toId,
683
- type: control_flow_graph_1.CfgEdge.getType(info),
684
- when: control_flow_graph_1.CfgEdge.getWhen(info)
685
- }))),
686
- entryPoints: cfg.entryPoints,
687
- exitPoints: cfg.exitPoints,
688
- breaks: cfg.breaks,
689
- nexts: cfg.nexts,
690
- returns: cfg.returns
691
- }, config);
692
- }
693
- //# sourceMappingURL=extract-cfg.js.map