@eagleoutice/flowr 2.15.8 → 2.15.9

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 (617) hide show
  1. package/README.md +39 -280
  2. package/abstract-interpretation/absint-inference.d.ts +5 -5
  3. package/abstract-interpretation/absint-inference.js +12 -12
  4. package/abstract-interpretation/abstract-semantics.d.ts +10 -10
  5. package/abstract-interpretation/data-frame/arguments.d.ts +9 -9
  6. package/abstract-interpretation/data-frame/arguments.js +11 -11
  7. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +1 -1
  8. package/abstract-interpretation/data-frame/dataframe-semantics.js +14 -14
  9. package/abstract-interpretation/unsupported-functions.d.ts +0 -1
  10. package/abstract-interpretation/unsupported-functions.js +1 -2
  11. package/abstract-interpretation/value-semantics.d.ts +1 -1
  12. package/abstract-interpretation/value-semantics.js +2 -3
  13. package/benchmark/calibration.d.ts +0 -2
  14. package/benchmark/calibration.js +0 -5
  15. package/benchmark/slicer.d.ts +2 -2
  16. package/benchmark/slicer.js +4 -4
  17. package/benchmark/stats/size-of.d.ts +1 -1
  18. package/benchmark/stats/size-of.js +2 -2
  19. package/benchmark/summarizer/first-phase/process.d.ts +1 -1
  20. package/benchmark/summarizer/first-phase/process.js +1 -1
  21. package/benchmark/summarizer/second-phase/graph.d.ts +1 -1
  22. package/benchmark/summarizer/second-phase/graph.js +1 -1
  23. package/cli/benchmark-app.js +3 -3
  24. package/cli/common/options.d.ts +0 -16
  25. package/cli/common/options.js +0 -3
  26. package/cli/common/scripts-info.d.ts +0 -16
  27. package/cli/compile-cache.d.ts +1 -0
  28. package/cli/compile-cache.js +19 -0
  29. package/cli/flowr-main-options.d.ts +5 -0
  30. package/cli/flowr-main-options.js +6 -0
  31. package/cli/flowr.d.ts +13 -0
  32. package/cli/flowr.js +27 -2
  33. package/cli/repl/commands/repl-clipboard.d.ts +4 -1
  34. package/cli/repl/commands/repl-clipboard.js +4 -1
  35. package/cli/repl/commands/repl-main.d.ts +0 -2
  36. package/cli/repl/commands/repl-main.js +0 -5
  37. package/cli/repl/commands/repl-normalize.js +3 -0
  38. package/cli/repl/commands/repl-parse.js +27 -0
  39. package/cli/repl/commands/repl-signature.js +17 -1
  40. package/cli/script-core/summarizer-core.js +0 -9
  41. package/cli/summarizer-app.d.ts +0 -3
  42. package/cli/wiki.d.ts +2 -2
  43. package/cli/wiki.js +18 -2
  44. package/config.d.ts +54 -5
  45. package/config.js +43 -8
  46. package/control-flow/cfg-dead-code.js +5 -4
  47. package/control-flow/cfg-properties.d.ts +2 -2
  48. package/control-flow/cfg-properties.js +2 -2
  49. package/control-flow/control-flow-graph.d.ts +32 -10
  50. package/control-flow/control-flow-graph.js +22 -10
  51. package/control-flow/diff-cfg.js +3 -2
  52. package/control-flow/happens-before.d.ts +6 -0
  53. package/control-flow/happens-before.js +42 -0
  54. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  55. package/control-flow/semantic-cfg-guided-visitor.js +5 -2
  56. package/control-flow/simple-visitor.d.ts +2 -7
  57. package/control-flow/simple-visitor.js +2 -6
  58. package/control-flow/useless-loop.d.ts +2 -2
  59. package/control-flow/useless-loop.js +11 -8
  60. package/core/pipeline-executor.d.ts +2 -2
  61. package/core/pipeline-executor.js +2 -2
  62. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  63. package/core/steps/all/static-slicing/00-slice.d.ts +1 -1
  64. package/core/steps/all/static-slicing/00-slice.js +1 -1
  65. package/core/steps/all/static-slicing/10-reconstruct.js +1 -1
  66. package/core/steps/pipeline/default-pipelines.d.ts +16 -16
  67. package/core/steps/pipeline/pipeline.d.ts +1 -6
  68. package/data/r-base-packages.generated.d.ts +2 -2
  69. package/data/r-base-packages.generated.js +4 -4
  70. package/dataflow/cluster.js +1 -1
  71. package/dataflow/environments/apply-kill.d.ts +4 -0
  72. package/dataflow/environments/apply-kill.js +43 -8
  73. package/dataflow/environments/built-in-config.d.ts +7 -2
  74. package/dataflow/environments/built-in-config.js +7 -5
  75. package/dataflow/environments/built-in-eval-name.d.ts +4 -2
  76. package/dataflow/environments/built-in-eval-name.js +3 -1
  77. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  78. package/dataflow/environments/built-in-proc-name.js +2 -0
  79. package/dataflow/environments/built-in-props.d.ts +23 -7
  80. package/dataflow/environments/built-in-props.js +27 -10
  81. package/dataflow/environments/built-in.d.ts +5 -6
  82. package/dataflow/environments/built-in.js +12 -16
  83. package/dataflow/environments/data-masking-functions.js +1 -1
  84. package/dataflow/environments/default-builtin-config.d.ts +221 -32
  85. package/dataflow/environments/default-builtin-config.js +133 -83
  86. package/dataflow/environments/environment.d.ts +5 -0
  87. package/dataflow/environments/environment.js +39 -11
  88. package/dataflow/environments/frame-memory.d.ts +41 -2
  89. package/dataflow/environments/frame-memory.js +143 -12
  90. package/dataflow/environments/identifier.d.ts +64 -9
  91. package/dataflow/environments/identifier.js +99 -13
  92. package/dataflow/environments/query-fn-props.d.ts +8 -2
  93. package/dataflow/environments/query-fn-props.js +20 -12
  94. package/dataflow/environments/reference-to-maybe.js +1 -1
  95. package/dataflow/environments/removal-marker.d.ts +7 -0
  96. package/dataflow/environments/removal-marker.js +20 -0
  97. package/dataflow/environments/resolve-by-name.d.ts +8 -8
  98. package/dataflow/environments/resolve-by-name.js +15 -12
  99. package/dataflow/environments/resolve-helper.d.ts +26 -4
  100. package/dataflow/environments/resolve-helper.js +27 -4
  101. package/dataflow/eval/resolve/alias-tracking.d.ts +17 -17
  102. package/dataflow/eval/resolve/alias-tracking.js +57 -32
  103. package/dataflow/eval/resolve/node-value.d.ts +15 -28
  104. package/dataflow/eval/resolve/node-value.js +26 -45
  105. package/dataflow/eval/resolve/resolve-argument.js +21 -2
  106. package/dataflow/eval/resolve/resolve-get.d.ts +28 -0
  107. package/dataflow/eval/resolve/resolve-get.js +49 -0
  108. package/dataflow/eval/resolve/resolve-numbers.d.ts +4 -2
  109. package/dataflow/eval/resolve/resolve-numbers.js +4 -2
  110. package/dataflow/eval/resolve/resolve-operators.d.ts +4 -1
  111. package/dataflow/eval/resolve/resolve-operators.js +7 -3
  112. package/dataflow/eval/resolve/resolve-strings.d.ts +6 -3
  113. package/dataflow/eval/resolve/resolve-strings.js +29 -5
  114. package/dataflow/eval/resolve/resolve-working-directory.js +2 -8
  115. package/dataflow/eval/resolve/resolve.js +27 -15
  116. package/dataflow/eval/values/general.js +13 -12
  117. package/dataflow/eval/values/intervals/interval-constants.d.ts +10 -2
  118. package/dataflow/eval/values/intervals/interval-constants.js +10 -2
  119. package/dataflow/eval/values/logical/logical-constants.d.ts +1 -8
  120. package/dataflow/eval/values/logical/logical-constants.js +1 -23
  121. package/dataflow/eval/values/r-value.d.ts +8 -9
  122. package/dataflow/eval/values/r-value.js +8 -8
  123. package/dataflow/eval/values/scalar/scalar-constants.d.ts +1 -12
  124. package/dataflow/eval/values/scalar/scalar-constants.js +0 -14
  125. package/dataflow/eval/values/sets/set-constants.d.ts +1 -4
  126. package/dataflow/eval/values/sets/set-constants.js +0 -11
  127. package/dataflow/eval/values/string/string-constants.d.ts +4 -18
  128. package/dataflow/eval/values/string/string-constants.js +3 -18
  129. package/dataflow/eval/values/vectors/vector-constants.d.ts +1 -1
  130. package/dataflow/eval/values/vectors/vector-constants.js +1 -1
  131. package/dataflow/extractor.js +176 -13
  132. package/dataflow/fn/argument-roles.d.ts +10 -12
  133. package/dataflow/fn/argument-roles.js +16 -22
  134. package/dataflow/fn/class-declaration.d.ts +8 -30
  135. package/dataflow/fn/class-declaration.js +12 -37
  136. package/dataflow/fn/exceptions-of-function.d.ts +3 -16
  137. package/dataflow/fn/exceptions-of-function.js +5 -21
  138. package/dataflow/fn/frame-reflection.d.ts +5 -19
  139. package/dataflow/fn/frame-reflection.js +14 -29
  140. package/dataflow/fn/function-props.d.ts +9 -10
  141. package/dataflow/fn/function-props.js +16 -20
  142. package/dataflow/fn/function-semantics.d.ts +130 -0
  143. package/dataflow/fn/function-semantics.js +89 -0
  144. package/dataflow/fn/higher-order-function.d.ts +8 -16
  145. package/dataflow/fn/higher-order-function.js +17 -28
  146. package/dataflow/fn/recursive-function.js +1 -1
  147. package/dataflow/fn/strict-function.d.ts +8 -20
  148. package/dataflow/fn/strict-function.js +20 -38
  149. package/dataflow/graph/call-graph.d.ts +9 -0
  150. package/dataflow/graph/call-graph.js +15 -14
  151. package/dataflow/graph/dataflowgraph-builder.d.ts +18 -23
  152. package/dataflow/graph/dataflowgraph-builder.js +18 -29
  153. package/dataflow/graph/df-helper.d.ts +22 -109
  154. package/dataflow/graph/df-helper.js +20 -64
  155. package/dataflow/graph/diff-dataflow-graph.d.ts +5 -0
  156. package/dataflow/graph/diff-dataflow-graph.js +12 -7
  157. package/dataflow/graph/edge.d.ts +1 -0
  158. package/dataflow/graph/edge.js +1 -0
  159. package/dataflow/graph/graph-helper.d.ts +26 -1
  160. package/dataflow/graph/graph-helper.js +53 -2
  161. package/dataflow/graph/graph.d.ts +42 -7
  162. package/dataflow/graph/graph.js +43 -9
  163. package/dataflow/graph/match-args.d.ts +16 -12
  164. package/dataflow/graph/match-args.js +68 -26
  165. package/dataflow/graph/vertex.d.ts +38 -57
  166. package/dataflow/graph/vertex.js +38 -66
  167. package/dataflow/info.d.ts +5 -2
  168. package/dataflow/info.js +3 -1
  169. package/dataflow/internal/control-flow.d.ts +13 -12
  170. package/dataflow/internal/control-flow.js +13 -12
  171. package/dataflow/internal/linker.d.ts +24 -15
  172. package/dataflow/internal/linker.js +115 -33
  173. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +6 -8
  174. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -7
  175. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +17 -3
  176. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +112 -39
  177. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +10 -2
  178. package/dataflow/internal/process/functions/call/built-in/built-in-class-relation.d.ts +1 -1
  179. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +21 -0
  180. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +99 -0
  181. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +56 -13
  182. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +179 -45
  183. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +2 -0
  184. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +46 -5
  185. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +49 -13
  186. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +119 -22
  187. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +5 -1
  188. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +62 -28
  189. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
  190. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -2
  191. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +9 -2
  192. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +26 -10
  193. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  194. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +13 -10
  195. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
  196. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +36 -22
  197. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +2 -2
  198. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +7 -7
  199. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +3 -2
  200. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
  201. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +7 -11
  202. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +5 -5
  203. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +7 -7
  204. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +2 -0
  205. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +28 -7
  206. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +5 -5
  207. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +1 -1
  208. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +2 -2
  209. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +2 -2
  210. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +12 -14
  211. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
  212. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +3 -4
  213. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +8 -2
  214. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +21 -13
  215. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -0
  216. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +29 -11
  217. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  218. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +15 -12
  219. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +5 -5
  220. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +23 -16
  221. package/dataflow/internal/process/functions/call/common.d.ts +7 -1
  222. package/dataflow/internal/process/functions/call/common.js +17 -7
  223. package/dataflow/internal/process/functions/call/deferred.d.ts +1 -3
  224. package/dataflow/internal/process/functions/call/deferred.js +20 -10
  225. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -4
  226. package/dataflow/internal/process/functions/call/known-call-handling.js +17 -8
  227. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  228. package/dataflow/internal/process/functions/call/named-call-handling.js +5 -4
  229. package/dataflow/internal/process/functions/call/nse.d.ts +1 -2
  230. package/dataflow/internal/process/functions/call/nse.js +13 -15
  231. package/dataflow/internal/process/functions/call/quoted.d.ts +3 -4
  232. package/dataflow/internal/process/functions/call/quoted.js +96 -42
  233. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
  234. package/dataflow/internal/process/functions/process-parameter.d.ts +4 -1
  235. package/dataflow/internal/process/functions/process-parameter.js +4 -1
  236. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  237. package/dataflow/origin/dfg-get-origin.js +17 -10
  238. package/dataflow/origin/dfg-get-symbol-refs.d.ts +2 -2
  239. package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
  240. package/dataflow/processor.d.ts +10 -0
  241. package/documentation/data/dfg/doc-data-dfg-util.d.ts +2 -2
  242. package/documentation/data/dfg/doc-data-dfg-util.js +2 -2
  243. package/documentation/data/faq/faqs.d.ts +2 -1
  244. package/documentation/data/faq/faqs.js +12 -3
  245. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  246. package/documentation/data/server/doc-data-server-messages.js +2 -1
  247. package/documentation/doc-capabilities.d.ts +13 -7
  248. package/documentation/doc-capabilities.js +445 -126
  249. package/documentation/doc-util/doc-auto-gen.d.ts +4 -2
  250. package/documentation/doc-util/doc-auto-gen.js +22 -4
  251. package/documentation/doc-util/doc-cfg.js +2 -2
  252. package/documentation/doc-util/doc-code.d.ts +8 -2
  253. package/documentation/doc-util/doc-code.js +36 -7
  254. package/documentation/doc-util/doc-dfg.d.ts +2 -0
  255. package/documentation/doc-util/doc-dfg.js +4 -3
  256. package/documentation/doc-util/doc-env.d.ts +2 -1
  257. package/documentation/doc-util/doc-env.js +2 -1
  258. package/documentation/doc-util/doc-escape.d.ts +2 -2
  259. package/documentation/doc-util/doc-escape.js +2 -2
  260. package/documentation/doc-util/doc-files.d.ts +0 -2
  261. package/documentation/doc-util/doc-files.js +2 -3
  262. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  263. package/documentation/doc-util/doc-query.d.ts +2 -1
  264. package/documentation/doc-util/doc-query.js +4 -3
  265. package/documentation/doc-util/doc-repl.d.ts +1 -1
  266. package/documentation/doc-util/doc-repl.js +1 -1
  267. package/documentation/doc-util/doc-search.js +2 -2
  268. package/documentation/doc-util/doc-server-message.js +2 -2
  269. package/documentation/doc-util/doc-sigdb.js +1 -1
  270. package/documentation/doc-util/doc-structure.d.ts +10 -3
  271. package/documentation/doc-util/doc-structure.js +10 -3
  272. package/documentation/doc-util/doc-timings.d.ts +19 -0
  273. package/documentation/doc-util/doc-timings.js +44 -0
  274. package/documentation/doc-util/doc-types.d.ts +8 -6
  275. package/documentation/doc-util/doc-types.js +11 -8
  276. package/documentation/index.d.ts +1 -0
  277. package/documentation/index.js +1 -0
  278. package/documentation/wiki-core.js +3 -0
  279. package/documentation/wiki-create-linting-rules.js +1 -1
  280. package/documentation/wiki-dataflow-graph.js +19 -20
  281. package/documentation/wiki-engine.js +13 -2
  282. package/documentation/wiki-helper-objects.d.ts +9 -0
  283. package/documentation/wiki-helper-objects.js +102 -0
  284. package/documentation/wiki-linter.js +154 -16
  285. package/documentation/wiki-linting-and-testing.js +99 -6
  286. package/documentation/wiki-mk/doc-context.d.ts +33 -29
  287. package/documentation/wiki-mk/doc-context.js +1 -0
  288. package/documentation/wiki-mk/doc-maker.d.ts +1 -1
  289. package/documentation/wiki-mk/doc-maker.js +18 -2
  290. package/documentation/wiki-query.js +44 -0
  291. package/documentation/wiki-signature-database.js +7 -3
  292. package/gas.d.ts +3 -2
  293. package/index.d.ts +18 -3
  294. package/index.js +29 -3
  295. package/linter/linter-executor.js +2 -2
  296. package/linter/linter-format.d.ts +9 -3
  297. package/linter/linter-format.js +2 -0
  298. package/linter/linter-rules.d.ts +118 -98
  299. package/linter/linter-rules.js +3 -1
  300. package/linter/rules/absolute-path.d.ts +10 -10
  301. package/linter/rules/absolute-path.js +9 -12
  302. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  303. package/linter/rules/dataframe-access-validation.js +17 -4
  304. package/linter/rules/dead-code.d.ts +2 -2
  305. package/linter/rules/dead-code.js +1 -1
  306. package/linter/rules/deprecated-functions.d.ts +5 -5
  307. package/linter/rules/deprecated-functions.js +8 -8
  308. package/linter/rules/file-path-validity.d.ts +7 -7
  309. package/linter/rules/file-path-validity.js +4 -4
  310. package/linter/rules/function-finder-util.d.ts +0 -6
  311. package/linter/rules/function-finder-util.js +7 -2
  312. package/linter/rules/namespace-access.d.ts +42 -0
  313. package/linter/rules/namespace-access.js +78 -0
  314. package/linter/rules/naming-convention.d.ts +3 -3
  315. package/linter/rules/naming-convention.js +7 -3
  316. package/linter/rules/network-functions.d.ts +5 -5
  317. package/linter/rules/network-functions.js +5 -6
  318. package/linter/rules/no-leaked-credentials.d.ts +3 -3
  319. package/linter/rules/no-leaked-credentials.js +4 -5
  320. package/linter/rules/problematic-inputs.d.ts +5 -5
  321. package/linter/rules/problematic-inputs.js +13 -21
  322. package/linter/rules/roxygen-arguments.d.ts +1 -1
  323. package/linter/rules/roxygen-arguments.js +4 -3
  324. package/linter/rules/seeded-randomness.d.ts +6 -5
  325. package/linter/rules/seeded-randomness.js +15 -13
  326. package/linter/rules/software-has-license.d.ts +2 -2
  327. package/linter/rules/software-has-license.js +2 -2
  328. package/linter/rules/software-has-tests.d.ts +3 -3
  329. package/linter/rules/software-has-tests.js +2 -2
  330. package/linter/rules/stop-with-call-arg.d.ts +1 -1
  331. package/linter/rules/stop-with-call-arg.js +16 -3
  332. package/linter/rules/syntactically-valid.d.ts +3 -3
  333. package/linter/rules/syntactically-valid.js +2 -2
  334. package/linter/rules/unclosed-connection.d.ts +3 -3
  335. package/linter/rules/unclosed-connection.js +23 -12
  336. package/linter/rules/undefined-symbol-util.d.ts +3 -1
  337. package/linter/rules/undefined-symbol-util.js +9 -7
  338. package/linter/rules/undefined-symbol.d.ts +4 -4
  339. package/linter/rules/undefined-symbol.js +4 -4
  340. package/linter/rules/unescaped-arguments.d.ts +37 -37
  341. package/linter/rules/unescaped-arguments.js +20 -21
  342. package/linter/rules/unused-definition.d.ts +3 -3
  343. package/linter/rules/unused-definition.js +63 -26
  344. package/linter/rules/unused-import.d.ts +4 -4
  345. package/linter/rules/unused-import.js +14 -5
  346. package/linter/rules/useless-loop.d.ts +3 -3
  347. package/linter/rules/useless-loop.js +3 -3
  348. package/package.json +6 -4
  349. package/project/context/flowr-analyzer-context.d.ts +5 -0
  350. package/project/context/flowr-analyzer-context.js +5 -0
  351. package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -3
  352. package/project/context/flowr-analyzer-environment-context.d.ts +20 -1
  353. package/project/context/flowr-analyzer-environment-context.js +24 -1
  354. package/project/context/flowr-analyzer-files-context.d.ts +7 -3
  355. package/project/context/flowr-analyzer-files-context.js +53 -22
  356. package/project/context/flowr-analyzer-functions-context.d.ts +1 -6
  357. package/project/context/flowr-analyzer-functions-context.js +1 -7
  358. package/project/context/flowr-analyzer-gas-context.d.ts +7 -0
  359. package/project/context/flowr-analyzer-gas-context.js +6 -1
  360. package/project/dependency-version-space.d.ts +7 -0
  361. package/project/dependency-version-space.js +2 -2
  362. package/project/flowr-analyzer-builder.d.ts +14 -4
  363. package/project/flowr-analyzer-builder.js +3 -1
  364. package/project/flowr-analyzer.d.ts +3 -3
  365. package/project/flowr-analyzer.js +1 -3
  366. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +1 -1
  367. package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
  368. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -1
  369. package/project/plugins/file-plugins/files/flowr-namespace-file.js +1 -1
  370. package/project/plugins/file-plugins/files/flowr-rda-file.js +8 -6
  371. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +3 -3
  372. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +33 -10
  373. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -2
  374. package/project/plugins/file-plugins/files/flowr-sweave-file.js +2 -2
  375. package/project/plugins/file-plugins/files/r-fun-tab.d.ts +4 -67
  376. package/project/plugins/file-plugins/files/r-fun-tab.js +6 -653
  377. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +4 -1
  378. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +4 -1
  379. package/project/plugins/flowr-analyzer-plugin.d.ts +1 -1
  380. package/project/plugins/flowr-analyzer-plugin.js +1 -1
  381. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +0 -19
  382. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -51
  383. package/project/sigdb/codec.d.ts +0 -4
  384. package/project/sigdb/codec.js +1 -8
  385. package/project/sigdb/manifest.d.ts +0 -2
  386. package/project/sigdb/manifest.js +2 -6
  387. package/project/sigdb/memory-source.js +2 -1
  388. package/project/sigdb/reader.js +3 -2
  389. package/project/sigdb/schema.d.ts +0 -2
  390. package/project/sigdb/schema.js +1 -7
  391. package/project/sigdb/signature-db.d.ts +9 -1
  392. package/project/sigdb/signature-db.js +8 -0
  393. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -1
  394. package/queries/catalog/call-context-query/call-context-query-executor.js +5 -4
  395. package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
  396. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
  397. package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
  398. package/queries/catalog/dependencies-query/dependencies-query-executor.js +40 -6
  399. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +33 -54
  400. package/queries/catalog/dependencies-query/dependencies-query-format.js +37 -13
  401. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +3 -2
  402. package/queries/catalog/dependencies-query/function-info/derived-functions.js +5 -5
  403. package/queries/catalog/dependencies-query/function-info/read-functions.d.ts +6 -1
  404. package/queries/catalog/dependencies-query/function-info/read-functions.js +12 -9
  405. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +2 -2
  406. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +1 -2
  407. package/queries/catalog/dependencies-query/function-info/write-functions.d.ts +9 -1
  408. package/queries/catalog/dependencies-query/function-info/write-functions.js +17 -6
  409. package/queries/catalog/dependencies-query/implicit-echo.js +28 -5
  410. package/queries/catalog/dependencies-query/link-devices.js +23 -10
  411. package/queries/catalog/dice-query/dice-query-executor.js +2 -14
  412. package/queries/catalog/does-call-query/does-call-query-executor.js +1 -2
  413. package/queries/catalog/files-query/files-query-format.d.ts +1 -1
  414. package/queries/catalog/function-info-query/function-info-query-executor.d.ts +7 -0
  415. package/queries/catalog/function-info-query/function-info-query-executor.js +38 -0
  416. package/queries/catalog/function-info-query/function-info-query-format.d.ts +48 -0
  417. package/queries/catalog/function-info-query/function-info-query-format.js +54 -0
  418. package/queries/catalog/function-info-query/function-origin.d.ts +22 -0
  419. package/queries/catalog/function-info-query/function-origin.js +46 -0
  420. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
  421. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
  422. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
  423. package/queries/catalog/input-sources-query/input-source-functions.d.ts +2 -2
  424. package/queries/catalog/input-sources-query/input-source-functions.js +1 -2
  425. package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -2
  426. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +4 -2
  427. package/queries/catalog/input-sources-query/input-sources-query-format.js +24 -24
  428. package/queries/catalog/input-sources-query/input-types.d.ts +2 -2
  429. package/queries/catalog/input-sources-query/input-types.js +2 -2
  430. package/queries/catalog/input-sources-query/simple-input-classifier.js +6 -6
  431. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -2
  432. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +1 -1
  433. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +6 -7
  434. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +4 -4
  435. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +8 -7
  436. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -2
  437. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +1 -1
  438. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +1 -1
  439. package/queries/catalog/linter-query/linter-query-format.d.ts +1 -1
  440. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -11
  441. package/queries/catalog/signature-query/signature-query-executor.js +124 -63
  442. package/queries/catalog/signature-query/signature-query-format.d.ts +21 -0
  443. package/queries/catalog/signature-query/signature-query-format.js +5 -1
  444. package/queries/catalog/signature-query/signature-query-render.js +28 -3
  445. package/queries/catalog/slice-query-options.d.ts +19 -2
  446. package/queries/catalog/slice-query-options.js +19 -3
  447. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +2 -2
  448. package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -17
  449. package/queries/query-function-filter.d.ts +1 -0
  450. package/queries/query-function-filter.js +1 -0
  451. package/queries/query.d.ts +13 -2
  452. package/queries/query.js +4 -1
  453. package/r-bridge/data/data.d.ts +1435 -450
  454. package/r-bridge/data/data.js +1063 -478
  455. package/r-bridge/data/get.d.ts +1 -6
  456. package/r-bridge/data/get.js +0 -32
  457. package/r-bridge/data/types.d.ts +3 -0
  458. package/r-bridge/init.d.ts +7 -2
  459. package/r-bridge/init.js +10 -5
  460. package/r-bridge/lang-4.x/ast/model/model.d.ts +10 -8
  461. package/r-bridge/lang-4.x/ast/model/model.js +9 -10
  462. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +4 -4
  463. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +5 -5
  464. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +1 -1
  465. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +4 -4
  466. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +4 -4
  467. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +4 -4
  468. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +4 -4
  469. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +4 -4
  470. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +6 -6
  471. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -2
  472. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +4 -4
  473. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +4 -4
  474. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +4 -4
  475. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +4 -4
  476. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +4 -4
  477. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +4 -4
  478. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +5 -5
  479. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -1
  480. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +6 -4
  481. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +4 -0
  482. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +4 -3
  483. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +4 -3
  484. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +4 -4
  485. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +5 -5
  486. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +1 -1
  487. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +5 -5
  488. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -1
  489. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +4 -4
  490. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +4 -4
  491. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +4 -20
  492. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -43
  493. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +11 -0
  494. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +18 -3
  495. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +0 -5
  496. package/r-bridge/lang-4.x/ast/model/processing/role.js +0 -13
  497. package/r-bridge/lang-4.x/ast/model/versions.d.ts +2 -0
  498. package/r-bridge/lang-4.x/ast/model/versions.js +3 -1
  499. package/r-bridge/lang-4.x/ast/parser/json/parser.js +3 -2
  500. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.d.ts +2 -2
  501. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +2 -2
  502. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.d.ts +1 -1
  503. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +1 -1
  504. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.d.ts +1 -1
  505. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +10 -2
  506. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.d.ts +2 -2
  507. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +2 -2
  508. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.d.ts +1 -1
  509. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +1 -1
  510. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.d.ts +3 -1
  511. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.js +3 -1
  512. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.d.ts +5 -1
  513. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +5 -1
  514. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.d.ts +3 -1
  515. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +3 -1
  516. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.d.ts +1 -1
  517. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -1
  518. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.d.ts +1 -1
  519. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -1
  520. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +39 -2
  521. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.d.ts +1 -1
  522. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +1 -1
  523. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.d.ts +1 -1
  524. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +2 -1
  525. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -1
  526. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -1
  527. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +2 -2
  528. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +2 -2
  529. package/r-bridge/lang-4.x/convert-values.d.ts +6 -0
  530. package/r-bridge/lang-4.x/convert-values.js +6 -0
  531. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  532. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +2 -2
  533. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +1 -1
  534. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +15 -2
  535. package/r-bridge/parser.d.ts +1 -1
  536. package/r-bridge/parser.js +1 -1
  537. package/r-bridge/retriever.d.ts +0 -21
  538. package/r-bridge/retriever.js +5 -63
  539. package/r-bridge/roxygen2/documentation-provider.d.ts +2 -2
  540. package/r-bridge/roxygen2/documentation-provider.js +2 -2
  541. package/r-bridge/shell-executor.js +1 -1
  542. package/r-bridge/shell.d.ts +4 -4
  543. package/r-bridge/shell.js +58 -35
  544. package/reconstruct/inline/source-inline-map.d.ts +15 -22
  545. package/reconstruct/inline/source-inline-map.js +63 -70
  546. package/reconstruct/reconstruct.d.ts +1 -1
  547. package/reconstruct/reconstruct.js +5 -2
  548. package/search/flowr-search-builder.d.ts +17 -16
  549. package/search/flowr-search-builder.js +9 -8
  550. package/search/flowr-search-filters.d.ts +1 -13
  551. package/search/flowr-search-filters.js +4 -13
  552. package/search/search-executor/search-enrichers.d.ts +2 -2
  553. package/search/search-executor/search-enrichers.js +3 -3
  554. package/search/search-executor/search-generators.d.ts +0 -3
  555. package/search/search-executor/search-transformer.d.ts +0 -3
  556. package/slicing/criterion/parse.d.ts +24 -20
  557. package/slicing/criterion/parse.js +34 -24
  558. package/slicing/static/slice-call.d.ts +1 -1
  559. package/slicing/static/slice-call.js +28 -9
  560. package/slicing/static/static-slicer.js +3 -4
  561. package/slicing/static/visiting-queue.d.ts +3 -1
  562. package/slicing/static/visiting-queue.js +25 -14
  563. package/util/accessor.d.ts +22 -0
  564. package/util/accessor.js +3 -0
  565. package/util/assert.d.ts +14 -8
  566. package/util/assert.js +25 -8
  567. package/util/collections/arrays.d.ts +11 -7
  568. package/util/collections/arrays.js +14 -14
  569. package/util/collections/defaultmap.d.ts +5 -0
  570. package/util/collections/defaultmap.js +14 -0
  571. package/util/diff-graph.d.ts +1 -2
  572. package/util/diff-graph.js +0 -1
  573. package/util/files.d.ts +20 -34
  574. package/util/files.js +36 -51
  575. package/util/glob.js +1 -1
  576. package/util/json.d.ts +0 -7
  577. package/util/json.js +0 -15
  578. package/util/logic.d.ts +5 -0
  579. package/util/logic.js +6 -1
  580. package/util/mermaid/dfg.d.ts +2 -1
  581. package/util/mermaid/dfg.js +7 -6
  582. package/util/mermaid/mermaid.d.ts +1 -0
  583. package/util/mermaid/mermaid.js +1 -0
  584. package/util/numbers.d.ts +0 -5
  585. package/util/numbers.js +0 -9
  586. package/util/objects.d.ts +3 -3
  587. package/util/objects.js +3 -3
  588. package/util/quads.d.ts +2 -2
  589. package/util/quads.js +1 -1
  590. package/util/r-base-packages.d.ts +14 -1
  591. package/util/r-base-packages.js +21 -1
  592. package/util/r-package-urls.d.ts +33 -0
  593. package/util/r-package-urls.js +79 -0
  594. package/util/r-version.d.ts +8 -2
  595. package/util/r-version.js +8 -2
  596. package/util/range.d.ts +173 -54
  597. package/util/range.js +221 -75
  598. package/util/record.d.ts +7 -6
  599. package/util/record.js +7 -6
  600. package/util/simple-df/dfg-ascii.js +6 -6
  601. package/util/summarizer.d.ts +2 -15
  602. package/util/summarizer.js +0 -15
  603. package/util/text/args.d.ts +2 -2
  604. package/util/text/args.js +2 -2
  605. package/util/text/playground-link.d.ts +3 -23
  606. package/util/text/playground-link.js +10 -10
  607. package/util/text/r-highlight.d.ts +20 -0
  608. package/util/text/r-highlight.js +171 -0
  609. package/util/text/strings.d.ts +6 -0
  610. package/util/text/strings.js +11 -2
  611. package/util/version.js +2 -2
  612. package/cli/run-script.d.ts +0 -7
  613. package/cli/run-script.js +0 -17
  614. package/project/sigdb/signature-match.d.ts +0 -18
  615. package/project/sigdb/signature-match.js +0 -32
  616. package/util/text/text.d.ts +0 -5
  617. package/util/text/text.js +0 -24
