@eagleoutice/flowr 2.17.5 → 2.17.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 (1128) hide show
  1. package/README.md +13 -51
  2. package/abstract-interpretation/absint-inference.d.ts +13 -29
  3. package/abstract-interpretation/absint-inference.js +18 -32
  4. package/abstract-interpretation/abstract-semantics.d.ts +2 -1
  5. package/abstract-interpretation/branch-paths-interpreter.d.ts +1 -0
  6. package/abstract-interpretation/branch-paths-interpreter.js +56 -0
  7. package/abstract-interpretation/branch-paths.d.ts +59 -0
  8. package/abstract-interpretation/branch-paths.js +120 -0
  9. package/abstract-interpretation/data-frame/arguments.d.ts +3 -14
  10. package/abstract-interpretation/data-frame/arguments.js +2 -10
  11. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +4 -12
  12. package/abstract-interpretation/data-frame/dataframe-domain.js +6 -20
  13. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +8 -7
  14. package/abstract-interpretation/data-frame/dataframe-semantics.js +218 -325
  15. package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -6
  16. package/abstract-interpretation/data-frame/semantics.d.ts +3 -0
  17. package/abstract-interpretation/data-frame/semantics.js +24 -52
  18. package/abstract-interpretation/data-frame/shape-inference.d.ts +5 -15
  19. package/abstract-interpretation/domains/abstract-domain.d.ts +7 -21
  20. package/abstract-interpretation/domains/abstract-domain.js +6 -18
  21. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  22. package/abstract-interpretation/domains/interval-domain.d.ts +2 -6
  23. package/abstract-interpretation/domains/interval-domain.js +3 -10
  24. package/abstract-interpretation/domains/lattice.d.ts +14 -42
  25. package/abstract-interpretation/domains/set-range-domain.d.ts +6 -18
  26. package/abstract-interpretation/domains/set-range-domain.js +4 -12
  27. package/abstract-interpretation/domains/state-domain.d.ts +9 -27
  28. package/abstract-interpretation/domains/value-abstract-domain.d.ts +22 -66
  29. package/abstract-interpretation/domains/value-abstract-domain.js +3 -9
  30. package/abstract-interpretation/unsupported-functions.d.ts +2 -6
  31. package/abstract-interpretation/unsupported-functions.js +3 -9
  32. package/abstract-interpretation/value-semantics.d.ts +1 -2
  33. package/benchmark/slicer.d.ts +4 -11
  34. package/benchmark/slicer.js +8 -24
  35. package/benchmark/stats/count-comments.d.ts +1 -3
  36. package/benchmark/stats/count-comments.js +1 -3
  37. package/benchmark/stats/print.d.ts +3 -10
  38. package/benchmark/stats/print.js +39 -110
  39. package/benchmark/stats/sigdb-counts.js +1 -5
  40. package/benchmark/stats/size-of.js +3 -13
  41. package/benchmark/stats/stats.d.ts +1 -3
  42. package/benchmark/stopwatch.d.ts +1 -3
  43. package/benchmark/stopwatch.js +1 -3
  44. package/benchmark/summarizer/first-phase/input.d.ts +2 -6
  45. package/benchmark/summarizer/first-phase/input.js +2 -6
  46. package/benchmark/summarizer/first-phase/process.d.ts +4 -12
  47. package/benchmark/summarizer/first-phase/process.js +22 -39
  48. package/benchmark/summarizer/second-phase/graph.d.ts +0 -1
  49. package/benchmark/summarizer/second-phase/graph.js +9 -33
  50. package/benchmark/summarizer/second-phase/process.d.ts +4 -12
  51. package/benchmark/summarizer/second-phase/process.js +78 -221
  52. package/benchmark/summarizer/summarizer.d.ts +4 -12
  53. package/cli/benchmark-app.js +1 -5
  54. package/cli/benchmark-helper-app.js +2 -10
  55. package/cli/common/options.d.ts +1 -3
  56. package/cli/common/options.js +1 -3
  57. package/cli/common/script.d.ts +1 -3
  58. package/cli/common/script.js +3 -11
  59. package/cli/common/scripts-info.d.ts +2 -7
  60. package/cli/common/scripts-info.js +2 -6
  61. package/cli/flowr-main-options.d.ts +1 -3
  62. package/cli/flowr-main-options.js +6 -31
  63. package/cli/flowr.js +5 -8
  64. package/cli/repl/commands/repl-commands.d.ts +5 -15
  65. package/cli/repl/commands/repl-commands.js +7 -17
  66. package/cli/repl/commands/repl-dataflow.js +4 -4
  67. package/cli/repl/commands/repl-execute.d.ts +1 -4
  68. package/cli/repl/commands/repl-execute.js +1 -4
  69. package/cli/repl/commands/repl-main.d.ts +4 -14
  70. package/cli/repl/commands/repl-main.js +1 -5
  71. package/cli/repl/commands/repl-query.js +2 -10
  72. package/cli/repl/commands/repl-signature.js +2 -3
  73. package/cli/repl/completion.d.ts +11 -3
  74. package/cli/repl/completion.js +32 -0
  75. package/cli/repl/core.d.ts +5 -16
  76. package/cli/repl/core.js +58 -19
  77. package/cli/repl/execute.js +3 -11
  78. package/cli/repl/ghost-hint.js +6 -6
  79. package/cli/repl/parser/slice-query-parser.d.ts +3 -9
  80. package/cli/repl/parser/slice-query-parser.js +6 -10
  81. package/cli/repl/print-version.d.ts +2 -6
  82. package/cli/repl/print-version.js +4 -8
  83. package/cli/repl/prompt.d.ts +1 -0
  84. package/cli/repl/prompt.js +1 -0
  85. package/cli/repl/server/connection.d.ts +2 -6
  86. package/cli/repl/server/connection.js +8 -35
  87. package/cli/repl/server/messages/all-messages.d.ts +3 -9
  88. package/cli/repl/server/messages/all-messages.js +1 -4
  89. package/cli/repl/server/messages/message-analysis.d.ts +6 -18
  90. package/cli/repl/server/messages/message-error.d.ts +1 -3
  91. package/cli/repl/server/messages/message-hello.d.ts +2 -7
  92. package/cli/repl/server/messages/message-repl.d.ts +1 -1
  93. package/cli/repl/server/messages/message-slice.d.ts +2 -7
  94. package/cli/repl/server/net.d.ts +3 -11
  95. package/cli/repl/server/net.js +1 -3
  96. package/cli/repl/server/send.d.ts +2 -6
  97. package/cli/repl/server/send.js +2 -6
  98. package/cli/repl/server/server.js +1 -6
  99. package/cli/repl/server/validate.d.ts +3 -9
  100. package/cli/repl/server/validate.js +3 -9
  101. package/cli/script-core/summarizer-core.d.ts +1 -3
  102. package/cli/script-core/summarizer-core.js +1 -3
  103. package/cli/summarizer-app.js +1 -4
  104. package/cli/wiki.d.ts +1 -3
  105. package/cli/wiki.js +3 -15
  106. package/clones/algorithms/baxter-ast.js +2 -2
  107. package/clones/clone-ast.js +2 -2
  108. package/clones/clone-detector.js +2 -2
  109. package/config.d.ts +5 -15
  110. package/config.js +17 -59
  111. package/control-flow/basic-cfg-guided-visitor.d.ts +2 -6
  112. package/control-flow/basic-cfg-guided-visitor.js +2 -6
  113. package/control-flow/cfg-dead-code.d.ts +1 -1
  114. package/control-flow/cfg-dead-code.js +27 -47
  115. package/control-flow/cfg-properties.d.ts +1 -3
  116. package/control-flow/cfg-properties.js +1 -3
  117. package/control-flow/cfg-simplification.d.ts +2 -6
  118. package/control-flow/cfg-simplification.js +2 -6
  119. package/control-flow/cfg-to-basic-blocks.d.ts +1 -3
  120. package/control-flow/cfg-to-basic-blocks.js +2 -9
  121. package/control-flow/control-flow-graph.d.ts +16 -49
  122. package/control-flow/control-flow-graph.js +60 -194
  123. package/control-flow/dfg-cfg-guided-visitor.d.ts +2 -6
  124. package/control-flow/dfg-cfg-guided-visitor.js +2 -6
  125. package/control-flow/happens-before.d.ts +1 -3
  126. package/control-flow/happens-before.js +1 -3
  127. package/control-flow/semantic-cfg-guided-visitor.d.ts +3 -7
  128. package/control-flow/semantic-cfg-guided-visitor.js +12 -45
  129. package/control-flow/simple-visitor.d.ts +1 -5
  130. package/control-flow/simple-visitor.js +1 -5
  131. package/control-flow/syntax-cfg-guided-visitor.d.ts +23 -67
  132. package/control-flow/syntax-cfg-guided-visitor.js +22 -66
  133. package/control-flow/useless-loop.d.ts +0 -5
  134. package/control-flow/useless-loop.js +0 -5
  135. package/core/pipeline-executor.d.ts +1 -4
  136. package/core/pipeline-executor.js +2 -8
  137. package/core/print/print.d.ts +4 -14
  138. package/core/print/slice-diff-ansi.d.ts +1 -3
  139. package/core/print/slice-diff-ansi.js +2 -7
  140. package/core/steps/all/core/01-parse-tree-sitter.js +1 -4
  141. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  142. package/core/steps/all/static-slicing/00-slice.d.ts +1 -1
  143. package/core/steps/all/static-slicing/00-slice.js +1 -3
  144. package/core/steps/all/static-slicing/10-reconstruct.js +1 -3
  145. package/core/steps/pipeline/create-pipeline.d.ts +1 -3
  146. package/core/steps/pipeline/create-pipeline.js +2 -8
  147. package/core/steps/pipeline/default-pipelines.d.ts +48 -323
  148. package/core/steps/pipeline/default-pipelines.js +9 -47
  149. package/core/steps/pipeline/invalid-pipeline-error.d.ts +1 -3
  150. package/core/steps/pipeline/invalid-pipeline-error.js +1 -3
  151. package/core/steps/pipeline/pipeline.d.ts +1 -6
  152. package/core/steps/pipeline-step.d.ts +2 -6
  153. package/data/packed.d.ts +10 -0
  154. package/data/packed.js +33 -0
  155. package/data/r-base-guards.generated.d.ts +7 -0
  156. package/data/r-base-guards.generated.js +12 -0
  157. package/data/r-datasets.generated.d.ts +4 -0
  158. package/data/r-datasets.generated.js +10 -0
  159. package/data/r-formals.generated.d.ts +4 -0
  160. package/data/r-formals.generated.js +10 -0
  161. package/data/r-group-method-guards.generated.d.ts +3 -0
  162. package/data/r-group-method-guards.generated.js +8 -0
  163. package/dataflow/cluster.d.ts +1 -3
  164. package/dataflow/cluster.js +1 -3
  165. package/dataflow/environments/ambient-contract.d.ts +102 -0
  166. package/dataflow/environments/ambient-contract.js +134 -0
  167. package/dataflow/environments/ambient-effect.d.ts +1064 -0
  168. package/dataflow/environments/ambient-effect.js +276 -0
  169. package/dataflow/environments/ambient-state-name.d.ts +50 -3
  170. package/dataflow/environments/ambient-state-name.js +68 -7
  171. package/dataflow/environments/append.d.ts +1 -3
  172. package/dataflow/environments/append.js +2 -7
  173. package/dataflow/environments/apply-kill.d.ts +2 -3
  174. package/dataflow/environments/apply-kill.js +34 -52
  175. package/dataflow/environments/built-in-config.d.ts +1 -2
  176. package/dataflow/environments/built-in-kinds.d.ts +4 -46
  177. package/dataflow/environments/built-in-kinds.js +6 -2
  178. package/dataflow/environments/built-in-proc-name.d.ts +2 -6
  179. package/dataflow/environments/built-in-proc-name.js +2 -6
  180. package/dataflow/environments/built-in-props.d.ts +16 -4
  181. package/dataflow/environments/built-in-props.js +12 -7
  182. package/dataflow/environments/built-in.d.ts +8 -4
  183. package/dataflow/environments/built-in.js +16 -42
  184. package/dataflow/environments/clone.js +1 -4
  185. package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
  186. package/dataflow/environments/default-builtin-config/base-functions.js +114 -56
  187. package/dataflow/environments/default-builtin-config/base-language.d.ts +1 -1
  188. package/dataflow/environments/default-builtin-config/base-language.js +11 -8
  189. package/dataflow/environments/default-builtin-config/define-helpers.d.ts +4 -0
  190. package/dataflow/environments/default-builtin-config/define-helpers.js +4 -0
  191. package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +1 -1
  192. package/dataflow/environments/default-builtin-config/dev-tooling.js +11 -8
  193. package/dataflow/environments/default-builtin-config/file-io.js +6 -4
  194. package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +1 -1
  195. package/dataflow/environments/default-builtin-config/graphics-devices.js +25 -15
  196. package/dataflow/environments/default-builtin-config/guard-builders.d.ts +23 -0
  197. package/dataflow/environments/default-builtin-config/guard-builders.js +36 -0
  198. package/dataflow/environments/default-builtin-config/guards-primitive-lang.d.ts +15 -0
  199. package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +228 -0
  200. package/dataflow/environments/default-builtin-config/guards-primitive-ops.d.ts +11 -0
  201. package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +154 -0
  202. package/dataflow/environments/default-builtin-config/guards.d.ts +9 -0
  203. package/dataflow/environments/default-builtin-config/guards.js +206 -0
  204. package/dataflow/environments/default-builtin-config/index.d.ts +4 -4
  205. package/dataflow/environments/default-builtin-config/index.js +22 -7
  206. package/dataflow/environments/default-builtin-config/media-formats.js +4 -4
  207. package/dataflow/environments/default-builtin-config/package-data-table.d.ts +1 -1
  208. package/dataflow/environments/default-builtin-config/package-data-table.js +2 -3
  209. package/dataflow/environments/default-builtin-config/package-spatial.js +2 -1
  210. package/dataflow/environments/default-builtin-config/package-tidyverse.js +3 -2
  211. package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
  212. package/dataflow/environments/default-builtin-config/package-utils.js +23 -6
  213. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
  214. package/dataflow/environments/default-builtin-config/parallel-execution.js +3 -1
  215. package/dataflow/environments/default-builtin-config/r-formals.d.ts +13 -0
  216. package/dataflow/environments/default-builtin-config/r-formals.js +110 -0
  217. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +209 -77
  218. package/dataflow/environments/default-builtin-config/shared-configs.js +70 -91
  219. package/dataflow/environments/default-builtin-config/statistics.d.ts +1 -1
  220. package/dataflow/environments/default-builtin-config/statistics.js +4 -1
  221. package/dataflow/environments/define.js +1 -4
  222. package/dataflow/environments/diff.d.ts +4 -10
  223. package/dataflow/environments/diff.js +8 -11
  224. package/dataflow/environments/environment.d.ts +22 -4
  225. package/dataflow/environments/environment.js +48 -22
  226. package/dataflow/environments/frame-memory.d.ts +0 -1
  227. package/dataflow/environments/frame-memory.js +0 -1
  228. package/dataflow/environments/group-generics.d.ts +5 -1
  229. package/dataflow/environments/group-generics.js +13 -3
  230. package/dataflow/environments/guard-facts.d.ts +169 -0
  231. package/dataflow/environments/guard-facts.js +26 -0
  232. package/dataflow/environments/identifier.d.ts +9 -1
  233. package/dataflow/environments/identifier.js +5 -0
  234. package/dataflow/environments/overwrite.js +1 -4
  235. package/dataflow/environments/pkg-name.d.ts +1 -0
  236. package/dataflow/environments/query-fn-props.d.ts +11 -7
  237. package/dataflow/environments/query-fn-props.js +78 -81
  238. package/dataflow/environments/reference-to-maybe.d.ts +3 -6
  239. package/dataflow/environments/reference-to-maybe.js +1 -3
  240. package/dataflow/environments/removal-marker.d.ts +2 -0
  241. package/dataflow/environments/removal-marker.js +5 -0
  242. package/dataflow/environments/resolve-helper.d.ts +3 -2
  243. package/dataflow/environments/resolve-helper.js +2 -0
  244. package/dataflow/environments/scoping.js +2 -8
  245. package/dataflow/eval/resolve/alias-tracking.d.ts +2 -0
  246. package/dataflow/eval/resolve/alias-tracking.js +52 -80
  247. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -3
  248. package/dataflow/eval/resolve/resolve-argument.js +8 -13
  249. package/dataflow/eval/resolve/resolve-get.js +1 -4
  250. package/dataflow/eval/resolve/resolve-strings.d.ts +2 -5
  251. package/dataflow/eval/resolve/resolve-strings.js +5 -5
  252. package/dataflow/eval/resolve/resolve-working-directory.js +1 -3
  253. package/dataflow/eval/resolve/resolve.d.ts +1 -1
  254. package/dataflow/eval/resolve/resolve.js +15 -16
  255. package/dataflow/eval/values/general.js +10 -11
  256. package/dataflow/eval/values/intervals/interval-constants.d.ts +0 -2
  257. package/dataflow/eval/values/intervals/interval-constants.js +1 -9
  258. package/dataflow/eval/values/logical/logical-constants.js +1 -4
  259. package/dataflow/eval/values/scalar/scalar-constants.d.ts +2 -6
  260. package/dataflow/eval/values/scalar/scalar-constants.js +4 -18
  261. package/dataflow/eval/values/sets/set-constants.js +1 -4
  262. package/dataflow/eval/values/vectors/vector-constants.js +1 -5
  263. package/dataflow/extractor.js +124 -28
  264. package/dataflow/fn/argument-roles.d.ts +2 -2
  265. package/dataflow/fn/argument-roles.js +9 -5
  266. package/dataflow/fn/call-sites.d.ts +57 -0
  267. package/dataflow/fn/call-sites.js +167 -0
  268. package/dataflow/fn/class-declaration.js +2 -2
  269. package/dataflow/fn/condition-handlers.d.ts +2 -0
  270. package/dataflow/fn/condition-handlers.js +3 -1
  271. package/dataflow/fn/dispatch.js +6 -5
  272. package/dataflow/fn/exceptions-of-function.d.ts +1 -1
  273. package/dataflow/fn/frame-reflection.d.ts +6 -4
  274. package/dataflow/fn/frame-reflection.js +16 -0
  275. package/dataflow/fn/function-props.d.ts +1 -1
  276. package/dataflow/fn/function-props.js +15 -25
  277. package/dataflow/fn/function-semantics.d.ts +45 -2
  278. package/dataflow/fn/function-semantics.js +18 -0
  279. package/dataflow/fn/guards/built-in-guards.d.ts +112 -0
  280. package/dataflow/fn/guards/built-in-guards.js +193 -0
  281. package/dataflow/fn/guards/call-contracts.d.ts +97 -0
  282. package/dataflow/fn/guards/call-contracts.js +331 -0
  283. package/dataflow/fn/guards/condition-grouping.d.ts +20 -0
  284. package/dataflow/fn/guards/condition-grouping.js +135 -0
  285. package/dataflow/fn/guards/function-guards.d.ts +112 -0
  286. package/dataflow/fn/guards/function-guards.js +1551 -0
  287. package/dataflow/fn/guards/group-method-guards.d.ts +28 -0
  288. package/dataflow/fn/guards/group-method-guards.js +56 -0
  289. package/dataflow/fn/guards/guard-claims.d.ts +125 -0
  290. package/dataflow/fn/guards/guard-claims.js +679 -0
  291. package/dataflow/fn/guards/guard-knowledge.d.ts +41 -0
  292. package/dataflow/fn/guards/guard-knowledge.js +180 -0
  293. package/dataflow/fn/guards/guard-term-syntax.d.ts +9 -0
  294. package/dataflow/fn/guards/guard-term-syntax.js +210 -0
  295. package/dataflow/fn/guards/guard-term.d.ts +136 -0
  296. package/dataflow/fn/guards/guard-term.js +550 -0
  297. package/dataflow/fn/guards/stated-guards.d.ts +13 -0
  298. package/dataflow/fn/guards/stated-guards.js +35 -0
  299. package/dataflow/fn/guards/stored-location.d.ts +21 -0
  300. package/dataflow/fn/guards/stored-location.js +21 -0
  301. package/dataflow/fn/higher-order-function.d.ts +2 -0
  302. package/dataflow/fn/higher-order-function.js +1 -0
  303. package/dataflow/fn/strict-function.d.ts +5 -1
  304. package/dataflow/fn/strict-function.js +73 -26
  305. package/dataflow/graph/ambient-access.d.ts +4 -1
  306. package/dataflow/graph/ambient-access.js +8 -2
  307. package/dataflow/graph/call-graph.d.ts +1 -1
  308. package/dataflow/graph/call-graph.js +1 -5
  309. package/dataflow/graph/closure-frames.js +1 -1
  310. package/dataflow/graph/dataflowgraph-builder.d.ts +4 -3
  311. package/dataflow/graph/dataflowgraph-builder.js +24 -31
  312. package/dataflow/graph/df-helper.d.ts +6 -0
  313. package/dataflow/graph/df-helper.js +33 -31
  314. package/dataflow/graph/edge.d.ts +3 -9
  315. package/dataflow/graph/edge.js +2 -6
  316. package/dataflow/graph/graph-helper.d.ts +2 -3
  317. package/dataflow/graph/graph.d.ts +13 -8
  318. package/dataflow/graph/graph.js +29 -41
  319. package/dataflow/graph/match-args.d.ts +1 -1
  320. package/dataflow/graph/match-args.js +13 -31
  321. package/dataflow/graph/quads.js +2 -7
  322. package/dataflow/graph/vertex.d.ts +1 -1
  323. package/dataflow/graph/vertex.js +1 -5
  324. package/dataflow/hooks.d.ts +1 -1
  325. package/dataflow/info.d.ts +10 -26
  326. package/dataflow/info.js +12 -33
  327. package/dataflow/internal/control-flow.d.ts +1 -2
  328. package/dataflow/internal/dispatch-linking.d.ts +3 -1
  329. package/dataflow/internal/dispatch-linking.js +1 -0
  330. package/dataflow/internal/linker.d.ts +4 -3
  331. package/dataflow/internal/linker.js +151 -43
  332. package/dataflow/internal/process/functions/call/argument/make-argument.d.ts +3 -8
  333. package/dataflow/internal/process/functions/call/argument/make-argument.js +3 -10
  334. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -1
  335. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -13
  336. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +14 -5
  337. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +33 -5
  338. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +34 -57
  339. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +506 -339
  340. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +14 -5
  341. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +14 -16
  342. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +115 -30
  343. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +2 -2
  344. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +26 -9
  345. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -3
  346. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +1 -1
  347. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +37 -14
  348. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
  349. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -7
  350. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +6 -7
  351. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +37 -44
  352. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +2 -2
  353. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +20 -20
  354. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +19 -2
  355. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +352 -55
  356. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -9
  357. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +6 -1
  358. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +119 -30
  359. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +2 -0
  360. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +9 -2
  361. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  362. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -9
  363. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +9 -6
  364. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +38 -34
  365. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +1 -1
  366. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -1
  367. package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +2 -2
  368. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +45 -134
  369. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +7 -2
  370. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +39 -11
  371. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +1 -1
  372. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -6
  373. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +7 -17
  374. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -9
  375. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +1 -1
  376. package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +1 -4
  377. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +6 -11
  378. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +4 -11
  379. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -11
  380. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.d.ts +0 -1
  381. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +0 -1
  382. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  383. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +22 -12
  384. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
  385. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +57 -19
  386. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  387. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -3
  388. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +1 -3
  389. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +2 -4
  390. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -4
  391. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  392. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -9
  393. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -2
  394. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -10
  395. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +1 -1
  396. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +4 -7
  397. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +9 -1
  398. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +65 -8
  399. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.d.ts +2 -2
  400. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +5 -23
  401. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +1 -1
  402. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  403. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +2 -2
  404. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +168 -28
  405. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -1
  406. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
  407. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  408. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
  409. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +8 -2
  410. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +155 -28
  411. package/dataflow/internal/process/functions/call/common.d.ts +2 -2
  412. package/dataflow/internal/process/functions/call/common.js +4 -5
  413. package/dataflow/internal/process/functions/call/deferred.js +2 -2
  414. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -3
  415. package/dataflow/internal/process/functions/call/named-call-handling.js +2 -2
  416. package/dataflow/internal/process/functions/call/nse-kind.d.ts +1 -4
  417. package/dataflow/internal/process/functions/call/nse-kind.js +1 -4
  418. package/dataflow/internal/process/functions/call/nse.js +1 -6
  419. package/dataflow/internal/process/functions/call/quoted.d.ts +4 -2
  420. package/dataflow/internal/process/functions/call/quoted.js +24 -5
  421. package/dataflow/internal/process/functions/process-argument.d.ts +2 -6
  422. package/dataflow/internal/process/functions/process-argument.js +3 -11
  423. package/dataflow/internal/process/functions/process-parameter.d.ts +0 -1
  424. package/dataflow/internal/process/functions/process-parameter.js +0 -1
  425. package/dataflow/internal/process/process-named-call.d.ts +1 -3
  426. package/dataflow/internal/process/process-named-call.js +1 -3
  427. package/dataflow/internal/process/process-value.d.ts +1 -4
  428. package/dataflow/internal/process/process-value.js +2 -9
  429. package/dataflow/origin/dfg-get-origin.d.ts +1 -3
  430. package/dataflow/origin/dfg-get-origin.js +10 -30
  431. package/dataflow/origin/dfg-get-symbol-refs.d.ts +0 -1
  432. package/dataflow/origin/dfg-get-symbol-refs.js +0 -1
  433. package/dataflow/processor.d.ts +10 -24
  434. package/dataflow/processor.js +1 -0
  435. package/documentation/data/dfg/doc-ambient.d.ts +4 -0
  436. package/documentation/data/dfg/doc-ambient.js +83 -0
  437. package/documentation/data/dfg/doc-data-dfg-util.d.ts +2 -6
  438. package/documentation/data/dfg/doc-data-dfg-util.js +2 -6
  439. package/documentation/data/faq/faqs.js +1 -3
  440. package/documentation/data/faq/recommended-configs.js +2 -15
  441. package/documentation/data/faq/wiki-faq-store.d.ts +1 -3
  442. package/documentation/data/faq/wiki-faq-store.js +4 -13
  443. package/documentation/data/interface/doc-writing-code.d.ts +1 -3
  444. package/documentation/data/interface/doc-writing-code.js +4 -12
  445. package/documentation/data/server/doc-data-server-messages.js +28 -120
  446. package/documentation/doc-capabilities.js +2 -2
  447. package/documentation/doc-readme.d.ts +2 -5
  448. package/documentation/doc-readme.js +4 -18
  449. package/documentation/doc-util/doc-benchmarks.d.ts +2 -6
  450. package/documentation/doc-util/doc-benchmarks.js +2 -6
  451. package/documentation/doc-util/doc-cfg.d.ts +4 -10
  452. package/documentation/doc-util/doc-cfg.js +7 -21
  453. package/documentation/doc-util/doc-cli-option.d.ts +4 -10
  454. package/documentation/doc-util/doc-cli-option.js +3 -9
  455. package/documentation/doc-util/doc-dfg.d.ts +10 -9
  456. package/documentation/doc-util/doc-dfg.js +9 -24
  457. package/documentation/doc-util/doc-escape.js +1 -7
  458. package/documentation/doc-util/doc-files.d.ts +2 -6
  459. package/documentation/doc-util/doc-files.js +2 -6
  460. package/documentation/doc-util/doc-general.d.ts +0 -10
  461. package/documentation/doc-util/doc-general.js +0 -18
  462. package/documentation/doc-util/doc-normalized-ast.js +4 -7
  463. package/documentation/doc-util/doc-playground.d.ts +1 -1
  464. package/documentation/doc-util/doc-query.d.ts +6 -8
  465. package/documentation/doc-util/doc-query.js +9 -12
  466. package/documentation/doc-util/doc-repl.d.ts +1 -3
  467. package/documentation/doc-util/doc-repl.js +1 -3
  468. package/documentation/doc-util/doc-search.d.ts +1 -3
  469. package/documentation/doc-util/doc-search.js +2 -7
  470. package/documentation/doc-util/doc-server-message.d.ts +4 -12
  471. package/documentation/doc-util/doc-server-message.js +4 -12
  472. package/documentation/doc-util/doc-structure.d.ts +5 -7
  473. package/documentation/doc-util/doc-structure.js +9 -9
  474. package/documentation/doc-util/doc-types.d.ts +4 -12
  475. package/documentation/doc-util/doc-types.js +29 -127
  476. package/documentation/issue-linting-rule.d.ts +2 -5
  477. package/documentation/issue-linting-rule.js +1 -3
  478. package/documentation/wiki-absint.js +3 -6
  479. package/documentation/wiki-analyzer.d.ts +2 -5
  480. package/documentation/wiki-analyzer.js +22 -61
  481. package/documentation/wiki-cfg.d.ts +1 -2
  482. package/documentation/wiki-cfg.js +23 -56
  483. package/documentation/wiki-core.d.ts +3 -8
  484. package/documentation/wiki-core.js +32 -59
  485. package/documentation/wiki-create-linting-rules.d.ts +1 -2
  486. package/documentation/wiki-create-linting-rules.js +1 -4
  487. package/documentation/wiki-dataflow-graph.d.ts +2 -5
  488. package/documentation/wiki-dataflow-graph.js +83 -133
  489. package/documentation/wiki-engine.d.ts +2 -5
  490. package/documentation/wiki-engine.js +3 -11
  491. package/documentation/wiki-faq.d.ts +2 -5
  492. package/documentation/wiki-faq.js +1 -3
  493. package/documentation/wiki-helper-objects.d.ts +2 -5
  494. package/documentation/wiki-helper-objects.js +3 -5
  495. package/documentation/wiki-interface.d.ts +2 -5
  496. package/documentation/wiki-interface.js +14 -54
  497. package/documentation/wiki-linter.d.ts +2 -8
  498. package/documentation/wiki-linter.js +33 -92
  499. package/documentation/wiki-linting-and-testing.d.ts +2 -5
  500. package/documentation/wiki-linting-and-testing.js +4 -9
  501. package/documentation/wiki-mk/doc-context.d.ts +6 -14
  502. package/documentation/wiki-mk/doc-context.js +8 -28
  503. package/documentation/wiki-mk/doc-maker.d.ts +9 -27
  504. package/documentation/wiki-mk/doc-maker.js +6 -18
  505. package/documentation/wiki-normalized-ast.d.ts +2 -5
  506. package/documentation/wiki-normalized-ast.js +2 -7
  507. package/documentation/wiki-onboarding.d.ts +2 -5
  508. package/documentation/wiki-onboarding.js +1 -3
  509. package/documentation/wiki-overview.d.ts +2 -5
  510. package/documentation/wiki-overview.js +1 -3
  511. package/documentation/wiki-query.d.ts +2 -5
  512. package/documentation/wiki-query.js +262 -329
  513. package/documentation/wiki-search.d.ts +2 -5
  514. package/documentation/wiki-search.js +1 -3
  515. package/documentation/wiki-setup.d.ts +2 -5
  516. package/documentation/wiki-setup.js +1 -3
  517. package/documentation/wiki-signature-database.d.ts +2 -5
  518. package/documentation/wiki-signature-database.js +3 -5
  519. package/engines.d.ts +1 -4
  520. package/engines.js +1 -4
  521. package/linter/linter-executor.d.ts +1 -3
  522. package/linter/linter-executor.js +3 -11
  523. package/linter/linter-fix.d.ts +5 -0
  524. package/linter/linter-fix.js +7 -22
  525. package/linter/linter-format.d.ts +23 -55
  526. package/linter/linter-format.js +13 -26
  527. package/linter/linter-rules.d.ts +126 -73
  528. package/linter/linter-rules.js +25 -9
  529. package/linter/linter-tags.d.ts +9 -29
  530. package/linter/linter-tags.js +9 -29
  531. package/linter/rules/{absolute-path.d.ts → absolute-file-paths.d.ts} +10 -10
  532. package/linter/rules/{absolute-path.js → absolute-file-paths.js} +16 -20
  533. package/linter/rules/call-contracts.d.ts +40 -0
  534. package/linter/rules/call-contracts.js +56 -0
  535. package/linter/rules/cmd-check/bogus-return.js +1 -1
  536. package/linter/rules/cmd-check/call-arguments.js +7 -17
  537. package/linter/rules/cmd-check/class-string-comparison.js +1 -4
  538. package/linter/rules/cmd-check/cmd-check-util.d.ts +3 -6
  539. package/linter/rules/cmd-check/cmd-check-util.js +17 -35
  540. package/linter/rules/cmd-check/compiled-code.js +6 -6
  541. package/linter/rules/cmd-check/dependency-declaration.js +4 -10
  542. package/linter/rules/cmd-check/description-metadata.js +5 -9
  543. package/linter/rules/cmd-check/documentation-mismatch.d.ts +9 -2
  544. package/linter/rules/cmd-check/documentation-mismatch.js +11 -69
  545. package/linter/rules/cmd-check/file-checks.d.ts +5 -0
  546. package/linter/rules/cmd-check/file-checks.js +5 -3
  547. package/linter/rules/cmd-check/foreign-function-calls.js +5 -7
  548. package/linter/rules/cmd-check/global-environment-modification.js +6 -9
  549. package/linter/rules/cmd-check/namespace-tampering.js +14 -24
  550. package/linter/rules/cmd-check/non-ascii-code.js +1 -4
  551. package/linter/rules/cmd-check/package-data.js +4 -4
  552. package/linter/rules/cmd-check/package-files.d.ts +1 -3
  553. package/linter/rules/cmd-check/package-files.js +2 -2
  554. package/linter/rules/cmd-check/package-hooks.js +3 -5
  555. package/linter/rules/cmd-check/package-metafiles.d.ts +2 -2
  556. package/linter/rules/cmd-check/package-metafiles.js +5 -23
  557. package/linter/rules/cmd-check/package-runtime.js +6 -19
  558. package/linter/rules/cmd-check/package-structure.js +7 -8
  559. package/linter/rules/cmd-check/rd-files.d.ts +2 -2
  560. package/linter/rules/cmd-check/rd-files.js +31 -37
  561. package/linter/rules/cmd-check/s-three-method-consistency.js +9 -14
  562. package/linter/rules/cmd-check/true-false-abbreviation.js +1 -3
  563. package/linter/rules/dataframe-access-validation.d.ts +9 -9
  564. package/linter/rules/dataframe-access-validation.js +2 -2
  565. package/linter/rules/dead-code.js +2 -15
  566. package/linter/rules/deprecated-functions.d.ts +2 -4
  567. package/linter/rules/deprecated-functions.js +45 -141
  568. package/linter/rules/file-path-validity.d.ts +1 -3
  569. package/linter/rules/file-path-validity.js +20 -61
  570. package/linter/rules/function-finder-util.d.ts +4 -9
  571. package/linter/rules/function-finder-util.js +5 -16
  572. package/linter/rules/interactive-functions.d.ts +30 -0
  573. package/linter/rules/interactive-functions.js +85 -0
  574. package/linter/rules/naming-convention.d.ts +5 -15
  575. package/linter/rules/naming-convention.js +14 -54
  576. package/linter/rules/network-functions.d.ts +3 -7
  577. package/linter/rules/network-functions.js +1 -3
  578. package/linter/rules/overwritten-file.js +4 -4
  579. package/linter/rules/problematic-inputs.d.ts +1 -2
  580. package/linter/rules/problematic-inputs.js +1 -4
  581. package/linter/rules/process-state-in-session.d.ts +0 -1
  582. package/linter/rules/process-state-in-session.js +7 -7
  583. package/linter/rules/roxygen-arguments.d.ts +6 -6
  584. package/linter/rules/roxygen-arguments.js +2 -2
  585. package/linter/rules/seeded-randomness.d.ts +2 -4
  586. package/linter/rules/seeded-randomness.js +9 -9
  587. package/linter/rules/software-has-license.js +1 -3
  588. package/linter/rules/software-has-tests.js +2 -10
  589. package/linter/rules/{stop-with-call-arg.d.ts → stop-call.d.ts} +6 -6
  590. package/linter/rules/{stop-with-call-arg.js → stop-call.js} +4 -6
  591. package/linter/rules/syntactically-valid.js +17 -44
  592. package/linter/rules/unclosed-connection.d.ts +1 -2
  593. package/linter/rules/unclosed-connection.js +1 -4
  594. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  595. package/linter/rules/undefined-symbol-util.js +8 -2
  596. package/linter/rules/undefined-symbol.js +39 -64
  597. package/linter/rules/unescaped-arguments.d.ts +10 -30
  598. package/linter/rules/unescaped-arguments.js +20 -53
  599. package/linter/rules/{unused-definition.d.ts → unused-definitions.d.ts} +12 -14
  600. package/linter/rules/{unused-definition.js → unused-definitions.js} +41 -84
  601. package/linter/rules/unused-import.d.ts +1 -1
  602. package/linter/rules/unused-import.js +4 -13
  603. package/linter/rules/useless-loop.d.ts +1 -1
  604. package/linter/rules/useless-loop.js +3 -13
  605. package/package.json +1 -1
  606. package/project/cache/flowr-analyzer-cache.d.ts +2 -7
  607. package/project/cache/flowr-analyzer-cache.js +5 -14
  608. package/project/cache/flowr-analyzer-controlflow-cache.d.ts +2 -3
  609. package/project/cache/flowr-analyzer-controlflow-cache.js +0 -1
  610. package/project/cache/flowr-cache.d.ts +2 -7
  611. package/project/cache/flowr-cache.js +2 -7
  612. package/project/context/abstract-flowr-analyzer-context.d.ts +7 -22
  613. package/project/context/abstract-flowr-analyzer-context.js +5 -16
  614. package/project/context/flowr-analyzer-context.d.ts +7 -12
  615. package/project/context/flowr-analyzer-context.js +8 -22
  616. package/project/context/flowr-analyzer-dependencies-context.d.ts +7 -19
  617. package/project/context/flowr-analyzer-dependencies-context.js +8 -22
  618. package/project/context/flowr-analyzer-environment-context.d.ts +12 -30
  619. package/project/context/flowr-analyzer-environment-context.js +4 -15
  620. package/project/context/flowr-analyzer-files-context.d.ts +14 -37
  621. package/project/context/flowr-analyzer-files-context.js +27 -87
  622. package/project/context/flowr-analyzer-gas-context.d.ts +1 -0
  623. package/project/context/flowr-analyzer-gas-context.js +9 -31
  624. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -10
  625. package/project/context/flowr-analyzer-incremental-analysis-context.js +2 -6
  626. package/project/context/flowr-analyzer-loading-order-context.d.ts +5 -15
  627. package/project/context/flowr-analyzer-meta-context.d.ts +8 -33
  628. package/project/context/flowr-analyzer-meta-context.js +0 -1
  629. package/project/context/flowr-file.d.ts +6 -14
  630. package/project/context/flowr-file.js +1 -3
  631. package/project/dependency-version-space.d.ts +1 -3
  632. package/project/dependency-version-space.js +41 -135
  633. package/project/flowr-analyzer-builder.d.ts +7 -5
  634. package/project/flowr-analyzer-builder.js +10 -12
  635. package/project/flowr-analyzer.d.ts +13 -34
  636. package/project/flowr-analyzer.js +10 -19
  637. package/project/incremental/incremental-parse/edit-computation.js +1 -8
  638. package/project/incremental/incremental-parse/incremental-parse.js +3 -12
  639. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +13 -35
  640. package/project/plugins/file-plugins/files/flowr-description-file.js +12 -38
  641. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +1 -2
  642. package/project/plugins/file-plugins/files/flowr-manifest-files.js +1 -4
  643. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +1 -2
  644. package/project/plugins/file-plugins/files/flowr-namespace-file.js +8 -42
  645. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -7
  646. package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +1 -2
  647. package/project/plugins/file-plugins/files/flowr-rd-file.js +17 -32
  648. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +15 -40
  649. package/project/plugins/file-plugins/files/flowr-rda-file.js +343 -819
  650. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +6 -18
  651. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +10 -34
  652. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +1 -2
  653. package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +4 -13
  654. package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -18
  655. package/project/plugins/file-plugins/files/flowr-sysdata-file.d.ts +1 -1
  656. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +1 -3
  657. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +1 -3
  658. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -5
  659. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.d.ts +2 -6
  660. package/project/plugins/file-plugins/flowr-analyzer-license-file-plugin.js +2 -6
  661. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +1 -4
  662. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +1 -4
  663. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -3
  664. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +1 -3
  665. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.d.ts +1 -3
  666. package/project/plugins/file-plugins/flowr-analyzer-rda-file-plugin.js +1 -3
  667. package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.d.ts +1 -3
  668. package/project/plugins/file-plugins/flowr-analyzer-sysdata-file-plugin.js +1 -3
  669. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.d.ts +1 -3
  670. package/project/plugins/file-plugins/notebooks/flowr-analyzer-jupyter-file-plugin.js +1 -3
  671. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -3
  672. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +1 -3
  673. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +1 -3
  674. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +1 -3
  675. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -3
  676. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +1 -3
  677. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +1 -3
  678. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +1 -3
  679. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -3
  680. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.js +1 -3
  681. package/project/plugins/flowr-analyzer-plugin.d.ts +2 -6
  682. package/project/plugins/flowr-analyzer-plugin.js +2 -6
  683. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +1 -3
  684. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +1 -3
  685. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +1 -5
  686. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -4
  687. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +2 -2
  688. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +13 -9
  689. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +1 -3
  690. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +0 -5
  691. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +7 -35
  692. package/project/plugins/package-version-plugins/package.d.ts +1 -1
  693. package/project/plugins/plugin-registry.d.ts +3 -10
  694. package/project/plugins/plugin-registry.js +3 -10
  695. package/project/plugins/project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin.d.ts +1 -1
  696. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -8
  697. package/project/sigdb/build.d.ts +2 -0
  698. package/project/sigdb/build.js +130 -186
  699. package/project/sigdb/decode.d.ts +4 -1
  700. package/project/sigdb/decode.js +13 -5
  701. package/project/sigdb/guarded-source.d.ts +6 -0
  702. package/project/sigdb/guarded-source.js +29 -0
  703. package/project/sigdb/manifest.js +10 -10
  704. package/project/sigdb/memory-source.d.ts +1 -1
  705. package/project/sigdb/memory-source.js +1 -1
  706. package/project/sigdb/on-demand/package-sources.js +2 -2
  707. package/project/sigdb/on-demand/recoverer.d.ts +1 -1
  708. package/project/sigdb/on-demand/remote-sources.js +2 -2
  709. package/project/sigdb/reader.d.ts +41 -25
  710. package/project/sigdb/reader.js +90 -82
  711. package/project/sigdb/schema.d.ts +24 -2
  712. package/project/sigdb/sigdb-download.js +2 -12
  713. package/project/sigdb/signature-db.d.ts +1 -1
  714. package/project/sigdb/signature-db.js +6 -6
  715. package/project/sigdb/spec-query.js +4 -4
  716. package/queries/base-query-format.js +2 -8
  717. package/queries/catalog/absint-query/absint-query-format.d.ts +4 -3
  718. package/queries/catalog/absint-query/absint-query-format.js +50 -10
  719. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +5 -3
  720. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +46 -3
  721. package/queries/catalog/call-context-query/call-context-query-executor.js +7 -45
  722. package/queries/catalog/call-context-query/call-context-query-format.d.ts +6 -21
  723. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +5 -11
  724. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +4 -10
  725. package/queries/catalog/call-context-query/identify-link-to-relation.d.ts +1 -4
  726. package/queries/catalog/call-context-query/identify-link-to-relation.js +1 -4
  727. package/queries/catalog/call-graph-query/call-graph-query-executor.d.ts +1 -3
  728. package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -7
  729. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -3
  730. package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -6
  731. package/queries/catalog/cluster-query/cluster-query-format.js +12 -3
  732. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +4 -3
  733. package/queries/catalog/code-clones-query/code-clones-query-format.js +25 -6
  734. package/queries/catalog/config-query/config-query-format.d.ts +3 -2
  735. package/queries/catalog/config-query/config-query-format.js +39 -2
  736. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +5 -9
  737. package/queries/catalog/control-flow-query/control-flow-query-format.js +13 -4
  738. package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +70 -0
  739. package/queries/catalog/data-columns-query/data-columns-query-format.js +210 -0
  740. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +4 -5
  741. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +30 -2
  742. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +4 -5
  743. package/queries/catalog/dataflow-query/dataflow-query-format.js +10 -2
  744. package/queries/catalog/dependencies-query/data-flow.js +5 -4
  745. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +1 -3
  746. package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -15
  747. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -4
  748. package/queries/catalog/dependencies-query/dependencies-query-format.js +13 -32
  749. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +1 -1
  750. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +0 -1
  751. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +1 -1
  752. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +6 -5
  753. package/queries/catalog/dependencies-query/function-info/remote-functions.js +24 -17
  754. package/queries/catalog/dependencies-query/function-info/tagged-functions.d.ts +11 -0
  755. package/queries/catalog/dependencies-query/function-info/tagged-functions.js +15 -0
  756. package/queries/catalog/dependencies-query/function-info/test-functions.js +2 -8
  757. package/queries/catalog/dependencies-query/function-info/transform-functions.js +1 -4
  758. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +1 -3
  759. package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -3
  760. package/queries/catalog/dependencies-query/plot-description.js +2 -2
  761. package/queries/catalog/dice-query/dice-query-format.d.ts +7 -2
  762. package/queries/catalog/dice-query/dice-query-format.js +32 -6
  763. package/queries/catalog/does-call-query/does-call-query-format.d.ts +5 -4
  764. package/queries/catalog/does-call-query/does-call-query-format.js +115 -30
  765. package/queries/catalog/files-query/files-query-format.d.ts +5 -6
  766. package/queries/catalog/files-query/files-query-format.js +36 -31
  767. package/queries/catalog/function-info-query/function-info-query-executor.js +1 -7
  768. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +4 -3
  769. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +301 -2
  770. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +8 -4
  771. package/queries/catalog/happens-before-query/happens-before-query-format.js +34 -2
  772. package/queries/catalog/id-map-query/id-map-query-format.d.ts +3 -2
  773. package/queries/catalog/id-map-query/id-map-query-format.js +10 -2
  774. package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -1
  775. package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +1 -3
  776. package/queries/catalog/input-sources-query/input-sources-query-executor.js +2 -7
  777. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -4
  778. package/queries/catalog/input-sources-query/input-sources-query-format.js +2 -2
  779. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +5 -11
  780. package/queries/catalog/input-sources-query/simple-input-classifier.js +2 -1
  781. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +4 -6
  782. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +33 -9
  783. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +37 -0
  784. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +123 -0
  785. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +5 -4
  786. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +58 -9
  787. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +5 -6
  788. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +21 -2
  789. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +5 -6
  790. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +13 -2
  791. package/queries/catalog/linter-query/linter-query-format.d.ts +10 -6
  792. package/queries/catalog/linter-query/linter-query-format.js +68 -25
  793. package/queries/catalog/location-map-query/location-map-query-format.d.ts +7 -3
  794. package/queries/catalog/location-map-query/location-map-query-format.js +62 -10
  795. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +4 -5
  796. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +10 -2
  797. package/queries/catalog/origin-query/origin-query-format.d.ts +4 -3
  798. package/queries/catalog/origin-query/origin-query-format.js +25 -9
  799. package/queries/catalog/project-query/project-query-format.d.ts +6 -5
  800. package/queries/catalog/project-query/project-query-format.js +93 -2
  801. package/queries/catalog/provenance-query/provenance-query-format.d.ts +7 -10
  802. package/queries/catalog/provenance-query/provenance-query-format.js +26 -5
  803. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +6 -3
  804. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +30 -11
  805. package/queries/catalog/search-query/search-query-format.d.ts +3 -2
  806. package/queries/catalog/search-query/search-query-format.js +15 -2
  807. package/queries/catalog/signature-query/signature-query-executor.d.ts +1 -1
  808. package/queries/catalog/signature-query/signature-query-executor.js +18 -41
  809. package/queries/catalog/signature-query/signature-query-format.d.ts +3 -0
  810. package/queries/catalog/signature-query/signature-query-render.d.ts +1 -1
  811. package/queries/catalog/signature-query/signature-query-render.js +29 -4
  812. package/queries/catalog/slice-query-options.d.ts +1 -1
  813. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +13 -2
  814. package/queries/catalog/static-slice-query/static-slice-query-format.js +52 -2
  815. package/queries/catalog/taint-query/taint-query-format.d.ts +5 -4
  816. package/queries/catalog/taint-query/taint-query-format.js +18 -33
  817. package/queries/query-function-filter.js +7 -33
  818. package/queries/query-function-property.d.ts +1 -1
  819. package/queries/query-function-property.js +4 -7
  820. package/queries/query-meta.d.ts +2 -0
  821. package/queries/query-meta.js +8 -0
  822. package/queries/query-print.d.ts +6 -10
  823. package/queries/query-print.js +20 -75
  824. package/queries/query.d.ts +67 -58
  825. package/queries/query.js +51 -73
  826. package/queries/virtual-query/compound-query.d.ts +2 -7
  827. package/queries/virtual-query/compound-query.js +2 -8
  828. package/queries/virtual-query/virtual-queries.js +1 -3
  829. package/r-bridge/data/get.d.ts +1 -3
  830. package/r-bridge/data/get.js +1 -3
  831. package/r-bridge/lang-4.x/ast/model/model.d.ts +19 -59
  832. package/r-bridge/lang-4.x/ast/model/model.js +9 -27
  833. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -2
  834. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +5 -14
  835. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +2 -6
  836. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +9 -25
  837. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +6 -18
  838. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -8
  839. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -3
  840. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -5
  841. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -2
  842. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -5
  843. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -3
  844. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +4 -5
  845. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -11
  846. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -6
  847. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -2
  848. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -2
  849. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -5
  850. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +4 -11
  851. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +2 -6
  852. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -5
  853. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -7
  854. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -5
  855. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +5 -15
  856. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +3 -10
  857. package/r-bridge/lang-4.x/ast/model/nodes/r-project.d.ts +3 -8
  858. package/r-bridge/lang-4.x/ast/model/nodes/r-project.js +2 -7
  859. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -2
  860. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -5
  861. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -2
  862. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -8
  863. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -3
  864. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -2
  865. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +4 -14
  866. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +42 -126
  867. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +4 -6
  868. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +5 -3
  869. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +18 -0
  870. package/r-bridge/lang-4.x/ast/model/processing/role.js +25 -0
  871. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -3
  872. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.js +1 -3
  873. package/r-bridge/lang-4.x/ast/model/syntax-version.js +2 -2
  874. package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -5
  875. package/r-bridge/lang-4.x/ast/model/type.js +1 -5
  876. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +5 -17
  877. package/r-bridge/lang-4.x/ast/parser/json/format.js +4 -20
  878. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +1 -3
  879. package/r-bridge/lang-4.x/ast/parser/json/parser.js +1 -3
  880. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.d.ts +1 -3
  881. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then-else.js +2 -7
  882. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.d.ts +1 -3
  883. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -3
  884. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -5
  885. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -10
  886. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +2 -12
  887. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -10
  888. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.js +1 -10
  889. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +2 -10
  890. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -6
  891. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -7
  892. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.d.ts +1 -3
  893. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +1 -3
  894. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
  895. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +3 -23
  896. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.d.ts +0 -1
  897. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +1 -9
  898. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +1 -10
  899. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-line-directive.js +7 -30
  900. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.d.ts +1 -3
  901. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-delimiter.js +2 -9
  902. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.d.ts +3 -9
  903. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +6 -21
  904. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -5
  905. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.d.ts +0 -1
  906. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +0 -1
  907. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +4 -20
  908. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +7 -19
  909. package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +8 -26
  910. package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.d.ts +4 -12
  911. package/r-bridge/lang-4.x/ast/parser/main/normalizer-data.js +1 -3
  912. package/r-bridge/lang-4.x/convert-values.d.ts +6 -20
  913. package/r-bridge/lang-4.x/convert-values.js +10 -41
  914. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -5
  915. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -3
  916. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -1
  917. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +39 -208
  918. package/r-bridge/parser.d.ts +1 -3
  919. package/r-bridge/parser.js +1 -4
  920. package/r-bridge/retriever.d.ts +5 -16
  921. package/r-bridge/retriever.js +5 -17
  922. package/r-bridge/roxygen2/documentation-provider.d.ts +1 -1
  923. package/r-bridge/roxygen2/roxygen-ast.d.ts +5 -15
  924. package/r-bridge/roxygen2/roxygen-ast.js +2 -6
  925. package/r-bridge/roxygen2/roxygen-parse.d.ts +2 -1
  926. package/r-bridge/roxygen2/roxygen-parse.js +4 -13
  927. package/r-bridge/shell-executor.d.ts +3 -9
  928. package/r-bridge/shell-executor.js +4 -13
  929. package/r-bridge/shell.d.ts +7 -24
  930. package/r-bridge/shell.js +15 -31
  931. package/reconstruct/auto-select/auto-select-defaults.d.ts +1 -3
  932. package/reconstruct/auto-select/auto-select-defaults.js +1 -3
  933. package/reconstruct/reconstruct.js +23 -18
  934. package/search/flowr-search-builder.d.ts +16 -48
  935. package/search/flowr-search-builder.js +15 -46
  936. package/search/flowr-search-executor.d.ts +1 -3
  937. package/search/flowr-search-executor.js +1 -3
  938. package/search/flowr-search-filters.d.ts +5 -9
  939. package/search/flowr-search-filters.js +4 -13
  940. package/search/flowr-search-printer.d.ts +3 -9
  941. package/search/flowr-search-printer.js +3 -9
  942. package/search/flowr-search-traverse.d.ts +1 -3
  943. package/search/flowr-search-traverse.js +1 -3
  944. package/search/flowr-search.d.ts +6 -19
  945. package/search/search-executor/search-enrichers.d.ts +5 -15
  946. package/search/search-executor/search-enrichers.js +6 -25
  947. package/search/search-executor/search-generators.d.ts +3 -9
  948. package/search/search-executor/search-generators.js +4 -10
  949. package/search/search-executor/search-mappers.d.ts +1 -3
  950. package/search/search-executor/search-mappers.js +1 -3
  951. package/search/search-executor/search-transformer.d.ts +3 -9
  952. package/search/search-executor/search-transformer.js +2 -6
  953. package/search/search-optimizer/search-optimizer.d.ts +1 -4
  954. package/search/search-optimizer/search-optimizer.js +4 -26
  955. package/slicing/criterion/collect-all.d.ts +1 -3
  956. package/slicing/criterion/filters/all-variables.js +2 -9
  957. package/slicing/criterion/parse.d.ts +2 -6
  958. package/slicing/criterion/parse.js +3 -9
  959. package/slicing/static/fingerprint.d.ts +1 -1
  960. package/slicing/static/removal-slice.js +6 -5
  961. package/slicing/static/slice-call.d.ts +13 -4
  962. package/slicing/static/slice-call.js +45 -6
  963. package/slicing/static/slicer-types.d.ts +3 -9
  964. package/slicing/static/static-slicer.d.ts +3 -4
  965. package/slicing/static/static-slicer.js +144 -32
  966. package/slicing/static/visiting-queue.d.ts +2 -1
  967. package/slicing/static/visiting-queue.js +4 -1
  968. package/taint-analysis/builder/domain.d.ts +1 -2
  969. package/taint-analysis/builder/domain.js +1 -6
  970. package/taint-analysis/builder/report-template.d.ts +4 -11
  971. package/taint-analysis/builder/report-template.js +2 -7
  972. package/taint-analysis/builder/taint-analysis-definition.d.ts +2 -3
  973. package/taint-analysis/builder/taint-analysis-definition.js +1 -5
  974. package/taint-analysis/builder/taint-analysis.d.ts +9 -25
  975. package/taint-analysis/builder/taint-analysis.js +1 -3
  976. package/taint-analysis/builtin-index-bridge.js +1 -7
  977. package/taint-analysis/function-categories.d.ts +4 -7
  978. package/taint-analysis/function-categories.js +4 -15
  979. package/taint-analysis/predefined/normalization.js +5 -10
  980. package/taint-analysis/predefined/predefined.d.ts +0 -1
  981. package/taint-analysis/predefined/predefined.js +1 -2
  982. package/taint-analysis/predefined/randomness-analysis.js +4 -16
  983. package/taint-analysis/predefined/secret-analysis.js +2 -8
  984. package/taint-analysis/predefined/security-analysis.js +9 -43
  985. package/taint-analysis/taint-mapping.d.ts +4 -13
  986. package/taint-analysis/taint-mapping.js +3 -9
  987. package/taint-analysis/taint-resolve.d.ts +2 -3
  988. package/taint-analysis/taint-visitor.d.ts +1 -3
  989. package/taint-analysis/taint-visitor.js +2 -2
  990. package/util/arg-matching.js +4 -4
  991. package/util/assert.d.ts +1 -3
  992. package/util/assert.js +2 -5
  993. package/util/collections/arrays.d.ts +9 -30
  994. package/util/collections/arrays.js +5 -18
  995. package/util/collections/defaultmap.d.ts +2 -7
  996. package/util/collections/defaultmap.js +2 -7
  997. package/util/collections/objectmap.d.ts +2 -6
  998. package/util/collections/objectmap.js +2 -6
  999. package/util/collections/set.d.ts +2 -6
  1000. package/util/collections/set.js +2 -6
  1001. package/util/diff-graph.d.ts +1 -3
  1002. package/util/diff-graph.js +2 -8
  1003. package/util/diff.d.ts +2 -6
  1004. package/util/diff.js +1 -3
  1005. package/util/files.d.ts +3 -9
  1006. package/util/files.js +3 -9
  1007. package/util/flowr-version.d.ts +2 -4
  1008. package/util/flowr-version.js +3 -5
  1009. package/util/html-hover-over.d.ts +1 -5
  1010. package/util/html-hover-over.js +1 -5
  1011. package/util/json.d.ts +1 -3
  1012. package/util/json.js +1 -3
  1013. package/util/log.d.ts +2 -1
  1014. package/util/log.js +7 -14
  1015. package/util/mermaid/ast.d.ts +3 -7
  1016. package/util/mermaid/ast.js +2 -6
  1017. package/util/mermaid/cfg.d.ts +2 -4
  1018. package/util/mermaid/cfg.js +4 -8
  1019. package/util/mermaid/dfg.d.ts +5 -15
  1020. package/util/mermaid/dfg.js +20 -16
  1021. package/util/mermaid/mermaid.d.ts +4 -13
  1022. package/util/mermaid/mermaid.js +5 -19
  1023. package/util/numbers.d.ts +1 -3
  1024. package/util/numbers.js +1 -3
  1025. package/util/objects.d.ts +6 -10
  1026. package/util/objects.js +12 -6
  1027. package/util/os.d.ts +1 -3
  1028. package/util/os.js +1 -3
  1029. package/util/parallel.d.ts +1 -4
  1030. package/util/parallel.js +1 -4
  1031. package/util/proc.js +2 -2
  1032. package/util/quads.d.ts +6 -19
  1033. package/util/quads.js +2 -7
  1034. package/util/r-author.d.ts +1 -3
  1035. package/util/r-author.js +2 -10
  1036. package/util/r-datasets.d.ts +27 -0
  1037. package/util/r-datasets.js +45 -0
  1038. package/util/r-license.d.ts +2 -6
  1039. package/util/r-license.js +10 -43
  1040. package/util/r-regex.d.ts +1 -3
  1041. package/util/r-regex.js +1 -3
  1042. package/util/r-value.d.ts +3 -9
  1043. package/util/r-value.js +7 -21
  1044. package/util/random.d.ts +1 -3
  1045. package/util/random.js +1 -3
  1046. package/util/range.d.ts +22 -66
  1047. package/util/range.js +22 -66
  1048. package/util/schema.d.ts +4 -13
  1049. package/util/schema.js +4 -13
  1050. package/util/simple-df/dfg-ascii.d.ts +1 -3
  1051. package/util/simple-df/dfg-ascii.js +5 -27
  1052. package/util/simple-df/dfg-view.d.ts +1 -3
  1053. package/util/simple-df/dfg-view.js +1 -3
  1054. package/util/slice-direction.d.ts +1 -3
  1055. package/util/slice-direction.js +1 -3
  1056. package/util/summarizer.d.ts +3 -8
  1057. package/util/summarizer.js +1 -3
  1058. package/util/text/ansi.d.ts +5 -15
  1059. package/util/text/ansi.js +5 -15
  1060. package/util/text/args.d.ts +8 -2
  1061. package/util/text/args.js +41 -9
  1062. package/util/text/playground-link.d.ts +11 -0
  1063. package/util/text/playground-link.js +17 -11
  1064. package/util/text/r-highlight.js +6 -6
  1065. package/util/text/strings.d.ts +6 -19
  1066. package/util/text/strings.js +7 -24
  1067. package/util/text/time.d.ts +1 -3
  1068. package/util/text/time.js +1 -3
  1069. package/util/version.d.ts +3 -9
  1070. package/util/version.js +4 -8
  1071. package/queries/catalog/absint-query/absint-query-executor.d.ts +0 -6
  1072. package/queries/catalog/absint-query/absint-query-executor.js +0 -61
  1073. package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +0 -6
  1074. package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +0 -50
  1075. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +0 -6
  1076. package/queries/catalog/cluster-query/cluster-query-executor.js +0 -21
  1077. package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +0 -6
  1078. package/queries/catalog/code-clones-query/code-clones-query-executor.js +0 -38
  1079. package/queries/catalog/config-query/config-query-executor.d.ts +0 -6
  1080. package/queries/catalog/config-query/config-query-executor.js +0 -45
  1081. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +0 -6
  1082. package/queries/catalog/control-flow-query/control-flow-query-executor.js +0 -21
  1083. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +0 -6
  1084. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +0 -40
  1085. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +0 -6
  1086. package/queries/catalog/dataflow-query/dataflow-query-executor.js +0 -20
  1087. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +0 -9
  1088. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +0 -18
  1089. package/queries/catalog/dice-query/dice-query-executor.d.ts +0 -8
  1090. package/queries/catalog/dice-query/dice-query-executor.js +0 -37
  1091. package/queries/catalog/does-call-query/does-call-query-executor.d.ts +0 -6
  1092. package/queries/catalog/does-call-query/does-call-query-executor.js +0 -116
  1093. package/queries/catalog/files-query/files-query-executor.d.ts +0 -6
  1094. package/queries/catalog/files-query/files-query-executor.js +0 -47
  1095. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +0 -6
  1096. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +0 -307
  1097. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +0 -7
  1098. package/queries/catalog/happens-before-query/happens-before-query-executor.js +0 -40
  1099. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +0 -6
  1100. package/queries/catalog/id-map-query/id-map-query-executor.js +0 -20
  1101. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -6
  1102. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +0 -31
  1103. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +0 -4
  1104. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +0 -58
  1105. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +0 -7
  1106. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +0 -25
  1107. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +0 -7
  1108. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +0 -17
  1109. package/queries/catalog/linter-query/linter-query-executor.d.ts +0 -9
  1110. package/queries/catalog/linter-query/linter-query-executor.js +0 -62
  1111. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +0 -7
  1112. package/queries/catalog/location-map-query/location-map-query-executor.js +0 -73
  1113. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +0 -6
  1114. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +0 -20
  1115. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -6
  1116. package/queries/catalog/origin-query/origin-query-executor.js +0 -31
  1117. package/queries/catalog/project-query/project-query-executor.d.ts +0 -6
  1118. package/queries/catalog/project-query/project-query-executor.js +0 -103
  1119. package/queries/catalog/provenance-query/provenance-query-executor.d.ts +0 -6
  1120. package/queries/catalog/provenance-query/provenance-query-executor.js +0 -33
  1121. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +0 -10
  1122. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +0 -40
  1123. package/queries/catalog/search-query/search-query-executor.d.ts +0 -6
  1124. package/queries/catalog/search-query/search-query-executor.js +0 -25
  1125. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +0 -14
  1126. package/queries/catalog/static-slice-query/static-slice-query-executor.js +0 -59
  1127. package/queries/catalog/taint-query/taint-query-executor.d.ts +0 -7
  1128. package/queries/catalog/taint-query/taint-query-executor.js +0 -30
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PrintingOptions = void 0;
3
+ exports.PrintWrites = exports.PrintingOptions = void 0;
4
4
  exports.hidesBody = hidesBody;
