@eagleoutice/flowr 2.16.6 → 2.16.7

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 (315) hide show
  1. package/README.md +21 -15
  2. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
  3. package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
  4. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
  5. package/abstract-interpretation/data-frame/resolve-args.js +2 -11
  6. package/cli/repl/commands/repl-cfg.js +5 -19
  7. package/cli/repl/commands/repl-code-command.d.ts +10 -0
  8. package/cli/repl/commands/repl-code-command.js +18 -0
  9. package/cli/repl/commands/repl-dataflow.js +34 -59
  10. package/cli/repl/commands/repl-normalize.js +24 -41
  11. package/cli/repl/commands/repl-query.js +10 -17
  12. package/config.js +3 -3
  13. package/control-flow/cfg-dead-code.js +15 -2
  14. package/control-flow/useless-loop.js +1 -2
  15. package/data/r-base-packages.generated.d.ts +1 -1
  16. package/data/r-base-packages.generated.js +3 -3
  17. package/dataflow/environments/ambient-state-name.d.ts +80 -0
  18. package/dataflow/environments/ambient-state-name.js +113 -0
  19. package/dataflow/environments/built-in-eval-name.d.ts +3 -1
  20. package/dataflow/environments/built-in-eval-name.js +2 -0
  21. package/dataflow/environments/built-in-props.d.ts +27 -7
  22. package/dataflow/environments/built-in-props.js +59 -44
  23. package/dataflow/environments/built-in.d.ts +5 -2
  24. package/dataflow/environments/built-in.js +22 -5
  25. package/dataflow/environments/default-builtin-config.d.ts +538 -14
  26. package/dataflow/environments/default-builtin-config.js +189 -123
  27. package/dataflow/environments/environment.d.ts +7 -1
  28. package/dataflow/environments/environment.js +19 -1
  29. package/dataflow/environments/identifier.d.ts +11 -0
  30. package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
  31. package/dataflow/eval/resolve/alias-tracking.js +66 -37
  32. package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
  33. package/dataflow/eval/resolve/resolve-argument.js +23 -11
  34. package/dataflow/eval/resolve/resolve.d.ts +5 -0
  35. package/dataflow/eval/resolve/resolve.js +25 -3
  36. package/dataflow/eval/values/r-value.d.ts +4 -2
  37. package/dataflow/eval/values/r-value.js +3 -1
  38. package/dataflow/eval/values/string/string-constants.d.ts +7 -1
  39. package/dataflow/eval/values/string/string-constants.js +38 -36
  40. package/dataflow/extractor.js +105 -2
  41. package/dataflow/fn/argument-roles.js +22 -8
  42. package/dataflow/fn/function-semantics.d.ts +3 -2
  43. package/dataflow/fn/strict-function.js +13 -2
  44. package/dataflow/graph/df-helper.d.ts +14 -1
  45. package/dataflow/graph/df-helper.js +37 -4
  46. package/dataflow/graph/graph.d.ts +6 -0
  47. package/dataflow/graph/graph.js +6 -0
  48. package/dataflow/internal/linker.d.ts +4 -1
  49. package/dataflow/internal/linker.js +11 -7
  50. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
  52. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -44
  53. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
  54. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
  55. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
  56. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
  58. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
  59. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
  61. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
  62. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
  63. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  64. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +3 -0
  66. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
  67. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
  69. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  70. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
  71. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  72. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
  73. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +42 -0
  74. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
  75. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
  76. package/dataflow/internal/process/functions/call/common.js +3 -4
  77. package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
  78. package/dataflow/internal/process/functions/call/deferred.js +17 -9
  79. package/dataflow/internal/process/functions/call/quoted.js +1 -1
  80. package/documentation/doc-capabilities.js +3 -2
  81. package/documentation/doc-readme.js +1 -2
  82. package/documentation/doc-util/doc-dfg.js +2 -2
  83. package/documentation/doc-util/doc-query.d.ts +3 -1
  84. package/documentation/doc-util/doc-query.js +4 -4
  85. package/documentation/wiki-create-linting-rules.js +1 -1
  86. package/documentation/wiki-linter.js +16 -206
  87. package/documentation/wiki-linting-and-testing.js +31 -64
  88. package/documentation/wiki-query.js +41 -0
  89. package/index.d.ts +1 -0
  90. package/index.js +5 -1
  91. package/linter/linter-format.d.ts +6 -0
  92. package/linter/linter-format.js +10 -0
  93. package/linter/linter-rules.d.ts +155 -103
  94. package/linter/linter-rules.js +2 -0
  95. package/linter/linter-util.d.ts +23 -0
  96. package/linter/linter-util.js +58 -0
  97. package/linter/rules/absolute-path.d.ts +2 -2
  98. package/linter/rules/absolute-path.js +1 -4
  99. package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
  100. package/linter/rules/cmd-check/bogus-return.js +3 -7
  101. package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
  102. package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
  103. package/linter/rules/cmd-check/class-string-comparison.js +3 -7
  104. package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
  105. package/linter/rules/cmd-check/cmd-check-util.js +14 -26
  106. package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
  107. package/linter/rules/cmd-check/compiled-code.js +3 -13
  108. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
  109. package/linter/rules/cmd-check/dependency-declaration.js +6 -7
  110. package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
  111. package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
  112. package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
  113. package/linter/rules/cmd-check/file-checks.d.ts +19 -6
  114. package/linter/rules/cmd-check/file-checks.js +13 -5
  115. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
  116. package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
  117. package/linter/rules/cmd-check/global-environment-modification.js +3 -2
  118. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
  119. package/linter/rules/cmd-check/namespace-tampering.js +9 -9
  120. package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
  121. package/linter/rules/cmd-check/package-data.d.ts +11 -5
  122. package/linter/rules/cmd-check/package-data.js +5 -12
  123. package/linter/rules/cmd-check/package-files.js +4 -10
  124. package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
  125. package/linter/rules/cmd-check/package-hooks.js +10 -8
  126. package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
  127. package/linter/rules/cmd-check/package-metafiles.js +3 -12
  128. package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
  129. package/linter/rules/cmd-check/package-runtime.js +64 -20
  130. package/linter/rules/cmd-check/package-structure.d.ts +11 -5
  131. package/linter/rules/cmd-check/package-structure.js +4 -12
  132. package/linter/rules/cmd-check/rd-files.d.ts +8 -3
  133. package/linter/rules/cmd-check/rd-files.js +4 -14
  134. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
  135. package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
  136. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
  137. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  138. package/linter/rules/dataframe-access-validation.js +5 -8
  139. package/linter/rules/dead-code.d.ts +5 -4
  140. package/linter/rules/dead-code.js +25 -14
  141. package/linter/rules/deprecated-functions.d.ts +3 -3
  142. package/linter/rules/deprecated-functions.js +16 -23
  143. package/linter/rules/file-path-validity.d.ts +2 -2
  144. package/linter/rules/file-path-validity.js +3 -6
  145. package/linter/rules/function-finder-util.d.ts +3 -3
  146. package/linter/rules/function-finder-util.js +7 -14
  147. package/linter/rules/namespace-access.d.ts +2 -2
  148. package/linter/rules/namespace-access.js +6 -9
  149. package/linter/rules/naming-convention.d.ts +2 -2
  150. package/linter/rules/naming-convention.js +1 -4
  151. package/linter/rules/network-functions.d.ts +3 -3
  152. package/linter/rules/no-leaked-credentials.d.ts +2 -2
  153. package/linter/rules/no-leaked-credentials.js +1 -4
  154. package/linter/rules/overwritten-file.d.ts +38 -0
  155. package/linter/rules/overwritten-file.js +102 -0
  156. package/linter/rules/problematic-inputs.d.ts +16 -6
  157. package/linter/rules/problematic-inputs.js +78 -34
  158. package/linter/rules/roxygen-arguments.d.ts +2 -2
  159. package/linter/rules/roxygen-arguments.js +1 -4
  160. package/linter/rules/seeded-randomness.d.ts +3 -3
  161. package/linter/rules/seeded-randomness.js +6 -23
  162. package/linter/rules/software-has-license.d.ts +2 -2
  163. package/linter/rules/software-has-license.js +1 -4
  164. package/linter/rules/software-has-tests.d.ts +2 -2
  165. package/linter/rules/software-has-tests.js +1 -4
  166. package/linter/rules/stop-with-call-arg.d.ts +2 -2
  167. package/linter/rules/stop-with-call-arg.js +4 -11
  168. package/linter/rules/syntactically-valid.d.ts +4 -2
  169. package/linter/rules/syntactically-valid.js +29 -10
  170. package/linter/rules/unclosed-connection.d.ts +2 -2
  171. package/linter/rules/unclosed-connection.js +1 -4
  172. package/linter/rules/undefined-symbol.d.ts +2 -2
  173. package/linter/rules/undefined-symbol.js +25 -22
  174. package/linter/rules/unescaped-arguments.d.ts +2 -2
  175. package/linter/rules/unescaped-arguments.js +1 -4
  176. package/linter/rules/unused-definition.d.ts +2 -2
  177. package/linter/rules/unused-definition.js +37 -25
  178. package/linter/rules/unused-import.d.ts +2 -2
  179. package/linter/rules/unused-import.js +9 -14
  180. package/linter/rules/useless-loop.d.ts +7 -6
  181. package/linter/rules/useless-loop.js +4 -8
  182. package/package.json +5 -3
  183. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  184. package/project/cache/flowr-analyzer-cache.js +15 -11
  185. package/project/context/flowr-analyzer-files-context.d.ts +3 -0
  186. package/project/context/flowr-analyzer-files-context.js +6 -0
  187. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
  188. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
  189. package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
  190. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
  191. package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
  192. package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
  193. package/project/plugins/file-plugins/files/r-session.js +58 -0
  194. package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
  195. package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
  196. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
  197. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
  198. package/project/plugins/plugin-registry.d.ts +2 -1
  199. package/project/plugins/plugin-registry.js +2 -0
  200. package/project/sigdb/spec-query.d.ts +73 -0
  201. package/project/sigdb/spec-query.js +339 -0
  202. package/queries/base-query-format.d.ts +1 -1
  203. package/queries/base-query-format.js +2 -2
  204. package/queries/catalog/absint-query/absint-query-executor.js +3 -6
  205. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
  206. package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
  207. package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
  208. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
  209. package/queries/catalog/config-query/config-query-format.d.ts +0 -1
  210. package/queries/catalog/config-query/config-query-format.js +1 -2
  211. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
  212. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
  213. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
  214. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
  215. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
  216. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
  217. package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
  218. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
  219. package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
  220. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
  221. package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
  222. package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
  223. package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
  224. package/queries/catalog/dice-query/dice-query-executor.js +2 -3
  225. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
  226. package/queries/catalog/files-query/files-query-executor.js +2 -3
  227. package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
  228. package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
  229. package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
  230. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
  231. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
  232. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
  233. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
  234. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
  235. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
  236. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
  237. package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
  238. package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
  239. package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
  240. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
  241. package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
  242. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
  243. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
  244. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
  245. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
  246. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
  247. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
  248. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
  249. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
  250. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
  251. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
  252. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
  253. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  254. package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
  255. package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
  256. package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
  257. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
  258. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
  259. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
  260. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
  261. package/queries/catalog/origin-query/origin-query-executor.js +3 -11
  262. package/queries/catalog/project-query/project-query-executor.js +23 -7
  263. package/queries/catalog/project-query/project-query-format.d.ts +5 -0
  264. package/queries/catalog/project-query/project-query-format.js +20 -2
  265. package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
  266. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
  267. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
  268. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
  269. package/queries/catalog/search-query/search-query-executor.js +2 -3
  270. package/queries/catalog/signature-query/signature-query-executor.js +39 -0
  271. package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
  272. package/queries/catalog/signature-query/signature-query-format.js +15 -1
  273. package/queries/catalog/signature-query/signature-query-render.js +2 -1
  274. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
  275. package/queries/query-function-property.d.ts +28 -0
  276. package/queries/query-function-property.js +48 -0
  277. package/queries/query-meta.d.ts +3 -0
  278. package/queries/query-meta.js +8 -0
  279. package/queries/query.d.ts +13 -18
  280. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
  281. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
  282. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  283. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
  284. package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
  285. package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
  286. package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
  287. package/r-bridge/lang-4.x/ast/model/type.js +3 -0
  288. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
  289. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
  290. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
  291. package/reconstruct/reconstruct.js +35 -1
  292. package/search/search-executor/search-generators.js +1 -1
  293. package/slicing/static/fingerprint.js +7 -3
  294. package/slicing/static/static-slicer.js +6 -0
  295. package/util/assert.js +2 -2
  296. package/util/collections/arrays.d.ts +4 -0
  297. package/util/collections/arrays.js +11 -0
  298. package/util/collections/defaultmap.d.ts +5 -1
  299. package/util/collections/defaultmap.js +6 -1
  300. package/util/files.js +26 -5
  301. package/util/flowr-version.d.ts +10 -0
  302. package/util/flowr-version.js +20 -0
  303. package/util/glob.js +6 -4
  304. package/util/r-regex.d.ts +6 -0
  305. package/util/r-regex.js +17 -0
  306. package/util/text/args.d.ts +5 -0
  307. package/util/text/args.js +28 -22
  308. package/util/text/name-rank.d.ts +2 -0
  309. package/util/text/name-rank.js +3 -1
  310. package/util/text/regex.d.ts +10 -0
  311. package/util/text/regex.js +29 -0
  312. package/util/version.d.ts +1 -6
  313. package/util/version.js +6 -14
  314. package/documentation/doc-util/doc-functions.d.ts +0 -24
  315. package/documentation/doc-util/doc-functions.js +0 -65
