@eagleoutice/flowr 2.16.6 → 2.16.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. package/README.md +21 -15
  2. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
  3. package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
  4. package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
  5. package/abstract-interpretation/data-frame/resolve-args.js +2 -11
  6. package/cli/repl/commands/repl-cfg.js +5 -19
  7. package/cli/repl/commands/repl-code-command.d.ts +10 -0
  8. package/cli/repl/commands/repl-code-command.js +18 -0
  9. package/cli/repl/commands/repl-dataflow.js +34 -59
  10. package/cli/repl/commands/repl-normalize.js +24 -41
  11. package/cli/repl/commands/repl-query.js +10 -17
  12. package/config.js +3 -3
  13. package/control-flow/cfg-dead-code.js +15 -2
  14. package/control-flow/useless-loop.js +1 -2
  15. package/data/r-base-packages.generated.d.ts +1 -1
  16. package/data/r-base-packages.generated.js +3 -3
  17. package/dataflow/environments/ambient-state-name.d.ts +80 -0
  18. package/dataflow/environments/ambient-state-name.js +113 -0
  19. package/dataflow/environments/built-in-eval-name.d.ts +3 -1
  20. package/dataflow/environments/built-in-eval-name.js +2 -0
  21. package/dataflow/environments/built-in-props.d.ts +27 -7
  22. package/dataflow/environments/built-in-props.js +59 -44
  23. package/dataflow/environments/built-in.d.ts +5 -2
  24. package/dataflow/environments/built-in.js +22 -5
  25. package/dataflow/environments/default-builtin-config.d.ts +538 -14
  26. package/dataflow/environments/default-builtin-config.js +189 -123
  27. package/dataflow/environments/environment.d.ts +7 -1
  28. package/dataflow/environments/environment.js +19 -1
  29. package/dataflow/environments/identifier.d.ts +11 -0
  30. package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
  31. package/dataflow/eval/resolve/alias-tracking.js +66 -37
  32. package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
  33. package/dataflow/eval/resolve/resolve-argument.js +23 -11
  34. package/dataflow/eval/resolve/resolve.d.ts +5 -0
  35. package/dataflow/eval/resolve/resolve.js +25 -3
  36. package/dataflow/eval/values/r-value.d.ts +4 -2
  37. package/dataflow/eval/values/r-value.js +3 -1
  38. package/dataflow/eval/values/string/string-constants.d.ts +7 -1
  39. package/dataflow/eval/values/string/string-constants.js +38 -36
  40. package/dataflow/extractor.js +105 -2
  41. package/dataflow/fn/argument-roles.js +22 -8
  42. package/dataflow/fn/function-semantics.d.ts +3 -2
  43. package/dataflow/fn/strict-function.js +13 -2
  44. package/dataflow/graph/df-helper.d.ts +14 -1
  45. package/dataflow/graph/df-helper.js +37 -4
  46. package/dataflow/graph/graph.d.ts +6 -0
  47. package/dataflow/graph/graph.js +6 -0
  48. package/dataflow/internal/linker.d.ts +4 -1
  49. package/dataflow/internal/linker.js +11 -7
  50. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
  52. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -44
  53. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
  54. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
  55. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
  56. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
  58. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
  59. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
  61. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
  62. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
  63. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  64. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +8 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +3 -0
  66. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
  67. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
  69. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  70. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
  71. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
  72. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
  73. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +42 -0
  74. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
  75. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
  76. package/dataflow/internal/process/functions/call/common.js +3 -4
  77. package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
  78. package/dataflow/internal/process/functions/call/deferred.js +17 -9
  79. package/dataflow/internal/process/functions/call/quoted.js +1 -1
  80. package/documentation/doc-capabilities.js +3 -2
  81. package/documentation/doc-readme.js +1 -2
  82. package/documentation/doc-util/doc-dfg.js +2 -2
  83. package/documentation/doc-util/doc-query.d.ts +3 -1
  84. package/documentation/doc-util/doc-query.js +4 -4
  85. package/documentation/wiki-create-linting-rules.js +1 -1
  86. package/documentation/wiki-linter.js +16 -206
  87. package/documentation/wiki-linting-and-testing.js +31 -64
  88. package/documentation/wiki-query.js +41 -0
  89. package/index.d.ts +1 -0
  90. package/index.js +5 -1
  91. package/linter/linter-format.d.ts +6 -0
  92. package/linter/linter-format.js +10 -0
  93. package/linter/linter-rules.d.ts +155 -103
  94. package/linter/linter-rules.js +2 -0
  95. package/linter/linter-util.d.ts +23 -0
  96. package/linter/linter-util.js +58 -0
  97. package/linter/rules/absolute-path.d.ts +2 -2
  98. package/linter/rules/absolute-path.js +1 -4
  99. package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
  100. package/linter/rules/cmd-check/bogus-return.js +3 -7
  101. package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
  102. package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
  103. package/linter/rules/cmd-check/class-string-comparison.js +3 -7
  104. package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
  105. package/linter/rules/cmd-check/cmd-check-util.js +14 -26
  106. package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
  107. package/linter/rules/cmd-check/compiled-code.js +3 -13
  108. package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
  109. package/linter/rules/cmd-check/dependency-declaration.js +6 -7
  110. package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
  111. package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
  112. package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
  113. package/linter/rules/cmd-check/file-checks.d.ts +19 -6
  114. package/linter/rules/cmd-check/file-checks.js +13 -5
  115. package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
  116. package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
  117. package/linter/rules/cmd-check/global-environment-modification.js +3 -2
  118. package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
  119. package/linter/rules/cmd-check/namespace-tampering.js +9 -9
  120. package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
  121. package/linter/rules/cmd-check/package-data.d.ts +11 -5
  122. package/linter/rules/cmd-check/package-data.js +5 -12
  123. package/linter/rules/cmd-check/package-files.js +4 -10
  124. package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
  125. package/linter/rules/cmd-check/package-hooks.js +10 -8
  126. package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
  127. package/linter/rules/cmd-check/package-metafiles.js +3 -12
  128. package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
  129. package/linter/rules/cmd-check/package-runtime.js +64 -20
  130. package/linter/rules/cmd-check/package-structure.d.ts +11 -5
  131. package/linter/rules/cmd-check/package-structure.js +4 -12
  132. package/linter/rules/cmd-check/rd-files.d.ts +8 -3
  133. package/linter/rules/cmd-check/rd-files.js +4 -14
  134. package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
  135. package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
  136. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
  137. package/linter/rules/dataframe-access-validation.d.ts +2 -2
  138. package/linter/rules/dataframe-access-validation.js +5 -8
  139. package/linter/rules/dead-code.d.ts +5 -4
  140. package/linter/rules/dead-code.js +25 -14
  141. package/linter/rules/deprecated-functions.d.ts +3 -3
  142. package/linter/rules/deprecated-functions.js +16 -23
  143. package/linter/rules/file-path-validity.d.ts +2 -2
  144. package/linter/rules/file-path-validity.js +3 -6
  145. package/linter/rules/function-finder-util.d.ts +3 -3
  146. package/linter/rules/function-finder-util.js +7 -14
  147. package/linter/rules/namespace-access.d.ts +2 -2
  148. package/linter/rules/namespace-access.js +6 -9
  149. package/linter/rules/naming-convention.d.ts +2 -2
  150. package/linter/rules/naming-convention.js +1 -4
  151. package/linter/rules/network-functions.d.ts +3 -3
  152. package/linter/rules/no-leaked-credentials.d.ts +2 -2
  153. package/linter/rules/no-leaked-credentials.js +1 -4
  154. package/linter/rules/overwritten-file.d.ts +38 -0
  155. package/linter/rules/overwritten-file.js +102 -0
  156. package/linter/rules/problematic-inputs.d.ts +16 -6
  157. package/linter/rules/problematic-inputs.js +78 -34
  158. package/linter/rules/roxygen-arguments.d.ts +2 -2
  159. package/linter/rules/roxygen-arguments.js +1 -4
  160. package/linter/rules/seeded-randomness.d.ts +3 -3
  161. package/linter/rules/seeded-randomness.js +6 -23
  162. package/linter/rules/software-has-license.d.ts +2 -2
  163. package/linter/rules/software-has-license.js +1 -4
  164. package/linter/rules/software-has-tests.d.ts +2 -2
  165. package/linter/rules/software-has-tests.js +1 -4
  166. package/linter/rules/stop-with-call-arg.d.ts +2 -2
  167. package/linter/rules/stop-with-call-arg.js +4 -11
  168. package/linter/rules/syntactically-valid.d.ts +4 -2
  169. package/linter/rules/syntactically-valid.js +29 -10
  170. package/linter/rules/unclosed-connection.d.ts +2 -2
  171. package/linter/rules/unclosed-connection.js +1 -4
  172. package/linter/rules/undefined-symbol.d.ts +2 -2
  173. package/linter/rules/undefined-symbol.js +25 -22
  174. package/linter/rules/unescaped-arguments.d.ts +2 -2
  175. package/linter/rules/unescaped-arguments.js +1 -4
  176. package/linter/rules/unused-definition.d.ts +2 -2
  177. package/linter/rules/unused-definition.js +37 -25
  178. package/linter/rules/unused-import.d.ts +2 -2
  179. package/linter/rules/unused-import.js +9 -14
  180. package/linter/rules/useless-loop.d.ts +7 -6
  181. package/linter/rules/useless-loop.js +4 -8
  182. package/package.json +5 -3
  183. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  184. package/project/cache/flowr-analyzer-cache.js +15 -11
  185. package/project/context/flowr-analyzer-files-context.d.ts +3 -0
  186. package/project/context/flowr-analyzer-files-context.js +6 -0
  187. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
  188. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
  189. package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
  190. package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
  191. package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
  192. package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
  193. package/project/plugins/file-plugins/files/r-session.js +58 -0
  194. package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
  195. package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
  196. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
  197. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
  198. package/project/plugins/plugin-registry.d.ts +2 -1
  199. package/project/plugins/plugin-registry.js +2 -0
  200. package/project/sigdb/spec-query.d.ts +73 -0
  201. package/project/sigdb/spec-query.js +339 -0
  202. package/queries/base-query-format.d.ts +1 -1
  203. package/queries/base-query-format.js +2 -2
  204. package/queries/catalog/absint-query/absint-query-executor.js +3 -6
  205. package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
  206. package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
  207. package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
  208. package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
  209. package/queries/catalog/config-query/config-query-format.d.ts +0 -1
  210. package/queries/catalog/config-query/config-query-format.js +1 -2
  211. package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
  212. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
  213. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
  214. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
  215. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
  216. package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
  217. package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
  218. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
  219. package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
  220. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
  221. package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
  222. package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
  223. package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
  224. package/queries/catalog/dice-query/dice-query-executor.js +2 -3
  225. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
  226. package/queries/catalog/files-query/files-query-executor.js +2 -3
  227. package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
  228. package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
  229. package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
  230. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
  231. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
  232. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
  233. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
  234. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
  235. package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
  236. package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
  237. package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
  238. package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
  239. package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
  240. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
  241. package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
  242. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
  243. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
  244. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
  245. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
  246. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
  247. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
  248. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
  249. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
  250. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
  251. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
  252. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
  253. package/queries/catalog/linter-query/linter-query-executor.js +2 -3
  254. package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
  255. package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
  256. package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
  257. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
  258. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
  259. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
  260. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
  261. package/queries/catalog/origin-query/origin-query-executor.js +3 -11
  262. package/queries/catalog/project-query/project-query-executor.js +23 -7
  263. package/queries/catalog/project-query/project-query-format.d.ts +5 -0
  264. package/queries/catalog/project-query/project-query-format.js +20 -2
  265. package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
  266. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
  267. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
  268. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
  269. package/queries/catalog/search-query/search-query-executor.js +2 -3
  270. package/queries/catalog/signature-query/signature-query-executor.js +39 -0
  271. package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
  272. package/queries/catalog/signature-query/signature-query-format.js +15 -1
  273. package/queries/catalog/signature-query/signature-query-render.js +2 -1
  274. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
  275. package/queries/query-function-property.d.ts +28 -0
  276. package/queries/query-function-property.js +48 -0
  277. package/queries/query-meta.d.ts +3 -0
  278. package/queries/query-meta.js +8 -0
  279. package/queries/query.d.ts +13 -18
  280. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
  281. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
  282. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  283. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
  284. package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
  285. package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
  286. package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
  287. package/r-bridge/lang-4.x/ast/model/type.js +3 -0
  288. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
  289. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
  290. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
  291. package/reconstruct/reconstruct.js +35 -1
  292. package/search/search-executor/search-generators.js +1 -1
  293. package/slicing/static/fingerprint.js +7 -3
  294. package/slicing/static/static-slicer.js +6 -0
  295. package/util/assert.js +2 -2
  296. package/util/collections/arrays.d.ts +4 -0
  297. package/util/collections/arrays.js +11 -0
  298. package/util/collections/defaultmap.d.ts +5 -1
  299. package/util/collections/defaultmap.js +6 -1
  300. package/util/files.js +26 -5
  301. package/util/flowr-version.d.ts +10 -0
  302. package/util/flowr-version.js +20 -0
  303. package/util/glob.js +6 -4
  304. package/util/r-regex.d.ts +6 -0
  305. package/util/r-regex.js +17 -0
  306. package/util/text/args.d.ts +5 -0
  307. package/util/text/args.js +28 -22
  308. package/util/text/name-rank.d.ts +2 -0
  309. package/util/text/name-rank.js +3 -1
  310. package/util/text/regex.d.ts +10 -0
  311. package/util/text/regex.js +29 -0
  312. package/util/version.d.ts +1 -6
  313. package/util/version.js +6 -14
  314. package/documentation/doc-util/doc-functions.d.ts +0 -24
  315. package/documentation/doc-util/doc-functions.js +0 -65
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeDiceQuery = executeDiceQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const static_slicer_1 = require("../../../slicing/static/static-slicer");
5
6
  const slice_query_options_1 = require("../slice-query-options");