5
5
  exports.reachesBuiltInLate = reachesBuiltInLate;
6
6
  exports.readsAllAmbientState = readsAllAmbientState;
@@ -9,10 +9,15 @@ exports.ambientWritesOfRelease = ambientWritesOfRelease;
9
9
  exports.makeAmbientWritesMaybe = makeAmbientWritesMaybe;
10
10
  exports.ambientWritesBetween = ambientWritesBetween;
11
11
  exports.markForcing = markForcing;
12
+ exports.markLocking = markLocking;
13
+ exports.mayLock = mayLock;
12
14
  exports.mayForce = mayForce;
13
15
  exports.ambientAccessOfSymbol = ambientAccessOfSymbol;
16
+ exports.holds = holds;
17
+ exports.decide = decide;
18
+ exports.applies = applies;
14
19
  exports.drawingWritesDevice = drawingWritesDevice;
15
- exports.applyAmbientStateAccess = applyAmbientStateAccess;
20
+ exports.applyAmbientEffects = applyAmbientEffects;
16
21
  exports.applyAmbientStateOfCallee = applyAmbientStateOfCallee;
17
22
  exports.hiddenSideEffects = hiddenSideEffects;
18
23
  exports.writesOfHiddenBuiltIn = writesOfHiddenBuiltIn;