@@ -4,6 +4,7 @@ exports.processAssignmentLike = processAssignmentLike;
4
4
  exports.processAssignment = processAssignment;
5
5
  exports.processDefineArgument = processDefineArgument;
6
6
  exports.markAsAssignment = markAsAssignment;
7
+ const function_semantics_1 = require("../../../../../fn/function-semantics");
7
8
  const known_call_handling_1 = require("../known-call-handling");
8
9
  const nse_1 = require("../nse");
9
10
  const data_masking_functions_1 = require("../../../../../environments/data-masking-functions");
@@ -21,6 +22,7 @@ const overwrite_1 = require("../../../../../environments/overwrite");
21
22
  const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
22
23
  const retriever_1 = require("../../../../../../r-bridge/retriever");
23
24
  const vertex_1 = require("../../../../../graph/vertex");
25
+ const linker_1 = require("../../../../linker");
24
26
  const define_1 = require("../../../../../environments/define");
25
27
  const edge_1 = require("../../../../../graph/edge");
26
28
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
@@ -34,7 +36,6 @@ const built_in_list_1 = require("./built-in-list");
34
36
  const built_in_class_generator_1 = require("./built-in-class-generator");
35
37
  const built_in_stack_env_1 = require("./built-in-stack-env");
36
38
  const resolve_helper_1 = require("../../../../../environments/resolve-helper");
