@eagleoutice/flowr 2.17.4 → 2.17.5

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 (544) hide show
  1. package/README.md +13 -52
  2. package/abstract-interpretation/absint-inference.js +1 -2
  3. package/abstract-interpretation/data-frame/arguments.d.ts +14 -3
  4. package/abstract-interpretation/data-frame/arguments.js +34 -0
  5. package/abstract-interpretation/data-frame/dataframe-semantics.js +7 -15
  6. package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -2
  7. package/abstract-interpretation/data-frame/semantics.d.ts +8 -1
  8. package/abstract-interpretation/data-frame/semantics.js +14 -6
  9. package/abstract-interpretation/domains/state-abstract-domain.js +28 -18
  10. package/abstract-interpretation/domains/state-map.d.ts +43 -0
  11. package/abstract-interpretation/domains/state-map.js +147 -0
  12. package/benchmark/slicer.d.ts +1 -1
  13. package/benchmark/slicer.js +8 -7
  14. package/cli/repl/commands/repl-dataflow.js +5 -5
  15. package/cli/repl/commands/repl-execute.js +3 -2
  16. package/cli/repl/commands/repl-parse.js +2 -1
  17. package/cli/repl/print-version.d.ts +1 -1
  18. package/cli/repl/print-version.js +2 -1
  19. package/cli/repl/server/connection.d.ts +1 -1
  20. package/cli/repl/server/connection.js +7 -9
  21. package/cli/slicer-app.js +2 -1
  22. package/clones/algorithms/baxter-ast.d.ts +33 -0
  23. package/clones/algorithms/baxter-ast.js +70 -0
  24. package/clones/algorithms/greedy-string-tiling.d.ts +17 -0
  25. package/clones/algorithms/greedy-string-tiling.js +56 -0
  26. package/clones/algorithms/winnowing.d.ts +27 -0
  27. package/clones/algorithms/winnowing.js +66 -0
  28. package/clones/clone-ast.d.ts +75 -0
  29. package/clones/clone-ast.js +174 -0
  30. package/clones/clone-dataflow.d.ts +11 -0
  31. package/clones/clone-dataflow.js +83 -0
  32. package/clones/clone-detector.d.ts +116 -0
  33. package/clones/clone-detector.js +200 -0
  34. package/clones/clone-index.d.ts +54 -0
  35. package/clones/clone-index.js +56 -0
  36. package/config.d.ts +21 -2
  37. package/config.js +7 -1
  38. package/control-flow/basic-cfg-guided-visitor.js +1 -2
  39. package/control-flow/happens-before.d.ts +2 -0
  40. package/control-flow/happens-before.js +15 -9
  41. package/control-flow/simple-visitor.js +2 -4
  42. package/core/steps/all/core/00-parse.js +2 -1
  43. package/core/steps/all/core/01-parse-tree-sitter.js +2 -1
  44. package/core/steps/all/core/10-normalize.js +2 -1
  45. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -1
  46. package/core/steps/all/static-slicing/00-slice.js +2 -1
  47. package/core/steps/all/static-slicing/10-reconstruct.js +2 -1
  48. package/core/steps/pipeline/create-pipeline.js +1 -2
  49. package/core/steps/pipeline/default-pipelines.d.ts +1 -1
  50. package/core/steps/pipeline/default-pipelines.js +5 -4
  51. package/core/steps/pipeline-step.d.ts +3 -1
  52. package/core/steps/pipeline-step.js +5 -0
  53. package/data/r-base-primitives.generated.d.ts +2 -1
  54. package/dataflow/cluster.js +1 -2
  55. package/dataflow/environments/ambient-state-name.d.ts +14 -22
  56. package/dataflow/environments/ambient-state-name.js +4 -18
  57. package/dataflow/environments/apply-kill.d.ts +9 -20
  58. package/dataflow/environments/apply-kill.js +51 -25
  59. package/dataflow/environments/built-in-config.d.ts +7 -15
  60. package/dataflow/environments/built-in-config.js +15 -16
  61. package/dataflow/environments/built-in-eval-name.d.ts +5 -6
  62. package/dataflow/environments/built-in-eval-name.js +4 -5
  63. package/dataflow/environments/built-in-kinds.d.ts +111 -0
  64. package/dataflow/environments/built-in-kinds.js +35 -0
  65. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  66. package/dataflow/environments/built-in-proc-name.js +11 -0
  67. package/dataflow/environments/built-in-props.d.ts +62 -175
  68. package/dataflow/environments/built-in-props.js +42 -154
  69. package/dataflow/environments/built-in.d.ts +37 -73
  70. package/dataflow/environments/built-in.js +41 -62
  71. package/dataflow/environments/data-masking-functions.d.ts +2 -2
  72. package/dataflow/environments/default-builtin-config/base-functions.d.ts +7 -0
  73. package/dataflow/environments/default-builtin-config/base-functions.js +339 -0
  74. package/dataflow/environments/default-builtin-config/base-language.d.ts +3 -0
  75. package/dataflow/environments/default-builtin-config/base-language.js +66 -0
  76. package/dataflow/environments/default-builtin-config/base-operators.d.ts +58 -0
  77. package/dataflow/environments/default-builtin-config/base-operators.js +169 -0
  78. package/dataflow/environments/default-builtin-config/database-access.d.ts +3 -0
  79. package/dataflow/environments/default-builtin-config/database-access.js +16 -0
  80. package/dataflow/environments/default-builtin-config/define-helpers.d.ts +45 -0
  81. package/dataflow/environments/default-builtin-config/define-helpers.js +50 -0
  82. package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +3 -0
  83. package/dataflow/environments/default-builtin-config/dev-tooling.js +63 -0
  84. package/dataflow/environments/default-builtin-config/file-io.d.ts +3 -0
  85. package/dataflow/environments/default-builtin-config/file-io.js +81 -0
  86. package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +3 -0
  87. package/dataflow/environments/default-builtin-config/graphics-devices.js +57 -0
  88. package/dataflow/environments/default-builtin-config/index.d.ts +18 -0
  89. package/dataflow/environments/default-builtin-config/index.js +114 -0
  90. package/dataflow/environments/default-builtin-config/media-formats.d.ts +3 -0
  91. package/dataflow/environments/default-builtin-config/media-formats.js +41 -0
  92. package/dataflow/environments/default-builtin-config/misc-packages.d.ts +3 -0
  93. package/dataflow/environments/default-builtin-config/misc-packages.js +18 -0
  94. package/dataflow/environments/default-builtin-config/network-access.d.ts +3 -0
  95. package/dataflow/environments/default-builtin-config/network-access.js +47 -0
  96. package/dataflow/environments/default-builtin-config/object-systems.d.ts +3 -0
  97. package/dataflow/environments/default-builtin-config/object-systems.js +39 -0
  98. package/dataflow/environments/default-builtin-config/package-data-table.d.ts +3 -0
  99. package/dataflow/environments/default-builtin-config/package-data-table.js +18 -0
  100. package/dataflow/environments/default-builtin-config/package-spatial.d.ts +3 -0
  101. package/dataflow/environments/default-builtin-config/package-spatial.js +32 -0
  102. package/dataflow/environments/default-builtin-config/package-tidyverse.d.ts +3 -0
  103. package/dataflow/environments/default-builtin-config/package-tidyverse.js +96 -0
  104. package/dataflow/environments/default-builtin-config/package-utils.d.ts +3 -0
  105. package/dataflow/environments/default-builtin-config/package-utils.js +35 -0
  106. package/dataflow/environments/default-builtin-config/package-withr.d.ts +3 -0
  107. package/dataflow/environments/default-builtin-config/package-withr.js +41 -0
  108. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +3 -0
  109. package/dataflow/environments/default-builtin-config/parallel-execution.js +31 -0
  110. package/dataflow/environments/default-builtin-config/session-interactive.d.ts +3 -0
  111. package/dataflow/environments/default-builtin-config/session-interactive.js +31 -0
  112. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +267 -0
  113. package/dataflow/environments/default-builtin-config/shared-configs.js +483 -0
  114. package/dataflow/environments/default-builtin-config/shared-signatures.d.ts +21 -0
  115. package/dataflow/environments/default-builtin-config/shared-signatures.js +32 -0
  116. package/dataflow/environments/default-builtin-config/statistics.d.ts +3 -0
  117. package/dataflow/environments/default-builtin-config/statistics.js +32 -0
  118. package/dataflow/environments/default-builtin-config/unit-testing.d.ts +3 -0
  119. package/dataflow/environments/default-builtin-config/unit-testing.js +13 -0
  120. package/dataflow/environments/environment.d.ts +28 -52
  121. package/dataflow/environments/environment.js +24 -71
  122. package/dataflow/environments/group-generics.d.ts +12 -19
  123. package/dataflow/environments/group-generics.js +17 -14
  124. package/dataflow/environments/identifier.d.ts +72 -427
  125. package/dataflow/environments/identifier.js +34 -145
  126. package/dataflow/environments/pkg-name.d.ts +197 -0
  127. package/dataflow/environments/pkg-name.js +3 -0
  128. package/dataflow/environments/query-fn-props.d.ts +27 -76
  129. package/dataflow/environments/query-fn-props.js +34 -95
  130. package/dataflow/environments/resolve-by-name.d.ts +6 -16
  131. package/dataflow/environments/resolve-by-name.js +23 -35
  132. package/dataflow/environments/scoping.d.ts +5 -5
  133. package/dataflow/environments/scoping.js +13 -5
  134. package/dataflow/eval/resolve/alias-tracking.d.ts +31 -68
  135. package/dataflow/eval/resolve/alias-tracking.js +611 -126
  136. package/dataflow/eval/resolve/match-arguments.d.ts +5 -3
  137. package/dataflow/eval/resolve/resolve-argument.d.ts +11 -11
  138. package/dataflow/eval/resolve/resolve-argument.js +25 -30
  139. package/dataflow/eval/resolve/resolve-field.d.ts +10 -0
  140. package/dataflow/eval/resolve/resolve-field.js +127 -0
  141. package/dataflow/eval/resolve/resolve-replacement.d.ts +10 -0
  142. package/dataflow/eval/resolve/resolve-replacement.js +80 -0
  143. package/dataflow/eval/resolve/resolve-strings.d.ts +2 -2
  144. package/dataflow/eval/resolve/resolve.d.ts +13 -10
  145. package/dataflow/eval/resolve/resolve.js +81 -32
  146. package/dataflow/eval/values/general.d.ts +6 -24
  147. package/dataflow/eval/values/general.js +12 -29
  148. package/dataflow/eval/values/lists/list-constants.d.ts +11 -0
  149. package/dataflow/eval/values/lists/list-constants.js +65 -0
  150. package/dataflow/eval/values/r-value.d.ts +20 -23
  151. package/dataflow/eval/values/r-value.js +22 -17
  152. package/dataflow/extractor.d.ts +2 -10
  153. package/dataflow/extractor.js +100 -46
  154. package/dataflow/fn/argument-roles.d.ts +2 -4
  155. package/dataflow/fn/argument-roles.js +49 -23
  156. package/dataflow/fn/class-declaration.d.ts +36 -52
  157. package/dataflow/fn/class-declaration.js +22 -56
  158. package/dataflow/fn/condition-handlers.d.ts +2 -1
  159. package/dataflow/fn/dispatch.d.ts +70 -0
  160. package/dataflow/fn/dispatch.js +434 -0
  161. package/dataflow/fn/exceptions-of-function.d.ts +1 -2
  162. package/dataflow/fn/exceptions-of-function.js +36 -106
  163. package/dataflow/fn/frame-reflection.d.ts +1 -3
  164. package/dataflow/fn/frame-reflection.js +8 -16
  165. package/dataflow/fn/function-props.d.ts +2 -5
  166. package/dataflow/fn/function-props.js +27 -36
  167. package/dataflow/fn/function-semantics.d.ts +14 -26
  168. package/dataflow/fn/function-semantics.js +4 -18
  169. package/dataflow/fn/higher-order-function.js +2 -4
  170. package/dataflow/fn/strict-function.d.ts +10 -35
  171. package/dataflow/fn/strict-function.js +126 -138
  172. package/dataflow/graph/ambient-access.d.ts +51 -0
  173. package/dataflow/graph/ambient-access.js +80 -0
  174. package/dataflow/graph/call-graph.d.ts +9 -29
  175. package/dataflow/graph/call-graph.js +17 -41
  176. package/dataflow/graph/closure-frames.d.ts +46 -0
  177. package/dataflow/graph/closure-frames.js +225 -0
  178. package/dataflow/graph/dataflowgraph-builder.d.ts +25 -96
  179. package/dataflow/graph/dataflowgraph-builder.js +29 -97
  180. package/dataflow/graph/df-helper.d.ts +48 -188
  181. package/dataflow/graph/df-helper.js +107 -208
  182. package/dataflow/graph/diff-dataflow-graph.d.ts +5 -15
  183. package/dataflow/graph/diff-dataflow-graph.js +25 -25
  184. package/dataflow/graph/edge.js +1 -1
  185. package/dataflow/graph/graph-helper.d.ts +10 -46
  186. package/dataflow/graph/graph-helper.js +16 -50
  187. package/dataflow/graph/graph.d.ts +44 -97
  188. package/dataflow/graph/graph.js +83 -79
  189. package/dataflow/graph/match-args.d.ts +21 -88
  190. package/dataflow/graph/match-args.js +284 -97
  191. package/dataflow/graph/vertex.d.ts +101 -128
  192. package/dataflow/graph/vertex.js +23 -20
  193. package/dataflow/hooks.d.ts +7 -14
  194. package/dataflow/hooks.js +15 -13
  195. package/dataflow/info.d.ts +2 -17
  196. package/dataflow/internal/dispatch-linking.d.ts +71 -0
  197. package/dataflow/internal/dispatch-linking.js +332 -0
  198. package/dataflow/internal/linker.d.ts +48 -50
  199. package/dataflow/internal/linker.js +457 -155
  200. package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
  201. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -14
  202. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -46
  203. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +7 -6
  204. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +10 -9
  205. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +23 -75
  206. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +263 -97
  207. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +10 -7
  208. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +66 -45
  209. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +15 -19
  210. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +82 -62
  211. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -4
  212. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -2
  213. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +2 -2
  214. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +3 -2
  215. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +15 -0
  216. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +416 -0
  217. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +37 -54
  218. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +192 -111
  219. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +4 -3
  220. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +60 -13
  221. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -3
  222. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +80 -76
  223. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.d.ts +1 -7
  224. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -13
  225. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +4 -8
  226. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +436 -140
  227. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +18 -10
  228. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +90 -12
  229. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -5
  230. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -14
  231. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +9 -8
  232. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -7
  233. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -2
  234. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +3 -5
  235. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -6
  236. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +9 -24
  237. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +10 -6
  238. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +5 -6
  239. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -4
  240. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -4
  241. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +8 -11
  242. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -5
  243. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +20 -28
  244. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +17 -4
  245. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +117 -4
  246. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +5 -3
  247. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  248. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +8 -4
  249. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +18 -29
  250. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -25
  251. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +31 -35
  252. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +4 -18
  253. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +13 -19
  254. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +18 -16
  255. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +130 -65
  256. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -1
  257. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +38 -30
  258. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +584 -114
  259. package/dataflow/internal/process/functions/call/common.d.ts +8 -24
  260. package/dataflow/internal/process/functions/call/common.js +24 -24
  261. package/dataflow/internal/process/functions/call/deferred.d.ts +7 -27
  262. package/dataflow/internal/process/functions/call/deferred.js +6 -27
  263. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -26
  264. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -16
  265. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -4
  266. package/dataflow/internal/process/functions/call/named-call-handling.js +14 -35
  267. package/dataflow/internal/process/functions/call/nse.d.ts +2 -9
  268. package/dataflow/internal/process/functions/call/nse.js +6 -13
  269. package/dataflow/internal/process/functions/call/quoted.d.ts +4 -15
  270. package/dataflow/internal/process/functions/call/quoted.js +26 -62
  271. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +3 -6
  272. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +29 -11
  273. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  274. package/dataflow/internal/program-order.d.ts +3 -10
  275. package/dataflow/internal/program-order.js +19 -10
  276. package/dataflow/origin/dfg-get-origin.js +2 -1
  277. package/documentation/data/faq/faqs.js +16 -1
  278. package/documentation/data/interface/doc-writing-code.js +5 -7
  279. package/documentation/doc-capabilities.js +3 -3
  280. package/documentation/doc-readme.js +1 -1
  281. package/documentation/doc-util/doc-code.d.ts +0 -5
  282. package/documentation/doc-util/doc-code.js +2 -22
  283. package/documentation/doc-util/doc-query.d.ts +1 -2
  284. package/documentation/doc-util/doc-query.js +4 -5
  285. package/documentation/doc-util/doc-search.js +1 -1
  286. package/documentation/wiki-analyzer.js +4 -3
  287. package/documentation/wiki-core.js +5 -5
  288. package/documentation/wiki-dataflow-graph.js +6 -0
  289. package/documentation/wiki-interface.js +2 -1
  290. package/documentation/wiki-linter.js +15 -3
  291. package/documentation/wiki-linting-and-testing.js +15 -2
  292. package/documentation/wiki-query.js +111 -29
  293. package/index.d.ts +3 -1
  294. package/index.js +6 -3
  295. package/linter/linter-executor.js +1 -1
  296. package/linter/linter-rules.d.ts +37 -8
  297. package/linter/linter-rules.js +8 -1
  298. package/linter/linter-util.d.ts +3 -3
  299. package/linter/linter-util.js +1 -1
  300. package/linter/rules/cmd-check/bogus-return.d.ts +2 -1
  301. package/linter/rules/cmd-check/call-arguments.d.ts +3 -2
  302. package/linter/rules/cmd-check/call-arguments.js +5 -5
  303. package/linter/rules/cmd-check/cmd-check-util.d.ts +9 -8
  304. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -1
  305. package/linter/rules/cmd-check/dependency-declaration.js +1 -1
  306. package/linter/rules/cmd-check/documentation-mismatch.d.ts +3 -2
  307. package/linter/rules/cmd-check/documentation-mismatch.js +2 -1
  308. package/linter/rules/cmd-check/file-checks.d.ts +2 -2
  309. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -1
  310. package/linter/rules/cmd-check/global-environment-modification.d.ts +6 -5
  311. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -1
  312. package/linter/rules/cmd-check/non-ascii-code.js +1 -1
  313. package/linter/rules/cmd-check/package-files.d.ts +2 -2
  314. package/linter/rules/cmd-check/package-hooks.d.ts +5 -4
  315. package/linter/rules/cmd-check/package-runtime.js +2 -2
  316. package/linter/rules/cmd-check/rd-files.js +2 -1
  317. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +3 -2
  318. package/linter/rules/cmd-check/s-three-method-consistency.js +2 -1
  319. package/linter/rules/code-clones.d.ts +57 -0
  320. package/linter/rules/code-clones.js +53 -0
  321. package/linter/rules/deprecated-functions.js +3 -6
  322. package/linter/rules/file-path-validity.js +6 -4
  323. package/linter/rules/function-finder-util.d.ts +4 -2
  324. package/linter/rules/naming-convention.d.ts +6 -5
  325. package/linter/rules/naming-convention.js +2 -3
  326. package/linter/rules/no-leaked-credentials.d.ts +2 -1
  327. package/linter/rules/no-leaked-credentials.js +1 -1
  328. package/linter/rules/overwritten-file.d.ts +2 -1
  329. package/linter/rules/problematic-inputs.d.ts +2 -1
  330. package/linter/rules/problematic-inputs.js +3 -3
  331. package/linter/rules/process-state-in-session.d.ts +7 -6
  332. package/linter/rules/process-state-in-session.js +1 -1
  333. package/linter/rules/roxygen-arguments.d.ts +1 -1
  334. package/linter/rules/secret-exfiltration.js +1 -1
  335. package/linter/rules/seeded-randomness.d.ts +3 -3
  336. package/linter/rules/unclosed-connection.js +1 -2
  337. package/linter/rules/undefined-symbol-util.d.ts +3 -2
  338. package/linter/rules/undefined-symbol.d.ts +3 -2
  339. package/linter/rules/unescaped-arguments.d.ts +1 -1
  340. package/linter/rules/unescaped-arguments.js +6 -8
  341. package/linter/rules/unused-definition.d.ts +4 -3
  342. package/linter/rules/unused-definition.js +10 -12
  343. package/linter/rules/unused-import.d.ts +6 -5
  344. package/package.json +1 -1
  345. package/project/attached-packages.d.ts +5 -4
  346. package/project/cache/flowr-analyzer-cache.d.ts +14 -1
  347. package/project/cache/flowr-analyzer-cache.js +40 -3
  348. package/project/context/flowr-analyzer-dependencies-context.d.ts +12 -12
  349. package/project/context/flowr-analyzer-environment-context.d.ts +3 -3
  350. package/project/context/flowr-analyzer-environment-context.js +3 -3
  351. package/project/context/flowr-analyzer-functions-context.d.ts +9 -7
  352. package/project/context/flowr-analyzer-gas-context.d.ts +25 -0
  353. package/project/context/flowr-analyzer-gas-context.js +34 -4
  354. package/project/dependency-version-space.d.ts +30 -29
  355. package/project/dependency-version-space.js +1 -2
  356. package/project/flowr-analyzer-builder.d.ts +2 -3
  357. package/project/flowr-analyzer.d.ts +35 -3
  358. package/project/flowr-analyzer.js +11 -5
  359. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +15 -14
  360. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +5 -4
  361. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +1 -1
  362. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -1
  363. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -3
  364. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +2 -1
  365. package/project/plugins/package-version-plugins/package.d.ts +6 -5
  366. package/project/sigdb/build.js +1 -1
  367. package/project/sigdb/decode.d.ts +8 -7
  368. package/project/sigdb/decode.js +1 -2
  369. package/project/sigdb/dict.d.ts +2 -1
  370. package/project/sigdb/dict.js +2 -2
  371. package/project/sigdb/index-format.d.ts +2 -1
  372. package/project/sigdb/manifest.d.ts +1 -1
  373. package/project/sigdb/memory-source.d.ts +18 -17
  374. package/project/sigdb/on-demand/package-sources.d.ts +4 -3
  375. package/project/sigdb/on-demand/recoverer.d.ts +2 -1
  376. package/project/sigdb/on-demand/remote-sources.d.ts +2 -1
  377. package/project/sigdb/reader.d.ts +85 -80
  378. package/project/sigdb/reader.js +0 -4
  379. package/project/sigdb/schema.d.ts +9 -8
  380. package/project/sigdb/signature-db.d.ts +6 -6
  381. package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +6 -0
  382. package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +50 -0
  383. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +54 -0
  384. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +45 -0
  385. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +2 -1
  386. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  387. package/queries/catalog/call-graph-query/expand-library-internals.d.ts +3 -2
  388. package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +6 -0
  389. package/queries/catalog/code-clones-query/code-clones-query-executor.js +38 -0
  390. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +54 -0
  391. package/queries/catalog/code-clones-query/code-clones-query-format.js +73 -0
  392. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +3 -3
  393. package/queries/catalog/dependencies-query/data-flow.d.ts +5 -4
  394. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +5 -2
  395. package/queries/catalog/dependencies-query/dependencies-query-executor.js +5 -5
  396. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -2
  397. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  398. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -4
  399. package/queries/catalog/dependencies-query/implicit-echo.js +2 -1
  400. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -0
  401. package/queries/catalog/dice-query/dice-query-format.js +1 -0
  402. package/queries/catalog/does-call-query/does-call-query-executor.js +1 -2
  403. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -0
  404. package/queries/catalog/does-call-query/does-call-query-format.js +1 -0
  405. package/queries/catalog/function-info-query/function-info-query-format.d.ts +2 -1
  406. package/queries/catalog/function-info-query/function-origin.d.ts +3 -2
  407. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -3
  408. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +5 -4
  409. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
  410. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
  411. package/queries/catalog/input-sources-query/input-sources-query-executor.js +7 -3
  412. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +9 -9
  413. package/queries/catalog/input-sources-query/simple-input-classifier.js +1 -1
  414. package/queries/catalog/linter-query/linter-query-executor.js +4 -1
  415. package/queries/catalog/linter-query/linter-query-format.js +3 -2
  416. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -0
  417. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  418. package/queries/catalog/project-query/project-query-format.d.ts +2 -1
  419. package/queries/catalog/provenance-query/provenance-query-format.d.ts +1 -0
  420. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  421. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -0
  422. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  423. package/queries/catalog/signature-query/signature-query-executor.d.ts +9 -6
  424. package/queries/catalog/signature-query/signature-query-executor.js +14 -15
  425. package/queries/catalog/signature-query/signature-query-format.d.ts +21 -20
  426. package/queries/catalog/signature-query/signature-query-render.js +1 -1
  427. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  428. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +9 -5
  429. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  430. package/queries/query-function-filter.d.ts +1 -1
  431. package/queries/query.d.ts +59 -8
  432. package/queries/query.js +59 -37
  433. package/r-bridge/data/data.d.ts +39 -28
  434. package/r-bridge/data/data.js +37 -28
  435. package/r-bridge/lang-4.x/ast/model/model.d.ts +10 -1
  436. package/r-bridge/lang-4.x/ast/model/model.js +30 -0
  437. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +21 -0
  438. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +25 -2
  439. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
  440. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -2
  441. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +2 -2
  442. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  443. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  444. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  445. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  446. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -3
  447. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  448. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  449. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  450. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  451. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  452. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  453. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  454. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  455. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  456. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +5 -6
  457. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +2 -7
  458. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  459. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -2
  460. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +2 -2
  461. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  462. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -5
  463. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +7 -2
  464. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +14 -6
  465. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +1 -1
  466. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +2 -2
  467. package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -1
  468. package/r-bridge/lang-4.x/ast/model/type.js +1 -1
  469. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -2
  470. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -2
  471. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  472. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +3 -2
  473. package/r-bridge/parser.d.ts +8 -2
  474. package/r-bridge/parser.js +6 -0
  475. package/r-bridge/shell-executor.d.ts +2 -2
  476. package/r-bridge/shell-executor.js +3 -2
  477. package/r-bridge/shell.d.ts +2 -2
  478. package/r-bridge/shell.js +3 -2
  479. package/reconstruct/auto-select/magic-comments.js +1 -1
  480. package/reconstruct/reconstruct.d.ts +0 -5
  481. package/reconstruct/reconstruct.js +6 -5
  482. package/search/flowr-search-builder.d.ts +14 -0
  483. package/search/flowr-search-builder.js +7 -0
  484. package/search/flowr-search-executor.js +2 -2
  485. package/search/flowr-search-filters.js +8 -9
  486. package/search/flowr-search.js +1 -1
  487. package/search/search-executor/search-enrichers.d.ts +2 -0
  488. package/search/search-executor/search-enrichers.js +6 -1
  489. package/search/search-executor/search-generators.d.ts +2 -2
  490. package/search/search-executor/search-generators.js +13 -8
  491. package/search/search-executor/search-mappers.js +1 -1
  492. package/search/search-executor/search-transformer.d.ts +2 -2
  493. package/search/search-executor/search-transformer.js +6 -6
  494. package/slicing/criterion/parse.d.ts +2 -1
  495. package/slicing/criterion/parse.js +2 -1
  496. package/slicing/static/removal-slice.js +2 -1
  497. package/slicing/static/slice-call.d.ts +30 -4
  498. package/slicing/static/slice-call.js +74 -9
  499. package/slicing/static/slicer-types.d.ts +2 -1
  500. package/slicing/static/static-slicer.js +66 -11
  501. package/slicing/static/visiting-queue.d.ts +2 -0
  502. package/slicing/static/visiting-queue.js +4 -0
  503. package/taint-analysis/builder/report-template.d.ts +3 -3
  504. package/util/arg-matching.d.ts +1 -1
  505. package/util/collections/relation.d.ts +23 -0
  506. package/util/collections/relation.js +63 -0
  507. package/util/fixpoint.d.ts +65 -0
  508. package/util/fixpoint.js +216 -0
  509. package/util/flowr-version.d.ts +1 -1
  510. package/util/flowr-version.js +2 -2
  511. package/util/json.d.ts +4 -0
  512. package/util/json.js +12 -3
  513. package/util/mermaid/cfg.js +1 -2
  514. package/util/mermaid/dfg.d.ts +1 -1
  515. package/util/mermaid/dfg.js +1 -1
  516. package/util/mermaid/mermaid.d.ts +2 -1
  517. package/util/monoid.d.ts +26 -0
  518. package/util/monoid.js +31 -0
  519. package/util/prefix.d.ts +1 -1
  520. package/util/r-base-packages.d.ts +10 -7
  521. package/util/r-base-packages.js +11 -6
  522. package/util/r-package-urls.d.ts +10 -9
  523. package/util/r-value.js +2 -1
  524. package/util/r-version-order.d.ts +2 -0
  525. package/util/r-version-order.js +19 -0
  526. package/util/r-version.d.ts +2 -1
  527. package/util/r-version.js +2 -14
  528. package/util/range.d.ts +38 -29
  529. package/util/range.js +10 -5
  530. package/util/simple-df/dfg-ascii.js +2 -2
  531. package/util/text/ansi.d.ts +13 -9
  532. package/util/text/ansi.js +4 -6
  533. package/util/text/strings.d.ts +10 -3
  534. package/util/text/strings.js +10 -1
  535. package/util/version.d.ts +1 -1
  536. package/util/version.js +2 -1
  537. package/dataflow/environments/default-builtin-config.d.ts +0 -8874
  538. package/dataflow/environments/default-builtin-config.js +0 -1737
  539. package/r-bridge/lang-4.x/ast/model/operators.d.ts +0 -33
  540. package/r-bridge/lang-4.x/ast/model/operators.js +0 -54
  541. package/taint-analysis/eval/eval.d.ts +0 -1
  542. package/taint-analysis/eval/eval.js +0 -124
  543. package/taint-analysis/eval/instrumentation.d.ts +0 -59
  544. package/taint-analysis/eval/instrumentation.js +0 -124