@@ -23,11 +28,13 @@ exports.processAmbientScope = processAmbientScope;
23
28
  exports.evaluatesCapturedCode = evaluatesCapturedCode;
24
29
  exports.autoPrintReads = autoPrintReads;
25
30
  exports.readsOfAutoPrint = readsOfAutoPrint;
31
+ exports.autoPrintsStatementsOf = autoPrintsStatementsOf;
26
32
  exports.autoPrints = autoPrints;
27
33
  exports.applyAmbientStateOfCalledBuiltIns = applyAmbientStateOfCalledBuiltIns;
28
34
  exports.errorsOfWarnings = errorsOfWarnings;
29
35
  exports.signalSites = signalSites;
30
36
  exports.maySignal = maySignal;
37
+ exports.testsValue = testsValue;
31
38
  const info_1 = require("../../../../../info");
32
39
  const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
33
40
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
@@ -36,6 +43,8 @@ const built_in_props_1 = require("../../../../../environments/built-in-props");
36
43
  const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
37
44
  const r_expression_list_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
38
45
  const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
46
+ const r_logical_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
47
+ const query_fn_props_1 = require("../../../../../environments/query-fn-props");
39
48
  const identifier_1 = require("../../../../../environments/identifier");
40
49
  const environment_1 = require("../../../../../environments/environment");
