@eagleoutice/flowr 2.14.3 → 2.15.0

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 (385) hide show
  1. package/README.md +76 -63
  2. package/abstract-interpretation/absint-inference.d.ts +347 -0
  3. package/abstract-interpretation/{absint-visitor.js → absint-inference.js} +327 -97
  4. package/abstract-interpretation/abstract-semantics.d.ts +246 -0
  5. package/abstract-interpretation/abstract-semantics.js +3 -0
  6. package/abstract-interpretation/data-frame/{mappers/arguments.d.ts → arguments.d.ts} +18 -16
  7. package/abstract-interpretation/data-frame/{mappers/arguments.js → arguments.js} +20 -21
  8. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +52 -0
  9. package/abstract-interpretation/data-frame/dataframe-semantics.js +1656 -0
  10. package/abstract-interpretation/data-frame/resolve-args.js +4 -4
  11. package/abstract-interpretation/data-frame/semantics.d.ts +15 -21
  12. package/abstract-interpretation/data-frame/semantics.js +27 -29
  13. package/abstract-interpretation/data-frame/shape-inference.d.ts +28 -24
  14. package/abstract-interpretation/data-frame/shape-inference.js +14 -79
  15. package/abstract-interpretation/domains/interval-domain.d.ts +5 -1
  16. package/abstract-interpretation/domains/interval-domain.js +25 -33
  17. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +6 -3
  18. package/abstract-interpretation/domains/multi-value-state-domain.js +24 -4
  19. package/abstract-interpretation/domains/partial-product-domain.d.ts +12 -6
  20. package/abstract-interpretation/domains/partial-product-domain.js +26 -43
  21. package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -6
  22. package/abstract-interpretation/domains/positive-interval-domain.js +3 -29
  23. package/abstract-interpretation/domains/product-domain.d.ts +1 -1
  24. package/abstract-interpretation/domains/set-range-domain.d.ts +6 -0
  25. package/abstract-interpretation/domains/set-range-domain.js +29 -62
  26. package/abstract-interpretation/domains/state-abstract-domain.d.ts +9 -2
  27. package/abstract-interpretation/domains/state-abstract-domain.js +26 -37
  28. package/abstract-interpretation/domains/{state-domain-like.d.ts → state-domain.d.ts} +10 -6
  29. package/abstract-interpretation/domains/{state-domain-like.js → state-domain.js} +1 -1
  30. package/abstract-interpretation/value-semantics.d.ts +113 -0
  31. package/abstract-interpretation/value-semantics.js +115 -0
  32. package/benchmark/slicer.js +12 -6
  33. package/benchmark/stats/feature-counts.d.ts +2 -1
  34. package/benchmark/stats/feature-counts.js +25 -1
  35. package/benchmark/stats/stats.d.ts +4 -0
  36. package/benchmark/summarizer/second-phase/graph.js +7 -0
  37. package/cli/repl/commands/repl-parse.js +11 -22
  38. package/cli/repl/parser/slice-query-parser.d.ts +2 -0
  39. package/cli/repl/parser/slice-query-parser.js +1 -0
  40. package/config.d.ts +30 -205
  41. package/config.js +37 -3
  42. package/control-flow/cfg-properties.d.ts +5 -0
  43. package/control-flow/cfg-properties.js +25 -7
  44. package/control-flow/control-flow-graph.d.ts +11 -37
  45. package/control-flow/control-flow-graph.js +33 -77
  46. package/control-flow/semantic-cfg-guided-visitor.d.ts +63 -320
  47. package/control-flow/semantic-cfg-guided-visitor.js +65 -320
  48. package/dataflow/environments/built-in-config.d.ts +2 -0
  49. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  50. package/dataflow/environments/built-in-proc-name.js +4 -0
  51. package/dataflow/environments/built-in-props.d.ts +192 -82
  52. package/dataflow/environments/built-in-props.js +336 -106
  53. package/dataflow/environments/built-in.d.ts +21 -9
  54. package/dataflow/environments/built-in.js +43 -12
  55. package/dataflow/environments/default-builtin-config.d.ts +3219 -328
  56. package/dataflow/environments/default-builtin-config.js +804 -1031
  57. package/dataflow/environments/environment.d.ts +26 -49
  58. package/dataflow/environments/environment.js +34 -47
  59. package/dataflow/environments/group-generics.d.ts +36 -0
  60. package/dataflow/environments/group-generics.js +58 -0
  61. package/dataflow/environments/identifier.d.ts +106 -6
  62. package/dataflow/environments/identifier.js +19 -1
  63. package/dataflow/environments/query-fn-props.d.ts +16 -8
  64. package/dataflow/environments/query-fn-props.js +45 -21
  65. package/dataflow/environments/resolve-by-name.js +9 -2
  66. package/dataflow/environments/scoping.d.ts +5 -0
  67. package/dataflow/environments/scoping.js +11 -0
  68. package/dataflow/eval/resolve/alias-tracking.d.ts +1 -1
  69. package/dataflow/eval/resolve/alias-tracking.js +20 -2
  70. package/dataflow/eval/resolve/resolve-numbers.d.ts +182 -7
  71. package/dataflow/eval/resolve/resolve-numbers.js +44 -9
  72. package/dataflow/eval/resolve/resolve-strings.d.ts +79 -2
  73. package/dataflow/eval/resolve/resolve-strings.js +16 -7
  74. package/dataflow/eval/resolve/resolve.d.ts +5 -22
  75. package/dataflow/eval/resolve/resolve.js +24 -34
  76. package/dataflow/eval/values/general.d.ts +7 -1
  77. package/dataflow/eval/values/general.js +17 -3
  78. package/dataflow/eval/values/string/string-constants.d.ts +16 -15
  79. package/dataflow/eval/values/string/string-constants.js +59 -27
  80. package/dataflow/extractor.d.ts +2 -1
  81. package/dataflow/extractor.js +16 -4
  82. package/dataflow/fn/argument-roles.d.ts +35 -0
  83. package/dataflow/fn/argument-roles.js +252 -0
  84. package/dataflow/fn/class-declaration.d.ts +148 -0
  85. package/dataflow/fn/class-declaration.js +317 -0
  86. package/dataflow/fn/condition-handlers.d.ts +5 -0
  87. package/dataflow/fn/condition-handlers.js +13 -0
  88. package/dataflow/fn/exceptions-of-function.d.ts +21 -7
  89. package/dataflow/fn/exceptions-of-function.js +74 -43
  90. package/dataflow/fn/frame-reflection.d.ts +46 -0
  91. package/dataflow/fn/frame-reflection.js +169 -0
  92. package/dataflow/fn/function-props.d.ts +32 -0
  93. package/dataflow/fn/function-props.js +160 -0
  94. package/dataflow/fn/higher-order-function.d.ts +23 -5
  95. package/dataflow/fn/higher-order-function.js +64 -18
  96. package/dataflow/fn/strict-function.d.ts +24 -2
  97. package/dataflow/fn/strict-function.js +49 -19
  98. package/dataflow/graph/call-graph.js +10 -2
  99. package/dataflow/graph/df-helper.d.ts +1 -12
  100. package/dataflow/graph/df-helper.js +2 -19
  101. package/dataflow/graph/diff-dataflow-graph.d.ts +1 -1
  102. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  103. package/dataflow/graph/graph.d.ts +39 -188
  104. package/dataflow/graph/graph.js +46 -163
  105. package/dataflow/graph/match-args.d.ts +34 -2
  106. package/dataflow/graph/match-args.js +45 -12
  107. package/dataflow/graph/vertex.d.ts +8 -0
  108. package/dataflow/info.d.ts +7 -5
  109. package/dataflow/info.js +1 -5
  110. package/dataflow/internal/control-flow.js +20 -17
  111. package/dataflow/internal/linker.d.ts +8 -37
  112. package/dataflow/internal/linker.js +22 -55
  113. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -2
  114. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -8
  115. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +3 -4
  116. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +8 -14
  117. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +43 -50
  118. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +4 -1
  119. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +5 -2
  120. package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.d.ts +23 -0
  121. package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.js +24 -0
  122. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -2
  123. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
  124. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +0 -4
  125. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +73 -27
  126. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -11
  127. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +131 -92
  128. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +17 -12
  129. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +187 -99
  130. package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +4 -0
  131. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -0
  132. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +2 -3
  133. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +4 -3
  134. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
  135. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -2
  136. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +0 -1
  137. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -1
  138. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +31 -0
  139. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +101 -0
  140. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +2 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +7 -0
  142. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +23 -21
  143. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +1 -2
  144. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -2
  145. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +22 -1
  146. package/dataflow/internal/process/functions/call/common.d.ts +4 -6
  147. package/dataflow/internal/process/functions/call/common.js +2 -2
  148. package/dataflow/internal/process/functions/call/deferred.d.ts +1 -1
  149. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  150. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +5 -3
  151. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -4
  152. package/dataflow/internal/process/functions/call/named-call-handling.js +19 -13
  153. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -2
  154. package/dataflow/internal/process/functions/call/quoted.js +144 -28
  155. package/dataflow/origin/dfg-get-origin.js +23 -10
  156. package/dataflow/processor.d.ts +2 -1
  157. package/dataflow/processor.js +6 -0
  158. package/documentation/data/interface/doc-writing-code.js +2 -0
  159. package/documentation/doc-util/doc-search.js +1 -1
  160. package/documentation/wiki-absint.d.ts +11 -14
  161. package/documentation/wiki-absint.js +73 -59
  162. package/documentation/wiki-core.js +64 -24
  163. package/documentation/wiki-linter.js +1 -0
  164. package/documentation/wiki-query.js +82 -264
  165. package/documentation/wiki-signature-database.js +23 -6
  166. package/gas.d.ts +91 -47
  167. package/gas.js +97 -13
  168. package/index.d.ts +31 -0
  169. package/index.js +52 -0
  170. package/linter/linter-rules.d.ts +87 -23
  171. package/linter/linter-rules.js +3 -1
  172. package/linter/rules/absolute-path.d.ts +1 -1
  173. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  174. package/linter/rules/dataframe-access-validation.js +10 -8
  175. package/linter/rules/dead-code.d.ts +1 -1
  176. package/linter/rules/deprecated-functions.js +14 -5
  177. package/linter/rules/file-path-validity.d.ts +1 -1
  178. package/linter/rules/naming-convention.d.ts +1 -1
  179. package/linter/rules/naming-convention.js +13 -2
  180. package/linter/rules/network-functions.d.ts +10 -5
  181. package/linter/rules/network-functions.js +48 -36
  182. package/linter/rules/no-leaked-credentials.d.ts +1 -1
  183. package/linter/rules/problematic-inputs.d.ts +1 -1
  184. package/linter/rules/problematic-inputs.js +1 -1
  185. package/linter/rules/seeded-randomness.d.ts +3 -2
  186. package/linter/rules/seeded-randomness.js +7 -3
  187. package/linter/rules/software-has-license.d.ts +1 -1
  188. package/linter/rules/software-has-tests.d.ts +1 -1
  189. package/linter/rules/stop-with-call-arg.d.ts +1 -1
  190. package/linter/rules/syntactically-valid.d.ts +1 -1
  191. package/linter/rules/unclosed-connection.d.ts +3 -3
  192. package/linter/rules/unclosed-connection.js +3 -4
  193. package/linter/rules/undefined-symbol.d.ts +1 -1
  194. package/linter/rules/unescaped-arguments.d.ts +161 -0
  195. package/linter/rules/unescaped-arguments.js +293 -0
  196. package/linter/rules/unused-definition.d.ts +1 -1
  197. package/linter/rules/unused-definition.js +51 -6
  198. package/linter/rules/unused-import.d.ts +1 -1
  199. package/linter/rules/useless-loop.d.ts +1 -1
  200. package/package.json +3 -198
  201. package/project/context/flowr-analyzer-environment-context.d.ts +12 -1
  202. package/project/context/flowr-analyzer-environment-context.js +33 -1
  203. package/project/context/flowr-analyzer-files-context.d.ts +24 -1
  204. package/project/context/flowr-analyzer-files-context.js +42 -21
  205. package/project/context/flowr-analyzer-functions-context.d.ts +8 -0
  206. package/project/context/flowr-analyzer-functions-context.js +2 -0
  207. package/project/context/flowr-analyzer-gas-context.d.ts +9 -1
  208. package/project/context/flowr-analyzer-gas-context.js +21 -0
  209. package/project/context/flowr-file.d.ts +16 -1
  210. package/project/context/flowr-file.js +26 -2
  211. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +19 -20
  212. package/project/plugins/file-plugins/files/flowr-description-file.js +55 -41
  213. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +9 -4
  214. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +11 -3
  215. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +6 -9
  216. package/project/plugins/file-plugins/files/flowr-manifest-files.js +5 -21
  217. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +11 -12
  218. package/project/plugins/file-plugins/files/flowr-namespace-file.js +48 -61
  219. package/project/plugins/file-plugins/files/flowr-news-file.d.ts +3 -12
  220. package/project/plugins/file-plugins/files/flowr-news-file.js +2 -19
  221. package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +145 -0
  222. package/project/plugins/file-plugins/files/flowr-rd-file.js +676 -0
  223. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +122 -422
  224. package/project/plugins/file-plugins/files/flowr-rda-file.js +517 -1005
  225. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +8 -2
  226. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +10 -1
  227. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +7 -2
  228. package/project/plugins/file-plugins/files/flowr-sweave-file.js +9 -1
  229. package/project/plugins/file-plugins/files/flowr-sysdata-file.d.ts +17 -0
  230. package/project/plugins/file-plugins/files/flowr-sysdata-file.js +40 -0
  231. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -0
  232. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +3 -1
  233. package/project/plugins/file-plugins/flowr-analyzer-rd-file-plugin.d.ts +58 -0
  234. package/project/plugins/file-plugins/flowr-analyzer-rd-file-plugin.js +95 -0
  235. package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.d.ts +23 -0
  236. package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.js +33 -0
  237. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +33 -72
  238. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +17 -15
  239. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +20 -37
  240. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +29 -53
  241. package/project/plugins/package-version-plugins/package.js +2 -1
  242. package/project/plugins/plugin-registry.d.ts +3 -1
  243. package/project/plugins/plugin-registry.js +11 -0
  244. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +20 -4
  245. package/project/sigdb/build.d.ts +9 -15
  246. package/project/sigdb/build.js +63 -42
  247. package/project/sigdb/decode.d.ts +10 -4
  248. package/project/sigdb/decode.js +60 -21
  249. package/project/sigdb/memory-source.d.ts +4 -0
  250. package/project/sigdb/memory-source.js +8 -0
  251. package/project/sigdb/reader.d.ts +50 -100
  252. package/project/sigdb/reader.js +84 -105
  253. package/project/sigdb/schema.d.ts +102 -26
  254. package/project/sigdb/schema.js +14 -6
  255. package/project/sigdb/signature-db.d.ts +4 -0
  256. package/project/sigdb/signature-db.js +8 -1
  257. package/queries/base-query-format.d.ts +7 -0
  258. package/queries/base-query-format.js +29 -0
  259. package/queries/catalog/absint-query/absint-query-executor.js +8 -6
  260. package/queries/catalog/absint-query/absint-query-format.d.ts +20 -9
  261. package/queries/catalog/absint-query/absint-query-format.js +32 -19
  262. package/queries/catalog/call-context-query/call-context-query-executor.js +3 -3
  263. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
  264. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  265. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
  266. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
  267. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  268. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  269. package/queries/catalog/dependencies-query/dependencies-query-executor.js +33 -7
  270. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  271. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +2 -2
  272. package/queries/catalog/dependencies-query/function-info/derived-functions.js +14 -4
  273. package/queries/catalog/dependencies-query/function-info/read-functions.js +7 -121
  274. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +1 -1
  275. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +2 -2
  276. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +4 -46
  277. package/queries/catalog/dependencies-query/function-info/write-functions.js +3 -76
  278. package/queries/catalog/dependencies-query/implicit-echo.js +2 -2
  279. package/queries/catalog/dependencies-query/link-devices.d.ts +2 -2
  280. package/queries/catalog/dependencies-query/link-devices.js +6 -7
  281. package/queries/catalog/dice-query/dice-query-executor.js +1 -1
  282. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
  283. package/queries/catalog/does-call-query/does-call-query-executor.js +4 -0
  284. package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -1
  285. package/queries/catalog/files-query/files-query-format.d.ts +1 -1
  286. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +1 -1
  287. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -1
  288. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  289. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  290. package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -1
  291. package/queries/catalog/input-sources-query/input-source-functions.js +2 -2
  292. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +7 -17
  293. package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -27
  294. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +1 -1
  295. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +3 -8
  296. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +2 -11
  297. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +4 -0
  298. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +60 -0
  299. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +35 -0
  300. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +63 -0
  301. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -6
  302. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +3 -8
  303. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +2 -11
  304. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +3 -8
  305. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +2 -12
  306. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  307. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  308. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  309. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  310. package/queries/catalog/provenance-query/provenance-query-format.d.ts +3 -8
  311. package/queries/catalog/provenance-query/provenance-query-format.js +2 -14
  312. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  313. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  314. package/queries/catalog/signature-query/signature-query-executor.d.ts +9 -9
  315. package/queries/catalog/signature-query/signature-query-executor.js +104 -95
  316. package/queries/catalog/signature-query/signature-query-format.d.ts +34 -8
  317. package/queries/catalog/signature-query/signature-query-format.js +16 -4
  318. package/queries/catalog/signature-query/signature-query-render.js +24 -4
  319. package/queries/catalog/slice-query-options.d.ts +14 -0
  320. package/queries/catalog/slice-query-options.js +15 -0
  321. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +2 -1
  322. package/queries/catalog/static-slice-query/static-slice-query-executor.js +3 -2
  323. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +4 -3
  324. package/queries/catalog/static-slice-query/static-slice-query-format.js +7 -5
  325. package/queries/query-function-filter.d.ts +8 -3
  326. package/queries/query-function-filter.js +16 -6
  327. package/queries/query.d.ts +38 -38
  328. package/queries/query.js +30 -4
  329. package/r-bridge/lang-4.x/ast/model/model.d.ts +5 -0
  330. package/r-bridge/lang-4.x/ast/model/model.js +14 -0
  331. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  332. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +1 -0
  333. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  334. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  335. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  336. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  337. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  338. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  339. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  340. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  341. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  342. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  343. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  344. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  345. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  346. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  347. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  350. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  351. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  352. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +17 -9
  353. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +35 -27
  354. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +33 -22
  355. package/reconstruct/reconstruct.d.ts +9 -20
  356. package/reconstruct/reconstruct.js +66 -28
  357. package/search/flowr-search-filters.d.ts +7 -6
  358. package/search/flowr-search-filters.js +6 -4
  359. package/search/search-executor/search-enrichers.d.ts +10 -10
  360. package/search/search-executor/search-enrichers.js +32 -3
  361. package/search/search-executor/search-transformer.js +15 -23
  362. package/slicing/criterion/parse.js +2 -12
  363. package/slicing/static/slice-call.js +1 -8
  364. package/slicing/static/static-slicer.js +1 -1
  365. package/util/collections/bimap.js +14 -6
  366. package/util/objects.js +16 -17
  367. package/util/r-value.d.ts +5 -4
  368. package/util/record.d.ts +38 -3
  369. package/util/record.js +48 -1
  370. package/util/simple-df/dfg-ascii.js +1 -1
  371. package/util/text/name-rank.js +8 -2
  372. package/util/text/strings.d.ts +5 -0
  373. package/util/text/strings.js +10 -0
  374. package/util/version.js +2 -2
  375. package/abstract-interpretation/absint-visitor.d.ts +0 -223
  376. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +0 -19
  377. package/abstract-interpretation/data-frame/mappers/access-mapper.js +0 -151
  378. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +0 -287
  379. package/abstract-interpretation/data-frame/mappers/function-mapper.js +0 -1096
  380. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +0 -15
  381. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +0 -207
  382. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.d.ts +0 -6
  383. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-executor.js +0 -25
  384. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.d.ts +0 -31
  385. package/queries/catalog/inspect-strictness-query/inspect-strictness-query-format.js +0 -56