6
7
  const log_1 = require("../../../util/log");
@@ -29,9 +30,7 @@ async function executeDiceQuery({ analyzer }, queries) {
29
30
  results[key] = (0, slice_query_options_1.timedSliceEntry)(query, slice, Date.now() - sliceStart, () => (0, slice_query_options_1.reconstructSlice)(ast, df.graph, slice.result, query));
30
31
  }
31
32
  return {
32
- '.meta': {
33
- timing: Date.now() - start
34
- },
33
+ ...(0, query_meta_1.metaSince)(start),
35
34
  results
36
35
  };
37
36
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeDoesCallQuery = executeDoesCallQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const log_1 = require("../../../util/log");
5
6
  const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
6
7
  const identifier_1 = require("../../../dataflow/environments/identifier");
@@ -30,9 +31,7 @@ async function executeDoesCallQuery({ analyzer }, queries) {
30
31
  results[id] = findCallersMatchingConstraints(cg, nodeId, c, query.expandLibraryInternals ? deps : undefined);
31
32
  }
32
33
  return {
33
- '.meta': {
34
- timing: Date.now() - start
35
- },
34
+ ...(0, query_meta_1.metaSince)(start),
36
35
  results
37
36
  };
38
37
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeFileQuery = executeFileQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  /**
5
6
  * Executes the given files queries using the provided analyzer.
6
7
  */