41
50
  const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
@@ -46,6 +55,7 @@ const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast
46
55
  const r_value_1 = require("../../../../../eval/values/r-value");
47
56
  const match_args_1 = require("../../../../../graph/match-args");
48
57
  const known_call_handling_1 = require("../known-call-handling");
58
+ const built_in_expression_list_1 = require("./built-in-expression-list");
49
59
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
50
60
  const node_value_1 = require("../../../../../eval/resolve/node-value");
51
61
  const applied_arguments_1 = require("../../../../../graph/applied-arguments");
@@ -62,16 +72,22 @@ const arrays_1 = require("../../../../../../util/collections/arrays");
62
72
  const ambient_access_1 = require("../../../../../graph/ambient-access");
63
73
  const ambient_state_name_1 = require("../../../../../environments/ambient-state-name");
64
74
  const built_in_ambient_keys_1 = require("./built-in-ambient-keys");
75
+ const logic_1 = require("../../../../../../util/logic");
65
76
  const base_operators_1 = require("../../../../../environments/default-builtin-config/base-operators");
66
77
  const r_while_loop_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-while-loop");
67
78
  const r_for_loop_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-for-loop");
68
79
  const built_in_kinds_1 = require("../../../../../environments/built-in-kinds");
80
+ const ambient_effect_1 = require("../../../../../environments/ambient-effect");
69
81
  var built_in_kinds_2 = require("../../../../../environments/built-in-kinds");
70
82
  Object.defineProperty(exports, "PrintingOptions", { enumerable: true, get: function () { return built_in_kinds_2.PrintingOptions; } });
71
83
  const ListConstructors = new Set(['list', 'c']);
72
- const DeviceStates = [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.otherDevices, ambient_state_name_1.AmbientStateName.device, ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy];
84
+ /** the states of the active instance of a family */
85
+ function activeStates(family) {
86
+ return family.states.map(([active]) => active);
87
+ }
88
+ const DeviceStates = ambient_state_name_1.GraphicsDevices.states.flat();
73
89
  const Accumulating = new Set([
74
- ...DeviceStates, ambient_state_name_1.AmbientStateName.canvas, ambient_state_name_1.AmbientStateName.palette, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.unknownOption,
90
+ ...DeviceStates, ...ambient_state_name_1.OutputSinks.states.flat(), ...ambient_state_name_1.MessageSinks.states.flat(), ambient_state_name_1.AmbientStateName.canvas, ambient_state_name_1.AmbientStateName.palette, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.unknownOption,
75
91
  ambient_state_name_1.AmbientStateName.warnsAsErrors, ambient_state_name_1.AmbientStateName.files, ambient_state_name_1.AmbientStateName.rngKind, ambient_state_name_1.AmbientStateName.finalizers, ...ambient_state_name_1.KeyedAccumulators
76
92
  ]);
77
93
  /** What a call does to the graphics devices. */
@@ -80,7 +96,9 @@ var DeviceAccess;
80
96
  DeviceAccess["Open"] = "open";
81
97
  DeviceAccess["Close"] = "close";
82
98
  DeviceAccess["CloseAll"] = "close-all";
83
- /** closes one that is not known to be the active one, or makes another one active */
99
+ /** closes one that is not known to be the active one, which writes what any of them holds */
100
+ DeviceAccess["CloseSome"] = "close-some";
101
+ /** makes another one active */
84
102
  DeviceAccess["Switch"] = "switch";
85
103
  })(DeviceAccess || (DeviceAccess = {}));
86
104
  /** How a write differs from the default, see {@link AmbientWrite}. */
@@ -101,21 +119,33 @@ function maybe(name) {
101
119
  function optionReads(keys) {
102
120
  return keys === undefined ? [ambient_state_name_1.AmbientStateName.allOptions] : [...keys.map(ambient_state_name_1.AmbientStateName.option), ambient_state_name_1.AmbientStateName.unknownOption];
103
121
  }
104
- /** Links `getOption(key)` to the values the calls it surely reads the option from set it to (`options(cb = function() 4)`), so it hands them back like a call hands back its result. */
105
- function linkOptionValue(res, rootId, keys, data) {
106
- if (keys?.length !== 1 || resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.unknownOption, data.environment)?.some(d => !node_id_1.NodeId.isBuiltIn(d.nodeId))) {
122
+ /**
123
+ * Links a call handing back the entry `key` of a keyed state (`getOption("digits")`, `Sys.getenv("A")`, `par("mfrow")`) to the values the calls that may have set it last gave it,
124
+ * so value resolution sees them like the result of a call. It links only if these calls cover every path and named the entry, as anything else (`options(op)`, `layout(m)`, a new device) may set it to a value we do not know.
125
+ */
126
+ function linkEntryValue(res, rootId, state, keys, data) {
127
+ const [key] = keys;
128
+ if (keys.length !== 1 || key === ambient_state_name_1.UnknownKey || resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.keyed(state, ambient_state_name_1.UnknownKey), data.environment)?.some(d => !node_id_1.NodeId.isBuiltIn(d.nodeId))) {
107
129
  return;
108
130
  }
109
- const defs = resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.option(keys[0]), data.environment) ?? [];
110
- if (!defs.some(d => (0, info_1.happensInEveryBranch)(d.cds))) {
131
+ const defs = resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.keyed(state, key), data.environment) ?? [];
132
+ const whole = new Set((resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.allOf(state), data.environment) ?? []).map(d => d.nodeId));
133
+ const own = new Set(defs.map(d => d.nodeId));
134
+ /* a write of the whole state that names no entry, like `layout(m)`, may change this one as well */
135
+ const namesEntries = (id) => {
136
+ const setter = data.completeAst.idMap.get(id);
137
+ return node_id_1.NodeId.isBuiltIn(id) || (r_function_call_1.RFunctionCall.is(setter) && setter.arguments.every(a => a === r_function_call_1.EmptyArgument || a.name !== undefined));
138
+ };
139
+ if (defs.length === 0 || [...whole].some(id => !own.has(id) && !namesEntries(id)) || !(defs.some(d => (0, info_1.happensInEveryBranch)(d.cds)) || (0, info_1.happensInEveryBranch)(defs.flatMap(d => d.cds ?? [])))) {
111
140
  return;
112
141
  }
113
142
  const values = [];
114
143
  for (const { nodeId } of defs) {
115
144
  const setter = data.completeAst.idMap.get(nodeId);
116
- const named = r_function_call_1.RFunctionCall.is(setter) ? setter.arguments.filter(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && identifier_1.Identifier.getName(a.name.content) === keys[0]) : [];
145
+ const named = r_function_call_1.RFunctionCall.is(setter) && whole.has(nodeId) ? setter.arguments.filter(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && identifier_1.Identifier.getName(a.name.content) === key) : [];
117
146
  const value = named.length === 1 ? r_argument_1.RArgument.valueOf(named[0]) : undefined;
118
- if (value === undefined) {
147
+ /* setting an option to NULL removes it, so reading it hands back the default instead */
148
+ if (value === undefined || (r_symbol_1.RSymbol.is(value) && identifier_1.Identifier.getName(value.content) === 'NULL')) {
119
149
  return;
120
150
  }
121
151
  values.push(value.info.id);
@@ -135,22 +165,19 @@ function reachesBuiltInLate(call) {
135
165
  }
136
166
  /** A call into code flowR cannot see may read any option, draw random numbers (with `draws` advancing the generator), and with `graphics` draw on the device. */
137
167
  function readsAllAmbientState(res, rootId, data, graphics, draws = true) {
138
- const reads = [ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.Env)];
139
- if (graphics) {
140
- reads.push(ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette);
141
- }
168
+ const reads = [ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.Env), ...graphics ? [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette] : []];
142
169
  return withAccess(res, rootId, data, reads, draws ? [{ ...maybe(ambient_state_name_1.AmbientStateName.rng), assumed: true }] : []);
143
170
  }
144
171
  /** Adds the reads and writes of the ambient state to what a call does, see {@link AmbientStateName}. */
