@eagleoutice/flowr 2.10.9 → 2.11.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 (417) hide show
  1. package/README.md +116 -38
  2. package/abstract-interpretation/absint-visitor.js +6 -3
  3. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
  4. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  5. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  6. package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
  7. package/abstract-interpretation/domains/interval-domain.js +1 -1
  8. package/abstract-interpretation/domains/lattice.d.ts +1 -1
  9. package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
  10. package/abstract-interpretation/domains/partial-product-domain.js +2 -2
  11. package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
  12. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  13. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
  14. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  15. package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
  16. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  17. package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
  18. package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
  19. package/abstract-interpretation/unsupported-functions.d.ts +3 -2
  20. package/abstract-interpretation/unsupported-functions.js +38 -28
  21. package/cli/benchmark-app.js +2 -1
  22. package/cli/common/options.d.ts +2 -108
  23. package/cli/common/options.js +3 -27
  24. package/cli/common/script.js +3 -2
  25. package/cli/common/scripts-info.d.ts +2 -123
  26. package/cli/common/scripts-info.js +0 -17
  27. package/cli/flowr-main-options.d.ts +5 -0
  28. package/cli/flowr-main-options.js +10 -0
  29. package/cli/flowr.js +48 -11
  30. package/cli/repl/commands/repl-cfg.js +9 -9
  31. package/cli/repl/commands/repl-commands.js +5 -0
  32. package/cli/repl/commands/repl-dataflow.js +31 -24
  33. package/cli/repl/commands/repl-main.d.ts +6 -0
  34. package/cli/repl/commands/repl-normalize.js +15 -12
  35. package/cli/repl/commands/repl-parse.js +1 -1
  36. package/cli/repl/commands/repl-query.js +4 -5
  37. package/cli/repl/commands/repl-quit.js +2 -1
  38. package/cli/repl/core.d.ts +11 -0
  39. package/cli/repl/core.js +101 -3
  40. package/cli/repl/execute.js +3 -2
  41. package/cli/repl/parser/slice-query-parser.d.ts +16 -0
  42. package/cli/repl/parser/slice-query-parser.js +52 -0
  43. package/cli/repl/print-version.d.ts +3 -1
  44. package/cli/repl/print-version.js +21 -2
  45. package/cli/repl/server/connection.d.ts +3 -0
  46. package/cli/repl/server/connection.js +65 -31
  47. package/cli/repl/server/messages/message-analysis.d.ts +10 -0
  48. package/cli/repl/server/messages/message-analysis.js +6 -2
  49. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  50. package/cli/script-core/summarizer-core.js +13 -32
  51. package/cli/wiki.d.ts +3 -1
  52. package/cli/wiki.js +6 -1
  53. package/config.d.ts +22 -10
  54. package/config.js +33 -7
  55. package/control-flow/diff-cfg.d.ts +1 -1
  56. package/control-flow/diff-cfg.js +1 -1
  57. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  58. package/control-flow/simple-visitor.js +6 -5
  59. package/control-flow/useless-loop.js +2 -2
  60. package/core/print/dataflow-printer.d.ts +2 -2
  61. package/core/print/dataflow-printer.js +2 -2
  62. package/core/steps/all/static-slicing/00-slice.js +1 -1
  63. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  64. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  65. package/dataflow/environments/append.d.ts +2 -2
  66. package/dataflow/environments/append.js +4 -10
  67. package/dataflow/environments/apply-kill.d.ts +21 -0
  68. package/dataflow/environments/apply-kill.js +155 -0
  69. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  70. package/dataflow/environments/built-in-proc-name.js +4 -0
  71. package/dataflow/environments/built-in.d.ts +4 -0
  72. package/dataflow/environments/built-in.js +4 -0
  73. package/dataflow/environments/default-builtin-config.d.ts +183 -67
  74. package/dataflow/environments/default-builtin-config.js +358 -147
  75. package/dataflow/environments/environment.d.ts +49 -31
  76. package/dataflow/environments/environment.js +144 -25
  77. package/dataflow/environments/identifier.d.ts +65 -2
  78. package/dataflow/environments/identifier.js +37 -2
  79. package/dataflow/environments/overwrite.js +2 -10
  80. package/dataflow/environments/reference-to-maybe.d.ts +2 -0
  81. package/dataflow/environments/reference-to-maybe.js +56 -11
  82. package/dataflow/environments/resolve-by-name.d.ts +1 -1
  83. package/dataflow/environments/resolve-by-name.js +23 -9
  84. package/dataflow/environments/scoping.d.ts +9 -2
  85. package/dataflow/environments/scoping.js +15 -2
  86. package/dataflow/eval/values/general.js +4 -0
  87. package/dataflow/extractor.js +35 -4
  88. package/dataflow/graph/df-helper.d.ts +14 -0
  89. package/dataflow/graph/df-helper.js +41 -0
  90. package/dataflow/graph/graph.d.ts +4 -1
  91. package/dataflow/graph/graph.js +6 -2
  92. package/dataflow/info.d.ts +27 -1
  93. package/dataflow/internal/linker.d.ts +5 -1
  94. package/dataflow/internal/linker.js +34 -9
  95. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
  96. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
  97. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
  98. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
  99. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
  100. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
  101. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
  102. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +7 -2
  103. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
  104. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +61 -1
  105. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
  106. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
  107. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
  108. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
  109. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
  110. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  111. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +3 -2
  112. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +132 -25
  113. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
  114. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
  115. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
  116. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +11 -4
  117. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
  118. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
  119. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
  120. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  121. package/dataflow/internal/process/functions/call/named-call-handling.js +23 -0
  122. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  123. package/dataflow/origin/dfg-get-origin.js +1 -1
  124. package/dataflow/processor.d.ts +6 -0
  125. package/documentation/data/faq/faqs.d.ts +2 -1
  126. package/documentation/data/faq/faqs.js +78 -57
  127. package/documentation/data/interface/doc-writing-code.js +4 -80
  128. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  129. package/documentation/data/server/doc-data-server-messages.js +15 -7
  130. package/documentation/doc-readme.js +15 -15
  131. package/documentation/doc-util/doc-cfg.d.ts +3 -1
  132. package/documentation/doc-util/doc-cfg.js +3 -3
  133. package/documentation/doc-util/doc-dfg.d.ts +3 -1
  134. package/documentation/doc-util/doc-dfg.js +3 -3
  135. package/documentation/doc-util/doc-files.d.ts +3 -1
  136. package/documentation/doc-util/doc-files.js +9 -6
  137. package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
  138. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  139. package/documentation/doc-util/doc-query.d.ts +2 -1
  140. package/documentation/doc-util/doc-query.js +2 -2
  141. package/documentation/doc-util/doc-repl.js +1 -0
  142. package/documentation/doc-util/doc-structure.js +1 -2
  143. package/documentation/doc-util/doc-types.d.ts +6 -6
  144. package/documentation/doc-util/doc-types.js +11 -9
  145. package/documentation/issue-linting-rule.js +1 -2
  146. package/documentation/wiki-analyzer.js +9 -9
  147. package/documentation/wiki-cfg.js +40 -41
  148. package/documentation/wiki-core.js +121 -32
  149. package/documentation/wiki-create-linting-rules.d.ts +6 -0
  150. package/documentation/wiki-create-linting-rules.js +95 -0
  151. package/documentation/wiki-dataflow-graph.js +112 -77
  152. package/documentation/wiki-engine.js +1 -2
  153. package/documentation/wiki-faq.d.ts +2 -1
  154. package/documentation/wiki-faq.js +4 -4
  155. package/documentation/wiki-interface.js +22 -8
  156. package/documentation/wiki-linter.d.ts +1 -1
  157. package/documentation/wiki-linter.js +16 -6
  158. package/documentation/wiki-linting-and-testing.js +2 -2
  159. package/documentation/wiki-mk/doc-context.d.ts +3 -3
  160. package/documentation/wiki-mk/doc-maker.d.ts +2 -0
  161. package/documentation/wiki-mk/doc-maker.js +7 -1
  162. package/documentation/wiki-normalized-ast.js +5 -5
  163. package/documentation/wiki-onboarding.d.ts +2 -1
  164. package/documentation/wiki-onboarding.js +5 -5
  165. package/documentation/wiki-overview.js +4 -17
  166. package/documentation/wiki-package-database.d.ts +9 -0
  167. package/documentation/wiki-package-database.js +63 -0
  168. package/documentation/wiki-query.js +86 -84
  169. package/documentation/wiki-search.js +4 -5
  170. package/documentation/wiki-setup.js +6 -7
  171. package/gas.d.ts +74 -0
  172. package/gas.js +18 -0
  173. package/linter/linter-executor.js +2 -8
  174. package/linter/linter-format.d.ts +4 -11
  175. package/linter/linter-rules.d.ts +111 -86
  176. package/linter/linter-rules.js +9 -1
  177. package/linter/rules/absolute-path.d.ts +2 -7
  178. package/linter/rules/absolute-path.js +8 -5
  179. package/linter/rules/dataframe-access-validation.d.ts +1 -6
  180. package/linter/rules/dataframe-access-validation.js +8 -6
  181. package/linter/rules/dead-code.d.ts +2 -11
  182. package/linter/rules/dead-code.js +16 -11
  183. package/linter/rules/deprecated-functions.d.ts +3 -3
  184. package/linter/rules/file-path-validity.d.ts +1 -6
  185. package/linter/rules/file-path-validity.js +5 -5
  186. package/linter/rules/function-finder-util.d.ts +7 -11
  187. package/linter/rules/function-finder-util.js +9 -6
  188. package/linter/rules/naming-convention.d.ts +2 -7
  189. package/linter/rules/naming-convention.js +3 -2
  190. package/linter/rules/network-functions.d.ts +2 -7
  191. package/linter/rules/network-functions.js +14 -12
  192. package/linter/rules/no-leaked-credentials.d.ts +36 -0
  193. package/linter/rules/no-leaked-credentials.js +75 -0
  194. package/linter/rules/problematic-inputs.d.ts +1 -8
  195. package/linter/rules/problematic-inputs.js +5 -4
  196. package/linter/rules/roxygen-arguments.d.ts +2 -7
  197. package/linter/rules/roxygen-arguments.js +13 -20
  198. package/linter/rules/seeded-randomness.d.ts +2 -7
  199. package/linter/rules/seeded-randomness.js +7 -4
  200. package/linter/rules/software-has-license.d.ts +31 -0
  201. package/linter/rules/software-has-license.js +46 -0
  202. package/linter/rules/software-has-tests.d.ts +38 -0
  203. package/linter/rules/software-has-tests.js +48 -0
  204. package/linter/rules/stop-with-call-arg.d.ts +2 -7
  205. package/linter/rules/stop-with-call-arg.js +3 -2
  206. package/linter/rules/undefined-symbol.d.ts +39 -0
  207. package/linter/rules/undefined-symbol.js +80 -0
  208. package/linter/rules/unused-definition.d.ts +3 -8
  209. package/linter/rules/unused-definition.js +7 -5
  210. package/linter/rules/useless-loop.d.ts +2 -7
  211. package/linter/rules/useless-loop.js +5 -2
  212. package/package.json +5 -5
  213. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  214. package/project/cache/flowr-analyzer-cache.js +9 -1
  215. package/project/context/flowr-analyzer-context.d.ts +13 -14
  216. package/project/context/flowr-analyzer-context.js +4 -0
  217. package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
  218. package/project/context/flowr-analyzer-dependencies-context.js +36 -4
  219. package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
  220. package/project/context/flowr-analyzer-environment-context.js +3 -4
  221. package/project/context/flowr-analyzer-files-context.d.ts +13 -0
  222. package/project/context/flowr-analyzer-files-context.js +12 -2
  223. package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
  224. package/project/context/flowr-analyzer-gas-context.js +101 -0
  225. package/project/context/flowr-file.d.ts +2 -0
  226. package/project/context/flowr-file.js +2 -0
  227. package/project/flowr-analyzer-builder.js +3 -0
  228. package/project/flowr-analyzer.d.ts +2 -1
  229. package/project/flowr-analyzer.js +3 -1
  230. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
  231. package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
  232. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
  233. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
  234. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
  235. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
  236. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  237. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
  238. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
  239. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
  240. package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
  241. package/project/plugins/flowr-analyzer-plugin.js +14 -7
  242. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
  243. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
  244. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
  245. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
  246. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
  247. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
  248. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  249. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
  250. package/project/plugins/package-version-plugins/package.d.ts +3 -0
  251. package/project/plugins/package-version-plugins/package.js +12 -0
  252. package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
  253. package/project/plugins/package-version-plugins/pkgdb.js +370 -0
  254. package/project/plugins/plugin-registry.d.ts +5 -1
  255. package/project/plugins/plugin-registry.js +10 -1
  256. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
  257. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
  258. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
  259. package/queries/catalog/call-context-query/call-context-query-executor.js +62 -8
  260. package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -2
  261. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  262. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
  263. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
  264. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
  265. package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
  266. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
  267. package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
  268. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
  269. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
  270. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  271. package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
  272. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
  273. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  274. package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
  275. package/queries/catalog/dice-query/dice-query-executor.js +52 -0
  276. package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
  277. package/queries/catalog/dice-query/dice-query-format.js +102 -0
  278. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  279. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
  280. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
  281. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
  282. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
  283. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
  284. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
  285. package/queries/catalog/linter-query/linter-query-executor.js +8 -0
  286. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
  287. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  288. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  289. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  290. package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
  291. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  292. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
  293. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  294. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  295. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  296. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  297. package/queries/query.d.ts +18 -1
  298. package/queries/query.js +3 -1
  299. package/r-bridge/data/data.d.ts +7 -2
  300. package/r-bridge/data/data.js +8 -2
  301. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
  302. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
  303. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  304. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
  305. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  306. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
  307. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
  308. package/r-bridge/parser.js +2 -9
  309. package/r-bridge/shell.d.ts +8 -1
  310. package/r-bridge/shell.js +26 -7
  311. package/search/flowr-search-builder.d.ts +2 -2
  312. package/search/flowr-search-builder.js +1 -1
  313. package/search/flowr-search-filters.d.ts +30 -9
  314. package/search/flowr-search-filters.js +26 -21
  315. package/search/search-executor/search-enrichers.d.ts +601 -1
  316. package/search/search-executor/search-enrichers.js +30 -6
  317. package/slicing/static/static-slicer.d.ts +39 -11
  318. package/slicing/static/static-slicer.js +44 -14
  319. package/util/collections/queue.d.ts +16 -0
  320. package/util/collections/queue.js +38 -0
  321. package/util/log.d.ts +1 -1
  322. package/util/log.js +1 -1
  323. package/util/mermaid/dfg.d.ts +2 -2
  324. package/util/mermaid/dfg.js +2 -2
  325. package/util/mermaid/mermaid.d.ts +4 -0
  326. package/util/mermaid/mermaid.js +8 -1
  327. package/util/objects.d.ts +9 -0
  328. package/util/objects.js +54 -0
  329. package/util/proc.d.ts +6 -0
  330. package/util/proc.js +20 -0
  331. package/util/version.js +10 -2
  332. package/cli/common/features.d.ts +0 -9
  333. package/cli/common/features.js +0 -35
  334. package/cli/script-core/statistics-core.d.ts +0 -6
  335. package/cli/script-core/statistics-core.js +0 -103
  336. package/cli/script-core/statistics-helper-core.d.ts +0 -6
  337. package/cli/script-core/statistics-helper-core.js +0 -85
  338. package/cli/statistics-app.d.ts +0 -11
  339. package/cli/statistics-app.js +0 -16
  340. package/cli/statistics-helper-app.d.ts +0 -11
  341. package/cli/statistics-helper-app.js +0 -14
  342. package/statistics/features/common-syntax-probability.d.ts +0 -38
  343. package/statistics/features/common-syntax-probability.js +0 -169
  344. package/statistics/features/feature.d.ts +0 -179
  345. package/statistics/features/feature.js +0 -38
  346. package/statistics/features/post-processing.d.ts +0 -18
  347. package/statistics/features/post-processing.js +0 -26
  348. package/statistics/features/supported/assignments/assignments.d.ts +0 -12
  349. package/statistics/features/supported/assignments/assignments.js +0 -56
  350. package/statistics/features/supported/assignments/post-process.d.ts +0 -6
  351. package/statistics/features/supported/assignments/post-process.js +0 -126
  352. package/statistics/features/supported/comments/comments.d.ts +0 -18
  353. package/statistics/features/supported/comments/comments.js +0 -143
  354. package/statistics/features/supported/comments/post-process.d.ts +0 -6
  355. package/statistics/features/supported/comments/post-process.js +0 -51
  356. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  357. package/statistics/features/supported/control-flow/control-flow.js +0 -69
  358. package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
  359. package/statistics/features/supported/control-flow/post-process.js +0 -66
  360. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  361. package/statistics/features/supported/data-access/data-access.js +0 -122
  362. package/statistics/features/supported/data-access/post-process.d.ts +0 -6
  363. package/statistics/features/supported/data-access/post-process.js +0 -108
  364. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
  365. package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
  366. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  367. package/statistics/features/supported/defined-functions/post-process.js +0 -168
  368. package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
  369. package/statistics/features/supported/expression-list/post-process.js +0 -45
  370. package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
  371. package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
  372. package/statistics/features/supported/loops/loops.d.ts +0 -20
  373. package/statistics/features/supported/loops/loops.js +0 -81
  374. package/statistics/features/supported/loops/post-process.d.ts +0 -6
  375. package/statistics/features/supported/loops/post-process.js +0 -73
  376. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  377. package/statistics/features/supported/used-functions/post-process.js +0 -176
  378. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  379. package/statistics/features/supported/used-functions/used-functions.js +0 -99
  380. package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
  381. package/statistics/features/supported/used-packages/post-process.js +0 -122
  382. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  383. package/statistics/features/supported/used-packages/used-packages.js +0 -140
  384. package/statistics/features/supported/values/post-process.d.ts +0 -6
  385. package/statistics/features/supported/values/post-process.js +0 -73
  386. package/statistics/features/supported/values/values.d.ts +0 -14
  387. package/statistics/features/supported/values/values.js +0 -111
  388. package/statistics/features/supported/variables/post-process.d.ts +0 -15
  389. package/statistics/features/supported/variables/post-process.js +0 -126
  390. package/statistics/features/supported/variables/variables.d.ts +0 -15
  391. package/statistics/features/supported/variables/variables.js +0 -62
  392. package/statistics/meta-statistics.d.ts +0 -32
  393. package/statistics/meta-statistics.js +0 -16
  394. package/statistics/output/file-provider.d.ts +0 -36
  395. package/statistics/output/file-provider.js +0 -96
  396. package/statistics/output/print-stats.d.ts +0 -29
  397. package/statistics/output/print-stats.js +0 -81
  398. package/statistics/output/statistics-file.d.ts +0 -36
  399. package/statistics/output/statistics-file.js +0 -68
  400. package/statistics/statistics.d.ts +0 -29
  401. package/statistics/statistics.js +0 -108
  402. package/statistics/summarizer/auto-detect.d.ts +0 -5
  403. package/statistics/summarizer/auto-detect.js +0 -34
  404. package/statistics/summarizer/first-phase/process.d.ts +0 -6
  405. package/statistics/summarizer/first-phase/process.js +0 -81
  406. package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
  407. package/statistics/summarizer/post-process/clusterer.js +0 -40
  408. package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
  409. package/statistics/summarizer/post-process/file-based-count.js +0 -47
  410. package/statistics/summarizer/post-process/histogram.d.ts +0 -57
  411. package/statistics/summarizer/post-process/histogram.js +0 -126
  412. package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
  413. package/statistics/summarizer/post-process/post-process-output.js +0 -102
  414. package/statistics/summarizer/second-phase/process.d.ts +0 -15
  415. package/statistics/summarizer/second-phase/process.js +0 -118
  416. package/statistics/summarizer/summarizer.d.ts +0 -34
  417. package/statistics/summarizer/summarizer.js +0 -141