37
- const graph_1 = require("../../../../../graph/graph");
38
39
  function toReplacementSymbol(target, prefix, superAssignment) {
39
40
  return {
40
41
  type: type_1.RType.Symbol,
@@ -58,7 +59,17 @@ function findRootAccess(node) {
58
59
  }
59
60
  return undefined;
60
61
  }
61
- function tryReplacement(rootId, functionName, data, superAssignment, args) {
62
+ const EnvironmentProducers = [built_in_proc_name_1.BuiltInProcName.NewEnv, built_in_proc_name_1.BuiltInProcName.StackEnv, built_in_proc_name_1.BuiltInProcName.ListToEnv];
63
+ function yieldsEnvironment(node, graph, data) {
64
+ if (!r_function_call_1.RFunctionCall.isNamed(node)) {
65
+ return false;
66
+ }
67
+ const vertex = graph.getVertex(node.info.id);
68
+ return EnvironmentProducers.some(origin => vertex_1.DfgVertex.hasOrigin(vertex, origin))
69
+ || (identifier_1.Identifier.getName(node.functionName.content) === 'environment'
70
+ && resolve_helper_1.Resolve.isBuiltIn(node.functionName.content, data.environment, identifier_1.ReferenceType.Function));
71
+ }
72
+ function tryReplacement(rootId, functionName, data, superAssignment, args, beforeDefine) {
62
73
  const resolved = resolve_helper_1.Resolve.byNameAndType(functionName.content, data.environment, identifier_1.ReferenceType.Function) ?? [];
63
74
  const builtIn = resolved.length === 1 && resolved[0].type === identifier_1.ReferenceType.BuiltInFunction ? resolved[0] : undefined;
64
75
  /* every replacement function rebinds its target, no matter whether we ship a built-in for it or the user wrote
@@ -72,12 +83,14 @@ function tryReplacement(rootId, functionName, data, superAssignment, args) {
72
83
  location: functionName.location
73
84
  }, (0, make_argument_1.wrapArgumentsUnnamed)(args, data.completeAst.idMap), functionName.info.id, data, builtIn ? {
74
85
  ...builtIn.config,
75
- assignRootId: rootId
86
+ assignRootId: rootId,
87
+ beforeDefine
76
88
  } : {
77
89
  readIndices: true,
78
90
  makeMaybe: true,
79
91
  assignmentOperator: superAssignment ? '<<-' : '<-',
80
- assignRootId: rootId
92
+ assignRootId: rootId,
93
+ beforeDefine
81
94
  });
82
95
  if (builtIn) {
83
96
  (0, named_call_handling_1.markAsOnlyBuiltIn)(info.graph, functionName.info.id);
@@ -139,17 +152,34 @@ function processMaskedNamePair(name, args, rootId, data) {
139
152
  const target = args[0];
140
153
  (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.First, {
141
154
  kind: known_call_handling_1.NseKind.DataMasked,
142
- evaluated: nse_1.Nse.unquoted(r_argument_1.RArgument.isEmpty(target) ? undefined : target?.value, nse_1.Unquote.Rlang)
155
+ evaluated: function_semantics_1.FunctionSemantics.call.nse.unquoted(r_argument_1.RArgument.isEmpty(target) ? undefined : target?.value, nse_1.Unquote.Rlang)
143
156
  });
144
157
  return information;
145
158
  }
146
159
  /**
147
160
  * Processes an assignment `<target> <- <source>` as the function call \`&lt;-\` `(<target>, <source>)`,
148
- * including replacement functions (e.g., `names(x) <- ...` as \`names&lt;-\` `(x, ...)`).
161
+ * including replacement functions (e.g., `names(x) <- ...` as \`names&lt;-\` `(x, ...)`).
149
162
  */
150
163
  function processAssignment(name,
151
164
  /* we expect them to be ordered in the sense that we have (source, target): `<source> <- <target>` */
152
165
  args, rootId, data, config) {
166
+ const information = processAssignmentTarget(name, args, rootId, data, config);
167
+ if (config.callsSource) {
168
+ linkSourceAsCalled(args, rootId, data, config, information);
169
+ }
170
+ return information;
171
+ }
172
+ function linkSourceAsCalled(args, rootId, data, config, information) {
173
+ const source = (0, unpack_argument_1.unpackArg)(args[config.swapSourceAndTarget ? 0 : 1]);
174
+ const vertex = source ? information.graph.getVertex(source.info.id) : undefined;
175
+ if (vertex && vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
176
+ linker_1.ClosureRefs.resolveOpenIngoing(information.graph, rootId, vertex, data.environment);
177
+ for (const written of information.out) {
178
+ information.graph.addEdge(written.nodeId, vertex.id, edge_1.EdgeType.Calls);
179
+ }
180
+ }
181
+ }
182
+ function processAssignmentTarget(name, args, rootId, data, config) {
153
183
  if (isMaskedNamePair(name, rootId, data)) {
154
184
  return processMaskedNamePair(name, args, rootId, data);
155
185
  }
@@ -182,7 +212,7 @@ args, rootId, data, config) {
182
212
  reverseOrder: !config.swapSourceAndTarget,
183
213
  origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
184
214
  });
185
- return processAssignmentToSymbol({
215
+ const info = processAssignmentToSymbol({
186
216
  ...config,
187
217
  nameOfAssignmentFunction: name.content,
188
218
  source,
@@ -193,6 +223,12 @@ args, rootId, data, config) {
193
223
  data,
194
224
  information: res.information,
195
225
  });
226
+ if (config.readTarget && r_symbol_1.RSymbol.is(target)) {
227
+ /* just like a replacement function, the call works on the old value of its target */
228
+ info.graph.addEdge(target.info.id, rootId, edge_1.EdgeType.Reads);
229
+ return { ...info, in: [...info.in, { name: target.content, type: identifier_1.ReferenceType.Variable, nodeId: target.info.id, cds: data.cds }] };
230
+ }
231
+ return info;
196
232
  };
197
233
  if (type === type_1.RType.Symbol && !config.targetVariable) {
198
234
  return assignToSymbol();
@@ -208,7 +244,7 @@ args, rootId, data, config) {
208
244
  /* as replacement functions take precedence over the lhs fn-call (i.e., `names(x) <- ...` is independent from the definition of `names`), we do not have to process the call */
209
245
  logger_1.dataflowLogger.debug(`Assignment ${identifier_1.Identifier.toString(name.content)} has a function call as target ==> replacement function ${target.lexeme}`);
210
246
  const replacement = toReplacementSymbol(target, target.functionName.content, config.superAssignment ?? false);
211
- return tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [...target.arguments, source]);
247
+ return tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [...target.arguments, source], config.beforeDefine);
212
248
  }
213
249
  else if (config.canBeReplacement && type === type_1.RType.Access) {
214
250
  logger_1.dataflowLogger.debug(`Assignment ${identifier_1.Identifier.toString(name.content)} has an access-type node as target ==> replacement function ${target.lexeme}`);
@@ -217,7 +253,11 @@ args, rootId, data, config) {
217
253
  if (envRouted !== undefined) {
218
254
  return envRouted;
219
255
  }
220
- return tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source]);
256
+ const replaced = tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source], config.beforeDefine);
257
+ if (yieldsEnvironment(target.accessed, replaced.graph, data)) {
258
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(replaced.graph, replaced.environment, rootId);
259
+ }
260
+ return replaced;
221
261
  }