@@ -1,18 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnvirPositionFormals = void 0;
3
+ exports.EnvironmentProducers = exports.EnvironmentLookups = exports.EnvirPositionFormals = void 0;
4
4
  exports.signatureParamNames = signatureParamNames;
5
5
  exports.pipedCall = pipedCall;
6
6
  exports.resolveConstantString = resolveConstantString;
7
7
  exports.findReturnsEnvState = findReturnsEnvState;
8
8
  exports.envirOf = envirOf;
9
9
  exports.resolveArgToEnvirOrAmbiguous = resolveArgToEnvirOrAmbiguous;
10
+ exports.closureFrameResolution = closureFrameResolution;
11
+ exports.linkClosureFrameReads = linkClosureFrameReads;
10
12
  exports.resolveEnvirArgOrAmbiguous = resolveEnvirArgOrAmbiguous;
11
13
  exports.suppliesArg = suppliesArg;
14
+ exports.resolveEnvirOrPosition = resolveEnvirOrPosition;
12
15
  exports.resolveFirstEnvirArg = resolveFirstEnvirArg;
13
16
  exports.unknownIfAmbiguous = unknownIfAmbiguous;
14
17
  exports.resolveSymbolToEnvir = resolveSymbolToEnvir;
18
+ exports.readEnvironmentContents = readEnvironmentContents;
19
+ exports.holdsValueOf = holdsValueOf;
20
+ exports.rebindAliases = rebindAliases;
15
21
  exports.rebindHolders = rebindHolders;
