@eagleoutice/flowr 2.6.2 → 2.7.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 (435) hide show
  1. package/README.md +36 -34
  2. package/abstract-interpretation/data-frame/absint-visitor.d.ts +1 -1
  3. package/abstract-interpretation/data-frame/absint-visitor.js +6 -6
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -7
  5. package/abstract-interpretation/data-frame/dataframe-domain.js +5 -11
  6. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +3 -1
  7. package/abstract-interpretation/data-frame/mappers/access-mapper.js +3 -2
  8. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
  9. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +3 -1
  10. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +3 -2
  11. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +7 -7
  12. package/abstract-interpretation/data-frame/mappers/function-mapper.js +28 -24
  13. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +3 -1
  14. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +3 -2
  15. package/abstract-interpretation/data-frame/semantics.js +54 -41
  16. package/abstract-interpretation/data-frame/shape-inference.d.ts +3 -3
  17. package/abstract-interpretation/data-frame/shape-inference.js +3 -3
  18. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -0
  19. package/abstract-interpretation/domains/abstract-domain.js +3 -2
  20. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  21. package/abstract-interpretation/domains/interval-domain.d.ts +2 -2
  22. package/abstract-interpretation/domains/interval-domain.js +3 -6
  23. package/abstract-interpretation/domains/lattice.d.ts +2 -0
  24. package/abstract-interpretation/domains/lattice.js +3 -1
  25. package/abstract-interpretation/domains/positive-interval-domain.d.ts +1 -1
  26. package/abstract-interpretation/domains/positive-interval-domain.js +1 -1
  27. package/abstract-interpretation/domains/satisfiable-domain.d.ts +2 -2
  28. package/abstract-interpretation/domains/satisfiable-domain.js +2 -2
  29. package/abstract-interpretation/domains/set-range-domain.d.ts +98 -0
  30. package/abstract-interpretation/domains/set-range-domain.js +400 -0
  31. package/abstract-interpretation/domains/set-upper-bound-domain.js +2 -2
  32. package/abstract-interpretation/domains/singleton-domain.js +2 -2
  33. package/abstract-interpretation/normalized-ast-fold.d.ts +1 -1
  34. package/benchmark/slicer.d.ts +3 -1
  35. package/benchmark/slicer.js +50 -27
  36. package/benchmark/stats/print.js +8 -5
  37. package/benchmark/stats/stats.d.ts +3 -2
  38. package/benchmark/summarizer/data.d.ts +11 -8
  39. package/benchmark/summarizer/first-phase/process.js +12 -9
  40. package/benchmark/summarizer/second-phase/graph.d.ts +3 -1
  41. package/benchmark/summarizer/second-phase/graph.js +3 -1
  42. package/benchmark/summarizer/second-phase/process.js +24 -18
  43. package/cli/export-quads-app.js +1 -1
  44. package/cli/repl/commands/repl-dataflow.js +2 -1
  45. package/cli/repl/commands/repl-parse.js +16 -4
  46. package/cli/repl/commands/repl-query.js +1 -1
  47. package/cli/repl/core.js +16 -13
  48. package/cli/repl/server/connection.js +2 -1
  49. package/cli/script-core/statistics-helper-core.js +2 -1
  50. package/cli/slicer-app.js +3 -4
  51. package/cli/wiki.d.ts +4 -0
  52. package/cli/wiki.js +165 -0
  53. package/config.d.ts +4 -0
  54. package/config.js +6 -0
  55. package/control-flow/cfg-dead-code.js +14 -3
  56. package/control-flow/cfg-simplification.d.ts +5 -2
  57. package/control-flow/cfg-simplification.js +3 -0
  58. package/control-flow/extract-cfg.d.ts +9 -3
  59. package/control-flow/extract-cfg.js +44 -4
  60. package/control-flow/semantic-cfg-guided-visitor.d.ts +2 -2
  61. package/control-flow/simple-visitor.js +2 -2
  62. package/control-flow/useless-loop.d.ts +3 -3
  63. package/control-flow/useless-loop.js +16 -5
  64. package/core/pipeline-executor.d.ts +3 -6
  65. package/core/pipeline-executor.js +4 -7
  66. package/core/print/normalize-printer.d.ts +1 -1
  67. package/core/print/normalize-printer.js +2 -2
  68. package/core/steps/all/core/00-parse.d.ts +1 -1
  69. package/core/steps/all/core/00-parse.js +1 -1
  70. package/core/steps/all/core/10-normalize.d.ts +3 -9
  71. package/core/steps/all/core/10-normalize.js +1 -16
  72. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +2 -3
  73. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -3
  74. package/core/steps/all/core/20-dataflow.d.ts +3 -4
  75. package/core/steps/all/core/20-dataflow.js +2 -2
  76. package/core/steps/all/static-slicing/00-slice.d.ts +4 -2
  77. package/core/steps/all/static-slicing/00-slice.js +3 -2
  78. package/core/steps/all/static-slicing/10-reconstruct.d.ts +8 -0
  79. package/core/steps/all/static-slicing/10-reconstruct.js +4 -1
  80. package/core/steps/pipeline/default-pipelines.d.ts +94 -95
  81. package/core/steps/pipeline/default-pipelines.js +8 -8
  82. package/dataflow/cluster.js +2 -2
  83. package/dataflow/environments/append.d.ts +5 -0
  84. package/dataflow/environments/append.js +6 -20
  85. package/dataflow/environments/built-in.d.ts +2 -1
  86. package/dataflow/environments/clone.d.ts +1 -2
  87. package/dataflow/environments/clone.js +3 -17
  88. package/dataflow/environments/define.d.ts +7 -3
  89. package/dataflow/environments/define.js +9 -56
  90. package/dataflow/environments/diff.js +3 -3
  91. package/dataflow/environments/environment.d.ts +48 -28
  92. package/dataflow/environments/environment.js +187 -62
  93. package/dataflow/environments/overwrite.d.ts +1 -5
  94. package/dataflow/environments/overwrite.js +2 -61
  95. package/dataflow/environments/reference-to-maybe.d.ts +13 -0
  96. package/dataflow/environments/reference-to-maybe.js +54 -0
  97. package/dataflow/environments/resolve-by-name.d.ts +6 -1
  98. package/dataflow/environments/resolve-by-name.js +56 -4
  99. package/dataflow/environments/scoping.d.ts +8 -4
  100. package/dataflow/environments/scoping.js +13 -9
  101. package/dataflow/eval/resolve/alias-tracking.d.ts +10 -4
  102. package/dataflow/eval/resolve/alias-tracking.js +15 -13
  103. package/dataflow/eval/resolve/resolve-argument.d.ts +2 -1
  104. package/dataflow/eval/resolve/resolve-argument.js +10 -10
  105. package/dataflow/eval/resolve/resolve.d.ts +13 -11
  106. package/dataflow/eval/resolve/resolve.js +16 -15
  107. package/dataflow/eval/values/string/string-constants.d.ts +9 -3
  108. package/dataflow/eval/values/string/string-constants.js +9 -3
  109. package/dataflow/extractor.d.ts +2 -3
  110. package/dataflow/extractor.js +25 -28
  111. package/dataflow/fn/higher-order-function.d.ts +2 -1
  112. package/dataflow/fn/higher-order-function.js +4 -4
  113. package/dataflow/graph/dataflowgraph-builder.d.ts +9 -5
  114. package/dataflow/graph/dataflowgraph-builder.js +21 -11
  115. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  116. package/dataflow/graph/graph.d.ts +13 -11
  117. package/dataflow/graph/graph.js +40 -24
  118. package/dataflow/graph/invert-dfg.d.ts +3 -2
  119. package/dataflow/graph/invert-dfg.js +3 -3
  120. package/dataflow/graph/resolve-graph.d.ts +2 -1
  121. package/dataflow/graph/resolve-graph.js +2 -2
  122. package/dataflow/graph/unknown-replacement.d.ts +4 -2
  123. package/dataflow/graph/unknown-replacement.js +4 -2
  124. package/dataflow/graph/vertex.d.ts +3 -3
  125. package/dataflow/graph/vertex.js +3 -3
  126. package/dataflow/info.d.ts +8 -1
  127. package/dataflow/info.js +21 -0
  128. package/dataflow/internal/linker.js +10 -11
  129. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +2 -2
  130. package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -3
  131. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +7 -1
  132. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +12 -3
  133. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
  134. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -7
  135. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -2
  136. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +3 -1
  137. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -6
  138. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -14
  139. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +10 -8
  140. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -4
  141. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -1
  142. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +10 -14
  143. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  144. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -2
  145. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +3 -1
  146. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +8 -6
  147. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +1 -1
  148. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  149. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +4 -4
  150. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +6 -1
  151. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +7 -2
  152. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -5
  153. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +6 -4
  154. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +15 -10
  155. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +78 -75
  156. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +3 -1
  157. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
  158. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
  159. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -5
  160. package/dataflow/internal/process/functions/call/common.d.ts +1 -1
  161. package/dataflow/internal/process/functions/call/common.js +6 -7
  162. package/dataflow/internal/process/functions/call/default-call-handling.d.ts +3 -1
  163. package/dataflow/internal/process/functions/call/default-call-handling.js +3 -1
  164. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -4
  165. package/dataflow/internal/process/functions/call/named-call-handling.js +4 -4
  166. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +1 -1
  167. package/dataflow/internal/process/functions/process-argument.js +1 -1
  168. package/dataflow/internal/process/functions/process-parameter.js +4 -4
  169. package/dataflow/internal/process/process-symbol.js +1 -1
  170. package/dataflow/internal/process/process-value.d.ts +1 -1
  171. package/dataflow/internal/process/process-value.js +7 -7
  172. package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -1
  173. package/dataflow/origin/dfg-get-symbol-refs.js +1 -1
  174. package/dataflow/processor.d.ts +7 -16
  175. package/documentation/data/dfg/doc-data-dfg-util.d.ts +0 -2
  176. package/documentation/data/faq/faqs.js +27 -18
  177. package/documentation/data/faq/recommended-configs.d.ts +36 -0
  178. package/documentation/data/faq/recommended-configs.js +40 -0
  179. package/documentation/data/faq/wiki-faq-store.d.ts +1 -0
  180. package/documentation/data/faq/wiki-faq-store.js +10 -2
  181. package/documentation/data/server/doc-data-server-messages.js +1 -1
  182. package/documentation/doc-capabilities.d.ts +9 -0
  183. package/documentation/{print-capabilities-markdown.js → doc-capabilities.js} +18 -21
  184. package/documentation/doc-readme.d.ts +9 -0
  185. package/documentation/{print-readme.js → doc-readme.js} +31 -35
  186. package/documentation/doc-util/doc-benchmarks.d.ts +6 -4
  187. package/documentation/doc-util/doc-benchmarks.js +6 -4
  188. package/documentation/doc-util/doc-cfg.js +5 -8
  189. package/documentation/doc-util/doc-dfg.d.ts +7 -7
  190. package/documentation/doc-util/doc-dfg.js +15 -14
  191. package/documentation/doc-util/doc-escape.d.ts +6 -0
  192. package/documentation/doc-util/doc-escape.js +11 -0
  193. package/documentation/doc-util/doc-general.d.ts +22 -2
  194. package/documentation/doc-util/doc-general.js +22 -2
  195. package/documentation/doc-util/doc-normalized-ast.d.ts +10 -5
  196. package/documentation/doc-util/doc-normalized-ast.js +14 -10
  197. package/documentation/doc-util/doc-query.d.ts +12 -4
  198. package/documentation/doc-util/doc-query.js +18 -11
  199. package/documentation/doc-util/doc-search.d.ts +0 -30
  200. package/documentation/doc-util/doc-search.js +2 -73
  201. package/documentation/doc-util/doc-server-message.d.ts +5 -5
  202. package/documentation/doc-util/doc-server-message.js +4 -4
  203. package/documentation/doc-util/doc-types.d.ts +69 -32
  204. package/documentation/doc-util/doc-types.js +109 -62
  205. package/documentation/index.d.ts +9 -9
  206. package/documentation/index.js +9 -9
  207. package/documentation/issue-linting-rule.d.ts +9 -0
  208. package/documentation/{print-linter-issue.js → issue-linting-rule.js} +20 -23
  209. package/documentation/wiki-analyzer.d.ts +9 -0
  210. package/documentation/wiki-analyzer.js +425 -0
  211. package/documentation/wiki-cfg.d.ts +9 -0
  212. package/documentation/{print-cfg-wiki.js → wiki-cfg.js} +144 -160
  213. package/documentation/wiki-core.d.ts +14 -0
  214. package/documentation/{print-core-wiki.js → wiki-core.js} +164 -175
  215. package/documentation/wiki-dataflow-graph.d.ts +9 -0
  216. package/documentation/{print-dataflow-graph-wiki.js → wiki-dataflow-graph.js} +146 -177
  217. package/documentation/wiki-engine.d.ts +9 -0
  218. package/documentation/{print-engines-wiki.js → wiki-engine.js} +27 -42
  219. package/documentation/wiki-faq.d.ts +8 -0
  220. package/documentation/wiki-faq.js +21 -0
  221. package/documentation/wiki-interface.d.ts +9 -0
  222. package/documentation/{print-interface-wiki.js → wiki-interface.js} +59 -56
  223. package/documentation/wiki-linter.d.ts +9 -0
  224. package/documentation/{print-linter-wiki.js → wiki-linter.js} +52 -48
  225. package/documentation/wiki-linting-and-testing.d.ts +9 -0
  226. package/documentation/{print-linting-and-testing-wiki.js → wiki-linting-and-testing.js} +25 -32
  227. package/documentation/wiki-mk/doc-context.d.ts +186 -0
  228. package/documentation/wiki-mk/doc-context.js +84 -0
  229. package/documentation/wiki-mk/doc-maker.d.ts +95 -0
  230. package/documentation/wiki-mk/doc-maker.js +134 -0
  231. package/documentation/wiki-normalized-ast.d.ts +9 -0
  232. package/documentation/{print-normalized-ast-wiki.js → wiki-normalized-ast.js} +64 -47
  233. package/documentation/wiki-onboarding.d.ts +8 -0
  234. package/documentation/{print-onboarding-wiki.js → wiki-onboarding.js} +18 -15
  235. package/documentation/wiki-query.d.ts +9 -0
  236. package/documentation/{print-query-wiki.js → wiki-query.js} +62 -47
  237. package/documentation/wiki-search.d.ts +9 -0
  238. package/documentation/wiki-search.js +61 -0
  239. package/linter/linter-executor.js +3 -2
  240. package/linter/linter-format.d.ts +2 -2
  241. package/linter/linter-rules.d.ts +15 -19
  242. package/linter/rules/absolute-path.d.ts +1 -2
  243. package/linter/rules/absolute-path.js +5 -5
  244. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  245. package/linter/rules/dataframe-access-validation.js +13 -9
  246. package/linter/rules/dead-code.d.ts +1 -1
  247. package/linter/rules/deprecated-functions.d.ts +1 -5
  248. package/linter/rules/file-path-validity.d.ts +1 -1
  249. package/linter/rules/file-path-validity.js +4 -4
  250. package/linter/rules/function-finder-util.d.ts +3 -7
  251. package/linter/rules/function-finder-util.js +1 -1
  252. package/linter/rules/naming-convention.d.ts +2 -2
  253. package/linter/rules/naming-convention.js +1 -1
  254. package/linter/rules/network-functions.d.ts +1 -1
  255. package/linter/rules/network-functions.js +1 -1
  256. package/linter/rules/seeded-randomness.d.ts +4 -3
  257. package/linter/rules/seeded-randomness.js +38 -18
  258. package/linter/rules/unused-definition.d.ts +1 -1
  259. package/linter/rules/useless-loop.d.ts +2 -2
  260. package/linter/rules/useless-loop.js +2 -2
  261. package/package.json +5 -17
  262. package/project/cache/flowr-analyzer-cache.d.ts +7 -10
  263. package/project/cache/flowr-analyzer-cache.js +17 -38
  264. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +34 -0
  265. package/project/cache/flowr-analyzer-controlflow-cache.js +79 -0
  266. package/project/context/flowr-analyzer-context.d.ts +37 -5
  267. package/project/context/flowr-analyzer-context.js +51 -4
  268. package/project/context/flowr-analyzer-environment-context.d.ts +47 -0
  269. package/project/context/flowr-analyzer-environment-context.js +50 -0
  270. package/project/context/flowr-analyzer-files-context.d.ts +63 -13
  271. package/project/context/flowr-analyzer-files-context.js +110 -39
  272. package/project/context/flowr-file.d.ts +32 -10
  273. package/project/context/flowr-file.js +30 -9
  274. package/project/flowr-analyzer-builder.d.ts +22 -28
  275. package/project/flowr-analyzer-builder.js +32 -70
  276. package/project/flowr-analyzer.d.ts +55 -14
  277. package/project/flowr-analyzer.js +53 -8
  278. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +7 -1
  279. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +13 -5
  280. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +3 -3
  281. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +11 -5
  282. package/project/plugins/file-plugins/flowr-description-file.d.ts +3 -3
  283. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +22 -0
  284. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +33 -0
  285. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +22 -0
  286. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +33 -0
  287. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +22 -0
  288. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +33 -0
  289. package/project/plugins/file-plugins/notebooks/flowr-jupyter-file.d.ts +20 -0
  290. package/project/plugins/file-plugins/notebooks/flowr-jupyter-file.js +42 -0
  291. package/project/plugins/file-plugins/notebooks/flowr-rmarkdown-file.d.ts +59 -0
  292. package/project/plugins/file-plugins/notebooks/flowr-rmarkdown-file.js +132 -0
  293. package/project/plugins/file-plugins/notebooks/notebook.d.ts +0 -0
  294. package/project/plugins/file-plugins/notebooks/notebook.js +2 -0
  295. package/project/plugins/flowr-analyzer-plugin-defaults.d.ts +5 -0
  296. package/project/plugins/flowr-analyzer-plugin-defaults.js +23 -0
  297. package/project/plugins/flowr-analyzer-plugin.d.ts +2 -0
  298. package/project/plugins/flowr-analyzer-plugin.js +2 -0
  299. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
  300. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  301. package/project/plugins/plugin-registry.d.ts +34 -0
  302. package/project/plugins/plugin-registry.js +62 -0
  303. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +7 -1
  304. package/queries/catalog/call-context-query/call-context-query-executor.js +5 -6
  305. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +5 -2
  306. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +25 -18
  307. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  308. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +1 -1
  309. package/queries/catalog/control-flow-query/control-flow-query-format.js +3 -2
  310. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +1 -1
  311. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  312. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  313. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -1
  314. package/queries/catalog/dependencies-query/dependencies-query-executor.js +5 -5
  315. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  316. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  317. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +1 -1
  318. package/queries/catalog/df-shape-query/df-shape-query-executor.js +2 -2
  319. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +6 -6
  320. package/queries/catalog/df-shape-query/df-shape-query-format.js +8 -7
  321. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +2 -1
  322. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  323. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  324. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  325. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +1 -1
  326. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +4 -4
  327. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
  328. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  329. package/queries/catalog/linter-query/linter-query-format.js +13 -2
  330. package/queries/catalog/location-map-query/location-map-query-executor.js +2 -1
  331. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  332. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  333. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  334. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
  335. package/queries/catalog/project-query/project-query-executor.js +3 -1
  336. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  337. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +2 -2
  338. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +3 -3
  339. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  340. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  341. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -2
  342. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  343. package/queries/catalog/static-slice-query/static-slice-query-format.js +13 -1
  344. package/queries/query.d.ts +26 -18
  345. package/queries/query.js +21 -1
  346. package/r-bridge/lang-4.x/ast/model/collect.d.ts +2 -1
  347. package/r-bridge/lang-4.x/ast/model/collect.js +4 -0
  348. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +29 -0
  349. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +15 -0
  350. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +5 -7
  351. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +24 -11
  352. package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
  353. package/r-bridge/lang-4.x/ast/model/type.js +2 -0
  354. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  355. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +9 -8
  356. package/r-bridge/lang-4.x/ast/parser/json/parser.js +11 -10
  357. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.d.ts +4 -3
  358. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +20 -11
  359. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +3 -3
  360. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +5 -4
  361. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +3 -2
  362. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +14 -5
  363. package/r-bridge/parser.d.ts +15 -5
  364. package/r-bridge/parser.js +27 -13
  365. package/r-bridge/retriever.d.ts +9 -15
  366. package/r-bridge/retriever.js +14 -5
  367. package/r-bridge/shell.d.ts +1 -1
  368. package/r-bridge/shell.js +1 -1
  369. package/reconstruct/auto-select/auto-select-defaults.d.ts +0 -1
  370. package/reconstruct/auto-select/magic-comments.js +1 -1
  371. package/reconstruct/reconstruct.d.ts +17 -9
  372. package/reconstruct/reconstruct.js +19 -8
  373. package/search/flowr-search.d.ts +12 -0
  374. package/search/search-executor/search-enrichers.d.ts +9 -2
  375. package/search/search-executor/search-enrichers.js +1 -3
  376. package/search/search-executor/search-generators.d.ts +1 -1
  377. package/search/search-executor/search-generators.js +9 -4
  378. package/slicing/criterion/collect-all.d.ts +3 -2
  379. package/slicing/criterion/collect-all.js +1 -1
  380. package/slicing/criterion/parse.js +4 -4
  381. package/slicing/static/slice-call.d.ts +3 -2
  382. package/slicing/static/slice-call.js +4 -4
  383. package/slicing/static/static-slicer.d.ts +3 -1
  384. package/slicing/static/static-slicer.js +6 -7
  385. package/statistics/features/supported/assignments/assignments.js +1 -1
  386. package/statistics/features/supported/control-flow/control-flow.js +2 -2
  387. package/statistics/features/supported/data-access/data-access.js +1 -1
  388. package/statistics/features/supported/defined-functions/defined-functions.js +1 -1
  389. package/statistics/features/supported/expression-list/statistics-expression-list.js +1 -1
  390. package/statistics/features/supported/loops/loops.js +1 -1
  391. package/statistics/features/supported/used-functions/used-functions.js +2 -2
  392. package/statistics/features/supported/variables/variables.js +3 -2
  393. package/statistics/statistics.js +3 -2
  394. package/util/assert.d.ts +4 -0
  395. package/util/assert.js +4 -0
  396. package/util/containers.js +1 -1
  397. package/util/files.d.ts +1 -1
  398. package/util/files.js +1 -1
  399. package/util/mermaid/ast.d.ts +4 -3
  400. package/util/mermaid/ast.js +36 -8
  401. package/util/mermaid/cfg.js +1 -1
  402. package/util/mermaid/dfg.d.ts +1 -0
  403. package/util/mermaid/dfg.js +3 -3
  404. package/util/simple-df/dfg-view.d.ts +2 -1
  405. package/util/simple-df/dfg-view.js +2 -2
  406. package/util/version.js +1 -1
  407. package/dataflow/environments/remove.d.ts +0 -12
  408. package/dataflow/environments/remove.js +0 -52
  409. package/documentation/print-analyzer-wiki.d.ts +0 -1
  410. package/documentation/print-analyzer-wiki.js +0 -141
  411. package/documentation/print-capabilities-markdown.d.ts +0 -1
  412. package/documentation/print-cfg-wiki.d.ts +0 -1
  413. package/documentation/print-core-wiki.d.ts +0 -5
  414. package/documentation/print-dataflow-graph-wiki.d.ts +0 -1
  415. package/documentation/print-engines-wiki.d.ts +0 -1
  416. package/documentation/print-faq-wiki.d.ts +0 -1
  417. package/documentation/print-faq-wiki.js +0 -18
  418. package/documentation/print-interface-wiki.d.ts +0 -1
  419. package/documentation/print-linter-issue.d.ts +0 -1
  420. package/documentation/print-linter-wiki.d.ts +0 -1
  421. package/documentation/print-linting-and-testing-wiki.d.ts +0 -1
  422. package/documentation/print-normalized-ast-wiki.d.ts +0 -1
  423. package/documentation/print-onboarding-wiki.d.ts +0 -1
  424. package/documentation/print-query-wiki.d.ts +0 -1
  425. package/documentation/print-readme.d.ts +0 -1
  426. package/documentation/print-search-wiki.d.ts +0 -1
  427. package/documentation/print-search-wiki.js +0 -74
  428. package/util/formats/adapter-format.d.ts +0 -6
  429. package/util/formats/adapter-format.js +0 -3
  430. package/util/formats/adapter.d.ts +0 -27
  431. package/util/formats/adapter.js +0 -58
  432. package/util/formats/adapters/r-adapter.d.ts +0 -4
  433. package/util/formats/adapters/r-adapter.js +0 -7
  434. package/util/formats/adapters/rmd-adapter.d.ts +0 -35
  435. package/util/formats/adapters/rmd-adapter.js +0 -100
