@eagleoutice/flowr 2.11.1 → 2.12.1

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 (264) hide show
  1. package/README.md +187 -257
  2. package/abstract-interpretation/absint-visitor.d.ts +1 -0
  3. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
  4. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  5. package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
  6. package/benchmark/slicer.d.ts +1 -1
  7. package/benchmark/slicer.js +3 -1
  8. package/benchmark/summarizer/second-phase/graph.js +5 -0
  9. package/cli/common/options.d.ts +8 -0
  10. package/cli/common/options.js +2 -0
  11. package/cli/common/scripts-info.d.ts +8 -0
  12. package/cli/repl/commands/repl-commands.d.ts +1 -0
  13. package/cli/repl/commands/repl-commands.js +66 -15
  14. package/cli/repl/commands/repl-dataflow.js +48 -4
  15. package/cli/repl/commands/repl-main.d.ts +2 -0
  16. package/cli/repl/commands/repl-main.js +5 -0
  17. package/cli/repl/commands/repl-query.d.ts +4 -1
  18. package/cli/repl/commands/repl-query.js +72 -22
  19. package/cli/repl/commands/repl-signature.d.ts +7 -0
  20. package/cli/repl/commands/repl-signature.js +119 -0
  21. package/cli/repl/core.d.ts +8 -1
  22. package/cli/repl/core.js +46 -6
  23. package/cli/repl/ghost-hint.d.ts +37 -0
  24. package/cli/repl/ghost-hint.js +72 -0
  25. package/cli/repl/parser/slice-query-parser.d.ts +11 -1
  26. package/cli/repl/parser/slice-query-parser.js +45 -16
  27. package/cli/repl/print-version.d.ts +2 -4
  28. package/cli/repl/print-version.js +41 -23
  29. package/cli/repl/server/connection.js +19 -17
  30. package/cli/slicer-app.d.ts +2 -0
  31. package/cli/slicer-app.js +3 -3
  32. package/cli/wiki.d.ts +2 -2
  33. package/cli/wiki.js +2 -2
  34. package/config.d.ts +63 -2
  35. package/config.js +64 -8
  36. package/control-flow/cfg-dead-code.js +0 -1
  37. package/control-flow/control-flow-graph.js +6 -6
  38. package/control-flow/diff-cfg.js +2 -2
  39. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  40. package/core/print/slice-diff-ansi.js +8 -8
  41. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  42. package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
  43. package/core/steps/all/static-slicing/00-slice.js +1 -1
  44. package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
  45. package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
  46. package/core/steps/pipeline/default-pipelines.d.ts +20 -16
  47. package/data/r-base-packages.generated.d.ts +44 -0
  48. package/data/r-base-packages.generated.js +32 -0
  49. package/data/r-base-primitives.generated.d.ts +1 -0
  50. package/data/r-base-primitives.generated.js +15 -0
  51. package/data/sigdb/sigdb.remote.json +112 -0
  52. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  53. package/dataflow/environments/built-in-proc-name.js +4 -0
  54. package/dataflow/environments/built-in.d.ts +14 -4
  55. package/dataflow/environments/built-in.js +13 -2
  56. package/dataflow/environments/data-masking-functions.d.ts +12 -0
  57. package/dataflow/environments/data-masking-functions.js +46 -0
  58. package/dataflow/environments/default-builtin-config.d.ts +72 -19
  59. package/dataflow/environments/default-builtin-config.js +48 -14
  60. package/dataflow/environments/diff.js +1 -1
  61. package/dataflow/environments/environment.js +1 -2
  62. package/dataflow/environments/identifier.d.ts +11 -4
  63. package/dataflow/environments/identifier.js +28 -10
  64. package/dataflow/environments/resolve-by-name.js +16 -2
  65. package/dataflow/extractor.js +6 -3
  66. package/dataflow/graph/call-graph.d.ts +2 -2
  67. package/dataflow/graph/df-helper.d.ts +4 -4
  68. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  69. package/dataflow/graph/edge.d.ts +3 -3
  70. package/dataflow/graph/edge.js +3 -3
  71. package/dataflow/graph/graph-helper.d.ts +2 -2
  72. package/dataflow/internal/linker.js +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
  74. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
  77. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
  81. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
  86. package/dataflow/internal/process/functions/call/common.js +8 -1
  87. package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
  90. package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
  91. package/dataflow/internal/process/functions/process-argument.js +12 -1
  92. package/dataflow/internal/process/process-named-call.d.ts +18 -1
  93. package/dataflow/internal/process/process-named-call.js +94 -0
  94. package/dataflow/processor.d.ts +18 -0
  95. package/documentation/data/faq/faqs.js +5 -1
  96. package/documentation/doc-capabilities.js +1 -1
  97. package/documentation/doc-util/doc-cli-option.d.ts +10 -0
  98. package/documentation/doc-util/doc-cli-option.js +23 -0
  99. package/documentation/doc-util/doc-dfg.js +2 -1
  100. package/documentation/doc-util/doc-query.d.ts +9 -3
  101. package/documentation/doc-util/doc-query.js +9 -4
  102. package/documentation/wiki-dataflow-graph.js +8 -5
  103. package/documentation/wiki-interface.js +4 -2
  104. package/documentation/wiki-linter.js +1 -1
  105. package/documentation/wiki-linting-and-testing.js +4 -1
  106. package/documentation/wiki-mk/doc-context.d.ts +14 -0
  107. package/documentation/wiki-mk/doc-context.js +3 -0
  108. package/documentation/wiki-mk/doc-maker.js +3 -1
  109. package/documentation/wiki-query.js +36 -15
  110. package/documentation/wiki-setup.js +10 -7
  111. package/documentation/wiki-signature-database.d.ts +16 -0
  112. package/documentation/wiki-signature-database.js +293 -0
  113. package/linter/linter-format.d.ts +7 -0
  114. package/linter/linter-rules.d.ts +10 -9
  115. package/linter/rules/naming-convention.d.ts +1 -0
  116. package/linter/rules/naming-convention.js +2 -0
  117. package/linter/rules/no-leaked-credentials.js +1 -2
  118. package/linter/rules/roxygen-arguments.js +18 -5
  119. package/linter/rules/stop-with-call-arg.js +2 -2
  120. package/linter/rules/undefined-symbol-util.d.ts +36 -0
  121. package/linter/rules/undefined-symbol-util.js +149 -0
  122. package/linter/rules/undefined-symbol.d.ts +58 -17
  123. package/linter/rules/undefined-symbol.js +143 -33
  124. package/linter/rules/unused-definition.d.ts +8 -1
  125. package/linter/rules/unused-definition.js +126 -1
  126. package/package.json +22 -10
  127. package/project/context/abstract-flowr-analyzer-context.js +7 -1
  128. package/project/context/flowr-analyzer-context.d.ts +8 -0
  129. package/project/context/flowr-analyzer-context.js +10 -0
  130. package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
  131. package/project/context/flowr-analyzer-dependencies-context.js +51 -2
  132. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  133. package/project/context/flowr-analyzer-files-context.js +2 -1
  134. package/project/context/flowr-analyzer-functions-context.js +1 -1
  135. package/project/context/flowr-file.d.ts +5 -0
  136. package/project/context/flowr-file.js +5 -0
  137. package/project/flowr-analyzer-builder.js +12 -2
  138. package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
  139. package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
  140. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
  141. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
  142. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
  147. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
  148. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
  149. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
  150. package/project/plugins/package-version-plugins/package.d.ts +5 -3
  151. package/project/plugins/package-version-plugins/package.js +27 -25
  152. package/project/plugins/plugin-registry.d.ts +3 -2
  153. package/project/plugins/plugin-registry.js +4 -2
  154. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
  155. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
  156. package/project/sigdb/build.d.ts +131 -0
  157. package/project/sigdb/build.js +628 -0
  158. package/project/sigdb/codec.d.ts +51 -0
  159. package/project/sigdb/codec.js +122 -0
  160. package/project/sigdb/decode.d.ts +58 -0
  161. package/project/sigdb/decode.js +129 -0
  162. package/project/sigdb/decompress.d.ts +44 -0
  163. package/project/sigdb/decompress.js +176 -0
  164. package/project/sigdb/hash.d.ts +9 -0
  165. package/project/sigdb/hash.js +54 -0
  166. package/project/sigdb/index-format.d.ts +40 -0
  167. package/project/sigdb/index-format.js +28 -0
  168. package/project/sigdb/manifest.d.ts +68 -0
  169. package/project/sigdb/manifest.js +146 -0
  170. package/project/sigdb/reader.d.ts +250 -0
  171. package/project/sigdb/reader.js +692 -0
  172. package/project/sigdb/schema.d.ts +196 -0
  173. package/project/sigdb/schema.js +33 -0
  174. package/project/sigdb/sigdb-download.d.ts +65 -0
  175. package/project/sigdb/sigdb-download.js +237 -0
  176. package/project/sigdb/signature-match.d.ts +26 -0
  177. package/project/sigdb/signature-match.js +40 -0
  178. package/project/sigdb/version.d.ts +20 -0
  179. package/project/sigdb/version.js +55 -0
  180. package/queries/catalog/absint-query/absint-query-executor.d.ts +6 -0
  181. package/queries/catalog/absint-query/absint-query-executor.js +63 -0
  182. package/queries/catalog/absint-query/absint-query-format.d.ts +37 -0
  183. package/queries/catalog/absint-query/absint-query-format.js +102 -0
  184. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
  185. package/queries/catalog/config-query/config-query-format.d.ts +3 -1
  186. package/queries/catalog/config-query/config-query-format.js +68 -9
  187. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
  188. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  189. package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
  190. package/queries/catalog/linter-query/linter-query-executor.js +6 -1
  191. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
  192. package/queries/catalog/linter-query/linter-query-format.js +40 -8
  193. package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
  194. package/queries/catalog/project-query/project-query-executor.js +96 -4
  195. package/queries/catalog/project-query/project-query-format.d.ts +44 -0
  196. package/queries/catalog/project-query/project-query-format.js +33 -2
  197. package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
  198. package/queries/catalog/signature-query/signature-query-executor.js +461 -0
  199. package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
  200. package/queries/catalog/signature-query/signature-query-format.js +76 -0
  201. package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
  202. package/queries/catalog/signature-query/signature-query-render.js +155 -0
  203. package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
  204. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
  205. package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
  206. package/queries/query-print.js +5 -0
  207. package/queries/query.d.ts +15 -5
  208. package/queries/query.js +7 -4
  209. package/r-bridge/init.js +5 -1
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
  212. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
  213. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
  214. package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
  215. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
  216. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
  217. package/r-bridge/parser.d.ts +2 -0
  218. package/r-bridge/retriever.js +4 -1
  219. package/r-bridge/roxygen2/documentation-provider.js +2 -1
  220. package/r-bridge/shell.d.ts +5 -0
  221. package/r-bridge/shell.js +17 -1
  222. package/reconstruct/inline/source-inline-map.d.ts +48 -0
  223. package/reconstruct/inline/source-inline-map.js +94 -0
  224. package/reconstruct/reconstruct.d.ts +19 -2
  225. package/reconstruct/reconstruct.js +79 -16
  226. package/search/search-executor/search-generators.js +5 -22
  227. package/search/search-executor/search-transformer.js +10 -6
  228. package/slicing/criterion/parse.d.ts +28 -4
  229. package/slicing/criterion/parse.js +133 -18
  230. package/slicing/static/slice-call.d.ts +24 -1
  231. package/slicing/static/slice-call.js +90 -0
  232. package/slicing/static/static-slicer.d.ts +7 -0
  233. package/slicing/static/static-slicer.js +38 -3
  234. package/util/collections/arrays.d.ts +4 -5
  235. package/util/collections/arrays.js +7 -18
  236. package/util/hash.d.ts +14 -0
  237. package/util/hash.js +31 -0
  238. package/util/mermaid/dfg.d.ts +7 -2
  239. package/util/mermaid/dfg.js +53 -13
  240. package/util/r-base-packages.d.ts +19 -0
  241. package/util/r-base-packages.js +72 -0
  242. package/util/r-license.js +2 -10
  243. package/util/r-version.d.ts +45 -15
  244. package/util/r-version.js +97 -36
  245. package/util/range.d.ts +15 -0
  246. package/util/range.js +39 -0
  247. package/util/schema.d.ts +10 -0
  248. package/util/schema.js +22 -0
  249. package/util/text/ansi.d.ts +3 -0
  250. package/util/text/ansi.js +10 -0
  251. package/util/text/args.js +1 -2
  252. package/util/version.js +28 -8
  253. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  254. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  255. package/documentation/wiki-package-database.d.ts +0 -9
  256. package/documentation/wiki-package-database.js +0 -63
  257. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
  258. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
  259. package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
  260. package/project/plugins/package-version-plugins/pkgdb.js +0 -370
  261. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +0 -6
  262. package/queries/catalog/df-shape-query/df-shape-query-executor.js +0 -58
  263. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +0 -27
  264. package/queries/catalog/df-shape-query/df-shape-query-format.js +0 -56