22
+ exports.addEnvironmentWrites = addEnvironmentWrites;
16
23
  exports.routeWrittenToStackEnv = routeWrittenToStackEnv;
17
24
  exports.routeWrittenToEnvir = routeWrittenToEnvir;
18
25
  exports.resolveAttachPosition = resolveAttachPosition;
@@ -30,9 +37,14 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
30
37
  const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
31
38
  const r_pipe_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
32
39
  const edge_1 = require("../../../../../graph/edge");
40
+ const vertex_1 = require("../../../../../graph/vertex");
41
+ const df_helper_1 = require("../../../../../graph/df-helper");
42
+ const closure_frames_1 = require("../../../../../graph/closure-frames");
43
+ const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
33
44
  const make_argument_1 = require("../argument/make-argument");
34
45
  const unknown_side_effect_1 = require("../../../../../graph/unknown-side-effect");
35
46
  const match_args_1 = require("../../../../../graph/match-args");
47
+ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
36
48
  const built_in_props_1 = require("../../../../../environments/built-in-props");
37
49
  function stackKindOf(envState) {
38
50
  return envState.current.globalEnv === true ? 'global' : envState.current.builtInEnv === true ? 'base' : undefined;
@@ -42,14 +54,6 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
42
54
  return undefined;
43
55
  }