@@ -1,29 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cloneEnvironmentInformation = cloneEnvironmentInformation;
4
- const environment_1 = require("./environment");
5
- function cloneEnvironment(environment, recurseParents) {
6
- if (environment === undefined) {
7
- return undefined;
8
- }
9
- else if (environment.builtInEnv) {
10
- return environment; // do not clone the built-in environment
11
- }
12
- /* make sure the clone has the same id */
13
- const clone = new environment_1.Environment(recurseParents ? cloneEnvironment(environment.parent, recurseParents) : environment.parent, environment.builtInEnv);
14
- clone.memory = new Map(JSON.parse(JSON.stringify([...environment.memory])));
15
- return clone;
16
- }
17
4
  /**
18
5
  * Produce a clone of the given environment information.
19
6
  * @param environment - The environment information to clone.
20
- * @param builtInEnvironment - The built-in environment
21
7
  * @param recurseParents - Whether to clone the parent environments as well.
22
8
  */
23
- function cloneEnvironmentInformation(environment, recurseParents = true) {
9
+ function cloneEnvironmentInformation({ current, level }, recurseParents = true) {
24
10
  return {
25
- current: cloneEnvironment(environment.current, recurseParents),
26
- level: environment.level
11
+ current: current.clone(recurseParents),
12
+ level
27
13
  };
28
14
  }
29
15
  //# sourceMappingURL=clone.js.map
@@ -1,12 +1,16 @@
1
1
  import type { REnvironmentInformation } from './environment';
2
- import type { IdentifierDefinition, InGraphIdentifierDefinition } from './identifier';
2
+ import type { Identifier, IdentifierDefinition, InGraphIdentifierDefinition } from './identifier';
3
3
  import type { FlowrConfigOptions } from '../../config';
4
4
  /**
5
5
  * assumes: existing is not undefined, the overwrite has indices
6
6
  */
7
- export declare function mergeDefinitions(existing: readonly IdentifierDefinition[], definition: InGraphIdentifierDefinition): InGraphIdentifierDefinition[];
7
+ export declare function mergeDefinitionsForPointer(existing: readonly IdentifierDefinition[], definition: InGraphIdentifierDefinition): InGraphIdentifierDefinition[];
8
8
  /**
9
9
  * Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
10
10
  * Does not modify the passed along `environments` in-place! It returns the new reference.
11
+ * @see {@link Environment#define} - for details on how (local) definitions are handled.
12
+ * @see {@link Environment#defineSuper} - for details on how (super) definitions are handled.
11
13
  */
12
- export declare function define(definition: IdentifierDefinition, superAssign: boolean | undefined, environment: REnvironmentInformation, config: FlowrConfigOptions): REnvironmentInformation;
14
+ export declare function define(definition: IdentifierDefinition & {
15
+ name: Identifier;
16
+ }, superAssign: boolean | undefined, { level, current }: REnvironmentInformation, config: FlowrConfigOptions): REnvironmentInformation;
@@ -1,39 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mergeDefinitions = mergeDefinitions;
3
+ exports.mergeDefinitionsForPointer = mergeDefinitionsForPointer;
4
4
  exports.define = define;
5
5
  const assert_1 = require("../../util/assert");
6
- const clone_1 = require("./clone");
7
6
  const vertex_1 = require("../graph/vertex");
8
- function defInEnv(newEnvironments, name, definition, config) {
9
- const existing = newEnvironments.memory.get(name);
10
- // When there are defined indices, merge the definitions
11
- const inGraphDefinition = definition;
12
- if (config.solver.pointerTracking &&
13
- existing !== undefined &&
14
- inGraphDefinition.controlDependencies === undefined) {
15
- if (inGraphDefinition.indicesCollection !== undefined) {
16
- newEnvironments.memory.set(name, mergeDefinitions(existing, inGraphDefinition));
17
- return;
18
- }
19
- else if (existing?.flatMap(i => i.indicesCollection ?? []).length > 0) {
20
- // When indices couldn't be resolved, but indices where defined before, just add the definition
21
- existing.push(definition);
22
- return;
23
- }
24
- }
25
- // check if it is maybe or not
26
- if (existing === undefined || definition.controlDependencies === undefined) {
27
- newEnvironments.memory.set(name, [definition]);
28
- }
29
- else {
30
- existing.push(definition);
31
- }
32
- }
33
7
  /**
34
8
  * assumes: existing is not undefined, the overwrite has indices
35
9
  */
36
- function mergeDefinitions(existing, definition) {
10
+ function mergeDefinitionsForPointer(existing, definition) {
37
11
  // When new definition is not a single index, e.g., a list redefinition, then reset existing definition
38
12
  if (definition.indicesCollection?.some(indices => indices.isContainer)) {
39
13
  return [definition];
@@ -119,34 +93,13 @@ function overwriteContainerIndices(existingIndices, overwriteIndex) {
119
93
  /**
120
94
  * Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
121
95
  * Does not modify the passed along `environments` in-place! It returns the new reference.
96
+ * @see {@link Environment#define} - for details on how (local) definitions are handled.
97
+ * @see {@link Environment#defineSuper} - for details on how (super) definitions are handled.
122
98
  */
123
- function define(definition, superAssign, environment, config) {
124
- const name = definition.name;
125
- (0, assert_1.guard)(name !== undefined, () => `Name must be defined, but isn't for ${JSON.stringify(definition)}`);
126
- let newEnvironment;
127
- if (superAssign) {
128
- newEnvironment = (0, clone_1.cloneEnvironmentInformation)(environment, true);
129
- let current = newEnvironment.current;
130
- let last = undefined;
131
- let found = false;
132
- do {
133
- if (current.memory.has(name)) {
134
- current.memory.set(name, [definition]);
135
- found = true;
136
- break;
137
- }
138
- last = current;
139
- current = current.parent;
140
- } while (!current.builtInEnv);
141
- if (!found) {
142
- (0, assert_1.guard)(last !== undefined, () => `Could not find global scope for ${name}`);
143
- last.memory.set(name, [definition]);
144
- }
145
- }
146
- else {
147
- newEnvironment = (0, clone_1.cloneEnvironmentInformation)(environment, false);
148
- defInEnv(newEnvironment.current, name, definition, config);
149
- }
150
- return newEnvironment;
99
+ function define(definition, superAssign, { level, current }, config) {
100
+ return {
101
+ level,
102
+ current: superAssign ? current.defineSuper(definition) : current.define(definition, config),
103
+ };
151
104
  }
152
105
  //# sourceMappingURL=define.js.map
@@ -33,8 +33,8 @@ function diffMemory(a, b, info) {
33
33
  continue;
34
34
  }
35
35
  // we sort both value arrays by their id so that we have no problems with differently ordered arrays (which have no impact)
36
- const sorted = [...value].sort((a, b) => String(a.nodeId).localeCompare(String(b.nodeId)));
37
- const sorted2 = [...value2].sort((a, b) => String(a.nodeId).localeCompare(String(b.nodeId)));
36
+ const sorted = value.slice().sort((a, b) => String(a.nodeId).localeCompare(String(b.nodeId)));
37
+ const sorted2 = value2.slice().sort((a, b) => String(a.nodeId).localeCompare(String(b.nodeId)));
38
38
  for (let i = 0; i < value.length; ++i) {
39
39
  const aVal = sorted[i];
40
40
  const bVal = sorted2[i];
@@ -69,7 +69,7 @@ function diffEnvironment(a, b, info, depth) {
69
69
  }
70
70
  if (a.memory.size !== b.memory.size) {
71
71
  info.report.addComment(`${info.position}[at level: ${depth}] Different number of definitions in environment. ${info.leftname}: ${a.memory.size} vs. ${info.rightname}: ${b.memory.size}`);
72
- (0, diff_1.setDifference)(new Set([...a.memory.keys()]), new Set([...b.memory.keys()]), {
72
+ (0, diff_1.setDifference)(new Set(a.memory.keys()), new Set(b.memory.keys()), {
73
73
  ...info,
74
74
  position: `${info.position}[at level: ${depth}] Key comparison. `
75
75
  });
@@ -1,20 +1,8 @@
1
- /**
2
- * Provides an environment structure similar to R.
3
- * This allows the dataflow to hold current definition locations for variables, based on the current scope.
4
- * @module
5
- */
6
- import type { IdentifierReference } from './identifier';
7
- import type { DataflowGraph } from '../graph/graph';
8
- import type { ControlDependency } from '../info';
9
1
  import type { BuiltInMemory } from './built-in';
10
- /**
11
- * Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#controlDependencies|control dependencies}).
12
- */
13
- export declare function makeReferenceMaybe(ref: IdentifierReference, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency | undefined): IdentifierReference;
14
- /**
15
- *
16
- */
17
- export declare function makeAllMaybe(references: readonly IdentifierReference[] | undefined, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency | undefined): IdentifierReference[];
2
+ import type { Identifier, IdentifierDefinition } from './identifier';
3
+ import type { ControlDependency } from '../info';
4
+ import type { FlowrConfigOptions } from '../../config';
5
+ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
18
6
  /** A single entry/scope within an {@link REnvironmentInformation} */
19
7
  export interface IEnvironment {
20
8
  /** Unique and internally generated identifier -- will not be used for comparison but helps with debugging for tracking identities */
@@ -28,6 +16,12 @@ export interface IEnvironment {
28
16
  */
29
17
  builtInEnv?: true | undefined;
30
18
  }
19
+ type Jsonified = {
20
+ id: NodeId;
21
+ parent: Jsonified | undefined;
22
+ builtInEnv?: true;
23
+ memory: BuiltInMemory;
24
+ };
31
25
  /**
32
26
  * Please use this function only if you do not know the object type.
33
27
  * Otherwise, rely on {@link IEnvironment#builtInEnv}
@@ -36,14 +30,43 @@ export declare function isDefaultBuiltInEnvironment(obj: unknown): boolean;
36
30
  /** @see REnvironmentInformation */
37
31
  export declare class Environment implements IEnvironment {
38
32
  readonly id: number;
39
- parent: IEnvironment;
33
+ parent: Environment;
40
34
  memory: BuiltInMemory;
35
+ cache?: BuiltInMemory;
41
36
  builtInEnv?: true;
42
- constructor(parent: IEnvironment, isBuiltInDefault?: true | undefined);
43
- }
44
- export interface WorkingDirectoryReference {
45
- readonly path: string;
46
- readonly controlDependencies: ControlDependency[] | undefined;
37
+ constructor(parent: Environment, isBuiltInDefault?: true | undefined);
38
+ /**
39
+ * Create a deep clone of this environment.
40
+ * @param recurseParents - Whether to also clone parent environments
41
+ */
42
+ clone(recurseParents: boolean): Environment;
43
+ /**
44
+ * Define a new identifier definition within this environment.
45
+ * @param definition - The definition to add.
46
+ * @param config - The flowr configuration options.
47
+ */
48
+ define(definition: IdentifierDefinition & {
49
+ name: Identifier;
50
+ }, { solver: { pointerTracking } }: FlowrConfigOptions): Environment;
51
+ defineSuper(definition: IdentifierDefinition & {
52
+ name: Identifier;
53
+ }): Environment;
54
+ /**
55
+ * Assumes, that all definitions within other replace those within this environment (given the same name).
56
+ * <b>But</b> if all definitions within other are maybe, then they are appended to the current definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}.
57
+ * This always recurses parents.
58
+ */
59
+ overwrite(other: Environment | undefined, applyCds?: readonly ControlDependency[]): Environment;
60
+ /**
61
+ * Adds all writes of `other` to this environment (i.e., the operations of `other` *might* happen).
62
+ * This always recurses parents.
63
+ */
64
+ append(other: Environment | undefined): Environment;
65
+ remove(name: Identifier): this;
66
+ removeAll(names: readonly {
67
+ name: Identifier;
68
+ }[]): Environment;
69
+ toJSON(): Jsonified;
47
70
  }
48
71
  /**
49
72
  * An environment describes a ({@link IEnvironment#parent|scoped}) mapping of names to their definitions ({@link BuiltIns}).
@@ -55,7 +78,7 @@ export interface WorkingDirectoryReference {
55
78
  * but statically determining all attached environments is theoretically impossible --- consider attachments by user input).
56
79
  *
57
80
  * One important environment is the {@link BuiltIns|BuiltInEnvironment} which contains the default definitions for R's built-in functions and constants.
58
- * Please use {@link initializeCleanEnvironments} to initialize the environments (which includes the built-ins).
81
+ * This environment is created and provided by the {@link FlowrAnalyzerEnvironmentContext}.
59
82
  * During serialization, you may want to rely on the {@link builtInEnvJsonReplacer} to avoid the huge built-in environment.
60
83
  * @see {@link define} - to define a new {@link IdentifierDefinition|identifier definition} within an environment
61
84
  * @see {@link resolveByName} - to resolve an {@link Identifier|identifier/name} to its {@link IdentifierDefinition|definitions} within an environment
@@ -67,15 +90,12 @@ export interface WorkingDirectoryReference {
67
90
  */
68
91
  export interface REnvironmentInformation {
69
92
  /** The currently active environment (the stack is represented by the currently active {@link IEnvironment#parent}). Environments are maintained within the dataflow graph. */
70
- readonly current: IEnvironment;
93
+ readonly current: Environment;
71
94
  /** nesting level of the environment, will be `0` for the global/root environment */
72
95
  readonly level: number;
73
96
  }
74
- /**
75
- * Initialize a new {@link REnvironmentInformation|environment} with the built-ins.
76
- */
77
- export declare function initializeCleanEnvironments(memory?: BuiltInMemory, fullBuiltIns?: boolean): REnvironmentInformation;
78
97
  /**
79
98
  * Helps to serialize an environment, but replaces the built-in environment with a placeholder.
80
99
  */
81
100
  export declare function builtInEnvJsonReplacer(k: unknown, v: unknown): unknown;
101
+ export {};
@@ -1,61 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Environment = void 0;
4
- exports.makeReferenceMaybe = makeReferenceMaybe;
5
- exports.makeAllMaybe = makeAllMaybe;
6
4
  exports.isDefaultBuiltInEnvironment = isDefaultBuiltInEnvironment;
7
- exports.initializeCleanEnvironments = initializeCleanEnvironments;
8
5
  exports.builtInEnvJsonReplacer = builtInEnvJsonReplacer;
9
- const identifier_1 = require("./identifier");
10
- const resolve_by_name_1 = require("./resolve-by-name");
11
- const json_1 = require("../../util/json");
12
- const built_in_config_1 = require("./built-in-config");
13
- /**
14
- * Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#controlDependencies|control dependencies}).
15
- */
16
- function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = undefined) {
17
- if (includeDefs) {
18
- const definitions = ref.name ? (0, resolve_by_name_1.resolveByName)(ref.name, environments, ref.type) : undefined;
19
- for (const definition of definitions ?? []) {
20
- if (definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant) {
21
- if (definition.controlDependencies) {
22
- if (defaultCd && !definition.controlDependencies.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
23
- definition.controlDependencies.push(defaultCd);
24
- }
25
- }
26
- else {
27
- definition.controlDependencies = defaultCd ? [defaultCd] : [];
28
- }
29
- }
30
- }
31
- }
32
- const node = graph.getVertex(ref.nodeId, true);
33
- if (node) {
34
- if (node.cds) {
35
- if (defaultCd && !node.cds.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
36
- node.cds.push(defaultCd);
37
- }
38
- }
39
- else {
40
- node.cds = defaultCd ? [defaultCd] : [];
41
- }
42
- }
43
- if (ref.controlDependencies) {
44
- if (defaultCd && !ref.controlDependencies.find(c => c.id === defaultCd.id && c.when === defaultCd.when)) {
45
- return { ...ref, controlDependencies: (ref.controlDependencies ?? []).concat(defaultCd ? [defaultCd] : []) };
46
- }
47
- }
48
- else {
49
- return { ...ref, controlDependencies: ref.controlDependencies ?? (defaultCd ? [defaultCd] : []) };
50
- }
51
- return ref;
52
- }
53
6
  /**
54
- *
7
+ * Provides an environment structure similar to R.
8
+ * This allows the dataflow to hold current definition locations for variables, based on the current scope.
9
+ * @module
55
10
  */
56
- function makeAllMaybe(references, graph, environments, includeDefs, defaultCd = undefined) {
57
- return references?.map(ref => makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd)) ?? [];
58
- }
11
+ const json_1 = require("../../util/json");
12
+ const assert_1 = require("../../util/assert");
13
+ const info_1 = require("../info");
14
+ const define_1 = require("./define");
15
+ const append_1 = require("./append");
59
16
  /**
60
17
  * Please use this function only if you do not know the object type.
61
18
  * Otherwise, rely on {@link IEnvironment#builtInEnv}
@@ -69,6 +26,7 @@ class Environment {
69
26
  id;
70
27
  parent;
71
28
  memory;
29
+ cache;
72
30
  builtInEnv;
73
31
  constructor(parent, isBuiltInDefault = undefined) {
74
32
  this.id = isBuiltInDefault ? 0 : environmentIdCounter++;
@@ -79,19 +37,186 @@ class Environment {
79
37
  this.builtInEnv = isBuiltInDefault;
80
38
  }
81
39
  }
40
+ /**
41
+ * Create a deep clone of this environment.
42
+ * @param recurseParents - Whether to also clone parent environments
43
+ */
44
+ clone(recurseParents) {
45
+ if (this.builtInEnv) {
46
+ return this; // do not clone the built-in environment
47
+ }
48
+ const parent = recurseParents ? this.parent.clone(recurseParents) : this.parent;
49
+ const clone = new Environment(parent, this.builtInEnv);
50
+ clone.memory = new Map(this.memory.entries()
51
+ .map(([k, v]) => [k,
52
+ v.map(s => ({
53
+ ...s,
54
+ controlDependencies: s.controlDependencies?.slice()
55
+ }))
56
+ ]));
57
+ return clone;
58
+ }
59
+ /**
60
+ * Define a new identifier definition within this environment.
61
+ * @param definition - The definition to add.
62
+ * @param config - The flowr configuration options.
63
+ */
64
+ define(definition, { solver: { pointerTracking } }) {
65
+ const { name } = definition;
66
+ const newEnvironment = this.clone(false);
67
+ // When there are defined indices, merge the definitions
68
+ if (definition.controlDependencies === undefined && !pointerTracking) {
69
+ newEnvironment.memory.set(name, [definition]);
70
+ }
71
+ else {
72
+ const existing = newEnvironment.memory.get(name);
73
+ const inGraphDefinition = definition;
74
+ if (pointerTracking &&
75
+ existing !== undefined &&
76
+ inGraphDefinition.controlDependencies === undefined) {
77
+ if (inGraphDefinition.indicesCollection !== undefined) {
78
+ const defs = (0, define_1.mergeDefinitionsForPointer)(existing, inGraphDefinition);
79
+ newEnvironment.memory.set(name, defs);
80
+ }
81
+ else if (existing?.flatMap(i => i.indicesCollection ?? []).length > 0) {
82
+ // When indices couldn't be resolved, but indices where defined before, just add the definition
83
+ existing.push(definition);
84
+ }
85
+ }
86
+ else if (existing === undefined || definition.controlDependencies === undefined) {
87
+ newEnvironment.memory.set(name, [definition]);
88
+ }
89
+ else {
90
+ existing.push(definition);
91
+ }
92
+ }
93
+ return newEnvironment;
94
+ }
95
+ defineSuper(definition) {
96
+ const { name } = definition;
97
+ const newEnvironment = this.clone(true);
98
+ let current = newEnvironment;
99
+ let last = undefined;
100
+ let found = false;
101
+ do {
102
+ if (current.memory.has(name)) {
103
+ current.memory.set(name, [definition]);
104
+ found = true;
105
+ break;
106
+ }
107
+ last = current;
108
+ current = current.parent;
109
+ } while (!current.builtInEnv);
110
+ if (!found) {
111
+ (0, assert_1.guard)(last !== undefined, () => `Could not find global scope for ${name}`);
112
+ last.memory.set(name, [definition]);
113
+ }
114
+ return newEnvironment;
115
+ }
116
+ /**
117
+ * Assumes, that all definitions within other replace those within this environment (given the same name).
118
+ * <b>But</b> if all definitions within other are maybe, then they are appended to the current definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}.
119
+ * This always recurses parents.
120
+ */
121
+ overwrite(other, applyCds) {
122
+ if (!other || this.builtInEnv) {
123
+ return this;
124
+ }
125
+ const map = new Map(this.memory);
126
+ for (const [key, values] of other.memory) {
127
+ const hasMaybe = applyCds === undefined ? values.length === 0 || values.some(v => v.controlDependencies !== undefined) : true;
128
+ if (hasMaybe) {
129
+ const old = map.get(key);
130
+ // we need to make a copy to avoid side effects for old reference in other environments
131
+ const updatedOld = old?.slice() ?? [];
132
+ for (const v of values) {
133
+ const index = updatedOld.findIndex(o => o.nodeId === v.nodeId && o.definedAt === v.definedAt);
134
+ if (index >= 0) {
135
+ continue;
136
+ }
137
+ if (applyCds === undefined) {
138
+ updatedOld.push(v);
139
+ }
140
+ else {
141
+ updatedOld.push({
142
+ ...v,
143
+ controlDependencies: v.controlDependencies ? applyCds.concat(v.controlDependencies) : applyCds.slice()
144
+ });
145
+ }
146
+ }
147
+ map.set(key, updatedOld);
148
+ }
149
+ else {
150
+ map.set(key, values);
151
+ }
152
+ }
153
+ const out = new Environment(this.parent.overwrite(other.parent, applyCds));
154
+ out.memory = map;
155
+ return out;
156
+ }
157
+ /**
158
+ * Adds all writes of `other` to this environment (i.e., the operations of `other` *might* happen).
159
+ * This always recurses parents.
160
+ */
161
+ append(other) {
162
+ if (!other || this.builtInEnv) {
163
+ return this;
164
+ }
165
+ const map = new Map(this.memory);
166
+ for (const [key, value] of other.memory) {
167
+ const old = map.get(key);
168
+ if (old) {
169
+ map.set(key, (0, append_1.uniqueMergeValuesInDefinitions)(old, value));
170
+ }
171
+ else {
172
+ map.set(key, value);
173
+ }
174
+ }
175
+ const out = new Environment(this.parent.append(other.parent));
176
+ out.memory = map;
177
+ return out;
178
+ }
179
+ remove(name) {
180
+ if (this.builtInEnv) {
181
+ return this;
182
+ }
183
+ const definition = this.memory.get(name);
184
+ let cont = true;
185
+ if (definition !== undefined) {
186
+ this.memory.delete(name);
187
+ this.cache?.delete(name);
188
+ cont = !definition.every(d => (0, info_1.happensInEveryBranch)(d.controlDependencies));
189
+ }
190
+ if (cont) {
191
+ this.parent.remove(name);
192
+ }
193
+ return this;
194
+ }
195
+ removeAll(names) {
196
+ if (this.builtInEnv || names.length === 0) {
197
+ return this;
198
+ }
199
+ const newEnv = this.clone(true);
200
+ // we should optimize this later
201
+ for (const { name } of names) {
202
+ newEnv.remove(name);
203
+ }
204
+ return newEnv;
205
+ }
206
+ toJSON() {
207
+ return this.builtInEnv ? {
208
+ id: this.id,
209
+ parent: this.parent,
210
+ builtInEnv: this.builtInEnv,
211
+ memory: this.memory,
212
+ } : {
213
+ id: this.id,
214
+ parent: this.parent,
215
+ memory: this.memory,
216
+ };
217
+ }
82
218
  }
83
219
  exports.Environment = Environment;
84
- /**
85
- * Initialize a new {@link REnvironmentInformation|environment} with the built-ins.
86
- */
87
- function initializeCleanEnvironments(memory, fullBuiltIns = true) {
88
- const builtInEnv = new Environment(undefined, true);
89
- builtInEnv.memory = memory ?? (fullBuiltIns ? (0, built_in_config_1.getDefaultBuiltInDefinitions)().builtInMemory : (0, built_in_config_1.getDefaultBuiltInDefinitions)().emptyBuiltInMemory);
90
- return {
91
- current: new Environment(builtInEnv),
92
- level: 0
93
- };
94
- }
95
220
  /**
96
221
  * Helps to serialize an environment, but replaces the built-in environment with a placeholder.
97
222
  */
@@ -1,9 +1,5 @@
1
- import { type IEnvironment, type REnvironmentInformation } from './environment';
1
+ import { type REnvironmentInformation } from './environment';
2
2
  import type { ControlDependency } from '../info';
3
- /**
4
- *
5
- */
6
- export declare function overwriteIEnvironmentWith(base: IEnvironment | undefined, next: IEnvironment | undefined, includeParent?: boolean, applyCds?: readonly ControlDependency[]): IEnvironment;
7
3
  export declare function overwriteEnvironment(base: REnvironmentInformation, next: REnvironmentInformation | undefined, applyCds?: readonly ControlDependency[]): REnvironmentInformation;
8
4
  export declare function overwriteEnvironment(base: REnvironmentInformation | undefined, next: REnvironmentInformation, applyCds?: readonly ControlDependency[]): REnvironmentInformation;
9
5
  export declare function overwriteEnvironment(base: undefined, next: undefined, applyCds?: readonly ControlDependency[]): undefined;
@@ -1,70 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.overwriteIEnvironmentWith = overwriteIEnvironmentWith;
4
3
  exports.overwriteEnvironment = overwriteEnvironment;
5
4
  const assert_1 = require("../../util/assert");
6
- const environment_1 = require("./environment");
7
- const log_1 = require("../../util/log");
8
- function anyIsMaybeOrEmpty(values) {
9
- if (values.length === 0) {
10
- return true;
11
- }
12
- for (const val of values) {
13
- if (val.controlDependencies !== undefined) {
14
- return true;
15
- }
16
- }
17
- return false;
18
- }
19
- /**
20
- *
21
- */
22
- function overwriteIEnvironmentWith(base, next, includeParent = true, applyCds) {
23
- (0, assert_1.guard)(base !== undefined && next !== undefined, 'can not overwrite environments with undefined');
24
- const map = new Map(base.memory);
25
- for (const [key, values] of next.memory) {
26
- if (values.length > 1_000_000) {
27
- log_1.log.warn(`Overwriting environment with ${values.length} definitions for ${key}`);
28
- }
29
- const hasMaybe = applyCds !== undefined ? true : anyIsMaybeOrEmpty(values);
30
- if (hasMaybe) {
31
- const old = map.get(key);
32
- // we need to make a copy to avoid side effects for old reference in other environments
33
- const updatedOld = [...old ?? []];
34
- for (const v of values) {
35
- const index = updatedOld.findIndex(o => o.nodeId === v.nodeId && o.definedAt === v.definedAt);
36
- if (index < 0) {
37
- if (applyCds !== undefined) {
38
- updatedOld.push({
39
- ...v,
40
- controlDependencies: applyCds.concat(v.controlDependencies ?? [])
41
- });
42
- }
43
- else {
44
- updatedOld.push(v);
45
- }
46
- }
47
- }
48
- map.set(key, updatedOld);
49
- }
50
- else {
51
- map.set(key, values);
52
- }
53
- }
54
- let parent;
55
- if (includeParent) {
56
- parent = base.parent.builtInEnv ? base.parent : overwriteIEnvironmentWith(base.parent, next.parent, includeParent, applyCds);
57
- }
58
- else {
59
- parent = base.parent;
60
- }
61
- const out = new environment_1.Environment(parent);
62
- out.memory = map;
63
- return out;
64
- }
65
5
  /**
66
6
  * Assumes, that all definitions within next replace those within base (given the same name).
67
7
  * <b>But</b> if all definitions within next are maybe, then they are appended to the base definitions (updating them to be `maybe` from now on as well), similar to {@link appendEnvironment}.
8
+ * @see {@link Environment.overwrite} - for details on how definitions are handled.
68
9
  */
69
10
  function overwriteEnvironment(base, next, applyCds) {
70
11
  if (base === undefined) {
@@ -75,7 +16,7 @@ function overwriteEnvironment(base, next, applyCds) {
75
16
  }
76
17
  (0, assert_1.guard)(next.level === base.level, `cannot overwrite environments with differently nested local scopes, base ${base.level} vs. next ${next.level}. This should not happen.`);
77
18
  return {
78
- current: overwriteIEnvironmentWith(base.current, next.current, true, applyCds),
19
+ current: base.current.overwrite(next.current, applyCds),
79
20
  level: base.level
80
21
  };
81
22
  }
@@ -0,0 +1,13 @@
1
+ import type { IdentifierReference } from './identifier';
2
+ import type { DataflowGraph } from '../graph/graph';
3
+ import type { ControlDependency } from '../info';
4
+ import type { REnvironmentInformation } from './environment';
5
+ /**
6
+ * Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#controlDependencies|control dependencies}).
7
+ */
8
+ export declare function makeReferenceMaybe(ref: IdentifierReference, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency | undefined): IdentifierReference;
9
+ /**
10
+ * Marks all references as maybe (i.e., as controlled by a set of {@link IdentifierReference#controlDependencies|control dependencies}).
11
+ * @see {@link makeReferenceMaybe}
12
+ */
13
+ export declare function makeAllMaybe(references: readonly IdentifierReference[] | undefined, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency | undefined): IdentifierReference[];