@@ -39,9 +40,7 @@ function executeFileQuery({ analyzer }, queries) {
39
40
  }
40
41
  }
41
42
  return Promise.resolve({
42
- '.meta': {
43
- timing: Date.now() - start
44
- },
43
+ ...(0, query_meta_1.metaSince)(start),
45
44
  files
46
45
  });
47
46
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeFunctionInfoQuery = executeFunctionInfoQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const function_origin_1 = require("./function-origin");
5
6
  const r_base_packages_1 = require("../../../util/r-base-packages");
6
7
  const identifier_1 = require("../../../dataflow/environments/identifier");
@@ -29,7 +30,7 @@ function executeFunctionInfoQuery({ analyzer }, queries) {
29
30
  };
30
31
  });
31
32
  return Promise.resolve({
32
- '.meta': { timing: Date.now() - start },
33
+ ...(0, query_meta_1.metaSince)(start),
33
34
  name: query.name,
34
35
  packages,
35
36
  builtin: (0, function_origin_1.builtinModelsOf)(query.name, analyzer.inspectContext())
@@ -2,7 +2,6 @@ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import Joi from 'joi';
3
3
  import type { ParsedQueryLine } from '../../query';
4
4
  import { type OutputFormatter } from '../../../util/text/ansi';
5
- import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
5
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
7
6
  import type { FlowrConfig } from '../../../config';
8
7
  import { executeFunctionInfoQuery } from './function-info-query-executor';
@@ -43,6 +42,5 @@ export declare const FunctionInfoQueryDefinition: {
43
42
  readonly syntax: "@function-info <name> [<package>...]";
44
43
  readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
45
44
  readonly schema: Joi.ObjectSchema<any>;
46
- readonly flattenInvolvedNodes: () => NodeId[];
47
45
  };
48
46
  export {};
@@ -48,7 +48,6 @@ exports.FunctionInfoQueryDefinition = {
48
48
  type: joi_1.default.string().valid('function-info').required().description('The type of the query.'),
49
49
  name: joi_1.default.string().required().description('The bare function/symbol name to look up.'),
50
50
  packages: joi_1.default.array().items(joi_1.default.string()).optional().description('Restrict the package list to these names; every exporting package is considered when omitted.')
51
- }).description('Reports which packages export a function name, its signature/details in each, and whether flowR itself carries a built-in definition for it.'),
52
- flattenInvolvedNodes: () => []
51
+ }).description('Reports which packages export a function name, its signature/details in each, and whether flowR itself carries a built-in definition for it.')
53
52
  };
54
53
  //# sourceMappingURL=function-info-query-format.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeGuessDepVersionsQuery = executeGuessDepVersionsQuery;
4
4
  const strings_1 = require("../../../util/text/strings");
5
+ const query_meta_1 = require("../../query-meta");
5
6
  const guess_dep_versions_query_format_1 = require("./guess-dep-versions-query-format");
6
7
  const r_version_1 = require("../../../util/r-version");
7
8
  const objects_1 = require("../../../util/objects");