@@ -1,26 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractInterpretationVisitor = void 0;
3
+ exports.AbstractInterpreter = void 0;
4
4
  const control_flow_graph_1 = require("../control-flow/control-flow-graph");
5
- const simple_visitor_1 = require("../control-flow/simple-visitor");
6
5
  const semantic_cfg_guided_visitor_1 = require("../control-flow/semantic-cfg-guided-visitor");
6
+ const simple_visitor_1 = require("../control-flow/simple-visitor");
7
7
  const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
8
+ const identifier_1 = require("../dataflow/environments/identifier");
8
9
  const df_helper_1 = require("../dataflow/graph/df-helper");
9
- const graph_1 = require("../dataflow/graph/graph");
10
10
  const edge_1 = require("../dataflow/graph/edge");
11
+ const graph_1 = require("../dataflow/graph/graph");
11
12
  const vertex_1 = require("../dataflow/graph/vertex");
12
- const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
13
- const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
14
- const assert_1 = require("../util/assert");
15
- const abstract_domain_1 = require("./domains/abstract-domain");
16
- const unsupported_functions_1 = require("./unsupported-functions");
13
+ const r_access_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-access");
17
14
  const r_argument_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-argument");
18
15
  const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
19
16
  const r_expression_list_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
17
+ const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
20
18
  const r_if_then_else_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else");