222
262
  else if (type === type_1.RType.Access) {
223
263
  const rootArg = findRootAccess(target);
@@ -324,16 +364,37 @@ function checkTargetReferenceType(sourceInfo, fnModes) {
324
364
  }
325
365
  }
326
366
  /**
327
- * Returns `true` when the entry-point of `sourceInfo` is a call to a `new.env`-family function.
367
+ * The node an assignment takes its value from, following the {@link EdgeType.Returns} edges of the graph.
368
+ * A block hands back its last expression and a grouping what it wraps, so `e <- { new.env() }` creates an
369
+ * environment just like `e <- new.env()` does. `undefined` whenever more than one node may produce the value,
370
+ * as a branch or a loop does, since the assignment then has no single source to speak of.
371
+ */
372
+ function valueEntryPointOf(sourceInfo) {
373
+ const seen = new Set();
374
+ let id = sourceInfo.entryPoint;
375
+ while (true) {
376
+ const returns = [...sourceInfo.graph.edgesFrom(id)].filter(([, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns));
377
+ if (returns.length === 0) {
378
+ return id;
379
+ }
380
+ else if (returns.length > 1 || seen.has(id)) {
381
+ return undefined;
382
+ }
383
+ seen.add(id);
384
+ id = returns[0][0];
385
+ }
386
+ }
387
+ /**
388
+ * Returns `true` when the value of `sourceInfo` comes from a call to a `new.env`-family function.
328
389
  * Used by {@link processAssignmentToSymbol} to attach an initial {@link InGraphIdentifierDefinition#envState}.
329
390
  */
330
- function isEnvCreatorSource(sourceInfo) {
331
- const vert = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
332
- return vertex_1.FunctionCallVertex.hasOrigin(vert, built_in_proc_name_1.BuiltInProcName.NewEnv);
391
+ function isEnvCreatorSource(sourceInfo, entryPoint) {
392
+ const vert = entryPoint === undefined ? undefined : sourceInfo.graph.getVertex(entryPoint);
393
+ return vertex_1.DfgVertex.hasOrigin(vert, built_in_proc_name_1.BuiltInProcName.NewEnv);
333
394
  }
334
395
  /**
335
396
  * When `e$x <- val` and `e` holds a tracked {@link InGraphIdentifierDefinition#envState}, adds field `x` into that
336
- * envState instead of redefining `e`; returns `undefined` when routing is not applicable.
397
+ * envState instead of redefining `e`; returns `undefined` when routing is not applicable.
337
398
  */
338
399
  function tryRouteDollarEnvAssign(rootId, data, config, target, source, replacement) {
339
400
  if (target.operator !== '$' || !r_symbol_1.RSymbol.is(target.accessed)) {
@@ -348,12 +409,13 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
348
409
  return undefined;
349
410
  }
350
411
  const fieldName = (r_string_1.RString.is(fieldNode) ? fieldNode.content.str : fieldNode.lexeme);
351
- const normalResult = tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source]);
412
+ const normalResult = tryReplacement(rootId, replacement, data, config.superAssignment ?? false, [(0, make_argument_1.toUnnamedArgument)(target.accessed, data.completeAst.idMap), ...target.access, source], config.beforeDefine);
413
+ const isFunction = (0, built_in_list_1.holdsFunction)(source, data.environment);
352
414
  const fieldDef = {
353
- type: identifier_1.ReferenceType.Variable,
415
+ type: isFunction ? identifier_1.ReferenceType.Function : identifier_1.ReferenceType.Variable,
354
416
  name: fieldName,
355
- nodeId: fieldNode.info.id,
356
- definedAt: rootId,
417
+ nodeId: source.info.id,
418
+ definedAt: normalResult.entryPoint,
357
419
  cds: data.cds ?? (config.makeMaybe ? [] : undefined)
358
420
  };
359
421
  const newEnvState = (0, define_1.define)(fieldDef, false, envirResolution.envDef.envState);
@@ -371,24 +433,31 @@ function tryRouteDollarEnvAssign(rootId, data, config, target, source, replaceme
371
433
  }
372
434
  /**
373
435
  * When `config.environmentArg` (e.g. `'envir'` for `assign`) resolves to a variable with a tracked
374
- * {@link InGraphIdentifierDefinition#envState}, routes the written definitions there instead of the current scope; returns `undefined` if not possible.
436
+ * {@link InGraphIdentifierDefinition#envState}, routes the written definitions there instead of the current scope; returns `undefined` if not possible.
437
+ * An `envir=` that names a value we cannot pin down (e.g. a parameter) is not a "no envir" call: routing the
438
+ * write into the local scope would be a guess, so the call becomes an unknown side effect instead.
375
439
  */
376
440
  function tryRouteToCustomEnv(name, args, rootId, data, config) {
377
- const resolution = (0, built_in_envir_utils_1.resolveEnvirArg)(args, data, config.environmentArg);
378
- if (!resolution) {
441
+ const envirRouting = (0, built_in_envir_utils_1.resolveEnvirArgOrAmbiguous)(args, data, config.sig, config.environmentArg)
442
+ ?? (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, built_in_envir_utils_1.EnvirPositionFormals);
443
+ if (envirRouting === 'ambiguous' || (!envirRouting && (0, built_in_envir_utils_1.suppliesArg)(args, config.sig, built_in_envir_utils_1.EnvirPositionFormals))) {
444
+ const info = (0, known_call_handling_1.processKnownFunctionCall)({
445
+ name, args, rootId, data,
446
+ origin: config.superAssignment ? built_in_proc_name_1.BuiltInProcName.SuperAssignment : built_in_proc_name_1.BuiltInProcName.Assignment
447
+ }).information;
448
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(info.graph, info.environment, rootId);
449
+ return info;
450
+ }
451
+ if (!envirRouting) {
379
452
  return undefined;
380
453
  }
381
- if (resolution.isStackEnv) {
382
- /* real stack env, not a private snapshot. Route a global write as a super-assignment so it reaches global scope from inside a function. */
383
- if (resolution.envirData.environment.current.globalEnv !== true) {
384
- return undefined;
385
- }
454
+ if (envirRouting.stack === 'global') {
386
455
  const globalResult = processAssignment(name, args, rootId, data, {
387
456
  ...config,
388
457
  environmentArg: undefined, // prevent re-entry
389
458
  superAssignment: true
390
459
  });
391
- globalResult.graph.addEdge(rootId, resolution.envirNodeId, edge_1.EdgeType.Reads);
460
+ globalResult.graph.addEdge(rootId, envirRouting.envirNodeId, edge_1.EdgeType.Reads);
392
461
  return globalResult;
393
462
  }
394
463
  /* run the normal assignment path to get the correct graph structure */
@@ -396,13 +465,12 @@ function tryRouteToCustomEnv(name, args, rootId, data, config) {
396
465
  ...config,
397
466
  environmentArg: undefined // prevent re-entry
398
467
  });
399
- normalResult.graph.addEdge(rootId, resolution.envirNodeId, edge_1.EdgeType.Reads);
400
468
  /* pass rootId as definedAt so only defs made at this call site are routed */
401
- return (0, built_in_envir_utils_1.routeWrittenToCustomEnv)(normalResult, resolution.envDef, rootId, rootId);
469
+ return (0, built_in_envir_utils_1.routeWrittenToEnvir)(normalResult, envirRouting, rootId, data.environment, rootId);
402
470
  }
403
471
  /**
404
472
  * Models a call like `Hmisc::getHdata(x)` that loads a dataset into the variable it is *given*: `x` is both
405
- * **read** (its value comes from outside) and **defined** by the call; unlike {@link markAsAssignment} we keep the read edge.
473
+ * **read** (its value comes from outside) and **defined** by the call; unlike {@link markAsAssignment} we keep the read edge.
406
474
  */
407
475
  function processDefineArgument(name, args, rootId, data, config) {
408
476
  const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.DefineArgument });
@@ -429,14 +497,15 @@ function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignme
429
497
  }