145
- function withAccess(res, rootId, data, reads, writes = []) {
146
- if (reads.length === 0 && writes.length === 0) {
172
+ function withAccess(res, rootId, data, reads, writes = [], kills = []) {
173
+ if (reads.length === 0 && writes.length === 0 && kills.length === 0) {
147
174
  return res;
148
175
  }
149
176
  const cds = data.cds ? [...data.cds] : undefined;
150
177
  const maybeWritten = writes.flatMap(w => typeof w === 'object' && w.mode === AmbientWriteMode.Maybe ? [w.name] : []);
151
178
  const read = (0, arrays_1.uniqueArrayMerge)(reads, maybeWritten);
152
179
  const readRefs = read.map(name => ({ nodeId: rootId, name, type: identifier_1.ReferenceType.Variable, cds }));
153
- recordAmbient(res.graph, rootId, res.environment, read, writes);
180
+ recordAmbient(res.graph, rootId, res.environment, read, writes, kills);
154
181
  /* the writes stay out of `out`: an assignment reads whatever else its source writes (`x <- y <- 3`) */
155
182
  return {
156
183
  ...res,
@@ -162,9 +189,9 @@ function withAccess(res, rootId, data, reads, writes = []) {
162
189
  function writesLocally(environment, name, mode) {
163
190
  return mode === AmbientWriteMode.Local || (environment.level > 0 && environment.current.memory.has(name));
164
191
  }
165
- /** Notes in `graph` what the call `rootId` reads and writes, see {@link DataflowGraph#recordAmbientAccess}; `environment` is the one the writes apply to. */
166
- function recordAmbient(graph, rootId, environment, reads, writes) {
167
- if (reads.length === 0 && writes.length === 0) {
192
+ /** Notes in `graph` what the call `rootId` reads, writes, and ends (`kills`), see {@link DataflowGraph#recordAmbientAccess}; `environment` is the one the writes apply to. */
193
+ function recordAmbient(graph, rootId, environment, reads, writes, kills = []) {
194
+ if (reads.length === 0 && writes.length === 0 && kills.length === 0) {
168
195
  return;
169
196
  }
170
197
  const global = [];
@@ -174,7 +201,7 @@ function recordAmbient(graph, rootId, environment, reads, writes) {
174
201
  const { name, mode, assumed: isAssumed } = typeof write === 'string' ? { name: write, mode: undefined, assumed: undefined } : write;
175
202
  (writesLocally(environment, name, mode) ? local : isAssumed ? assumed : global).push(name);
176
203
  }
177
- graph.recordAmbientAccess(rootId, { reads, writes: global, assumed, local });
204
+ graph.recordAmbientAccess(rootId, { reads, writes: global, assumed, local, kills });
178
205
  }
179
206
  /** Whether the code itself binds a variable of the same name, by quoting it in backticks, which a write of the state must not replace, as they only share the name. */
180
207
  function boundByCode(environment, name) {
@@ -246,16 +273,20 @@ function makeAmbientWritesMaybe(after, before, target, cds) {
246
273
  }
247
274
  /** The states written in `after` that `before` does not hold, as by a promise (`delayedAssign`) whose writes only happen once a read forces it. */
248
275
  function ambientWritesBetween(after, before) {
249
- const names = new Set();
250
- for (const [name] of ambientDefinitionsBetween(after, before, false)) {
251
- names.add(name);
252
- }
253
- return [...names];
276
+ return (0, arrays_1.uniqueArray)(ambientDefinitionsBetween(after, before, false).map(([name]) => name));
254
277
  }
255
278
  /** Notes that a definition binds a promise or a text connection, which reads have to look for from now on. */
256
279
  function markForcing(environment) {
257
280
  environment_1.REnvironment.findBuiltIn(environment.current).forcing = true;
258
281
  }
282
+ /** Notes that a call may lock a binding or an environment (`lockBinding`), after which binding a name may fail. */
283
+ function markLocking(environment) {
284
+ environment_1.REnvironment.findBuiltIn(environment.current).locking = true;
285
+ }
286
+ /** Whether a call seen so far may lock a binding, see {@link markLocking}. */
287
+ function mayLock(environment) {
288
+ return environment_1.REnvironment.findBuiltIn(environment.current).locking === true;
289
+ }
259
290
  /** Whether a definition seen so far binds a promise or a text connection, see {@link markForcing}. */
260
291
  function mayForce(environment) {
261
292
  return environment_1.REnvironment.findBuiltIn(environment.current).forcing === true;
@@ -264,8 +295,17 @@ function mayForce(environment) {
264
295
  function ambientAccessOfSymbol(res, symbol, data) {
265
296
  const forcing = mayForce(data.environment);
266
297
  const definitions = forcing ? resolve_helper_1.Resolve.byName(symbol.content, data.environment) ?? [] : [];
267
- const forces = definitions.filter(identifier_1.isInGraphDefinition).flatMap(d => d.forces ?? []);
268
- return withAccess(res, symbol.info.id, data, ambientReadsOfSymbol(symbol, data, forcing), forces.map(maybe));
298
+ const promises = definitions.filter(identifier_1.isInGraphDefinition);
299
+ const reads = (0, arrays_1.uniqueArrayMerge)(ambientReadsOfSymbol(symbol, data, forcing), promises.flatMap(d => d.forcedReads ?? []));
300
+ const accessed = withAccess(res, symbol.info.id, data, reads, promises.flatMap(d => d.forces ?? []).map(maybe));
301
+ /* a read may be the one forcing the promise, so what its code binds may be bound from here on (the first read forces it, so only maybe) */
302
+ let environment = accessed.environment;
303
+ for (const write of promises.flatMap(d => d.forcedWrites ?? [])) {
304
+ environment = environment_1.REnvironment.define(write, false, environment, true);
305
+ }
306
+ /* a read reached either forces the promise or comes after a forcing that left already, so it leaves as the promise does */
307
+ const exits = promises.flatMap(d => d.forcedExits ?? []).map(e => ({ ...e, nodeId: symbol.info.id, cds: e.cds ?? data.cds }));
308
+ return environment === accessed.environment && exits.length === 0 ? accessed : { ...accessed, environment, exitPoints: [...accessed.exitPoints, ...exits] };
269
309
  }
270
310
  /** Binds `name` (globally) to the given definitions, in addition to what it holds with `keep`, so `#graphics` can become what another state holds. */
271
311
  function setAmbient(environment, name, definitions, keep = false) {
@@ -287,10 +327,7 @@ function ambientReadsOfSymbol(symbol, data, forcing) {
287
327
  else if (name === ambient_state_name_1.AmbientStateName.rngVariable) {
288
328
  return [ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.rngKind];
289
329
  }
290
- else if (name !== '.Options') {
291
- return [];
292
- }
293
- return optionsVariableReads(symbol, data);
330
+ return name === '.Options' ? optionsVariableReads(symbol, data) : [];
294
331
  }
295
332
  /** `.Options$digits` (or `.Options[["digits"]]`) reads that option, anything else done with `.Options` reads all of them. */
296
333
  function optionsVariableReads(symbol, data) {
@@ -299,13 +336,7 @@ function optionsVariableReads(symbol, data) {
299
336
  return optionReads(undefined);
300
337
  }
301
338
  const value = r_argument_1.RArgument.valueOf(parent.access[0]);
302
- if (r_string_1.RString.is(value)) {
303
- return optionReads([value.content.str]);
304
- }
305
- else if (parent.operator === '$' && r_symbol_1.RSymbol.is(value)) {
306
- return optionReads([identifier_1.Identifier.getName(value.content)]);
307
- }
308
- return optionReads(undefined);
339
+ return optionReads(r_string_1.RString.is(value) ? [value.content.str] : parent.operator === '$' && r_symbol_1.RSymbol.is(value) ? [identifier_1.Identifier.getName(value.content)] : undefined);
309
340
  }
310
341
  /** Options affecting calls we cannot name (`scipen` changes every number-to-string conversion), so setting one stays an unknown side effect. */
311
342
  const GlobalEffectOptions = new Set([
@@ -320,147 +351,289 @@ const GlobalEffectEnv = /^(TZ|LANG|LANGUAGE|LC_\w+|R_\w+|TMPDIR|TEMP|TMP|HOME|PA
320
351
  function keyedReads(state, keys) {
321
352
  return keys.length === 0 || keys.includes(ambient_state_name_1.UnknownKey) ? [ambient_state_name_1.AmbientStateName.allOf(state)] : [...keys.map(k => ambient_state_name_1.AmbientStateName.keyed(state, k)), ambient_state_name_1.AmbientStateName.keyed(state, ambient_state_name_1.UnknownKey)];
322
353
  }
354
+ const Families = {
355
+ [ambient_effect_1.AmbientPart.Device]: { state: ambient_state_name_1.AmbientStateName.device, instances: ambient_state_name_1.GraphicsDevices },
356
+ [ambient_effect_1.AmbientPart.Sink]: { state: ambient_state_name_1.AmbientStateName.sink, instances: ambient_state_name_1.OutputSinks },
357
+ [ambient_effect_1.AmbientPart.MessageSink]: { state: ambient_state_name_1.MessageSinks.switched, instances: ambient_state_name_1.MessageSinks },
358
+ [ambient_effect_1.AmbientPart.Plot]: { state: ambient_state_name_1.AmbientStateName.plot, of: ambient_state_name_1.GraphicsDevices },
359
+ [ambient_state_name_1.KeyedState.Par]: { state: ambient_state_name_1.AmbientStateName.graphics, keyed: ambient_state_name_1.KeyedState.Par, of: ambient_state_name_1.GraphicsDevices },
360
+ [ambient_effect_1.AmbientPart.Palette]: { state: ambient_state_name_1.AmbientStateName.palette },
361
+ [ambient_effect_1.AmbientPart.LastPlot]: { state: ambient_state_name_1.AmbientStateName.lastPlot },
362
+ [ambient_state_name_1.KeyedState.Option]: { state: ambient_state_name_1.AmbientStateName.allOptions, keyed: ambient_state_name_1.KeyedState.Option },
363
+ [ambient_state_name_1.KeyedState.Env]: { state: ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.Env), keyed: ambient_state_name_1.KeyedState.Env },
364
+ [ambient_state_name_1.KeyedState.Locale]: { state: ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.Locale), keyed: ambient_state_name_1.KeyedState.Locale },
365
+ [ambient_state_name_1.KeyedState.SearchPath]: { state: ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.SearchPath), keyed: ambient_state_name_1.KeyedState.SearchPath },
366
+ [ambient_state_name_1.KeyedState.InstalledPackages]: { state: ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.InstalledPackages), keyed: ambient_state_name_1.KeyedState.InstalledPackages },
367
+ [ambient_effect_1.AmbientPart.Rng]: { state: ambient_state_name_1.AmbientStateName.rng },
368
+ [ambient_effect_1.AmbientPart.RngKind]: { state: ambient_state_name_1.AmbientStateName.rngKind },
369
+ [ambient_effect_1.AmbientPart.WorkingDirectory]: { state: ambient_state_name_1.AmbientStateName.workingDirectory },
370
+ [ambient_effect_1.AmbientPart.Directories]: { state: ambient_state_name_1.AmbientStateName.directories },
371
+ [ambient_effect_1.AmbientPart.Files]: { state: ambient_state_name_1.AmbientStateName.files },
372
+ [ambient_effect_1.AmbientPart.ProjectRoot]: { state: ambient_state_name_1.AmbientStateName.projectRoot },
373
+ [ambient_effect_1.AmbientPart.LibPaths]: { state: ambient_state_name_1.AmbientStateName.libPaths },
374
+ [ambient_effect_1.AmbientPart.Umask]: { state: ambient_state_name_1.AmbientStateName.umask },
375
+ [ambient_effect_1.AmbientPart.Finalizers]: { state: ambient_state_name_1.AmbientStateName.finalizers },
376
+ [ambient_effect_1.AmbientPart.TextConnection]: { state: ambient_state_name_1.AmbientStateName.anyFile },
377
+ [ambient_effect_1.AmbientPart.ErrorMessage]: { state: ambient_state_name_1.AmbientStateName.errorMessage }
378
+ };
379
+ /** Whether an effect changes the state, so a call whose only changes are off only queries it. */
380
+ function changes(effect) {
381
+ return effect.access !== ambient_effect_1.AmbientVerb.Reads && effect.access !== ambient_effect_1.AmbientVerb.Builds;
382
+ }
383
+ function isProcessorInfo(data) {
384
+ return data !== undefined && 'completeAst' in data;
385
+ }
386
+ /** Whether the `condition` holds for the arguments `args`, what values are known decided with `data`, see {@link decide}. */
387
+ function holds(condition, args, data) {
388
+ return decide(condition, args, data).holds;
389
+ }
390
+ /**
391
+ * Whether the `condition` holds for the arguments `args`, what values are known decided with `data`, and the argument nodes that decided it.
392
+ * A forwarded `...` may hold any argument, so what it could give leaves a condition open.
393
+ */
394
+ function decide(condition, args, data) {
395
+ const dots = args.some(built_in_ambient_keys_1.forwardsDots);
396
+ const given = args.filter((a) => a !== r_function_call_1.EmptyArgument && !(0, built_in_ambient_keys_1.forwardsDots)(a));
397
+ const all = { decidedBy: args.flatMap(a => a === r_function_call_1.EmptyArgument ? [] : [a.info.id]) };
398
+ const open = (known, never = logic_1.Ternary.Never) => dots && known === never ? logic_1.Ternary.Maybe : known;
399
+ if (condition === 'no-arguments') {
400
+ return { holds: given.length > 0 ? logic_1.Ternary.Never : dots ? logic_1.Ternary.Maybe : logic_1.Ternary.Always, ...all };
401
+ }
402
+ else if (condition === 'query') {
403
+ return { holds: open(isQuery(given) ? logic_1.Ternary.Always : logic_1.Ternary.Never, logic_1.Ternary.Always), ...all };
404
+ }
405
+ else if ('flag' in condition) {
406
+ const flag = given.find(a => a.name !== undefined && identifier_1.Identifier.getName(a.name.content) === condition.flag);
407
+ if (flag === undefined) {
408
+ return { holds: open(logic_1.Ternary.Never), decidedBy: [] };
409
+ }
410
+ return { holds: r_logical_1.RLogical.is(flag.value) ? flag.value.content ? logic_1.Ternary.Always : logic_1.Ternary.Never : data === undefined ? logic_1.Ternary.Maybe : (0, built_in_ambient_keys_1.flagValue)(flag.value, data), decidedBy: [flag.info.id] };
411
+ }
412
+ else if ('arg' in condition) {
413
+ const arg = match_args_1.MatchArgs.toNames(args, condition.formals).get(condition.arg);
414
+ if (arg !== undefined && (0, built_in_ambient_keys_1.forwardsDots)(arg)) {
415
+ return { holds: logic_1.Ternary.Maybe, decidedBy: [arg.info.id] };
416
+ }
417
+ const known = 'calls' in condition ? argumentCalls(arg, condition.calls, data) : argumentIs(arg, condition.is, data);
418
+ return { holds: arg === undefined && dots ? logic_1.Ternary.Maybe : known, decidedBy: arg === undefined ? [] : [arg.info.id] };
419
+ }
420
+ const besides = given.some(a => {
421
+ const at = args.indexOf(a);
422
+ return a.name === undefined ? at >= condition.besides.length : !condition.besides.includes(identifier_1.Identifier.getName(a.name.content));
423
+ });
424
+ return { holds: besides ? logic_1.Ternary.Always : open(logic_1.Ternary.Never), ...all };
425
+ }
426
+ /** Whether the argument is one of the strings `is`, `null` standing for a missing or `NULL` argument. */
427
+ function argumentIs(arg, is, data) {
428
+ const value = r_argument_1.RArgument.valueOf(arg);
429
+ if (value === undefined || (r_symbol_1.RSymbol.is(value) && value.content === convert_values_1.RNull)) {
430
+ return is.includes(null) ? logic_1.Ternary.Always : logic_1.Ternary.Never;
431
+ }
432
+ /* an argument given is taken for a value, `NULL` only if written so */
433
+ const strings = r_string_1.RString.is(value) ? [value.content.str] : data === undefined ? undefined : (0, built_in_ambient_keys_1.stringValuesOf)(value, data);
434
+ if (!is.some(v => v !== null)) {
435
+ return logic_1.Ternary.Never;
436
+ }
437
+ else if (strings === undefined) {
438
+ return logic_1.Ternary.Maybe;
439
+ }
440
+ const known = strings.map(v => is.includes(v));
441
+ return known.every(Boolean) ? logic_1.Ternary.Always : known.some(Boolean) ? logic_1.Ternary.Maybe : logic_1.Ternary.Never;
442
+ }
443
+ /** Whether the argument is a call of one of the functions `calls`, or a variable bound to one (which only a processor tracks, after it a variable is left open). */
444
+ function argumentCalls(arg, calls, data) {
445
+ if (arg === undefined) {
446
+ return logic_1.Ternary.Never;
447
+ }
448
+ const direct = r_argument_1.RArgument.valueOf(arg);
449
+ const values = isProcessorInfo(data) ? boundValues(arg.info.id, data) : r_symbol_1.RSymbol.is(direct) ? [] : [direct].filter(assert_1.isNotUndefined);
450
+ const known = values.map(v => r_function_call_1.RFunctionCall.isNamed(v, new Set(calls)));
451
+ return known.length === 0 ? logic_1.Ternary.Maybe : known.every(Boolean) ? logic_1.Ternary.Always : known.some(Boolean) ? logic_1.Ternary.Maybe : logic_1.Ternary.Never;
452
+ }
453
+ /** Whether the effect happens for the arguments `args`, see {@link AmbientEffect#when}. */
454
+ function applies(effect, args, data) {
455
+ return logic_1.TernaryLogic.and(effect.when === undefined ? logic_1.Ternary.Always : holds(effect.when, args, data), effect.unless === undefined ? logic_1.Ternary.Always : logic_1.TernaryLogic.negate(holds(effect.unless, args, data)));
456
+ }
457
+ /**
458
+ * What the effect on a part without instances does to its state, for the entries `keys` (all of them if `undefined`).
459
+ * A part of the active instance of a family opens one on the fly, a drawing on the plot writes the canvas with `drawing`.
460
+ * With `maybe` the arguments are unknown, so a reset only adds and an entry is not known to be removed.
461
+ */
462
+ function stateAccess(effect, keys, maybe, drawing) {
463
+ const { state, keyed, of } = Families[effect.family];
464
+ const { access } = effect;
465
+ if (access === ambient_effect_1.AmbientVerb.Builds) {
466
+ return { reads: [], writes: [], kills: [] };
467
+ }
468
+ const read = keyed === undefined ? [state] : keyedReads(keyed, keys ?? []);
469
+ const written = keyed === undefined ? [state] : keys === undefined ? [ambient_state_name_1.AmbientStateName.allOf(keyed)] : (0, built_in_ambient_keys_1.keyedWrites)(keyed, keys);
470
+ const writes = [
471
+ ...of === undefined ? [] : [of.used],
472
+ ...drawing && effect.family === ambient_effect_1.AmbientPart.Plot && (access === ambient_effect_1.AmbientVerb.Adds || access === ambient_effect_1.AmbientVerb.Resets) ? [ambient_state_name_1.AmbientStateName.canvas] : [],
473
+ ...access === ambient_effect_1.AmbientVerb.Reads ? [] : access === ambient_effect_1.AmbientVerb.Resets && !maybe ? written.map(name => ({ name, mode: AmbientWriteMode.Reset })) : written
474
+ ];
475
+ return {
476
+ /* with unknown arguments, a reset may add to what is there (`plot(f, add = TRUE)`) */
477
+ reads: access === ambient_effect_1.AmbientVerb.Reads || access === ambient_effect_1.AmbientVerb.Adds || (maybe && access === ambient_effect_1.AmbientVerb.Resets) ? read : [],
478
+ writes,
479
+ kills: access === ambient_effect_1.AmbientVerb.Kills && !maybe ? written.filter(n => keyed === undefined || n !== ambient_state_name_1.AmbientStateName.allOf(keyed)) : []
480
+ };
481
+ }
323
482
  /** Whether a call drawing on a device writes its canvas, see `semantics.ambient.drawingWritesDevice`. */
324
483
  function drawingWritesDevice(config) {
325
484
  return config.semantics.ambient?.drawingWritesDevice === true;
326
485
  }
327
- /** Wires the {@link AmbientStateAccess} of a call into its dataflow information: reads become unknown references, writes define the pseudo variable globally. */
328
- function applyAmbientStateAccess(res, args, rootId, data, access) {
329
- if (!('type' in access)) {
330
- return access.reduce((r, a) => applyAmbientStateAccess(r, args, rootId, data, a), res);
331
- }
332
- else if (args === UnknownArguments) {
333
- return applyWithUnknownArguments(res, rootId, data, access);
334
- }
335
- const reads = [];
336
- const writes = [];
337
- switch (access.type) {
338
- case "read-graphics" /* AmbientStateAccessType.ReadGraphics */:
339
- reads.push(ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette);
340
- if (drawingWritesDevice(data.ctx.config)) {
341
- writes.push(ambient_state_name_1.AmbientStateName.canvas);
342
- }
343
- break;
344
- case "set-graphics" /* AmbientStateAccessType.SetGraphics */:
345
- /* the call returns the previous state */
346
- reads.push(ambient_state_name_1.AmbientStateName.graphics);
347
- if (onlyQueries(access, args)) {
348
- if (access.queryLinksTo) {
349
- (0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId, access.queryLinksTo);
350
- }
351
- }
352
- else {
353
- writes.push(ambient_state_name_1.AmbientStateName.graphics, ...access.keys === undefined ? [] : (0, built_in_ambient_keys_1.keyedWrites)(ambient_state_name_1.KeyedState.Par, (0, built_in_ambient_keys_1.keysOf)(access.keys, args, data)));
354
- }
355
- break;
356
- case "set-palette" /* AmbientStateAccessType.SetPalette */:
357
- reads.push(ambient_state_name_1.AmbientStateName.palette);
358
- if (!onlyQueries(access, args)) {
359
- writes.push(ambient_state_name_1.AmbientStateName.palette);
360
- }
361
- break;
362
- case "read-options" /* AmbientStateAccessType.ReadOptions */: {
363
- const dispatched = access.dispatchOn === undefined ? undefined : r_argument_1.RArgument.valueOf(args[access.dispatchOn]);
364
- reads.push(...printingReads(dispatched, access.dispatchOn !== undefined, access.keys, data));
365
- break;
366
- }
367
- case "get-option" /* AmbientStateAccessType.GetOption */: {
368
- const first = args.find(a => a !== r_function_call_1.EmptyArgument && (a.name === undefined || identifier_1.Identifier.getName(a.name.content) === 'x'));
369
- const keys = (0, built_in_ambient_keys_1.stringValuesOf)(r_argument_1.RArgument.valueOf(first), data);
370
- reads.push(...optionReads(keys));
371
- if (args.length === 1) {
372
- linkOptionValue(res, rootId, keys, data);
373
- }
374
- break;
486
+ /** Wires the {@link AmbientEffect}s of a call into its dataflow information: reads become unknown references, writes define the pseudo variable globally. */
487
+ function applyAmbientEffects(res, args, rootId, data, effects) {
488
+ for (const effect of ambient_effect_1.Ambient.list(effects)) {
489
+ if (args === UnknownArguments) {
490
+ res = applyWithUnknownArguments(res, rootId, data, effect);
375
491
  }
376
- case "set-options" /* AmbientStateAccessType.SetOptions */:
377
- return setOptions(res, args, rootId, data);
378
- case "set-keyed" /* AmbientStateAccessType.SetKeyed */: {
379
- const keys = (0, built_in_ambient_keys_1.keysOf)(access.keys, args, data);
380
- /* a variable R or a child process reads by itself is read by calls we cannot name */
381
- if (access.state === ambient_state_name_1.KeyedState.Env && keys.some(k => k === ambient_state_name_1.UnknownKey || GlobalEffectEnv.test(k))) {
382
- res.graph.markIdForUnknownSideEffects(rootId);
492
+ else {
493
+ const happens = applies(effect, args, data);
494
+ if (happens !== logic_1.Ternary.Never) {
495
+ res = applyEffect(res, args, rootId, data, effect, happens === logic_1.Ternary.Maybe);
383
496
  }
384
- writes.push(...(0, built_in_ambient_keys_1.keyedWrites)(access.state, keys));
385
- break;
386
497
  }
387
- case "read-keyed" /* AmbientStateAccessType.ReadKeyed */:
388
- reads.push(...keyedReads(access.state, (0, built_in_ambient_keys_1.keysOf)(access.keys, args, data)));
389
- break;
390
- case "set-state" /* AmbientStateAccessType.SetState */:
391
- if (!onlyQueries(access, args)) {
392
- writes.push(access.state);
393
- }
394
- break;
395
- case "read-state" /* AmbientStateAccessType.ReadState */:
396
- reads.push(access.state);
397
- break;
398
- case "open-device" /* AmbientStateAccessType.OpenDevice */:
399
- return deviceAccess(res, rootId, data, DeviceAccess.Open);
400
- case "close-device" /* AmbientStateAccessType.CloseDevice */:
401
- /* `dev.off(which)` may close a device other than the active one, which keeps its state then */
402
- return deviceAccess(res, rootId, data, access.all ? DeviceAccess.CloseAll : args.length > 0 ? DeviceAccess.Switch : DeviceAccess.Close);
403
- case "switch-device" /* AmbientStateAccessType.SwitchDevice */:
404
- return deviceAccess(res, rootId, data, DeviceAccess.Switch);
405
- case "set-rng" /* AmbientStateAccessType.SetRng */: {
406
- const kindFrom = access.kindFrom ?? 1;
407
- reads.push(ambient_state_name_1.AmbientStateName.rngKind);
408
- if (kindFrom > 0) {
409
- writes.push(ambient_state_name_1.AmbientStateName.rng);
410
- }
411
- /* a new kind reseeds the generator from its current state, so it changes the stream as well */
412
- if (args.some((a, i) => a !== r_function_call_1.EmptyArgument && (a.name === undefined ? i >= kindFrom : identifier_1.Identifier.getName(a.name.content) !== 'seed'))) {
413
- reads.push(ambient_state_name_1.AmbientStateName.rng);
414
- writes.push(ambient_state_name_1.AmbientStateName.rngKind, ambient_state_name_1.AmbientStateName.rng);
498
+ }
499
+ return res;
500
+ }
501
+ /** Applies the effect, which only `maybe` happens. */
502
+ function applyEffect(res, args, rootId, data, effect, maybe = false) {
503
+ const { instances, keyed } = Families[effect.family];
504
+ if (instances !== undefined) {
505
+ return instanceAccess(res, rootId, data, effect, instances, args.length > 0);
506
+ }
507
+ const named = effect.member === undefined || effect.member === 'every' ? undefined : (0, built_in_ambient_keys_1.keysOf)(effect.member, args, data);
508
+ /* a path, url, or remote (`user/repo`) does not tell which package it installs */
509
+ const keys = effect.family === ambient_state_name_1.KeyedState.InstalledPackages ? named?.map(k => ambient_state_name_1.PlainPackageName.test(k) ? k : ambient_state_name_1.UnknownKey) : named;
510
+ switch (effect.family) {
511
+ case ambient_state_name_1.KeyedState.Option:
512
+ return effect.access === ambient_effect_1.AmbientVerb.Reads ? readOptions(res, args, rootId, data, effect, keys) : setOptions(res, args, rootId, data);
513
+ case ambient_effect_1.AmbientPart.Files:
514
+ return fileAccess(res, rootId, data, effect);
515
+ case ambient_effect_1.AmbientPart.TextConnection:
516
+ return openTextConnection(res, args, rootId, data);
517
+ case ambient_effect_1.AmbientPart.Finalizers:
518
+ return effect.access === ambient_effect_1.AmbientVerb.Reads ? runFinalizers(res, rootId, data) : registerFinalizer(res, args, rootId, data);
519
+ case ambient_effect_1.AmbientPart.LastPlot:
520
+ if (changes(effect)) {
521
+ /* the plot object is what the outermost `+` the call is part of builds */
522
+ recordAmbient(res.graph, rootId, res.environment, [], [ambient_state_name_1.AmbientStateName.lastPlot]);
523
+ return { ...res, environment: defineAmbient(res.environment, outermostPlus(rootId, data.completeAst.idMap), data.cds ? [...data.cds] : undefined, [ambient_state_name_1.AmbientStateName.lastPlot]) };
415
524
  }
416
525
  break;
417
- }
418
- case "draw-rng" /* AmbientStateAccessType.DrawRng */:
419
- reads.push(ambient_state_name_1.AmbientStateName.rng);
420
- writes.push(ambient_state_name_1.AmbientStateName.rng);
421
- break;
422
- case "read-files" /* AmbientStateAccessType.ReadFiles */: {
423
- const stems = fileStems(res, rootId, data, access);
424
- if (stems?.length === 0) {
425
- break;
526
+ case ambient_state_name_1.KeyedState.Env:
527
+ case ambient_state_name_1.KeyedState.Par:
528
+ if (effect.handsBack && keys !== undefined && keyed !== undefined) {
529
+ linkEntryValue(res, rootId, keyed, keys, data);
426
530
  }
427
- reads.push(ambient_state_name_1.AmbientStateName.workingDirectory, ...stems === undefined ? [ambient_state_name_1.AmbientStateName.files] : [...stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.anyFile]);
428
- /* a read through a connection the program holds moves its position, so the next read depends on this one */
429
- if (readsThroughHandle(res, rootId, data, access.sig)) {
430
- writes.push(...stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] : stems.map(ambient_state_name_1.AmbientStateName.file));
431
- }
432
- break;
433
- }
434
- case "write-files" /* AmbientStateAccessType.WriteFiles */: {
435
- const stems = fileStems(res, rootId, data, access);
436
- if (stems?.length === 0) {
437
- break;
531
+ /* a variable R or a child process reads by itself is read by calls we cannot name */
532
+ if (effect.family === ambient_state_name_1.KeyedState.Env && changes(effect) && keys?.some(k => k === ambient_state_name_1.UnknownKey || GlobalEffectEnv.test(k))) {
533
+ res.graph.markIdForUnknownSideEffects(rootId);
438
534
  }
439
- reads.push(ambient_state_name_1.AmbientStateName.workingDirectory);
440
- writes.push(...stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile] : stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.files);
441
535
  break;
442
- }
443
- case "set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */:
444
- /* a relative `dir` resolves against the current one, which the call also returns */
445
- reads.push(ambient_state_name_1.AmbientStateName.workingDirectory);
446
- writes.push(ambient_state_name_1.AmbientStateName.workingDirectory);
447
- break;
448
- case "get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */:
449
- reads.push(ambient_state_name_1.AmbientStateName.workingDirectory);
450
- break;
451
- case "open-text-connection" /* AmbientStateAccessType.OpenTextConnection */:
452
- return openTextConnection(res, args, rootId, data);
453
- case "register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */:
454
- return registerFinalizer(res, args, rootId, data);
455
- case "run-finalizers" /* AmbientStateAccessType.RunFinalizers */: {
456
- const registered = (resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.finalizers, data.environment) ?? []).filter(identifier_1.isInGraphDefinition);
457
- for (const fn of registered.flatMap(d => d.value ?? [])) {
458
- res.graph.addEdge(rootId, fn, edge_1.EdgeType.Calls);
459
- }
460
- return withAccess(res, rootId, data, [ambient_state_name_1.AmbientStateName.finalizers], registered.flatMap(d => d.writes ?? []).map(maybe));
536
+ }
537
+ const { reads, writes, kills } = stateAccess(effect, keyed === undefined ? undefined : keys, maybe, drawingWritesDevice(data.ctx.config));
538
+ return withAccess(res, rootId, data, reads, (0, arrays_1.uniqueArray)(writes), kills);
539
+ }
540
+ /** What the effect on an instance family does: opening, closing, and switching move the states of the instances, see {@link deviceAccess}. */
541
+ function instanceAccess(res, rootId, data, effect, family, named) {
542
+ const { state } = Families[effect.family];
543
+ switch (effect.access) {
544
+ case ambient_effect_1.AmbientVerb.Opens:
545
+ return deviceAccess(res, rootId, data, DeviceAccess.Open, family);
546
+ case ambient_effect_1.AmbientVerb.Switches:
547
+ return deviceAccess(res, rootId, data, DeviceAccess.Switch, family);
548
+ case ambient_effect_1.AmbientVerb.Closes:
549
+ /* `dev.off(which)` may close an instance other than the active one, which keeps its state then */
550
+ return deviceAccess(res, rootId, data, effect.member === 'every' ? DeviceAccess.CloseAll : named ? DeviceAccess.CloseSome : DeviceAccess.Close, family);
551
+ default: {
552
+ const { reads, writes } = instanceStateAccess(effect, state, family);
553
+ return withAccess(res, rootId, data, reads, writes);
461
554
  }
462
555
  }
463
- return withAccess(res, rootId, data, reads, (0, arrays_1.uniqueArray)(writes));
556
+ }
557
+ /** What reading or using an instance does, `every` one with {@link AmbientEffect#member}: using it adds to what its closing links to. */
558
+ function instanceStateAccess(effect, state, family) {
559
+ const others = family.states.find(([active]) => active === state)?.[1];
560
+ return {
561
+ reads: effect.access === ambient_effect_1.AmbientVerb.Builds ? [] : [state, ...effect.member === 'every' && others !== undefined ? [others] : []],
562
+ writes: changes(effect) ? [family.used] : []
563
+ };
564
+ }
565
+ /** What reading options does: the entries `keys` names, all options if a method may print the value `print(x)` dispatches on, which draws a plot object. */
566
+ function readOptions(res, args, rootId, data, effect, keys) {
567
+ if (effect.dispatchOn !== undefined) {
568
+ const dispatched = r_argument_1.RArgument.valueOf(args[effect.dispatchOn]);
569
+ return withAccess(res, rootId, data, printingReads(dispatched, true, keys ?? [], data), mayHoldPlot(dispatched, data) ? DrawsNewPlot : []);
570
+ }
571
+ if (effect.handsBack) {
572
+ linkEntryValue(res, rootId, ambient_state_name_1.KeyedState.Option, keys ?? [], data);
573
+ }
574
+ return withAccess(res, rootId, data, keyedReads(ambient_state_name_1.KeyedState.Option, keys ?? []));
575
+ }
576
+ /** what every access of a file reads to find it: the working directory a relative path starts from and the directories the path leads through */
577
+ const FileSystemReads = [ambient_state_name_1.AmbientStateName.workingDirectory, ambient_state_name_1.AmbientStateName.directories];
578
+ /** What reading or writing the files the call names does, see {@link fileStems}. */
579
+ function fileAccess(res, rootId, data, effect) {
580
+ const stems = fileStems(res, rootId, data, effect);
581
+ if (stems?.length === 0) {
582
+ return res;
583
+ }
584
+ if (effect.access === ambient_effect_1.AmbientVerb.Reads) {
585
+ /* a read through a connection the program holds moves its position, so the next read depends on this one */
586
+ const moves = readsThroughHandle(res, rootId, data, effect.sig) ? stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] : stems.map(ambient_state_name_1.AmbientStateName.file) : [];
587
+ return withAccess(res, rootId, data, [...FileSystemReads, ...stems === undefined ? [ambient_state_name_1.AmbientStateName.files] : [...stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.anyFile]], moves);
588
+ }
589
+ return withAccess(res, rootId, data, FileSystemReads, [...stems === undefined ? [ambient_state_name_1.AmbientStateName.anyFile] : stems.map(ambient_state_name_1.AmbientStateName.file), ambient_state_name_1.AmbientStateName.files]);
590
+ }
591
+ /** `gc()` may run every registered finalizer whose object is released. */
592
+ function runFinalizers(res, rootId, data) {
593
+ const registered = (resolve_helper_1.Resolve.byName(ambient_state_name_1.AmbientStateName.finalizers, data.environment) ?? []).filter(identifier_1.isInGraphDefinition);
594
+ for (const fn of registered.flatMap(d => d.value ?? [])) {
595
+ res.graph.addEdge(rootId, fn, edge_1.EdgeType.Calls);
596
+ }
597
+ return withAccess(res, rootId, data, [ambient_state_name_1.AmbientStateName.finalizers], registered.flatMap(d => d.writes ?? []).map(maybe));
598
+ }
599
+ /** drawing a new plot adds to the device, which opens one if none is open, and replaces its plot */
600
+ const DrawsNewPlot = [ambient_state_name_1.AmbientStateName.device, { name: ambient_state_name_1.AmbientStateName.plot, mode: AmbientWriteMode.Reset }];
601
+ /**
602
+ * Whether the value of `node` may be a plot object, which printing draws: a call building one ({@link AmbientVerb.Builds}, as `ggplot` does),
603
+ * a `+` adding to one, or a variable bound to either.
604
+ */
605
+ function mayHoldPlot(node, data, seen = new Set()) {
606
+ if (node === undefined || seen.has(node.info.id)) {
607
+ return false;
608
+ }
609
+ seen.add(node.info.id);
610
+ if (r_function_call_1.RFunctionCall.isNamed(node)) {
611
+ return ((0, query_fn_props_1.statedFunctions)(node.functionName.content, data.environment) ?? []).some(t => hiddenAccess(t).some(a => a.family === ambient_effect_1.AmbientPart.Plot && a.access === ambient_effect_1.AmbientVerb.Builds));
612
+ }
613
+ else if (r_binary_op_1.RBinaryOp.is(node)) {
614
+ return node.operator === '+' && (mayHoldPlot(node.lhs, data, seen) || mayHoldPlot(node.rhs, data, seen));
615
+ }
616
+ else if (r_if_then_else_1.RIfThenElse.is(node)) {
617
+ return mayHoldPlot(node.then, data, seen) || mayHoldPlot(node.otherwise, data, seen);
618
+ }
619
+ else if (r_expression_list_1.RExpressionList.is(node)) {
620
+ return mayHoldPlot(node.children.at(-1), data, seen);
621
+ }
622
+ else if (!r_symbol_1.RSymbol.is(node)) {
623
+ return false;
624
+ }
625
+ return (resolve_helper_1.Resolve.byName(node.content, data.environment) ?? []).filter(identifier_1.isInGraphDefinition).some(d => {
626
+ const source = data.completeAst.idMap.get(d.definedAt);
627
+ return r_binary_op_1.RBinaryOp.is(source) && mayHoldPlot(source.lhs.info.id === d.nodeId ? source.rhs : source.lhs, data, seen);
628
+ });
629
+ }
630
+ /** the outermost `+` chain holding `id`, `id` itself if it is part of none */
631
+ function outermostPlus(id, idMap) {
632
+ let at = idMap.get(id);
633
+ for (let parent = at === undefined ? undefined : model_1.RNode.directParent(at, idMap); r_binary_op_1.RBinaryOp.is(parent) && parent.operator === '+'; parent = model_1.RNode.directParent(parent, idMap)) {
634
+ at = parent;
635
+ }
636
+ return at?.info.id ?? id;
464
637
  }
465
638
  /** `reg.finalizer(e, f)` keeps the functions `f` may be, and the name holding `e`, whose release lets `gc()` run them. */
466
639
  function registerFinalizer(res, args, rootId, data) {
@@ -528,8 +701,7 @@ function callsTagged(node, data, tag) {
528
701
  /** Whether the resource argument `id` names no file: `""` (the console for `cat`), `NULL`, or a console connection like `stdout()`. */
529
702
  function namesNoFile(id, data) {
530
703
  const values = boundValues(id, data);
531
- return values.length > 0 && values.every(v => (r_string_1.RString.is(v) && v.content.str === '') || (r_symbol_1.RSymbol.is(v) && v.content === convert_values_1.RNull)
532
- || callsTagged(v, data, built_in_props_1.SemanticCallTag.Console));
704
+ return values.length > 0 && values.every(v => (r_string_1.RString.is(v) && v.content.str === '') || (r_symbol_1.RSymbol.is(v) && v.content === convert_values_1.RNull) || callsTagged(v, data, built_in_props_1.SemanticCallTag.Console));
533
705
  }
534
706
  /** The stems of the files the call names, `undefined` unless every file argument is a known path to a file with an extension (a device's `plot%03d.png` or a directory may stand for others). */
535
707
  function fileStems(res, rootId, data, { sig, numbered }) {
@@ -581,133 +753,120 @@ function isPlainValue(node, data) {
581
753
  }
582
754
  /** The arguments of a call made on our behalf, like `do.call(par, args)`, which we cannot see. */
583
755
  const UnknownArguments = Symbol('unknown-arguments');
584
- function applyWithUnknownArguments(res, rootId, data, access) {
585
- switch (access.type) {
586
- case "close-device" /* AmbientStateAccessType.CloseDevice */:
587
- return deviceAccess(res, rootId, data, access.all ? DeviceAccess.CloseAll : DeviceAccess.Switch);
756
+ function applyWithUnknownArguments(res, rootId, data, effect) {
757
+ const { instances } = Families[effect.family];
758
+ if (instances !== undefined && effect.access !== ambient_effect_1.AmbientVerb.Reads && effect.access !== ambient_effect_1.AmbientVerb.Adds) {
759
+ /* we cannot tell which instance a close closes */
760
+ return instanceAccess(res, rootId, data, effect, instances, true);
761
+ }
762
+ else if (effect.family === ambient_effect_1.AmbientPart.Files) {
588
763
  /* the arguments handed on (`do.call(readLines, list("a.txt"))`, `lapply(files, readLines)`) may still name the files */
589
- case "open-device" /* AmbientStateAccessType.OpenDevice */:
590
- case "switch-device" /* AmbientStateAccessType.SwitchDevice */:
591
- case "read-files" /* AmbientStateAccessType.ReadFiles */:
592
- case "write-files" /* AmbientStateAccessType.WriteFiles */:
593
- return applyAmbientStateAccess(res, [], rootId, data, access);
594
- case "set-options" /* AmbientStateAccessType.SetOptions */:
595
- /* like `options(op)`: it may set anything */
596
- res.graph.markIdForUnknownSideEffects(rootId);
597
- }
598
- const { reads, writes } = unknownArgumentAccess(access, drawingWritesDevice(data.ctx.config));
764
+ return applyEffect(res, [], rootId, data, effect);
765
+ }
766
+ else if (effect.family === ambient_state_name_1.KeyedState.Option && changes(effect)) {
767
+ /* like `options(op)`: it may set anything */
768
+ res.graph.markIdForUnknownSideEffects(rootId);
769
+ }
770
+ const { reads, writes } = unknownArgumentAccess(effect, drawingWritesDevice(data.ctx.config));
599
771
  return withAccess(res, rootId, data, reads, writes);
600
772
  }
601
- const Devices = { reads: [], writes: [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device] };
602
773
  /* evaluated code may attach a package as well, which every call nothing else resolves reads */
603
774
  const Quoted = { reads: [ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette], writes: [ambient_state_name_1.AmbientStateName.unknownOption, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette, ambient_state_name_1.AmbientStateName.allOf(ambient_state_name_1.KeyedState.SearchPath)] };
604
- /** What a call of the given kind may read and write when its arguments are unknown, as when only linking reveals it. */
605
- const UnknownArgumentAccess = {
606
- ["set-options" /* AmbientStateAccessType.SetOptions */]: { reads: [ambient_state_name_1.AmbientStateName.allOptions], writes: [ambient_state_name_1.AmbientStateName.unknownOption, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.warnsAsErrors] },
607
- ["get-option" /* AmbientStateAccessType.GetOption */]: { reads: [ambient_state_name_1.AmbientStateName.allOptions], writes: [] },
608
- ["set-graphics" /* AmbientStateAccessType.SetGraphics */]: { reads: [ambient_state_name_1.AmbientStateName.graphics], writes: [ambient_state_name_1.AmbientStateName.graphics] },
609
- ["read-graphics" /* AmbientStateAccessType.ReadGraphics */]: { reads: [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.palette], writes: [] },
610
- ["set-palette" /* AmbientStateAccessType.SetPalette */]: { reads: [ambient_state_name_1.AmbientStateName.palette], writes: [ambient_state_name_1.AmbientStateName.palette] },
611
- ["open-device" /* AmbientStateAccessType.OpenDevice */]: Devices,
612
- ["close-device" /* AmbientStateAccessType.CloseDevice */]: Devices,
613
- ["switch-device" /* AmbientStateAccessType.SwitchDevice */]: Devices,
614
- ["set-rng" /* AmbientStateAccessType.SetRng */]: { reads: [ambient_state_name_1.AmbientStateName.rngKind], writes: [ambient_state_name_1.AmbientStateName.rng, ambient_state_name_1.AmbientStateName.rngKind] },
615
- ["draw-rng" /* AmbientStateAccessType.DrawRng */]: { reads: [ambient_state_name_1.AmbientStateName.rng], writes: [ambient_state_name_1.AmbientStateName.rng] },
616
- ["read-files" /* AmbientStateAccessType.ReadFiles */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory, ambient_state_name_1.AmbientStateName.files], writes: [] },
617
- ["write-files" /* AmbientStateAccessType.WriteFiles */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory], writes: [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] },
618
- ["set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory], writes: [ambient_state_name_1.AmbientStateName.workingDirectory] },
619
- ["get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */]: { reads: [ambient_state_name_1.AmbientStateName.workingDirectory], writes: [] },
620
- ["open-text-connection" /* AmbientStateAccessType.OpenTextConnection */]: { reads: [], writes: [] },
621
- ["register-finalizer" /* AmbientStateAccessType.RegisterFinalizer */]: { reads: [], writes: [ambient_state_name_1.AmbientStateName.finalizers] },
622
- ["run-finalizers" /* AmbientStateAccessType.RunFinalizers */]: { reads: [ambient_state_name_1.AmbientStateName.finalizers], writes: [] }
623
- };
624
- function unknownArgumentAccess(access, drawing) {
625
- switch (access.type) {
626
- case "read-options" /* AmbientStateAccessType.ReadOptions */:
627
- return { reads: optionReads(access.dispatchOn === undefined ? access.keys : undefined), writes: [] };
628
- case "set-keyed" /* AmbientStateAccessType.SetKeyed */:
629
- return { reads: [], writes: (0, built_in_ambient_keys_1.keyedWrites)(access.state, [ambient_state_name_1.UnknownKey]) };
630
- case "read-keyed" /* AmbientStateAccessType.ReadKeyed */:
631
- return { reads: [ambient_state_name_1.AmbientStateName.allOf(access.state)], writes: [] };
632
- case "set-state" /* AmbientStateAccessType.SetState */:
633
- return { reads: [], writes: [access.state] };
634
- case "read-state" /* AmbientStateAccessType.ReadState */:
635
- return { reads: [access.state], writes: [] };
636
- case "read-graphics" /* AmbientStateAccessType.ReadGraphics */:
637
- return { reads: UnknownArgumentAccess[access.type].reads, writes: drawing ? [ambient_state_name_1.AmbientStateName.canvas] : [] };
638
- default:
639
- return UnknownArgumentAccess[access.type];
640
- }
641
- }
642
- /** Graphics parameters are per device; within a function the open devices are unknown, so a device call only adds. */
643
- function deviceAccess(res, rootId, data, kind) {
644
- /* only a switch reads the state; what a closed device holds reaches its file through the plots on it (see LinkToLastPlot) */
645
- const reads = kind === DeviceAccess.Switch ? [ambient_state_name_1.AmbientStateName.graphics] : [];
775
+ /** What the effect may read and write when the arguments of the call are unknown, as when only linking reveals it: any condition may hold, and any entry be named but stated ones. */
776
+ function unknownArgumentAccess(effect, drawing) {
777
+ const { state, instances } = Families[effect.family];
778
+ if (instances !== undefined) {
779
+ return effect.access === ambient_effect_1.AmbientVerb.Reads || effect.access === ambient_effect_1.AmbientVerb.Adds ? instanceStateAccess(effect, state, instances) : { reads: [], writes: activeStates(instances) };
780
+ }
781
+ switch (effect.family) {
782
+ case ambient_state_name_1.KeyedState.Option:
783
+ if (changes(effect)) {
784
+ return { reads: [ambient_state_name_1.AmbientStateName.allOptions], writes: [ambient_state_name_1.AmbientStateName.unknownOption, ambient_state_name_1.AmbientStateName.allOptions, ambient_state_name_1.AmbientStateName.warnsAsErrors] };
785
+ }
786
+ break;
787
+ case ambient_effect_1.AmbientPart.Files:
788
+ return effect.access === ambient_effect_1.AmbientVerb.Reads ? { reads: [...FileSystemReads, ambient_state_name_1.AmbientStateName.files], writes: [] }
789
+ : { reads: FileSystemReads, writes: [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files] };
790
+ case ambient_effect_1.AmbientPart.TextConnection:
791
+ return { reads: [], writes: [] };
792
+ case ambient_effect_1.AmbientPart.Finalizers:
793
+ return effect.access === ambient_effect_1.AmbientVerb.Reads ? { reads: [state], writes: [] } : { reads: [], writes: [state] };
794
+ }
795
+ const member = effect.member;
796
+ const keys = typeof member === 'object' && member.from === 'constant' && effect.dispatchOn === undefined ? member.keys : [ambient_state_name_1.UnknownKey];
797
+ const { reads, writes } = stateAccess(effect, Families[effect.family].keyed === undefined ? undefined : keys, true, drawing);
798
+ return { reads, writes: writes.map(w => typeof w === 'string' ? w : w.name) };
799
+ }
800
+ /**
801
+ * Opens, closes, or switches an instance of the `family` (a graphics device), each of whose states is per instance.
802
+ * A close reads the calls that opened and used the closed instance, the explicit opening reads the close in turn, so keeping it keeps the close.
803
+ * Within a function the open instances are unknown, so a call only adds.
804
+ */
805
+ function deviceAccess(res, rootId, data, kind, family = ambient_state_name_1.GraphicsDevices) {
806
+ const otherOf = (state) => family.states.find(([active]) => active === state)?.[1] ?? state;
807
+ const actives = activeStates(family);
808
+ /* `x <- dev.off()` is the device that is active afterward, one of the others */
809
+ const closing = kind === DeviceAccess.Close ? [family.used, ...resultIsUsed(rootId, data) ? [otherOf(family.used)] : []] : [];
810
+ const all = [family.used, otherOf(family.used)];
811
+ const reads = kind === DeviceAccess.Switch ? [family.switched] : kind === DeviceAccess.CloseSome ? [family.switched, ...all] : kind === DeviceAccess.CloseAll ? all : closing;
646
812
  /* closing writes the file of the device, which its opening names unless we do not know the device closed */
647
813
  const unnamedFile = kind === DeviceAccess.Open ? [] : [ambient_state_name_1.AmbientStateName.anyFile, ambient_state_name_1.AmbientStateName.files];
648
814
  const cds = data.cds ? [...data.cds] : undefined;
649
815
  if (data.environment.level > 0) {
650
816
  /* a device the body opened itself is the one a later close in the same body closes: `f <- function() { pdf("a.pdf"); plot(1); dev.off() }` writes `a.pdf` and no other file */
651
- const here = kind === DeviceAccess.Close ? res.environment.current.memory.get(ambient_state_name_1.AmbientStateName.deviceOpenedHere) ?? [] : [];
817
+ const here = kind === DeviceAccess.Close ? res.environment.current.memory.get(family.openedHere) ?? [] : [];
652
818
  for (const open of here) {
653
819
  res.graph.addEdge(open.nodeId, rootId, edge_1.EdgeType.Reads);
654
820
  }
655
- let environment = { ...res.environment, current: res.environment.current.removeAll([{ name: ambient_state_name_1.AmbientStateName.deviceOpenedHere }]) };
821
+ let environment = { ...res.environment, current: res.environment.current.removeAll([{ name: family.openedHere }]) };
656
822
  if (kind === DeviceAccess.Open) {
657
- environment = defineAmbient(environment, rootId, cds, [{ name: ambient_state_name_1.AmbientStateName.deviceOpenedHere, mode: AmbientWriteMode.Local }]);
823
+ environment = defineAmbient(environment, rootId, cds, [{ name: family.openedHere, mode: AmbientWriteMode.Local }]);
658
824
  }
659
- return withAccess({ ...res, environment }, rootId, data, reads, [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device, ...here.length > 0 ? [] : unnamedFile]);
825
+ recordAmbient(res.graph, rootId, environment, [], [], kind === DeviceAccess.Close || kind === DeviceAccess.CloseAll ? actives : []);
826
+ return withAccess({ ...res, environment }, rootId, data, reads, [...actives, ...here.length > 0 ? [] : unnamedFile]);
660
827
  }
661
828
  const lookup = (name) => resolve_helper_1.Resolve.byName(name, res.environment) ?? [];
662
- const current = lookup(ambient_state_name_1.AmbientStateName.graphics);
663
- const others = lookup(ambient_state_name_1.AmbientStateName.otherDevices);
664
- const opener = lookup(ambient_state_name_1.AmbientStateName.device);
665
- const otherOpeners = lookup(ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy);
666
- let environment = res.environment;
667
- const reset = (name) => defineAmbient(environment, rootId, cds, [{ name, mode: AmbientWriteMode.Reset }]);
668
- /* a later plot depends on neither the close nor the closed device's state; a device only depends on its close so it does not catch later plots */
669
- const closes = (openers) => {
670
- for (const open of openers) {
671
- res.graph.addEdge(open.nodeId, rootId, edge_1.EdgeType.Reads);
672
- }
673
- };
829
+ /* a use opening the device on the fly (`plot` without one) names no file and needs no close */
830
+ const closed = kind === DeviceAccess.Close ? lookup(family.opened) : kind === DeviceAccess.CloseAll ? [...lookup(family.opened), ...lookup(otherOf(family.opened))] : [];
831
+ for (const open of closed) {
832
+ res.graph.addEdge(open.nodeId, rootId, edge_1.EdgeType.Reads);
833
+ }
674
834
  /* in a loop, an earlier round may have opened a device this one leaves behind, or a close may leave one open */
675
835
  const repeats = model_1.RLoopConstructs.encloses(rootId, data.completeAst.idMap);
676
- const earlierRound = repeats ? [{ nodeId: rootId, name: ambient_state_name_1.AmbientStateName.device, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds: cds ?? [] }] : [];
677
- switch (kind) {
678
- case DeviceAccess.Open:
679
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevices, [...others, ...current, ...earlierRound]);
680
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy, [...otherOpeners, ...opener, ...earlierRound]);
681
- environment = reset(ambient_state_name_1.AmbientStateName.graphics);
682
- environment = reset(ambient_state_name_1.AmbientStateName.device);
683
- break;
684
- case DeviceAccess.Close:
685
- closes(opener);
686
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.graphics, repeats ? [...others, ...current] : others);
687
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.device, repeats ? [...otherOpeners, ...opener] : otherOpeners);
688
- break;
689
- case DeviceAccess.CloseAll:
690
- closes([...opener, ...otherOpeners]);
691
- for (const name of DeviceStates) {
692
- environment = setAmbient(environment, name, []);
693
- }
694
- break;
695
- case DeviceAccess.Switch:
696
- environment = defineAmbient(environment, rootId, cds, [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device]);
697
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.graphics, others, true);
698
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevices, current, true);
699
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.device, otherOpeners, true);
700
- environment = setAmbient(environment, ambient_state_name_1.AmbientStateName.otherDevicesOpenedBy, opener, true);
701
- break;
836
+ const earlierRound = repeats ? [{ nodeId: rootId, name: family.used, type: identifier_1.ReferenceType.Variable, definedAt: rootId, cds: cds ?? [] }] : [];
837
+ let environment = res.environment;
838
+ if (kind === DeviceAccess.Switch || kind === DeviceAccess.CloseSome) {
839
+ environment = defineAmbient(environment, rootId, cds, actives);
840
+ }
841
+ for (const [active, others] of family.states) {
842
+ const current = lookup(active);
843
+ const other = lookup(others);
844
+ switch (kind) {
845
+ case DeviceAccess.Open:
846
+ environment = setAmbient(environment, others, [...other, ...current, ...earlierRound]);
847
+ environment = defineAmbient(environment, rootId, cds, [{ name: active, mode: AmbientWriteMode.Reset }]);
848
+ break;
849
+ case DeviceAccess.Close:
850
+ environment = setAmbient(environment, active, repeats ? [...other, ...current] : other);
851
+ break;
852
+ case DeviceAccess.CloseAll:
853
+ environment = setAmbient(setAmbient(environment, active, []), others, []);
854
+ break;
855
+ case DeviceAccess.Switch:
856
+ case DeviceAccess.CloseSome:
857
+ environment = setAmbient(setAmbient(environment, active, other, true), others, current, true);
858
+ break;
859
+ }
702
860
  }
703
- recordAmbient(res.graph, rootId, res.environment, [], kind === DeviceAccess.CloseAll ? DeviceStates : [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device]);
704
- const known = kind === DeviceAccess.Close ? opener.length > 0 : kind === DeviceAccess.CloseAll && opener.length + otherOpeners.length > 0;
705
- return withAccess({ ...res, environment }, rootId, data, reads, kind === DeviceAccess.Open || known ? [] : unnamedFile);
861
+ /* a close ends the state of the device it closes, all of them for every device */
862
+ const kills = kind === DeviceAccess.Close ? actives : kind === DeviceAccess.CloseAll ? family.states.flat() : [];
863
+ recordAmbient(res.graph, rootId, res.environment, [], kind === DeviceAccess.CloseAll ? family.states.flat() : actives, kills);
864
+ return withAccess({ ...res, environment }, rootId, data, reads, kind === DeviceAccess.Open || closed.length > 0 ? [] : unnamedFile);
706
865
  }
707
866
  /** A call to `fn` made on our behalf (`do.call(fn, args)`, `sapply(x, fn)`): it accesses the state as `fn` does, or reads all of it if `fn` is opaque. */
708
867
  function applyAmbientStateOfCallee(res, callId, fn, data) {
709
868
  const targets = resolve_helper_1.Resolve.byNameAndType(fn, data.environment, identifier_1.ReferenceType.Function) ?? [];
710
- res = applyAmbientStateAccess(res, UnknownArguments, callId, data, targets.flatMap(hiddenAccess));
869
+ res = applyAmbientEffects(res, UnknownArguments, callId, data, targets.flatMap(hiddenAccess));
711
870
  hiddenSideEffects(res.graph, res.environment, callId, targets);
712
871
  const unknown = (targets.length === 0 && data.environment.level === 0) || targets.some(t => t.type !== identifier_1.ReferenceType.BuiltInFunction && hidesBody(t));
713
872
  return unknown ? readsAllAmbientState(res, callId, data, true) : res;
@@ -724,8 +883,7 @@ function hiddenSideEffects(graph, environment, callId, targets) {
724
883
  for (const target of targets) {
725
884
  const builtIn = target.type === identifier_1.ReferenceType.BuiltInFunction ? target : undefined;
726
885
  const processor = builtIn?.processorName;
727
- const effect = builtIn?.config?.hasUnknownSideEffects
728
- ?? (processor !== undefined && WritesEnvironment.has(processor));
886
+ const effect = builtIn?.config?.hasUnknownSideEffects ?? (processor !== undefined && WritesEnvironment.has(processor));
729
887
  if (effect) {
730
888
  (0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, callId, effect === true ? undefined : effect);
731
889
  }
@@ -735,8 +893,7 @@ function hiddenSideEffects(graph, environment, callId, targets) {
735
893
  }
736
894
  }
737
895
  function hiddenAccess(target) {
738
- const access = target.type === identifier_1.ReferenceType.BuiltInFunction ? target.config?.ambient : undefined;
739
- return [access ?? []].flat();
896
+ return ambient_effect_1.Ambient.list(target.type === identifier_1.ReferenceType.BuiltInFunction ? target.config?.ambient : undefined);
740
897
  }
741
898
  /** The (maybe) writes of the call `callId` to the built-in `target` through a parameter, like `g <- function(f, ...) f(...); g(options, digits = 3)`. */
742
899
  function writesOfHiddenBuiltIn(target, callId, drawing = false) {
@@ -776,62 +933,40 @@ function setOptions(res, args, rootId, data) {
776
933
  }
777
934
  /* the call returns the previous values of what it sets, which only matters if that value is used */
778
935
  const previous = resultIsUsed(rootId, data) ? written : [];
779
- const reads = [...queried.map(ambient_state_name_1.AmbientStateName.option), ...previous];
780
- if (args.length === 0 || unknownKeys) {
781
- reads.push(ambient_state_name_1.AmbientStateName.allOptions);
782
- }
783
- if (reads.length > 0) {
784
- reads.push(ambient_state_name_1.AmbientStateName.unknownOption);
785
- }
786
- const writes = [...written];
787
- if (unknownKeys) {
788
- writes.push(ambient_state_name_1.AmbientStateName.unknownOption);
789
- }
790
- if (warnsAsErrors) {
791
- writes.push(ambient_state_name_1.AmbientStateName.warnsAsErrors);
792
- }
793
- if (writes.length > 0) {
794
- writes.push(ambient_state_name_1.AmbientStateName.allOptions);
795
- }
796
- return withAccess(res, rootId, data, reads, writes);
936
+ const reads = [...queried.map(ambient_state_name_1.AmbientStateName.option), ...previous, ...args.length === 0 || unknownKeys ? [ambient_state_name_1.AmbientStateName.allOptions] : []];
937
+ const writes = [...written, ...unknownKeys ? [ambient_state_name_1.AmbientStateName.unknownOption] : [], ...warnsAsErrors ? [ambient_state_name_1.AmbientStateName.warnsAsErrors] : []];
938
+ return withAccess(res, rootId, data, reads.length > 0 ? [...reads, ambient_state_name_1.AmbientStateName.unknownOption] : [], writes.length > 0 ? [...writes, ambient_state_name_1.AmbientStateName.allOptions] : []);
797
939
  }
798
940
  /** Whether the call to `fn` only queries the state it may set, as `par("mar")`, `options("digits")` and `palette()` do, which hand that state back visibly where setting it returns the previous one invisibly. */
799
941
  function callOnlyQueries(fn, args, environment) {
800
942
  const targets = resolve_helper_1.Resolve.byNameAndType(fn, environment, identifier_1.ReferenceType.Function) ?? [];
801
- return targets.length > 0 && targets.every(t => hiddenAccess(t).some(a => onlyQueries(a, args)));
802
- }
803
- function onlyQueries(access, args) {
804
- switch (access.type) {
805
- case "set-graphics" /* AmbientStateAccessType.SetGraphics */:
806
- return args.length === 0 || (access.queryOnUnnamedStrings === true && isQuery(args));
807
- case "set-options" /* AmbientStateAccessType.SetOptions */:
808
- return isQuery(args);
809
- case "set-palette" /* AmbientStateAccessType.SetPalette */:
810
- return args.length === 0;
811
- case "set-state" /* AmbientStateAccessType.SetState */:
812
- return access.queryWithoutArguments === true && args.length === 0;
813
- default:
814
- return false;
815
- }
943
+ return targets.length > 0 && targets.every(t => onlyQueries(hiddenAccess(t), args));
944
+ }
945
+ /** Whether a call with the `effects` only queries: a change is off for the arguments `args`, and no other one happens. */
946
+ function onlyQueries(effects, args) {
947
+ const changing = effects.filter(changes);
948
+ return changing.some(e => e.unless !== undefined && holds(e.unless, args) === logic_1.Ternary.Always) && changing.every(e => applies(e, args) === logic_1.Ternary.Never);
816
949
  }
817
950
  /** `par()`, `par("mar", "usr")`, and `par(no.readonly = TRUE)` only query the graphics state */
818
951
  function isQuery(args) {
819
- return args.every(a => a === r_function_call_1.EmptyArgument
820
- || (a.name === undefined ? r_string_1.RString.is(a.value) : identifier_1.Identifier.getName(a.name.content) === 'no.readonly'));
952
+ return args.every(a => a === r_function_call_1.EmptyArgument || (a.name === undefined ? r_string_1.RString.is(a.value) : identifier_1.Identifier.getName(a.name.content) === 'no.readonly'));
821
953
  }
822
- /** Whether the call's value may be used: anything but a non-final statement or the script's last statement (the last of a block is its value). */
823
- function resultIsUsed(rootId, data) {
954
+ /** Whether the call's value may be used: anything but a non-final statement or, unless it is `printed` there, a top-level statement of the script (the last of a block is its value). */
955
+ function resultIsUsed(rootId, data, printed) {
824
956
  const node = data.completeAst.idMap.get(rootId);
825
957
  const parent = node === undefined ? undefined : model_1.RNode.directParent(node, data.completeAst.idMap);
958
+ /* R prints the value a top-level statement leaves visible */
959
+ printed ??= !(r_function_call_1.RFunctionCall.isNamed(node) && returnsInvisibly(node.functionName.content, data.environment));
826
960
  if (parent === undefined) {
827
961
  return false;
828
962
  }
829
963
  else if (r_expression_list_1.RExpressionList.is(parent)) {
830
964
  /* a block yields its last value, which is used where the block's is */
831
- return parent.children.at(-1)?.info.id === rootId && !data.completeAst.ast.files.some(f => f.root.info.id === parent.info.id) && resultIsUsed(parent.info.id, data);
965
+ return data.completeAst.ast.files.some(f => f.root.info.id === parent.info.id) ? printed && autoPrintsStatementsOf(parent.info.id, data)
966
+ : parent.children.at(-1)?.info.id === rootId && resultIsUsed(parent.info.id, data, printed);
832
967
  }
833
968
  else if (r_if_then_else_1.RIfThenElse.is(parent)) {
834
- return parent.condition.info.id === rootId || resultIsUsed(parent.info.id, data);
969
+ return parent.condition.info.id === rootId || resultIsUsed(parent.info.id, data, printed);
835
970
  }
836
971
  /* a loop discards what its body yields */
837
972
  return !(model_1.RLoopConstructs.is(parent) && parent.body.info.id === rootId);
@@ -852,22 +987,34 @@ function linkAmbientStateWithinLoop(graph, reads, body) {
852
987
  function processAmbientScope(name, args, rootId, data, scope) {
853
988
  const bound = match_args_1.MatchArgs.toNames(args, scope.params);
854
989
  const code = scope.code === undefined ? undefined : bound.get(scope.code);
855
- const codeIndex = code === undefined ? -1 : args.findIndex(a => a !== r_function_call_1.EmptyArgument && a.info.id === code.info.id);
990
+ /* the code may be several arguments, all that fall to `...` (`capture.output(print(1), print(2))`) */
991
+ const formals = new Set([...bound.entries()].filter(([param]) => param !== '...').map(([, arg]) => arg.info.id));
992
+ const isCode = (arg) => arg !== undefined && arg !== r_function_call_1.EmptyArgument
993
+ && (scope.code === '...' ? !formals.has(arg.info.id) : arg.info.id === code?.info.id);
994
+ const family = scopedFamily(scope.state);
856
995
  const local = code === undefined && data.environment.level > 0;
857
996
  const { writes, unknown } = scope.preserve ? { writes: local ? [{ name: singleStateOf(built_in_kinds_1.AmbientSingleState.Rng), mode: AmbientWriteMode.Local }] : [], unknown: false } : scopedWrites(scope, args, bound, local);
858
997
  const cds = data.cds ? [...data.cds] : undefined;
859
- const apply = (environment) => scope.state === built_in_kinds_1.AmbientSingleState.Device ? deviceAccess({ ...info_1.DataflowInformation.initialize(rootId, data), environment }, rootId, data, local ? DeviceAccess.Switch : DeviceAccess.Open).environment
998
+ const apply = (environment) => family !== undefined ? deviceAccess({ ...info_1.DataflowInformation.initialize(rootId, data), environment }, rootId, data, local ? DeviceAccess.Switch : DeviceAccess.Open, family).environment
860
999
  : defineAmbient(environment, rootId, cds, writes);
861
- const { information } = (0, known_call_handling_1.processKnownFunctionCall)({
1000
+ let { information } = (0, known_call_handling_1.processKnownFunctionCall)({
862
1001
  name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Default,
863
- patchData: (d, i) => i === codeIndex ? { ...d, environment: apply(d.environment) } : d
1002
+ patchData: (d, i) => isCode(args[i]) ? { ...d, environment: apply(d.environment) } : d
864
1003
  });
1004
+ /* `capture.output` prints every visible value of its code into the diversion, as the top level does */
1005
+ for (const value of family === ambient_state_name_1.OutputSinks ? args.filter(isCode).map(r_argument_1.RArgument.valueOf) : []) {
1006
+ if (value !== undefined && autoPrints(value, information, data)) {
1007
+ const environment = information.environment;
1008
+ information = readsOfAutoPrint(information, value, { ...data, environment });
1009
+ (0, built_in_expression_list_1.printMethodsOf)(value.info.id, environment, information.graph, { graph: information.graph, idMap: data.completeAst.idMap, ctx: data.ctx, environment });
1010
+ }
1011
+ }
865
1012
  if (unknown) {
866
1013
  information.graph.markIdForUnknownSideEffects(rootId);
867
1014
  }
868
1015
  /* the state a scope changes around its code is back afterward */
869
- const changed = scope.state === built_in_kinds_1.AmbientSingleState.Device ? [ambient_state_name_1.AmbientStateName.graphics, ambient_state_name_1.AmbientStateName.device] : writes;
870
- recordAmbient(information.graph, rootId, information.environment, [], code === undefined && !(scope.state === built_in_kinds_1.AmbientSingleState.Device && local) ? changed : changed.map(w => ({ name: typeof w === 'string' ? w : w.name, mode: AmbientWriteMode.Local })));
1016
+ const changed = family !== undefined ? activeStates(family) : writes;
1017
+ recordAmbient(information.graph, rootId, information.environment, [], code === undefined && !(family !== undefined && local) ? changed : changed.map(w => ({ name: typeof w === 'string' ? w : w.name, mode: AmbientWriteMode.Local })));
871
1018
  if (code === undefined) {
872
1019
  const applied = { ...information, environment: apply(information.environment) };
873
1020
  /* the frame starts out with the state as it was */
@@ -876,13 +1023,13 @@ function processAmbientScope(name, args, rootId, data, scope) {
876
1023
  /* afterward, what the scope changed is back to what it was before */
877
1024
  let environment = information.environment;
878
1025
  const keyed = keyedStateOf(scope);
879
- const restored = scope.state === built_in_kinds_1.AmbientSingleState.Device ? DeviceStates
1026
+ const restored = family !== undefined ? family.states.flat()
880
1027
  : scope.state === built_in_kinds_1.AmbientSingleState.Rng || scope.state === built_in_kinds_1.AmbientSingleState.WorkingDirectory ? [singleStateOf(scope.state)]
881
1028
  : writes.map(w => typeof w === 'string' ? w : w.name).filter(n => keyed !== undefined && n.startsWith(ambient_state_name_1.AmbientStateName.keyed(keyed, '')) && n !== ambient_state_name_1.AmbientStateName.keyed(keyed, ambient_state_name_1.UnknownKey));
882
1029
  for (const state of restored) {
883
1030
  const before = resolve_helper_1.Resolve.byName(state, data.environment);
884
1031
  /* an entry nothing set before keeps the scope's definition, we cannot tell R's default apart */
885
- if ((before !== undefined && before.length > 0) || ((scope.state === built_in_kinds_1.AmbientSingleState.Device || scope.state === built_in_kinds_1.AmbientSingleState.Rng || scope.state === built_in_kinds_1.AmbientSingleState.WorkingDirectory) && data.environment.level === 0)) {
1032
+ if ((before !== undefined && before.length > 0) || ((family !== undefined || scope.state === built_in_kinds_1.AmbientSingleState.Rng || scope.state === built_in_kinds_1.AmbientSingleState.WorkingDirectory) && data.environment.level === 0)) {
886
1033
  environment = setAmbient(environment, state, before ?? []);
887
1034
  }
888
1035
  }
@@ -893,6 +1040,10 @@ function processAmbientScope(name, args, rootId, data, scope) {
893
1040
  }
894
1041
  return { ...information, environment };
895
1042
  }
1043
+ /** The family of instances a scope opens one of for its code, `with_png` a device and `capture.output` a diversion of the output. */
1044
+ function scopedFamily(state) {
1045
+ return state === built_in_kinds_1.AmbientSingleState.Device ? ambient_state_name_1.GraphicsDevices : state === built_in_kinds_1.AmbientSingleState.Sink ? ambient_state_name_1.OutputSinks : undefined;
1046
+ }
896
1047
  /** The keyed state an {@link AmbientScope} changes the entries of, `undefined` for a state without entries. */
897
1048
  function keyedStateOf(scope) {
898
1049
  return scope.state === ambient_state_name_1.KeyedState.Option || scope.state === ambient_state_name_1.KeyedState.Env || scope.state === ambient_state_name_1.KeyedState.Locale ? scope.state : undefined;
@@ -961,22 +1112,28 @@ function evaluatesCapturedCode(res, rootId, data) {
961
1112
  }
962
1113
  /** What the implicit `print` of a top-level value reads (see {@link readsOfAutoPrint}): every option if a method may print it (`dispatched`). */
963
1114
  function autoPrintReads(dispatched) {
964
- return optionReads(dispatched ? undefined : built_in_kinds_1.PrintingOptions);
1115
+ return [...optionReads(dispatched ? undefined : built_in_kinds_1.PrintingOptions), ambient_state_name_1.AmbientStateName.sink];
965
1116
  }
966
- /** R prints every visible top-level value (see {@link autoPrints}) by an implicit `print`, which reads the options the configured `print` reads for that value. */
1117
+ /** what printing writes: it is part of the diversion of the output, see {@link OutputSinks} */
1118
+ exports.PrintWrites = [ambient_state_name_1.AmbientStateName.sinkOutput];
1119
+ /** R prints every visible top-level value (see {@link autoPrints}) by an implicit `print`, which reads the options the configured `print` reads for that value, and draws a plot object. */
967
1120
  function readsOfAutoPrint(processed, expression, data) {
968
1121
  const print = resolve_helper_1.Resolve.byNameAndType('print', { current: environment_1.REnvironment.findBuiltIn(data.environment.current), level: 0 }, identifier_1.ReferenceType.Function)?.slice(0, 1) ?? [];
969
- const reads = print.flatMap(hiddenAccess).flatMap(access => access.type === "read-options" /* AmbientStateAccessType.ReadOptions */
970
- ? printingReads(expression, access.dispatchOn !== undefined, access.keys, data) : []);
971
- return withAccess(processed, expression.info.id, data, reads, []);
1122
+ const reads = print.flatMap(hiddenAccess).flatMap(effect => effect.family === ambient_state_name_1.KeyedState.Option && effect.access === ambient_effect_1.AmbientVerb.Reads
1123
+ ? printingReads(expression, effect.dispatchOn !== undefined, typeof effect.member === 'object' && effect.member.from === 'constant' ? effect.member.keys : [], data) : []);
1124
+ return withAccess(processed, expression.info.id, data, [...reads, ambient_state_name_1.AmbientStateName.sink], [...exports.PrintWrites, ...mayHoldPlot(expression, data) ? DrawsNewPlot : []]);
972
1125
  }
973
1126
  /** the processors whose calls return invisibly, although their configuration states no {@link CallProp.Invisible} */
974
1127
  const InvisibleProcessors = new Set([built_in_proc_name_1.BuiltInProcName.ForLoop, built_in_proc_name_1.BuiltInProcName.WhileLoop, built_in_proc_name_1.BuiltInProcName.RepeatLoop,
975
1128
  built_in_proc_name_1.BuiltInProcName.Assignment, built_in_proc_name_1.BuiltInProcName.SuperAssignment, built_in_proc_name_1.BuiltInProcName.FunctionDefinition]);
1129
+ /** Whether R prints the visible values of the statements of the expression list `list`: those of the top level of the analyzed script, not of a sourced file. */
1130
+ function autoPrintsStatementsOf(list, data) {
1131
+ return data.referenceChain.length <= 1 && data.environment.level === 0 && data.completeAst.ast.files.some(f => f.root.info.id === list);
1132
+ }
976
1133
  /** whether the value of the top-level `expression` is visible, so that R prints it, decided on its vertex */
977
1134
  function autoPrints(expression, processed, data) {
978
1135
  const vertex = processed.graph.getVertex(expression.info.id);
979
- if (vertex === undefined || vertex_1.DfgVertex.isFunctionDefinition(vertex)) {
1136
+ if (vertex === undefined) {
980
1137
  return false;
981
1138
  }
982
1139
  else if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
@@ -985,9 +1142,16 @@ function autoPrints(expression, processed, data) {
985
1142
  else if (Array.isArray(vertex.origin) && vertex.origin.some(o => InvisibleProcessors.has(o))) {
986
1143
  return false;
987
1144
  }
988
- /* `invisible`, `library`, ...: everything this resolves to returns invisibly */
989
- const targets = resolve_helper_1.Resolve.byNameAndType(vertex.name, data.environment, identifier_1.ReferenceType.Function);
990
- return targets === undefined || targets.length === 0 || !targets.every(t => t.type === identifier_1.ReferenceType.BuiltInFunction && built_in_props_1.CallProps.hasAny(t.config, built_in_props_1.CallProp.Invisible));
1145
+ else if (r_expression_list_1.RExpressionList.is(expression) && expression.grouping?.[0].lexeme === '{' && vertex.onlyBuiltin && expression.children.length > 0) {
1146
+ /* a block hands on its last value, visible or not */
1147
+ return autoPrints(expression.children[expression.children.length - 1], processed, data);
1148
+ }
1149
+ return !returnsInvisibly(vertex.name, data.environment);
1150
+ }
1151
+ /** `invisible`, `library`, ...: whether everything `name` resolves to returns invisibly */
1152
+ function returnsInvisibly(name, environment) {
1153
+ const targets = resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.Function);
1154
+ return targets !== undefined && targets.length > 0 && targets.every(t => t.type === identifier_1.ReferenceType.BuiltInFunction && built_in_props_1.CallProps.hasAny(t.config, built_in_props_1.CallProp.Invisible));
991
1155
  }
992
1156
  /** A call through a variable bound to a built-in (`p <- par; p(...)`), only revealed when linking the statement's calls. */
993
1157
  function applyAmbientStateOfCalledBuiltIns(res, callId, builtIns, before, graph, data) {
@@ -998,7 +1162,7 @@ function applyAmbientStateOfCalledBuiltIns(res, callId, builtIns, before, graph,
998
1162
  const known = res.unknownReferences.length;
999
1163
  for (const builtIn of builtIns) {
1000
1164
  const targets = node_id_1.NodeId.isBuiltIn(builtIn) ? resolve_helper_1.Resolve.byNameAndType(node_id_1.NodeId.fromBuiltIn(builtIn), before, identifier_1.ReferenceType.Function) ?? [] : [];
1001
- res = applyAmbientStateAccess(res, call.arguments, callId, data, targets.flatMap(hiddenAccess));
1165
+ res = applyAmbientEffects(res, call.arguments, callId, data, targets.flatMap(hiddenAccess));
1002
1166
  hiddenSideEffects(graph, before, callId, targets);
1003
1167
  }
1004
1168
  const access = res.graph.ambientAccessOf(callId);
@@ -1088,12 +1252,16 @@ function rejectsArguments(definition, call) {
1088
1252
  const given = call.arguments.filter(a => a !== r_function_call_1.EmptyArgument);
1089
1253
  return given.length > names.length || given.some(a => a.name !== undefined && !names.some(n => n.startsWith(identifier_1.Identifier.getName(a.name?.content ?? ''))));
1090
1254
  }
1255
+ /** Whether `id` follows a statement that always exits, so it never runs and has no vertex. */
1256
+ function unanalyzed(id, graph, data) {
1257
+ return data.unreachable?.has(id) === true && !graph.hasVertex(id);
1258
+ }
1091
1259
  /** what may warn when `root` runs, see {@link WarningSiteMode}, `bodies` holds what may in the bodies of the closures seen so far */
1092
1260
  function warningSites(root, graph, data, bodies, mode) {
1093
1261
  const sites = [];
1094
1262
  const { signal } = mode;
1095
1263
  model_1.RNode.visitAst(root, node => {
1096
- if (r_function_definition_1.RFunctionDefinition.is(node)) {
1264
+ if (r_function_definition_1.RFunctionDefinition.is(node) || unanalyzed(node.info.id, graph, data)) {
1097
1265
  return true;
1098
1266
  }
1099
1267
  else if (r_binary_op_1.RBinaryOp.is(node) ? r_binary_op_1.RBinaryOp.getOperatorInfo(node)?.usedAs !== base_operators_1.OperatorUsedAs.Assignment : r_unary_op_1.RUnaryOp.is(node) || r_access_1.RAccess.is(node)) {
@@ -1111,7 +1279,7 @@ function warningSites(root, graph, data, bodies, mode) {
1111
1279
  }
1112
1280
  return false;
1113
1281
  }
1114
- if (mode.muffled && r_function_call_1.RFunctionCall.isNamed(node, 'suppressWarnings') && targets.every(t => node_id_1.NodeId.isBuiltIn(t.nodeId))) {
1282
+ if (mode.muffled && targets.length > 0 && targets.every(t => t.type === identifier_1.ReferenceType.BuiltInFunction && t.config?.muffles?.includes('warning') === true)) {
1115
1283
  return true;
1116
1284
  }
1117
1285
  const handlers = mode.muffled ? muffledHandlers(node, graph, data) : undefined;
@@ -1146,10 +1314,9 @@ function warningSites(root, graph, data, bodies, mode) {
1146
1314
  });
1147
1315
  return sites;
1148
1316
  }
1149
- /** Whether `node` branches or loops on a value that is not a constant, which R may reject (`if(NA)`). */
1317
+ /** Whether `node` branches or loops on a value R may reject: a condition that is not `TRUE` or `FALSE` (`if(NA)`, `if(logical(0))`) or a vector that is not a constant. */
1150
1318
  function testsValue(node) {
1151
- const tested = r_if_then_else_1.RIfThenElse.is(node) || r_while_loop_1.RWhileLoop.is(node) ? node.condition : r_for_loop_1.RForLoop.is(node) ? node.vector : undefined;
1152
- return tested !== undefined && !model_1.RConstant.is(tested);
1319
+ return r_if_then_else_1.RIfThenElse.is(node) || r_while_loop_1.RWhileLoop.is(node) ? !r_logical_1.RLogical.is(node.condition) : r_for_loop_1.RForLoop.is(node) && !model_1.RConstant.is(node.vector);
1153
1320
  }
1154
1321
  /** The handlers of a `withCallingHandlers` whose first handler muffles every `warning` of its `expr`, `undefined` otherwise. */
1155
1322
  function muffledHandlers(call, graph, data) {