@eagleoutice/flowr 2.17.5 → 2.17.6

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 (357) hide show
  1. package/README.md +13 -51
  2. package/abstract-interpretation/absint-inference.d.ts +4 -4
  3. package/abstract-interpretation/absint-inference.js +11 -11
  4. package/abstract-interpretation/abstract-semantics.d.ts +2 -1
  5. package/abstract-interpretation/branch-paths-interpreter.d.ts +1 -0
  6. package/abstract-interpretation/branch-paths-interpreter.js +60 -0
  7. package/abstract-interpretation/branch-paths.d.ts +60 -0
  8. package/abstract-interpretation/branch-paths.js +120 -0
  9. package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +6 -1
  10. package/abstract-interpretation/data-frame/dataframe-semantics.js +60 -1
  11. package/abstract-interpretation/data-frame/semantics.js +4 -10
  12. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  13. package/cli/repl/core.js +51 -0
  14. package/control-flow/cfg-dead-code.js +12 -7
  15. package/data/packed.d.ts +10 -0
  16. package/data/packed.js +33 -0
  17. package/data/r-base-guards.generated.d.ts +7 -0
  18. package/data/r-base-guards.generated.js +12 -0
  19. package/data/r-datasets.generated.d.ts +4 -0
  20. package/data/r-datasets.generated.js +10 -0
  21. package/data/r-formals.generated.d.ts +4 -0
  22. package/data/r-formals.generated.js +10 -0
  23. package/data/r-group-method-guards.generated.d.ts +3 -0
  24. package/data/r-group-method-guards.generated.js +8 -0
  25. package/dataflow/environments/ambient-effect.d.ts +1000 -0
  26. package/dataflow/environments/ambient-effect.js +234 -0
  27. package/dataflow/environments/ambient-state-name.d.ts +45 -2
  28. package/dataflow/environments/ambient-state-name.js +61 -3
  29. package/dataflow/environments/apply-kill.js +11 -4
  30. package/dataflow/environments/built-in-kinds.d.ts +4 -46
  31. package/dataflow/environments/built-in-kinds.js +6 -2
  32. package/dataflow/environments/built-in-props.d.ts +16 -4
  33. package/dataflow/environments/built-in-props.js +11 -3
  34. package/dataflow/environments/built-in.d.ts +6 -1
  35. package/dataflow/environments/built-in.js +13 -36
  36. package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
  37. package/dataflow/environments/default-builtin-config/base-functions.js +110 -52
  38. package/dataflow/environments/default-builtin-config/base-language.d.ts +1 -1
  39. package/dataflow/environments/default-builtin-config/base-language.js +11 -8
  40. package/dataflow/environments/default-builtin-config/dev-tooling.js +1 -1
  41. package/dataflow/environments/default-builtin-config/file-io.js +6 -4
  42. package/dataflow/environments/default-builtin-config/graphics-devices.d.ts +1 -1
  43. package/dataflow/environments/default-builtin-config/graphics-devices.js +24 -14
  44. package/dataflow/environments/default-builtin-config/guard-builders.d.ts +16 -0
  45. package/dataflow/environments/default-builtin-config/guard-builders.js +29 -0
  46. package/dataflow/environments/default-builtin-config/guards-primitive-lang.d.ts +15 -0
  47. package/dataflow/environments/default-builtin-config/guards-primitive-lang.js +228 -0
  48. package/dataflow/environments/default-builtin-config/guards-primitive-ops.d.ts +11 -0
  49. package/dataflow/environments/default-builtin-config/guards-primitive-ops.js +154 -0
  50. package/dataflow/environments/default-builtin-config/guards.d.ts +9 -0
  51. package/dataflow/environments/default-builtin-config/guards.js +211 -0
  52. package/dataflow/environments/default-builtin-config/index.d.ts +3 -3
  53. package/dataflow/environments/default-builtin-config/index.js +22 -7
  54. package/dataflow/environments/default-builtin-config/media-formats.js +4 -4
  55. package/dataflow/environments/default-builtin-config/package-spatial.js +2 -1
  56. package/dataflow/environments/default-builtin-config/package-tidyverse.js +3 -2
  57. package/dataflow/environments/default-builtin-config/package-utils.d.ts +1 -1
  58. package/dataflow/environments/default-builtin-config/package-utils.js +5 -2
  59. package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
  60. package/dataflow/environments/default-builtin-config/parallel-execution.js +3 -1
  61. package/dataflow/environments/default-builtin-config/r-formals.d.ts +13 -0
  62. package/dataflow/environments/default-builtin-config/r-formals.js +110 -0
  63. package/dataflow/environments/default-builtin-config/shared-configs.d.ts +138 -77
  64. package/dataflow/environments/default-builtin-config/shared-configs.js +52 -88
  65. package/dataflow/environments/default-builtin-config/statistics.d.ts +1 -1
  66. package/dataflow/environments/default-builtin-config/statistics.js +4 -1
  67. package/dataflow/environments/diff.js +5 -2
  68. package/dataflow/environments/environment.d.ts +20 -0
  69. package/dataflow/environments/environment.js +39 -4
  70. package/dataflow/environments/group-generics.d.ts +5 -1
  71. package/dataflow/environments/group-generics.js +13 -3
  72. package/dataflow/environments/guard-facts.d.ts +169 -0
  73. package/dataflow/environments/guard-facts.js +26 -0
  74. package/dataflow/environments/identifier.d.ts +9 -1
  75. package/dataflow/environments/identifier.js +5 -0
  76. package/dataflow/environments/pkg-name.d.ts +1 -0
  77. package/dataflow/environments/query-fn-props.d.ts +3 -5
  78. package/dataflow/environments/query-fn-props.js +44 -21
  79. package/dataflow/environments/removal-marker.d.ts +2 -0
  80. package/dataflow/environments/removal-marker.js +5 -0
  81. package/dataflow/eval/resolve/resolve-strings.d.ts +2 -5
  82. package/dataflow/eval/resolve/resolve-strings.js +2 -2
  83. package/dataflow/extractor.js +24 -15
  84. package/dataflow/fn/condition-handlers.d.ts +2 -0
  85. package/dataflow/fn/condition-handlers.js +3 -1
  86. package/dataflow/fn/frame-reflection.d.ts +4 -2
  87. package/dataflow/fn/frame-reflection.js +16 -0
  88. package/dataflow/fn/function-props.js +15 -22
  89. package/dataflow/fn/function-semantics.d.ts +31 -1
  90. package/dataflow/fn/function-semantics.js +15 -0
  91. package/dataflow/fn/guards/built-in-guards.d.ts +112 -0
  92. package/dataflow/fn/guards/built-in-guards.js +199 -0
  93. package/dataflow/fn/guards/call-contracts.d.ts +97 -0
  94. package/dataflow/fn/guards/call-contracts.js +331 -0
  95. package/dataflow/fn/guards/condition-grouping.d.ts +20 -0
  96. package/dataflow/fn/guards/condition-grouping.js +135 -0
  97. package/dataflow/fn/guards/function-guards.d.ts +112 -0
  98. package/dataflow/fn/guards/function-guards.js +1549 -0
  99. package/dataflow/fn/guards/group-method-guards.d.ts +28 -0
  100. package/dataflow/fn/guards/group-method-guards.js +56 -0
  101. package/dataflow/fn/guards/guard-claims.d.ts +125 -0
  102. package/dataflow/fn/guards/guard-claims.js +678 -0
  103. package/dataflow/fn/guards/guard-knowledge.d.ts +41 -0
  104. package/dataflow/fn/guards/guard-knowledge.js +180 -0
  105. package/dataflow/fn/guards/guard-term-syntax.d.ts +9 -0
  106. package/dataflow/fn/guards/guard-term-syntax.js +210 -0
  107. package/dataflow/fn/guards/guard-term.d.ts +136 -0
  108. package/dataflow/fn/guards/guard-term.js +550 -0
  109. package/dataflow/fn/guards/stated-guards.d.ts +13 -0
  110. package/dataflow/fn/guards/stated-guards.js +35 -0
  111. package/dataflow/fn/higher-order-function.d.ts +2 -0
  112. package/dataflow/fn/higher-order-function.js +1 -0
  113. package/dataflow/fn/strict-function.d.ts +4 -0
  114. package/dataflow/fn/strict-function.js +66 -17
  115. package/dataflow/graph/ambient-access.d.ts +4 -1
  116. package/dataflow/graph/ambient-access.js +8 -2
  117. package/dataflow/graph/closure-frames.js +1 -1
  118. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  119. package/dataflow/graph/dataflowgraph-builder.js +2 -2
  120. package/dataflow/graph/df-helper.d.ts +6 -0
  121. package/dataflow/graph/df-helper.js +15 -0
  122. package/dataflow/graph/graph.d.ts +12 -6
  123. package/dataflow/graph/graph.js +21 -28
  124. package/dataflow/info.d.ts +2 -1
  125. package/dataflow/info.js +3 -1
  126. package/dataflow/internal/dispatch-linking.d.ts +3 -1
  127. package/dataflow/internal/dispatch-linking.js +1 -0
  128. package/dataflow/internal/linker.d.ts +2 -0
  129. package/dataflow/internal/linker.js +115 -6
  130. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -1
  131. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +5 -2
  132. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +2 -1
  133. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +19 -57
  134. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +471 -295
  135. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +13 -1
  136. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -0
  137. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +106 -19
  138. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -1
  139. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +24 -3
  140. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.d.ts +1 -1
  141. package/dataflow/internal/process/functions/call/built-in/built-in-deferred-env-ops.js +33 -11
  142. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +4 -0
  143. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +4 -4
  144. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +23 -7
  145. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  146. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +19 -2
  147. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +347 -46
  148. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  149. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +5 -0
  150. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +110 -16
  151. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +2 -0
  152. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +9 -2
  153. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.d.ts +1 -1
  154. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -2
  155. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -0
  156. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +28 -0
  157. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +16 -6
  158. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +6 -1
  159. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +37 -2
  160. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +4 -0
  161. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -1
  162. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
  163. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +55 -11
  164. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -2
  165. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -10
  166. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -1
  167. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +8 -0
  168. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +64 -7
  169. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +1 -1
  170. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +160 -20
  171. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +5 -3
  172. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +6 -0
  173. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +142 -4
  174. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  175. package/dataflow/internal/process/functions/call/quoted.js +23 -4
  176. package/dataflow/processor.d.ts +2 -0
  177. package/documentation/data/dfg/doc-ambient.d.ts +4 -0
  178. package/documentation/data/dfg/doc-ambient.js +74 -0
  179. package/documentation/wiki-dataflow-graph.js +10 -4
  180. package/documentation/wiki-linter.js +12 -0
  181. package/documentation/wiki-query.js +112 -1
  182. package/linter/linter-rules.d.ts +41 -1
  183. package/linter/linter-rules.js +5 -1
  184. package/linter/rules/call-contracts.d.ts +40 -0
  185. package/linter/rules/call-contracts.js +56 -0
  186. package/linter/rules/cmd-check/bogus-return.js +1 -1
  187. package/linter/rules/cmd-check/call-arguments.js +5 -6
  188. package/linter/rules/cmd-check/cmd-check-util.d.ts +0 -6
  189. package/linter/rules/cmd-check/cmd-check-util.js +0 -28
  190. package/linter/rules/cmd-check/package-hooks.js +2 -1
  191. package/linter/rules/cmd-check/s-three-method-consistency.js +1 -1
  192. package/linter/rules/interactive-functions.d.ts +30 -0
  193. package/linter/rules/interactive-functions.js +87 -0
  194. package/linter/rules/process-state-in-session.js +1 -1
  195. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  196. package/linter/rules/undefined-symbol-util.js +8 -2
  197. package/linter/rules/undefined-symbol.js +18 -7
  198. package/linter/rules/useless-loop.d.ts +1 -1
  199. package/package.json +1 -1
  200. package/project/context/flowr-analyzer-dependencies-context.js +2 -1
  201. package/project/flowr-analyzer.d.ts +1 -0
  202. package/project/flowr-analyzer.js +5 -5
  203. package/project/sigdb/build.js +14 -4
  204. package/project/sigdb/decode.d.ts +3 -0
  205. package/project/sigdb/decode.js +10 -1
  206. package/project/sigdb/guarded-source.d.ts +6 -0
  207. package/project/sigdb/guarded-source.js +29 -0
  208. package/project/sigdb/reader.d.ts +5 -0
  209. package/project/sigdb/reader.js +27 -1
  210. package/project/sigdb/schema.d.ts +24 -2
  211. package/queries/catalog/absint-query/absint-query-format.d.ts +6 -3
  212. package/queries/catalog/absint-query/absint-query-format.js +57 -2
  213. package/queries/catalog/ambient-access-query/ambient-access-query-format.d.ts +6 -2
  214. package/queries/catalog/ambient-access-query/ambient-access-query-format.js +48 -3
  215. package/queries/catalog/cluster-query/cluster-query-format.d.ts +5 -2
  216. package/queries/catalog/cluster-query/cluster-query-format.js +19 -2
  217. package/queries/catalog/code-clones-query/code-clones-query-format.d.ts +5 -2
  218. package/queries/catalog/code-clones-query/code-clones-query-format.js +34 -2
  219. package/queries/catalog/config-query/config-query-format.d.ts +5 -2
  220. package/queries/catalog/config-query/config-query-format.js +41 -2
  221. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +5 -2
  222. package/queries/catalog/control-flow-query/control-flow-query-format.js +19 -2
  223. package/queries/catalog/data-columns-query/data-columns-query-format.d.ts +72 -0
  224. package/queries/catalog/data-columns-query/data-columns-query-format.js +215 -0
  225. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +5 -2
  226. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +38 -2
  227. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +5 -2
  228. package/queries/catalog/dataflow-query/dataflow-query-format.js +18 -2
  229. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  230. package/queries/catalog/dependencies-query/dependencies-query-format.js +8 -3
  231. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +1 -1
  232. package/queries/catalog/dependencies-query/function-info/tagged-functions.d.ts +11 -0
  233. package/queries/catalog/dependencies-query/function-info/tagged-functions.js +18 -0
  234. package/queries/catalog/dice-query/dice-query-format.d.ts +7 -2
  235. package/queries/catalog/dice-query/dice-query-format.js +34 -2
  236. package/queries/catalog/does-call-query/does-call-query-format.d.ts +7 -4
  237. package/queries/catalog/does-call-query/does-call-query-format.js +114 -2
  238. package/queries/catalog/files-query/files-query-format.d.ts +5 -2
  239. package/queries/catalog/files-query/files-query-format.js +45 -2
  240. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +6 -3
  241. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +303 -2
  242. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +8 -4
  243. package/queries/catalog/happens-before-query/happens-before-query-format.js +37 -2
  244. package/queries/catalog/id-map-query/id-map-query-format.d.ts +5 -2
  245. package/queries/catalog/id-map-query/id-map-query-format.js +18 -2
  246. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +5 -2
  247. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +29 -2
  248. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +37 -0
  249. package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +125 -0
  250. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -2
  251. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +54 -2
  252. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -2
  253. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +23 -2
  254. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -2
  255. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +15 -2
  256. package/queries/catalog/linter-query/linter-query-format.d.ts +8 -2
  257. package/queries/catalog/linter-query/linter-query-format.js +69 -4
  258. package/queries/catalog/location-map-query/location-map-query-format.d.ts +7 -3
  259. package/queries/catalog/location-map-query/location-map-query-format.js +70 -2
  260. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +5 -2
  261. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +18 -2
  262. package/queries/catalog/origin-query/origin-query-format.d.ts +6 -3
  263. package/queries/catalog/origin-query/origin-query-format.js +29 -2
  264. package/queries/catalog/project-query/project-query-format.d.ts +6 -3
  265. package/queries/catalog/project-query/project-query-format.js +98 -2
  266. package/queries/catalog/provenance-query/provenance-query-format.d.ts +6 -3
  267. package/queries/catalog/provenance-query/provenance-query-format.js +30 -2
  268. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +9 -2
  269. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +38 -2
  270. package/queries/catalog/search-query/search-query-format.d.ts +5 -2
  271. package/queries/catalog/search-query/search-query-format.js +23 -2
  272. package/queries/catalog/signature-query/signature-query-executor.js +3 -1
  273. package/queries/catalog/signature-query/signature-query-format.d.ts +3 -0
  274. package/queries/catalog/signature-query/signature-query-render.js +23 -0
  275. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +13 -2
  276. package/queries/catalog/static-slice-query/static-slice-query-format.js +55 -2
  277. package/queries/catalog/taint-query/taint-query-format.d.ts +6 -3
  278. package/queries/catalog/taint-query/taint-query-format.js +28 -2
  279. package/queries/query.d.ts +48 -27
  280. package/queries/query.js +6 -4
  281. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +2 -0
  282. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -0
  283. package/r-bridge/shell.js +7 -2
  284. package/reconstruct/reconstruct.js +18 -3
  285. package/slicing/static/removal-slice.js +4 -3
  286. package/slicing/static/slice-call.d.ts +11 -0
  287. package/slicing/static/slice-call.js +43 -2
  288. package/slicing/static/static-slicer.d.ts +2 -0
  289. package/slicing/static/static-slicer.js +137 -21
  290. package/slicing/static/visiting-queue.d.ts +2 -0
  291. package/slicing/static/visiting-queue.js +4 -0
  292. package/util/flowr-version.d.ts +1 -1
  293. package/util/flowr-version.js +2 -2
  294. package/util/objects.d.ts +2 -0
  295. package/util/objects.js +5 -0
  296. package/util/r-datasets.d.ts +27 -0
  297. package/util/r-datasets.js +45 -0
  298. package/util/text/playground-link.d.ts +2 -0
  299. package/util/text/playground-link.js +2 -0
  300. package/queries/catalog/absint-query/absint-query-executor.d.ts +0 -6
  301. package/queries/catalog/absint-query/absint-query-executor.js +0 -61
  302. package/queries/catalog/ambient-access-query/ambient-access-query-executor.d.ts +0 -6
  303. package/queries/catalog/ambient-access-query/ambient-access-query-executor.js +0 -50
  304. package/queries/catalog/cluster-query/cluster-query-executor.d.ts +0 -6
  305. package/queries/catalog/cluster-query/cluster-query-executor.js +0 -21
  306. package/queries/catalog/code-clones-query/code-clones-query-executor.d.ts +0 -6
  307. package/queries/catalog/code-clones-query/code-clones-query-executor.js +0 -38
  308. package/queries/catalog/config-query/config-query-executor.d.ts +0 -6
  309. package/queries/catalog/config-query/config-query-executor.js +0 -45
  310. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +0 -6
  311. package/queries/catalog/control-flow-query/control-flow-query-executor.js +0 -21
  312. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.d.ts +0 -6
  313. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +0 -40
  314. package/queries/catalog/dataflow-query/dataflow-query-executor.d.ts +0 -6
  315. package/queries/catalog/dataflow-query/dataflow-query-executor.js +0 -20
  316. package/queries/catalog/dependencies-query/function-info/statistics-functions.d.ts +0 -9
  317. package/queries/catalog/dependencies-query/function-info/statistics-functions.js +0 -18
  318. package/queries/catalog/dice-query/dice-query-executor.d.ts +0 -8
  319. package/queries/catalog/dice-query/dice-query-executor.js +0 -37
  320. package/queries/catalog/does-call-query/does-call-query-executor.d.ts +0 -6
  321. package/queries/catalog/does-call-query/does-call-query-executor.js +0 -116
  322. package/queries/catalog/files-query/files-query-executor.d.ts +0 -6
  323. package/queries/catalog/files-query/files-query-executor.js +0 -47
  324. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.d.ts +0 -6
  325. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +0 -307
  326. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +0 -7
  327. package/queries/catalog/happens-before-query/happens-before-query-executor.js +0 -40
  328. package/queries/catalog/id-map-query/id-map-query-executor.d.ts +0 -6
  329. package/queries/catalog/id-map-query/id-map-query-executor.js +0 -20
  330. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -6
  331. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +0 -31
  332. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.d.ts +0 -4
  333. package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +0 -58
  334. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +0 -7
  335. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +0 -25
  336. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +0 -7
  337. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +0 -17
  338. package/queries/catalog/linter-query/linter-query-executor.d.ts +0 -9
  339. package/queries/catalog/linter-query/linter-query-executor.js +0 -62
  340. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +0 -7
  341. package/queries/catalog/location-map-query/location-map-query-executor.js +0 -73
  342. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.d.ts +0 -6
  343. package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +0 -20
  344. package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -6
  345. package/queries/catalog/origin-query/origin-query-executor.js +0 -31
  346. package/queries/catalog/project-query/project-query-executor.d.ts +0 -6
  347. package/queries/catalog/project-query/project-query-executor.js +0 -103
  348. package/queries/catalog/provenance-query/provenance-query-executor.d.ts +0 -6
  349. package/queries/catalog/provenance-query/provenance-query-executor.js +0 -33
  350. package/queries/catalog/resolve-value-query/resolve-value-query-executor.d.ts +0 -10
  351. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +0 -40
  352. package/queries/catalog/search-query/search-query-executor.d.ts +0 -6
  353. package/queries/catalog/search-query/search-query-executor.js +0 -25
  354. package/queries/catalog/static-slice-query/static-slice-query-executor.d.ts +0 -14
  355. package/queries/catalog/static-slice-query/static-slice-query-executor.js +0 -59
  356. package/queries/catalog/taint-query/taint-query-executor.d.ts +0 -7
  357. package/queries/catalog/taint-query/taint-query-executor.js +0 -30