430
498
  information.graph.addEdge(nid, rootIdOfAssignment, edge_1.EdgeType.DefinedBy);
431
499
  // kinda dirty, but we have to remove existing read edges for the symbol, added by the child
432
- for (const [id] of information.graph.outgoingEdges(nodeToDefine.nodeId) ?? graph_1.NoEdges) {
500
+ for (const [id] of information.graph.edgesFrom(nodeToDefine.nodeId)) {
433
501
  information.graph.removeEdgeType(nodeToDefine.nodeId, id, edge_1.EdgeType.Reads);
434
502
  }
435
503
  }
436
504
  /** Helper for when the _target_ of an assignment is known to be a (single) symbol (i.e. `x <- ...`, not `names(x) <- ...`). */
437
505
  function processAssignmentToSymbol(config) {
438
506
  const { nameOfAssignmentFunction, source, args: [targetArg, sourceArg], targetId, targetName, rootId, data, information, makeMaybe, quoteSource } = config;
439
- const referenceType = checkTargetReferenceType(sourceArg, config.modesForFn);
507
+ const kindOfValue = checkTargetReferenceType(sourceArg, config.modesForFn);
508
+ const referenceType = config.replacement && kindOfValue === identifier_1.ReferenceType.Variable ? identifier_1.ReferenceType.Unknown : kindOfValue;
440
509
  const useSourceIds = [sourceArg.graph.hasVertex(source.info.id) ? source.info.id : sourceArg.entryPoint];
441
510
  const aliases = (0, alias_tracking_1.getAliases)(useSourceIds, information.graph, information.environment);
442
511
  const writeNodes = targetName ? [{
@@ -451,8 +520,9 @@ function processAssignmentToSymbol(config) {
451
520
  if (data.ctx.config.solver.trackEnvironments) {
452
521
  let envState;
453
522
  let returnsEnvState;
454
- const stackEnv = (0, built_in_stack_env_1.stackEnvStateFromSource)(sourceArg, data);
455
- if (isEnvCreatorSource(sourceArg)) {
523
+ const valueEntry = valueEntryPointOf(sourceArg);
524
+ const stackEnv = (0, built_in_stack_env_1.stackEnvStateFromSource)(sourceArg, data, valueEntry);
525
+ if (isEnvCreatorSource(sourceArg, valueEntry)) {
456
526
  envState = (0, built_in_new_env_1.createFreshEnvState)(data, sourceArg);
457
527
  }
458
528
  else if (stackEnv !== undefined) {
@@ -461,21 +531,21 @@ function processAssignmentToSymbol(config) {
461
531
  }
462
532
  else if (r_symbol_1.RSymbol.is(source)) {
463
533
  const defs = resolve_helper_1.Resolve.byNameAndType(source.content, data.environment, identifier_1.ReferenceType.Variable);
464
- envState = defs?.find((d) => d.envState !== undefined)?.envState
534
+ envState = defs?.find(identifier_1.hasEnvState)?.envState
465
535
  ?? (0, built_in_envir_utils_1.findReturnsEnvState)(defs);
466
536
  }
467
537
  else {
468
538
  const entryVertex = sourceArg.graph.getVertex(sourceArg.entryPoint);
469
- if (vertex_1.FunctionCallVertex.hasOrigin(entryVertex, built_in_proc_name_1.BuiltInProcName.List)) {
539
+ if (vertex_1.DfgVertex.hasOrigin(entryVertex, built_in_proc_name_1.BuiltInProcName.List)) {
470
540
  envState = (0, built_in_list_1.resolveListToEnvState)(source, data);
471
541
  }
472
- else if (vertex_1.FunctionCallVertex.hasOrigin(entryVertex, built_in_proc_name_1.BuiltInProcName.ClassGenerator)) {
542
+ else if (vertex_1.DfgVertex.hasOrigin(entryVertex, built_in_proc_name_1.BuiltInProcName.ClassGenerator)) {
473
543
  returnsEnvState = (0, built_in_class_generator_1.resolveClassMethodsToEnvState)(source, data);
474
544
  }
475
- else if (vertex_1.FunctionDefinitionVertex.is(entryVertex) && entryVertex.returnEnvState !== undefined) {
545
+ else if (vertex_1.DfgVertex.isFunctionDefinition(entryVertex) && entryVertex.returnEnvState !== undefined) {
476
546
  returnsEnvState = entryVertex.returnEnvState;
477
547
  }
478
- else if (vertex_1.FunctionCallVertex.is(entryVertex) && entryVertex.name) {
548
+ else if (vertex_1.DfgVertex.isFunctionCall(entryVertex) && entryVertex.name) {
479
549
  envState = (0, built_in_envir_utils_1.findReturnsEnvState)(resolve_helper_1.Resolve.byNameAndType(entryVertex.name, data.environment, identifier_1.ReferenceType.Function));
480
550
  }
481
551
  envState ??= (0, built_in_class_generator_1.resolveConstructorInstanceEnvState)(source, data);
@@ -513,6 +583,9 @@ function processAssignmentToSymbol(config) {
513
583
  }
514
584
  readTargets.push(...readFromSourceWritten);
515
585
  information.environment = (0, overwrite_1.overwriteEnvironment)(sourceArg.environment, targetArg.environment);
586
+ if (config.beforeDefine) {
587
+ information.environment = config.beforeDefine(information);
588
+ }
516
589
  // install assigned variables in environment
517
590
  for (const write of writeNodes) {
518
591
  markAsAssignment(information, write, useSourceIds, rootId, data, config);
@@ -18,6 +18,7 @@ const r_function_call_2 = require("../../../../../../r-bridge/lang-4.x/ast/model
18
18
  const built_in_s_seven_new_generic_1 = require("./built-in-s-seven-new-generic");
19
19
  /** R6's `public` / Reference Class's `methods` argument carrying the class generator's methods. */
20
20
  const MethodListArguments = ['public', 'methods'];
21
+ const FieldListArguments = ['fields', 'private'];
21
22
  /** Processes an `R6Class`/`setRefClass` generator call, tagging it so the assignment layer can record its method list. */
22
23
  function processClassGenerator(name, args, rootId, data, config) {
23
24
  const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.ClassGenerator }).information;
@@ -29,8 +30,15 @@ function resolveClassMethodsToEnvState(source, data) {
29
30
  if (!r_function_call_1.RFunctionCall.isNamed(source)) {
30
31
  return undefined;
31
32
  }
32
- const methodList = source.arguments.find(arg => arg !== r_function_call_2.EmptyArgument && arg.name !== undefined && MethodListArguments.includes(arg.name.content));
33
- return methodList && methodList !== r_function_call_2.EmptyArgument && methodList.value !== undefined ? (0, built_in_list_1.resolveListToEnvState)(methodList.value, data) : undefined;
33
+ let envState;
34
+ for (const [names, values] of [[MethodListArguments, false], [FieldListArguments, true]]) {
35
+ const list = source.arguments.find(arg => arg !== r_function_call_2.EmptyArgument && arg.name !== undefined && names.includes(arg.name.content));
36
+ const resolved = list && list !== r_function_call_2.EmptyArgument && list.value !== undefined
37
+ ? (0, built_in_list_1.resolveListToEnvState)(list.value, envState ? { environment: envState } : data, values)
38
+ : undefined;
39
+ envState = resolved ?? envState;
40
+ }
41
+ return envState;
34
42
  }
35
43
  const ConstructorField = 'new';
36
44
  /** The method env an instance from `<Cls>$new(...)`/`<Cls>[["new"]](...)` carries, from the generator's recorded `returnsEnvState`; `undefined` otherwise. */
@@ -9,7 +9,7 @@ import { type AssignmentConfiguration, type ExtendedAssignmentConfiguration } fr
9
9
  import { type S4UseConfig } from './built-in-s-four';
10
10
  /** Configuration of {@link processClassRelation}. */
11
11
  export interface ClassRelationConfiguration extends S4UseConfig {
12
- /** what the call states about the classes it relates, see {@link classDeclarationOf} */
12
+ /** what the call states about the classes it relates, see {@link classDeclarationOfImpl} */
13
13
  readonly classDecl?: ClassDeclarationConfig;
14
14
  /** when set, the call also binds a name, and is processed as that assignment first (`setValidity`) */
15
15
  readonly assignment?: AssignmentConfiguration;
@@ -0,0 +1,21 @@
1
+ import type { DataflowProcessorInformation } from '../../../../../processor';
2
+ import type { DataflowInformation } from '../../../../../info';
3
+ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
+ import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
+ import { 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 type { FnSig } from '../../../../../environments/built-in-props';
8
+ /**
9
+ * Processes a call listing what an environment holds (`ls`, `objects`), which reads every binding in it: the
10
+ * answer changes with each one, so each has to stay.
11
+ */
12
+ export declare function processEnvContents<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
13
+ sig?: FnSig;
14
+ }): DataflowInformation;
15
+ /**
16
+ * Processes `list2env(x, envir)`, which binds each named element of the list in the target environment; an
17
+ * unresolvable list leaves the call with an unknown side effect rather than with no effect at all.
18
+ */
19
+ export declare function processListToEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
20
+ sig?: FnSig;
21
+ }): DataflowInformation;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processEnvContents = processEnvContents;
4
+ exports.processListToEnv = processListToEnv;
5
+ const known_call_handling_1 = require("../known-call-handling");
6
+ const unpack_argument_1 = require("../argument/unpack-argument");
7
+ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
8
+ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
9
+ const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
10
+ const identifier_1 = require("../../../../../environments/identifier");
11
+ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
12
+ const edge_1 = require("../../../../../graph/edge");
13
+ const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
14
+ const built_in_envir_utils_1 = require("./built-in-envir-utils");
15
+ const resolve_helper_1 = require("../../../../../environments/resolve-helper");
16
+ const define_1 = require("../../../../../environments/define");
17
+ /**
18
+ * Processes a call listing what an environment holds (`ls`, `objects`), which reads every binding in it: the
19
+ * answer changes with each one, so each has to stay.
20
+ */
21
+ function processEnvContents(name, args, rootId, data, config = {}) {
22
+ const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.EnvContents }).information;
23
+ const resolution = (0, built_in_envir_utils_1.resolveFirstEnvirArg)(args, data, config.sig, ['envir', 'name']);
24
+ if (!resolution) {
25
+ return result;
26
+ }
27
+ for (const defs of resolution.envDef.envState.current.memory.values()) {
28
+ for (const def of defs) {
29
+ result.graph.addEdge(rootId, def.nodeId, edge_1.EdgeType.Reads);
30
+ if (def.definedAt !== undefined && def.definedAt !== def.nodeId) {
31
+ result.graph.addEdge(rootId, def.definedAt, edge_1.EdgeType.Reads);
32
+ }
33
+ }
34
+ }
35
+ return result;
36
+ }
37
+ function listLiteralOf(node, data) {
38
+ if (r_function_call_1.RFunctionCall.isNamed(node) && identifier_1.Identifier.getName(node.functionName.content) === 'list'
39
+ && resolve_helper_1.Resolve.isBuiltIn(node.functionName.content, data.environment, identifier_1.ReferenceType.Function)) {
40
+ return node;
41
+ }
42
+ if (!r_symbol_1.RSymbol.is(node)) {
43
+ return undefined;
44
+ }
45
+ for (const def of resolve_helper_1.Resolve.byNameAndType(node.content, data.environment, identifier_1.ReferenceType.Variable) ?? []) {
46
+ for (const value of def.value ?? []) {
47
+ const literal = listLiteralOf(data.completeAst.idMap.get(value), data);
48
+ if (literal !== undefined) {
49
+ return literal;
50
+ }
51
+ }
52
+ }
53
+ return undefined;
54
+ }
55
+ /**
56
+ * Processes `list2env(x, envir)`, which binds each named element of the list in the target environment; an
57
+ * unresolvable list leaves the call with an unknown side effect rather than with no effect at all.
58
+ */
59
+ function processListToEnv(name, args, rootId, data, config = {}) {
60
+ const result = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.ListToEnv }).information;
61
+ const envirRouting = (0, built_in_envir_utils_1.resolveEnvirArgOrAmbiguous)(args, data, config.sig);
62
+ if ((0, built_in_envir_utils_1.unknownIfAmbiguous)(envirRouting, result, rootId)) {
63
+ return result;
64
+ }
65
+ const first = args.length >= 1 && args[0] !== r_function_call_1.EmptyArgument ? (0, unpack_argument_1.unpackArg)(args[0]) : undefined;
66
+ const literal = listLiteralOf(first, data);
67
+ if (literal === undefined) {
68
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(result.graph, result.environment, rootId);
69
+ return result;
70
+ }
71
+ const written = [];
72
+ for (const arg of literal.arguments) {
73
+ if (r_argument_1.RArgument.isEmpty(arg) || arg.name === undefined || arg.value === undefined) {
74
+ continue;
75
+ }
76
+ written.push({
77
+ type: identifier_1.ReferenceType.Variable,
78
+ name: arg.name.content,
79
+ nodeId: arg.info.id,
80
+ definedAt: rootId,
81
+ cds: data.cds
82
+ });
83
+ result.graph.addEdge(arg.info.id, arg.value.info.id, edge_1.EdgeType.DefinedBy);
84
+ result.graph.addEdge(arg.info.id, rootId, edge_1.EdgeType.DefinedBy);
85
+ result.graph.addEdge(rootId, arg.value.info.id, edge_1.EdgeType.Reads);
86
+ }
87
+ if (written.length === 0) {
88
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(result.graph, result.environment, rootId);
89
+ return result;
90
+ }
91
+ let environment = result.environment;
92
+ for (const definition of written) {
93
+ environment = (0, define_1.define)(definition, false, environment);
94
+ }
95
+ const defined = { ...result, environment, out: [...result.out, ...written] };
96
+ const envirResolution = (0, built_in_envir_utils_1.envirOf)(envirRouting);
97
+ return envirResolution ? (0, built_in_envir_utils_1.routeWrittenToEnvir)(defined, envirResolution, rootId, data.environment, rootId) : defined;
98
+ }
99
+ //# sourceMappingURL=built-in-env-contents.js.map
@@ -3,11 +3,14 @@ import type { DataflowProcessorInformation } from '../../../../../processor';
3
3
  import type { DataflowInformation } from '../../../../../info';
4
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
5
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
6
+ import { RFunctionCall } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
6
7
  import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
- import type { IdentifierDefinition, NamedInGraphIdentifierDefinition } from '../../../../../environments/identifier';
8
- import { Identifier } from '../../../../../environments/identifier';
8
+ import type { IdentifierDefinition, NamedInGraphIdentifierDefinition, Identifier } from '../../../../../environments/identifier';
9
9
  import type { REnvironmentInformation } from '../../../../../environments/environment';
10
10
  import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
11
+ import { FnSig } from '../../../../../environments/built-in-props';
12
+ /** The real stack environments a resolution can name, as opposed to a tracked custom env. */
13
+ export type StackEnv = 'global' | 'base';
11
14
  /** Result type for a successful envir-argument resolution. */
12
15
  export interface EnvirResolution<OtherInfo> {
13
16
  /** `data` with its `environment` replaced by the resolved `envState` for in-env lookups. */
@@ -18,8 +21,8 @@ export interface EnvirResolution<OtherInfo> {
18
21
  };
19
22
  /** Node ID of the USE of the envir variable (e.g. the `e` in `envir=e`). */
20
23
  readonly envirNodeId: NodeId;
21
- /** `true` when this resolves to a real stack environment (`globalenv()`/`.GlobalEnv`), not a tracked custom env. */
22
- readonly isStackEnv?: boolean;
24
+ /** which real stack env this resolves to, absent for a tracked custom env; only `'global'` reaches the real frame chain */
25
+ readonly stack?: StackEnv;
23
26
  }
24
27
  /**
25
28
  * The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
@@ -28,20 +31,60 @@ export interface EnvirResolution<OtherInfo> {
28
31
  * instead of a hardcoded formal list, while staying correct -- and graph-invariant -- when no signature is available.
29
32
  */
30
33
  export declare function signatureParamNames<OtherInfo>(data: DataflowProcessorInformation<OtherInfo & ParentInformation>, id: Identifier, fallback: readonly string[]): readonly string[];
31
- /** The constant string a name-position node denotes at construction time (string literal, aliased variable, or a paste-like join of such); `undefined` if any part is dynamic or the paste builtin is user-shadowed. */
34
+ /** desugars `lhs |> rhs(...)` one level to `rhs(lhs, ...)`, for literal-shape inspection */
35
+ export declare function pipedCall<OtherInfo>(node: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): RFunctionCall<OtherInfo & ParentInformation> & {
36
+ named: true;
37
+ } | undefined;
38
+ /**
39
+ * The constant string a name-position node denotes at construction time (string literal, aliased variable, or
40
+ * a paste-like join of such); `undefined` if any part is dynamic or the fold is user-shadowed. Unwraps one
41
+ * leading pipe (the value domain does not desugar those) and otherwise defers entirely to it -- the shadow
42
+ * check, the paste-like fold and its numeric/logical coercion all live there, in {@link resolveAsStringFn}.
43
+ */
32
44
  export declare function resolveConstantString<OtherInfo>(node: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): string | undefined;
33
45
  /** The `returnsEnvState` of the first reaching definition that carries one, else `undefined`. */
34
46
  export declare function findReturnsEnvState(defs: readonly IdentifierDefinition[] | undefined): REnvironmentInformation | undefined;
35
- /** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
36
- export declare function resolveArgToEnvir<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
37
- /** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
38
- export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string): EnvirResolution<OtherInfo> | undefined;
47
+ /**
48
+ * The environment to route into, if flowR can pin one down; `'ambiguous'` when the argument names a value whose
49
+ * identity is out of reach at this point (e.g. a function parameter), so routing anywhere would be unsound.
50
+ */
51
+ export type EnvirArgRouting<OtherInfo> = EnvirResolution<OtherInfo> | 'ambiguous' | undefined;
52
+ /** the environment `routing` pinned down, dropping the ambiguous marker. */
53
+ export declare function envirOf<OtherInfo>(routing: EnvirArgRouting<OtherInfo>): EnvirResolution<OtherInfo> | undefined;
54
+ /** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirArgRouting}. */
55
+ export declare function resolveArgToEnvirOrAmbiguous<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirArgRouting<OtherInfo>;
56
+ /**
57
+ * The slots `envir` falls back to (`envir = as.environment(pos)`), so an environment handed to one of them is the
58
+ * target as well. They are tried after the envir formal itself.
59
+ */
60
+ export declare const EnvirPositionFormals: readonly string[];
61
+ /** Resolves the argument bound to `formal` (default `'envir'`) to an {@link EnvirArgRouting}. */
62
+ export declare function resolveEnvirArgOrAmbiguous<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, sig: FnSig | undefined, formal?: string): EnvirArgRouting<OtherInfo>;
63
+ /**
64
+ * Whether the call supplies an argument for any of `formals` at all, however it resolves. A `pos`/`where` that is
65
+ * not an environment names a position on R's search path (`envir = as.environment(pos)`), which flowR does not
66
+ * model: `assign("x", 2, 1)` writes the global environment, not the calling scope.
67
+ */
68
+ export declare function suppliesArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], sig: FnSig | undefined, formals: readonly string[]): boolean;
69
+ /** The first of `formals` whose argument resolves to a tracked environment; ambiguity is left to the caller. */
70
+ export declare function resolveFirstEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, sig: FnSig | undefined, formals: readonly string[]): EnvirResolution<OtherInfo> | undefined;
71
+ /**
72
+ * Marks `result` as an unknown side effect when the envir argument names a value that cannot be pinned down
73
+ * (e.g. a parameter), so routing the writes anywhere would be a guess; reports whether it did.
74
+ */
75
+ export declare function unknownIfAmbiguous<OtherInfo>(routing: EnvirArgRouting<OtherInfo>, result: DataflowInformation, rootId: NodeId): boolean;
39
76
  /** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
40
77
  export declare function resolveSymbolToEnvir<OtherInfo>(symbolName: Identifier, nodeId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
41
- /** Moves definitions written into a custom environment from the caller's scope into `envDef`'s tracked `envState`, re-defining the holder variable. */
42
- export declare function routeWrittenToCustomEnv(result: DataflowInformation, envDef: NamedInGraphIdentifierDefinition & {
43
- envState: REnvironmentInformation;
44
- }, newDefAt: NodeId, definedAt?: NodeId): DataflowInformation;
78
+ /**
79
+ * Routes writes into a real stack env's frame chain, the same way `<<-` reaches an outer scope.
80
+ * Each write also gets a `Reads` edge back to `rootId`, so slicing does not drop the call that made it.
81
+ */
82
+ export declare function routeWrittenToStackEnv(result: DataflowInformation, into: REnvironmentInformation, rootId: NodeId, definedAt?: NodeId): DataflowInformation;
83
+ /**
84
+ * Routes writes under a resolved `envir=` to the real stack frame or a tracked custom env, and adds the
85
+ * `Reads` edge from `rootId` to the envir argument.
86
+ */
87
+ export declare function routeWrittenToEnvir<OtherInfo>(result: DataflowInformation, resolution: EnvirResolution<OtherInfo>, rootId: NodeId, callerEnvironment: REnvironmentInformation, definedAt?: NodeId): DataflowInformation;
45
88
  /**
46
89
  * The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of
47
90
  * an existing entry (`pos = "package:base"`). Returns `undefined` when there is no such argument, its value is unknown