@@ -1,7 +1,7 @@
1
1
  import type { BuiltInMemory } from './built-in';
2
2
  import type { BrandedIdentifier, IdentifierDefinition, ReferenceType } from './identifier';
3
3
  import { Identifier } from './identifier';
4
- import type { ControlDependency } from '../info';
4
+ import { ControlDependency } from '../info';
5
5
  import { appendEnvironment } from './append';
6
6
  import { define as defineInEnvironment } from './define';
7
7
  import { overwriteEnvironment } from './overwrite';
@@ -90,6 +90,12 @@ export declare class Environment implements IEnvironment {
90
90
  sameMemoryAs(other: Environment): boolean;
91
91
  /** What `name` holds here; the chain walks of name resolution take this rather than {@link memory}. */
92
92
  lookup(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
93
+ /**
94
+ * The definitions of `name` in this frame and the frames around it, looking into what an emptied frame stood in
95
+ * for (see {@link superMemory}). For `g <- "p"; f <- function(x) UseMethod(g)` the frames are emptied while the
96
+ * body of `f` is analyzed, and this still finds `g <- "p"`.
97
+ */
98
+ lookupLexically(name: BrandedIdentifier): IdentifierDefinition[] | undefined;
93
99
  /** Takes `map` as the bindings, sharing it until something writes. */
94
100
  adoptMap(map: MemoryView): void;
95
101
  /** Takes `frame` as the bindings, owned outright unless `shared`, where a write has to fork it first. */
@@ -33,6 +33,11 @@ function isDefaultBuiltInEnvironment(obj) {
33
33
  return typeof obj === 'object' && obj !== null && (obj.builtInEnv === true);
34
34
  }
35
35
  let environmentIdCounter = 1; // Zero is reserved for built-in environment
36
+ /** whether two definitions are the same one, made by the same node under the same control dependencies */
37
+ function sameDefinition(a, b) {
38
+ const [ca, cb] = [a.cds ?? [], b.cds ?? []];
39
+ return a.nodeId === b.nodeId && a.type === b.type && info_1.ControlDependency.minus(ca, cb).length === 0 && info_1.ControlDependency.minus(cb, ca).length === 0;
40
+ }
36
41
  /** @see REnvironmentInformation */
37
42
  class Environment {
38
43
  id;
@@ -121,6 +126,17 @@ class Environment {
121
126
  lookup(name) {
122
127
  return this.frame.get(name);
123
128
  }
129
+ /**
130
+ * The definitions of `name` in this frame and the frames around it, looking into what an emptied frame stood in
131
+ * for (see {@link superMemory}). For `g <- "p"; f <- function(x) UseMethod(g)` the frames are emptied while the
132
+ * body of `f` is analyzed, and this still finds `g <- "p"`.
133
+ */
134
+ lookupLexically(name) {
135
+ if (this.builtInEnv) {
136
+ return undefined;
137
+ }
138
+ return this.lookup(name) ?? this.superMemory?.get(name) ?? this.parent?.lookupLexically(name);
139
+ }
124
140
  /** Takes `map` as the bindings, sharing it until something writes. */
125
141
  adoptMap(map) {
126
142
  this.frame = frame_memory_1.Frame.of(map);
@@ -255,7 +271,9 @@ class Environment {
255
271
  break;
256
272
  }
257
273
  }
258
- current.writableMemory.set(name, append ? [...current.lookup(name) ?? [], definition] : [definition]);
274
+ const existing = append ? current.lookup(name) ?? [] : [];
275
+ /* a definition the name already has under the same conditions adds nothing, while keeping it would double the list with every merge of two states */
276
+ current.writableMemory.set(name, existing.some(d => sameDefinition(d, definition)) ? existing : [...existing, definition]);
259
277
  return newEnvironment;
260
278
  }
261
279
  /** Definitions within `other` replace those here by name; if all of `other`'s are maybe, they are appended instead (turning existing ones maybe too). Always recurses parents. */
@@ -231,6 +231,7 @@ export declare const enum PkgName {
231
231
  Claddis = "Claddis",
232
232
  Cli = "cli",
233
233
  CohortBuilder = "cohortBuilder",
234
+ Corrplot = "corrplot",
234
235
  Cowplot = "cowplot",
235
236
  Curl = "curl",
236
237
  DataTable = "data.table",
@@ -244,10 +245,13 @@ export declare const enum PkgName {
244
245
  DoSnow = "doSNOW",
245
246
  Dplyr = "dplyr",
246
247
  EbImage = "EBImage",
248
+ Emmeans = "emmeans",
247
249
  ExperimentHub = "ExperimentHub",
248
250
  Expss = "expss",
249
251
  FastUtils = "FastUtils",
250
252
  Feather = "feather",
253
+ Fields = "fields",
254
+ Fixest = "fixest",
251
255
  Foreach = "foreach",
252
256
  Forecats = "forcats",
253
257
  Foreign = "foreign",
@@ -260,6 +264,7 @@ export declare const enum PkgName {
260
264
  FutureCallr = "future.callr",
261
265
  Geomorph = "geomorph",
262
266
  GgPlot2 = "ggplot2",
267
+ GgPubr = "ggpubr",
263
268
  Gifski = "gifski",
264
269
  Glue = "glue",
265
270
  GoogleCloudStorageR = "googleCloudStorageR",
@@ -279,10 +284,12 @@ export declare const enum PkgName {
279
284
  Jsonlite = "jsonlite",
280
285
  Lattice = "lattice",
281
286
  Lim = "LIM",
287
+ Lme4 = "lme4",
282
288
  LmTest = "lmtest",
283
289
  Magick = "magick",
284
290
  Magrittr = "magrittr",
285
291
  Maptools = "maptools",
292
+ Mass = "MASS",
286
293
  Meltr = "meltr",
287
294
  Mirai = "mirai",
288
295
  Msgr = "msgr",
@@ -292,6 +299,7 @@ export declare const enum PkgName {
292
299
  OpenImageR = "OpenImageR",
293
300
  OpenXlsx = "openxlsx",
294
301
  Parallelly = "parallelly",
302
+ Patchwork = "patchwork",
295
303
  PkgLoad = "pkgload",
296
304
  Plyr = "plyr",
297
305
  Png = "png",
@@ -312,6 +320,7 @@ export declare const enum PkgName {
312
320
  Readstata13 = "readstata13",
313
321
  Readxl = "readxl",
314
322
  Remotes = "remotes",
323
+ Reshape2 = "reshape2",
315
324
  Rgdal = "rgdal",
316
325
  Rhdf5 = "rhdf5",
317
326
  Rio = "rio",
@@ -335,6 +344,7 @@ export declare const enum PkgName {
335
344
  ShinyFiles = "shinyFiles",
336
345
  ShinyJs = "shinyjs",
337
346
  SimPhe = "SimPhe",
347
+ SjPlot = "sjPlot",
338
348
  Soda = "SoDA",
339
349
  Sourcetools = "sourcetools",
340
350
  Sqldf = "sqldf",
@@ -342,6 +352,7 @@ export declare const enum PkgName {
342
352
  Stars = "stars",
343
353
  Stringmagic = "stringmagic",
344
354
  Stringr = "stringr",
355
+ Survival = "survival",
345
356
  SvDialogs = "svDialogs",
346
357
  Svglite = "svglite",
347
358
  Sys = "sys",
@@ -22,7 +22,16 @@ export interface ResolveInfo {
22
22
  ctx: ReadOnlyFlowrAnalyzerContext;
23
23
  /** If set, the ids that should not be considered during resolution (=&gt; top) */
24
24
  blocked?: Set<NodeId>;
25
+ /** If set, resolves the parameters of the functions it names for one of their calls only, see {@link CallContext} */
26
+ callContext?: CallContext;
25
27
  }
28
+ /**
29
+ * The call each of some functions is resolved for, keyed by the id of the function definition: a parameter of such a
30
+ * function holds only what that call hands it, or its default when the call hands it nothing. Without one, a
31
+ * parameter holds what any call of its function may hand it, which is what a value in the function body has to
32
+ * expect. With one, `save <- function(n) write.csv(d, n)` writes `"a.csv"` for `save("a.csv")` and nothing else.
33
+ */
34
+ export type CallContext = ReadonlyMap<NodeId, NodeId>;
26
35
  /**
27
36
  * Gets the definitions / aliases of a node
28
37
  *
@@ -59,7 +68,7 @@ export declare function getAliases(sourceIds: readonly NodeId[], dataflow: Dataf
59
68
  * @param blocked - If set, the ids that should not be considered during resolution (=&gt;top)
60
69
  * @useInstead {@link Resolve.toValue}
61
70
  */
62
- export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked }: ResolveInfo): ResolveResult;
71
+ export declare function resolveIdToValue(id: NodeId | RNodeWithParent | undefined, { environment, graph, idMap, full, ctx, resolve, blocked, callContext }: ResolveInfo): ResolveResult;
63
72
  /**
64
73
  * Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant.
65
74
  * @useInstead {@link Resolve.toSingleString}
@@ -75,7 +84,7 @@ export declare function resolveIdToSingleString(id: NodeId | RNodeWithParent | u
75
84
  * @param environment - Environment to use
76
85
  * @returns Value of Identifier or Top
77
86
  */
78
- export declare function trackAliasInEnvironments(identifier: Identifier | undefined, environment: REnvironmentInformation, { blocked, idMap, resolve, ctx, graph }: Omit<ResolveInfo, 'environment'>): ResolveResult;
87
+ export declare function trackAliasInEnvironments(identifier: Identifier | undefined, environment: REnvironmentInformation, { blocked, idMap, resolve, ctx, graph, callContext }: Omit<ResolveInfo, 'environment'>): ResolveResult;
79
88
  /**
80
89
  * Please use {@link resolveIdToValue}
81
90
  *
@@ -85,9 +94,10 @@ export declare function trackAliasInEnvironments(identifier: Identifier | undefi
85
94
  * @param graph - dataflow graph
86
95
  * @param idMap - idmap of dataflow graph
87
96
  * @param blocked - the ids already being resolved, so a cyclic definition stops
97
+ * @param callContext - the calls to resolve parameters for, see {@link CallContext}
88
98
  * @returns Value of node or Top/Bottom
89
99
  */
90
- export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap, blocked?: Set<NodeId>): ResolveResult;
100
+ export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap, blocked?: Set<NodeId>, callContext?: CallContext): ResolveResult;
91
101
  /**
92
102
  * Please use {@link resolveIdToValue}
93
103
  *
@@ -20,9 +20,12 @@ const unknown_side_effect_1 = require("../../graph/unknown-side-effect");
20
20
  const vertex_1 = require("../../graph/vertex");
21
21
  const general_1 = require("../values/general");
22
22
  const r_value_1 = require("../values/r-value");
23
+ const r_access_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
23
24
  const set_constants_1 = require("../values/sets/set-constants");
24
25
  const resolve_1 = require("./resolve");
25
26
  const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
27
+ const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
28
+ const r_pipe_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
26
29
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
27
30
  const resolve_helper_1 = require("../../environments/resolve-helper");
28
31
  const node_value_1 = require("./node-value");
@@ -34,6 +37,38 @@ const AliasHandler = {
34
37
  [vertex_1.VertexType.FunctionDefinition]: () => undefined,
35
38
  [vertex_1.VertexType.VariableDefinition]: () => undefined
36
39
  };
40
+ /** the call the context resolves the function of the parameter named by `id` for, if `id` names a parameter at all */
41
+ function contextCallOf(id, idMap, callContext) {
42
+ if (callContext === undefined) {
43
+ return undefined;
44
+ }
45
+ const node = idMap.get(id);
46
+ const parameter = node?.info.role === "param-n" /* RoleInParent.ParameterName */ && node.info.parent !== undefined ? idMap.get(node.info.parent) : undefined;
47
+ return parameter?.info.parent === undefined ? undefined : callContext.get(parameter.info.parent);
48
+ }
49
+ /** the call an argument value is handed to: the closest call around it, or the call a pipe feeds it into */
50
+ function callOfArgument(value, idMap) {
51
+ for (const parent of model_1.RNode.iterateParents(idMap.get(value), idMap)) {
52
+ if (r_function_call_1.RFunctionCall.is(parent)) {
53
+ return parent.info.id;
54
+ }
55
+ else if (r_pipe_1.RPipe.is(parent)) {
56
+ return parent.rhs.info.id;
57
+ }
58
+ }
59
+ return undefined;
60
+ }
61
+ /**
62
+ * Whether the walk may follow `edge` from the parameter `id` of a function the context resolves for `call`: an argument
63
+ * only if that call hands it, the default only if that call hands none.
64
+ */
65
+ function followsInCall(edges, target, edge, call, idMap) {
66
+ const handed = (t, e) => edge_1.DfEdge.isOnlyType(e, edge_1.EdgeType.DefinedByOnCall) && callOfArgument(t, idMap) === call;
67
+ if (edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedByOnCall)) {
68
+ return handed(target, edge);
69
+ }
70
+ return !edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedBy) || !edges.entries().some(([t, e]) => handed(t, e));
71
+ }
37
72
  function environmentNameOf(sourceId, idMap) {
38
73
  const node = idMap?.get(sourceId);
39
74
  return r_symbol_1.RSymbol.is(node) ? node.content : node?.lexeme;
@@ -133,7 +168,7 @@ function getAliases(sourceIds, dataflow, environment) {
133
168
  * @param blocked - If set, the ids that should not be considered during resolution (=&gt;top)
134
169
  * @useInstead {@link Resolve.toValue}
135
170
  */
136
- function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, resolve = ctx.config.solver.variables, blocked }) {
171
+ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, resolve = ctx.config.solver.variables, blocked, callContext }) {
137
172
  blocked ??= new Set();
138
173
  if (id === undefined) {
139
174
  return r_value_1.Top;
@@ -147,14 +182,14 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
147
182
  switch (node.type) {
148
183
  case type_1.RType.Argument:
149
184
  /* a missing argument (`f(x=)`) carries no value, and it is no symbol to resolve either */
150
- return node.value ? resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve, ctx, blocked }) : r_value_1.Top;
185
+ return node.value ? resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve, ctx, blocked, callContext }) : r_value_1.Top;
151
186
  case type_1.RType.Symbol:
152
187
  if (full) {
153
188
  if (environment) {
154
- return trackAliasInEnvironments(identifier_1.Identifier.toString(node.content), environment, { idMap, resolve, ctx, graph, blocked });
189
+ return trackAliasInEnvironments(identifier_1.Identifier.toString(node.content), environment, { idMap, resolve, ctx, graph, blocked, callContext });
155
190
  }
156
191
  else if (graph && resolve === config_1.VariableResolve.Alias) {
157
- return trackAliasesInGraph(node.info.id, graph, ctx, idMap, blocked);
192
+ return trackAliasesInGraph(node.info.id, graph, ctx, idMap, blocked, callContext);
158
193
  }
159
194
  }
160
195
  return r_value_1.Top;
@@ -164,8 +199,9 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
164
199
  case type_1.RType.BinaryOp:
165
200
  case type_1.RType.UnaryOp:
166
201
  case type_1.RType.ExpressionList:
202
+ case type_1.RType.Access:
167
203
  return (0, set_constants_1.setFrom)((0, resolve_1.resolveNode)({
168
- resolve, node, ctx, environment, graph, idMap, blocked
204
+ resolve, node, ctx, environment, graph, idMap, blocked, callContext
169
205
  }));
170
206
  case type_1.RType.String:
171
207
  case type_1.RType.Number:
@@ -203,7 +239,7 @@ function iteratedElements(value) {
203
239
  * @param environment - Environment to use
204
240
  * @returns Value of Identifier or Top
205
241
  */
206
- function trackAliasInEnvironments(identifier, environment, { blocked, idMap, resolve = config_1.VariableResolve.Alias, ctx, graph }) {
242
+ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, resolve = config_1.VariableResolve.Alias, ctx, graph, callContext }) {
207
243
  if (identifier === undefined) {
208
244
  return r_value_1.Top;
209
245
  }
@@ -220,7 +256,7 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
220
256
  // Tracked in #1207
221
257
  }
222
258
  else if (def.value === undefined && graph !== undefined && !node_id_1.NodeId.isBuiltIn(def.nodeId)) {
223
- const value = trackAliasesInGraph(def.nodeId, graph, ctx, idMap, blocked);
259
+ const value = trackAliasesInGraph(def.nodeId, graph, ctx, idMap, blocked, callContext);
224
260
  if ((0, r_value_1.isTop)(value)) {
225
261
  return r_value_1.Top;
226
262
  }
@@ -236,12 +272,12 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
236
272
  if (definitionOfAlias !== undefined) {
237
273
  /* the environment attempt below marks what it visited as blocked, so the retry starts from a copy */
238
274
  const beforeAttempt = blocked === undefined ? undefined : new Set(blocked);
239
- let value = (0, resolve_1.resolveNode)({ resolve, node: definitionOfAlias, ctx, environment, graph, idMap, blocked });
275
+ let value = (0, resolve_1.resolveNode)({ resolve, node: definitionOfAlias, ctx, environment, graph, idMap, blocked, callContext });
240
276
  if ((0, r_value_1.isTop)(value) && graph?.unknownSideEffects.size === 0) {
241
277
  /* `x <- x + 1`: the environment holds only the definition we are resolving, so its own operand
242
278
  * finds nothing there, while the graph still knows which definition that operand reads. Only
243
279
  * when nothing unknown happened, as then the environment is right to give up */
244
- value = (0, resolve_1.resolveNode)({ resolve, node: definitionOfAlias, ctx, graph, idMap, blocked: beforeAttempt });
280
+ value = (0, resolve_1.resolveNode)({ resolve, node: definitionOfAlias, ctx, graph, idMap, blocked: beforeAttempt, callContext });
245
281
  }
246
282
  if ((0, r_value_1.isTop)(value)) {
247
283
  return r_value_1.Top;
@@ -296,9 +332,6 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
296
332
  current = current.parent;
297
333
  }
298
334
  });
299
- function isNestedInLoop(node, ast) {
300
- return model_1.RNode.iterateParents(node, ast).some(model_1.RLoopConstructs.is);
301
- }
302
335
  function parameterDefaultState(node, idMap, graph) {
303
336
  const parameter = node === undefined ? undefined
304
337
  : [node, ...model_1.RNode.iterateParents(node, idMap)].find(p => p.info.role === "param-v" /* RoleInParent.ParameterDefaultValue */)?.info.parent;
@@ -351,9 +384,10 @@ function callsBuiltInAndDefinition(edges) {
351
384
  * @param graph - dataflow graph
352
385
  * @param idMap - idmap of dataflow graph
353
386
  * @param blocked - the ids already being resolved, so a cyclic definition stops
387
+ * @param callContext - the calls to resolve parameters for, see {@link CallContext}
354
388
  * @returns Value of node or Top/Bottom
355
389
  */
356
- function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
390
+ function trackAliasesInGraph(id, graph, ctx, idMap, blocked, callContext) {
357
391
  if (!graph.get(id)) {
358
392
  return r_value_1.Bottom;
359
393
  }
@@ -362,15 +396,13 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
362
396
  /* a loop makes the walk below give up, yet the variable of a `for` is precisely its sequence, elementwise */
363
397
  const sequence = iteratedSequence(id, graph, idMap);
364
398
  if (sequence !== undefined) {
365
- const value = resolveIdToValue(sequence.info.id, { graph, idMap, ctx, blocked });
399
+ const value = resolveIdToValue(sequence.info.id, { graph, idMap, ctx, blocked, callContext });
366
400
  return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setOf)(iteratedElements(value));
367
401
  }
368
- const start = id;
369
402
  const queue = new visiting_queue_1.VisitingQueue(10);
370
403
  const clean = ctx.env.makeCleanEnv();
371
404
  const cleanFingerprint = ctx.env.getCleanEnvFingerprint();
372
405
  queue.add(id, clean, cleanFingerprint, false);
373
- let forceTop = false;
374
406
  const resultIds = [];
375
407
  /* what a call the walk ended in folds to, see below */
376
408
  const folded = [];
@@ -380,25 +412,8 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
380
412
  if (!vertex) {
381
413
  continue;
382
414
  }
383
- const cds = vertex.cds;
384
- /* a read in a loop sees the same value every round unless a definition in the loop reaches it, which the walk meets */
385
- const loopedRead = id === start && vertex_1.DfgVertex.isUse(vertex);
386
- for (const cd of loopedRead ? [] : cds ?? []) {
387
- const target = graph.idMap?.get(cd.id);
388
- if (target === undefined) {
389
- continue;
390
- }
391
- if (model_1.RLoopConstructs.is(target)) {
392
- forceTop = true;
393
- break;
394
- }
395
- }
396
- if (!forceTop && !loopedRead && (cds?.length === 0 && isNestedInLoop(idMap.get(id), idMap))) {
397
- forceTop = true;
398
- }
399
- if (forceTop) {
400
- break;
401
- }
415
+ /* a definition in a loop may hold the value of any iteration, and the walk collects all of them; one that
416
+ * depends on its own earlier value, like `x <- x + 1`, reaches itself again, is blocked, and stays unknown */
402
417
  const t = vertex.tag;
403
418
  /* a replacement (`df[1] <- v`) defines its target from just a part of it, so what it is defined by is not
404
419
  * the value of the target */
@@ -410,6 +425,16 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
410
425
  continue;
411
426
  }
412
427
  const isFn = t === vertex_1.VertexType.FunctionCall;
428
+ /* an access hands back a part of what it accesses, `x[[2]]` an element of `x`, so its `Returns` edge to `x`
429
+ * says nothing about its value, which only the evaluation of the access knows */
430
+ if (isFn && r_access_1.RAccess.is(idMap.get(id))) {
431
+ const values = (0, general_1.valueSetGuard)(resolveIdToValue(id, { graph, idMap, ctx, resolve: config_1.VariableResolve.Alias, blocked: new Set(blocked), callContext }));
432
+ if (values === undefined || values.elements.some(r_value_1.isTop)) {
433
+ return r_value_1.Top;
434
+ }
435
+ folded.push(...values.elements);
436
+ continue;
437
+ }
413
438
  const outgoingEdges = graph.edgesFrom(id);
414
439
  if (isFn && callsBuiltInAndDefinition(outgoingEdges)) {
415
440
  /* `if(u) toupper <- function(x) "z"`: the call may run the built-in just as well as the definition,
@@ -418,8 +443,12 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
418
443
  return r_value_1.Top;
419
444
  }
420
445
  let foundRetuns = false;
446
+ const inCall = isFn ? undefined : contextCallOf(id, idMap, callContext);
421
447
  // travel all read and defined-by edges
422
448
  for (const [targetId, edge] of outgoingEdges) {
449
+ if (inCall !== undefined && !followsInCall(outgoingEdges, targetId, edge, inCall, idMap)) {
450
+ continue;
451
+ }
423
452
  if (isFn) {
424
453
  if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Returns) || edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedByOnCall) || edge_1.DfEdge.isOnlyType(edge, edge_1.EdgeType.DefinedBy)) {
425
454
  queue.add(targetId, baseEnvironment, cleanFingerprint, false);
@@ -440,7 +469,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
440
469
  if (state === 'overridden') {
441
470
  continue;
442
471
  }
443
- const values = state === 'unknown' ? undefined : (0, general_1.valueSetGuard)(resolveIdToValue(node, { graph, idMap, ctx, resolve: config_1.VariableResolve.Alias, blocked }));
472
+ const values = state === 'unknown' ? undefined : (0, general_1.valueSetGuard)(resolveIdToValue(node, { graph, idMap, ctx, resolve: config_1.VariableResolve.Alias, blocked, callContext }));
444
473
  if (values === undefined || values.elements.some(r_value_1.isTop)) {
445
474
  return r_value_1.Top;
446
475
  }
@@ -448,7 +477,7 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
448
477
  continue;
449
478
  }
450
479
  }
451
- if (forceTop || (resultIds.length === 0 && folded.length === 0)) {
480
+ if (resultIds.length === 0 && folded.length === 0) {
452
481
  return r_value_1.Top;
453
482
  }
454
483
  const values = new Set(folded);
@@ -3,6 +3,7 @@ import type { DataflowGraphVertexFunctionCall } from '../../graph/vertex';
3
3
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
4
  import type { VariableResolve } from '../../../config';
5
5
  import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
6
+ import type { CallContext } from './alias-tracking';
6
7
  /**
7
8
  * The index of the argument of `vertex` that binds the formal `argumentName`, R's matching when the formals are known and the `argumentIndex`-th unnamed argument otherwise.
8
9
  * Pass the `formals` of the call when they are known already, which saves looking them up again.
@@ -10,6 +11,7 @@ import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flow
10
11
  export declare function boundArgumentIndex<Idx extends number | 'unnamed' | undefined>(graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: Idx, argumentName: string, ctx: ReadOnlyFlowrAnalyzerContext, formals?: readonly string[]): Idx | number;
11
12
  /**
12
13
  * Get the values of all arguments matching the criteria, keyed by the id of the argument.
13
- * Pass the `formals` of the call when they are known already, see {@link boundArgumentIndex}.
14
+ * Pass the `formals` of the call when they are known already, see {@link boundArgumentIndex}, and a `callContext` to
15
+ * get the values for particular calls of the functions around the call only.
14
16
  */
15
- export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined, ctx: ReadOnlyFlowrAnalyzerContext, formals?: readonly string[]): Map<NodeId, Set<string | undefined>> | undefined;
17
+ export declare function getArgumentStringValue(variableResolve: VariableResolve, graph: DataflowGraph, vertex: DataflowGraphVertexFunctionCall, argumentIndex: number | 'unnamed' | undefined, argumentName: string | undefined, resolveValue: boolean | 'library' | undefined, ctx: ReadOnlyFlowrAnalyzerContext, formals?: readonly string[], callContext?: CallContext): Map<NodeId, Set<string | undefined>> | undefined;
@@ -47,9 +47,14 @@ function boundArgumentIndex(graph, vertex, argumentIndex, argumentName, ctx, for
47
47
  }
48
48
  /**
49
49
  * Get the values of all arguments matching the criteria, keyed by the id of the argument.
50
- * Pass the `formals` of the call when they are known already, see {@link boundArgumentIndex}.
50
+ * Pass the `formals` of the call when they are known already, see {@link boundArgumentIndex}, and a `callContext` to
51
+ * get the values for particular calls of the functions around the call only.
51
52
  */
52
- function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx, formals) {
53
+ function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx, formals, callContext) {
54
+ return argumentStringValues(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx, formals, callContext, new Set());
55
+ }
56
+ /** {@link getArgumentStringValue}, where `opening` are the calls whose resource is being resolved already, see {@link openedResourceOf} */
57
+ function argumentStringValues(variableResolve, graph, vertex, argumentIndex, argumentName, resolveValue, ctx, formals, callContext, opening) {
53
58
  vertex = (0, applied_arguments_1.appliedArguments)(graph, vertex);
54
59
  if (argumentName && argumentIndex !== 'unnamed') {
55
60
  argumentIndex = boundArgumentIndex(graph, vertex, argumentIndex, argumentName, ctx, formals);
@@ -66,7 +71,7 @@ function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, a
66
71
  }
67
72
  const ref = graph_1.FunctionArgument.getReference(arg);
68
73
  const resolveAs = graph_1.FunctionArgument.isNamed(arg) && resolveValue === 'library' ? true : resolveValue;
69
- const values = argumentValues(variableResolve, graph, vertex, ref, resolveAs, ctx);
74
+ const values = argumentValues(variableResolve, graph, vertex, ref, resolveAs, ctx, callContext, opening);
70
75
  if (ref !== undefined && values !== undefined) {
71
76
  map.set(ref, values);
72
77
  }
@@ -74,22 +79,29 @@ function getArgumentStringValue(variableResolve, graph, vertex, argumentIndex, a
74
79
  return map;
75
80
  }
76
81
  const ref = argumentIndex < vertex.args.length ? graph_1.FunctionArgument.getReference(vertex.args[argumentIndex]) : undefined;
77
- const values = argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx);
82
+ const values = argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx, callContext, opening);
78
83
  return ref === undefined || values === undefined ? undefined : new Map([[ref, values]]);
79
84
  }
80
85
  /** The values of the argument `ref` passes to `vertex`, falling back to the resource a call it reads from opens, and to {@link Unknown}. */
81
- function argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx) {
86
+ function argumentValues(variableResolve, graph, vertex, ref, resolveValue, ctx, callContext, opening) {
82
87
  const valueNode = ref === undefined ? undefined : r_argument_1.RArgument.valueOf(graph.idMap?.get(ref));
83
88
  if (valueNode === undefined) {
84
89
  return undefined;
85
90
  }
86
- const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, resolveValue, ctx)
87
- ?? openedResourceOf(variableResolve, graph, valueNode.info.id, ctx)
91
+ const values = resolveBasedOnConfig(variableResolve, graph, vertex, valueNode, resolveValue, ctx, callContext)
92
+ ?? openedResourceOf(variableResolve, graph, valueNode.info.id, ctx, opening)
88
93
  ?? [dependencies_query_format_1.Unknown];
89
94
  return new Set(values);
90
95
  }
