@eagleoutice/flowr 2.17.4 → 2.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (544) hide show
  1. package/README.md +13 -52
  2. package/abstract-interpretation/absint-inference.js +1 -2
  3. package/abstract-interpretation/data-frame/arguments.d.ts +14 -3
  4. package/abstract-interpretation/data-frame/arguments.js +34 -0
  5. package/abstract-interpretation/data-frame/dataframe-semantics.js +7 -15
  6. package/abstract-interpretation/data-frame/resolve-args.d.ts +2 -2
  7. package/abstract-interpretation/data-frame/semantics.d.ts +8 -1
  8. package/abstract-interpretation/data-frame/semantics.js +14 -6
  9. package/abstract-interpretation/domains/state-abstract-domain.js +28 -18
  10. package/abstract-interpretation/domains/state-map.d.ts +43 -0
  11. package/abstract-interpretation/domains/state-map.js +147 -0
  12. package/benchmark/slicer.d.ts +1 -1
  13. package/benchmark/slicer.js +8 -7
  14. package/cli/repl/commands/repl-dataflow.js +5 -5
  15. package/cli/repl/commands/repl-execute.js +3 -2
  16. package/cli/repl/commands/repl-parse.js +2 -1
  17. package/cli/repl/print-version.d.ts +1 -1
  18. package/cli/repl/print-version.js +2 -1
  19. package/cli/repl/server/connection.d.ts +1 -1
  20. package/cli/repl/server/connection.js +7 -9
  21. package/cli/slicer-app.js +2 -1
  22. package/clones/algorithms/baxter-ast.d.ts +33 -0
  23. package/clones/algorithms/baxter-ast.js +70 -0
  24. package/clones/algorithms/greedy-string-tiling.d.ts +17 -0
  25. package/clones/algorithms/greedy-string-tiling.js +56 -0
  26. package/clones/algorithms/winnowing.d.ts +27 -0
  27. package/clones/algorithms/winnowing.js +66 -0
  28. package/clones/clone-ast.d.ts +75 -0
  29. package/clones/clone-ast.js +174 -0
  30. package/clones/clone-dataflow.d.ts +11 -0
  31. package/clones/clone-dataflow.js +83 -0
  32. package/clones/clone-detector.d.ts +116 -0
  33. package/clones/clone-detector.js +200 -0
  34. package/clones/clone-index.d.ts +54 -0
  35. package/clones/clone-index.js +56 -0
  36. package/config.d.ts +21 -2
  37. package/config.js +7 -1
  38. package/control-flow/basic-cfg-guided-visitor.js +1 -2
  39. package/control-flow/happens-before.d.ts +2 -0
  40. package/control-flow/happens-before.js +15 -9
  41. package/control-flow/simple-visitor.js +2 -4
  42. package/core/steps/all/core/00-parse.js +2 -1
  43. package/core/steps/all/core/01-parse-tree-sitter.js +2 -1
  44. package/core/steps/all/core/10-normalize.js +2 -1
  45. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -1
  46. package/core/steps/all/static-slicing/00-slice.js +2 -1
  47. package/core/steps/all/static-slicing/10-reconstruct.js +2 -1
  48. package/core/steps/pipeline/create-pipeline.js +1 -2
  49. package/core/steps/pipeline/default-pipelines.d.ts +1 -1
  50. package/core/steps/pipeline/default-pipelines.js +5 -4
  51. package/core/steps/pipeline-step.d.ts +3 -1
  52. package/core/steps/pipeline-step.js +5 -0
  53. package/data/r-base-primitives.generated.d.ts +2 -1
  54. package/dataflow/cluster.js +1 -2
  55. package/dataflow/environments/ambient-state-name.d.ts +14 -22
  56. package/dataflow/environments/ambient-state-name.js +4 -18
  57. package/dataflow/environments/apply-kill.d.ts +9 -20
  58. package/dataflow/environments/apply-kill.js +51 -25
  59. package/dataflow/environments/built-in-config.d.ts +7 -15
  60. package/dataflow/environments/built-in-config.js +15 -16
  61. package/dataflow/environments/built-in-eval-name.d.ts +5 -6
  62. package/dataflow/environments/built-in-eval-name.js +4 -5
  63. package/dataflow/environments/built-in-kinds.d.ts +111 -0
  64. package/dataflow/environments/built-in-kinds.js +35 -0
  65. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  66. package/dataflow/environments/built-in-proc-name.js +11 -0
  67. package/dataflow/environments/built-in-props.d.ts +62 -175
  68. package/dataflow/environments/built-in-props.js +42 -154
  69. package/dataflow/environments/built-in.d.ts +37 -73
  70. package/dataflow/environments/built-in.js +41 -62
  71. package/dataflow/environments/data-masking-functions.d.ts +2 -2
  72. package/dataflow/environments/default-builtin-config/base-functions.d.ts +7 -0
  73. package/dataflow/environments/default-builtin-config/base-functions.js +339 -0
  74. package/dataflow/environments/default-builtin-config/base-language.d.ts +3 -0
  75. package/dataflow/environments/default-builtin-config/base-language.js +66 -0
  76. package/dataflow/environments/default-builtin-config/base-operators.d.ts +58 -0
  77. package/dataflow/environments/default-builtin-config/base-operators.js +169 -0
  78. package/dataflow/environments/default-builtin-config/database-access.d.ts +3 -0
  79. package/dataflow/environments/default-builtin-config/database-access.js +16 -0
  80. package/dataflow/environments/default-builtin-config/define-helpers.d.ts +45 -0
  81. package/dataflow/environments/default-builtin-config/define-helpers.js +50 -0
  82. package/dataflow/environments/default-builtin-config/dev-tooling.d.ts +3 -0
  83. package/dataflow/environments/default-builtin-config/dev-tooling.js +63 -0
  84. package/dataflow/environments/default-builtin-config/file-io.d.ts +3 -0
  85. package/dataflow/environments/default-builtin-config/file-io.js +81 -0
  86. package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +3 -0
  87. package/dataflow/environments/default-builtin-config/graphics-devices.js +57 -0
  88. package/dataflow/environments/default-builtin-config/index.d.ts +18 -0
  89. package/dataflow/environments/default-builtin-config/index.js +114 -0
  90. package/dataflow/environments/default-builtin-config/media-formats.d.ts +3 -0
  91. package/dataflow/environments/default-builtin-config/media-formats.js +41 -0
  92. package/dataflow/environments/default-builtin-config/misc-packages.d.ts +3 -0
  93. package/dataflow/environments/default-builtin-config/misc-packages.js +18 -0
  94. package/dataflow/environments/default-builtin-config/network-access.d.ts +3 -0
  95. package/dataflow/environments/default-builtin-config/network-access.js +47 -0
  96. package/dataflow/environments/default-builtin-config/object-systems.d.ts +3 -0
  97. package/dataflow/environments/default-builtin-config/object-systems.js +39 -0
  98. package/dataflow/environments/default-builtin-config/package-data-table.d.ts +3 -0
  99. package/dataflow/environments/default-builtin-config/package-data-table.js +18 -0
  100. package/dataflow/environments/default-builtin-config/package-spatial.d.ts +3 -0
  101. package/dataflow/environments/default-builtin-config/package-spatial.js +32 -0
  102. package/dataflow/environments/default-builtin-config/package-tidyverse.d.ts +3 -0
  103. package/dataflow/environments/default-builtin-config/package-tidyverse.js +96 -0
  104. package/dataflow/environments/default-builtin-config/package-utils.d.ts +3 -0
  105. package/dataflow/environments/default-builtin-config/package-utils.js +35 -0
  106. package/dataflow/environments/default-builtin-config/package-withr.d.ts +3 -0
  107. package/dataflow/environments/default-builtin-config/package-withr.js +41 -0
  108. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +3 -0
  109. package/dataflow/environments/default-builtin-config/parallel-execution.js +31 -0
  110. package/dataflow/environments/default-builtin-config/session-interactive.d.ts +3 -0
  111. package/dataflow/environments/default-builtin-config/session-interactive.js +31 -0
  112. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +267 -0
  113. package/dataflow/environments/default-builtin-config/shared-configs.js +483 -0
  114. package/dataflow/environments/default-builtin-config/shared-signatures.d.ts +21 -0
  115. package/dataflow/environments/default-builtin-config/shared-signatures.js +32 -0
  116. package/dataflow/environments/default-builtin-config/statistics.d.ts +3 -0
  117. package/dataflow/environments/default-builtin-config/statistics.js +32 -0
  118. package/dataflow/environments/default-builtin-config/unit-testing.d.ts +3 -0
  119. package/dataflow/environments/default-builtin-config/unit-testing.js +13 -0
  120. package/dataflow/environments/environment.d.ts +28 -52
  121. package/dataflow/environments/environment.js +24 -71
  122. package/dataflow/environments/group-generics.d.ts +12 -19
  123. package/dataflow/environments/group-generics.js +17 -14
  124. package/dataflow/environments/identifier.d.ts +72 -427
  125. package/dataflow/environments/identifier.js +34 -145
  126. package/dataflow/environments/pkg-name.d.ts +197 -0
  127. package/dataflow/environments/pkg-name.js +3 -0
  128. package/dataflow/environments/query-fn-props.d.ts +27 -76
  129. package/dataflow/environments/query-fn-props.js +34 -95
  130. package/dataflow/environments/resolve-by-name.d.ts +6 -16
  131. package/dataflow/environments/resolve-by-name.js +23 -35
  132. package/dataflow/environments/scoping.d.ts +5 -5
  133. package/dataflow/environments/scoping.js +13 -5
  134. package/dataflow/eval/resolve/alias-tracking.d.ts +31 -68
  135. package/dataflow/eval/resolve/alias-tracking.js +611 -126
  136. package/dataflow/eval/resolve/match-arguments.d.ts +5 -3
  137. package/dataflow/eval/resolve/resolve-argument.d.ts +11 -11
  138. package/dataflow/eval/resolve/resolve-argument.js +25 -30
  139. package/dataflow/eval/resolve/resolve-field.d.ts +10 -0
  140. package/dataflow/eval/resolve/resolve-field.js +127 -0
  141. package/dataflow/eval/resolve/resolve-replacement.d.ts +10 -0
  142. package/dataflow/eval/resolve/resolve-replacement.js +80 -0
  143. package/dataflow/eval/resolve/resolve-strings.d.ts +2 -2
  144. package/dataflow/eval/resolve/resolve.d.ts +13 -10
  145. package/dataflow/eval/resolve/resolve.js +81 -32
  146. package/dataflow/eval/values/general.d.ts +6 -24
  147. package/dataflow/eval/values/general.js +12 -29
  148. package/dataflow/eval/values/lists/list-constants.d.ts +11 -0
  149. package/dataflow/eval/values/lists/list-constants.js +65 -0
  150. package/dataflow/eval/values/r-value.d.ts +20 -23
  151. package/dataflow/eval/values/r-value.js +22 -17
  152. package/dataflow/extractor.d.ts +2 -10
  153. package/dataflow/extractor.js +100 -46
  154. package/dataflow/fn/argument-roles.d.ts +2 -4
  155. package/dataflow/fn/argument-roles.js +49 -23
  156. package/dataflow/fn/class-declaration.d.ts +36 -52
  157. package/dataflow/fn/class-declaration.js +22 -56
  158. package/dataflow/fn/condition-handlers.d.ts +2 -1
  159. package/dataflow/fn/dispatch.d.ts +70 -0
  160. package/dataflow/fn/dispatch.js +434 -0
  161. package/dataflow/fn/exceptions-of-function.d.ts +1 -2
  162. package/dataflow/fn/exceptions-of-function.js +36 -106
  163. package/dataflow/fn/frame-reflection.d.ts +1 -3
  164. package/dataflow/fn/frame-reflection.js +8 -16
  165. package/dataflow/fn/function-props.d.ts +2 -5
  166. package/dataflow/fn/function-props.js +27 -36
  167. package/dataflow/fn/function-semantics.d.ts +14 -26
  168. package/dataflow/fn/function-semantics.js +4 -18
  169. package/dataflow/fn/higher-order-function.js +2 -4
  170. package/dataflow/fn/strict-function.d.ts +10 -35
  171. package/dataflow/fn/strict-function.js +126 -138
  172. package/dataflow/graph/ambient-access.d.ts +51 -0
  173. package/dataflow/graph/ambient-access.js +80 -0
  174. package/dataflow/graph/call-graph.d.ts +9 -29
  175. package/dataflow/graph/call-graph.js +17 -41
  176. package/dataflow/graph/closure-frames.d.ts +46 -0
  177. package/dataflow/graph/closure-frames.js +225 -0
  178. package/dataflow/graph/dataflowgraph-builder.d.ts +25 -96
  179. package/dataflow/graph/dataflowgraph-builder.js +29 -97
  180. package/dataflow/graph/df-helper.d.ts +48 -188
  181. package/dataflow/graph/df-helper.js +107 -208
  182. package/dataflow/graph/diff-dataflow-graph.d.ts +5 -15
  183. package/dataflow/graph/diff-dataflow-graph.js +25 -25
  184. package/dataflow/graph/edge.js +1 -1
  185. package/dataflow/graph/graph-helper.d.ts +10 -46
  186. package/dataflow/graph/graph-helper.js +16 -50
  187. package/dataflow/graph/graph.d.ts +44 -97
  188. package/dataflow/graph/graph.js +83 -79
  189. package/dataflow/graph/match-args.d.ts +21 -88
  190. package/dataflow/graph/match-args.js +284 -97
  191. package/dataflow/graph/vertex.d.ts +101 -128
  192. package/dataflow/graph/vertex.js +23 -20
  193. package/dataflow/hooks.d.ts +7 -14
  194. package/dataflow/hooks.js +15 -13
  195. package/dataflow/info.d.ts +2 -17
  196. package/dataflow/internal/dispatch-linking.d.ts +71 -0
  197. package/dataflow/internal/dispatch-linking.js +332 -0
  198. package/dataflow/internal/linker.d.ts +48 -50
  199. package/dataflow/internal/linker.js +457 -155
  200. package/dataflow/internal/process/functions/call/argument/make-argument.js +2 -1
  201. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +2 -14
  202. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -46
  203. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +7 -6
  204. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +10 -9
  205. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +23 -75
  206. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +263 -97
  207. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +10 -7
  208. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +66 -45
  209. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +15 -19
  210. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +82 -62
  211. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -4
  212. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +2 -2
  213. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +2 -2
  214. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +3 -2
  215. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +15 -0
  216. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +416 -0
  217. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +37 -54
  218. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +192 -111
  219. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +4 -3
  220. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +60 -13
  221. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -3
  222. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +80 -76
  223. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.d.ts +1 -7
  224. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -13
  225. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +4 -8
  226. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +436 -140
  227. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +18 -10
  228. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +90 -12
  229. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -5
  230. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -14
  231. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +9 -8
  232. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -7
  233. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -2
  234. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +3 -5
  235. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -6
  236. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.d.ts +9 -24
  237. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +10 -6
  238. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +5 -6
  239. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -4
  240. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -4
  241. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +8 -11
  242. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -5
  243. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +20 -28
  244. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +17 -4
  245. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +117 -4
  246. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +5 -3
  247. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  248. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +8 -4
  249. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +18 -29
  250. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -25
  251. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +31 -35
  252. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +4 -18
  253. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +13 -19
  254. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +18 -16
  255. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +130 -65
  256. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -1
  257. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +38 -30
  258. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +584 -114
  259. package/dataflow/internal/process/functions/call/common.d.ts +8 -24
  260. package/dataflow/internal/process/functions/call/common.js +24 -24
  261. package/dataflow/internal/process/functions/call/deferred.d.ts +7 -27
  262. package/dataflow/internal/process/functions/call/deferred.js +6 -27
  263. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -26
  264. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -16
  265. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -4
  266. package/dataflow/internal/process/functions/call/named-call-handling.js +14 -35
  267. package/dataflow/internal/process/functions/call/nse.d.ts +2 -9
  268. package/dataflow/internal/process/functions/call/nse.js +6 -13
  269. package/dataflow/internal/process/functions/call/quoted.d.ts +4 -15
  270. package/dataflow/internal/process/functions/call/quoted.js +26 -62
  271. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +3 -6
  272. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +29 -11
  273. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  274. package/dataflow/internal/program-order.d.ts +3 -10
  275. package/dataflow/internal/program-order.js +19 -10
  276. package/dataflow/origin/dfg-get-origin.js +2 -1
  277. package/documentation/data/faq/faqs.js +16 -1
  278. package/documentation/data/interface/doc-writing-code.js +5 -7
  279. package/documentation/doc-capabilities.js +3 -3
  280. package/documentation/doc-readme.js +1 -1
  281. package/documentation/doc-util/doc-code.d.ts +0 -5
  282. package/documentation/doc-util/doc-code.js +2 -22
  283. package/documentation/doc-util/doc-query.d.ts +1 -2
  284. package/documentation/doc-util/doc-query.js +4 -5
  285. package/documentation/doc-util/doc-search.js +1 -1
  286. package/documentation/wiki-analyzer.js +4 -3
  287. package/documentation/wiki-core.js +5 -5
  288. package/documentation/wiki-dataflow-graph.js +6 -0
  289. package/documentation/wiki-interface.js +2 -1
  290. package/documentation/wiki-linter.js +15 -3
  291. package/documentation/wiki-linting-and-testing.js +15 -2
  292. package/documentation/wiki-query.js +111 -29
  293. package/index.d.ts +3 -1
  294. package/index.js +6 -3
  295. package/linter/linter-executor.js +1 -1
  296. package/linter/linter-rules.d.ts +37 -8
  297. package/linter/linter-rules.js +8 -1
  298. package/linter/linter-util.d.ts +3 -3
  299. package/linter/linter-util.js +1 -1
  300. package/linter/rules/cmd-check/bogus-return.d.ts +2 -1
  301. package/linter/rules/cmd-check/call-arguments.d.ts +3 -2
  302. package/linter/rules/cmd-check/call-arguments.js +5 -5
  303. package/linter/rules/cmd-check/cmd-check-util.d.ts +9 -8
  304. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -1
  305. package/linter/rules/cmd-check/dependency-declaration.js +1 -1
  306. package/linter/rules/cmd-check/documentation-mismatch.d.ts +3 -2
  307. package/linter/rules/cmd-check/documentation-mismatch.js +2 -1
  308. package/linter/rules/cmd-check/file-checks.d.ts +2 -2
  309. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -1
  310. package/linter/rules/cmd-check/global-environment-modification.d.ts +6 -5
  311. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -1
  312. package/linter/rules/cmd-check/non-ascii-code.js +1 -1
  313. package/linter/rules/cmd-check/package-files.d.ts +2 -2
  314. package/linter/rules/cmd-check/package-hooks.d.ts +5 -4
  315. package/linter/rules/cmd-check/package-runtime.js +2 -2
  316. package/linter/rules/cmd-check/rd-files.js +2 -1
  317. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +3 -2
  318. package/linter/rules/cmd-check/s-three-method-consistency.js +2 -1
  319. package/linter/rules/code-clones.d.ts +57 -0
  320. package/linter/rules/code-clones.js +53 -0
  321. package/linter/rules/deprecated-functions.js +3 -6
  322. package/linter/rules/file-path-validity.js +6 -4
  323. package/linter/rules/function-finder-util.d.ts +4 -2
  324. package/linter/rules/naming-convention.d.ts +6 -5
  325. package/linter/rules/naming-convention.js +2 -3
  326. package/linter/rules/no-leaked-credentials.d.ts +2 -1
  327. package/linter/rules/no-leaked-credentials.js +1 -1
  328. package/linter/rules/overwritten-file.d.ts +2 -1
  329. package/linter/rules/problematic-inputs.d.ts +2 -1
  330. package/linter/rules/problematic-inputs.js +3 -3
  331. package/linter/rules/process-state-in-session.d.ts +7 -6
  332. package/linter/rules/process-state-in-session.js +1 -1
  333. package/linter/rules/roxygen-arguments.d.ts +1 -1
  334. package/linter/rules/secret-exfiltration.js +1 -1
  335. package/linter/rules/seeded-randomness.d.ts +3 -3
  336. package/linter/rules/unclosed-connection.js +1 -2
  337. package/linter/rules/undefined-symbol-util.d.ts +3 -2
  338. package/linter/rules/undefined-symbol.d.ts +3 -2
  339. package/linter/rules/unescaped-arguments.d.ts +1 -1
  340. package/linter/rules/unescaped-arguments.js +6 -8
  341. package/linter/rules/unused-definition.d.ts +4 -3
  342. package/linter/rules/unused-definition.js +10 -12
  343. package/linter/rules/unused-import.d.ts +6 -5
  344. package/package.json +1 -1
  345. package/project/attached-packages.d.ts +5 -4
  346. package/project/cache/flowr-analyzer-cache.d.ts +14 -1
  347. package/project/cache/flowr-analyzer-cache.js +40 -3
  348. package/project/context/flowr-analyzer-dependencies-context.d.ts +12 -12
  349. package/project/context/flowr-analyzer-environment-context.d.ts +3 -3
  350. package/project/context/flowr-analyzer-environment-context.js +3 -3
  351. package/project/context/flowr-analyzer-functions-context.d.ts +9 -7
  352. package/project/context/flowr-analyzer-gas-context.d.ts +25 -0
  353. package/project/context/flowr-analyzer-gas-context.js +34 -4
  354. package/project/dependency-version-space.d.ts +30 -29
  355. package/project/dependency-version-space.js +1 -2
  356. package/project/flowr-analyzer-builder.d.ts +2 -3
  357. package/project/flowr-analyzer.d.ts +35 -3
  358. package/project/flowr-analyzer.js +11 -5
  359. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +15 -14
  360. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +5 -4
  361. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +1 -1
  362. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +2 -1
  363. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +4 -3
  364. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +2 -1
  365. package/project/plugins/package-version-plugins/package.d.ts +6 -5
  366. package/project/sigdb/build.js +1 -1
  367. package/project/sigdb/decode.d.ts +8 -7
  368. package/project/sigdb/decode.js +1 -2
  369. package/project/sigdb/dict.d.ts +2 -1
  370. package/project/sigdb/dict.js +2 -2
  371. package/project/sigdb/index-format.d.ts +2 -1
  372. package/project/sigdb/manifest.d.ts +1 -1
  373. package/project/sigdb/memory-source.d.ts +18 -17
  374. package/project/sigdb/on-demand/package-sources.d.ts +4 -3
  375. package/project/sigdb/on-demand/recoverer.d.ts +2 -1
  376. package/project/sigdb/on-demand/remote-sources.d.ts +2 -1
  377. package/project/sigdb/reader.d.ts +85 -80
  378. package/project/sigdb/reader.js +0 -4
  379. package/project/sigdb/schema.d.ts +9 -8
  380. package/project/sigdb/signature-db.d.ts +6 -6
  381. package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +6 -0
  382. package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +50 -0
  383. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +54 -0
  384. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +45 -0
  385. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +2 -1
  386. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -2
  387. package/queries/catalog/call-graph-query/expand-library-internals.d.ts +3 -2
  388. package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +6 -0
  389. package/queries/catalog/code-clones-query/code-clones-query-executor.js +38 -0
  390. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +54 -0
  391. package/queries/catalog/code-clones-query/code-clones-query-format.js +73 -0
  392. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +3 -3
  393. package/queries/catalog/dependencies-query/data-flow.d.ts +5 -4
  394. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +5 -2
  395. package/queries/catalog/dependencies-query/dependencies-query-executor.js +5 -5
  396. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -2
  397. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  398. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -4
  399. package/queries/catalog/dependencies-query/implicit-echo.js +2 -1
  400. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -0
  401. package/queries/catalog/dice-query/dice-query-format.js +1 -0
  402. package/queries/catalog/does-call-query/does-call-query-executor.js +1 -2
  403. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -0
  404. package/queries/catalog/does-call-query/does-call-query-format.js +1 -0
  405. package/queries/catalog/function-info-query/function-info-query-format.d.ts +2 -1
  406. package/queries/catalog/function-info-query/function-origin.d.ts +3 -2
  407. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -3
  408. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +5 -4
  409. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -0
  410. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -0
  411. package/queries/catalog/input-sources-query/input-sources-query-executor.js +7 -3
  412. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +9 -9
  413. package/queries/catalog/input-sources-query/simple-input-classifier.js +1 -1
  414. package/queries/catalog/linter-query/linter-query-executor.js +4 -1
  415. package/queries/catalog/linter-query/linter-query-format.js +3 -2
  416. package/queries/catalog/origin-query/origin-query-format.d.ts +1 -0
  417. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  418. package/queries/catalog/project-query/project-query-format.d.ts +2 -1
  419. package/queries/catalog/provenance-query/provenance-query-format.d.ts +1 -0
  420. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  421. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -0
  422. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  423. package/queries/catalog/signature-query/signature-query-executor.d.ts +9 -6
  424. package/queries/catalog/signature-query/signature-query-executor.js +14 -15
  425. package/queries/catalog/signature-query/signature-query-format.d.ts +21 -20
  426. package/queries/catalog/signature-query/signature-query-render.js +1 -1
  427. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  428. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +9 -5
  429. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  430. package/queries/query-function-filter.d.ts +1 -1
  431. package/queries/query.d.ts +59 -8
  432. package/queries/query.js +59 -37
  433. package/r-bridge/data/data.d.ts +39 -28
  434. package/r-bridge/data/data.js +37 -28
  435. package/r-bridge/lang-4.x/ast/model/model.d.ts +10 -1
  436. package/r-bridge/lang-4.x/ast/model/model.js +30 -0
  437. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +21 -0
  438. package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +25 -2
  439. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
  440. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -2
  441. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +2 -2
  442. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  443. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  444. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  445. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  446. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -3
  447. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  448. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  449. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  450. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  451. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  452. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  453. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  454. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  455. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  456. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +5 -6
  457. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +2 -7
  458. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  459. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -2
  460. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +2 -2
  461. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  462. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -5
  463. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +7 -2
  464. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +14 -6
  465. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +1 -1
  466. package/r-bridge/lang-4.x/ast/model/processing/visitor.js +2 -2
  467. package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -1
  468. package/r-bridge/lang-4.x/ast/model/type.js +1 -1
  469. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -2
  470. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -2
  471. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  472. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +3 -2
  473. package/r-bridge/parser.d.ts +8 -2
  474. package/r-bridge/parser.js +6 -0
  475. package/r-bridge/shell-executor.d.ts +2 -2
  476. package/r-bridge/shell-executor.js +3 -2
  477. package/r-bridge/shell.d.ts +2 -2
  478. package/r-bridge/shell.js +3 -2
  479. package/reconstruct/auto-select/magic-comments.js +1 -1
  480. package/reconstruct/reconstruct.d.ts +0 -5
  481. package/reconstruct/reconstruct.js +6 -5
  482. package/search/flowr-search-builder.d.ts +14 -0
  483. package/search/flowr-search-builder.js +7 -0
  484. package/search/flowr-search-executor.js +2 -2
  485. package/search/flowr-search-filters.js +8 -9
  486. package/search/flowr-search.js +1 -1
  487. package/search/search-executor/search-enrichers.d.ts +2 -0
  488. package/search/search-executor/search-enrichers.js +6 -1
  489. package/search/search-executor/search-generators.d.ts +2 -2
  490. package/search/search-executor/search-generators.js +13 -8
  491. package/search/search-executor/search-mappers.js +1 -1
  492. package/search/search-executor/search-transformer.d.ts +2 -2
  493. package/search/search-executor/search-transformer.js +6 -6
  494. package/slicing/criterion/parse.d.ts +2 -1
  495. package/slicing/criterion/parse.js +2 -1
  496. package/slicing/static/removal-slice.js +2 -1
  497. package/slicing/static/slice-call.d.ts +30 -4
  498. package/slicing/static/slice-call.js +74 -9
  499. package/slicing/static/slicer-types.d.ts +2 -1
  500. package/slicing/static/static-slicer.js +66 -11
  501. package/slicing/static/visiting-queue.d.ts +2 -0
  502. package/slicing/static/visiting-queue.js +4 -0
  503. package/taint-analysis/builder/report-template.d.ts +3 -3
  504. package/util/arg-matching.d.ts +1 -1
  505. package/util/collections/relation.d.ts +23 -0
  506. package/util/collections/relation.js +63 -0
  507. package/util/fixpoint.d.ts +65 -0
  508. package/util/fixpoint.js +216 -0
  509. package/util/flowr-version.d.ts +1 -1
  510. package/util/flowr-version.js +2 -2
  511. package/util/json.d.ts +4 -0
  512. package/util/json.js +12 -3
  513. package/util/mermaid/cfg.js +1 -2
  514. package/util/mermaid/dfg.d.ts +1 -1
  515. package/util/mermaid/dfg.js +1 -1
  516. package/util/mermaid/mermaid.d.ts +2 -1
  517. package/util/monoid.d.ts +26 -0
  518. package/util/monoid.js +31 -0
  519. package/util/prefix.d.ts +1 -1
  520. package/util/r-base-packages.d.ts +10 -7
  521. package/util/r-base-packages.js +11 -6
  522. package/util/r-package-urls.d.ts +10 -9
  523. package/util/r-value.js +2 -1
  524. package/util/r-version-order.d.ts +2 -0
  525. package/util/r-version-order.js +19 -0
  526. package/util/r-version.d.ts +2 -1
  527. package/util/r-version.js +2 -14
  528. package/util/range.d.ts +38 -29
  529. package/util/range.js +10 -5
  530. package/util/simple-df/dfg-ascii.js +2 -2
  531. package/util/text/ansi.d.ts +13 -9
  532. package/util/text/ansi.js +4 -6
  533. package/util/text/strings.d.ts +10 -3
  534. package/util/text/strings.js +10 -1
  535. package/util/version.d.ts +1 -1
  536. package/util/version.js +2 -1
  537. package/dataflow/environments/default-builtin-config.d.ts +0 -8874
  538. package/dataflow/environments/default-builtin-config.js +0 -1737
  539. package/r-bridge/lang-4.x/ast/model/operators.d.ts +0 -33
  540. package/r-bridge/lang-4.x/ast/model/operators.js +0 -54
  541. package/taint-analysis/eval/eval.d.ts +0 -1
  542. package/taint-analysis/eval/eval.js +0 -124
  543. package/taint-analysis/eval/instrumentation.d.ts +0 -59
  544. package/taint-analysis/eval/instrumentation.js +0 -124
