@eagleoutice/flowr 2.14.0 → 2.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/README.md +169 -91
  2. package/abstract-interpretation/absint-visitor.d.ts +91 -25
  3. package/abstract-interpretation/absint-visitor.js +235 -74
  4. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +1 -1
  5. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
  6. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +1 -1
  7. package/abstract-interpretation/data-frame/mappers/arguments.js +1 -1
  8. package/abstract-interpretation/data-frame/mappers/function-mapper.js +107 -254
  9. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +5 -5
  10. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -1
  11. package/abstract-interpretation/data-frame/resolve-args.js +6 -4
  12. package/abstract-interpretation/data-frame/shape-inference.d.ts +4 -9
  13. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -0
  14. package/abstract-interpretation/domains/bounded-set-domain.js +1 -0
  15. package/abstract-interpretation/domains/partial-product-domain.js +1 -1
  16. package/abstract-interpretation/domains/set-range-domain.d.ts +3 -2
  17. package/abstract-interpretation/domains/set-range-domain.js +3 -2
  18. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +3 -2
  19. package/abstract-interpretation/domains/set-upper-bound-domain.js +3 -2
  20. package/benchmark/calibration.d.ts +18 -11
  21. package/benchmark/calibration.js +37 -27
  22. package/benchmark/slicer.d.ts +9 -2
  23. package/benchmark/slicer.js +44 -37
  24. package/benchmark/stats/count-comments.d.ts +16 -0
  25. package/benchmark/stats/count-comments.js +30 -0
  26. package/benchmark/stats/print.js +2 -0
  27. package/benchmark/stats/size-of.d.ts +7 -3
  28. package/benchmark/stats/size-of.js +7 -3
  29. package/benchmark/stats/stats.d.ts +7 -0
  30. package/benchmark/summarizer/first-phase/process.js +2 -19
  31. package/benchmark/summarizer/second-phase/graph.js +13 -3
  32. package/benchmark/summarizer/second-phase/process.js +2 -0
  33. package/cli/benchmark-app.js +4 -1
  34. package/cli/benchmark-helper-app.d.ts +1 -0
  35. package/cli/benchmark-helper-app.js +2 -2
  36. package/cli/common/options.d.ts +5 -0
  37. package/cli/common/options.js +1 -0
  38. package/cli/common/scripts-info.d.ts +5 -0
  39. package/cli/repl/commands/repl-dataflow.js +70 -27
  40. package/cli/repl/core.d.ts +1 -1
  41. package/cli/repl/core.js +1 -1
  42. package/cli/repl/execute.d.ts +2 -2
  43. package/cli/repl/execute.js +2 -2
  44. package/cli/repl/parser/slice-query-parser.js +2 -1
  45. package/cli/repl/server/connection.d.ts +4 -0
  46. package/cli/repl/server/connection.js +19 -16
  47. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  48. package/config.d.ts +6 -0
  49. package/config.js +12 -9
  50. package/control-flow/basic-cfg-guided-visitor.d.ts +7 -2
  51. package/control-flow/basic-cfg-guided-visitor.js +37 -24
  52. package/control-flow/cfg-dead-code.js +44 -33
  53. package/control-flow/cfg-properties.js +2 -2
  54. package/control-flow/cfg-simplification.js +6 -5
  55. package/control-flow/cfg-to-basic-blocks.js +11 -13
  56. package/control-flow/control-flow-graph.d.ts +179 -189
  57. package/control-flow/control-flow-graph.js +400 -263
  58. package/control-flow/dfg-cfg-guided-visitor.d.ts +21 -3
  59. package/control-flow/dfg-cfg-guided-visitor.js +17 -13
  60. package/control-flow/diff-cfg.js +6 -14
  61. package/control-flow/happens-before.js +5 -4
  62. package/control-flow/semantic-cfg-guided-visitor.d.ts +44 -101
  63. package/control-flow/semantic-cfg-guided-visitor.js +6 -26
  64. package/control-flow/simple-visitor.js +14 -15
  65. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -1
  66. package/control-flow/useless-loop.js +18 -14
  67. package/core/steps/all/core/20-dataflow.d.ts +1 -3
  68. package/core/steps/pipeline/default-pipelines.d.ts +141 -157
  69. package/dataflow/cluster.js +7 -0
  70. package/dataflow/environments/apply-kill.d.ts +6 -0
  71. package/dataflow/environments/apply-kill.js +64 -32
  72. package/dataflow/environments/built-in-props.d.ts +10 -2
  73. package/dataflow/environments/built-in-props.js +9 -1
  74. package/dataflow/environments/built-in.d.ts +6 -3
  75. package/dataflow/environments/built-in.js +8 -5
  76. package/dataflow/environments/clone.d.ts +3 -3
  77. package/dataflow/environments/clone.js +5 -5
  78. package/dataflow/environments/default-builtin-config.d.ts +188 -8
  79. package/dataflow/environments/default-builtin-config.js +112 -39
  80. package/dataflow/environments/environment.d.ts +9 -1
  81. package/dataflow/environments/environment.js +25 -7
  82. package/dataflow/environments/identifier.d.ts +12 -1
  83. package/dataflow/environments/identifier.js +4 -1
  84. package/dataflow/environments/query-fn-props.d.ts +6 -0
  85. package/dataflow/environments/query-fn-props.js +20 -0
  86. package/dataflow/environments/resolve-by-name.d.ts +7 -0
  87. package/dataflow/environments/resolve-by-name.js +26 -2
  88. package/dataflow/environments/resolve-helper.d.ts +3 -1
  89. package/dataflow/environments/resolve-helper.js +2 -0
  90. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -2
  91. package/dataflow/eval/resolve/alias-tracking.js +2 -2
  92. package/dataflow/eval/resolve/match-arguments.js +7 -5
  93. package/dataflow/eval/resolve/node-value.d.ts +3 -1
  94. package/dataflow/eval/resolve/node-value.js +12 -0
  95. package/dataflow/eval/resolve/resolve-argument.js +5 -4
  96. package/dataflow/eval/resolve/resolve-operators.js +10 -7
  97. package/dataflow/eval/resolve/resolve-strings.js +2 -2
  98. package/dataflow/eval/resolve/resolve-working-directory.d.ts +1 -1
  99. package/dataflow/eval/resolve/resolve-working-directory.js +5 -5
  100. package/dataflow/eval/resolve/resolve.js +3 -2
  101. package/dataflow/eval/values/general.js +8 -5
  102. package/dataflow/extractor.d.ts +1 -4
  103. package/dataflow/extractor.js +11 -10
  104. package/dataflow/fn/exceptions-of-function.d.ts +6 -2
  105. package/dataflow/fn/exceptions-of-function.js +85 -38
  106. package/dataflow/fn/strict-function.d.ts +40 -0
  107. package/dataflow/fn/strict-function.js +339 -0
  108. package/dataflow/graph/call-graph.js +2 -2
  109. package/dataflow/graph/df-helper.d.ts +17 -2
  110. package/dataflow/graph/df-helper.js +19 -3
  111. package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
  112. package/dataflow/graph/diff-dataflow-graph.js +19 -2
  113. package/dataflow/graph/edge.d.ts +38 -2
  114. package/dataflow/graph/edge.js +32 -2
  115. package/dataflow/graph/graph.d.ts +32 -5
  116. package/dataflow/graph/graph.js +65 -4
  117. package/dataflow/graph/match-args.d.ts +69 -0
  118. package/dataflow/graph/match-args.js +167 -0
  119. package/dataflow/info.d.ts +40 -0
  120. package/dataflow/info.js +28 -1
  121. package/dataflow/internal/control-flow.d.ts +102 -0
  122. package/dataflow/internal/control-flow.js +200 -0
  123. package/dataflow/internal/linker.d.ts +6 -31
  124. package/dataflow/internal/linker.js +24 -81
  125. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  126. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +3 -3
  127. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -2
  128. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +9 -6
  129. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  130. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +6 -4
  131. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -10
  132. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -37
  133. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  134. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -3
  135. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +1 -1
  136. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +11 -7
  137. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
  138. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  139. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +18 -14
  140. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +8 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +11 -0
  142. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  143. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -20
  144. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -2
  145. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  146. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +35 -6
  147. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  148. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +20 -17
  149. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  150. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +6 -4
  151. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +4 -3
  152. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +8 -3
  153. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +2 -2
  154. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +5 -5
  155. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +1 -1
  156. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +5 -4
  157. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +7 -5
  158. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +15 -13
  160. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
  161. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  162. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +4 -3
  163. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +1 -1
  164. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +26 -4
  165. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -2
  166. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +17 -4
  167. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
  168. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +97 -33
  169. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +6 -15
  170. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +12 -13
  171. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
  172. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +15 -12
  173. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +15 -1
  174. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
  175. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +12 -8
  176. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -5
  177. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  178. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +5 -4
  179. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  180. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +45 -10
  181. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +2 -2
  182. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +19 -3
  183. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +6 -2
  184. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -8
  185. package/dataflow/internal/process/functions/call/common.js +5 -6
  186. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  187. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +12 -2
  188. package/dataflow/internal/process/functions/call/known-call-handling.js +23 -1
  189. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -0
  190. package/dataflow/internal/process/functions/call/nse.d.ts +1 -1
  191. package/dataflow/internal/process/functions/call/nse.js +6 -1
  192. package/dataflow/internal/process/functions/call/quoted.js +2 -2
  193. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +19 -6
  194. package/dataflow/internal/process/functions/process-argument.d.ts +1 -1
  195. package/dataflow/internal/process/functions/process-argument.js +12 -4
  196. package/dataflow/internal/process/functions/process-parameter.js +13 -0
  197. package/dataflow/internal/process/process-named-call.d.ts +2 -2
  198. package/dataflow/internal/process/process-named-call.js +9 -7
  199. package/documentation/data/server/doc-data-server-messages.js +4 -4
  200. package/documentation/doc-readme.js +45 -0
  201. package/documentation/doc-util/doc-cfg.d.ts +8 -7
  202. package/documentation/doc-util/doc-cfg.js +10 -10
  203. package/documentation/doc-util/doc-playground.d.ts +12 -0
  204. package/documentation/doc-util/doc-playground.js +21 -0
  205. package/documentation/doc-util/doc-query.d.ts +4 -1
  206. package/documentation/doc-util/doc-query.js +4 -2
  207. package/documentation/wiki-absint.d.ts +3 -4
  208. package/documentation/wiki-absint.js +12 -5
  209. package/documentation/wiki-analyzer.js +2 -2
  210. package/documentation/wiki-cfg.js +101 -106
  211. package/documentation/wiki-core.js +1 -1
  212. package/documentation/wiki-dataflow-graph.js +85 -53
  213. package/documentation/wiki-linter.js +16 -1
  214. package/documentation/wiki-linting-and-testing.js +1 -16
  215. package/documentation/wiki-mk/doc-maker.js +6 -4
  216. package/documentation/wiki-query.js +67 -4
  217. package/documentation/wiki-signature-database.js +28 -2
  218. package/linter/linter-fix.d.ts +16 -0
  219. package/linter/linter-fix.js +104 -0
  220. package/linter/linter-format.d.ts +18 -1
  221. package/linter/linter-format.js +31 -1
  222. package/linter/linter-output.js +47 -11
  223. package/linter/linter-rules.d.ts +64 -9
  224. package/linter/linter-rules.js +5 -1
  225. package/linter/rules/absolute-path.js +4 -2
  226. package/linter/rules/dataframe-access-validation.js +6 -7
  227. package/linter/rules/deprecated-functions.d.ts +107 -10
  228. package/linter/rules/deprecated-functions.js +309 -23
  229. package/linter/rules/file-path-validity.js +5 -4
  230. package/linter/rules/function-finder-util.d.ts +6 -0
  231. package/linter/rules/function-finder-util.js +21 -13
  232. package/linter/rules/naming-convention.js +1 -1
  233. package/linter/rules/network-functions.d.ts +3 -3
  234. package/linter/rules/stop-with-call-arg.js +2 -2
  235. package/linter/rules/unclosed-connection.d.ts +44 -0
  236. package/linter/rules/unclosed-connection.js +200 -0
  237. package/linter/rules/undefined-symbol-util.js +6 -4
  238. package/linter/rules/undefined-symbol.js +2 -2
  239. package/linter/rules/unused-definition.js +8 -4
  240. package/linter/rules/unused-import.d.ts +60 -0
  241. package/linter/rules/unused-import.js +179 -0
  242. package/package.json +5 -8
  243. package/project/attached-packages.js +2 -1
  244. package/project/cache/flowr-analyzer-cache.d.ts +2 -5
  245. package/project/cache/flowr-analyzer-cache.js +4 -7
  246. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +9 -8
  247. package/project/cache/flowr-analyzer-controlflow-cache.js +17 -34
  248. package/project/cache/flowr-cache.d.ts +9 -0
  249. package/project/cache/flowr-cache.js +19 -0
  250. package/project/context/flowr-analyzer-context.d.ts +7 -3
  251. package/project/context/flowr-analyzer-context.js +15 -9
  252. package/project/context/flowr-analyzer-dependencies-context.d.ts +24 -3
  253. package/project/context/flowr-analyzer-dependencies-context.js +9 -14
  254. package/project/context/flowr-analyzer-files-context.js +15 -17
  255. package/project/context/flowr-analyzer-meta-context.js +2 -12
  256. package/project/dependency-version-space.d.ts +3 -10
  257. package/project/dependency-version-space.js +10 -9
  258. package/project/flowr-analyzer.d.ts +4 -6
  259. package/project/flowr-analyzer.js +4 -5
  260. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
  261. package/project/plugins/file-plugins/files/flowr-description-file.js +1 -1
  262. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
  263. package/project/plugins/file-plugins/files/flowr-namespace-file.js +23 -35
  264. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +1 -1
  265. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -1
  266. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +13 -13
  267. package/project/plugins/file-plugins/files/flowr-rda-file.js +131 -286
  268. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +1 -0
  269. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -0
  270. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +2 -5
  271. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +2 -8
  272. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +32 -0
  273. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +43 -1
  274. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +4 -12
  275. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +3 -16
  276. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +5 -8
  277. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +4 -10
  278. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +3 -10
  279. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -13
  280. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +3 -6
  281. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -8
  282. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.d.ts +2 -5
  283. package/project/plugins/file-plugins/flowr-analyzer-news-file-plugin.js +2 -8
  284. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +2 -5
  285. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +2 -8
  286. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.d.ts +3 -4
  287. package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -6
  288. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.d.ts +4 -12
  289. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +3 -16
  290. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.d.ts +4 -12
  291. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +3 -16
  292. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +4 -12
  293. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -16
  294. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +2 -5
  295. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +2 -8
  296. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +2 -6
  297. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -10
  298. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +2 -5
  299. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +2 -8
  300. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +2 -1
  301. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +5 -5
  302. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +33 -6
  303. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  304. package/project/sigdb/build.d.ts +2 -2
  305. package/project/sigdb/decode.d.ts +0 -5
  306. package/project/sigdb/decode.js +0 -8
  307. package/project/sigdb/index-format.d.ts +4 -4
  308. package/project/sigdb/manifest.d.ts +5 -3
  309. package/project/sigdb/manifest.js +50 -9
  310. package/project/sigdb/reader.d.ts +48 -13
  311. package/project/sigdb/reader.js +3 -2
  312. package/project/sigdb/schema.d.ts +5 -3
  313. package/project/sigdb/schema.js +2 -2
  314. package/project/sigdb/signature-db.d.ts +69 -0
  315. package/project/sigdb/signature-db.js +54 -0
  316. package/project/sigdb/signature-match.d.ts +10 -5
  317. package/project/sigdb/signature-match.js +13 -8
  318. package/queries/catalog/absint-query/absint-query-executor.js +1 -2
  319. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -4
  320. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +1 -1
  321. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +33 -6
  322. package/queries/catalog/control-flow-query/control-flow-query-executor.js +1 -2
  323. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  324. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +8 -7
  325. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -35
  326. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +13 -1
  327. package/queries/catalog/dependencies-query/function-info/library-functions.js +26 -22
  328. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +9 -0
  329. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +19 -0
  330. package/queries/catalog/dependencies-query/implicit-echo.d.ts +13 -0
  331. package/queries/catalog/dependencies-query/implicit-echo.js +133 -0
  332. package/queries/catalog/dependencies-query/link-devices.js +2 -8
  333. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
  334. package/queries/catalog/happens-before-query/happens-before-query-executor.js +1 -2
  335. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -1
  336. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
  337. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -0
  338. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +6 -0
  339. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +25 -0
  340. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +31 -0
  341. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +56 -0
  342. package/queries/catalog/signature-query/signature-query-executor.js +4 -3
  343. package/queries/catalog/slice-query-options.d.ts +1 -1
  344. package/queries/catalog/slice-query-options.js +1 -1
  345. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  346. package/queries/query-function-filter.d.ts +8 -2
  347. package/queries/query-function-filter.js +11 -1
  348. package/queries/query.d.ts +11 -1
  349. package/queries/query.js +2 -0
  350. package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
  351. package/r-bridge/lang-4.x/ast/model/model.js +4 -4
  352. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
  353. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
  354. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  355. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
  356. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +4 -1
  357. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -2
  358. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  359. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
  360. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  361. package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
  362. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  363. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
  364. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  365. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
  366. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  367. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
  368. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -4
  369. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +6 -4
  370. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  371. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
  372. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  373. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
  374. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  375. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
  376. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  377. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
  378. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  379. package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
  380. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +6 -0
  381. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +13 -0
  382. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  383. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
  384. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  385. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
  386. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +1 -0
  387. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +1 -0
  388. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  389. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
  390. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  391. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -0
  392. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  393. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
  394. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  395. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
  396. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  397. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
  398. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +2 -1
  399. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  400. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +3 -2
  401. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -1
  402. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +2 -1
  403. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  404. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -1
  405. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +2 -2
  406. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +6 -3
  407. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -1
  408. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -1
  409. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -3
  410. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +2 -1
  411. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -1
  412. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -1
  413. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +5 -3
  414. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -1
  415. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +1 -1
  416. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -1
  417. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +3 -1
  418. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +1 -1
  419. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -1
  420. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +5 -3
  421. package/reconstruct/inline/source-inline-map.js +3 -3
  422. package/reconstruct/reconstruct.js +6 -4
  423. package/search/flowr-search-builder.d.ts +8 -8
  424. package/search/flowr-search-builder.js +4 -4
  425. package/search/flowr-search-filters.d.ts +2 -2
  426. package/search/flowr-search-filters.js +4 -15
  427. package/search/search-executor/search-enrichers.d.ts +6 -4
  428. package/search/search-executor/search-enrichers.js +44 -5
  429. package/slicing/criterion/filters/all-variables.js +2 -1
  430. package/slicing/criterion/parse.d.ts +2 -2
  431. package/slicing/criterion/parse.js +10 -8
  432. package/slicing/static/fingerprint.js +1 -1
  433. package/slicing/static/slice-call.js +2 -2
  434. package/util/arg-matching.d.ts +3 -0
  435. package/util/arg-matching.js +12 -1
  436. package/util/collections/arrays.d.ts +0 -4
  437. package/util/collections/arrays.js +4 -26
  438. package/util/diff-graph.d.ts +1 -1
  439. package/util/diff-graph.js +17 -3
  440. package/util/diff.d.ts +6 -0
  441. package/util/mermaid/ast.d.ts +1 -1
  442. package/util/mermaid/ast.js +5 -4
  443. package/util/mermaid/cfg.js +130 -24
  444. package/util/mermaid/dfg.js +31 -10
  445. package/util/mermaid/mermaid.js +2 -0
  446. package/util/objects.d.ts +21 -0
  447. package/util/objects.js +60 -0
  448. package/util/prefix.d.ts +1 -1
  449. package/util/simple-df/dfg-ascii.js +14 -3
  450. package/util/text/name-rank.d.ts +1 -1
  451. package/util/text/name-rank.js +1 -1
  452. package/util/text/playground-link.d.ts +131 -0
  453. package/util/text/playground-link.js +214 -0
  454. package/util/text/strings.js +7 -3
  455. package/util/version.js +1 -1
  456. package/control-flow/cfg-builder.d.ts +0 -30
  457. package/control-flow/cfg-builder.js +0 -79
  458. package/control-flow/extract-cfg.d.ts +0 -36
  459. package/control-flow/extract-cfg.js +0 -693
  460. package/project/cfg-kind.d.ts +0 -21
  461. package/project/cfg-kind.js +0 -26
@@ -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