21
- const r_pipe_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
22
19
  const r_parameter_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
20
+ const r_pipe_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
23
21
  const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
22
+ const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
23
+ const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
24
+ const assert_1 = require("../util/assert");
25
+ const record_1 = require("../util/record");
26
+ const abstract_domain_1 = require("./domains/abstract-domain");
27
+ const multi_value_state_domain_1 = require("./domains/multi-value-state-domain");
28
+ const unsupported_functions_1 = require("./unsupported-functions");
24
29
  function stepFrom(graph, node) {
25
30
  return { node, successors: [...graph.successors(node)], at: 0 };
26
31
  }
@@ -30,19 +35,23 @@ function sameValues(a, b) {
30
35
  && a.every((value, at) => value === undefined ? b[at] === undefined : b[at] !== undefined && value.equals(b[at]));
31
36
  }
32
37
  /**
33
- * A control flow graph visitor to perform abstract interpretation.
38
+ * An abstract interpreter that visits the control flow graph to perform abstract interpretation using fixpoint iteration.
34
39
  *
35
- * The worklist below stays within the function it starts in: a function definition produces a closure and its
36
- * body is a region of its own, which nothing flows into.
37
- *
38
- * Calls are not followed by default: flip {@link AbstractInterpretationVisitor#shouldEnterCall|shouldEnterCall()} to
39
- * step into what a call dispatches to and continue with the state at the function's exit points.
40
- * Condition semantics are not applied by default either, but everything needed for them is there:
41
- * {@link AbstractInterpretationVisitor#getPredecessorState|getPredecessorState()} is handed the branch that was
42
- * taken, and {@link BasicCfgGuidedVisitor#getDecidedConstructs|getDecidedConstructs()} names the construct a
43
- * condition belongs to.
40
+ * The visitor infers the abstract values of multiple abstract domains in a single traversal.
41
+ * The abstract state maps each AST node to the abstract values of all domains of the {@link AbsintAnalysis},
42
+ * and whenever a node is visited, the {@link AbstractSemantics} of every domain of the analysis are applied to that state.
43
+ * @template Domains - Type of the abstract product mapping the names of the abstract domains of the analysis to the respective domains
44
+ * @template Config - Type of the configuration of the abstract interpretation visitor
44
45
  */