@@ -157,7 +158,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
157
158
  const sources = deps.signatureSources();
158
159
  if (sources.length === 0) {
159
160
  return {
160
- '.meta': { timing: Date.now() - start },
161
+ ...(0, query_meta_1.metaSince)(start),
161
162
  dependencies: [],
162
163
  message: 'No signature database is loaded; version guessing needs the signature database (see the Signature Database wiki).'
163
164
  };
@@ -289,7 +290,7 @@ async function executeGuessDepVersionsQuery({ analyzer }, queries) {
289
290
  .map(a => (0, objects_1.compactRecord)({ versions: Object.fromEntries(a.versions), unverified: a.unverified }))
290
291
  : undefined;
291
292
  return (0, objects_1.compactRecord)({
292
- '.meta': { timing: Date.now() - start },
293
+ ...(0, query_meta_1.metaSince)(start),
293
294
  dependencies,
294
295
  dateCutoff: cutoff ? (0, dependency_version_space_1.isoDay)(cutoff) : undefined,
295
296
  rVersion,
@@ -1,6 +1,5 @@
1
1
  import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
2
  import Joi from 'joi';
3
- import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
3
  import type { ParsedQueryLine } from '../../query';
5
4
  import { type OutputFormatter } from '../../../util/text/ansi';
6
5
  import { type VersionString } from '../../../util/r-version';
@@ -190,6 +189,5 @@ export declare const GuessDepVersionsQueryDefinition: {
190
189
  readonly fromLine: typeof guessDepVersionsLineParser;
191
190
  readonly syntax: "@guess-dep-versions [<pkg> ...] [(clean | <=YYYY.MM.DD)] [--date YYYY.MM.DD] [--max <n>] [--iterations <n>] [--disabled <letters>] [--explode [--oldest] [--limit <n>] [--prefer <pkg>=<ver>]] <code | file://path>";
192
191
  readonly schema: Joi.ObjectSchema<any>;
193
- readonly flattenInvolvedNodes: () => NodeId[];
194
192
  };
195
193
  export {};
@@ -389,7 +389,6 @@ exports.GuessDepVersionsQueryDefinition = {
389
389
  prefer: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string()).optional().description('A version to prefer per dependency when it survives the constraints.'),
390
390
  limit: joi_1.default.number().integer().min(0).optional().description('Cap the number of version combinations considered. Combinations whose versions cannot be loaded together are skipped, so fewer assignments may come out.')
391
391
  }).optional().description('Also explode the guessed space into concrete per-dependency version assignments.')
392
- }).description('Guesses the possible version range of every dependency from declared constraints and signature-database usage.'),
393
- flattenInvolvedNodes: () => []
392
+ }).description('Guesses the possible version range of every dependency from declared constraints and signature-database usage.')
394
393
  };
395
394
  //# sourceMappingURL=guess-dep-versions-query-format.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeHappensBefore = executeHappensBefore;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const happens_before_query_format_1 = require("./happens-before-query-format");
5
6
  const logic_1 = require("../../../util/logic");
6
7
  const log_1 = require("../../../util/log");
@@ -32,9 +33,7 @@ async function executeHappensBefore({ analyzer }, queries) {
32
33
  }
33
34
  }
34
35
  return {
35
- '.meta': {
36
- timing: Date.now() - start
37
- },
36
+ ...(0, query_meta_1.metaSince)(start),
38
37
  results
39
38
  };
40
39
  }
@@ -31,5 +31,4 @@ export declare const HappensBeforeQueryDefinition: {
31
31
  readonly executor: typeof executeHappensBefore;
32
32
  readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
33
33
  readonly schema: Joi.ObjectSchema<any>;
34
- readonly flattenInvolvedNodes: () => never[];
35
34
  };
@@ -41,7 +41,6 @@ exports.HappensBeforeQueryDefinition = {
41
41
  type: joi_1.default.string().valid('happens-before').required().description('The type of the query.'),
42
42
  a: joi_1.default.string().required().description('The first slicing criterion.'),
43
43
  b: joi_1.default.string().required().description('The second slicing criterion.')
44
- }).description('Happens-Before tracks whether a always happens before b.'),
45
- flattenInvolvedNodes: () => []
44
+ }).description('Happens-Before tracks whether a always happens before b.')
46
45
  };
47
46
  //# sourceMappingURL=happens-before-query-format.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeIdMapQuery = executeIdMapQuery;
4
4
  const log_1 = require("../../../util/log");
5
+ const query_meta_1 = require("../../query-meta");
5
6
  /**
6
7
  * Executes the given ID map queries using the provided analyzer.
7
8
  */
@@ -12,9 +13,7 @@ async function executeIdMapQuery({ analyzer }, queries) {
12
13
  const startTime = Date.now();
13
14
  const idMap = (await analyzer.normalize()).idMap;
14
15
  return {
15
- '.meta': {
16
- timing: Date.now() - startTime
17
- },
16
+ ...(0, query_meta_1.metaSince)(startTime),
18
17
  idMap
19
18
  };
20
19
  }
@@ -13,5 +13,4 @@ export declare const IdMapQueryDefinition: {
13
13
  readonly executor: typeof executeIdMapQuery;
14
14
  readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => true;
15
15
  readonly schema: Joi.ObjectSchema<any>;
16
- readonly flattenInvolvedNodes: () => never[];
17
16
  };
@@ -18,7 +18,6 @@ exports.IdMapQueryDefinition = {
18
18
  },
19
19
  schema: joi_1.default.object({
20
20
  type: joi_1.default.string().valid('id-map').required().description('The type of the query.'),
21
- }).description('The id map query retrieves the id map from the normalized AST.'),
22
- flattenInvolvedNodes: () => []
21
+ }).description('The id map query retrieves the id map from the normalized AST.')
23
22
  };
24
23
  //# sourceMappingURL=id-map-query-format.js.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeInputSourcesQuery = executeInputSourcesQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const input_sources_query_format_1 = require("./input-sources-query-format");
5
6
  const log_1 = require("../../../util/log");
6
7
  const parse_1 = require("../../../slicing/criterion/parse");
@@ -38,13 +39,11 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
38
39
  const provenanceNode = nast.idMap.get(criterionId);