44
56
  const inDefs = defs;
45
- if (inDefs.length === 1) {
46
- const envState = inDefs[0].envState;
47
- if (!envState) {
48
- return undefined;
49
- }
50
- const envDef = inDefs[0];
51
- return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, stack: stackKindOf(envState) };
52
- }
53
57
  if (!inDefs.every(identifier_2.hasEnvState)) {
54
58
  return undefined;
55
59
  }
@@ -57,34 +61,21 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
57
61
  if (inDefs.some(d => stackKindOf(d.envState) !== stack)) {
58
62
  return 'ambiguous';
59
63
  }
64
+ /* the variable may hold any of them, so each binding of each joins the others */
60
65
  let mergedEnvState = inDefs[0].envState;
61
66
  for (let i = 1; i < inDefs.length; i++) {
62
- for (const [, varDefs] of (inDefs[i].envState).current.memory) {
67
+ for (const [name, varDefs] of (inDefs[i].envState).current.memory) {
63
68
  for (const varDef of varDefs) {
64
69
  const named = varDef;
65
- if (named.name !== undefined) {
66
- mergedEnvState = environment_1.REnvironment.define(named, false, mergedEnvState);
70
+ if (named.name !== undefined && !mergedEnvState.current.memory.get(name)?.some(d => d.nodeId === named.nodeId)) {
71
+ mergedEnvState = environment_1.REnvironment.define({ ...named, cds: named.cds ?? [] }, false, mergedEnvState);
67
72
  }
68
73
  }
69
74
  }
70
75
  }
71
- const envDef = {
72
- ...inDefs[0],
73
- envState: mergedEnvState
74
- };
75
- return {
76
- envirData: { ...data, environment: mergedEnvState },
77
- envDef,
78
- envirNodeId: nodeId,
79
- stack
80
- };
81
- }
82
- /**
83
- * The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
84
- * database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
85
- * built-in argument matcher use R's real signature (via {@link ReadOnlyFlowrAnalyzerDependenciesContext#signatureOf})
86
- * instead of a hardcoded formal list, while staying correct -- and graph-invariant -- when no signature is available.
87
- */
76
+ return { envirData: { ...data, environment: mergedEnvState }, envDef: { ...inDefs[0], envState: mergedEnvState }, envirNodeId: nodeId, stack };
77
+ }
78
+ /** The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. */
88
79
  function signatureParamNames(data, id, fallback) {
89
80
  const names = data.ctx.deps.signatures().parametersOf(id) ?? [];
90
81
  return names.length > 0 ? names : fallback;
@@ -97,12 +88,7 @@ function pipedCall(node, data) {
97
88
  const lhsArg = r_argument_1.RArgument.is(node.lhs) ? node.lhs : (0, make_argument_1.toUnnamedArgument)(node.lhs, data.completeAst.idMap);
98
89
  return { ...node.rhs, arguments: [lhsArg, ...node.rhs.arguments] };
99
90
  }
100
- /**
101
- * The constant string a name-position node denotes at construction time (string literal, aliased variable, or
102
- * a paste-like join of such); `undefined` if any part is dynamic or the fold is user-shadowed. Unwraps one
103
- * leading pipe (the value domain does not desugar those) and otherwise defers entirely to it -- the shadow
104
- * check, the paste-like fold and its numeric/logical coercion all live there, in {@link resolveAsStringFn}.
105
- */
91
+ /** 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 fold is user-shadowed. */
106
92
  function resolveConstantString(node, data) {
107
93
  const piped = pipedCall(node, data);
108
94
  return node_value_1.NodeValue.singleStringOf(piped ?? node, data);
@@ -127,29 +113,73 @@ function resolveArgToEnvirOrAmbiguous(arg, data) {
127
113
  return stackEnvirResolution(stackEnv, node.info.id, node.lexeme ?? '', data);
128
114
  }
129
115
  if (!r_symbol_1.RSymbol.is(node)) {
130
- return undefined;
116
+ return closureFrameResolution(node, data);
131
117
  }
132
118
  const defs = resolve_helper_1.Resolve.byNameAndType(node.content, data.environment, identifier_2.ReferenceType.Variable);
133
- /* an environment we do not track, or a free variable of a function body bound only once the function is called */
134
- return resolveDefsToEnvirResolution(defs, node.info.id, data)
135
- ?? ((defs === undefined && data.environment.level === 0) || !data.ctx.config.solver.trackEnvironments ? undefined : 'ambiguous');
119
+ if (!data.ctx.config.solver.trackEnvironments) {
120
+ return resolveDefsToEnvirResolution(defs, node.info.id, data);
121
+ }
122
+ else if (defs === undefined && data.environment.level > 0) {
123
+ return freeEnvirResolution(node.content, node.info.id, data);
124
+ }
125
+ /* an environment we do not track */
126
+ return resolveDefsToEnvirResolution(defs, node.info.id, data) ?? (defs === undefined ? undefined : 'ambiguous');
127
+ }
128
+ /** `environment(fn)` names the frame the closure `fn` holds, tracked as the environment state of the variable holding the closure: what is written into the frame is read by the closure once it is called (see {@link linkClosureFrameReads}). */
129
+ function closureFrameResolution(node, data) {
130
+ if (!r_function_call_1.RFunctionCall.isNamed(node, 'environment') || node.arguments.length !== 1 || !resolve_helper_1.Resolve.isBuiltIn(node.functionName.content, data.environment, identifier_2.ReferenceType.Function)) {
131
+ return undefined;
132
+ }
133
+ const fn = r_argument_1.RArgument.valueOf(node.arguments[0]);
134
+ const defs = r_symbol_1.RSymbol.is(fn) ? resolve_helper_1.Resolve.byName(fn.content, data.environment) : undefined;
135
+ const def = defs?.length === 1 ? defs[0] : undefined;
136
+ if (def?.name === undefined || node_id_1.NodeId.isBuiltIn(def.definedAt)) {
137
+ return undefined;
138
+ }
139
+ const envDef = { ...def, envState: def.envState ?? environment_1.REnvironment.pushLocal(data.environment), envId: def.envId ?? def.nodeId, closureFrame: true };
140
+ return { envirData: { ...data, environment: envDef.envState }, envDef, envirNodeId: node.info.id };
141
+ }
142
+ /** A call of a closure whose frame was written (see {@link closureFrameResolution}) reads those writes wherever its body reads a name it does not bind itself. */
143
+ function linkClosureFrameReads(call, called, environment, graph) {
144
+ const vertex = graph.getVertex(call);
145
+ const name = vertex_1.DfgVertex.isFunctionCall(vertex) ? vertex.name : undefined;
146
+ if (name === undefined || !resolve_helper_1.Resolve.byName(name, environment)?.some(d => d.closureFrame === true)) {
147
+ return;
148
+ }
149
+ called.framed = true;
150
+ const body = new Set(called.subflow.graph);
151
+ for (const id of body) {
152
+ const nested = graph.getVertex(id);
153
+ if (vertex_1.DfgVertex.isFunctionDefinition(nested)) {
154
+ nested.subflow.graph.forEach(inner => body.add(inner));
155
+ }
156
+ }
157
+ const idMap = graph.idMap;
158
+ for (const id of body) {
159
+ const read = idMap?.get(id);
160
+ if (!vertex_1.DfgVertex.isUse(graph.getVertex(id)) || !r_symbol_1.RSymbol.is(read) || df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads).some(t => body.has(t))) {
161
+ continue;
162
+ }
163
+ const written = closure_frames_1.ClosureFrames.writesOf(name, environment, identifier_1.Identifier.getName(read.content), called.id, graph);
164
+ /* the write as well, `environment(g)$v <- 5` defines `v` at the value it writes */
165
+ for (const target of [...written.ids, ...written.writers]) {
166
+ graph.addEdge(id, target, edge_1.EdgeType.Reads);
167
+ }
168
+ }
169
+ }
170
+ /** A free variable of a function body names an environment bound only once the function is called: what the body writes into it escapes the function like a `<<-` would, and the call adds it to the environment the name holds there. */
171
+ function freeEnvirResolution(name, nodeId, data) {
172
+ const envState = environment_1.REnvironment.pushLocal(data.environment);
173
+ const envDef = { name, nodeId, type: identifier_2.ReferenceType.Variable, definedAt: nodeId, cds: data.cds, envState, envWrites: true };
174
+ return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId };
136
175
  }