91
- function openedResourceOf(variableResolve, graph, argument, ctx) {
96
+ /**
97
+ * The resource a call that `argument` reads from opens, like the file of `gzfile(f)` in `read.csv(gzfile(f))`. A call
98
+ * already in `opening` is skipped: in `gzfile(d)` with `d` unknown, the provenance of `d` leads back to that very call.
99
+ */
100
+ function openedResourceOf(variableResolve, graph, argument, ctx, opening) {
92
101
  for (const id of df_helper_1.Dataflow.provenance(argument, graph, undefined, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall)) {
102
+ if (opening.has(id)) {
103
+ continue;
104
+ }
93
105
  const vertex = graph.getVertex(id);
94
106
  const info = vertex_1.DfgVertex.isFunctionCall(vertex) ? (0, query_fn_props_1.callFnProps)(id, { graph, environment: ctx.env.cleanEnv() }) : undefined;
95
107
  const resource = info?.sig?.findIndex(([, p]) => (p & built_in_props_1.ArgProp.Resource) !== 0) ?? -1;
@@ -100,7 +112,7 @@ function openedResourceOf(variableResolve, graph, argument, ctx) {
100
112
  /* a handle on data in memory (`textConnection(x)`) names no resource at all */
101
113
  return [dependencies_query_format_1.Constant];
102
114
  }
103
- const values = getArgumentStringValue(variableResolve, graph, vertex, resource, info?.sig?.[resource][0], true, ctx);
115
+ const values = argumentStringValues(variableResolve, graph, vertex, resource, info?.sig?.[resource][0], true, ctx, undefined, undefined, new Set([...opening, id]));
104
116
  return values === undefined ? undefined : [...values.values()].flatMap(v => [...v]).filter(assert_1.isNotUndefined);
105
117
  }
106
118
  return undefined;
@@ -117,7 +129,7 @@ function hasCharacterOnly(variableResolve, graph, vertex, ctx) {
117
129
  const hasFalse = hasTrue && treatAsChar.values().some(set => set === undefined || set.has('FALSE'));
118
130
  return hasTrue && hasFalse ? 'maybe' : hasTrue;
119
131
  }
120
- function resolveBasedOnConfig(variableResolve, graph, vertex, argument, resolveValue, ctx) {
132
+ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, resolveValue, ctx, callContext) {
121
133
  let full = !!resolveValue;
122
134
  if (resolveValue === 'library' && hasCharacterOnly(variableResolve, graph, vertex, ctx) === false) {
123
135
  if (r_symbol_1.RSymbol.is(argument)) {
@@ -126,7 +138,7 @@ function resolveBasedOnConfig(variableResolve, graph, vertex, argument, resolveV
126
138
  full = false;
127
139
  }
128
140
  // this should be evaluated in the callee-context
129
- const resolved = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(argument, { environment: vertex.environment, graph, full, resolve: variableResolve, ctx }));
141
+ const resolved = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(argument, { environment: vertex.environment, graph, full, resolve: variableResolve, ctx, callContext }));
130
142
  const strings = resolved?.elements.map(value => (0, r_value_2.isValue)(value) ? stringsOfValue(value, full) : undefined);
131
143
  return strings?.every(assert_1.isNotUndefined) ? strings.flat() : undefined;
132
144
  }
@@ -12,5 +12,10 @@ export declare function onlyLiterals(node: RNode<ParentInformation>): boolean;
12
12
  export declare function resolveNode(args: BuiltInEvalHandlerArgs): Value;
13
13
  /** Resolves a vector call `c` to a {@link ValueVector}; helper of {@link resolveNode|resolveNode}. */
14
14
  export declare function resolveAsVector(args: BuiltInEvalHandlerArgs): ValueVector | typeof Top;
15
+ /**
16
+ * Resolves `x[[i]]` to the element of `x` at position `i`, so `c("a", "b")[[2]]` is `"b"`. Where `i` is not known,
17
+ * as a loop counter often is not, it is any of the elements; helper of {@link resolveNode}.
18
+ */
19
+ export declare function resolveAsElement(args: BuiltInEvalHandlerArgs): Value;
15
20
  /** Resolves the sequence operator `:` to a {@link ValueVector} of {@link ValueNumber}s; helper of {@link resolveNode}. */
16
21
  export declare function resolveAsSeq(args: BuiltInEvalHandlerArgs): ValueVector<Lift<ValueNumber[]>> | typeof Top;
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.onlyLiterals = onlyLiterals;
4
4
  exports.resolveNode = resolveNode;
5
5
  exports.resolveAsVector = resolveAsVector;
6
+ exports.resolveAsElement = resolveAsElement;
6
7
  exports.resolveAsSeq = resolveAsSeq;
7
8
  const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
+ const r_access_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
10
+ const set_constants_1 = require("../values/sets/set-constants");
11
+ const general_1 = require("../values/general");
8
12
  const r_value_1 = require("../values/r-value");
9
13
  const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
10
14
  const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
@@ -14,7 +18,6 @@ const r_value_2 = require("../../../util/r-value");
14
18
  const logical_constants_1 = require("../values/logical/logical-constants");
15
19
  const r_value_3 = require("../values/r-value");
16
20
  const vector_constants_1 = require("../values/vectors/vector-constants");
17
- const general_1 = require("../values/general");
18
21
  const scalar_constants_1 = require("../values/scalar/scalar-constants");
19
22
  const identifier_1 = require("../../environments/identifier");
20
23
  const df_helper_1 = require("../../graph/df-helper");
@@ -38,7 +41,7 @@ function foldsThroughBuiltIn(name, ctx) {
38
41
  return ctx.env.builtInDefinitionsOf(name).some(d => d.type === identifier_1.ReferenceType.BuiltInFunction && d.evalHandler !== undefined);
39
42
  }
40
43
  /** the node types that may fold through a built-in: calls, operators, and the `(`/`{` groupings */
41
- const EvalNodeTypes = [type_1.RType.FunctionCall, type_1.RType.BinaryOp, type_1.RType.UnaryOp, type_1.RType.ExpressionList];
44
+ const EvalNodeTypes = [type_1.RType.FunctionCall, type_1.RType.BinaryOp, type_1.RType.UnaryOp, type_1.RType.ExpressionList, type_1.RType.Access];
42
45
  /** Whether the operator only combines literals (`1 + 2`), which alone fold while the analysis runs, as a name may still change its value. */
43
46
  function onlyLiterals(node) {
44
47
  return r_binary_op_1.RBinaryOp.is(node) ? onlyLiterals(node.lhs) && onlyLiterals(node.rhs)
@@ -56,7 +59,8 @@ function evalNameOf({ node, graph, environment, ctx }) {
56
59
  }
57
60
  else if (graph === undefined) {
58
61
  const named = r_expression_list_1.RExpressionList.is(node) ? r_expression_list_1.RExpressionList.groupStart(node)?.content
59
- : r_function_call_1.RFunctionCall.calledName(node) ?? ((r_binary_op_1.RBinaryOp.is(node) || r_unary_op_1.RUnaryOp.is(node)) && onlyLiterals(node) ? identifier_1.Identifier.make(node.operator) : undefined);
62
+ : r_access_1.RAccess.is(node) ? identifier_1.Identifier.make(node.operator)
63
+ : r_function_call_1.RFunctionCall.calledName(node) ?? ((r_binary_op_1.RBinaryOp.is(node) || r_unary_op_1.RUnaryOp.is(node)) && onlyLiterals(node) ? identifier_1.Identifier.make(node.operator) : undefined);
60
64
  return named !== undefined && environment !== undefined && foldsThroughBuiltIn(named, ctx)
61
65
  && resolve_helper_1.Resolve.isBuiltIn(named, environment, identifier_1.ReferenceType.Function) ? named : undefined;
62
66
  }
@@ -113,6 +117,24 @@ function resolveAsVector(args) {
113
117
  }
114
118
  return (0, vector_constants_1.vectorFrom)((0, vector_constants_1.flattenVectorElements)(node.arguments.map(arg => arg !== r_function_call_1.EmptyArgument ? resolve_helper_1.Resolve.toValue(arg.value, args) : r_value_3.Top)));
115
119
  }
120
+ /**
121
+ * Resolves `x[[i]]` to the element of `x` at position `i`, so `c("a", "b")[[2]]` is `"b"`. Where `i` is not known,
122
+ * as a loop counter often is not, it is any of the elements; helper of {@link resolveNode}.
123
+ */
124
+ function resolveAsElement(args) {
125
+ const node = args.node;
126
+ const index = r_access_1.RAccess.is(node) && node.operator === '[[' && node.access.length === 1 && node.access[0] !== r_function_call_1.EmptyArgument ? node.access[0].value : undefined;
127
+ if (!r_access_1.RAccess.is(node) || index === undefined) {
128
+ return r_value_3.Top;
129
+ }
130
+ const vectors = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(node.accessed, args))?.elements;
131
+ if (vectors === undefined || vectors.length === 0 || !vectors.every(v => v.type === 'vector' && (0, r_value_3.isValue)(v.elements) && v.elements.length > 0)) {
132
+ return r_value_3.Top;
133
+ }
134
+ const positions = (0, general_1.valueSetGuard)(resolve_helper_1.Resolve.toValue(index, args))?.elements.map(p => r_value_1.RValue.numberOf(p)) ?? [];
135
+ const known = positions.length > 0 && positions.every(p => p !== undefined && Number.isInteger(p)) ? positions : undefined;
136
+ return (0, set_constants_1.setOf)(vectors.flatMap(v => known === undefined ? v.elements : known.flatMap(p => v.elements[p - 1] ?? [])));
137
+ }
116
138
  /** Resolves the sequence operator `:` to a {@link ValueVector} of {@link ValueNumber}s; helper of {@link resolveNode}. */
117
139
  function resolveAsSeq(args) {
118
140
  const operator = args.node;
@@ -1,5 +1,5 @@
1
1
  import type { RNumberValue, RStringValue } from '../../../r-bridge/lang-4.x/convert-values';
2
- import { stringFromLiteral, unescapeRString } from './string/string-constants';
2
+ import { contentOf, stringFromLiteral, unescapeRString } from './string/string-constants';
3
3
  import type { RLogicalValue } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-logical';
4
4
  export declare const Top: {
5
5
  type: symbol;
@@ -79,8 +79,10 @@ export declare function stringifyValue(value: Lift<Value>): string;
79
79
  */
80
80
  export declare const RValue: {
81
81
  readonly name: "RValue";
82
- /** What the escapes in a string literal stand for; see {@link unescapeRString}. */
82
+ /** What the escapes in the content of a string literal stand for; see {@link unescapeRString}. */
83
83
  readonly unescapeString: typeof unescapeRString;
84
+ /** What a string literal stands for, raw or not; see {@link contentOf}. */
85
+ readonly contentOf: typeof contentOf;
84
86
  /** The string a literal stands for, `undefined` when R would not accept it; see {@link stringFromLiteral}. */
85
87
  readonly ofStringLiteral: typeof stringFromLiteral;
86
88
  /** The number the value stands for, collapsing an interval that admits a single one. */
@@ -104,8 +104,10 @@ function stringifyValue(value) {
104
104
  */
105
105
  exports.RValue = {
106
106
  name: 'RValue',
107
- /** What the escapes in a string literal stand for; see {@link unescapeRString}. */
107
+ /** What the escapes in the content of a string literal stand for; see {@link unescapeRString}. */
108
108
  unescapeString: string_constants_1.unescapeRString,
109
+ /** What a string literal stands for, raw or not; see {@link contentOf}. */
110
+ contentOf: string_constants_1.contentOf,
109
111
  /** The string a literal stands for, `undefined` when R would not accept it; see {@link stringFromLiteral}. */
110
112
  ofStringLiteral: string_constants_1.stringFromLiteral,
111
113
  /** The number the value stands for, collapsing an interval that admits a single one. */