@@ -1,7 +1,12 @@
1
1
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
2
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
- /** Either `line:column`, `line@variable-name`, or `$id` */
4
- export type SlicingCriterion = `${number}:${number}` | `${number}@${string}` | `$${NodeId | number}`;
3
+ /** An optional `(file-regex)` suffix restricting a criterion to nodes stemming from a matching file. */
4
+ type FileFilterSuffix = '' | `(${string})`;
5
+ /**
6
+ * Either `line:column`, `line~column`, `line@variable-name`, or `$id`; all but `$id` accept a trailing
7
+ * `(file-regex)`. See {@link SlicingCriterion.tryParse} for what each of them resolves to.
8
+ */
9
+ export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
5
10
  /**
6
11
  * The helper object associated with {@link SlicingCriterion} which makes it easy
7
12
  * to parse, validate and resolve slicing criteria.
@@ -9,12 +14,29 @@ export type SlicingCriterion = `${number}:${number}` | `${number}@${string}` | `
9
14
  export declare const SlicingCriterion: {
10
15
  readonly name: "SlicingCriterion";
11
16
  /**
12
- * Takes a criterion in the form of `line:column` or `line@variable-name` and returns the corresponding node id
17
+ * Checks whether a value has a valid slicing criterion syntax.
18
+ * This does not check whether the slicing criterion exists (represents a valid node ID).
19
+ * @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
20
+ */
21
+ readonly isValid: (this: void, criterion: unknown) => criterion is SlicingCriterion;
22
+ /**
23
+ * Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
13
24
  * @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
14
25
  */