@@ -26,6 +26,7 @@ const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
26
26
  const r_value_1 = require("../../../../../eval/values/r-value");
27
27
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
28
28
  const built_in_new_env_1 = require("./built-in-new-env");
29
+ const built_in_stack_env_1 = require("./built-in-stack-env");
29
30
  function toReplacementSymbol(target, prefix, superAssignment) {
30
31
  return {
31
32
  type: type_1.RType.Symbol,
@@ -357,6 +358,19 @@ function tryRouteToCustomEnv(name, args, rootId, data, config) {
357
358
  if (!resolution) {
358
359
  return undefined;
359
360
  }
361
+ if (resolution.isStackEnv) {
362
+ /* real stack env, not a private snapshot. Route a global write as a super-assignment so it reaches global scope from inside a function. */
363
+ if (resolution.envirData.environment.current.globalEnv !== true) {
364
+ return undefined;
365
+ }
366
+ const globalResult = processAssignment(name, args, rootId, data, {
367
+ ...config,
368
+ environmentArg: undefined, // prevent re-entry
369
+ superAssignment: true
370
+ });
371
+ globalResult.graph.addEdge(rootId, resolution.envirNodeId, edge_1.EdgeType.Reads);
372
+ return globalResult;
373
+ }
360
374
  /* run the normal assignment path to get the correct graph structure */
361
375
  const normalResult = processAssignment(name, args, rootId, data, {
362
376
  ...config,
@@ -414,9 +428,14 @@ function processAssignmentToSymbol(config) {
414
428
  if (data.ctx.config.solver.trackEnvironments) {
415
429
  let envState;
416
430
  let returnsEnvState;
431
+ const stackEnv = (0, built_in_stack_env_1.stackEnvStateFromSource)(sourceArg, data);
417
432
  if (isEnvCreatorSource(sourceArg)) {
418
433
  envState = (0, built_in_new_env_1.createFreshEnvState)(data, sourceArg);
419
434
  }
435
+ else if (stackEnv !== undefined) {
436
+ // globalenv()/baseenv()/emptyenv(): assigned variable points into that search-path stack env
437
+ envState = stackEnv;
438
+ }
420
439
  else if (source.type === type_1.RType.Symbol) {
421
440
  const defs = (0, resolve_by_name_1.resolveByName)(source.content, data.environment, identifier_1.ReferenceType.Variable);
422
441
  const def = defs?.find((d) => d.envState !== undefined);
@@ -4,12 +4,5 @@ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
4
4
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
5
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
6
  import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
- /**
8
- * Processes `attach(what, ...)` - when `what` is a variable that holds a tracked
9
- * {@link InGraphIdentifierDefinition#envState}, all statically-known definitions from
10
- * that environment are injected into a new scope layer inserted *between* the current
11
- * scope and its parent. This mirrors R's behaviour: `attach` adds to the search path
12
- * below `.GlobalEnv`, so existing global bindings take precedence, but after a
13
- * `rm(name)` removes a global shadow the attached binding becomes visible again.
14
- */
7
+ /** Processes `attach(what, ...)`, injecting the tracked env's known definitions into a new scope layer below `.GlobalEnv`. */
15
8
  export declare function processAttach<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -11,14 +11,7 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
11
11
  const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
12
12
  const edge_1 = require("../../../../../graph/edge");
13
13
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
14
- /**
15
- * Processes `attach(what, ...)` - when `what` is a variable that holds a tracked
16
- * {@link InGraphIdentifierDefinition#envState}, all statically-known definitions from
17
- * that environment are injected into a new scope layer inserted *between* the current
18
- * scope and its parent. This mirrors R's behaviour: `attach` adds to the search path
19
- * below `.GlobalEnv`, so existing global bindings take precedence, but after a
20
- * `rm(name)` removes a global shadow the attached binding becomes visible again.
21
- */
14
+ /** Processes `attach(what, ...)`, injecting the tracked env's known definitions into a new scope layer below `.GlobalEnv`. */
22
15
  function processAttach(name, args, rootId, data) {
23
16
  const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Attach }).information;
24
17
  const whatArg = args.length >= 1 ? args[0] : undefined;
@@ -33,7 +26,7 @@ function processAttach(name, args, rootId, data) {
33
26
  return result;
34
27
  }
35
28
  /* build the attached layer with the env's known bindings */
36
- let attachedLayer = new environment_1.Environment(result.environment.current.parent);
29
+ let attachedLayer = new environment_1.Environment(result.environment.current);
37
30
  for (const [varName, varDefs] of envirResolution.envDef.envState.current.memory) {
38
31
  for (const varDef of varDefs) {
39
32
  const inDef = varDef;
@@ -46,9 +39,10 @@ function processAttach(name, args, rootId, data) {
46
39
  result.graph.addEdge(inDef.nodeId, rootId, edge_1.EdgeType.Reads);
47
40
  }
48
41
  }
49
- /* splice the attached layer between the current scope and its original parent */
50
- const newCurrent = result.environment.current.clone(false);
51
- newCurrent.parent = attachedLayer;
52
- return { ...result, environment: { current: newCurrent, level: result.environment.level } };
42
+ /* R attaches below `.GlobalEnv`, so existing global bindings shadow the attached ones */
43
+ return { ...result, environment: {
44
+ current: environment_1.REnvironment.attachBelowGlobal(result.environment.current, attachedLayer, attachedLayer),
45
+ level: result.environment.level
46
+ } };
53
47
  }
54
48
  //# sourceMappingURL=built-in-attach.js.map
@@ -1,13 +1,4 @@
1
- /**
2
- * Shared utilities for built-in functions that interact with tracked R environments.
3
- *
4
- * - {@link bindArgs} - bind call arguments to formal parameter names using R's matching rules.
5
- * - {@link resolveArgToEnvir} - resolve a single already-found argument to an {@link EnvirResolution}.
6
- * - {@link resolveEnvirArg} / {@link resolveSymbolToEnvir} - resolve a named argument or
7
- * symbol to an {@link EnvirResolution} when it holds a tracked {@link InGraphIdentifierDefinition#envState}.
8
- * - {@link routeWrittenToCustomEnv} - move written definitions from the caller's scope into
9
- * the holder variable's `envState` after processing an expression that writes into a custom env.
10
- */
1
+ /** Shared utilities for built-in functions that interact with tracked R environments. */
11
2
  import type { DataflowProcessorInformation } from '../../../../../processor';
12
3
  import type { DataflowInformation } from '../../../../../info';
13
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -25,51 +16,21 @@ export interface EnvirResolution<OtherInfo> {
25
16
  };
26
17
  /** Node ID of the USE of the envir variable (e.g. the `e` in `envir=e`). */
27
18
  readonly envirNodeId: NodeId;
19
+ /** `true` when this resolves to a real stack environment (`globalenv()`/`.GlobalEnv`), not a tracked custom env. */
20
+ readonly isStackEnv?: boolean;
28
21
  }
29
22
  /**
30
- * Binds call arguments to formal parameter names following R's standard matching rules:
31
- * 1. Exact name matches (named args bound to exact-matching formal params).
32
- * 2. Partial (pmatch) name matches via {@link findByPrefixIfUnique}.
33
- * 3. Remaining unnamed args fill remaining unbound formal params left-to-right.
34
- *
35
- * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous
36
- * prefixes are rejected correctly. Use this when multiple formals must be found
37
- * simultaneously so that named-arg binding is consistent across all formals.
23
+ * Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
24
+ * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
38
25
  */
39
26
  export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], paramNames: readonly string[]): ReadonlyMap<string, PotentiallyEmptyRArgument<OtherInfo & ParentInformation>>;
40
- /**
41
- * Resolves a single already-found argument (e.g. from {@link bindArgs}) to an
42
- * {@link EnvirResolution} when the argument is a symbol that holds a tracked envState.
43
- * Returns `undefined` when the arg is empty, non-symbolic, or unresolved.
44
- */
27
+ /** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
45
28
  export declare function resolveArgToEnvir<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
46
- /**
47
- * Scans `args` for an argument named `argName` (default `'envir'`), or - when
48
- * `positionalFallbackIndex` is given - for the arg at that positional index when
49
- * no named match is found. When the resolved argument is a symbol that resolves
50
- * to a variable with a tracked {@link InGraphIdentifierDefinition#envState},
51
- * returns the resolved context; otherwise returns `undefined`.
52
- *
53
- * Named matching uses pmatch semantics: pass `allParamNames` (the full formal parameter
54
- * list) so ambiguous prefixes are rejected. Defaults to `[argName]`, which allows
55
- * prefix matches for `argName` only.
56
- *
57
- * When multiple formals must be matched simultaneously (e.g. `data` and `expr` in `with`),
58
- * use {@link bindArgs} + {@link resolveArgToEnvir} instead so named binding is consistent.
59
- */
29
+ /** Resolves the `argName` argument (default `'envir'`, pmatch against `allParamNames`), falling back to `positionalFallbackIndex`, to an {@link EnvirResolution}. */
60
30
  export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string, positionalFallbackIndex?: number, allParamNames?: readonly string[]): EnvirResolution<OtherInfo> | undefined;
61
- /**
62
- * Resolves a symbol by name to an {@link EnvirResolution} when the symbol holds a tracked
63
- * environment. Handles multiple reaching definitions (e.g. from if/else branches) by
64
- * merging their envStates - see {@link resolveDefsToEnvirResolution}.
65
- * Returns `undefined` when the name cannot be resolved or none of its definitions carry an envState.
66
- */
31
+ /** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
67
32
  export declare function resolveSymbolToEnvir<OtherInfo>(symbolName: Identifier, nodeId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
68
- /**
69
- * After processing an expression that writes into a custom environment, moves the
70
- * written definitions from the caller's scope into `envDef`'s tracked `envState`
71
- * and re-defines the holder variable in the returned environment.
72
- */
33
+ /** Moves definitions written into a custom environment from the caller's scope into `envDef`'s tracked `envState`, re-defining the holder variable. */
73
34
  export declare function routeWrittenToCustomEnv(result: DataflowInformation, envDef: NamedInGraphIdentifierDefinition & {
74
35
  envState: REnvironmentInformation;
75
36
  }, newDefAt: NodeId, definedAt?: NodeId): DataflowInformation;
@@ -12,14 +12,12 @@ const resolve_by_name_1 = require("../../../../../environments/resolve-by-name")
12
12
  const identifier_1 = require("../../../../../environments/identifier");
13
13
  const define_1 = require("../../../../../environments/define");
14
14
  const prefix_1 = require("../../../../../../util/prefix");
15
- /**
16
- * Core resolver: maps a list of identifier definitions (from {@link resolveByName}) to an
17
- * {@link EnvirResolution}. Accepts `undefined` so callers can pass `resolveByName` results
18
- * directly without an intermediate null check.
19
- *
20
- * Multiple reaching definitions (e.g. from if/else branches) are accepted only when every
21
- * definition carries an envState; their envStates are merged into a single combined snapshot.
22
- */
15
+ const built_in_stack_env_1 = require("./built-in-stack-env");
16
+ /** A tracked env is a real stack environment (not a private custom env) when its current layer is the global or the built-in/base env. */
17
+ function isStackEnvState(envState) {
18
+ return envState.current.globalEnv === true || envState.current.builtInEnv === true;
19
+ }
20
+ /** Maps a list of identifier definitions (from {@link resolveByName}) to an {@link EnvirResolution}, merging the envStates of multiple reaching definitions. */
23
21
  function resolveDefsToEnvirResolution(defs, nodeId, data) {
24
22
  if (!defs || defs.length === 0) {
25
23
  return undefined;
@@ -31,7 +29,7 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
31
29
  return undefined;
32
30
  }
33
31
  const envDef = inDefs[0];
34
- return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId };
32
+ return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, isStackEnv: isStackEnvState(envState) };
35
33
  }
36
34
  if (!inDefs.every(d => d.envState !== undefined)) {
37
35
  return undefined;
@@ -54,14 +52,8 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
54
52
  return { envirData: { ...data, environment: mergedEnvState }, envDef, envirNodeId: nodeId };
55
53
  }
56
54
  /**
57
- * Binds call arguments to formal parameter names following R's standard matching rules:
58
- * 1. Exact name matches (named args bound to exact-matching formal params).
59
- * 2. Partial (pmatch) name matches via {@link findByPrefixIfUnique}.
60
- * 3. Remaining unnamed args fill remaining unbound formal params left-to-right.
61
- *
62
- * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous
63
- * prefixes are rejected correctly. Use this when multiple formals must be found
64
- * simultaneously so that named-arg binding is consistent across all formals.
55
+ * Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
56
+ * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
65
57
  */
66
58
  function bindArgs(args, paramNames) {
67
59
  const bound = new Map();
@@ -114,35 +106,35 @@ function bindArgs(args, paramNames) {
114
106
  }
115
107
  return bound;
116
108
  }
117
- /**
118
- * Resolves a single already-found argument (e.g. from {@link bindArgs}) to an
119
- * {@link EnvirResolution} when the argument is a symbol that holds a tracked envState.
120
- * Returns `undefined` when the arg is empty, non-symbolic, or unresolved.
121
- */
109
+ /** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
122
110
  function resolveArgToEnvir(arg, data) {
123
111
  if (arg === r_function_call_1.EmptyArgument) {
124
112
  return undefined;
125
113
  }
126
114
  const node = (0, unpack_argument_1.unpackArg)(arg);
115
+ // `.GlobalEnv`/`.BaseEnv` or a `globalenv()`/`baseenv()`/`emptyenv()` call resolves to the corresponding stack env
116
+ const stackEnv = (0, built_in_stack_env_1.resolveNodeToStackEnv)(node, data);
117
+ if (stackEnv !== undefined && node !== undefined) {
118
+ return stackEnvirResolution(stackEnv, node.info.id, node.lexeme ?? '', data);
119
+ }
127
120
  if (node?.type !== type_1.RType.Symbol) {
128
121
  return undefined;
129
122
  }
130
123
  return resolveDefsToEnvirResolution((0, resolve_by_name_1.resolveByName)(node.content, data.environment, identifier_1.ReferenceType.Variable), node.info.id, data);
131
124
  }
132
- /**
133
- * Scans `args` for an argument named `argName` (default `'envir'`), or - when
134
- * `positionalFallbackIndex` is given - for the arg at that positional index when
135
- * no named match is found. When the resolved argument is a symbol that resolves
136
- * to a variable with a tracked {@link InGraphIdentifierDefinition#envState},
137
- * returns the resolved context; otherwise returns `undefined`.
138
- *
139
- * Named matching uses pmatch semantics: pass `allParamNames` (the full formal parameter
140
- * list) so ambiguous prefixes are rejected. Defaults to `[argName]`, which allows
141
- * prefix matches for `argName` only.
142
- *
143
- * When multiple formals must be matched simultaneously (e.g. `data` and `expr` in `with`),
144
- * use {@link bindArgs} + {@link resolveArgToEnvir} instead so named binding is consistent.
145
- */
125
+ /** Builds an {@link EnvirResolution} for an environment obtained directly (not via a holder variable), e.g. `globalenv()` / `.GlobalEnv`. */
126
+ function stackEnvirResolution(envState, nodeId, lexeme, data) {
127
+ // no holder variable: envDef is only a carrier for envState/nodeId
128
+ const envDef = {
129
+ name: lexeme,
130
+ nodeId,
131
+ type: identifier_1.ReferenceType.Variable,
132
+ definedAt: nodeId,
133
+ envState,
134
+ };
135
+ return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, isStackEnv: true };
136
+ }
137
+ /** Resolves the `argName` argument (default `'envir'`, pmatch against `allParamNames`), falling back to `positionalFallbackIndex`, to an {@link EnvirResolution}. */
146
138
  function resolveEnvirArg(args, data, argName = 'envir', positionalFallbackIndex, allParamNames = [argName]) {
147
139
  /* named pass: pmatch against the full parameter list */
148
140
  for (const arg of args) {
@@ -168,20 +160,11 @@ function resolveEnvirArg(args, data, argName = 'envir', positionalFallbackIndex,
168
160
  }
169
161
  return undefined;
170
162
  }
171
- /**
172
- * Resolves a symbol by name to an {@link EnvirResolution} when the symbol holds a tracked
173
- * environment. Handles multiple reaching definitions (e.g. from if/else branches) by
174
- * merging their envStates - see {@link resolveDefsToEnvirResolution}.
175
- * Returns `undefined` when the name cannot be resolved or none of its definitions carry an envState.
176
- */
163
+ /** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
177
164
  function resolveSymbolToEnvir(symbolName, nodeId, data) {
178
165
  return resolveDefsToEnvirResolution((0, resolve_by_name_1.resolveByName)(symbolName, data.environment, identifier_1.ReferenceType.Variable), nodeId, data);
179
166
  }
180
- /**
181
- * After processing an expression that writes into a custom environment, moves the
182
- * written definitions from the caller's scope into `envDef`'s tracked `envState`
183
- * and re-defines the holder variable in the returned environment.
184
- */
167
+ /** Moves definitions written into a custom environment from the caller's scope into `envDef`'s tracked `envState`, re-defining the holder variable. */
185
168
  function routeWrittenToCustomEnv(result, envDef, newDefAt, definedAt) {
186
169
  const written = result.out.filter((d) => d.name !== undefined && 'definedAt' in d &&
187
170
  (definedAt === undefined || d.definedAt === definedAt));
@@ -18,6 +18,7 @@ const overwrite_1 = require("../../../../../environments/overwrite");
18
18
  const logger_1 = require("../../../../../logger");
19
19
  const log_1 = require("../../../../../../util/log");
20
20
  const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
21
+ const apply_kill_1 = require("../../../../../environments/apply-kill");
21
22
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
22
23
  const general_1 = require("../../../../../eval/values/general");
23
24
  function linkReadNameToWriteIfPossible(read, environments, listEnvironments, remainingRead, nextGraph) {
@@ -75,6 +76,10 @@ function updateSideEffectsForCalledFunctions(calledEnvs, inputEnvironment, nextG
75
76
  let current = environment.current;
76
77
  let hasUpdate = false;
77
78
  while (!current?.builtInEnv) {
79
+ // a package attached inside the body (library()) must propagate to the caller, like R attaching globally
80
+ if (current.t !== undefined) {
81
+ hasUpdate = true;
82
+ }
78
83
  for (const definitions of current.memory.values()) {
79
84
  for (const def of definitions) {
80
85
  if (!node_id_1.NodeId.isBuiltIn(def.definedAt)) {
@@ -115,6 +120,8 @@ function processExpressionList(name, args, rootId, data) {
115
120
  const remainingRead = new Map();
116
121
  const nextGraph = new graph_1.DataflowGraph(data.completeAst.idMap);
117
122
  const out = [];
123
+ /* lazily created - `rm` is rare, so rm-free lists never allocate this */
124
+ let killed;
118
125
  const exitPoints = [];
119
126
  const activeCdsAtStart = data.cds;
120
127
  const invertExitCds = [];
@@ -158,6 +165,15 @@ function processExpressionList(name, args, rootId, data) {
158
165
  environment = exitPoints.length > 0 ? (0, overwrite_1.overwriteEnvironment)(environment, processed.environment) : processed.environment;
159
166
  // if the called function has global redefinitions, we have to keep them within our environment
160
167
  environment = updateSideEffectsForCalledFunctions(calledEnvs, environment, nextGraph, processed.out);
168
+ // removals are already reflected in the threaded environment; we only bubble them (net of later writes)
169
+ if (killed && processed.out.length > 0) {
170
+ killed = (0, apply_kill_1.cancelRevivedKills)(killed, processed.out);
171
+ }
172
+ if (processed.kill?.length) {
173
+ // if we may have already exited (break/next), the removal only happens maybe
174
+ const kills = exitPoints.length > 0 ? (0, apply_kill_1.makeKillsMaybe)(processed.kill, invertExitCds) : processed.kill;
175
+ (killed ??= []).push(...kills);
176
+ }
161
177
  for (const { nodeId } of processed.out) {
162
178
  listEnvironments.add(nodeId);
163
179
  }
@@ -216,6 +232,7 @@ function processExpressionList(name, args, rootId, data) {
216
232
  entryPoint: meId,
217
233
  exitPoints: exitPoints,
218
234
  hooks: processedExpressions.flatMap(p => p?.hooks ?? []),
235
+ kill: killed,
219
236
  };
220
237
  }
221
238
  //# sourceMappingURL=built-in-expression-list.js.map
@@ -15,6 +15,7 @@ const append_1 = require("../../../../../environments/append");
15
15
  const edge_1 = require("../../../../../graph/edge");
16
16
  const identifier_1 = require("../../../../../environments/identifier");
17
17
  const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
18
+ const apply_kill_1 = require("../../../../../environments/apply-kill");
18
19
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
19
20
  /**
20
21
  * Processes a for-loop call: `for(<variable> in <vector>) <body>`
@@ -64,7 +65,7 @@ function processForLoop(name, args, rootId, data) {
64
65
  }
65
66
  (0, reference_to_maybe_1.applyCdToReferences)(body.out, cd);
66
67
  const outgoing = variable.out.concat(writtenVariable, body.out);
67
- (0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out);
68
+ (0, linker_1.linkCircularRedefinitionsWithinALoop)(nextGraph, nameIdShares, body.out, body.environment);
68
69
  (0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences), nextGraph);
69
70
  (0, common_1.patchFunctionCall)({
70
71
  nextGraph,
@@ -78,6 +79,9 @@ function processForLoop(name, args, rootId, data) {
78
79
  nextGraph.addEdge(rootId, body.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
79
80
  // as the for-loop always evaluates its condition
80
81
  nextGraph.addEdge(name.info.id, vector.entryPoint, edge_1.EdgeType.Reads);
82
+ // the body may never execute, so a removal within it only happens maybe; apply it as the merge cannot represent it
83
+ const loopKill = body.kill?.length ? (0, apply_kill_1.makeKillsMaybe)(body.kill, cd) : undefined;
84
+ const loopEnvironment = (0, append_1.appendEnvironment)(origEnv, outEnvironment);
81
85
  return {
82
86
  unknownReferences: [],
83
87
  // we only want those not bound by a local variable
@@ -87,8 +91,9 @@ function processForLoop(name, args, rootId, data) {
87
91
  entryPoint: name.info.id,
88
92
  exitPoints: (0, info_1.filterOutLoopExitPoints)(body.exitPoints),
89
93
  // if we can not be sure that the for-loop runs once, we have to merge back the original environment, as the body may never execute
90
- environment: (0, append_1.appendEnvironment)(origEnv, outEnvironment),
94
+ environment: loopKill ? (0, apply_kill_1.applyKills)(loopEnvironment, loopKill) : loopEnvironment,
91
95
  hooks: variable.hooks.concat(vector.hooks, body.hooks),
96
+ kill: loopKill,
92
97
  };
93
98
  }
94
99
  //# sourceMappingURL=built-in-for-loop.js.map
@@ -6,7 +6,7 @@ import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-
6
6
  import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import { DataflowGraph } from '../../../../../graph/graph';
8
8
  import { type REnvironmentInformation } from '../../../../../environments/environment';
9
- import type { ReadOnlyFlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
9
+ import type { ReadOnlyFlowrAnalyzerContext, FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
10
10
  /**
11
11
  * Process a function definition, i.e., `function(a, b) { ... }`
12
12
  */
@@ -24,4 +24,4 @@ export declare function retrieveActiveEnvironment(callerEnvironment: REnvironmen
24
24
  * @param graph - dataflow graph to collect the function calls from and to update the closure links for
25
25
  * @param outEnvironment - active environment on resolving closures (i.e., exit of the function definition)
26
26
  */
27
- export declare function updateNestedFunctionCalls(graph: DataflowGraph, outEnvironment: REnvironmentInformation): void;
27
+ export declare function updateNestedFunctionCalls(graph: DataflowGraph, outEnvironment: REnvironmentInformation, ctx: FlowrAnalyzerContext): void;
@@ -21,6 +21,7 @@ const scoping_1 = require("../../../../../environments/scoping");
21
21
  const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
22
22
  const edge_1 = require("../../../../../graph/edge");
23
23
  const log_1 = require("../../../../../../util/log");
24
+ const built_in_library_1 = require("./built-in-library");
24
25
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
25
26
  const hooks_1 = require("../../../../../hooks");
26
27
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
@@ -55,6 +56,42 @@ function processFunctionDefinition(name, args, rootId, data) {
55
56
  }
56
57
  const paramsEnvironments = data.environment;
57
58
  const body = (0, processor_1.processDataflowFor)(bodyArg, data);
59
+ for (const [, v] of body.graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
60
+ if (!v.origin.includes(built_in_proc_name_1.BuiltInProcName.Rm)) {
61
+ continue;
62
+ }
63
+ const ea = v.args.find(a => a !== r_function_call_1.EmptyArgument && graph_1.FunctionArgument.isNamed(a) && a.name === 'envir');
64
+ if (!ea || !graph_1.FunctionArgument.isNamed(ea)) {
65
+ continue;
66
+ }
67
+ const offset = parseSysFrameOffset(data.completeAst.idMap.get(ea.valueId ?? ea.nodeId));
68
+ if (offset === undefined || offset > 0) {
69
+ continue;
70
+ }
71
+ const names = [];
72
+ for (const a of v.args) {
73
+ if (a === r_function_call_1.EmptyArgument || (graph_1.FunctionArgument.isNamed(a) && a.name === 'envir')) {
74
+ continue;
75
+ }
76
+ const node = data.completeAst.idMap.get(graph_1.FunctionArgument.isNamed(a) ? (a.valueId ?? a.nodeId) : a.nodeId);
77
+ if (node?.type === type_1.RType.String) {
78
+ names.push(node.content.str);
79
+ }
80
+ else if (node?.type === type_1.RType.Symbol) {
81
+ names.push(node.content);
82
+ }
83
+ }
84
+ const targetLevel = offset === 0 ? 0 : originalEnvironment.level + 1 + offset;
85
+ let targetEnv = originalEnvironment;
86
+ while (targetEnv.level > targetLevel && targetEnv.level > 0) {
87
+ targetEnv = (0, scoping_1.popLocalEnvironment)(targetEnv);
88
+ }
89
+ if (targetEnv.level === targetLevel) {
90
+ for (const n of names) {
91
+ targetEnv.current.remove(n);
92
+ }
93
+ }
94
+ }
58
95
  // As we know, parameters cannot technically duplicate (i.e., their names are unique), we overwrite their environments.
59
96
  // This is the correct behavior, even if someone uses non-`=` arguments in functions.
60
97
  const bodyEnvironment = body.environment;
@@ -283,7 +320,7 @@ function linkSuperAssignmentsToOuterDefinitions(parentGraph, nestedGraphNodeIds,
283
320
  * @param graph - dataflow graph to collect the function calls from and to update the closure links for
284
321
  * @param outEnvironment - active environment on resolving closures (i.e., exit of the function definition)
285
322
  */
286
- function updateNestedFunctionCalls(graph, outEnvironment) {
323
+ function updateNestedFunctionCalls(graph, outEnvironment, ctx) {
287
324
  // track *all* function definitions - including those nested within the current graph,
288
325
  // try to resolve their 'in' by only using the lowest scope which will be popped after this definition
289
326
  for (const [id, { onlyBuiltin, environment, name, args, origin }] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
@@ -296,6 +333,12 @@ function updateNestedFunctionCalls(graph, outEnvironment) {
296
333
  const treatAsS3 = origin.includes(built_in_proc_name_1.BuiltInProcName.S3Dispatch);
297
334
  for (const target of targets) {
298
335
  if (node_id_1.NodeId.isBuiltIn(target)) {
336
+ // a package export resolved lazily here (nested), so materialize it and link to its loader
337
+ const loader = (0, resolve_by_name_1.resolveByName)(name, effectiveEnvironment, identifier_1.ReferenceType.Function)?.find(r => r.nodeId === target)?.definedAt;
338
+ if (loader !== undefined && !node_id_1.NodeId.isBuiltIn(loader)) {
339
+ (0, built_in_library_1.attachExportVertex)(graph, target, effectiveEnvironment, ctx);
340
+ graph.addEdge(target, loader, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
341
+ }
299
342
  graph.addEdge(id, target, edge_1.EdgeType.Calls);
300
343
  continue;
301
344
  }
@@ -361,6 +404,23 @@ function updateNestedFunctionCalls(graph, outEnvironment) {
361
404
  }
362
405
  }
363
406
  }
407
+ function parseSysFrameOffset(node) {
408
+ if (!node || node.type !== type_1.RType.FunctionCall || !node.named || node.functionName.content !== 'sys.frame' || node.arguments.length !== 1) {
409
+ return undefined;
410
+ }
411
+ const arg = node.arguments[0];
412
+ if (arg === r_function_call_1.EmptyArgument || !arg.value) {
413
+ return undefined;
414
+ }
415
+ const v = arg.value;
416
+ if (v.type === type_1.RType.Number) {
417
+ return v.content.num;
418
+ }
419
+ if (v.type === type_1.RType.UnaryOp && v.operator === '-' && v.operand.type === type_1.RType.Number) {
420
+ return -v.operand.content.num;
421
+ }
422
+ return undefined;
423
+ }
364
424
  function prepareFunctionEnvironment(data, rootId) {
365
425
  let env = data.ctx.env.makeCleanEnv();
366
426
  for (let i = 0; i < data.environment.level + 1 /* add another env */; i++) {
@@ -13,6 +13,7 @@ const identifier_1 = require("../../../../../environments/identifier");
13
13
  const general_1 = require("../../../../../eval/values/general");
14
14
  const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
15
15
  const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
16
+ const apply_kill_1 = require("../../../../../environments/apply-kill");
16
17
  const linker_1 = require("../../../../linker");
17
18
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
18
19
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
@@ -107,6 +108,13 @@ function processIfThenElse(name, args, rootId, data, config) {
107
108
  // we assign all with a maybe marker
108
109
  // we do not merge even if they appear in both branches because the maybe links will refer to different ids
109
110
  const outgoing = cond.out.concat((makeThenMaybe ? (0, reference_to_maybe_1.makeAllMaybe)(then?.out, nextGraph, finalEnvironment, true, cdTrue) : then?.out ?? []), (makeOtherwiseMaybe ? (0, reference_to_maybe_1.makeAllMaybe)(otherwise?.out, nextGraph, finalEnvironment, true, cdFalse) : otherwise?.out ?? []));
111
+ // a branch-local removal only happens maybe; apply it here since the branch-environment merge cannot represent it
112
+ let killed;
113
+ if (then?.kill?.length || otherwise?.kill?.length) {
114
+ killed = (makeThenMaybe ? (0, apply_kill_1.makeKillsMaybe)(then?.kill, cdTrue) : then?.kill ?? [])
115
+ .concat(makeOtherwiseMaybe ? (0, apply_kill_1.makeKillsMaybe)(otherwise?.kill, cdFalse) : otherwise?.kill ?? []);
116
+ finalEnvironment = (0, apply_kill_1.applyKills)(finalEnvironment, killed);
117
+ }
110
118
  (0, common_1.patchFunctionCall)({
111
119
  nextGraph,
112
120
  rootId,
@@ -128,6 +136,7 @@ function processIfThenElse(name, args, rootId, data, config) {
128
136
  environment: finalEnvironment,
129
137
  graph: nextGraph,
130
138
  hooks: cond.hooks.concat(then?.hooks ?? [], otherwise?.hooks ?? []),
139
+ kill: killed,
131
140
  };
132
141
  }
133
142
  //# sourceMappingURL=built-in-if-then-else.js.map
@@ -1,10 +1,44 @@
1
1
  import { type DataflowProcessorInformation } from '../../../../../processor';
2
- import type { DataflowInformation } from '../../../../../info';
2
+ import type { DataflowInformation, ControlDependency } from '../../../../../info';
3
+ import type { DataflowGraph } from '../../../../../graph/graph';
3
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
5
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
6
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
- import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
+ import type { REnvironmentInformation } from '../../../../../environments/environment';
9
+ import type { FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
10
+ import { Package } from '../../../../../../project/plugins/package-version-plugins/package';
11
+ /** Controls how {@link processLibrary} brings a package into scope. */
12
+ export interface LibraryProcessorConfig {
13
+ /** `requireNamespace("pkg")` / `loadNamespace("pkg")`: load without attaching bare names */
14
+ readonly namespaceOnly?: boolean;
15
+ /** the package argument is evaluated, not taken as a symbol (`requireNamespace`/`loadNamespace`/`attachNamespace`, unlike `library`) */
16
+ readonly characterOnly?: boolean;
17
+ /** `import::from(pkg, a, b)`: attach only the symbols named in the call */
18
+ readonly fromImports?: boolean;
19
+ /** `box::use(pkg[a, b])`: attach only the symbols listed in the `[...]` bracket */
20
+ readonly boxUse?: boolean;
21
+ }
22
+ /** Restricts/aliases which exports of a package are attached; `undefined` fields attach every export. */
23
+ interface AttachSpec {
24
+ readonly namespaceOnly?: boolean;
25
+ /** attached exports as attachedName to exportName (`import::from`/`box::use` selection or aliasing) */
26
+ readonly include?: ReadonlyMap<string, string>;
27
+ /** attach all exports except these (`import::from` `.except`) */
28
+ readonly exclude?: ReadonlySet<string>;
29
+ /** attach every export (`import::from` `.all`, `box::use(pkg[...])`) */
30
+ readonly all?: boolean;
31
+ }
7
32
  /**
8
33
  * Process a library call like `library` or `require`
9
34
  */
10
- export declare function processLibrary<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
35
+ export declare function processLibrary<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: LibraryProcessorConfig): DataflowInformation;
36
+ /** Materialize the empty built-in function-definition vertex for a package export (idempotent). */
37
+ export declare function attachExportVertex(graph: DataflowGraph, builtInId: NodeId, environment: REnvironmentInformation, ctx: FlowrAnalyzerContext, cds?: ControlDependency[]): void;
38
+ /**
39
+ * Attaches `dependency`'s exports below the global environment (see {@link attachPackageBelowGlobal}) and returns the
40
+ * enriched environment (the graph is untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`,
41
+ * and the transitive side-effect propagation.
42
+ */
43
+ export declare function attachDependencyToEnvironment(dependency: Package, envInfo: REnvironmentInformation, ctx: FlowrAnalyzerContext, spec?: AttachSpec, definedAt?: NodeId): REnvironmentInformation;
44
+ export {};