45
- class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
46
+ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuidedVisitor {
47
+ /**
48
+ * The abstract interpretation analysis performed by the visitor, defining the abstract domains, their abstract semantics, and the reductions between them.
49
+ */
50
+ analysis;
51
+ /**
52
+ * The state abstract domain used by the abstract interpretation visitor.
53
+ */
54
+ stateDomain;
46
55
  /**
47
56
  * The abstract trace of the abstract interpretation visitor mapping node IDs to the abstract state at the respective node.
48
57
  */
@@ -55,14 +64,18 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
55
64
  * The current worklist stack of next vertex IDs to visit.
56
65
  */
57
66
  stack = [];
67
+ /**
68
+ * The cached abstract interpretation contexts of the abstract domains of the analysis (see {@link getContext}).
69
+ */
70
+ contexts = new Map();
58
71
  /**
59
72
  * The nodes a back edge of the control flow graph leads to, computed on demand.
60
- * @see {@link AbstractInterpretationVisitor#isWideningPoint|isWideningPoint()}
73
+ * @see {@link AbstractInterpreter#isWideningPoint|isWideningPoint()}
61
74
  */
62
75
  wideningPoints;
63
76
  /**
64
77
  * What leads to a vertex, without the call a body was entered from.
65
- * {@link AbstractInterpretationVisitor#shouldSkipVertex|shouldSkipVertex()} is asked once per vertex, so
78
+ * {@link AbstractInterpreter#shouldSkipVertex|shouldSkipVertex()} is asked once per vertex, so
66
79
  * an override of it has to say the same thing every time.
67
80
  */
68
81
  predecessorsOf = new Map();
@@ -87,22 +100,67 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
87
100
  returns = new Map();
88
101
  /** The calls that lead back into a definition still being interpreted, and the definition they reach. */
89
102
  recursiveCalls = new Map();
90
- constructor(config, stateDomain) {
103
+ /**
104
+ * Creates an abstract interpretation visitor performing the given analysis.
105
+ * @param config - The configuration of the visitor (containing the normalized AST, the dataflow graph, and the control flow graph of the program to analyze)
106
+ * @param analysis - The abstract interpretation analysis to perform, i.e. the abstract domains, their abstract semantics, and the reductions between them
107
+ */
108
+ constructor(config, analysis) {
91
109
  super({ ...config, defaultVisitingOrder: 'forward' });
92
- this.currentState = stateDomain.top();
110
+ this.analysis = analysis;
111
+ this.stateDomain = new multi_value_state_domain_1.MultiValueStateDomain(new Map(), analysis.domains, analysis.reductions);
112
+ this.currentState = this.stateDomain.top();
113
+ }
114
+ /**
115
+ * Creates the abstract interpretation context that is passed to the abstract semantics of one of the abstract domains of the analysis.
116
+ * The context provides access to the analyzed program and to the abstract states and values inferred for the requested abstract domain so far.
117
+ * @param type - The name of the abstract domain to create the context for
118
+ * @returns The abstract interpretation context for the requested abstract domain
119
+ */
120
+ getContext(type) {
121
+ const cached = this.contexts.get(type);
122
+ if (cached !== undefined) {
123
+ return cached;
124
+ }
125
+ const context = {
126
+ ast: this.config.normalizedAst,
127
+ dfg: this.config.dfg,
128
+ cfg: this.config.controlFlow.graph,
129
+ context: this.config.ctx,
130
+ domain: this.analysis.domains[type],
131
+ getAstNode: nodeId => this.getNormalizedAst(nodeId),
132
+ getDfgVertex: vertexId => vertexId !== undefined ? this.getDataflowGraph(vertexId) : undefined,
133
+ getCfgVertex: vertexId => vertexId !== undefined ? this.getCfgVertex(vertexId) : undefined,
134
+ getAbstractState: nodeId => this.getAbstractState(nodeId, type),
135
+ getAbstractValue: (nodeId, state) => this.getAbstractValue(nodeId, type, state),
136
+ getVariableOrigins: nodeId => this.getVariableOrigins(nodeId)
137
+ };
138
+ this.contexts.set(type, context);
139
+ return context;
93
140
  }
94
141
  /**
95
- * Resolves the inferred abstract value of an AST node.
96
- * This requires that the abstract interpretation visitor has been completed, or at least started.
97
- * @param id - The ID of the node to get the inferred value for
98
- * @param state - An optional state abstract domain used to resolve the inferred abstract value (defaults to the state at the requested node)
99
- * @returns The inferred abstract value of the node, or `undefined` if no value was inferred for the node
142
+ * Creates a view of a multi-value abstract state that only exposes the abstract values of one of the abstract domains of the analysis.
143
+ * All modifications of the returned view are applied to the underlying multi-value abstract state.
144
+ * @param type - The name of the abstract domain to create the state view for
145
+ * @param state - The multi-value abstract state to create the view for (defaults to the current abstract state)
146
+ * @returns The state abstract domain of the requested abstract domain
100
147
  */
101
- getAbstractValue(id, state) {
102
- const node = (id === undefined || typeof id === 'object') ? id : this.getNormalizedAst(id);
103
- state ??= node !== undefined ? this.getAbstractState(node.info.id) : undefined;
148
+ getState(type, state = this.currentState) {
149
+ return {
150
+ domain: this.analysis.domains[type],
151
+ get: id => state.getValue(id, type),
152
+ has: id => state.hasValue(id, type),
153
+ set: (id, value) => state.setValue(id, type, value),
154
+ remove: id => state.removeValue(id, type),
155
+ entries: () => state.entries(type),
156
+ isBottom: () => state.isBottom()
157
+ };
158
+ }
159
+ getAbstractValue(nodeId, type, state) {
160
+ const node = (nodeId === undefined || typeof nodeId === 'object') ? nodeId : this.getNormalizedAst(nodeId);
161
+ state ??= node !== undefined ? this.getAbstractState(node.info.id, type) : undefined;
104
162
  if (state?.isBottom()) {
105
- return this.currentState.domain.bottom();
163
+ return state.domain.bottom();
106
164
  }
107
165
  else if (node === undefined) {
108
166
  return;
@@ -110,7 +168,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
110
168
  const reached = this.recursiveCalls.get(node.info.id);
111
169
  if (reached !== undefined) {
112
170
  /* it is worth what the definition it reaches was last seen to leave behind, nothing in round one */
113
- return this.returns.get(reached) ?? this.currentState.domain.bottom();
171
+ return this.getReturnValue(reached, type) ?? state?.domain.bottom();
114
172
  }
115
173
  if (state?.has(node.info.id)) {
116
174
  return state.get(node.info.id);
@@ -119,62 +177,65 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
119
177
  const call = vertex_1.FunctionCallVertex.is(vertex) ? vertex : undefined;
120
178
  const origins = Array.isArray(call?.origin) ? call.origin : [];
121
179
  if (r_symbol_1.RSymbol.is(node)) {
180
+ if (node.info.role === "call-name" /* RoleInParent.FunctionCallName */) {
181
+ return this.getAbstractValue(node.info.parent, type, vertex !== undefined ? state : undefined);
182
+ }
122
183
  const values = this.getVariableOrigins(node.info.id)
123
- .map(origin => (this.getAbstractState(origin)?.isBottom() ? this.currentState.domain.bottom() : state?.get(origin)));
184
+ .map(origin => (this.getAbstractState(origin)?.isBottom() ? state?.domain.bottom() : state?.get(origin)));
124
185
  if (values.length > 0 && values.every(assert_1.isNotUndefined)) {
125
186
  return abstract_domain_1.AbstractDomain.joinAll(values);
126
187
  }
127
188
  }
128
189
  else if (r_argument_1.RArgument.isWithValue(node)) {
129
- return this.getAbstractValue(node.value, state);
190
+ return this.getAbstractValue(node.value, type, state);
130
191
  }
131
192
  else if (r_expression_list_1.RExpressionList.is(node) && node.children.length > 0) {
132
- return this.getAbstractValue(node.children.at(-1), state);
193
+ return this.getAbstractValue(node.children.at(-1), type, state);
133
194
  }
134
195
  else if (origins.includes(built_in_proc_name_1.BuiltInProcName.Return)) {
135
196
  /* leaving with `return(x)` is worth what `x` is worth, which is what a function that does it exits with */
136
197
  if (call?.args.length === 1 && call.args[0] !== r_function_call_1.EmptyArgument) {
137
- return this.getAbstractValue(call.args[0].nodeId, state);
198
+ return this.getAbstractValue(call.args[0].nodeId, type, state);
138
199
  }
139
200
  }
140
201
  else if (origins.includes(built_in_proc_name_1.BuiltInProcName.Pipe)) {
141
202
  if (r_pipe_1.RPipe.is(node) || r_binary_op_1.RBinaryOp.is(node)) {
142
- return this.getAbstractValue(node.rhs, state);
203
+ return this.getAbstractValue(node.rhs, type, state);
143
204
  }
144
205
  else if (call?.args.length === 2 && call?.args[1] !== r_function_call_1.EmptyArgument) {
145
- return this.getAbstractValue(call.args[1].nodeId, state);
206
+ return this.getAbstractValue(call.args[1].nodeId, type, state);
146
207
  }
147
208
  }
148
209
  else if (origins.includes(built_in_proc_name_1.BuiltInProcName.IfThenElse)) {
149
210
  let values = [];
150
211
  if (r_if_then_else_1.RIfThenElse.is(node) && node.otherwise !== undefined) {
151
- values = [node.then, node.otherwise].map(entry => this.getAbstractValue(entry, state));
212
+ values = [node.then, node.otherwise].map(entry => this.getAbstractValue(entry, type, state));
152
213
  }
153
214
  else if (call?.args.every(arg => arg !== r_function_call_1.EmptyArgument) && call.args.length === 3) {
154
- values = call.args.slice(1, 3).map(entry => this.getAbstractValue(entry.nodeId, state));
215
+ values = call.args.slice(1, 3).map(entry => this.getAbstractValue(entry.nodeId, type, state));
155
216
  }
156
217
  if (values.length > 0 && values.every(assert_1.isNotUndefined)) {
157
218
  return abstract_domain_1.AbstractDomain.joinAll(values);
158
219
  }
159
220
  }
160
221
  }
161
- /**
162
- * Gets the inferred abstract state at the location of a specific AST node.
163
- * This requires that the abstract interpretation visitor has been completed, or at least started.
164
- * @param id - The ID of the node to get the abstract state at
165
- * @returns The abstract state at the node, or `undefined` if the node has no abstract state (i.e. the node has not been visited or is unreachable).
166
- */
167
- getAbstractState(id) {
168
- return id === undefined ? undefined : this.trace.get(id);
222
+ getAbstractState(nodeId, type) {
223
+ if (nodeId === undefined) {
224
+ return;
225
+ }
226
+ const state = this.trace.get(nodeId);
227
+ if (type !== undefined && state !== undefined) {
228
+ return this.getState(type, state);
229
+ }
230
+ return state;
169
231
  }
170
- /**
171
- * Gets the inferred abstract state at the end of the program (exit nodes of the control flow graph).
172
- * This requires that the abstract interpretation visitor has been completed, or at least started.
173
- * @returns The inferred abstract state at the end of the program
174
- */
175
- getEndState() {
232
+ getEndState(type) {
176
233
  const states = this.config.controlFlow.exitPoints.map(node => this.trace.get(node)).filter(assert_1.isNotUndefined);
177
- return abstract_domain_1.AbstractDomain.joinAll(states, this.currentState.bottom());
234
+ const state = abstract_domain_1.AbstractDomain.joinAll(states, this.stateDomain.bottom());
235
+ if (type !== undefined && state !== undefined) {
236
+ return this.getState(type, state);
237
+ }
238
+ return state;
178
239
  }
179
240
  /**
180
241
  * Gets the inferred abstract trace mapping AST nodes to the inferred abstract state at the respective node.
@@ -183,6 +244,14 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
183
244
  getAbstractTrace() {
184
245
  return this.trace;
185
246
  }
247
+ /** What a definition currently being interpreted was last seen to leave behind, projected to one of the domains if asked for one. */
248
+ getReturnValue(def, type) {
249
+ const value = this.returns.get(def);
250
+ if (type === undefined || value === undefined) {
251
+ return value;
252
+ }
253
+ return value.isValue() ? value.value[type] : undefined;
254
+ }
186
255
  start() {
187
256
  (0, assert_1.guard)(this.trace.size === 0, 'Abstract interpretation visitor has already been started');
188
257
  super.start();
@@ -269,57 +338,210 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
269
338
  return this.onFunctionCall({ call });
270
339
  }
271
340
  }
272
- onVariableDefinition({ vertex }) {
273
- if (!this.trace.has(vertex.id)) {
274
- this.unassigned.add(vertex.id);
341
+ onExpressionList({ call }) {
342
+ const node = this.getNormalizedAst(call.id);
343
+ let expressions;
344
+ if (r_expression_list_1.RExpressionList.is(node)) {
345
+ expressions = node.children.map(child => child.info.id);
275
346
  }
276
- /*
277
- * `bindParameters` hands the arguments over before the function is entered, so a parameter still without
278
- * a value is one the call passed nothing for and is worth the default it names. That default runs before
279
- * the body, so standing on the parameter is the moment to read it.
280
- */
281
- if (this.currentState.has(vertex.id)) {
282
- return;
347
+ else {
348
+ expressions = call.args.map(arg => graph_1.FunctionArgument.isNotEmpty(arg) ? arg.nodeId : undefined).filter(assert_1.isNotUndefined);
283
349
  }
284
- const declaration = this.getNormalizedAst(this.getNormalizedAst(vertex.id)?.info.parent);
285
- if (!r_parameter_1.RParameter.isWithDefault(declaration)) {
350
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
351
+ semantics.handleExpressionList?.(this.getState(type), call, this.getContext(type), expressions);
352
+ }
353
+ }
354
+ onIfThenElseCall({ call, condition, yes, no }) {
355
+ if (condition === undefined || yes === undefined) {
286
356
  return;
287
357
  }
288
- const value = this.getAbstractValue(declaration.defaultValue, this.currentState);
289
- if (value !== undefined) {
290
- this.currentState.set(vertex.id, value);
291
- this.unassigned.delete(vertex.id);
358
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
359
+ semantics.handleIfThenElse?.(this.getState(type), call, this.getContext(type), condition, yes, no);
292
360
  }
293
361
  }
294
- onAssignmentCall({ target, source }) {
295
- if (target === undefined || source === undefined) {
362
+ onForLoopCall({ call, variable, vector, body }) {
363
+ if (graph_1.FunctionArgument.isEmpty(variable) || graph_1.FunctionArgument.isEmpty(vector) || graph_1.FunctionArgument.isEmpty(body)) {
296
364
  return;
297
365
  }
298
- const value = this.getAbstractValue(source);
299
- this.unassigned.delete(target);
300
- if (value !== undefined) {
301
- this.currentState.set(target, value);
366
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
367
+ semantics.handleForLoop?.(this.getState(type), call, this.getContext(type), variable.nodeId, vector.nodeId, body.nodeId);
302
368
  }
303
- else {
304
- this.currentState.remove(target);
369
+ }
370
+ onWhileLoopCall({ call, condition, body }) {
371
+ if (graph_1.FunctionArgument.isEmpty(condition) || graph_1.FunctionArgument.isEmpty(body)) {
372
+ return;
373
+ }
374
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
375
+ semantics.handleWhileLoop?.(this.getState(type), call, this.getContext(type), condition.nodeId, body.nodeId);
305
376
  }
306
- this.trace.set(target, this.currentState);
307
377
  }
308
- onReplacementCall({ target }) {
309
- if (target !== undefined) {
310
- this.unassigned.delete(target);
378
+ onRepeatLoopCall({ call, body }) {
379
+ if (graph_1.FunctionArgument.isEmpty(body)) {
380
+ return;
381
+ }
382
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
383
+ semantics.handleRepeatLoop?.(this.getState(type), call, this.getContext(type), body.nodeId);
311
384
  }
312
385
  }
313
386
  /**
314
387
  * This event triggers for every function call that is not a condition, loop, assignment, replacement call, or access operation.
315
388
  *
316
- *
317
- * For example, this triggers for `data.frame` in `x <- data.frame(id = 1:5, name = letters[1:5])`.
318
- *
319
389
  * This bundles all function calls that are no conditions, loops, assignments, replacement calls, and access operations.
320
390
  * @protected
321
391
  */
322
- onFunctionCall(_data) { }
392
+ onFunctionCall({ call }) {
393
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
394
+ semantics.handleFunctionCall?.(this.getState(type), call, this.getContext(type));
395
+ }
396
+ }
397
+ onAssignmentCall({ call, target, source }) {
398
+ if (target === undefined || source === undefined) {
399
+ return;
400
+ }
401
+ this.unassigned.delete(target);
402
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
403
+ semantics.handleAssignmentCall?.(this.getState(type), call, this.getContext(type), target, source);
404
+ }
405
+ // the assignment target is visited before the assignment, so we update its state with the assigned values
406
+ this.trace.set(target, this.currentState);
407
+ }
408
+ onReplacementCall({ call, target, source }) {
409
+ if (target === undefined || source === undefined) {
410
+ return;
411
+ }
412
+ this.unassigned.delete(target);
413
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
414
+ semantics.handleReplacementCall?.(this.getState(type), call, this.getContext(type), target, source);
415
+ }
416
+ }
417
+ onAccessCall({ call }) {
418
+ const node = this.getNormalizedAst(call.id);
419
+ let target;
420
+ if (r_access_1.RAccess.is(node)) {
421
+ target = node.accessed.info.id;
422
+ }
423
+ else {
424
+ const accessed = call.args.at(0);
425
+ if (accessed === undefined || graph_1.FunctionArgument.isEmpty(accessed)) {
426
+ return;
427
+ }
428
+ target = accessed.nodeId;
429
+ }
430
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
431
+ semantics.handleAccessCall?.(this.getState(type), call, this.getContext(type), target);
432
+ }
433
+ }
434
+ onPipeCall({ call }) {
435
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
436
+ semantics.handlePipeCall?.(this.getState(type), call, this.getContext(type));
437
+ }
438
+ }
439
+ onBreakCall({ call }) {
440
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
441
+ semantics.handleBreakCall?.(this.getState(type), call, this.getContext(type));
442
+ }
443
+ }
444
+ onReturnCall({ call }) {
445
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
446
+ semantics.handleReturnCall?.(this.getState(type), call, this.getContext(type));
447
+ }
448
+ }
449
+ onStringConstant({ vertex, node }) {
450
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
451
+ semantics.handleStringConstant?.(this.getState(type), vertex, this.getContext(type), node.content);
452
+ }
453
+ }
454
+ onNumberConstant({ vertex, node }) {
455
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
456
+ semantics.handleNumberConstant?.(this.getState(type), vertex, this.getContext(type), node.content);
457
+ }
458
+ }
459
+ onLogicalConstant({ vertex, node }) {
460
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
461
+ semantics.handleLogicalConstant?.(this.getState(type), vertex, this.getContext(type), node.content);
462
+ }
463
+ }
464
+ onNullConstant({ vertex, node }) {
465
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
466
+ semantics.handleNullConstant?.(this.getState(type), vertex, this.getContext(type), node.content);
467
+ }
468
+ }
469
+ onSymbolConstant({ vertex, node }) {
470
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
471
+ semantics.handleSymbolConstant?.(this.getState(type), vertex, this.getContext(type), node.content);
472
+ }
473
+ }
474
+ onVariableUse({ vertex }) {
475
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
476
+ semantics.handleVariableUse?.(this.getState(type), vertex, this.getContext(type));
477
+ }
478
+ }
479
+ onVariableDefinition({ vertex }) {
480
+ if (!this.trace.has(vertex.id)) {
481
+ this.unassigned.add(vertex.id);
482
+ }
483
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
484
+ semantics.handleVariableDefinition?.(this.getState(type), vertex, this.getContext(type));
485
+ }
486
+ this.bindParameterDefault(vertex.id);
487
+ }
488
+ onFunctionDefinition({ vertex, parameters }) {
489
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
490
+ semantics.handleFunctionDefinition?.(this.getState(type), vertex, this.getContext(type), parameters ?? record_1.Record.keys(vertex.params));
491
+ }
492
+ }
493
+ /**
494
+ * `bindParameters` hands the arguments over before the function is entered, so a parameter still without
495
+ * a value is one the call passed nothing for and is worth the default it names. That default runs before
496
+ * the body, so standing on the parameter is the moment to read it.
497
+ */
498
+ bindParameterDefault(nodeId) {
499
+ if (this.currentState.has(nodeId)) {
500
+ return;
501
+ }
502
+ const declaration = this.getNormalizedAst(this.getNormalizedAst(nodeId)?.info.parent);
503
+ if (!r_parameter_1.RParameter.isWithDefault(declaration)) {
504
+ return;
505
+ }
506
+ const value = this.getAbstractValue(declaration.defaultValue, undefined, this.currentState);
507
+ if (value !== undefined) {
508
+ this.currentState.set(nodeId, value);
509
+ this.unassigned.delete(nodeId);
510
+ }
511
+ }
512
+ handleConditionBranch(state, conditionVertex, branch) {
513
+ if (vertex_1.FunctionCallVertex.is(conditionVertex) && conditionVertex.args.every(graph_1.FunctionArgument.isNotEmpty)) {
514
+ const name = identifier_1.Identifier.getName(conditionVertex.name);
515
+ const isNot = identifier_1.Identifier.matches(name, ['base', '!']);
516
+ const isAnd = identifier_1.Identifier.matches(name, ['base', '&&']) || identifier_1.Identifier.matches(name, ['base', '&']);
517
+ const isOr = identifier_1.Identifier.matches(name, ['base', '||']) || identifier_1.Identifier.matches(name, ['base', '|']);
518
+ if (isNot && conditionVertex.args.length === 1) {
519
+ const childVertex = this.getDataflowGraph(conditionVertex.args[0].nodeId);
520
+ if (childVertex !== undefined) {
521
+ return this.handleConditionBranch(state, childVertex, branch === convert_values_1.RTrue ? convert_values_1.RFalse : convert_values_1.RTrue);
522
+ }
523
+ }
524
+ else if ((isAnd || isOr) && conditionVertex.args.length === 2) {
525
+ const leftVertex = this.getDataflowGraph(conditionVertex.args[0].nodeId);
526
+ const rightVertex = this.getDataflowGraph(conditionVertex.args[1].nodeId);
527
+ if (leftVertex !== undefined && rightVertex !== undefined) {
528
+ const leftState = this.handleConditionBranch(state, leftVertex, branch);
529
+ const rightState = this.handleConditionBranch(state, rightVertex, branch);
530
+ if (branch === convert_values_1.RTrue && isAnd || branch === convert_values_1.RFalse && isOr) {
531
+ return leftState.meet(rightState);
532
+ }
533
+ else if (branch === convert_values_1.RTrue && isOr || branch === convert_values_1.RFalse && isAnd) {
534
+ return leftState.join(rightState);
535
+ }
536
+ }
537
+ }
538
+ }
539
+ const newState = state.create(state.value);
540
+ for (const [type, semantics] of record_1.Record.properties(this.analysis.semantics)) {
541
+ semantics.handleConditionBranch?.(this.getState(type, newState), conditionVertex, this.getContext(type), branch);
542
+ }
543
+ return newState;
544
+ }
323
545
  /**
324
546
  * Everything the control flow may come from to reach this vertex, together with the branch it took to get here.
325
547
  * Skipped vertices hold no state of their own, so what led into them is reported instead.
@@ -356,11 +578,19 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
356
578
  /**
357
579
  * The abstract state one predecessor contributes, joined into the state at the current vertex.
358
580
  *
359
- * By default, this is the state as the predecessor left it. Override it to apply condition semantics:
360
- * on the then-branch of `if(u) a else b` the predecessor is `u` and `branch.when` is `true`, so `u` held.
581
+ * The condition semantics of the analysis are applied at branches: on the then-branch of `if(u) a else b`
582
+ * the predecessor is `u` and `branch.when` is `true`, so `u` held.
361
583
  */