15
26
  readonly parse: (this: void, criterion: SlicingCriterion, idMap: AstIdMap) => NodeId;
16
27
  /**
17
28
  * Tries to resolve a slicing criterion to an id, but does not throw an error if it fails.
29
+ *
30
+ * | Criterion | Resolves to |
31
+ * | --------- | ----------- |
32
+ * | `2@x` | `x` in line 2, preferring a call over the symbol it refers to |
33
+ * | `2@[3]x` | the 3rd occurrence of `x` in line 2 (by column); `[-1]` for the last |
34
+ * | `2:5` | the element *starting* at line 2, column 5 |
35
+ * | `2~5` | the innermost element *containing* line 2, column 5 |
36
+ * | `$42` | the node with the normalized id 42 |
37
+ *
38
+ * A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
39
+ * accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
18
40
  * @see {@link SlicingCriterion.parse} for the version that throws an error
19
41
  */
20
42
  readonly tryParse: (this: void, criterion: SlicingCriterion | NodeId, idMap: AstIdMap) => NodeId | undefined;
@@ -24,7 +46,8 @@ export declare const SlicingCriterion: {
24
46
  readonly fromId: (this: void, id: NodeId) => SlicingCriterion;
25
47
  };
26
48
  /**
27
- * A slicing criterion is a list of single slicing criteria, which can be in the form of `line:column`, `line@variable-name`, or `$id`.
49
+ * A slicing criterion is a list of single slicing criteria, which can be in the form of `line:column`,
50
+ * `line~column`, `line@variable-name`, or `$id`.
28
51
  */
29
52
  export type SlicingCriteria = SlicingCriterion[];