@@ -193,6 +193,11 @@ export declare class SigDatabase implements PackageSignatureSource {
193
193
  * nothing is known about the package yet, so this only ever skips work that would have found nothing.
194
194
  */
195
195
  private mayOffer;
196
+ /**
197
+ * Whether `pkg` may offer the name with dictionary id `id`, deciding from the raw bytes of a blob not decoded yet: every `[id,` they hold may
198
+ * start a function record, so their ids are a superset of the names the package has, kept for {@link mayOffer} as {@link nameIdsOfBlob}.
199
+ */
200
+ private mayHoldNameId;
196
201
  /** drop one decoded blob, for the shared budget to reclaim what it costs (see {@link keepBlob}) */
197
202
  dropBlob(blobIdx: number): void;
198
203
  /** store `value` under `key`, dropping the oldest entry first once the cache sits at `cap` */
@@ -490,6 +490,32 @@ class SigDatabase {
490
490
  }
491
491
  return false;
492
492
  }
493
+ /**
494
+ * Whether `pkg` may offer the name with dictionary id `id`, deciding from the raw bytes of a blob not decoded yet: every `[id,` they hold may
495
+ * start a function record, so their ids are a superset of the names the package has, kept for {@link mayOffer} as {@link nameIdsOfBlob}.
496
+ */
497
+ mayHoldNameId(pkg, name) {
498
+ const blobIdx = this.index.pkgs[pkg];
499
+ if (blobIdx === undefined || this.fd === NoFile || this.blobCache.has(blobIdx) || this.nameIdsOfBlob.has(blobIdx)) {
500
+ return true;
501
+ }
502
+ const [start, bytes] = this.index.blobs[blobIdx];
503
+ const buf = Buffer.allocUnsafe(bytes);
504
+ fs_1.default.readSync(this.fd, buf, 0, bytes, start);
505
+ const ids = new Set();
506
+ for (let at = buf.indexOf(91); at >= 0; at = buf.indexOf(91, at + 1)) {
507
+ let num = 0;
508
+ let end = at + 1;
509
+ for (; end < bytes && buf[end] >= 48 && buf[end] <= 57; end++) {
510
+ num = num * 10 + buf[end] - 48;
511
+ }
512
+ if (end > at + 1 && buf[end] === 44) {
513
+ ids.add(num);
514
+ }
515
+ }
516
+ this.nameIdsOfBlob.set(blobIdx, Int32Array.from(ids).sort());
517
+ return this.mayOffer(pkg, name);
518
+ }
493
519
  /** drop one decoded blob, for the shared budget to reclaim what it costs (see {@link keepBlob}) */