362
- getPredecessorState({ id }) {
363
- return this.trace.get(id);
584
+ getPredecessorState({ id, branch }) {
585
+ const predState = this.trace.get(id);
586
+ if (predState === undefined || branch === undefined) {
587
+ return predState;
588
+ }
589
+ const conditionVertex = this.getDataflowGraph(branch.id);
590
+ if (conditionVertex === undefined) {
591
+ return predState;
592
+ }
593
+ return this.handleConditionBranch(predState, conditionVertex, branch.when ? convert_values_1.RTrue : convert_values_1.RFalse);
364
594
  }
365
595
  visitFunctionCall(call) {
366
596
  super.visitFunctionCall(call);
@@ -497,7 +727,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
497
727
  continue;
498
728
  }
499
729
  states.push(state);
500
- const value = this.getAbstractValue(exit, state);
730
+ const value = this.getAbstractValue(exit, undefined, state);
501
731
  if (value === undefined) {
502
732
  complete = false;
503
733
  }
@@ -573,7 +803,7 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
573
803
  continue;
574
804
  }
575
805
  /* a call that is not the one being entered is read where it stands, not from the state here */
576
- let value = add === undefined ? this.getAbstractValue(target, this.currentState) : this.getAbstractValue(target);
806
+ let value = add === undefined ? this.getAbstractValue(target, undefined, this.currentState) : this.getAbstractValue(target);
577
807
  const previous = add === undefined ? undefined : this.currentState.get(parameter);
578
808
  if (value !== undefined && previous !== undefined) {
579
809
  value = (add === 'widen' ? previous.widen(value) : previous.join(value));
@@ -685,5 +915,5 @@ class AbstractInterpretationVisitor extends semantic_cfg_guided_visitor_1.Semant
685
915
  return (this.visited.get(control_flow_graph_1.CfgVertex.getId(wideningPoint)) ?? 0) >= this.config.ctx.config.abstractInterpretation.wideningThreshold;
686
916
  }
687
917
  }
688
- exports.AbstractInterpretationVisitor = AbstractInterpretationVisitor;
689
- //# sourceMappingURL=absint-visitor.js.map
918
+ exports.AbstractInterpreter = AbstractInterpreter;
919
+ //# sourceMappingURL=absint-inference.js.map