39
40
  const fdef = r_function_definition_1.RFunctionDefinition.rootFunctionDefinition(provenanceNode, nast.idMap);
40
41
  const provenance = df_helper_1.Dataflow.provenanceGraph(criterionId, df.graph, fdef ? model_1.RNode.collectAllIds(fdef) : undefined);
41
- results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph, packages);
42
+ results[criterion] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph, packages, df.environment);
42
43
  }
43
44
  }
44
45
  return {
45
- '.meta': {
46
- timing: Date.now() - start
47
- },
46
+ ...(0, query_meta_1.metaSince)(start),
48
47
  results
49
48
  };
50
49
  }
@@ -4,6 +4,7 @@ export { InputTraceType, InputType } from './input-types';
4
4
  import type { DataflowGraph } from '../../../dataflow/graph/graph';
5
5
  import type { MergeableRecord } from '../../../util/objects';
6
6
  import { Identifier } from '../../../dataflow/environments/identifier';
7
+ import type { REnvironmentInformation } from '../../../dataflow/environments/environment';
7
8
  import type { FlowrSearchLike } from '../../../search/flowr-search-builder';
8
9
  /**
9
10
  * An object that a framework hands to its users without any visible definition, like the `input` of a
@@ -134,4 +135,4 @@ export interface InputClassifierConfig<Functions extends InputClassifierFunction
134
135
  * For the scope escape analysis, pass on the full, non-reduced DFG as `fullDfg`, and the packages attached in the
135
136
  * program as `packages` so that bare calls only match the entries of packages that are actually in scope.
136
137
  */
137
- export declare function classifyInput(id: NodeId, dfg: DataflowGraph, config: InputClassifierConfig<InputClassifierFunctionIdentifiers>, fullDfg?: DataflowGraph, packages?: ReadonlySet<string>): InputSources;
138
+ export declare function classifyInput(id: NodeId, dfg: DataflowGraph, config: InputClassifierConfig<InputClassifierFunctionIdentifiers>, fullDfg?: DataflowGraph, packages?: ReadonlySet<string>, environment?: REnvironmentInformation): InputSources;
@@ -18,6 +18,8 @@ const r_comment_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-commen
18
18
  const assert_1 = require("../../../util/assert");
19
19
  const arrays_1 = require("../../../util/collections/arrays");
20
20
  const built_in_proc_name_1 = require("../../../dataflow/environments/built-in-proc-name");
21
+ const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
22
+ const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
21
23
  const record_1 = require("../../../util/record");
22
24
  const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
23
25
  const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
@@ -80,18 +82,23 @@ class InputClassifier {
80
82
  config;
81
83
  fullDfg;
82
84
  packages;
85
+ environment;
83
86
  cache = new Map();
84
87
  fullClassifier;
85
88
  unsanitized;
86
89
  declarationIndex;
87
90
  entryPointIndex;
88
91
  rebinding;
89
- /** `packages` are the packages attached in the analyzed program, `undefined` if that is not known (then everything may match) */
90
- constructor(dfg, config, fullDfg, packages) {
92
+ /**
93
+ * `packages` are the packages attached in the analyzed program, `undefined` if that is not known (then everything may match).
94
+ * `environment` is the environment of the program, used to look up the signatures of built-ins.
95
+ */
96
+ constructor(dfg, config, fullDfg, packages, environment) {
91
97
  this.dfg = dfg;
92
98
  this.config = config;
93
99
  this.fullDfg = fullDfg;
94
100
  this.packages = packages;
101
+ this.environment = environment;
95
102
  }
96
103
  get whole() {
97
104
  return this.fullDfg ?? this.dfg;
@@ -125,12 +132,22 @@ class InputClassifier {
125
132
  const written = r_string_1.RString.is(parent) ? (0, objects_1.compactRecord)({ ...sourceOf(ref, input_types_1.InputType.Constant), value: parent.content.str }) : this.classifyAt(parent.info.id);
126
133
  return written && { ...written, id: ref };
127
134
  }
128
- else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Apply) && vertex_1.DfgVertex.isFunctionCall(vtx) && df_helper_1.Dataflow.targetsOf(this.dfg, ref, edge_1.EdgeType.Reads).every(t => node_id_1.NodeId.isBuiltIn(t) || !this.functionDefinitionsAt(t).next().done)) {
129
- /* a name of a function the code defines or flowR knows */
130
- return sourceOf(ref, input_types_1.InputType.Constant);
135
+ else if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Apply) && vertex_1.DfgVertex.isFunctionCall(vtx)) {
136
+ /* `f` in `do.call(f, args)` or `lapply(x, f)`: a constant if it names a known function */
137
+ return df_helper_1.Dataflow.callsOnlyKnownFunctions(vtx.id, this.whole, this.environment) ? sourceOf(ref, input_types_1.InputType.Constant) : this.classifyHeldFunction(vtx) ?? this.classifyAt(ref);
131
138
  }
132
139
  return this.classifyAt(ref);
133
140
  }
141
+ /** classifies the function a call goes through: for `add2 <- adder(2); add2(5)` the value of `add2`; `undefined` if the call reads no variable */
142
+ classifyHeldFunction(call) {
143
+ const held = (df_helper_1.Dataflow.origin(this.dfg, call.id) ?? []).filter(o => o.type === 0 /* OriginType.ReadVariableOrigin */ || o.type === 1 /* OriginType.WriteVariableOrigin */);
144
+ if (held.length === 0) {
145
+ return undefined;
146
+ }
147
+ const acc = new ClassificationAccumulator();
148
+ held.forEach(o => acc.merge(this.classifyAt(o.id)));
149
+ return acc.build(call.id);
150
+ }
134
151
  /**
135
152
  * Returns the specification of the {@link LinkedInputObject|linked input object} the given id refers to
136
153
  * (e.g., shiny's `input`), or `undefined` if it refers to something else.
@@ -253,7 +270,7 @@ class InputClassifier {
253
270
  if (this.fullDfg === undefined || this.fullDfg === this.dfg) {
254
271
  return undefined;
255
272
  }
256
- this.fullClassifier ??= new InputClassifier(this.fullDfg, this.config, undefined, this.packages);
273
+ this.fullClassifier ??= new InputClassifier(this.fullDfg, this.config, undefined, this.packages, this.environment);
257
274
  return this.fullClassifier.classifyAt(id);
258
275
  }
259
276
  extractConstantValue(id) {
@@ -290,8 +307,9 @@ class InputClassifier {
290
307
  return this.classifyVariableDefinition(vertex);
291
308
  case vertex_1.VertexType.Use:
292
309
  return this.classifyVariable(vertex);
293
- default:
294
- return this.classifyCdsAndReturn(vertex, sourceOf(vertex.id, input_types_1.InputType.Unknown));
310
+ /* a function definition is a constant: its code is fixed, whatever it computes when called */
311
+ case vertex_1.VertexType.FunctionDefinition:
312
+ return this.classifyCdsAndReturn(vertex, sourceOf(vertex.id, input_types_1.InputType.Constant));
295
313
  }