30
53
  export interface DecodedCriterion {
@@ -54,3 +77,4 @@ export declare const SlicingCriteria: {
54
77
  export declare class CriteriaParseError extends Error {
55
78
  constructor(message: string);
56
79
  }
80
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CriteriaParseError = exports.SlicingCriteria = exports.SlicingCriterion = void 0;
4
+ const range_1 = require("../../util/range");
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 static_slicer_1 = require("../static/static-slicer");
@@ -12,7 +13,15 @@ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
12
13
  exports.SlicingCriterion = {
13
14
  name: 'SlicingCriterion',
14
15
  /**
15
- * Takes a criterion in the form of `line:column` or `line@variable-name` and returns the corresponding node id
16
+ * Checks whether a value has a valid slicing criterion syntax.
17
+ * This does not check whether the slicing criterion exists (represents a valid node ID).
18
+ * @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
19
+ */
20
+ isValid(criterion) {
21
+ return typeof criterion === 'string' && criterion.match(/^\d+:\d+|\d+@.+|\$.+$/) !== null;
22
+ },
23
+ /**
24
+ * Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
16
25
  * @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
17
26
  */
18
27
  parse(criterion, idMap) {
@@ -24,6 +33,17 @@ exports.SlicingCriterion = {
24
33
  },
25
34
  /**
26
35
  * Tries to resolve a slicing criterion to an id, but does not throw an error if it fails.
36
+ *
37
+ * | Criterion | Resolves to |
38
+ * | --------- | ----------- |
39
+ * | `2@x` | `x` in line 2, preferring a call over the symbol it refers to |
40
+ * | `2@[3]x` | the 3rd occurrence of `x` in line 2 (by column); `[-1]` for the last |
41
+ * | `2:5` | the element *starting* at line 2, column 5 |
42
+ * | `2~5` | the innermost element *containing* line 2, column 5 |
43
+ * | `$42` | the node with the normalized id 42 |
44
+ *
45
+ * A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
46
+ * accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
27
47
  * @see {@link SlicingCriterion.parse} for the version that throws an error
28
48
  */
29
49
  tryParse(criterion, idMap) {
@@ -31,15 +51,31 @@ exports.SlicingCriterion = {
31
51
  if (criterion.startsWith('$')) {
32
52
  return node_id_1.NodeId.normalize(criterion.substring(1));
33
53
  }
34
- else if (criterion.includes('@')) {
35
- const at = criterion.indexOf('@');
36
- const line = parseInt(criterion.substring(0, at));
37
- const name = criterion.substring(at + 1);
38
- return conventionalCriteriaToId(line, name, idMap);
54
+ const split = splitFileFilter(criterion);
55
+ if (split === undefined) {
56
+ return undefined; // a malformed file filter must not silently resolve without it
57
+ }
58
+ const { rest: base, file } = split;
59
+ if (base.includes('@')) {
60
+ const at = base.indexOf('@');
61
+ const line = parseLineNumber(base.substring(0, at), idMap, file);
62
+ const name = base.substring(at + 1);
63
+ if (line === undefined || name.length === 0) {
64
+ return undefined;
65
+ }
66
+ // an optional `[n]` prefix picks the n-th occurrence within the line (`2@[2]a`, `2@[-1]a` for the last one)
67
+ const nth = /^\[(-?\d+)](.+)$/.exec(name);
68
+ return nth ?
69
+ nthOccurrenceToId(line, nth[2], idMap, parseInt(nth[1]), file) :
70
+ nthOccurrenceToId(line, name, idMap, 1, file);
71
+ }
72
+ else if (base.includes(':')) {
73
+ const location = parseLocation(base, ':', idMap, file);
74
+ return location && locationToId(location, idMap, file);
39
75
  }
40
- else if (criterion.includes(':')) {
41
- const [line, column] = criterion.split(':').map(c => parseInt(c));
42
- return locationToId([line, column], idMap);
76
+ else if (base.includes('~')) {
77
+ const location = parseLocation(base, '~', idMap, file);
78
+ return location && fuzzyLocationToId(location, idMap, file);
43
79
  }
44
80
  },
45
81
  /**
@@ -79,10 +115,10 @@ class CriteriaParseError extends Error {
79
115
  }
80
116
  }
81
117
  exports.CriteriaParseError = CriteriaParseError;
82
- function locationToId(location, dataflowIdMap) {
118
+ function locationToId(location, dataflowIdMap, file) {
83
119
  let candidate;
84
120
  for (const [id, nodeInfo] of dataflowIdMap.entries()) {
85
- if (nodeInfo.location === undefined || nodeInfo.location[0] !== location[0] || nodeInfo.location[1] !== location[1]) {
121
+ if (nodeInfo.location === undefined || nodeInfo.location[0] !== location[0] || nodeInfo.location[1] !== location[1] || !matchesFile(nodeInfo, file)) {
86
122
  continue; // only consider those with position information
87
123
  }
88
124
  (0, log_1.expensiveTrace)(static_slicer_1.slicerLogger, () => `can resolve id ${id} (${JSON.stringify(nodeInfo.location)}) for location ${JSON.stringify(location)}`);
@@ -94,18 +130,97 @@ function locationToId(location, dataflowIdMap) {
94
130
  }
95
131
  return candidate?.info.id;
96
132
  }
97
- function conventionalCriteriaToId(line, name, dataflowIdMap) {
98
- let candidate;
133
+ /**
134
+ * Resolves a `line~column` criterion: unlike {@link locationToId}, which wants a node *starting* exactly there,
135
+ * this accepts any node whose source range *contains* the position and returns the innermost of them (the same
136
+ * matching the search API performs for `fuzzy` with `innermostOnly`).
137
+ */
138
+ function fuzzyLocationToId(location, dataflowIdMap, file) {
139
+ const potentials = [...dataflowIdMap.values()].filter(nodeInfo =>
140
+ // arguments and expression lists only wrap their content, sharing its range, so they never say more than it
141
+ nodeInfo.type !== type_1.RType.Argument && nodeInfo.type !== type_1.RType.ExpressionList && matchesFile(nodeInfo, file));
142
+ /* a call shares its range with the symbol naming it, so keep both (`treatChildAsInner: false`) and let the
143
+ * preference below decide, rather than always landing on the symbol */
144
+ const candidates = range_1.SourceRange.innermostNodes(range_1.SourceRange.nodesContaining(potentials, location[0], location[1]), false);
145
+ // prefer the call over the symbol it refers to, exactly as locationToId does
146
+ return (candidates.find(n => n.type === type_1.RType.FunctionCall) ?? candidates[0])?.info.id;
147
+ }
148
+ /**
149
+ * Splits the optional trailing `(file-regex)` off a criterion (e.g. `2@x(tmp/.*)`), which restricts it to nodes
150
+ * originating from a matching file. Returns `undefined` if the regex is malformed.
151
+ */
152
+ function splitFileFilter(criterion) {
153
+ const match = /^(.*)\(([^()]*)\)$/.exec(criterion);
154
+ if (match === null) {
155
+ return { rest: criterion, file: undefined };
156
+ }
157
+ try {
158
+ return { rest: match[1], file: new RegExp(match[2]) };
159
+ }
160
+ catch {
161
+ return undefined;
162
+ }
163
+ }
164
+ /** Whether the node stems from a file matching the criterion's `(file-regex)` suffix (if any). */
165
+ function matchesFile(nodeInfo, file) {
166
+ return file === undefined || file.test(nodeInfo.info.file ?? '');
167
+ }
168
+ /**
169
+ * The last line covered by the given AST (restricted to `file`), used to resolve lines counted from the end.
170
+ */
171
+ function lastLineOf(dataflowIdMap, file) {
172
+ let last = 0;
99
173
  for (const nodeInfo of dataflowIdMap.values()) {
100
- if (nodeInfo.location === undefined || nodeInfo.location[0] !== line || nodeInfo.lexeme !== name) {
174
+ const range = range_1.SourceRange.fromNode(nodeInfo);
175
+ if (range !== undefined && range[2] > last && matchesFile(nodeInfo, file)) {
176
+ last = range[2];
177
+ }
178
+ }
179
+ return last;
180
+ }
181
+ /**
182
+ * Parses the line part of a criterion, resolving a negative line (`-1` being the last line) against the AST.
183
+ * Returns `undefined` if it is not a number at all (e.g. `x@y`), so the criterion can be rejected as invalid.
184
+ */
185
+ function parseLineNumber(text, dataflowIdMap, file) {
186
+ if (!/^-?\d+$/.test(text)) {
187
+ return undefined;
188
+ }
189
+ const line = parseInt(text);
190
+ return line < 0 ? lastLineOf(dataflowIdMap, file) + line + 1 : line;
191
+ }
192
+ /** Parses a `line<sep>column` criterion, rejecting anything that is not a pair of numbers. */
193
+ function parseLocation(criterion, separator, dataflowIdMap, file) {
194
+ const parts = criterion.split(separator);
195
+ if (parts.length !== 2 || !/^\d+$/.test(parts[1])) {
196
+ return undefined;
197
+ }
198
+ const line = parseLineNumber(parts[0], dataflowIdMap, file);
199
+ return line === undefined ? undefined : [line, parseInt(parts[1])];
200
+ }
201
+ /**
202
+ * Resolves the `nth` occurrence of `name` in the given line (as written by the optional `[n]` prefix of
203
+ * `line@[n]name`); `n` is 1-based and may be negative to count from the end of the line (`-1` being the last).
204
+ * Occurrences are counted by column, as a function call and the symbol it refers to share a position and are
205
+ * thus one and the same occurrence.
206
+ */
207
+ function nthOccurrenceToId(line, name, dataflowIdMap, nth, file) {
208
+ const byColumn = new Map();
209
+ for (const nodeInfo of dataflowIdMap.values()) {
210
+ if (nodeInfo.location === undefined || nodeInfo.location[0] !== line || nodeInfo.lexeme !== name || !matchesFile(nodeInfo, file)) {
101
211
  continue;
102
212
  }
103
- // function calls have the same location as the symbol they refer to, so we need to prefer the function call
104
- if (candidate !== undefined && nodeInfo.type !== type_1.RType.FunctionCall || nodeInfo.type === type_1.RType.Argument || nodeInfo.type === type_1.RType.ExpressionList) {
213
+ if (nodeInfo.type === type_1.RType.Argument || nodeInfo.type === type_1.RType.ExpressionList) {
105
214
  continue;
106
215
  }
107
- candidate = nodeInfo;
216
+ const column = nodeInfo.location[1];
217
+ // function calls have the same location as the symbol they refer to, so we need to prefer the function call
218
+ if (!byColumn.has(column) || nodeInfo.type === type_1.RType.FunctionCall) {
219
+ byColumn.set(column, nodeInfo);
220
+ }
108
221
  }
109
- return candidate?.info.id;
222
+ const columns = [...byColumn.keys()].sort((a, b) => a - b);
223
+ const index = nth < 0 ? columns.length + nth : nth - 1;
224
+ return index >= 0 && index < columns.length ? byColumn.get(columns[index])?.info.id : undefined;
110
225
  }
111
226
  //# sourceMappingURL=parse.js.map
@@ -1,17 +1,40 @@
1
1
  import type { NodeToSlice } from './slicer-types';
2
2
  import type { VisitingQueue } from './visiting-queue';
3
3
  import { type Fingerprint } from './fingerprint';
4
- import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
4
+ import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
5
5
  import type { REnvironmentInformation } from '../../dataflow/environments/environment';
6
6
  import { type DataflowGraph, type OutgoingEdges } from '../../dataflow/graph/graph';
7
7
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { DataflowInformation } from '../../dataflow/info';
9
9
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
10
+ import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
10
11
  /**
11
12
  * Returns the function call targets (definitions) by the given caller
12
13
  */
13
14
  export declare function getAllFunctionCallTargetsForSlice(dataflowGraph: DataflowGraph, callerInfo: DataflowGraphVertexFunctionCall, baseEnvironment: REnvironmentInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): [Set<DataflowGraphVertexInfo>, REnvironmentInformation];
14
15
  /** returns the new threshold hit count */
15
16
  export declare function sliceForCall(current: NodeToSlice, callerInfo: DataflowGraphVertexFunctionCall, { graph }: DataflowInformation, queue: VisitingQueue, ctx: ReadOnlyFlowrAnalyzerContext): void;
17
+ /**
18
+ * Finds the nearest enclosing function-definition node for the given id by walking up the AST parent chain.
19
+ * Used by `includeCallees` to detect the function-definition boundary a node sits inside, as backward slicing
20
+ * does not otherwise visit the function-definition vertex itself (nothing within the body links to it).
21
+ */
22
+ export declare function findEnclosingFunctionDefinition(id: NodeId, idMap: AstIdMap): NodeId | undefined;
23
+ /**
24
+ * For `includeCallees`: decides whether the current slice of a function definition's body actually depends on
25
+ * the function's interface, i.e., whether the callers can influence the sliced result at all. This is the case iff
26
+ * the slice reaches one of the definition's parameters, or it reads a free reference captured from the enclosing
27
+ * scope. If the sliced body is self-contained (only locally-defined variables, no parameter and no captured
28
+ * variable), the callers are irrelevant and the boundary must not be crossed.
29
+ */
30
+ export declare function sliceReachesFunctionInterface(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, idMap: AstIdMap, ctx: ReadOnlyFlowrAnalyzerContext): boolean;
31
+ /**
32
+ * For `includeCallees`: given the id of a function-definition vertex, enqueues the vertex that binds/defines
33
+ * the function (e.g. `f <- function...`, via the `defined-by` edge) as well as all of its call sites (via
34
+ * `calls` edges). Call site arguments are picked up automatically once the call vertex is processed normally,
35
+ * as `argument` edges are always traversed.
36
+ * This is the reverse of what {@link sliceForCall} does for call -\> definition linking.
37
+ */
38
+ export declare function includeCalleesOfDefinition(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, baseEnvironment: REnvironmentInformation, baseEnvFingerprint: Fingerprint): void;
16
39
  /** Returns true if we found at least one return edge */
17
40
  export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges: OutgoingEdges, baseEnvFingerprint: Fingerprint, baseEnvironment: REnvironmentInformation): boolean;
@@ -2,10 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAllFunctionCallTargetsForSlice = getAllFunctionCallTargetsForSlice;
4
4
  exports.sliceForCall = sliceForCall;
5
+ exports.findEnclosingFunctionDefinition = findEnclosingFunctionDefinition;
6
+ exports.sliceReachesFunctionInterface = sliceReachesFunctionInterface;
7
+ exports.includeCalleesOfDefinition = includeCalleesOfDefinition;
5
8
  exports.handleReturns = handleReturns;
6
9
  const assert_1 = require("../../util/assert");
7
10
  const fingerprint_1 = require("./fingerprint");
8
11
  const linker_1 = require("../../dataflow/internal/linker");
12
+ const vertex_1 = require("../../dataflow/graph/vertex");
9
13
  const graph_1 = require("../../dataflow/graph/graph");
10
14
  const resolve_by_name_1 = require("../../dataflow/environments/resolve-by-name");
11
15
  const edge_1 = require("../../dataflow/graph/edge");
@@ -13,6 +17,8 @@ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id"
13
17
  const identifier_1 = require("../../dataflow/environments/identifier");
14
18
  const built_in_function_definition_1 = require("../../dataflow/internal/process/functions/call/built-in/built-in-function-definition");
15
19
  const static_slicer_1 = require("./static-slicer");
20
+ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
21
+ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
16
22
  /**
17
23
  * Returns the function call targets (definitions) by the given caller
18
24
  */
@@ -74,6 +80,90 @@ function sliceForCall(current, callerInfo, { graph }, queue, ctx) {
74
80
  const activeEnvironmentFingerprint = (0, fingerprint_1.envFingerprint)(activeEnvironment);
75
81
  linkCallTargets(current.onlyForSideEffects, functionCallTargets, activeEnvironment, activeEnvironmentFingerprint, queue);
76
82
  }
83
+ /**
84
+ * Finds the nearest enclosing function-definition node for the given id by walking up the AST parent chain.
85
+ * Used by `includeCallees` to detect the function-definition boundary a node sits inside, as backward slicing
86
+ * does not otherwise visit the function-definition vertex itself (nothing within the body links to it).
87
+ */
88
+ function findEnclosingFunctionDefinition(id, idMap) {
89
+ let node = idMap.get(id);
90
+ while (node !== undefined) {
91
+ if (node.type === type_1.RType.FunctionDefinition) {
92
+ return node.info.id;
93
+ }
94
+ node = node.info.parent !== undefined ? idMap.get(node.info.parent) : undefined;
95
+ }
96
+ return undefined;
97
+ }
98
+ /**
99
+ * For `includeCallees`: decides whether the current slice of a function definition's body actually depends on
100
+ * the function's interface, i.e., whether the callers can influence the sliced result at all. This is the case iff
101
+ * the slice reaches one of the definition's parameters, or it reads a free reference captured from the enclosing
102
+ * scope. If the sliced body is self-contained (only locally-defined variables, no parameter and no captured
103
+ * variable), the callers are irrelevant and the boundary must not be crossed.
104
+ */
105
+ function sliceReachesFunctionInterface(fnDefId, graph, queue, idMap, ctx) {
106
+ const vertex = graph.getVertex(fnDefId);
107
+ if (vertex === undefined || vertex.tag !== vertex_1.VertexType.FunctionDefinition) {
108
+ return false;
109
+ }
110
+ // (a) the slice reaches a parameter of this definition
111
+ for (const paramId of Object.keys(vertex.params)) {
112
+ if (queue.hasId(node_id_1.NodeId.normalize(paramId))) {
113
+ return true;
114
+ }
115
+ }
116
+ // (b) a sliced body node captures a variable from the enclosing scope: it links (via `defined-by-on-call`, the
117
+ // closure/argument binding resolved at the call site) to a non-builtin definition that lives outside this body.
118
+ const fnNode = idMap.get(fnDefId);
119
+ const bodyIds = fnNode ? new Set(model_1.RNode.collectAllIds(fnNode)) : new Set();
120
+ for (const bodyId of bodyIds) {
121
+ if (!queue.hasId(bodyId)) {
122
+ continue;
123
+ }
124
+ const outgoing = graph.outgoingEdges(bodyId);
125
+ if (outgoing === undefined) {
126
+ continue;
127
+ }
128
+ for (const [target, edge] of outgoing) {
129
+ if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedByOnCall) && !node_id_1.NodeId.isBuiltIn(target) && !bodyIds.has(target)) {
130
+ return true;
131
+ }
132
+ }
133
+ }
134
+ // (c) fallback for captures that could not be resolved at definition time: an open in-reference that is in the
135
+ // slice and resolves to a non-builtin definition in the enclosing scope.
136
+ const definitionEnvironment = vertex.environment ?? ctx.env.makeCleanEnv();
137
+ for (const open of vertex.subflow.in) {
138
+ if (open.name === undefined || !queue.hasId(open.nodeId)) {
139
+ continue;
140
+ }
141
+ const resolved = (0, resolve_by_name_1.resolveByName)(open.name, definitionEnvironment, open.type ?? identifier_1.ReferenceType.Unknown);
142
+ if (resolved?.some(d => !node_id_1.NodeId.isBuiltIn(d.nodeId))) {
143
+ return true;
144
+ }
145
+ }
146
+ return false;
147
+ }
148
+ const CalleeBoundaryEdges = edge_1.EdgeType.DefinedBy | edge_1.EdgeType.Calls;
149
+ /**
150
+ * For `includeCallees`: given the id of a function-definition vertex, enqueues the vertex that binds/defines
151
+ * the function (e.g. `f <- function...`, via the `defined-by` edge) as well as all of its call sites (via
152
+ * `calls` edges). Call site arguments are picked up automatically once the call vertex is processed normally,
153
+ * as `argument` edges are always traversed.
154
+ * This is the reverse of what {@link sliceForCall} does for call -\> definition linking.
155
+ */
156
+ function includeCalleesOfDefinition(fnDefId, graph, queue, baseEnvironment, baseEnvFingerprint) {
157
+ const ingoing = graph.ingoingEdges(fnDefId);
158
+ if (ingoing === undefined) {
159
+ return;
160
+ }
161
+ for (const [source, edge] of ingoing) {
162
+ if (edge_1.DfEdge.includesType(edge, CalleeBoundaryEdges)) {
163
+ queue.add(source, baseEnvironment, baseEnvFingerprint, false);
164
+ }
165
+ }
166
+ }
77
167
  const PotentialFollowOnReturn = edge_1.EdgeType.DefinesOnCall | edge_1.EdgeType.DefinedByOnCall | edge_1.EdgeType.Argument;
78
168
  /** Returns true if we found at least one return edge */
79
169
  function handleReturns(from, queue, currentEdges, baseEnvFingerprint, baseEnvironment) {
@@ -34,6 +34,13 @@ export interface StaticSliceOptions {
34
34
  * Used by {@link staticDice} to pass a reduced-and-inverted graph in a single allocation.
35
35
  */
36
36
  readonly sliceGraph?: DataflowGraph;
37
+ /**
38
+ * If set (and slicing backward), continue the slice past a function-definition boundary: whenever the
39
+ * slice reaches a node that lives inside a function definition, also include the vertex that binds/defines
40
+ * the function (e.g. `f <- function(...)`) as well as all of its call sites (and their arguments).
41
+ * Defaults to `false` (slicing stops at the function-definition boundary, the historic behavior).
42
+ */
43
+ readonly includeCallees?: boolean;
37
44
  }
38
45
  /**
39
46
  * Computes the node ids to include in a static slice, starting from the given seed ids.
@@ -24,6 +24,11 @@ function staticSlice(options) {
24
24
  const direction = options.direction ?? slice_direction_1.SliceDirection.Backward;
25
25
  const threshold = options.threshold ?? 75;
26
26
  (0, assert_1.guard)(ids.length > 0, 'must have at least one seed id to calculate slice');
27
+ // includeCallees only makes sense on the original (non-reduced) graph, backward
28
+ const trackCallees = (options.includeCallees ?? false) && direction === slice_direction_1.SliceDirection.Backward && sliceGraph === undefined;
29
+ // enclosing function definitions whose callees still need to be considered, mapped to the env to enqueue them in
30
+ const pendingCalleeBoundaries = new Map();
31
+ const resolvedCalleeBoundaries = new Set();
27
32
  let graph;
28
33
  if (sliceGraph !== undefined) {
29
34
  graph = sliceGraph;
@@ -57,15 +62,31 @@ function staticSlice(options) {
57
62
  }
58
63
  }
59
64
  }
60
- while (queue.nonEmpty()) {
65
+ do {
66
+ while (queue.nonEmpty()) {
67
+ processNode();
68
+ }
69
+ // the queue drained: only now do we know the full body slice, so decide per boundary whether the callers
70
+ // can actually influence the result (i.e., the slice reaches a parameter or a captured scope variable).
71
+ // resolving a boundary may enqueue new nodes, hence the surrounding do-while re-enters the traversal.
72
+ resolveCalleeBoundaries();
73
+ } while (queue.nonEmpty());
74
+ function processNode() {
61
75
  const current = queue.next();
62
76
  const { baseEnvironment, id, onlyForSideEffects, envFingerprint: baseEnvFingerprint } = current;
63
77
  const currentInfo = graph.get(id, true);
64
78
  if (currentInfo === undefined) {
65
79
  exports.slicerLogger.warn(`id: ${id} must be in graph but can not be found, keep in slice to be sure`);
66
- continue;
80
+ return;
67
81
  }
68
82
  const [currentVertex, currentEdges] = currentInfo;
83
+ // includeCallees: note the enclosing function definition (if any) so its callees can be considered once the body slice is complete
84
+ if (trackCallees) {
85
+ const enclosingFnDef = (0, slice_call_1.findEnclosingFunctionDefinition)(id, idMap);
86
+ if (enclosingFnDef !== undefined && !resolvedCalleeBoundaries.has(enclosingFnDef) && !pendingCalleeBoundaries.has(enclosingFnDef)) {
87
+ pendingCalleeBoundaries.set(enclosingFnDef, [baseEnvironment, baseEnvFingerprint]);
88
+ }
89
+ }
69
90
  // we only add control dependencies iff 1) we are in different function call or 2) they have, at least, the same nesting as the slicing seed
70
91
  if (currentVertex.cds && currentVertex.cds.length > 0) {
71
92
  const topLevel = graph.isRoot(id) || sliceSeedIds.has(id);
@@ -81,7 +102,7 @@ function staticSlice(options) {
81
102
  }
82
103
  const ret = (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment);
83
104
  if (ret) {
84
- continue;
105
+ return;
85
106
  }
86
107
  }
87
108
  for (const [target, e] of currentEdges) {
@@ -103,6 +124,20 @@ function staticSlice(options) {
103
124
  }
104
125
  }
105
126
  }
127
+ function resolveCalleeBoundaries() {
128
+ if (pendingCalleeBoundaries.size === 0) {
129
+ return;
130
+ }
131
+ const boundaries = [...pendingCalleeBoundaries];
132
+ pendingCalleeBoundaries.clear();
133
+ for (const [fnDefId, [env, fingerprint]] of boundaries) {
134
+ resolvedCalleeBoundaries.add(fnDefId);
135
+ // only continue past the boundary if the callers can actually influence the sliced result
136
+ if ((0, slice_call_1.sliceReachesFunctionInterface)(fnDefId, info.graph, queue, idMap, ctx)) {
137
+ (0, slice_call_1.includeCalleesOfDefinition)(fnDefId, info.graph, queue, env, fingerprint);
138
+ }
139
+ }
140
+ }
106
141
  if (ctx.config.solver.slicer?.autoExtend) {
107
142
  return { ...queue.status(), slicedFor: ids, result: extendSlices(queue.status().result, idMap) };
108
143
  }
@@ -35,17 +35,16 @@ export declare function splitArrayOn<T>(arr: readonly T[], predicate: (elem: T)
35
35
  * and the second one contains all elements for which the predicate returned false.
36
36
  */
37
37
  export declare function partitionArray<T>(arr: readonly T[], predicate: (elem: T) => boolean): [T[], T[]];
38
+ /**
39
+ * {@link partitionArray} for a mutable array.
40
+ */
41
+ export declare function partition<T>(arr: T[], predicate: (elem: T) => boolean): [T[], T[]];
38
42
  /**
39
43
  * Generate all permutations of the given array using Heap's algorithm (with its non-recursive variant).
40
44
  * @param arr - The array to permute
41
45
  * @see getUniqueCombinationsOfSize
42
46
  */
43
47
  export declare function allPermutations<T>(arr: T[]): Generator<T[], void, void>;
44
- /**
45
- * Returns a tuple of two arrays, where the first one contains all elements for which the predicate returned true,
46
- * and the second one contains all elements for which the predicate returned false.
47
- */
48
- export declare function partition<T>(arr: T[], predicate: (elem: T) => boolean): [T[], T[]];
49
48
  /**
50
49
  * Generate all unique combinations of the array with the given size.
51
50
  * In other words, given `[a,b,c]`, as well as `minSize=2` and `maxSize=2`, this will generate `[a,b]`, `[a,c]` and `[b,c]`,
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.splitArrayOn = splitArrayOn;
4
4
  exports.partitionArray = partitionArray;
5
- exports.allPermutations = allPermutations;
6
5
  exports.partition = partition;
6
+ exports.allPermutations = allPermutations;
7
7
  exports.getUniqueCombinationsOfSize = getUniqueCombinationsOfSize;
8
8
  exports.arraySum = arraySum;
9
9
  exports.array2bag = array2bag;
@@ -64,6 +64,12 @@ function partitionArray(arr, predicate) {
64
64
  }
65
65
  return [left, right];
66
66
  }
67
+ /**
68
+ * {@link partitionArray} for a mutable array.
69
+ */
70
+ function partition(arr, predicate) {
71
+ return partitionArray(arr, predicate);
72
+ }
67
73
  /**
68
74
  * Generate all permutations of the given array using Heap's algorithm (with its non-recursive variant).
69
75
  * @param arr - The array to permute
@@ -90,23 +96,6 @@ function* allPermutations(arr) {
90
96
  }
91
97
  }
92
98
  }
93
- /**
94
- * Returns a tuple of two arrays, where the first one contains all elements for which the predicate returned true,
95
- * and the second one contains all elements for which the predicate returned false.
96
- */
97
- function partition(arr, predicate) {
98
- const left = [];
99
- const right = [];
100
- for (const elem of arr) {
101
- if (predicate(elem)) {
102
- left.push(elem);
103
- }
104
- else {
105
- right.push(elem);
106
- }
107
- }
108
- return [left, right];
109
- }
110
99
  /**
111
100
  * Generate all unique combinations of the array with the given size.
112
101
  * In other words, given `[a,b,c]`, as well as `minSize=2` and `maxSize=2`, this will generate `[a,b]`, `[a,c]` and `[b,c]`,
package/util/hash.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Portable, streaming, non-cryptographic 64-bit hash (cyrb53), emitted as 16 hex chars. Feed it in
3
+ * chunks with {@link update} (so callers can hash data larger than a single string) and read the result
4
+ * with {@link digest}. Used for content/update detection where a stable, fast digest is enough; browser-safe
5
+ * (no node `crypto`, so it also works in the bundled/web build).
6
+ *
7
+ * cyrb53 is a public-domain hash by `bryc`.
8
+ */
9
+ export declare class Hash53 {
10
+ private h1;
11
+ private h2;
12
+ update(str: string): this;
13
+ digest(): string;
14
+ }
package/util/hash.js ADDED
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Hash53 = void 0;
4
+ /**
5
+ * Portable, streaming, non-cryptographic 64-bit hash (cyrb53), emitted as 16 hex chars. Feed it in
6
+ * chunks with {@link update} (so callers can hash data larger than a single string) and read the result
7
+ * with {@link digest}. Used for content/update detection where a stable, fast digest is enough; browser-safe
8
+ * (no node `crypto`, so it also works in the bundled/web build).
9
+ *
10
+ * cyrb53 is a public-domain hash by `bryc`.
11
+ */
12
+ class Hash53 {
13
+ h1 = 0xdeadbeef;
14
+ h2 = 0x41c6ce57;
15
+ update(str) {
16
+ for (let i = 0; i < str.length; i++) {
17
+ const ch = str.charCodeAt(i);
18
+ this.h1 = Math.imul(this.h1 ^ ch, 2654435761);
19
+ this.h2 = Math.imul(this.h2 ^ ch, 1597334677);
20
+ }
21
+ return this;
22
+ }
23
+ digest() {
24
+ const h1 = Math.imul(this.h1 ^ (this.h1 >>> 16), 2246822507) ^ Math.imul(this.h2 ^ (this.h2 >>> 13), 3266489909);
25
+ const h2 = Math.imul(this.h2 ^ (this.h2 >>> 16), 2246822507) ^ Math.imul(this.h1 ^ (this.h1 >>> 13), 3266489909);
26
+ // `^` yields a *signed* int32, so coerce each half to unsigned (`>>> 0`) before hex, else a high bit prints a `-`
27
+ return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
28
+ }
29
+ }
30
+ exports.Hash53 = Hash53;
31
+ //# sourceMappingURL=hash.js.map