@@ -1,12 +1,12 @@
1
1
  /**
2
- * `FunctionSemantics` wires the call helpers together and this file sits below it, so `CallProps` is used directly
3
- * here; reaching for `FunctionSemantics.call.props` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
2
+ * `FunctionSemantics` wires the call helpers together and this file sits below it, so `CallProps` is used directly here; reaching for `FunctionSemantics.call.props` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
4
3
  * @lintIgnore use-instead
5
4
  */
6
5
  import { type ArgProps, type BuiltInFnInfo, type FnSig, type PropSelector, type SemanticCallTags, type StatedProps, CallProps } from './built-in-props';
7
6
  import type { BuiltIns } from './built-in';
8
7
  import type { BuiltInDefinition, BuiltInDefinitions } from './built-in-config';
9
8
  import type { REnvironmentInformation } from './environment';
9
+ import type { BrandedIdentifier, BrandedNamespace } from './identifier';
10
10
  import { Identifier } from './identifier';
11
11
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
12
12
  import type { PackageSignatureSource } from '../../project/sigdb/reader';
@@ -14,10 +14,7 @@ import type { DecodedFunction } from '../../project/sigdb/decode';
14
14
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
15
15
  import type { DataflowInformation } from '../info';
16
16
  import type { DataflowGraph } from '../graph/graph';