296
314
  }
297
315
  /**
@@ -378,7 +396,24 @@ class InputClassifier {
378
396
  // a statically resolved `get("x")` yields the value of the retrieved variable, read via its first argument
379
397
  return { via: call.args[0], renamed: true };
380
398
  }
381
- return undefined;
399
+ return { via: this.aliasArgument(call), renamed: false };
400
+ }
401
+ /** the calls an apply makes: in `do.call(f, list(x))` the argument `f` gets a call vertex for `f(x)`, although the code has no call there */
402
+ appliedCalls(call) {
403
+ return [...this.whole.edgesFrom(call.id)]
404
+ .filter(([t, e]) => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Argument) && vertex_1.DfgVertex.isFunctionCall(this.whole.getVertex(t)) && !r_function_call_1.RFunctionCall.is(this.whole.idMap?.get(t)))
405
+ .map(([t]) => t);
406
+ }
407
+ /** the argument a built-in hands back unchanged, as its signature marks it {@link ArgProp.Alias} (like `(` or `identity`) */
408
+ aliasArgument(call) {
409
+ const sig = call.onlyBuiltin && this.environment !== undefined ? (0, query_fn_props_1.queryFnProps)(call.name, { environment: this.environment })?.sig : undefined;
410
+ const layout = sig === undefined ? undefined : built_in_props_1.FnSig.layout(sig);
411
+ if (layout === undefined || layout.alias < 0) {
412
+ return undefined;
413
+ }
414
+ const slots = built_in_props_1.FnSig.slots(layout, call.args.map(a => graph_1.FunctionArgument.isEmpty(a) ? undefined : graph_1.FunctionArgument.getName(a)));
415
+ /* on `...` it is the last argument that is handed back */
416
+ return layout.alias === layout.rest ? call.args.findLast((_, i) => slots[i] === layout.rest) : call.args.find((_, i) => slots[i] === layout.alias);
382
417
  }
383
418
  /** an `if` or `switch` yields one of its branches (`NULL` without a matching one), its condition only picks which */