137
176
  /** Builds an {@link EnvirResolution} for an environment obtained directly (not via a holder variable), e.g. `globalenv()` / `.GlobalEnv`. */
138
177
  function stackEnvirResolution(envState, nodeId, lexeme, data) {
139
178
  // no holder variable: envDef is only a carrier for envState/nodeId
140
- const envDef = {
141
- name: lexeme,
142
- nodeId,
143
- type: identifier_2.ReferenceType.Variable,
144
- definedAt: nodeId,
145
- envState,
146
- };
179
+ const envDef = { name: lexeme, nodeId, type: identifier_2.ReferenceType.Variable, definedAt: nodeId, envState };
147
180
  return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, stack: envState.current.globalEnv === true ? 'global' : 'base' };
148
181
  }
149
- /**
150
- * The slots `envir` falls back to (`envir = as.environment(pos)`), so an environment handed to one of them is the
151
- * target as well. They are tried after the envir formal itself.
152
- */
182
+ /** The slots `envir` falls back to (`envir = as.environment(pos)`), so an environment handed to one of them is the target as well. */
153
183
  exports.EnvirPositionFormals = ['pos', 'where'];
154
184
  function envirArgOf(args, bound, formal) {
155
185
  if (bound !== undefined) {
@@ -170,11 +200,7 @@ function resolveEnvirArgOrAmbiguous(args, data, sig, formal = 'envir') {
170
200
  const arg = envirArgOf(args, bindFormals(args, sig), formal);
171
201
  return arg === undefined ? undefined : resolveArgToEnvirOrAmbiguous(arg, data);
172
202
  }
173
- /**
174
- * Whether the call supplies an argument for any of `formals` at all, however it resolves. A `pos`/`where` that is
175
- * not an environment names a position on R's search path (`envir = as.environment(pos)`), which flowR does not
176
- * model: `assign("x", 2, 1)` writes the global environment, not the calling scope.
177
- */
203
+ /** Whether the call supplies an argument for any of `formals` at all, however it resolves. */
178
204
  function suppliesArg(args, sig, formals) {
179
205
  const bound = bindFormals(args, sig);
180
206
  return formals.some(formal => envirArgOf(args, bound, formal) !== undefined);
@@ -187,6 +213,10 @@ function globalPositionOf(arg, data) {
187
213
  }
188
214
  return stackEnvirResolution({ current: environment_1.REnvironment.findGlobal(data.environment.current), level: 0 }, node.info.id, node.lexeme ?? '', data);
189
215
  }
216
+ /** The environment the argument `arg` given for `formal` names, where a position formal may name the global environment by its number. */
217
+ function resolveEnvirOrPosition(arg, formal, data) {
218
+ return envirOf(resolveArgToEnvirOrAmbiguous(arg, data)) ?? (exports.EnvirPositionFormals.includes(formal) ? globalPositionOf(arg, data) : undefined);
219
+ }
190
220
  /** The first of `formals` whose argument resolves to a tracked environment; ambiguity is left to the caller. */
191
221
  function resolveFirstEnvirArg(args, data, sig, formals) {
192
222
  const bound = bindFormals(args, sig);
@@ -195,18 +225,14 @@ function resolveFirstEnvirArg(args, data, sig, formals) {
195
225
  if (arg === undefined) {
196
226
  continue;
197
227
  }
198
- const resolution = envirOf(resolveArgToEnvirOrAmbiguous(arg, data))
199
- ?? (exports.EnvirPositionFormals.includes(formal) ? globalPositionOf(arg, data) : undefined);
228
+ const resolution = resolveEnvirOrPosition(arg, formal, data);
200
229
  if (resolution !== undefined) {
201
230
  return resolution;
202
231
  }
203
232
  }
204
233
  return undefined;
205
234
  }
206
- /**
207
- * Marks `result` as an unknown side effect when the envir argument names a value that cannot be pinned down
208
- * (e.g. a parameter), so routing the writes anywhere would be a guess; reports whether it did.
209
- */
235
+ /** Marks `result` as an unknown side effect when the envir argument names a value that cannot be pinned down (e.g. a parameter), so routing the writes anywhere would be a guess; reports whether it did. */
210
236
  function unknownIfAmbiguous(routing, result, rootId) {
211
237
  if (routing !== 'ambiguous') {
212
238
  return false;
@@ -224,24 +250,19 @@ function writtenDefinitionsOf(result, definedAt) {
224
250
  }
225
251
  function holdersOf(environment, envDef) {
226
252
  const holders = [envDef];
227
- let env = environment.current;
228
- while (env !== undefined && !env.builtInEnv) {
253
+ for (let env = environment.current; env !== undefined && !env.builtInEnv; env = env.globalEnv ? undefined : env.parent) {
229
254
  for (const defs of env.memory.values()) {
230
255
  for (const def of defs) {
231
- /* a copy (`g <- e`) holds the same environment object, even once one of them saw a write */
232
- if ((def.envState === envDef.envState || (def.envId !== undefined && def.envId === envDef.envId)) && def.name !== undefined && def.nodeId !== envDef.nodeId) {
256
+ /* a copy (`g <- e`) holds the same environment object, even once one of them saw a write, as does the variable it was copied from */
257
+ if ((def.envState === envDef.envState || (def.envId !== undefined && def.envId === envDef.envId) || def.nodeId === envDef.envId) && def.name !== undefined && def.nodeId !== envDef.nodeId) {
233
258
  holders.push(def);
234
259
  }
235
260
  }
236
261
  }
237
- if (env.globalEnv) {
238
- break;
239
- }
240
- env = env.parent;
241
262
  }
242
263
  return holders;
243
264
  }
244
- function routeWrittenToCustomEnv(result, envDef, newDefAt, definedAt) {
265
+ function routeWrittenToCustomEnv(result, envDef, newDefAt, callerEnvironment, definedAt) {
245
266
  const written = writtenDefinitionsOf(result, definedAt);
246
267
  let newEnvState = envDef.envState;
247
268
  /* only a binding the write made here moves into the environment, `local(y <- 2, envir = e)` leaves the caller's `y` alone */
@@ -249,21 +270,105 @@ function routeWrittenToCustomEnv(result, envDef, newDefAt, definedAt) {
249
270
  for (const w of written) {
250
271
  newEnvState = environment_1.REnvironment.define(w, false, newEnvState);
251
272
  }
252
- const stripped = { current: result.environment.current.removeAll(namesToRemove), level: result.environment.level };
273
+ const current = result.environment.current.removeAll(namesToRemove);
274
+ /* what the caller bound before stays bound, `v <- 3; assign("v", 4, envir = e)` keeps `v` at 3 */
275
+ for (const { name } of namesToRemove) {
276
+ const before = callerEnvironment.current.lookup(identifier_1.Identifier.getName(name));
277
+ if (before !== undefined) {
278
+ current.writableMemory.set(identifier_1.Identifier.getName(name), before);
279
+ }
280
+ }
281
+ const stripped = { current, level: result.environment.level };
253
282
  return { ...result, environment: rebindHolders(stripped, envDef, newEnvState, newDefAt) };
254
283
  }
284
+ /** The calls that look up bindings in an environment they are given, or write into it, see {@link readEnvironmentContents}. */
285
+ exports.EnvironmentLookups = new Set([
286
+ built_in_proc_name_1.BuiltInProcName.Access, built_in_proc_name_1.BuiltInProcName.Assignment, built_in_proc_name_1.BuiltInProcName.Attach, built_in_proc_name_1.BuiltInProcName.EnvContents, built_in_proc_name_1.BuiltInProcName.Get,
287
+ built_in_proc_name_1.BuiltInProcName.Local, built_in_proc_name_1.BuiltInProcName.NewEnv, built_in_proc_name_1.BuiltInProcName.Replacement, built_in_proc_name_1.BuiltInProcName.Rm, built_in_proc_name_1.BuiltInProcName.With
288
+ ]);
289
+ /** An environment is changed in place, so a call given a variable holding a tracked environment reads everything written into the environment so far, through the writes, unless the call only looks up bindings in it (see {@link EnvironmentLookups}). */
290
+ function readEnvironmentContents(graph, call, holder) {
291
+ const envState = holder.envState;
292
+ /* a stack env or the frame of a function (`environment()`) holds variables the scoping links already */
293
+ if (envState === undefined || stackKindOf(envState) !== undefined || envState.current.closure !== undefined || holder.closureFrame === true) {
294
+ return;
295
+ }
296
+ for (const fields of envState.current.memory.values()) {
297
+ for (const field of fields) {
298
+ /* the write reads what it stores, which is data to the call: a function stored there is not what it calls */
299
+ if (!node_id_1.NodeId.isBuiltIn(field.definedAt)) {
300
+ graph.addEdge(call, field.definedAt, edge_1.EdgeType.Reads);
301
+ }
302
+ }
303
+ }
304
+ }
305
+ /** What creates an environment rather than another value: `new.env()`, `globalenv()` and its kin, and `list2env()`. */
306
+ exports.EnvironmentProducers = [built_in_proc_name_1.BuiltInProcName.NewEnv, built_in_proc_name_1.BuiltInProcName.StackEnv, built_in_proc_name_1.BuiltInProcName.ListToEnv];
307
+ /** Whether the variable definition `holder` surely holds a value one of `origins` created, following plain copies (`e2 <- e`) and replacements (`e$f <- v` keeps what `e` held). */
308
+ function holdsValueOf(holder, graph, origins) {
309
+ const sources = df_helper_1.Dataflow.valueSources(holder.nodeId, graph);
310
+ return sources !== undefined && sources.length > 0 && sources.every(v => origins.some(o => vertex_1.DfgVertex.hasOrigin(graph.getVertex(v), o)));
311
+ }
312
+ /** Binds every other variable holding the same object as the variable `name` (copied from it by `y <- x`, see {@link InGraphIdentifierDefinition#envId}) to the change in place `change` as well (`x[, a := 9L]`), which reaches all of them. */
313
+ function rebindAliases(environment, name, change, definedAt) {
314
+ const changed = resolve_helper_1.Resolve.byName(name, environment);
315
+ const identities = new Set(changed?.map(d => d.envId ?? d.nodeId).filter(i => i !== undefined && !node_id_1.NodeId.isBuiltIn(i)));
316
+ if (identities.size === 0) {
317
+ return [environment, undefined];
318
+ }
319
+ const target = identifier_1.Identifier.getName(name);
320
+ for (let env = environment.current; env !== undefined && !env.builtInEnv; env = env.parent) {
321
+ for (const defs of env.memory.values()) {
322
+ for (const def of defs) {
323
+ if (def.name !== undefined && identifier_1.Identifier.getName(def.name) !== target && identities.has(def.envId ?? def.nodeId)) {
324
+ /* the alias may still hold the object as it was, so the change joins its binding */
325
+ environment = environment_1.REnvironment.define({ ...def, name: def.name, nodeId: change, definedAt, cds: [] }, environment.current.lookup(identifier_1.Identifier.getName(def.name)) === undefined, environment);
326
+ }
327
+ }
328
+ }
329
+ }
330
+ return [environment, identities.size === 1 ? [...identities][0] : undefined];
331
+ }
255
332
  /** Binds every variable holding the environment of `envDef` to its new state, where that variable is bound. */
256
333
  function rebindHolders(environment, envDef, envState, definedAt) {
257
334
  for (const holder of holdersOf(environment, envDef)) {
258
335
  /* a holder bound in an enclosing frame is updated there, so the write escapes the function like a `<<-` */
259
- environment = environment_1.REnvironment.define({ ...holder, definedAt: definedAt ?? holder.definedAt, envState }, environment.current.lookup(identifier_1.Identifier.getName(holder.name)) === undefined, environment);
336
+ environment = environment_1.REnvironment.define({ ...holder, definedAt: definedAt ?? holder.definedAt, envState, ...envDef.closureFrame ? { closureFrame: true } : {} }, environment.current.lookup(identifier_1.Identifier.getName(holder.name)) === undefined, environment);
260
337
  }
261
338
  return environment;
262
339
  }
263
- /**
264
- * Routes writes into a real stack env's frame chain, the same way `<<-` reaches an outer scope.
265
- * Each write also gets a `Reads` edge back to `rootId`, so slicing does not drop the call that made it.
266
- */
340
+ /** Adds the `writes` a called function made into environments its free variables name (see {@link InGraphIdentifierDefinition#envWrites}) to the environments the caller binds these names to; a name still free in a calling function body stays with the writes, so its own calls add them. */
341
+ function addEnvironmentWrites(writes, callee, caller, call, graph) {
342
+ for (const written of writes) {
343
+ if (!(0, identifier_2.hasEnvState)(written) || written.name === undefined) {
344
+ continue;
345
+ }
346
+ const bound = resolve_helper_1.Resolve.byNameAndType(written.name, caller, identifier_2.ReferenceType.Variable);
347
+ if (bound === undefined && caller.level > 0) {
348
+ continue;
349
+ }
350
+ callee = { current: callee.current.removeAll([{ name: written.name }]), level: callee.level };
351
+ for (const holder of bound ?? []) {
352
+ if (!(0, identifier_2.hasEnvState)(holder) || holder.name === undefined) {
353
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(graph, caller, call);
354
+ continue;
355
+ }
356
+ let envState = holder.envState;
357
+ for (const fields of written.envState.current.memory.values()) {
358
+ for (const field of fields) {
359
+ if (field.name !== undefined) {
360
+ envState = environment_1.REnvironment.define(field, false, envState);
361
+ /* the call made the write */
362
+ graph.addEdge(field.nodeId, call, edge_1.EdgeType.SideEffectOnCall);
363
+ }
364
+ }
365
+ }
366
+ caller = rebindHolders(caller, holder, envState, call);
367
+ }
368
+ }
369
+ return [callee, caller];
370
+ }
371
+ /** Routes writes into a real stack env's frame chain, the same way `<<-` reaches an outer scope. */
267
372
  function routeWrittenToStackEnv(result, into, rootId, definedAt) {
268
373
  const written = writtenDefinitionsOf(result, definedAt);
269
374
  let environment = into;
@@ -273,52 +378,28 @@ function routeWrittenToStackEnv(result, into, rootId, definedAt) {
273
378
  }
274
379
  return { ...result, environment };
275
380
  }
276
- /**
277
- * Routes writes under a resolved `envir=` to the real stack frame or a tracked custom env, and adds the
278
- * `Reads` edge from `rootId` to the envir argument.
279
- */
381
+ /** Routes writes under a resolved `envir=` to the real stack frame or a tracked custom env, and adds the `Reads` edge from `rootId` to the envir argument. */
280
382
  function routeWrittenToEnvir(result, resolution, rootId, callerEnvironment, definedAt) {
281
383
  let routed;
282
384
  if (resolution.stack !== undefined) {
283
385
  routed = resolution.stack === 'global' ? routeWrittenToStackEnv(result, callerEnvironment, rootId, definedAt) : result;
284
386
  }
285
387
  else {
286
- routed = routeWrittenToCustomEnv(result, resolution.envDef, rootId, definedAt);
388
+ routed = routeWrittenToCustomEnv(result, resolution.envDef, rootId, callerEnvironment, definedAt);
287
389
  }
288
390
  routed.graph.addEdge(rootId, resolution.envirNodeId, edge_1.EdgeType.Reads);
289
391
  return routed;
290
392
  }
291
- /** A `search()` position must be an integer and may never displace the global environment (R rejects `pos = 1`). */
292
- function clampAttachPosition(pos) {
293
- return Number.isFinite(pos) ? Math.max(environment_1.DefaultAttachPosition, Math.trunc(pos)) : undefined;
294
- }
295
- /**
296
- * The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of
297
- * an existing entry (`pos = "package:base"`). Returns `undefined` when there is no such argument, its value is unknown
298
- * or ambiguous, or it names an entry that is not on the search path; callers then attach at {@link DefaultAttachPosition}
299
- * (as R does, which warns in the last case).
300
- */
393
+ /** The `search()` position the `pos` argument of a `library()` call requests, either given as a number or as the name of an existing entry (`pos = "package:base"`). */
301
394
  function resolveAttachPosition(posId, data) {
302
- if (posId === undefined) {
303
- return undefined;
304
- }
305
- const element = node_value_1.NodeValue.soleOf(posId, data);
306
- if (element === undefined) {
307
- return undefined;
308
- }
309
- const asNumber = r_value_1.RValue.numberOf(element);
310
- if (asNumber !== undefined) {
311
- return clampAttachPosition(asNumber);
395
+ const element = posId === undefined ? undefined : node_value_1.NodeValue.soleOf(posId, data);
396
+ const asNumber = element === undefined ? undefined : r_value_1.RValue.numberOf(element);
397
+ const asString = element === undefined || asNumber !== undefined ? undefined : r_value_1.RValue.stringOf(element);
398
+ const position = asNumber ?? (asString === undefined ? undefined : environment_1.REnvironment.searchPosition(data.environment.current, asString));
399
+ if (position === undefined && asString !== undefined) {
400
+ logger_1.dataflowLogger.warn(`search-path entry '${asString}' does not exist, attaching at the default position`);
312
401
  }
313
- const asString = r_value_1.RValue.stringOf(element);
314
- if (asString !== undefined) {
315
- const found = environment_1.REnvironment.searchPosition(data.environment.current, asString);
316
- if (found === undefined) {
317
- logger_1.dataflowLogger.warn(`search-path entry '${asString}' does not exist, attaching at the default position`);
318
- return undefined;
319
- }
320
- return clampAttachPosition(found);
321
- }
322
- return undefined;
402
+ /* it must be an integer and may never displace the global environment (R rejects `pos = 1`) */
403
+ return position !== undefined && Number.isFinite(position) ? Math.max(environment_1.DefaultAttachPosition, Math.trunc(position)) : undefined;
323
404
  }
324
405
  //# sourceMappingURL=built-in-envir-utils.js.map
@@ -4,9 +4,8 @@ import { type ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/
4
4
  import { type PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
5
  import { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
6
  import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
- /**
8
- * Process a call to `eval()`, trying to resolve the code being evaluated if possible.
9
- */
7
+ import { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
8
+ /** Process a call to `eval()`, trying to resolve the code being evaluated if possible. */
10
9
  export declare function processEvalCall<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
11
10
  /** should this produce an explicit source function call in the graph? */
12
11
  includeFunctionCall?: boolean;
@@ -15,3 +14,5 @@ export declare function processEvalCall<OtherInfo>(name: RSymbol<OtherInfo & Par
15
14
  parameterNames?: readonly string[];
16
15
  parentFrame?: boolean;
17
16
  }): DataflowInformation;
17
+ /** Processes the code the quoted values `nodes` hold where the call `rootId` may evaluate it: `do.call(f, list(quote(n <- 5)))` calls `f(n <- 5)`, so the code runs when `f` forces that argument, which is unknown here, hence it runs maybe. */
18
+ export declare function evaluateQuotedArguments<OtherInfo>(nodes: readonly (RNode<OtherInfo & ParentInformation> | undefined)[], rootId: NodeId, information: DataflowInformation, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processEvalCall = processEvalCall;
4
+ exports.evaluateQuotedArguments = evaluateQuotedArguments;
4
5
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
5
6
  const r_binary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
6
7
  const function_semantics_1 = require("../../../../../fn/function-semantics");
@@ -31,15 +32,14 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
31
32
  const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
32
33
  const r_function_call_2 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
33
34
  const built_in_ambient_state_1 = require("./built-in-ambient-state");
35
+ const built_in_apply_1 = require("./built-in-apply");
34
36
  const SymbolConstructors = new Set(['as.name', 'as.symbol']);
35
37
  const PasteFunctions = new Set(['paste', 'paste0']);
36
38
  const StringParsers = new Set(['str2lang', 'str2expression']);
37
39
  const SyntacticName = /^[.a-zA-Z][.a-zA-Z0-9_]*$/;
38
40
  /** the formals of `eval(expr, envir, enclos)` */
39
41
  const EvalParameterNames = ['expr', 'envir', 'enclos'];
40
- /**
41
- * Process a call to `eval()`, trying to resolve the code being evaluated if possible.
42
- */
42
+ /** Process a call to `eval()`, trying to resolve the code being evaluated if possible. */
43
43
  function processEvalCall(name, args, rootId, data, config) {
44
44
  const bound = function_semantics_1.FunctionSemantics.call.match.toNames(args, config.parameterNames ?? EvalParameterNames);
45
45
  /* `evalText` names its formal differently, so a lone argument is the expression whatever it is called */
@@ -69,11 +69,19 @@ function processEvalCall(name, args, rootId, data, config) {
69
69
  if (quoted !== undefined) {
70
70
  return evaluateQuoted(quoted, config.parentFrame || namesParentFrame(envirArg?.value, data) ? undefined : envirArg, rootId, information, data);
71
71
  }
72
+ const constructed = config.supportFunctionCall ? undefined : constructedCallOf(evalArgument, data);
73
+ if (constructed !== undefined) {
74
+ if (envirArg !== undefined) {
75
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
76
+ }
77
+ const [called, callId] = (0, built_in_apply_1.callNamedFunction)(information, constructed.fn, constructed.args, rootId, data, undefined, `${rootId}-call`);
78
+ called.graph.addEdge(rootId, callId, edge_1.EdgeType.Returns);
79
+ return called;
80
+ }
72
81
  const code = resolveEvalToCode(evalArgument, config, data);
73
82
  if (code) {
74
83
  if (envirArg !== undefined) {
75
- /* the code runs in another environment, so its definitions do not land in the current one and
76
- * pretending they do would produce wrong edges */
84
+ /* the code runs in another environment, so its definitions do not land in the current one and pretending they do would produce wrong edges */
77
85
  (0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
78
86
  }
79
87
  const idGenerator = (0, decorate_1.sourcedDeterministicCountingIdGenerator)(name.lexeme + '::' + rootId);
@@ -103,10 +111,7 @@ function processEvalCall(name, args, rootId, data, config) {
103
111
  function evaluationOf(code) {
104
112
  return `eval:${String(code)}`;
105
113
  }
106
- /**
107
- * The code `eval` runs, if it is written down: what a quoting call captures (`eval(quote(x <- 1))`), or what each
108
- * binding of a name captures (`q <- quote(x <- 1); eval(q)`).
109
- */
114
+ /** The code `eval` runs, if it is written down: what a quoting call captures (`eval(quote(x <- 1))`), or what each binding of a name captures (`q <- quote(x <- 1); eval(q)`). */
110
115
  function quotedCodeOf(node, data) {
111
116
  const val = (0, built_in_envir_utils_1.pipedCall)(node, data) ?? node;
112
117
  const code = r_symbol_1.RSymbol.is(val)
@@ -114,10 +119,7 @@ function quotedCodeOf(node, data) {
114
119
  : [capturedBy(val, data)];
115
120
  return code === undefined || code.length === 0 || code.some(assert_1.isUndefined) ? undefined : code;
116
121
  }
117
- /**
118
- * The one expression a call to a built-in capturing code (`quote`, `bquote`, `expression`) holds on to, unless it is
119
- * being evaluated already; `substitute(expr, env)` replaces names before anything runs.
120
- */
122
+ /** The one expression a call to a built-in capturing code (`quote`, `bquote`, `expression`) holds on to, unless it is being evaluated already; `substitute(expr, env)` replaces names before anything runs. */
121
123
  function capturedBy(node, data) {
122
124
  if (!r_function_call_1.RFunctionCall.isNamed(node)) {
123
125
  return undefined;
@@ -134,6 +136,17 @@ function boundValueOf(target, data) {
134
136
  const assignment = data.completeAst.idMap.get(data.completeAst.idMap.get(target)?.info.parent ?? '');
135
137
  return r_binary_op_1.RBinaryOp.is(assignment) ? assignment.lhs.info.id === target ? assignment.rhs : assignment.lhs : undefined;
136
138
  }
139
+ /** Processes the code the quoted values `nodes` hold where the call `rootId` may evaluate it: `do.call(f, list(quote(n <- 5)))` calls `f(n <- 5)`, so the code runs when `f` forces that argument, which is unknown here, hence it runs maybe. */
140
+ function evaluateQuotedArguments(nodes, rootId, information, data) {
141
+ const maybe = { ...data, cds: [...data.cds ?? [], { id: rootId, when: true }] };
142
+ for (const node of nodes) {
143
+ const code = node === undefined ? undefined : quotedCodeOf(node, data);
144
+ if (code !== undefined) {
145
+ information = evaluateQuoted(code, undefined, rootId, information, maybe);
146
+ }
147
+ }
148
+ return information;
149
+ }
137
150
  /** Runs the quoted `code` where `eval` runs it: right here, or in the environment `envir` names (see {@link evaluateInEnvir}); with several candidates, each may be the one. */
138
151
  function evaluateQuoted(code, envir, rootId, information, data) {
139
152
  const routing = envir === undefined ? undefined : (0, built_in_envir_utils_1.resolveArgToEnvirOrAmbiguous)(envir, data);
@@ -183,6 +196,40 @@ function escapeWritesToParentFrame(expr, rootId, data, information) {
183
196
  information.environment = routed.environment;
184
197
  information.out = [...information.out, ...written];
185
198
  }
199
+ /** The call a constructing call builds, the function it names and the arguments it hands over: `call("f", x)`, or `as.call(list(as.name("f"), x))`, written there or bound once to a name. */
200
+ function constructedCallOf(node, data) {
201
+ const val = (0, built_in_envir_utils_1.pipedCall)(node, data) ?? node;
202
+ if (r_symbol_1.RSymbol.is(val)) {
203
+ const defs = resolve_helper_1.Resolve.byName(val.content, data.environment);
204
+ const source = defs?.length === 1 ? boundValueOf(defs[0].nodeId, data) : undefined;
205
+ return source === undefined || r_symbol_1.RSymbol.is(source) ? undefined : constructedCallOf(source, data);
206
+ }
207
+ const parts = r_function_call_1.RFunctionCall.isNamed(val, 'call') && resolve_helper_1.Resolve.isBuiltIn(val.functionName.content, data.environment, identifier_1.ReferenceType.Function) ? val.arguments
208
+ : r_function_call_1.RFunctionCall.isNamed(val, 'as.call') && resolve_helper_1.Resolve.isBuiltIn(val.functionName.content, data.environment, identifier_1.ReferenceType.Function) ? listEntriesOf(r_function_call_1.RFunctionCall.soleArgument(val.arguments)?.value, data)
209
+ : undefined;
210
+ const named = parts === undefined ? undefined : r_argument_1.RArgument.valueOf(parts[0]);
211
+ const name = r_function_call_1.RFunctionCall.isNamed(named, SymbolConstructors) && resolve_helper_1.Resolve.isBuiltIn(named.functionName.content, data.environment, identifier_1.ReferenceType.Function)
212
+ ? r_function_call_1.RFunctionCall.soleArgument(named.arguments)?.value : named;
213
+ const fn = name === undefined ? undefined : (0, built_in_apply_1.resolveFunctionArgument)(name, data, { unquoteFunction: true });
214
+ if (fn === undefined || fn.anonymous || parts === undefined) {
215
+ return undefined;
216
+ }
217
+ return { fn: { ...fn, asString: true }, args: parts.slice(1).map(handedOver) };
218
+ }
219
+ /** The entries of a `list(...)` written out. */
220
+ function listEntriesOf(node, data) {
221
+ return r_function_call_1.RFunctionCall.isNamed(node, 'list') && resolve_helper_1.Resolve.isBuiltIn(node.functionName.content, data.environment, identifier_1.ReferenceType.Function) ? node.arguments : undefined;
222
+ }
223
+ /** An argument handed over to the constructed call, as the vertex the argument was processed to. */
224
+ function handedOver(arg) {
225
+ if (arg === r_function_call_2.EmptyArgument) {
226
+ return r_function_call_2.EmptyArgument;
227
+ }
228
+ else if (arg.name === undefined) {
229
+ return { nodeId: arg.value?.info.id ?? arg.info.id, cds: undefined, type: identifier_1.ReferenceType.Argument };
230
+ }
231
+ return { nodeId: arg.info.id, valueId: arg.value?.info.id, name: arg.name.content, cds: undefined, type: identifier_1.ReferenceType.Argument };
232
+ }
186
233
  function resolveEvalToCode(evalArgument, config, data) {
187
234
  const val = (0, built_in_envir_utils_1.pipedCall)(evalArgument, data) ?? evalArgument;
188
235
  if (config.supportFunctionCall) {
@@ -4,7 +4,5 @@ import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing
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
6
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
7
- /**
8
- * Processes a list of expressions joining their dataflow graphs accordingly.
9
- */
7
+ /** Processes a list of expressions joining their dataflow graphs accordingly. */
10
8
  export declare function processExpressionList<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;