17
- /**
18
- * Where to look up what flowR knows about a function, in that order:
19
- * the name as it resolves here, the built-in definitions, and the signature database for the rest.
20
- */
17
+ /** Where to look up what flowR knows about a function, in that order: the name as it resolves here, the built-in definitions, and the signature database for the rest. */
21
18
  export interface FnPropsSource {
22
19
  /** resolve the name here first, so a definition in the analyzed code shadows the built-in as it does in R */
23
20
  readonly environment?: REnvironmentInformation;
@@ -28,43 +25,31 @@ export interface FnPropsSource {
28
25
  /** the package version to ask the signature database for (its latest by default) */
29
26
  readonly version?: string;
30
27
  }
31
- /**
32
- * What flowR knows about the function `name`: what the built-in definitions state, filled up with what the
33
- * signature database knows (see {@link fnInfoFromSignature}). A declared signature wins, the properties of
34
- * both are joined. `undefined` if neither has anything to say, and also if the name resolves to a definition
35
- * in the analyzed code, which shadows any built-in.
36
- */
28
+ /** What flowR knows about the function `name`: what the built-in definitions state, filled up with what the signature database knows (see {@link fnInfoFromSignature}). */
37
29
  export declare function queryFnProps(name: Identifier, { environment, builtIns, signatures, version }: FnPropsSource): BuiltInFnInfo | undefined;
38
- /**
39
- * How to ask what flowR states about a built-in, answering every name once. The analyzer context decides, so a
40
- * configured or overwritten built-in is what answers; without one the defaults do.
41
- */
30
+ /** How to ask what flowR states about a built-in, answering every name once. */
42
31
  export declare function builtInLookup(ctx?: ReadOnlyFlowrAnalyzerContext): (name: Identifier) => BuiltInFnInfo | undefined;
43
32
  /** What flowR states about the call `id` makes, together with the name the call resolved to. */
44
- export declare function callFnProps(id: NodeId, { graph, environment }: Pick<DataflowInformation, 'graph' | 'environment'>): (BuiltInFnInfo & {
33
+ export declare function callFnProps(id: NodeId, graph: DataflowGraph, fallback?: REnvironmentInformation): (BuiltInFnInfo & {
34
+ name: Identifier;
35
+ }) | undefined;
36
+ export declare function callFnProps(id: NodeId, info: Pick<DataflowInformation, 'graph' | 'environment'>): (BuiltInFnInfo & {
45
37
  name: Identifier;
46
38
  }) | undefined;
47
39
  /** Whether `id` is quoted only by calls shipping it to a worker (`future(expr)`, `%dopar%`), which still runs it. */
48
40
  export declare function quotedForWorker(id: NodeId, graph: DataflowGraph, index: BuiltInIndex): boolean;
49
- /**
50
- * What the signature database implies for a package function: what its own entry states
51
- * (see {@link fnInfoFromSignature}) plus the {@link PropagatedProps} of everything it calls, transitively.
52
- * A package function that ends up in `system()` runs a system command as well.
53
- */
54
- export declare function inferFnProps(src: PackageSignatureSource, pkg: string, name: string, version?: string): BuiltInFnInfo | undefined;
55
- /**
56
- * Everything flowR knows about one function, no matter which of its sources knows it; see {@link fnInfo}.
57
- * It extends {@link BuiltInFnInfo}, so anything taking what a built-in states takes this as well.
58
- */
41
+ /** What the signature database implies for a package function: what its own entry states (see {@link fnInfoFromSignature}) plus the {@link PropagatedProps} of everything it calls, transitively. */
42
+ export declare function inferFnProps(src: PackageSignatureSource, pkg: BrandedNamespace, name: BrandedIdentifier, version?: string): BuiltInFnInfo | undefined;
43
+ /** Everything flowR knows about one function, no matter which of its sources knows it; see {@link fnInfo}. */
59
44
  export interface FnInfo extends BuiltInFnInfo {
60
45
  /** the identifier the answer is for, with the namespace filled in when an unqualified ask resolved to a package */
61
46
  readonly name: Identifier;
62
47
  /** the package the answer is for, `undefined` when the name resolves to no package at all */
63
- readonly package?: string;
48
+ readonly package?: BrandedNamespace;
64
49
  /** the package version the answer is for, i.e. the one the analysis assumes; see {@link SignatureDb.versionOf} */
65
50
  readonly version?: string;
66
51
  /** the formal names in order, empty when neither source declares any */
67
- readonly parameters: readonly string[];
52
+ readonly parameters: readonly BrandedIdentifier[];
68
53
  /** whether flowR's own built-in definitions state anything about the name */
69
54
  readonly builtIn: boolean;
70
55
  /** whether flowR's value solver can fold a call of it to a constant */
@@ -72,22 +57,14 @@ export interface FnInfo extends BuiltInFnInfo {
72
57
  /** the signature database entry: where the function is defined, its callees, its help topic */
73
58
  readonly entry?: DecodedFunction;
74
59
  }
75
- /**
76
- * The one place to ask what flowR knows about a function by name: one of its own built-ins, a package function
77
- * the signature database carries, or both. What the built-in states wins wherever the two overlap, exactly as
78
- * {@link queryFnProps} joins them. `undefined` when neither has anything to say about the name.
79
- * @param name - The function to ask about, qualified (`Identifier.make('lead', 'dplyr')`) to pin the package down.
80
- * @param ctx - The analyzer context the built-ins, the database and the assumed versions come from.
81
- * @param version - The package version to answer for, the one the analysis assumes if omitted.
82
- * @see {@link fnInfoLookup} - to ask the same question for many names
83
- * @example
84
- * ```ts
85
- * const ctx = analyzer.inspectContext();
86
- * fnInfo(Identifier.make('lead', 'dplyr'), ctx)?.parameters; // ['x', 'n', 'default', 'order_by', '...']
87
- * fnInfo(Identifier.make('nchar'), ctx)?.foldable; // true, flowR folds it itself
88
- * ```
89
- */
60
+ /** The one place to ask what flowR knows about a function by name: one of its own built-ins, a package function the signature database carries, or both. */
90
61
  export declare function fnInfo(name: Identifier, ctx: ReadOnlyFlowrAnalyzerContext, version?: string): FnInfo | undefined;
62
+ /** The package {@link fnInfo} answers `name` for and the signature database entry it finds there, without the props of everything the entry calls, for a caller after the formals or the entry alone. */
63
+ export declare function fnEntry(name: Identifier, ctx: ReadOnlyFlowrAnalyzerContext, version?: string): {
64
+ readonly pkg?: BrandedNamespace;
65
+ readonly qualified: Identifier;
66
+ readonly entry?: DecodedFunction;
67
+ };
91
68
  /** The identifiers a definition registers, with the suffixes of a replacement spelled out. */
92
69
  export declare function builtInNames(definition: BuiltInDefinition): Identifier[];
93
70
  /** One built-in as the {@link BuiltInIndex} sees it: the name it is registered under and what flowR states about it. */
@@ -109,20 +86,10 @@ export interface BuiltInParam {
109
86
  readonly call: Identifier;
110
87
  /** the position it is declared at; a `...` parameter covers every position from here on */
111
88
  readonly index: number;
112
- readonly name: string;
89
+ readonly name: BrandedIdentifier;
113
90
  readonly props: ArgProps;
114
91
  }
115
- /**
116
- * The one place to ask what flowR's built-ins are: _every pure function_, _every call that reads a file_,
117
- * _every parameter that names a resource_, _everything the value solver can fold_. Each answer is derived
118
- * from the {@link BuiltInFnInfo} the definitions carry, so a built-in that states its {@link CallProp} bits and
119
- * its {@link FnSig} is found here without anything else being registered.
120
- *
121
- * Build one over the {@link DefaultBuiltinConfig} with {@link BuiltInIndex.default} (computed once and shared),
122
- * over your own definitions with {@link BuiltInIndex.of}, or over the built-ins an analysis actually registered
123
- * with {@link BuiltInIndex.ofEnvironment}, which reflects configured overrides. For a single name (where a
124
- * definition in the analyzed code shadows the built-in) use {@link queryFnProps} instead.
125
- */
92
+ /** The one place to ask what flowR's built-ins are: _every pure function_, _every call that reads a file_, _every parameter that names a resource_, _everything the value solver can fold_. */
126
93
  export declare class BuiltInIndex {
127
94
  /** every built-in the index knows, one entry per namespace and name */
128
95
  readonly entries: readonly BuiltInEntry[];
@@ -141,23 +108,11 @@ export declare class BuiltInIndex {
141
108
  static ofEnvironment(builtIns: BuiltIns): BuiltInIndex;
142
109
  /** answers are keyed by what was asked, as every caller asks the same handful of questions over and over */
143
110
  private cached;
144
- /**
145
- * Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls.
146
- * @param props - The built-in must satisfy at least one of these properties.
147
- * @param excluding - Drop built-ins that also carry any of these properties.
148
- */
111
+ /** Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls. */
149
112
  with(props: PropSelector, excluding?: PropSelector): readonly Identifier[];
150
- /**
151
- * Every built-in carrying *every* property of `props`, for the questions a single one cannot answer,
152
- * like {@link FileInputProps} for the calls that read a file rather than only write one.
153
- * @param props - The built-in must satisfy all of these properties.
154
- * @param excluding - Drop built-ins that also carry any of these properties.
155
- */
113
+ /** Every built-in carrying *every* property of `props`, for the questions a single one cannot answer, like {@link FileInputProps} for the calls that read a file rather than only write one. */
156
114
  withAll(props: PropSelector, excluding?: PropSelector): readonly Identifier[];
157
- /**
158
- * Every built-in that states its props but carries none of `props`. With {@link InputProps} this yields
159
- * the calls that derive their result from their arguments alone.
160
- */
115
+ /** Every built-in that states its props but carries none of `props`. */
161
116
  without(props: PropSelector): readonly Identifier[];
162
117
  /** Every built-in flowR states computes a result and nothing else ({@link CallProp.Pure}). */
163
118
  get pure(): readonly Identifier[];
@@ -165,11 +120,7 @@ export declare class BuiltInIndex {
165
120
  get foldable(): readonly Identifier[];
166
121
  /** Every parameter whose argument carries at least one bit of `props`, like {@link ArgProp.Resource}. */
167
122
  params(props: ArgProps): BuiltInParam[];
168
- /**
169
- * What the index states about `name`. A qualified name answers for that package alone, so `stats::filter`
170
- * does not report what `dplyr::filter` states; an unqualified one answers with what R's default search
171
- * path would find, `base` first and the other {@link AttachedBasePackageSet|attached base packages} next.
172
- */
123
+ /** What the index states about `name`. */
173
124
  get(name: Identifier): BuiltInEntry | undefined;
174
125
  /** The {@link CallProp} bits of `name`, `undefined` when no built-in of that name states any. */
175
126
  propsOf(name: Identifier): CallProps | undefined;
@@ -7,10 +7,10 @@ exports.callFnProps = callFnProps;
7
7
  exports.quotedForWorker = quotedForWorker;
8
8
  exports.inferFnProps = inferFnProps;
9
9
  exports.fnInfo = fnInfo;
10
+ exports.fnEntry = fnEntry;
10
11
  exports.builtInNames = builtInNames;
11
12
  /**
12
- * `FunctionSemantics` wires the call helpers together and this file sits below it, so `CallProps` is used directly
13
- * here; reaching for `FunctionSemantics.call.props` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
13
+ * `FunctionSemantics` wires the call helpers together and this file sits below it, so `CallProps` is used directly here; reaching for `FunctionSemantics.call.props` would make `src/dataflow/fn/function-semantics.ts` import its own importers.
14
14
  * @lintIgnore use-instead
15
15
  */
16
16
  const built_in_props_1 = require("./built-in-props");
@@ -25,10 +25,7 @@ const vertex_1 = require("../graph/vertex");
25
25
  const df_helper_1 = require("../graph/df-helper");
26
26
  const edge_1 = require("../graph/edge");
27
27
  const r_base_packages_1 = require("../../util/r-base-packages");
28
- /**
29
- * What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR
30
- * states nothing about it. `library(pkg)` binds every export itself, and that binding hides the built-in layer.
31
- */
28
+ /** What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR states nothing about it. */
32
29
  function statedBuiltIn(definition, environment) {
33
30
  const pkgFn = definition.type === identifier_1.ReferenceType.Function ? node_id_1.NodeId.toPkgFn(definition.nodeId) : undefined;
34
31
  if (pkgFn === undefined) {
@@ -70,12 +67,7 @@ function ofDefinitions(definitions) {
70
67
  }
71
68
  return sig === undefined && frame === undefined && !function_semantics_1.FunctionSemantics.call.props.hasAny(stated) ? undefined : { sig, ...stated, frame };
72
69
  }
73
- /**
74
- * What flowR knows about the function `name`: what the built-in definitions state, filled up with what the
75
- * signature database knows (see {@link fnInfoFromSignature}). A declared signature wins, the properties of
76
- * both are joined. `undefined` if neither has anything to say, and also if the name resolves to a definition
77
- * in the analyzed code, which shadows any built-in.
78
- */
70
+ /** What flowR knows about the function `name`: what the built-in definitions state, filled up with what the signature database knows (see {@link fnInfoFromSignature}). */
79
71
  function queryFnProps(name, { environment, builtIns, signatures, version }) {
80
72
  let info;
81
73
  if (environment !== undefined) {
@@ -99,10 +91,7 @@ function queryFnProps(name, { environment, builtIns, signatures, version }) {
99
91
  }
100
92
  return { sig: info?.sig ?? known.sig, ...built_in_props_1.CallProps.join(info, known), frame: info?.frame };
101
93
  }
102
- /**
103
- * How to ask what flowR states about a built-in, answering every name once. The analyzer context decides, so a
104
- * configured or overwritten built-in is what answers; without one the defaults do.
105
- */
94
+ /** How to ask what flowR states about a built-in, answering every name once. */
106
95
  function builtInLookup(ctx) {
107
96
  const environment = ctx?.env.makeCleanEnv();
108
97
  /* keyed by namespace and name, as `stats::filter` and `dplyr::filter` are not the same function */
@@ -121,16 +110,18 @@ function builtInLookup(ctx) {
121
110
  return bucket.get(key);
122
111
  };
123
112
  }
124
- /** What flowR states about the call `id` makes, together with the name the call resolved to. */
125
- function callFnProps(id, { graph, environment }) {
113
+ function callFnProps(id, from, fallback) {
114
+ const [graph, environment] = 'graph' in from ? [from.graph, from.environment] : [from, fallback];
126
115
  const vertex = graph.getVertex(id);
127
116
  if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
128
117
  return undefined;
129
118
  }
130
- /* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
131
- * flowR settled on the built-ins keeps no environment, and a later redefinition must not speak for it */
119
+ /* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call flowR settled on the built-ins keeps no environment, and a later redefinition must not speak for it */
132
120
  const known = vertex.environment ?? environment;
133
121
  const name = df_helper_1.Dataflow.qualify(id, graph, false) ?? vertex.name;
122
+ if (known === undefined) {
123
+ return { name, ...BuiltInIndex.default().get(name) };
124
+ }
134
125
  return {
135
126
  name,
136
127
  ...queryFnProps(name, {
@@ -143,11 +134,7 @@ function quotedForWorker(id, graph, index) {
143
134
  const quoting = df_helper_1.Dataflow.sourcesOf(graph, id, edge_1.EdgeType.NonStandardEvaluation);
144
135
  return quoting.length > 0 && quoting.every(s => df_helper_1.Dataflow.targetsOf(graph, s, edge_1.EdgeType.Calls).some(t => node_id_1.NodeId.isBuiltIn(t) && ((index.propsOf(node_id_1.NodeId.fromBuiltIn(t)) ?? 0) & built_in_props_1.CallProp.Concurrent) !== 0));
145
136
  }
146
- /**
147
- * What the signature database implies for a package function: what its own entry states
148
- * (see {@link fnInfoFromSignature}) plus the {@link PropagatedProps} of everything it calls, transitively.
149
- * A package function that ends up in `system()` runs a system command as well.
150
- */
137
+ /** What the signature database implies for a package function: what its own entry states (see {@link fnInfoFromSignature}) plus the {@link PropagatedProps} of everything it calls, transitively. */
151
138
  function inferFnProps(src, pkg, name, version) {
152
139
  const fn = src.functionByName(pkg, name, version);
153
140
  return fn === undefined ? undefined : propsOfSignature(src, fn, pkg, version);
@@ -162,32 +149,13 @@ function propsOfSignature(src, fn, pkg, version) {
162
149
  }
163
150
  return { sig: own.sig, ...props };
164
151
  }
165
- /**
166
- * The one place to ask what flowR knows about a function by name: one of its own built-ins, a package function
167
- * the signature database carries, or both. What the built-in states wins wherever the two overlap, exactly as
168
- * {@link queryFnProps} joins them. `undefined` when neither has anything to say about the name.
169
- * @param name - The function to ask about, qualified (`Identifier.make('lead', 'dplyr')`) to pin the package down.
170
- * @param ctx - The analyzer context the built-ins, the database and the assumed versions come from.
171
- * @param version - The package version to answer for, the one the analysis assumes if omitted.
172
- * @see {@link fnInfoLookup} - to ask the same question for many names
173
- * @example
174
- * ```ts
175
- * const ctx = analyzer.inspectContext();
176
- * fnInfo(Identifier.make('lead', 'dplyr'), ctx)?.parameters; // ['x', 'n', 'default', 'order_by', '...']
177
- * fnInfo(Identifier.make('nchar'), ctx)?.foldable; // true, flowR folds it itself
178
- * ```
179
- */
152
+ /** The one place to ask what flowR knows about a function by name: one of its own built-ins, a package function the signature database carries, or both. */
180
153
  function fnInfo(name, ctx, version) {
181
154
  const db = (0, signature_db_1.signatureDbOf)(ctx.deps);
182
- const available = db.available();
183
- const [bare, namespace, internal] = identifier_1.Identifier.toArray(name);
184
- const pkg = namespace ?? packageExporting(bare, ctx);
155
+ const { pkg, qualified, entry } = fnEntry(name, ctx, version);
185
156
  /* an unqualified ask keeps its form, the built-in layer has a search path of its own */
186
157
  const stated = queryFnProps(name, { environment: ctx.env.makeCleanEnv() });
187
- const qualified = pkg === undefined ? name : identifier_1.Identifier.make(bare, pkg, internal === true);
188
158
  const assumed = pkg === undefined ? undefined : version ?? db.versionOf(pkg);
189
- /* the identifier says how far to reach, `::` to the exports and `:::` past them */
190
- const entry = pkg === undefined || !available ? undefined : db.functionOf(qualified, version);
191
159
  const known = entry === undefined || pkg === undefined ? undefined : propsOfSignature(db.sources(), entry, pkg, assumed);
192
160
  if (stated === undefined && known === undefined) {
193
161
  return undefined;
@@ -195,8 +163,7 @@ function fnInfo(name, ctx, version) {
195
163
  /* the same identifier the built-in layer was asked with, so both halves of the answer describe one function */
196
164
  const definition = ctx.env.builtInFunctionOf(name);
197
165
  const sig = nonEmpty(stated?.sig) ?? nonEmpty(known?.sig);
198
- /* the database keeps every formal, a `sig` only the ones flowR models, so it answers first, but an entry
199
- * that records none must not hide the formals the built-in does state */
166
+ /* the database keeps every formal, a `sig` only the ones flowR models, so it answers first, but an entry that records none must not hide the formals the built-in does state */
200
167
  const parameters = nonEmpty(entry?.signature)?.map(p => p.name) ?? sig?.map(([param]) => param) ?? [];
201
168
  return {
202
169
  name: qualified,
@@ -212,18 +179,22 @@ function fnInfo(name, ctx, version) {
212
179
  entry
213
180
  };
214
181
  }
182
+ /** The package {@link fnInfo} answers `name` for and the signature database entry it finds there, without the props of everything the entry calls, for a caller after the formals or the entry alone. */
183
+ function fnEntry(name, ctx, version) {
184
+ const db = (0, signature_db_1.signatureDbOf)(ctx.deps);
185
+ const available = db.available();
186
+ const [bare, namespace, internal] = identifier_1.Identifier.toArray(name);
187
+ const pkg = namespace ?? packageExporting(bare, ctx);
188
+ const qualified = pkg === undefined ? name : identifier_1.Identifier.make(bare, pkg, internal === true);
189
+ /* the identifier says how far to reach, `::` to the exports and `:::` past them */
190
+ const entry = pkg === undefined || !available ? undefined : db.functionOf(qualified, version);
191
+ return { pkg, qualified, entry };
192
+ }
215
193
  /** The array itself, `undefined` when it holds nothing, so an empty one does not count as an answer. */
216
194
  function nonEmpty(of) {
217
195
  return of !== undefined && of.length > 0 ? of : undefined;
218
196
  }
219
- /**
220
- * The package an unqualified `name` is answered for. Only one the project pulls in counts, as a name some
221
- * unrelated package exports says nothing about the code at hand, and a `library()` of one sits above the base
222
- * packages. Where several pulled-in packages export it the most-used answers, as attach order is not known here.
223
- *
224
- * Base R is settled by {@link baseRExportOwner} when the database's export index does not carry the name, so
225
- * `sum` still answers as `base::sum` on a bundle holding no record of it and with no database at all.
226
- */
197
+ /** The package an unqualified `name` is answered for. */
227
198
  function packageExporting(name, ctx) {
228
199
  let best;
229
200
  let bestRank = Number.MAX_SAFE_INTEGER;
@@ -262,9 +233,7 @@ function entryOfDefinition(definition) {
262
233
  }
263
234
  function entriesOfMemory(builtIns) {
264
235
  const out = [];
265
- /* the index says what flowR *knows*, not what is in scope, so the packages R does not attach on startup
266
- belong in it as much as the always-on built-ins do -- being gated changes when a name resolves, not
267
- whether flowR can answer for it */
236
+ /* the index says what flowR *knows*, not what is in scope, so the packages R does not attach on startup belong in it as much as the always-on built-ins do -- being gated changes when a name resolves, not whether flowR can answer for it */
268
237
  /* an entry of a package R does not attach keeps the package it belongs to, `config::get` is no `get` */
269
238
  for (const [pkg, memory] of [[undefined, builtIns.builtInMemory], ...builtIns.packageMemory.entries()]) {
270
239
  for (const [registered, definitions] of memory) {
@@ -282,11 +251,7 @@ function entriesOfMemory(builtIns) {
282
251
  return out;
283
252
  }
284
253
  let defaultIndex;
285
- /**
286
- * The one entry for a name several definitions state something about, the later definition winning wherever
287
- * it states anything -- a definition that only adds a {@link FnSig} must not drop the props of the one before.
288
- * A definition marked `overrides` replaces the earlier one outright, as that is what it says it does.
289
- */
254
+ /** The one entry for a name several definitions state something about, the later definition winning wherever it states anything -- a definition that only adds a {@link FnSig} must not drop the props of the one before. */
290
255
  function mergedEntry(known, next) {
291
256
  return {
292
257
  name: next.name,
@@ -308,17 +273,7 @@ function searchPathRank(name) {
308
273
  }
309
274
  return namespace === "base" /* PkgName.Base */ ? 1 : r_base_packages_1.AttachedBasePackageSet.has(namespace) ? 2 : 3;
310
275
  }
311
- /**
312
- * The one place to ask what flowR's built-ins are: _every pure function_, _every call that reads a file_,
313
- * _every parameter that names a resource_, _everything the value solver can fold_. Each answer is derived
314
- * from the {@link BuiltInFnInfo} the definitions carry, so a built-in that states its {@link CallProp} bits and
315
- * its {@link FnSig} is found here without anything else being registered.
316
- *
317
- * Build one over the {@link DefaultBuiltinConfig} with {@link BuiltInIndex.default} (computed once and shared),
318
- * over your own definitions with {@link BuiltInIndex.of}, or over the built-ins an analysis actually registered
319
- * with {@link BuiltInIndex.ofEnvironment}, which reflects configured overrides. For a single name (where a
320
- * definition in the analyzed code shadows the built-in) use {@link queryFnProps} instead.
321
- */
276
+ /** The one place to ask what flowR's built-ins are: _every pure function_, _every call that reads a file_, _every parameter that names a resource_, _everything the value solver can fold_. */
322
277
  class BuiltInIndex {
323
278
  /** every built-in the index knows, one entry per namespace and name */
324
279
  entries;
@@ -381,29 +336,17 @@ class BuiltInIndex {
381
336
  }
382
337
  return found;
383
338
  }
384
- /**
385
- * Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls.
386
- * @param props - The built-in must satisfy at least one of these properties.
387
- * @param excluding - Drop built-ins that also carry any of these properties.
388
- */
339
+ /** Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls. */
389
340
  with(props, excluding) {
390
341
  const key = `with:${built_in_props_1.CallProps.key(props)}${excluding === undefined ? '' : `!${built_in_props_1.CallProps.key(excluding)}`}`;
391
342
  return this.cached(key, e => built_in_props_1.CallProps.hasAny(e, props) && (excluding === undefined || !built_in_props_1.CallProps.hasAny(e, excluding)));
392
343
  }
393
- /**
394
- * Every built-in carrying *every* property of `props`, for the questions a single one cannot answer,
395
- * like {@link FileInputProps} for the calls that read a file rather than only write one.
396
- * @param props - The built-in must satisfy all of these properties.
397
- * @param excluding - Drop built-ins that also carry any of these properties.
398
- */
344
+ /** Every built-in carrying *every* property of `props`, for the questions a single one cannot answer, like {@link FileInputProps} for the calls that read a file rather than only write one. */
399
345
  withAll(props, excluding) {
400
346
  const key = `all:${built_in_props_1.CallProps.key(props)}${excluding === undefined ? '' : `!${built_in_props_1.CallProps.key(excluding)}`}`;
401
347
  return this.cached(key, e => built_in_props_1.CallProps.hasAny(e) && built_in_props_1.CallProps.hasAll(e, props) && (excluding === undefined || !built_in_props_1.CallProps.hasAny(e, excluding)));
402
348
  }
403
- /**
404
- * Every built-in that states its props but carries none of `props`. With {@link InputProps} this yields
405
- * the calls that derive their result from their arguments alone.
406
- */
349
+ /** Every built-in that states its props but carries none of `props`. */
407
350
  without(props) {
408
351
  return this.cached(`without:${function_semantics_1.FunctionSemantics.call.props.key(props)}`, e => function_semantics_1.FunctionSemantics.call.props.hasAny(e) && !function_semantics_1.FunctionSemantics.call.props.hasAny(e, props));
409
352
  }
@@ -427,11 +370,7 @@ class BuiltInIndex {
427
370
  }
428
371
  return found;
429
372
  }
430
- /**
431
- * What the index states about `name`. A qualified name answers for that package alone, so `stats::filter`
432
- * does not report what `dplyr::filter` states; an unqualified one answers with what R's default search
433
- * path would find, `base` first and the other {@link AttachedBasePackageSet|attached base packages} next.
434
- */
373
+ /** What the index states about `name`. */
435
374
  get(name) {
436
375
  const namespace = identifier_1.Identifier.getNamespace(name);
437
376
  if (namespace === undefined) {
@@ -1,35 +1,25 @@
1
1
  import { type REnvironmentInformation } from './environment';
2
2
  import { Ternary } from '../../util/logic';
3
- import { Identifier, type IdentifierDefinition, ReferenceType } from './identifier';
3
+ import { Identifier, type IdentifierDefinition, type IdentifierReference, ReferenceType } from './identifier';
4
+ /** The environment the reference `ref` resolves in: the global one for a read evaluated there, `env` otherwise. */
5
+ export declare function scopeOf(ref: Pick<IdentifierReference, 'global'>, env: REnvironmentInformation): REnvironmentInformation;
4
6
  /**
5
7
  * Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
6
- * If the type you want to reference is unknown, please use {@link resolveByNameAnyType} instead.
7
- * @param id - The identifier to resolve (optionally namespaced)
8
- * @param environment - The current environment used for name resolution
9
- * @param target - The target (meta) type of the identifier to resolve
10
- * @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
11
- * if the identifier is undefined in the current scope/with the current environment information.
12
8
  * @useInstead {@link Resolve.byNameAndType}
13
9
  */
14
- export declare function resolveByName(id: Identifier, environment: REnvironmentInformation, target: ReferenceType): readonly IdentifierDefinition[] | undefined;
10
+ export declare function resolveByName(id: Identifier | undefined, environment: REnvironmentInformation, target: ReferenceType): readonly IdentifierDefinition[] | undefined;
15
11
  /**
16
12
  * The more performant version of {@link resolveByName} when the target type is unknown.
17
13
  * @useInstead {@link Resolve.byName}
18
14
  */
19
- export declare function resolveByNameAnyType(id: Identifier, environment: REnvironmentInformation): IdentifierDefinition[] | undefined;
15
+ export declare function resolveByNameAnyType(id: Identifier | undefined, environment: REnvironmentInformation): IdentifierDefinition[] | undefined;
20
16
  /**
21
- * Whether every definition `name` may refer to is the built-in one (or there is none), i.e., the name is not
22
- * shadowed by a user definition. Pass the {@link ReferenceType} the use site wants: `Function` for a call like
23
- * `ls()`, `Constant` for a name like `.GlobalEnv`.
17
+ * Whether every definition `name` may refer to is the built-in one (or there is none), i.e., the name is not shadowed by a user definition.
24
18
  * @useInstead {@link Resolve.isBuiltIn}
25
19
  */
26
20
  export declare function resolvesToBuiltIn(name: Identifier, environment: REnvironmentInformation, target: ReferenceType.Function | ReferenceType.Constant): boolean;
27
21
  /**
28
22
  * Checks whether the given identifier name resolves to a built-in constant with the given value.
29
- * @param name - The name of the identifier to resolve
30
- * @param environment - The current environment used for name resolution
31
- * @param wantedValue - The built-in constant value to check for
32
- * @returns Whether the identifier always, never, or maybe resolves to the given built-in constant value
33
23
  * @useInstead {@link Resolve.toBuiltIn}
34
24
  */
35
25
  export declare function resolvesToBuiltInConstant(name: Identifier | undefined, environment: REnvironmentInformation, wantedValue: unknown): Ternary;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scopeOf = scopeOf;
3
4
  exports.resolveByName = resolveByName;
4
5
  exports.resolveByNameAnyType = resolveByNameAnyType;
5
6
  exports.resolvesToBuiltIn = resolvesToBuiltIn;
@@ -17,17 +18,16 @@ const TailCacheCap = 4096;
17
18
  function layerSkipped(layer, ns) {
18
19
  return ns !== undefined ? layer.n !== ns : layer.t === environment_1.EnvType.LoadedNamespace;
19
20
  }
20
- /**
21
- * What the built-in environment states about `pkg::name` for a package nothing attached: `pkg::fn` reaches its
22
- * package in R whether or not it is on the search path, so a namespaced name has to find it here. Failing that,
23
- * a package outside of base R never hands out a function of base R, so `config::get` is no `base::get`.
24
- */
21
+ /** What the built-in environment states about `pkg::name` for a package nothing attached: `pkg::fn` reaches its package in R whether or not it is on the search path, so a namespaced name has to find it here. */
25
22
  function statedIn(builtIn, name, ns) {
26
- const stated = ns === undefined ? undefined : builtIn.namespaces?.get(String(ns))?.get(name);
27
- if (stated !== undefined || ns === undefined || (0, r_base_packages_1.isBaseRPackage)(String(ns))) {
23
+ const stated = ns === undefined ? undefined : builtIn.namespaces?.get(ns)?.get(name);
24
+ if (stated !== undefined || ns === undefined || (0, r_base_packages_1.isBaseRPackage)(ns)) {
28
25
  return stated ?? builtIn.lookup(name);
29
26
  }
30
- const foreign = builtIn.lookup(name)?.filter(d => !(0, r_base_packages_1.isBaseRPackage)(String(d.name === undefined ? undefined : identifier_1.Identifier.getNamespace(d.name))));
27
+ const foreign = builtIn.lookup(name)?.filter(d => {
28
+ const own = d.name === undefined ? undefined : identifier_1.Identifier.getNamespace(d.name);
29
+ return own === undefined || !(0, r_base_packages_1.isBaseRPackage)(own);
30
+ });
31
31
  return foreign?.length ? foreign : undefined;
32
32
  }
33
33
  const FunctionTargetTypes = identifier_1.ReferenceType.Function | identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.Unknown | identifier_1.ReferenceType.Argument | identifier_1.ReferenceType.Parameter;
@@ -51,29 +51,23 @@ const TargetTypePredicate = {
51
51
  [identifier_1.ReferenceType.S7MethodPrefix]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
52
52
  [identifier_1.ReferenceType.NonFunction]: ({ type }) => (0, identifier_1.isReferenceType)(type, NonFunctionTargetTypes),
53
53
  };
54
- /**
55
- * What the script itself defines under `id`, ignoring everything flowR carries or a database attached.
56
- * This is the fallback of a value position ({@link ReferenceType.NonFunction}), and the two halves answer
57
- * the two ways a value position meets a function of its name. In a project that attaches packages,
58
- * `library(dplyr)` puts a function `id` in scope, and `filter(df, id > 2)` means the column, never that
59
- * function. A script writing `x <- function() 1` and then `x > 2` has only that one `x` to mean, wrong as
60
- * the comparison is, so the read stays: dropping it would leave the definition looking unused.
61
- */
54
+ /** What the script itself defines under `id`, ignoring everything flowR carries or a database attached. */
62
55
  function ownDefinitions(id, environment) {
63
56
  const own = resolveByNameAnyType(id, environment)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId));
64
57
  return own !== undefined && own.length > 0 ? own : undefined;
65
58
  }
59
+ /** The environment the reference `ref` resolves in: the global one for a read evaluated there, `env` otherwise. */
60
+ function scopeOf(ref, env) {
61
+ return ref.global ? { current: environment_1.REnvironment.findGlobal(env.current), level: 0 } : env;
62
+ }
66
63
  /**
67
64
  * Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
68
- * If the type you want to reference is unknown, please use {@link resolveByNameAnyType} instead.
69
- * @param id - The identifier to resolve (optionally namespaced)
70
- * @param environment - The current environment used for name resolution
71
- * @param target - The target (meta) type of the identifier to resolve
72
- * @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
73
- * if the identifier is undefined in the current scope/with the current environment information.
74
65
  * @useInstead {@link Resolve.byNameAndType}
75
66
  */
76
67
  function resolveByName(id, environment, target) {
68
+ if (id === undefined) {
69
+ return undefined;
70
+ }
77
71
  if (target === identifier_1.ReferenceType.Unknown) {
78
72
  return resolveByNameAnyType(id, environment);
79
73
  }
@@ -95,15 +89,13 @@ function resolveByTargetType(id, environment, target) {
95
89
  const ns = identifier_1.Identifier.getNamespace(id);
96
90
  const internal = identifier_1.Identifier.accessesInternal(id);
97
91
  let current = environment.current;
98
- /* `current` can already be the built-in environment itself (e.g. `get(x, envir=baseenv())`);
99
- * it has no parent to walk to, so resolve directly instead of entering the loop below. */
92
+ /* `current` can already be the built-in environment itself (e.g. `get(x, envir=baseenv())`); it has no parent to walk to, so resolve directly instead of entering the loop below. */
100
93
  if (current.builtInEnv) {
101
94
  return current.lookup(name);
102
95
  }
103
96
  let definitions = undefined;
104
97
  const wantedType = TargetTypePredicate[target];
105
- /* the attached packages below the code's own frames are a dozen layers deep and nothing writes them, so the
106
- * walk through them is done once per name and target instead of once per resolution */
98
+ /* the attached packages below the code's own frames are a dozen layers deep and nothing writes them, so the walk through them is done once per name and target instead of once per resolution */
107
99
  const flatten = ns === undefined && internal !== false && typeof id === 'string'
108
100
  && target !== identifier_1.ReferenceType.S3MethodPrefix && target !== identifier_1.ReferenceType.S7MethodPrefix;
109
101
  let flattenAt;
@@ -162,8 +154,7 @@ function resolveByTargetType(id, environment, target) {
162
154
  }
163
155
  current = current.parent;
164
156
  } while (!current.builtInEnv);
165
- /* the built-in layer is handed over as it is, except to a value position: `filter(df, c > 2)` means the
166
- column `c`, never `base::c`, and only with nothing left does `ownDefinitions` have its say */
157
+ /* the built-in layer is handed over as it is, except to a value position: `filter(df, c > 2)` means the column `c`, never `base::c`, and only with nothing left does `ownDefinitions` have its say */
167
158
  const known = statedIn(current, name, ns);
168
159
  const builtIns = target === identifier_1.ReferenceType.NonFunction ? known?.filter(wantedType) : known;
169
160
  const result = definitions
@@ -183,6 +174,9 @@ function resolveByTargetType(id, environment, target) {
183
174
  * @useInstead {@link Resolve.byName}
184
175
  */
185
176
  function resolveByNameAnyType(id, environment) {
177
+ if (id === undefined) {
178
+ return undefined;
179
+ }
186
180
  let current = environment.current;
187
181
  /* only cache plain names: namespaced ids are arrays (no stable map key) and must not answer plain lookups */
188
182
  if (typeof id === 'string') {
@@ -231,9 +225,7 @@ function remember(environment, id, definitions) {
231
225
  return definitions;
232
226
  }
233
227
  /**
234
- * Whether every definition `name` may refer to is the built-in one (or there is none), i.e., the name is not
235
- * shadowed by a user definition. Pass the {@link ReferenceType} the use site wants: `Function` for a call like
236
- * `ls()`, `Constant` for a name like `.GlobalEnv`.
228
+ * Whether every definition `name` may refer to is the built-in one (or there is none), i.e., the name is not shadowed by a user definition.
237
229
  * @useInstead {@link Resolve.isBuiltIn}
238
230
  */
239
231
  function resolvesToBuiltIn(name, environment, target) {
@@ -243,10 +235,6 @@ function resolvesToBuiltIn(name, environment, target) {
243
235
  }
244
236
  /**
245
237
  * Checks whether the given identifier name resolves to a built-in constant with the given value.
246
- * @param name - The name of the identifier to resolve
247
- * @param environment - The current environment used for name resolution
248
- * @param wantedValue - The built-in constant value to check for
249
- * @returns Whether the identifier always, never, or maybe resolves to the given built-in constant value
250
238
  * @useInstead {@link Resolve.toBuiltIn}
251
239
  */
252
240
  function resolvesToBuiltInConstant(name, environment, wantedValue) {
@@ -2,25 +2,25 @@ import { type REnvironmentInformation } from './environment';
2
2
  /**
3
3
  * Add a new local environment scope to the stack, returns the modified variant (shares the original stack, no deep-clone).
4
4
  * @useInstead {@link REnvironment.pushLocal}
5
- * @see {@link popLocalEnvironment} - to remove the local scope again
6
5
  */
7
6
  export declare function pushLocalEnvironment({ level, current }: REnvironmentInformation): REnvironmentInformation;
8
7
  /**
9
8
  * Remove the top local environment scope from the stack, returns the modified variant (shares the original stack, no deep-clone).
10
9
  * @useInstead {@link REnvironment.popLocal}
11
- * @see {@link pushLocalEnvironment} - to add a local scope
12
10
  */
13
11
  export declare function popLocalEnvironment({ current, level }: REnvironmentInformation): REnvironmentInformation;
14
12
  /**
15
- * Pads whichever of `base`/`next` is shallower with empty local scopes until both are at the same lexical {@link REnvironmentInformation#level|level}.
13
+ * The frames of `environment` a function whose body runs at `bodyLevel` can see: the frame it was defined in and those around it, never the frames of the functions calling it.
14
+ * @useInstead {@link REnvironment.visibleTo}
16
15
  */
16
+ export declare function framesVisibleTo(bodyLevel: number, environment: REnvironmentInformation): REnvironmentInformation;
17
+ /** Pads whichever of `base`/`next` is shallower with empty local scopes until both are at the same lexical {@link REnvironmentInformation#level|level}. */
17
18
  export declare function padToCommonScope(base: REnvironmentInformation, next: REnvironmentInformation): {
18
19
  base: REnvironmentInformation;
19
20
  next: REnvironmentInformation;
20
21
  };
21
22
  /**
22
- * The environment's search path with an empty global frame: attached packages stay visible, the global frame's
23
- * binds do not. Prefer this over `makeCleanEnv` wherever an environment is at hand; the chain below is shared.
23
+ * The environment's search path with an empty global frame: attached packages stay visible, the global frame's binds do not.
24
24
  * @useInstead {@link REnvironment.cleanOf}
25
25
  */
26
26
  export declare function cleanEnvOf({ current }: REnvironmentInformation): REnvironmentInformation;