384
419
  classifyBranches(call) {
@@ -429,6 +464,13 @@ class InputClassifier {
429
464
  if (passed) {
430
465
  return this.classifyCdsAndReturn(call, handed?.renamed ? { ...passed, id: call.id } : passed);
431
466
  }
467
+ /* `do.call(f, list(x))` returns what `f(x)` returns, and the same holds for `lapply` and the other applies */
468
+ const applied = vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Apply) ? this.appliedCalls(call) : [];
469
+ if (applied.length > 0) {
470
+ const acc = new ClassificationAccumulator();
471
+ applied.forEach(a => acc.merge(this.classifyAt(a)));
472
+ return this.classifyCdsAndReturn(call, acc.build(call.id));
473
+ }
432
474
  if (this.matches(call, this.config.sanitizers)) {
433
475
  const acc = new ClassificationAccumulator();
434
476
  acc.push(input_types_1.InputType.DerivedConstant);
@@ -490,7 +532,7 @@ class InputClassifier {
490
532
  const interpolated = this.templateReads(call);
491
533
  /* cutting into what a sanitizer escaped undoes the escape */
492
534
  const edits = this.matches(call, this.config.editing);
493
- const of = edits && this.config.sanitizers !== undefined ? this.unsanitized ??= new InputClassifier(this.dfg, { ...this.config, sanitizers: undefined }, this.fullDfg, this.packages) : this;
535
+ const of = edits && this.config.sanitizers !== undefined ? this.unsanitized ??= new InputClassifier(this.dfg, { ...this.config, sanitizers: undefined }, this.fullDfg, this.packages, this.environment) : this;
494
536
  for (const ref of (0, arrays_1.uniqueArray)([...call.args.filter(graph_1.FunctionArgument.isNotEmpty).map(graph_1.FunctionArgument.getReference), ...interpolated])) {
495
537
  /* a function handed in (`sapply(x, function(i) runif(1))`) contributes what it returns */
496
538
  const vtx = ref === undefined ? undefined : this.whole.getVertex(ref);
@@ -584,7 +626,8 @@ class InputClassifier {
584
626
  /** classifies what a call of a variable (e.g. a shiny reactive `n()`) yields, by what that variable holds */
585
627
  classifyCallee(call) {
586
628
  for (const o of df_helper_1.Dataflow.origin(this.dfg, call.id) ?? []) {
587
- if (o.type !== 0 /* OriginType.ReadVariableOrigin */ && o.type !== 1 /* OriginType.WriteVariableOrigin */) {
629
+ /* the result of calling a function the code defines is classified by what the function returns, see classifyDefinitionResult */
630
+ if ((o.type !== 0 /* OriginType.ReadVariableOrigin */ && o.type !== 1 /* OriginType.WriteVariableOrigin */) || !this.functionDefinitionsAt(o.id).next().done) {
588
631
  continue;
589
632
  }
590
633
  const classified = this.classifyAt(o.id) ?? this.classifyInFullGraph(o.id);
@@ -620,6 +663,10 @@ class InputClassifier {
620
663
  else if (o.type === 0 /* OriginType.ReadVariableOrigin */ || o.type === 1 /* OriginType.WriteVariableOrigin */) {
621
664
  this.classifyVariableOrigin(o.id, acc);
622
665
  }
666
+ else if (o.type === 3 /* OriginType.BuiltInFunctionOrigin */ && o.id === vtx.id) {
667
+ /* a built-in used as a value, like `sum` in `identity(sum)`, is a fixed function and so a constant */
668
+ acc.push(input_types_1.InputType.Constant);
669
+ }
623
670
  else if (o.type === 2 /* OriginType.FunctionCallOrigin */ || o.type === 3 /* OriginType.BuiltInFunctionOrigin */) {
624
671
  acc.merge(this.classifyAt(o.id));
625
672
  }
@@ -821,9 +868,9 @@ function callMeans(called, id, packages) {
821
868
  * For the scope escape analysis, pass on the full, non-reduced DFG as `fullDfg`, and the packages attached in the
822
869
  * program as `packages` so that bare calls only match the entries of packages that are actually in scope.
823
870
  */
824
- function classifyInput(id, dfg, config, fullDfg, packages) {
871
+ function classifyInput(id, dfg, config, fullDfg, packages, environment) {
825
872
  const vtx = dfg.getVertex(id);
826
- const c = new InputClassifier(dfg, config, fullDfg, packages);
873
+ const c = new InputClassifier(dfg, config, fullDfg, packages, environment);
827
874
  if (!vertex_1.DfgVertex.isFunctionCall(vtx)) {
828
875
  return vtx ? [c.classifyEntry(vtx)] : [];
829
876
  }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeExceptionQuery = executeExceptionQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const query_function_filter_1 = require("../../query-function-filter");
5
6
  const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
6
7
  /**
@@ -22,9 +23,7 @@ async function executeExceptionQuery({ analyzer }, queries) {
22
23
  }
23
24
  }
24
25
  return {
25
- '.meta': {
26
- timing: Date.now() - start
27
- },
26
+ ...(0, query_meta_1.metaSince)(start),
28
27
  /* collecting walks whatever the call graph holds, reporting stays with the definitions someone wrote */
29
28
  exceptions: Object.fromEntries(Object.entries(result).filter(([id]) => query_function_filter_1.QueryFunctionFilter.written(id)))
30
29
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeFnPropsQuery = executeFnPropsQuery;
4
+ const query_meta_1 = require("../../query-meta");
4
5
  const query_function_filter_1 = require("../../query-function-filter");
5
6
  const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
6
7
  const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
@@ -49,9 +50,7 @@ async function executeFnPropsQuery({ analyzer }, queries) {
49
50
  const graph = (await analyzer.dataflow()).graph;
50
51
  const inferred = function_semantics_1.FunctionSemantics.props(query_function_filter_1.QueryFunctionFilter.definitions(graph, filterFor), graph, { ctx, maxDepth, only });
51
52
  return {
52
- '.meta': {
53
- timing: Date.now() - start
54
- },
53
+ ...(0, query_meta_1.metaSince)(start),
55
54
  roles: keepRoles(inferred.roles, graph, formals && new Set(formals), props ? function_semantics_1.FunctionSemantics.call.argument.mask(props) : AllProps),
56
55
  props: keepProps(inferred.props, props ? function_semantics_1.FunctionSemantics.call.props.mask(props) : undefined)
57
56
  };
@@ -14,6 +14,7 @@ const range_1 = require("../../../util/range");
14
14
  const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
15
15
  const objects_1 = require("../../../util/objects");
16
16
  const argument_roles_1 = require("../../../dataflow/fn/argument-roles");
17
+ const query_function_property_1 = require("../../query-function-property");
17
18
  const arrays_1 = require("../../../util/collections/arrays");
18
19
  /** refuses a query that can only answer with nothing: `formals` narrowing an answer that carries none, or `props` naming only properties the single half it asks for cannot state */
19
20
  function rejectEmptyAnswer(query, helpers) {
@@ -51,7 +52,7 @@ exports.InspectFnPropsQueryDefinition = {
51
52
  syntax: '@inspect-fn-props [(<crit>;...)] <code | file://path>',
52
53
  schema: joi_1.default.object({
53
54
  type: joi_1.default.string().valid('inspect-fn-props').required().description('The type of the query.'),
54
- filter: joi_1.default.array().items(joi_1.default.string().required()).optional().description('If given, only function definitions that match one of the given slicing criteria are considered. Each criterion can be either `line:column`, `line@variable-name`, or `$id`, where the latter directly specifies the node id of the function definition to be considered.'),
55
+ filter: query_function_property_1.FunctionFilterSchema,
55
56
  maxDepth: joi_1.default.number().integer().min(1).optional().description(`How far a value is followed back through names and calls when deciding what a formal stands for (default ${argument_roles_1.DefaultDepth}).`),
56
57
  only: joi_1.default.string().valid('arguments', 'function').optional().description('Infer only what the formals do, or only what the function itself does; both are inferred when this is left out.'),
57
58
  formals: joi_1.default.array().items(joi_1.default.string()).min(1).optional().description('Keep only the formals written as one of these names.'),
@@ -1,6 +1,7 @@
1
- import type { InspectHigherOrderQuery, InspectHigherOrderQueryResult } from './inspect-higher-order-query-format';
1
+ import type { InspectHigherOrderQuery } from './inspect-higher-order-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
4
  /**
4
5
  * Execute higher-order function inspection queries on the given analyzer.
5
6
  */
6
- export declare function executeHigherOrderQuery({ analyzer }: BasicQueryData, queries: readonly InspectHigherOrderQuery[]): Promise<InspectHigherOrderQueryResult>;
7
+ export declare function executeHigherOrderQuery({ analyzer }: BasicQueryData, queries: readonly InspectHigherOrderQuery[]): Promise<Record<NodeId, boolean>>;
@@ -8,7 +8,6 @@ const function_semantics_1 = require("../../../dataflow/fn/function-semantics");
8
8
  * Execute higher-order function inspection queries on the given analyzer.
9
9
  */
10
10
  async function executeHigherOrderQuery({ analyzer }, queries) {
11
- const start = Date.now();
12
11
  const filterFor = await query_function_filter_1.QueryFunctionFilter.criteria(queries, analyzer);
13
12
  const graph = (await analyzer.dataflow()).graph;
14
13
  const fns = query_function_filter_1.QueryFunctionFilter.definitions(graph, filterFor);
@@ -21,11 +20,6 @@ async function executeHigherOrderQuery({ analyzer }, queries) {
21
20
  for (const id of fns) {
22
21
  result[id] = function_semantics_1.FunctionSemantics.isHigherOrder(id, graph, { ctx: analyzer.inspectContext(), invertedGraph, argumentFacts });
23
22
  }
24
- return {
25
- '.meta': {
26
- timing: Date.now() - start
27
- },
28
- higherOrder: result
29
- };
23
+ return result;
30
24
  }
31
25
  //# sourceMappingURL=inspect-higher-order-query-executor.js.map
@@ -1,9 +1,6 @@
1
- import { type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
2
- import Joi from 'joi';
3
- import { executeHigherOrderQuery } from './inspect-higher-order-query-executor';
4
- import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
1
+ import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
3
  import type { SlicingCriterion } from '../../../slicing/criterion/parse';
6
- import { criteriaQueryCompleter } from '../../../cli/repl/parser/slice-query-parser';
7
4
  /**
8
5
  * Either returns all function definitions alongside whether they are higher-order functions,
9
6
  * or just those matching the filters.
@@ -16,12 +13,12 @@ export interface InspectHigherOrderQueryResult extends BaseQueryResult {
16
13
  readonly higherOrder: Record<NodeId, boolean>;
17
14
  }
18
15
  export declare const InspectHigherOrderQueryDefinition: {
19
- readonly title: "Inspect Higher-Order Functions Query";
20
- readonly executor: typeof executeHigherOrderQuery;
16
+ readonly title: string;
17
+ readonly executor: (data: import("../../base-query-format").BasicQueryData, queries: readonly InspectHigherOrderQuery[]) => Promise<BaseQueryResult & Record<"higherOrder", Record<NodeId, boolean>>>;
21
18
  readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, processed: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, result: string[]) => Promise<boolean>;
19
+ readonly completer: typeof import("../../../cli/repl/parser/slice-query-parser").criteriaQueryCompleter;
22
20
  readonly fromLine: (_output: import("../../../cli/repl/commands/repl-main").ReplOutput, line: readonly string[], _config: import("../../..").FlowrConfig) => import("../../query").ParsedQueryLine<"inspect-higher-order">;
23
- readonly completer: typeof criteriaQueryCompleter;
24
21
  readonly syntax: "@inspect-higher-order [(<crit>;...)] <code | file://path>";
25
- readonly schema: Joi.ObjectSchema<any>;
22
+ readonly schema: import("joi").ObjectSchema<any>;
26
23
  readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
27
24
  };
@@ -1,39 +1,14 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.InspectHigherOrderQueryDefinition = void 0;
7
- const base_query_format_1 = require("../../base-query-format");
8
- const ansi_1 = require("../../../util/text/ansi");
9
- const joi_1 = __importDefault(require("joi"));
10
4
  const inspect_higher_order_query_executor_1 = require("./inspect-higher-order-query-executor");
11
- const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
12
- const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
13
- const range_1 = require("../../../util/range");
14
- exports.InspectHigherOrderQueryDefinition = {
5
+ const query_function_property_1 = require("../../query-function-property");
6
+ exports.InspectHigherOrderQueryDefinition = (0, query_function_property_1.functionPropertyQuery)({
7
+ type: 'inspect-higher-order',
15
8
  title: 'Inspect Higher-Order Functions Query',
16
- executor: inspect_higher_order_query_executor_1.executeHigherOrderQuery,
17
- asciiSummarizer: async (formatter, processed, queryResults, result) => {
18
- const out = queryResults;
19
- result.push(`Query: ${(0, ansi_1.bold)('inspect-higher-order', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
20
- for (const [r, v] of Object.entries(out.higherOrder)) {
21
- const node = (await processed.normalize()).idMap.get(node_id_1.NodeId.normalize(r));
22
- const loc = node ? range_1.SourceLocation.fromNode(node) : undefined;
23
- result.push(` - Function ${(0, ansi_1.bold)(r, formatter)} (${range_1.SourceLocation.format(loc)}) is ${v ? '' : 'not '}a higher-order function`);
24
- }
25
- return true;
26
- },
27
- fromLine: (0, base_query_format_1.filterLineParser)('inspect-higher-order'),
28
- completer: slice_query_parser_1.criteriaQueryCompleter,
29
- syntax: '@inspect-higher-order [(<crit>;...)] <code | file://path>',
30
- schema: joi_1.default.object({
31
- type: joi_1.default.string().valid('inspect-higher-order').required().description('The type of the query.'),
32
- filter: joi_1.default.array().items(joi_1.default.string().required()).optional().description('If given, only function definitions that match one of the given slicing criteria are considered. Each criterion can be either `line:column`, `line@variable-name`, or `$id`, where the latter directly specifies the node id of the function definition to be considered.')
33
- }).description('Either returns all function definitions alongside whether they are higher-order functions, or just those matching the filters.'),
34
- flattenInvolvedNodes: (queryResults) => {
35
- const out = queryResults;
36
- return Object.keys(out.higherOrder).filter(id => out.higherOrder[id]);
37
- }
38
- };
9
+ noun: 'higher-order functions',
10
+ resultKey: 'higherOrder',
11
+ phrase: 'a higher-order function',
12
+ compute: inspect_higher_order_query_executor_1.executeHigherOrderQuery
13
+ });
39
14
  //# sourceMappingURL=inspect-higher-order-query-format.js.map
@@ -1,6 +1,7 @@
1
- import type { InspectRecursionQuery, InspectRecursionQueryResult } from './inspect-recursion-query-format';
1
+ import type { InspectRecursionQuery } from './inspect-recursion-query-format';
2
2
  import type { BasicQueryData } from '../../base-query-format';
3
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
4
  /**
4
5
  * Execute recursion function inspection queries on the given analyzer.
5
6
  */
6
- export declare function executeRecursionQuery({ analyzer }: BasicQueryData, queries: readonly InspectRecursionQuery[]): Promise<InspectRecursionQueryResult>;
7
+ export declare function executeRecursionQuery({ analyzer }: BasicQueryData, queries: readonly InspectRecursionQuery[]): Promise<Record<NodeId, boolean>>;