494
520
  dropBlob(blobIdx) {
495
521
  this.blobCache.delete(blobIdx);
@@ -556,7 +582,7 @@ class SigDatabase {
556
582
  }
557
583
  const found = [];
558
584
  for (const pkg in this.index.pkgs) {
559
- if (this.mayOffer(pkg, name) && this.exportsNameId(pkg, id)) {
585
+ if (this.mayHoldNameId(pkg, name) && this.mayOffer(pkg, name) && this.exportsNameId(pkg, id)) {
560
586
  found.push(pkg);
561
587
  }
562
588
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { ArgProps } from '../../dataflow/environments/built-in-props';
7
7
  import type { BrandedIdentifier, BrandedNamespace } from '../../dataflow/environments/identifier';
8
+ import type { StatedGuards } from '../../dataflow/fn/guards/built-in-guards';
8
9
  /** The definition location of the binding, with a file path usually relative to the package project root. */
9
10
  export interface SigDefinitionLocation {
10
11
  readonly file: string;
@@ -44,15 +45,25 @@ export declare const MaxDefaultLength = 10;
44
45
  export declare const SigDbExt = ".sigs.ndjson";
45
46
  /** function-level boolean properties, packed into {@link SigFn}'s bitfield */
46
47
  export declare const enum FnProp {
48
+ /** the package exports the name, so a caller reaches it without `:::` */
47
49
  Exported = 1,
50
+ /** takes a function as an argument or returns one */
48
51
  HigherOrder = 2,
52
+ /** calls itself, directly or through other functions of the package */
49
53
  Recursive = 4,
54
+ /** calls something deprecated, so it may stop working once that goes */
50
55
  CallsDeprecated = 8,
56
+ /** may raise an error, so a caller cannot count on a value back */
51
57
  CanThrow = 16,
58
+ /** marked as deprecated by the package itself */
52
59
  Deprecated = 32,
60
+ /** calls into R's internal code, like `.Internal` or `.Call`, which no R source shows */
53
61
  CallsInternal = 64,
62
+ /** may answer differently for the same arguments, like random draws or the clock */
54
63
  NonDeterministic = 128,
64
+ /** the package has no manual page for the name */
55
65
  NoDoc = 256,
66
+ /** an implementation of a generic for one class, like `print.data.frame` */
56
67
  S3Method = 512,
57
68
  /**
58
69
  * An exported function that is also an S3 class this package OWNS: it is a same-named constructor for a
@@ -169,9 +180,16 @@ export interface PkgBlob {
169
180
  classes?: SigClass[];
170
181
  /** version name to a delta-encoded ascending list of indices into {@link PkgBlob.classes} */
171
182
  classesByVersion?: Record<string, number[]>;
183
+ /** pool of unique contracts (shared across a package's versions), absent when the bundle stores none */
184
+ contracts?: StatedGuards[];
185
+ /**
186
+ * Index into {@link PkgBlob.fns} to an index into {@link PkgBlob.contracts}, only for the functions with a contract.
187
+ * A function's contract is part of its pooled record, so two versions only share a slot if their contracts agree.
188
+ */
189
+ contractOf?: Record<number, number>;
172
190
  }
173
- /** On-disk tuple form of a {@link PkgBlob}, field order, ending `sources`; trailing elements are additive. */
174
- export type PkgBlobTuple = [Sig[], number[][], SigFn[], Record<string, number[]>, string[], SigDep[][], Record<string, number>, Record<string, number>?, Record<string, number>?, SigClass[]?, Record<string, number[]>?];
191
+ /** On-disk tuple form of a {@link PkgBlob}, field order, ending `contractOf`; trailing elements are additive. */
192
+ export type PkgBlobTuple = [Sig[], number[][], SigFn[], Record<string, number[]>, string[], SigDep[][], Record<string, number>, Record<string, number>?, Record<string, number>?, SigClass[]?, Record<string, number[]>?, StatedGuards[]?, Record<number, number>?];
175
193
  /**
176
194
  * Per-package metadata. The optional 4th element marks an **R-core / base package**: for these the version keys
177
195
  * are the R releases the package shipped with core R, so the set of versions is exactly its core-R history.
@@ -242,6 +260,8 @@ export interface SigFunctionInfo {
242
260
  readonly topic?: string;
243
261
  /** the package this name is re-exported from: the package defines nothing of the name, it imports and exports it */
244
262
  readonly reexportOf?: string;
263
+ /** what a call has to fulfill to return normally, as flowR infers it from the definition; absent when nothing sensible is known */
264
+ readonly guards?: StatedGuards;
245
265
  }
246
266
  /** one declared package dependency, e.g. `{ name: 'testthat', type: Suggests, constraint: '>= 2.1.0' }` */
247
267
  export interface SigDependencyInfo {
@@ -301,4 +321,6 @@ export interface SigDbFeatures {
301
321
  dependencies?: boolean;
302
322
  /** per-version class relations (superclasses, slots, unions) -- default true */
303
323
  classes?: boolean;
324
+ /** per-function contracts (what a call has to fulfill to return normally, see {@link SigFunctionInfo.guards}) -- default true */
325
+ contracts?: boolean;
304
326
  }
@@ -1,5 +1,4 @@
1
1
  import Joi from 'joi';
2
- import type { AbsintAnalysis } from '../../../abstract-interpretation/absint-inference';
3
2
  import { DataFrameShapeAnalysis } from '../../../abstract-interpretation/data-frame/shape-inference';
4
3
  import type { MultiValueDomain, MultiValueStateDomain } from '../../../abstract-interpretation/domains/multi-value-state-domain';
5
4
  import type { StateDomain } from '../../../abstract-interpretation/domains/state-domain';
@@ -8,9 +7,13 @@ import type { CommandCompletions } from '../../../cli/repl/completion';
8
7
  import type { FlowrConfig } from '../../../config';
9
8
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
10
9
  import { SlicingCriterion, type SlicingCriteria } from '../../../slicing/criterion/parse';
11
- import { type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
10
+ import { type BasicQueryData, type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
12
11
  import type { ParsedQueryLine } from '../../query';
13
- import { executeAbsintQuery } from './absint-query-executor';
12
+ import { type AbsintAnalysis } from '../../../abstract-interpretation/absint-inference';
13
+ /**
14
+ * Executes the given abstract interpretation queries using the provided analyzer.
15
+ */
16
+ export declare function executeAbsintQuery<AbsintType extends AbsintQueryType>({ analyzer }: BasicQueryData, queries: readonly AbsintQuery<AbsintType>[]): Promise<AbsintQueryResult<AbsintType>>;
14
17
  export interface AbsintQuery<AbsintType extends AbsintQueryType = AbsintQueryType> extends BaseQueryFormat {
15
18
  readonly type: 'absint';
16
19
  readonly inference: AbsintType;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AbsintQueryDefinition = exports.AbsintQueryInferences = void 0;
7
+ exports.executeAbsintQuery = executeAbsintQuery;
7
8
  const joi_1 = __importDefault(require("joi"));
8
9
  const query_print_1 = require("../../query-print");
9
10
  const shape_inference_1 = require("../../../abstract-interpretation/data-frame/shape-inference");
@@ -15,7 +16,61 @@ const parse_1 = require("../../../slicing/criterion/parse");
15
16
  const assert_1 = require("../../../util/assert");
16
17
  const record_1 = require("../../../util/record");
17
18
  const base_query_format_1 = require("../../base-query-format");
18
- const absint_query_executor_1 = require("./absint-query-executor");
19
+ const absint_inference_1 = require("../../../abstract-interpretation/absint-inference");
20
+ const log_1 = require("../../../util/log");
21
+ const query_meta_1 = require("../../query-meta");
22
+ /**
23
+ * Executes the given abstract interpretation queries using the provided analyzer.
24
+ */
25
+ async function executeAbsintQuery({ analyzer }, queries) {
26
+ if (queries.length === 0 || queries.some(query => query.inference !== queries[0].inference)) {
27
+ throw new Error('The inference types of bundled abstract interpretation queries must be the same.');
28
+ }
29
+ if (queries.length > 1 && queries.some(query => query.criteria === undefined)) {
30
+ log_1.log.warn('The abstract interpretation query expects only up to one query without slicing criteria, but got', queries.length);
31
+ queries = [{ type: 'absint', inference: queries[0].inference }];
32
+ }
33
+ const inference = exports.AbsintQueryInferences[queries[0].inference];
34
+ const ast = await analyzer.normalize();
35
+ const dfg = (await analyzer.dataflow()).graph;
36
+ const cfg = await analyzer.controlflow();
37
+ const start = Date.now();
38
+ const analysis = inference.create();
39
+ const interpreter = new absint_inference_1.AbstractInterpreter({ controlFlow: cfg, dfg, normalizedAst: ast, ctx: analyzer.inspectContext() }, analysis);
40
+ interpreter.start();
41
+ if (queries.length === 1 && queries[0].criteria === undefined) {
42
+ const state = ('domain' in inference ? interpreter.getEndState(inference.domain) : interpreter.getEndState());
43
+ return {
44
+ ...(0, query_meta_1.metaSince)(start),
45
+ result: state
46
+ };
47
+ }
48
+ const result = new Map();
49
+ for (const query of queries) {
50
+ if (query.criteria === undefined) {
51
+ log_1.log.warn('Missing criterion in abstract interpretation query');
52
+ continue;
53
+ }
54
+ for (const criterion of query.criteria) {
55
+ if (result.has(criterion)) {
56
+ log_1.log.warn('Duplicate criterion in abstract interpretation query:', query.criteria);
57
+ continue;
58
+ }
59
+ try {
60
+ const nodeId = parse_1.SlicingCriterion.parse(criterion, ast.idMap);
61
+ const value = ('domain' in inference ? interpreter.getAbstractValue(nodeId, inference.domain) : interpreter.getAbstractValue(nodeId));
62
+ result.set(criterion, value);
63
+ }
64
+ catch (err) {
65
+ console.error(err instanceof Error ? err.message : err);
66
+ }
67
+ }
68
+ }
69
+ return {
70
+ ...(0, query_meta_1.metaSince)(start),
71
+ result: result
72
+ };
73
+ }
19
74
  exports.AbsintQueryInferences = {
20
75
  'df-shape': { create: () => new shape_inference_1.DataFrameShapeAnalysis({ trackOperations: false }), domain: 'dataFrame' }
21
76
  };
@@ -65,7 +120,7 @@ function absintQueryLineParser(output, line, _config) {
65
120
  }
66
121
  exports.AbsintQueryDefinition = {
67
122
  title: 'Abstract Interpretation Query',
68
- executor: absint_query_executor_1.executeAbsintQuery,
123
+ executor: executeAbsintQuery,
69
124
  asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
70
125
  const out = queryResults;
71
126
  result.push((0, query_print_1.queryHeader)('absint', formatter, out['.meta'].timing));
@@ -1,11 +1,14 @@
1
1
  import type { AmbientStateName } from '../../../dataflow/environments/ambient-state-name';
2
2
  import type { BrandedIdentifier } from '../../../dataflow/environments/identifier';
3
3
  import Joi from 'joi';
4
- import { type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
4
+ import { type BasicQueryData, type BaseQueryFormat, type BaseQueryResult } from '../../base-query-format';
5
5
  import { criteriaQueryCompleter } from '../../../cli/repl/parser/slice-query-parser';
6
6
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { SlicingCriteria } from '../../../slicing/criterion/parse';
8
- import { executeAmbientAccessQuery } from './ambient-access-query-executor';
8
+ /**
9
+ * Executes {@link AmbientAccessQuery}s, sharing one pass over the call graph between all scopes they ask for.
10
+ */
11
+ export declare function executeAmbientAccessQuery({ analyzer }: BasicQueryData, queries: readonly AmbientAccessQuery[]): Promise<AmbientAccessQueryResult>;
9
12
  /**
10
13
  * What code reads and writes of the global state (options, environment variables, the working directory,
11
14
  * devices, the search path, ...), as the pseudo variables of {@link AmbientStateName}.
@@ -31,6 +34,7 @@ export interface AmbientAccessSummary {
31
34
  readonly reads: readonly AmbientStateName[];
32
35
  readonly writes: readonly AmbientStateName[];
33
36
  readonly assumed: readonly AmbientStateName[];
37
+ readonly kills: readonly AmbientStateName[];
34
38
  readonly variables: readonly BrandedIdentifier[];
35
39
  readonly draws: readonly NodeId[];
36
40
  }
@@ -4,12 +4,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.AmbientAccessQueryDefinition = exports.AmbientProjectKey = void 0;
7
+ exports.executeAmbientAccessQuery = executeAmbientAccessQuery;
7
8
  const joi_1 = __importDefault(require("joi"));
8
9
  const base_query_format_1 = require("../../base-query-format");
9
10
  const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
10
11
  const ansi_1 = require("../../../util/text/ansi");
11
12
  const query_print_1 = require("../../query-print");
12
- const ambient_access_query_executor_1 = require("./ambient-access-query-executor");
13
+ const query_meta_1 = require("../../query-meta");
14
+ const df_helper_1 = require("../../../dataflow/graph/df-helper");
15
+ const parse_1 = require("../../../slicing/criterion/parse");
16
+ const query_function_filter_1 = require("../../query-function-filter");
17
+ const log_1 = require("../../../util/log");
18
+ function summary(a) {
19
+ return { reads: [...a.reads.keys()].sort(), writes: [...a.writes.keys()].sort(), assumed: [...a.assumed.keys()].sort(), kills: [...a.kills.keys()].sort(), variables: [...a.variables.keys()].sort(), draws: [...a.draws] };
20
+ }
21
+ /**
22
+ * Executes {@link AmbientAccessQuery}s, sharing one pass over the call graph between all scopes they ask for.
23
+ */
24
+ async function executeAmbientAccessQuery({ analyzer }, queries) {
25
+ const start = Date.now();
26
+ const info = await analyzer.dataflow();
27
+ const { ast, idMap } = await analyzer.normalize();
28
+ const functions = df_helper_1.Dataflow.sideEffects.ambientAccessOfFunctions(info);
29
+ const results = {};
30
+ let perFunction;
31
+ for (const { criteria, includeCallees, functions: askFunctions } of queries) {
32
+ const opts = { includeCallees, functions };
33
+ if (criteria === undefined) {
34
+ ast.files.forEach((f, i) => {
35
+ results[f.filePath ?? `<file ${i + 1}>`] = summary(df_helper_1.Dataflow.sideEffects.ambientAccess(info, f.root, opts));
36
+ });
37
+ results[exports.AmbientProjectKey] = summary(df_helper_1.Dataflow.sideEffects.ambientAccess(info, ast, opts));
38
+ }
39
+ for (const criterion of criteria ?? []) {
40
+ const id = parse_1.SlicingCriterion.tryParse(criterion, idMap);
41
+ if (id === undefined) {
42
+ log_1.log.warn(`ambient-access: criterion ${criterion} matches no node`);
43
+ continue;
44
+ }
45
+ results[criterion] = summary(df_helper_1.Dataflow.sideEffects.ambientAccess(info, id, opts));
46
+ }
47
+ if (askFunctions) {
48
+ perFunction ??= {};
49
+ for (const [id, access] of functions) {
50
+ if (query_function_filter_1.QueryFunctionFilter.written(id)) {
51
+ perFunction[id] = summary(access);
52
+ }
53
+ }
54
+ }
55
+ }
56
+ return { ...(0, query_meta_1.metaSince)(start), results, ...(perFunction === undefined ? {} : { functions: perFunction }) };
57
+ }
13
58
  /** the key {@link AmbientAccessQueryResult.results} uses for all files together */
14
59
  exports.AmbientProjectKey = '<project>';
15
60
  function listed(name, items) {
@@ -17,13 +62,13 @@ function listed(name, items) {
17
62
  }
18
63
  exports.AmbientAccessQueryDefinition = {
19
64
  title: 'Ambient Access Query',
20
- executor: ambient_access_query_executor_1.executeAmbientAccessQuery,
65
+ executor: executeAmbientAccessQuery,
21
66
  asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
22
67
  const out = queryResults;
23
68
  result.push((0, query_print_1.queryHeader)('ambient-access', formatter, out['.meta'].timing));
24
69
  const entries = [...Object.entries(out.results), ...Object.entries(out.functions ?? {}).map(([id, a]) => [`function ${id}`, a])];
25
70
  for (const [key, a] of entries) {
26
- const line = listed('reads', a.reads) + listed('writes', a.writes) + listed('assumed', a.assumed) + listed('binds', a.variables) + listed('draws', a.draws);
71
+ const line = listed('reads', a.reads) + listed('writes', a.writes) + listed('assumed', a.assumed) + listed('kills', a.kills) + listed('binds', a.variables) + listed('draws', a.draws);
27
72
  result.push(` ╰ ${(0, ansi_1.bold)(key, formatter)}:${line === '' ? ' nothing' : line}`);
28
73
  }
29
74
  return true;
@@ -1,8 +1,11 @@
1
- import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
1
+ import type { BaseQueryFormat, BaseQueryResult, BasicQueryData } from '../../base-query-format';
2
2
  import Joi from 'joi';
3
3
  import type { DataflowGraphClusters } from '../../../dataflow/cluster';
4
- import { executeDataflowClusterQuery } from './cluster-query-executor';
5
4
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
+ /**
6
+ * Executes the given dataflow cluster queries using the provided analyzer.
7
+ */
8
+ export declare function executeDataflowClusterQuery({ analyzer }: BasicQueryData, queries: readonly DataflowClusterQuery[]): Promise<DataflowClusterQueryResult>;
6
9
  /**
7
10
  * Calculates and returns all clusters encountered in the dataflow graph.
8
11
  */
@@ -4,14 +4,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ClusterQueryDefinition = void 0;
7
+ exports.executeDataflowClusterQuery = executeDataflowClusterQuery;
7
8
  const ansi_1 = require("../../../util/text/ansi");
8
9
  const joi_1 = __importDefault(require("joi"));
9
- const cluster_query_executor_1 = require("./cluster-query-executor");
10
10
  const query_print_1 = require("../../query-print");
11
11
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
12
+ const log_1 = require("../../../util/log");
13
+ const cluster_1 = require("../../../dataflow/cluster");
14
+ const query_meta_1 = require("../../query-meta");
15
+ /**
16
+ * Executes the given dataflow cluster queries using the provided analyzer.
17
+ */
18
+ async function executeDataflowClusterQuery({ analyzer }, queries) {
19
+ if (queries.length !== 1) {
20
+ log_1.log.warn('The dataflow cluster query expects only up to one query, but got', queries.length);
21
+ }
22
+ const start = Date.now();
23
+ const clusters = (0, cluster_1.findAllClusters)((await analyzer.dataflow()).graph);
24
+ return {
25
+ ...(0, query_meta_1.metaSince)(start),
26
+ clusters
27
+ };
28
+ }
12
29
  exports.ClusterQueryDefinition = {
13
30
  title: 'Dataflow Cluster Query',
14
- executor: cluster_query_executor_1.executeDataflowClusterQuery,
31
+ executor: executeDataflowClusterQuery,
15
32
  asciiSummarizer: async (formatter, analyzer, queryResults, result) => {
16
33
  const out = queryResults;
17
34
  result.push(`Query: ${(0, ansi_1.bold)('dataflow-cluster', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);
@@ -1,4 +1,4 @@
1
- import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
1
+ import type { BaseQueryFormat, BaseQueryResult, BasicQueryData } 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';
@@ -9,7 +9,10 @@ import { CloneAlgorithm, type CloneDetectionConfig, type CloneDetectionStats, ty
9
9
  import { ClonePerspective } from '../../../clones/clone-ast';
10
10
  import type { SerializedCloneIndex } from '../../../clones/clone-index';
11
11
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
12
- import { executeCodeClonesQuery } from './code-clones-query-executor';
12
+ /**
13
+ * Builds the clone index of the analyzed files and runs the requested clone detectors on it.
14
+ */
15
+ export declare function executeCodeClonesQuery({ analyzer }: BasicQueryData, queries: readonly CodeClonesQuery[]): Promise<CodeClonesQueryResult>;
13
16
  /**
14
17
  * Finds code clones in all files of the analysis with a configurable selection of algorithms.
15
18
  * Keep in mind that:
@@ -4,14 +4,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CodeClonesQueryDefinition = void 0;
7
+ exports.executeCodeClonesQuery = executeCodeClonesQuery;
7
8
  const joi_1 = __importDefault(require("joi"));
8
9
  const query_print_1 = require("../../query-print");
9
10
  const ansi_1 = require("../../../util/text/ansi");
10
11
  const clone_detector_1 = require("../../../clones/clone-detector");
11
12
  const clone_ast_1 = require("../../../clones/clone-ast");
12
13
  const range_1 = require("../../../util/range");
13
- const code_clones_query_executor_1 = require("./code-clones-query-executor");
14
14
  const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
15
+ const clone_index_1 = require("../../../clones/clone-index");
16
+ const objects_1 = require("../../../util/objects");
17
+ const query_meta_1 = require("../../query-meta");
18
+ const log_1 = require("../../../util/log");
19
+ /**
20
+ * Builds the clone index of the analyzed files and runs the requested clone detectors on it.
21
+ */
22
+ async function executeCodeClonesQuery({ analyzer }, queries) {
23
+ if (queries.length !== 1) {
24
+ log_1.log.warn('The code-clones query expects only up to one query, but got', queries.length);
25
+ }
26
+ const query = queries[0];
27
+ const start = Date.now();
28
+ const algorithms = query.algorithms ?? clone_detector_1.DefaultCloneDetectionConfig.algorithms;
29
+ const config = { ...(0, objects_1.deepMergeObject)(clone_detector_1.DefaultCloneDetectionConfig, query.config), algorithms };
30
+ const against = query.against?.map(clone_index_1.CloneIndex.deserialize) ?? [];
31
+ /* the analyzed files must be presented like the stored ones, or the algorithms compare different rewrites */
32
+ const perspective = query.perspective ?? against[0]?.perspective ?? clone_ast_1.ClonePerspective.Canonical;
33
+ const mismatch = against.find(a => a.perspective !== perspective);
34
+ if (mismatch) {
35
+ throw new Error(`the code-clones query uses the ${perspective} perspective, but an index to search against was built with ${mismatch.perspective}`);
36
+ }
37
+ const index = await clone_index_1.CloneIndex.build(analyzer, { perspective });
38
+ const corpus = against.length > 0 ? { perspective, files: against.flatMap(a => a.files) } : undefined;
39
+ const { pairs, stats } = (0, clone_detector_1.detectClones)(index, config, corpus);
40
+ return {
41
+ ...(0, query_meta_1.metaSince)(start),
42
+ pairs,
43
+ stats,
44
+ ...(query.exportIndex ? { index: clone_index_1.CloneIndex.serialize(index) } : {})
45
+ };
46
+ }
15
47
  function codeClonesLineParser(_output, line, _config) {
16
48
  const known = new Set(Object.values(clone_detector_1.CloneAlgorithm));
17
49
  /* only the leading words name algorithms, the rest is the code */
@@ -31,7 +63,7 @@ function fragmentText(f, formatter) {
31
63
  }
32
64
  exports.CodeClonesQueryDefinition = {
33
65
  title: 'Code Clones Query',
34
- executor: code_clones_query_executor_1.executeCodeClonesQuery,
66
+ executor: executeCodeClonesQuery,
35
67
  fromLine: codeClonesLineParser,
36
68
  syntax: '@code-clones [baxter|gst|winnowing ...] [<code>]',
37
69
  asciiSummarizer: (formatter, _analyzer, queryResults, result) => {
@@ -1,5 +1,4 @@
1
- import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
2
- import { executeConfigQuery } from './config-query-executor';
1
+ import type { BaseQueryFormat, BaseQueryResult, BasicQueryData } from '../../base-query-format';
3
2
  import { type OutputFormatter } from '../../../util/text/ansi';
4
3
  import Joi from 'joi';
5
4
  import { FlowrConfig } from '../../../config';
@@ -8,6 +7,10 @@ import type { ParsedQueryLine, Query } from '../../query';
8
7
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
9
8
  import { type CommandCompletions } from '../../../cli/repl/completion';
10
9
  import type { ProjectKind } from '../../../project/context/project-kind';
10
+ /**
11
+ * Executes the given configuration queries using the provided analyzer.
12
+ */
13
+ export declare function executeConfigQuery({ analyzer }: BasicQueryData, queries: readonly ConfigQuery[]): Promise<ConfigQueryResult>;
11
14
  export interface ConfigQuery extends BaseQueryFormat {
12
15
  readonly type: 'config';
13
16
  readonly update?: DeepPartial<FlowrConfig>;
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConfigQueryDefinition = void 0;
7
+ exports.executeConfigQuery = executeConfigQuery;
7
8
  exports.validateConfigUpdate = validateConfigUpdate;
8
- const config_query_executor_1 = require("./config-query-executor");
9
9
  const query_print_1 = require("../../query-print");
10
10
  const ansi_1 = require("../../../util/text/ansi");
11
11
  const joi_1 = __importDefault(require("joi"));
@@ -14,6 +14,45 @@ const json_1 = require("../../../util/json");
14
14
  const completion_1 = require("../../../cli/repl/completion");
15
15
  const schema_1 = require("../../../util/schema");
16
16
  const strings_1 = require("../../../util/text/strings");
17
+ const log_1 = require("../../../util/log");
18
+ const assert_1 = require("../../../util/assert");
19
+ /**
20
+ * Executes the given configuration queries using the provided analyzer.
21
+ */
22
+ function executeConfigQuery({ analyzer }, queries) {
23
+ if (queries.some(q => q.reset)) {
24
+ analyzer.resetConfig();
25
+ }
26
+ const updates = queries.map(q => q.update).filter(assert_1.isNotUndefined);
27
+ if (updates.length > 1) {
28
+ log_1.log.warn('Config query usually expects only up to one update, but got', updates.length);
29
+ }
30
+ // validate here too (not only in the repl parser), so a programmatic / JSON-API update cannot merge an unknown
31
+ // key or a wrong-typed value; the update then lands via `updateConfig`, which invalidates the analysis cache
32
+ for (const given of updates) {
33
+ const err = validateConfigUpdate(given);
34
+ if (err !== undefined) {
35
+ log_1.log.warn(`ignoring invalid config update: ${err}`);
36
+ continue;
37
+ }
38
+ // queries may come from clients of the server, so they must not choose what flowR executes, loads, or downloads
39
+ const update = structuredClone(given);
40
+ const dropped = config_1.FlowrConfig.dropUntrusted(update);
41
+ if (dropped.length > 0) {
42
+ log_1.log.warn(`ignoring untrusted options in config update: ${dropped.join(', ')}`);
43
+ }
44
+ analyzer.updateConfig(update);
45
+ }
46
+ const specialization = analyzer.inspectContext().configSpecialization();
47
+ return Promise.resolve({
48
+ '.meta': {
49
+ /* there is no sense in measuring a get */
50
+ timing: 0
51
+ },
52
+ config: analyzer.flowrConfig,
53
+ ...(specialization ? { specialization } : {})
54
+ });
55
+ }
17
56
  function configReplCompleter(partialLine, startingNewArg, _config) {
18
57
  // the config query is a single token
19
58
  if (partialLine.length > 1 || (partialLine.length === 1 && startingNewArg)) {
@@ -292,7 +331,7 @@ function inspectedChildren(value, path, formatter) {
292
331
  exports.ConfigQueryDefinition = {
293
332
  title: 'Config Query',
294
333
  syntax: '@config [<path> | <glob>] | @config +<path>=<value> | @config +reset',
295
- executor: config_query_executor_1.executeConfigQuery,
334
+ executor: executeConfigQuery,
296
335
  asciiSummarizer: (formatter, _analyzer, queryResults, result, queries) => {
297
336
  const out = queryResults;
298
337
  result.push((0, query_print_1.queryHeader)('config', formatter, out['.meta'].timing));
@@ -1,9 +1,12 @@
1
- import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
1
+ import type { BaseQueryFormat, BaseQueryResult, BasicQueryData } from '../../base-query-format';
2
2
  import Joi from 'joi';
3
- import { executeControlFlowQuery } from './control-flow-query-executor';
4
3
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
4
  import { type ControlFlowInformation } from '../../../control-flow/control-flow-graph';
6
5
  import { type CfgSimplificationPassName } from '../../../control-flow/cfg-simplification';
6
+ /**
7
+ * Executes the control flow query with the given simplification passes.
8
+ */
9
+ export declare function executeControlFlowQuery({ analyzer }: BasicQueryData, queries: readonly ControlFlowQuery[]): Promise<ControlFlowQueryResult>;
7
10
  /**
8
11
  * Provides the control flow graph with an optional, fixed configuration
9
12
  */
@@ -4,15 +4,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ControlFlowQueryDefinition = void 0;
7
+ exports.executeControlFlowQuery = executeControlFlowQuery;
7
8
  const ansi_1 = require("../../../util/text/ansi");
8
9
  const joi_1 = __importDefault(require("joi"));
9
- const control_flow_query_executor_1 = require("./control-flow-query-executor");
10
10
  const control_flow_graph_1 = require("../../../control-flow/control-flow-graph");
11
11
  const cfg_1 = require("../../../util/mermaid/cfg");
12
12
  const cfg_simplification_1 = require("../../../control-flow/cfg-simplification");
13
+ const log_1 = require("../../../util/log");
14
+ const query_meta_1 = require("../../query-meta");
15
+ /**
16
+ * Executes the control flow query with the given simplification passes.
17
+ */
18
+ async function executeControlFlowQuery({ analyzer }, queries) {
19
+ if (queries.length !== 1) {
20
+ log_1.log.warn('The control flow query expects only up to one query, but got', queries.length);
21
+ }
22
+ const query = queries[0];
23
+ const start = Date.now();
24
+ const controlFlow = await analyzer.controlflow(query.config?.simplificationPasses);
25
+ return {
26
+ ...(0, query_meta_1.metaSince)(start),
27
+ controlFlow
28
+ };
29
+ }
13
30
  exports.ControlFlowQueryDefinition = {
14
31
  title: 'Control-Flow Query',
15
- executor: control_flow_query_executor_1.executeControlFlowQuery,
32
+ executor: executeControlFlowQuery,
16
33
  asciiSummarizer: async (formatter, analyzer, queryResults, result) => {
17
34
  const out = queryResults;
18
35
  result.push(`Query: ${(0, ansi_1.bold)('control-flow', formatter)} (${out['.meta'].timing.toFixed(0)}ms)`);