@eagleoutice/flowr 2.13.9 → 2.13.11

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 (181) hide show
  1. package/README.md +40 -40
  2. package/config.d.ts +50 -2
  3. package/config.js +37 -6
  4. package/dataflow/environments/apply-kill.js +4 -4
  5. package/dataflow/environments/built-in-props.d.ts +28 -4
  6. package/dataflow/environments/built-in-props.js +31 -8
  7. package/dataflow/environments/built-in.d.ts +7 -2
  8. package/dataflow/environments/built-in.js +10 -12
  9. package/dataflow/environments/default-builtin-config.d.ts +46 -6
  10. package/dataflow/environments/default-builtin-config.js +30 -16
  11. package/dataflow/environments/environment.d.ts +16 -0
  12. package/dataflow/environments/environment.js +114 -26
  13. package/dataflow/environments/identifier.d.ts +6 -0
  14. package/dataflow/environments/identifier.js +18 -5
  15. package/dataflow/environments/query-fn-props.js +34 -2
  16. package/dataflow/environments/reference-to-maybe.js +1 -1
  17. package/dataflow/environments/resolve-by-name.js +16 -6
  18. package/dataflow/environments/resolve-helper.d.ts +43 -0
  19. package/dataflow/environments/resolve-helper.js +47 -0
  20. package/dataflow/eval/resolve/alias-tracking.js +45 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +25 -17
  22. package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
  23. package/dataflow/eval/resolve/resolve-strings.js +16 -9
  24. package/dataflow/eval/resolve/resolve.js +3 -1
  25. package/dataflow/graph/call-graph.d.ts +7 -0
  26. package/dataflow/graph/call-graph.js +103 -0
  27. package/dataflow/graph/df-helper.d.ts +50 -1
  28. package/dataflow/graph/df-helper.js +63 -0
  29. package/dataflow/graph/graph.d.ts +5 -8
  30. package/dataflow/graph/graph.js +24 -13
  31. package/dataflow/internal/linker.d.ts +5 -5
  32. package/dataflow/internal/linker.js +31 -92
  33. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  34. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
  35. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
  36. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  40. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
  41. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
  42. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
  43. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
  44. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
  45. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
  46. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
  47. package/documentation/data/faq/faqs.js +1 -1
  48. package/documentation/data/faq/wiki-faq-store.js +3 -2
  49. package/documentation/data/server/doc-data-server-messages.js +1 -1
  50. package/documentation/doc-readme.js +1 -1
  51. package/documentation/doc-util/doc-files.d.ts +5 -0
  52. package/documentation/doc-util/doc-files.js +13 -3
  53. package/documentation/doc-util/doc-sigdb.d.ts +9 -0
  54. package/documentation/doc-util/doc-sigdb.js +32 -0
  55. package/documentation/wiki-analyzer.js +10 -10
  56. package/documentation/wiki-core.js +1 -1
  57. package/documentation/wiki-dataflow-graph.js +3 -3
  58. package/documentation/wiki-interface.js +13 -2
  59. package/documentation/wiki-linting-and-testing.js +13 -13
  60. package/documentation/wiki-mk/doc-context.d.ts +1 -1
  61. package/documentation/wiki-mk/doc-context.js +9 -5
  62. package/documentation/wiki-normalized-ast.js +1 -1
  63. package/documentation/wiki-overview.js +2 -2
  64. package/documentation/wiki-query.js +4 -1
  65. package/documentation/wiki-setup.js +3 -3
  66. package/documentation/wiki-signature-database.js +2 -5
  67. package/gas.d.ts +6 -0
  68. package/gas.js +7 -1
  69. package/linter/linter-rules.d.ts +1 -1
  70. package/linter/rules/syntactically-valid.d.ts +12 -1
  71. package/linter/rules/syntactically-valid.js +88 -17
  72. package/package.json +7 -8
  73. package/project/attached-packages.d.ts +13 -0
  74. package/project/attached-packages.js +30 -0
  75. package/project/context/flowr-analyzer-context.d.ts +15 -0
  76. package/project/context/flowr-analyzer-context.js +14 -3
  77. package/project/context/flowr-analyzer-files-context.d.ts +11 -0
  78. package/project/context/flowr-analyzer-files-context.js +3 -0
  79. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
  80. package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
  81. package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
  82. package/project/context/flowr-analyzer-loading-order-context.js +23 -2
  83. package/project/dependency-version-space.d.ts +33 -11
  84. package/project/dependency-version-space.js +58 -32
  85. package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
  86. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
  87. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
  89. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
  90. package/project/plugins/plugin-registry.d.ts +2 -1
  91. package/project/plugins/plugin-registry.js +2 -0
  92. package/project/sigdb/manifest.js +9 -5
  93. package/project/sigdb/reader.d.ts +20 -0
  94. package/project/sigdb/reader.js +93 -10
  95. package/project/sigdb/signature-match.d.ts +5 -18
  96. package/project/sigdb/signature-match.js +5 -18
  97. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  98. package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
  99. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
  100. package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
  101. package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
  102. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
  103. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
  104. package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
  105. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
  106. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
  107. package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
  108. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
  109. package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
  110. package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
  111. package/queries/catalog/dependencies-query/link-devices.js +104 -0
  112. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
  113. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
  114. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
  115. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
  116. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  117. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
  118. package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
  119. package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
  120. package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
  121. package/queries/catalog/input-sources-query/input-types.js +10 -0
  122. package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
  123. package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
  124. package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
  125. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  126. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
  127. package/queries/catalog/slice-query-options.d.ts +11 -1
  128. package/queries/catalog/slice-query-options.js +8 -4
  129. package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
  130. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
  131. package/queries/query.d.ts +1 -1
  132. package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
  133. package/r-bridge/lang-4.x/ast/model/model.js +44 -0
  134. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
  135. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  136. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
  137. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
  138. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
  139. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
  140. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
  141. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
  142. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
  143. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
  144. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
  145. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
  156. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
  157. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
  158. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  159. package/reconstruct/reconstruct.d.ts +9 -0
  160. package/reconstruct/reconstruct.js +1 -0
  161. package/search/flowr-search-filters.d.ts +25 -1
  162. package/search/flowr-search-filters.js +42 -7
  163. package/search/search-executor/search-generators.js +7 -2
  164. package/search/search-executor/search-transformer.js +4 -1
  165. package/slicing/criterion/parse.d.ts +5 -25
  166. package/slicing/criterion/parse.js +15 -20
  167. package/slicing/static/fingerprint.js +18 -6
  168. package/slicing/static/slice-call.js +2 -2
  169. package/slicing/static/slicer-types.d.ts +10 -0
  170. package/slicing/static/static-slicer.d.ts +1 -1
  171. package/slicing/static/static-slicer.js +29 -6
  172. package/slicing/static/visiting-queue.d.ts +12 -2
  173. package/slicing/static/visiting-queue.js +28 -3
  174. package/util/arg-matching.d.ts +18 -0
  175. package/util/arg-matching.js +70 -0
  176. package/util/collections/bimap.d.ts +21 -1
  177. package/util/collections/bimap.js +43 -7
  178. package/util/r-regex.js +19 -1
  179. package/util/range.d.ts +7 -8
  180. package/util/range.js +10 -11
  181. package/util/version.js +1 -1
@@ -52,6 +52,15 @@ export interface ReconstructionResult {
52
52
  linesWithAutoSelected: number;
53
53
  /** warnings raised while inlining `source()` calls (only set when {@link Selection#inlineSources} is active) */
54
54
  inlineWarnings?: InlineWarning[];
55
+ /**
56
+ * The reconstructed files, in loading order, each with the path it came from (absent for inline code).
57
+ * `code` holds the same parts, joined into one string when only a single file was reconstructed.
58
+ * Not set by the inlinings, whose whole purpose is to produce one self-contained text.
59
+ */
60
+ files?: readonly {
61
+ path: string | undefined;
62
+ code: string;
63
+ }[];
55
64
  }
56
65
  export declare function reconstructToCode(ast: NormalizedAst, selection: Selection & ({
57
66
  inlineSources: true;
@@ -540,6 +540,7 @@ function reconstructToCode(ast, selection, autoSelectIf = auto_select_defaults_1
540
540
  (0, log_1.expensiveTrace)(exports.reconstructLogger, () => `reconstructed ast before string conversion: ${JSON.stringify(results)}`);
541
541
  return {
542
542
  code: indices.length === 1 ? results[0] : results,
543
+ files: indices.map((i, k) => ({ path: ast.ast.files[i].filePath, code: results[k] })),
543
544
  linesWithAutoSelected: linesWithAutoSelected.size
544
545
  };
545
546
  }
@@ -6,6 +6,7 @@ import type { Enrichment } from './search-executor/search-enrichers';
6
6
  import type { DataflowInformation } from '../dataflow/info';
7
7
  import type { BuiltInProcName } from '../dataflow/environments/built-in-proc-name';
8
8
  import type { RoleInParent } from '../r-bridge/lang-4.x/ast/model/processing/role';
9
+ import type { CallProps } from '../dataflow/environments/built-in-props';
9
10
  export type FlowrFilterName = keyof typeof FlowrFilters;
10
11
  interface FlowrFilterWithArgs<Filter extends FlowrFilterName, Args extends FlowrFilterArgs<Filter>> {
11
12
  name: Filter;
@@ -37,7 +38,13 @@ export declare enum FlowrFilter {
37
38
  * Only returns search elements whose file path matches the given regular expression.
38
39
  * This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
39
40
  */
40
- FilePathFilter = "file-path-filter"
41
+ FilePathFilter = "file-path-filter",
42
+ /**
43
+ * Only returns function calls whose {@link CallProp} bits match the given mask, so that _every call that asks
44
+ * the user_ or _every call that closes a device_ can be searched for without naming a single function.
45
+ * This filter accepts {@link CallPropsArgs}.
46
+ */
47
+ CallProps = "call-props"
41
48
  }
42
49
  export type FlowrFilterFunction<T> = (e: FlowrSearchElement<ParentInformation>, args: T, data: {
43
50
  dataflow: DataflowInformation;
@@ -56,6 +63,9 @@ export declare const FlowrFilters: {
56
63
  roleInParent: RoleInParent;
57
64
  }) => boolean;
58
65
  readonly "file-path-filter": (e: FlowrSearchElement<ParentInformation>, args: FilePathFilterArgs) => boolean;
66
+ readonly "call-props": (e: FlowrSearchElement<ParentInformation>, args: CallPropsArgs, data: {
67
+ dataflow: DataflowInformation;
68
+ }) => boolean;
59
69
  };
60
70
  export type FlowrFilterArgs<F extends FlowrFilter> = typeof FlowrFilters[F] extends FlowrFilterFunction<infer Args> ? Args : never;
61
71
  export interface MatchesEnrichmentArgs<E extends Enrichment> {
@@ -77,6 +87,12 @@ export interface OriginKindArgs {
77
87
  export interface FilePathFilterArgs {
78
88
  filePathRegex: string | RegExp;
79
89
  }
90
+ export interface CallPropsArgs {
91
+ /** the {@link CallProp} bits to look for, e.g. `CallProp.User | CallProp.Closes` */
92
+ props: CallProps;
93
+ /** whether a call has to carry every bit of {@link props} or just one of them (the default) */
94
+ matchType?: 'some' | 'every';
95
+ }
80
96
  type ValidFilterTypes<F extends FlowrFilter = FlowrFilter> = FlowrFilterName | FlowrFilterWithArgs<F, FlowrFilterArgs<F>> | RType | VertexType;
81
97
  /**
82
98
  * By default, we provide filter for every {@link RType} and {@link VertexType}.
@@ -146,8 +162,16 @@ interface FilterData {
146
162
  dataflow: DataflowInformation;
147
163
  };
148
164
  }
165
+ /**
166
+ * Resolve a filter expression to the function that tests one element.
167
+ * Nothing here depends on the element, so a search over `n` elements should do this once instead of `n` times:
168
+ * a bare {@link VertexType}/{@link RType} filter otherwise builds a {@link FlowrFilterCombinator} per element.
169
+ * @see {@link evalFilter} - the one-shot form, if you only test a single element
170
+ */
171
+ export declare function prepareFilter<Filter extends FlowrFilter>(filter: FlowrFilterExpression<Filter>): (data: FilterData) => boolean;
149
172
  /**
150
173
  * Evaluates the given filter expression against the provided data.
174
+ * @see {@link prepareFilter} - resolve once when testing more than one element
151
175
  */
152
176
  export declare function evalFilter<Filter extends FlowrFilter>(filter: FlowrFilterExpression<Filter>, data: FilterData): boolean;
153
177
  export {};
@@ -3,12 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.F = exports.FlowrFilterCombinator = exports.FlowrFilters = exports.ValidFlowrFiltersReverse = exports.ValidFlowrFilters = exports.FlowrFilter = void 0;
4
4
  exports.binaryTreeToString = binaryTreeToString;
5
5
  exports.isBinaryTree = isBinaryTree;
6
+ exports.prepareFilter = prepareFilter;
6
7
  exports.evalFilter = evalFilter;
7
8
  const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
8
9
  const vertex_1 = require("../dataflow/graph/vertex");
9
10
  const search_enrichers_1 = require("./search-executor/search-enrichers");
10
11
  const objects_1 = require("../util/objects");
11
12
  const search_generators_1 = require("./search-executor/search-generators");
13
+ const query_fn_props_1 = require("../dataflow/environments/query-fn-props");
14
+ const df_helper_1 = require("../dataflow/graph/df-helper");
15
+ const environment_1 = require("../dataflow/environments/environment");
12
16
  var FlowrFilter;
13
17
  (function (FlowrFilter) {
14
18
  /**
@@ -37,6 +41,12 @@ var FlowrFilter;
37
41
  * This filter accepts {@link FilePathFilterArgs}, which includes the file path regex to test against.
38
42
  */
39
43
  FlowrFilter["FilePathFilter"] = "file-path-filter";
44
+ /**
45
+ * Only returns function calls whose {@link CallProp} bits match the given mask, so that _every call that asks
46
+ * the user_ or _every call that closes a device_ can be searched for without naming a single function.
47
+ * This filter accepts {@link CallPropsArgs}.
48
+ */
49
+ FlowrFilter["CallProps"] = "call-props";
40
50
  })(FlowrFilter || (exports.FlowrFilter = FlowrFilter = {}));
41
51
  exports.ValidFlowrFilters = new Set(Object.values(FlowrFilter));
42
52
  exports.ValidFlowrFiltersReverse = Object.fromEntries(Object.entries(FlowrFilter).map(([k, v]) => [v, k]));
@@ -66,6 +76,20 @@ exports.FlowrFilters = {
66
76
  const file = e.node.info.file;
67
77
  const rx = args.filePathRegex instanceof RegExp ? args.filePathRegex : new RegExp(args.filePathRegex);
68
78
  return rx.test(file ?? '');
79
+ }),
80
+ [FlowrFilter.CallProps]: ((e, args, data) => {
81
+ const graph = data.dataflow.graph;
82
+ const vertex = graph.getVertex(e.node.info.id);
83
+ if (vertex?.tag !== vertex_1.VertexType.FunctionCall) {
84
+ return false;
85
+ }
86
+ /* what the call resolved to decides, as a definition in the analyzed code shadows the built-in; a call
87
+ * flowR settled on the built-ins keeps no environment, and a later redefinition must not speak for it */
88
+ const known = vertex.environment ?? data.dataflow.environment;
89
+ const environment = vertex.onlyBuiltin ? { level: 0, current: environment_1.REnvironment.findBuiltIn(known.current) } : known;
90
+ const name = df_helper_1.Dataflow.qualify(e.node.info.id, graph, false) ?? vertex.name;
91
+ const props = (0, query_fn_props_1.queryFnProps)(name, { environment })?.props ?? 0;
92
+ return args.matchType === 'every' ? (props & args.props) === args.props : (props & args.props) !== 0;
69
93
  })
70
94
  };
71
95
  /**
@@ -208,24 +232,35 @@ function evalTree(tree, data) {
208
232
  return evalVisit[tree.type](tree, data);
209
233
  }
210
234
  /**
211
- * Evaluates the given filter expression against the provided data.
235
+ * Resolve a filter expression to the function that tests one element.
236
+ * Nothing here depends on the element, so a search over `n` elements should do this once instead of `n` times:
237
+ * a bare {@link VertexType}/{@link RType} filter otherwise builds a {@link FlowrFilterCombinator} per element.
238
+ * @see {@link evalFilter} - the one-shot form, if you only test a single element
212
239
  */
213
- function evalFilter(filter, data) {
240
+ function prepareFilter(filter) {
214
241
  if (filter instanceof FlowrFilterCombinator) {
215
- return evalTree(filter.get(), data);
242
+ const tree = filter.get();
243
+ return data => evalTree(tree, data);
216
244
  }
217
245
  else if (typeof filter === 'string' && exports.ValidFlowrFilters.has(filter)) {
218
246
  const handler = exports.FlowrFilters[filter];
219
- return handler(data.element, undefined, data.data);
247
+ return data => handler(data.element, undefined, data.data);
220
248
  }
221
249
  else if (typeof filter === 'object' && 'name' in filter) {
222
250
  const handler = exports.FlowrFilters[filter.name];
223
251
  const args = ('args' in filter ? filter.args : undefined);
224
- return handler(data.element, args, data.data);
252
+ return data => handler(data.element, args, data.data);
225
253
  }
226
254
  else {
227
- const tree = FlowrFilterCombinator.is(filter);
228
- return evalTree(tree.get(), data);
255
+ const tree = FlowrFilterCombinator.is(filter).get();
256
+ return data => evalTree(tree, data);
229
257
  }
230
258
  }
259
+ /**
260
+ * Evaluates the given filter expression against the provided data.
261
+ * @see {@link prepareFilter} - resolve once when testing more than one element
262
+ */
263
+ function evalFilter(filter, data) {
264
+ return prepareFilter(filter)(data);
265
+ }
231
266
  //# sourceMappingURL=flowr-search-filters.js.map
@@ -28,8 +28,13 @@ async function generateAll(data) {
28
28
  }
29
29
  async function getAllNodes(data) {
30
30
  const normalize = await data.normalize();
31
- return [...new Map([...normalize.idMap.values()].map(n => [n.info.id, n]))
32
- .values()];
31
+ // the id map holds some nodes under more than one id, so dedup; filled in place to skip the two
32
+ // intermediate arrays a spread plus `map` would build
33
+ const byId = new Map();
34
+ for (const n of normalize.idMap.values()) {
35
+ byId.set(n.info.id, n);
36
+ }
37
+ return [...byId.values()];
33
38
  }
34
39
  async function generateGet(input, { filter: { line, column, id, name, nameIsRegex, filePathRegex, fuzzy, innermostOnly } }) {
35
40
  const normalize = await input.normalize();
@@ -97,7 +97,10 @@ function getSkip(data, elements, { count }) {
97
97
  }
98
98
  async function getFilter(data, elements, { filter }) {
99
99
  const dataflow = await data.dataflow();
100
- return elements.mutate(e => e.filter(e => (0, flowr_search_filters_1.evalFilter)(filter, { element: e, data: { dataflow } })));
100
+ // neither depends on the element, so build them once rather than n times
101
+ const test = (0, flowr_search_filters_1.prepareFilter)(filter);
102
+ const shared = { dataflow };
103
+ return elements.mutate(e => e.filter(e => test({ element: e, data: shared })));
101
104
  }
102
105
  async function getWith(input, elements, { info, args }) {
103
106
  return (await elements.enrich(input, info, args)).mutate(async (s) => await Promise.all(s.map(e => (0, search_enrichers_1.enrichElement)(e, elements, input, info, args))));
@@ -2,10 +2,7 @@ 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
3
  /** An optional `(file-regex)` suffix restricting a criterion to nodes stemming from a matching file. */
4
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
- */
5
+ /** see {@link SlicingCriterion.tryParse} for what each of these formats resolves to */
9
6
  export type SlicingCriterion = `${number}:${number}${FileFilterSuffix}` | `${number}~${number}${FileFilterSuffix}` | `${number}^${FileFilterSuffix}` | `${number}@${string}` | `$${NodeId | number}`;
10
7
  /**
11
8
  * The helper object associated with {@link SlicingCriterion} which makes it easy
@@ -20,28 +17,14 @@ export declare const SlicingCriterion: {
20
17
  */
21
18
  readonly isValid: (this: void, criterion: unknown) => criterion is SlicingCriterion;
22
19
  /**
23
- * Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
20
+ * Resolves a slicing criterion to the corresponding node id.
24
21
  * @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
25
22
  */
26
23
  readonly parse: (this: void, criterion: SlicingCriterion, idMap: AstIdMap) => NodeId;
27
24
  /**
28
25
  * 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
- * | `2^` | the top-level statement line 2 belongs to, the first one when several share the line |
37
- * | `$42` | the node with the normalized id 42 |
38
- *
39
- * A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
40
- * accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
41
- *
42
- * Lines, columns, and the `[n]` occurrence are all *1-based*, so a `0` anywhere (`2:0`, `0@x`, `2@[0]x`)
43
- * addresses nothing and resolves to `undefined` -- it is not a wildcard for the whole line. A criterion
44
- * always denotes at most a single node; use one criterion per node to select several.
26
+ * The formats and what each of them resolves to are documented in the
27
+ * {@link https://github.com/flowr-analysis/flowr/wiki/Terminology#slicing-criterion|wiki}.
45
28
  * @see {@link SlicingCriterion.parse} for the version that throws an error
46
29
  */
47
30
  readonly tryParse: (this: void, criterion: SlicingCriterion | NodeId, idMap: AstIdMap) => NodeId | undefined;
@@ -50,10 +33,7 @@ export declare const SlicingCriterion: {
50
33
  */
51
34
  readonly fromId: (this: void, id: NodeId) => SlicingCriterion;
52
35
  };
53
- /**
54
- * A slicing criterion is a list of single slicing criteria, which can be in the form of `line:column`,
55
- * `line~column`, `line@variable-name`, or `$id`.
56
- */
36
+ /** several {@link SlicingCriterion}s, all of which are sliced for at once */
57
37
  export type SlicingCriteria = SlicingCriterion[];
58
38
  export interface DecodedCriterion {
59
39
  criterion: SlicingCriterion;
@@ -18,10 +18,18 @@ exports.SlicingCriterion = {
18
18
  * @see {@link SlicingCriterion.parse} to parse a slicing criterion to a node ID
19
19
  */
20
20
  isValid(criterion) {
21
- return typeof criterion === 'string' && /^(-?\d+([:~]\d+|\^|@.+)|\$.+)$/.test(criterion);
21
+ if (typeof criterion !== 'string') {
22
+ return false;
23
+ }
24
+ else if (criterion.startsWith('$')) {
25
+ return criterion.length > 1;
26
+ }
27
+ /* the file filter is optional on every form, so validate what remains once it is split off */
28
+ const split = splitFileFilter(criterion);
29
+ return split !== undefined && /^-?\d+([:~]\d+|\^|@.+)$/.test(split.rest);
22
30
  },
23
31
  /**
24
- * Takes a criterion in the form of `line:column`, `line~column`, or `line@variable-name` and returns the corresponding node id
32
+ * Resolves a slicing criterion to the corresponding node id.
25
33
  * @see {@link SlicingCriterion.tryParse} for a version that does not throw an error
26
34
  */
27
35
  parse(criterion, idMap) {
@@ -33,22 +41,8 @@ exports.SlicingCriterion = {
33
41
  },
34
42
  /**
35
43
  * 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
- * | `2^` | the top-level statement line 2 belongs to, the first one when several share the line |
44
- * | `$42` | the node with the normalized id 42 |
45
- *
46
- * A negative line counts from the end of the input (`-1` being the last line). Every criterion but `$id`
47
- * accepts a trailing `(file-regex)` (e.g. `2@x(tmp/.*)`) restricting it to a matching file.
48
- *
49
- * Lines, columns, and the `[n]` occurrence are all *1-based*, so a `0` anywhere (`2:0`, `0@x`, `2@[0]x`)
50
- * addresses nothing and resolves to `undefined` -- it is not a wildcard for the whole line. A criterion
51
- * always denotes at most a single node; use one criterion per node to select several.
44
+ * The formats and what each of them resolves to are documented in the
45
+ * {@link https://github.com/flowr-analysis/flowr/wiki/Terminology#slicing-criterion|wiki}.
52
46
  * @see {@link SlicingCriterion.parse} for the version that throws an error
53
47
  */
54
48
  tryParse(criterion, idMap) {
@@ -187,10 +181,11 @@ function topLevelStatementToId(line, idMap, file) {
187
181
  }
188
182
  /**
189
183
  * Splits the optional trailing `(file-regex)` off a criterion (e.g. `2@x(tmp/.*)`), which restricts it to nodes
190
- * originating from a matching file. Returns `undefined` if the regex is malformed.
184
+ * originating from a matching file. The regex may contain escaped parentheses (`3^(a\(b\)\.R)`).
185
+ * Returns `undefined` if the regex is malformed.
191
186
  */
192
187
  function splitFileFilter(criterion) {
193
- const match = /^(.*)\(([^()]*)\)$/.exec(criterion);
188
+ const match = /^([^()]*)\(((?:\\.|[^()])*)\)$/.exec(criterion);
194
189
  if (match === null) {
195
190
  return { rest: criterion, file: undefined };
196
191
  }
@@ -15,9 +15,13 @@ const HashOptions = {
15
15
  ignoreUnknown: true,
16
16
  replacer: (v) => (0, environment_1.isDefaultBuiltInEnvironment)(v) ? undefined : v
17
17
  };
18
- /* definitions and frames are shared across the environments a slice builds, and a definition may hold a whole
19
- * environment of its own (`envState`), so each is hashed once instead of on every fingerprint */
18
+ /* definitions, definition maps and frames are shared across the environments a slice builds, and a definition may
19
+ * hold a whole environment of its own (`envState`), so each is hashed once instead of on every fingerprint. The
20
+ * map is keyed separately from the frame because cloning a frame shares its definitions until one side writes
21
+ * (see {@link Environment#clone}): the graph holds many frames per distinct set of definitions, and hashing that
22
+ * set is what costs. */
20
23
  const definitionHashes = new WeakMap();
24
+ const memoryHashes = new WeakMap();
21
25
  const frameHashes = new WeakMap();
22
26
  function definitionHash(definition) {
23
27
  let hash = definitionHashes.get(definition);
@@ -27,15 +31,23 @@ function definitionHash(definition) {
27
31
  }
28
32
  return hash;
29
33
  }
30
- function frameHash(frame) {
31
- let hash = frameHashes.get(frame);
34
+ function memoryHash(memory) {
35
+ let hash = memoryHashes.get(memory);
32
36
  if (hash === undefined) {
33
37
  const entries = [];
34
- for (const [name, definitions] of frame.memory) {
38
+ for (const [name, definitions] of memory) {
35
39
  entries.push(`${String(name)}=${definitions.map(definitionHash).join(',')}`);
36
40
  }
37
41
  entries.sort();
38
- hash = (0, object_hash_1.default)([frame.n, frame.t, frame.closure, frame.globalEnv === true, entries], HashOptions);
42
+ hash = (0, object_hash_1.default)(entries, HashOptions);
43
+ memoryHashes.set(memory, hash);
44
+ }
45
+ return hash;
46
+ }
47
+ function frameHash(frame) {
48
+ let hash = frameHashes.get(frame);
49
+ if (hash === undefined) {
50
+ hash = (0, object_hash_1.default)([frame.n, frame.t, frame.closure, frame.globalEnv === true, memoryHash(frame.memory)], HashOptions);
39
51
  frameHashes.set(frame, hash);
40
52
  }
41
53
  return hash;
@@ -30,7 +30,7 @@ function getAllFunctionCallTargetsForSlice(dataflowGraph, callerInfo, baseEnviro
30
30
  const activeEnvironment = (0, built_in_function_definition_1.retrieveActiveEnvironment)(callerInfo.environment, baseEnvironment, ctx);
31
31
  const name = callerInfo.name;
32
32
  (0, assert_1.guard)(name !== undefined, () => `name of id: ${callerInfo.id} can not be found in id map`);
33
- const functionCallDefs = (0, resolve_by_name_1.resolveByName)(name, activeEnvironment, identifier_1.ReferenceType.Unknown)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.definedAt))?.map(d => d.nodeId) ?? [];
33
+ const functionCallDefs = (0, resolve_by_name_1.resolveByNameAnyType)(name, activeEnvironment)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.definedAt))?.map(d => d.nodeId) ?? [];
34
34
  for (const [target, outgoingEdge] of outgoingEdges[1].entries()) {
35
35
  if (edge_1.DfEdge.includesType(outgoingEdge, edge_1.EdgeType.Calls)) {
36
36
  functionCallDefs.push(target);
@@ -56,7 +56,7 @@ function linkCallTargets(onlyForSideEffects, functionCallTargets, activeEnvironm
56
56
  for (const openIn of functionCallTarget.subflow.in) {
57
57
  // resolve them in the active env
58
58
  if (openIn.name) {
59
- const resolved = (0, resolve_by_name_1.resolveByName)(openIn.name, activeEnvironment, identifier_1.ReferenceType.Unknown);
59
+ const resolved = (0, resolve_by_name_1.resolveByNameAnyType)(openIn.name, activeEnvironment);
60
60
  for (const res of resolved ?? []) {
61
61
  (0, static_slicer_1.updatePotentialAddition)(queue, functionCallTarget.id, res.nodeId, activeEnvironment, activeEnvironmentFingerprint);
62
62
  }
@@ -31,4 +31,14 @@ export interface SliceResult {
31
31
  * The ids of the nodes in the normalized ast that were used as seed ids for slicing. This is a subset of {@link result}.
32
32
  */
33
33
  readonly slicedFor: readonly NodeId[];
34
+ /**
35
+ * Set when the {@link GasFeatureKey.Slicer|gas guard} stopped the traversal before the queue drained, so
36
+ * {@link result} is what was reached until then and not the complete slice.
37
+ */
38
+ readonly stoppedEarly?: boolean;
39
+ /**
40
+ * The names the slice reads without defining them, so running it on its own would fail with
41
+ * `object 'x' not found`. Empty when the slice is closed under the names it uses.
42
+ */
43
+ readonly freeNames?: readonly string[];
34
44
  }
@@ -3,7 +3,7 @@ import type { Fingerprint } from './fingerprint';
3
3
  import { VisitingQueue } from './visiting-queue';
4
4
  import type { NormalizedAst } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
5
  import type { REnvironmentInformation } from '../../dataflow/environments/environment';
6
- import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { DataflowInformation } from '../../dataflow/info';
8
8
  import type { DataflowGraph } from '../../dataflow/graph/graph';
9
9
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
@@ -8,6 +8,7 @@ const assert_1 = require("../../util/assert");
8
8
  const log_1 = require("../../util/log");
9
9
  const visiting_queue_1 = require("./visiting-queue");
10
10
  const slice_call_1 = require("./slice-call");
11
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
11
12
  const vertex_1 = require("../../dataflow/graph/vertex");
12
13
  const edge_1 = require("../../dataflow/graph/edge");
13
14
  const df_helper_1 = require("../../dataflow/graph/df-helper");
@@ -39,7 +40,7 @@ function staticSlice(options) {
39
40
  graph = df_helper_1.Dataflow.invertGraph(graph, ctx.env.makeCleanEnv());
40
41
  }
41
42
  }
42
- const queue = new visiting_queue_1.VisitingQueue(threshold, cache, id => graph.hasVertex(id));
43
+ const queue = new visiting_queue_1.VisitingQueue(threshold, cache, id => graph.hasVertex(id), ctx.gas);
43
44
  let minNesting = Number.MAX_SAFE_INTEGER;
44
45
  const sliceSeedIds = new Set();
45
46
  // every node ships the call environment which registers the calling environment
@@ -139,12 +140,33 @@ function staticSlice(options) {
139
140
  }
140
141
  }
141
142
  const status = queue.status();
142
- if (ctx.config.solver.slicer?.autoExtend) {
143
- return { ...status, slicedFor: ids, result: extendSlices(status.result, idMap) };
144
- }
145
- else {
146
- return { ...status, slicedFor: ids };
143
+ const result = ctx.config.solver.slicer?.autoExtend ? extendSlices(status.result, idMap) : status.result;
144
+ return { ...status, slicedFor: ids, result, freeNames: freeNamesOf(result, info.graph) };
145
+ }
146
+ /**
147
+ * The names the slice reads without defining them: a use whose definitions all stayed outside meets that name
148
+ * undefined, and so does one that reads nothing at all (a name the program never defines). Reading a built-in
149
+ * is no such case, as those are there whatever the slice contains.
150
+ */
151
+ function freeNamesOf(slice, graph) {
152
+ const free = new Set();
153
+ for (const id of slice) {
154
+ if (graph.getVertex(id)?.tag !== vertex_1.VertexType.Use) {
155
+ continue;
156
+ }
157
+ let defined = false;
158
+ for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
159
+ if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && (slice.has(target) || node_id_1.NodeId.isBuiltIn(target))) {
160
+ defined = true;
161
+ break;
162
+ }
163
+ }
164
+ const name = defined ? undefined : (0, node_id_1.recoverName)(id, graph.idMap);
165
+ if (name !== undefined) {
166
+ free.add(name);
167
+ }
147
168
  }
169
+ return [...free].sort();
148
170
  }
149
171
  /**
150
172
  * Computes a program dice: only those nodes reachable forward from `startIds` that are also in the backward slice of `endIds`.
@@ -171,6 +193,7 @@ function staticDice(ctx, info, ast, startIds, endIds, threshold = 75, includeCal
171
193
  timesHitThreshold: forward.timesHitThreshold + backward.timesHitThreshold,
172
194
  result,
173
195
  slicedFor: [...startIds, ...endIds],
196
+ ...(forward.stoppedEarly || backward.stoppedEarly ? { stoppedEarly: true } : {})
174
197
  };
175
198
  }
176
199
  function extendSlices(results, ast) {
@@ -3,6 +3,7 @@ import type { NodeToSlice, SliceResult } from './slicer-types';
3
3
  import type { REnvironmentInformation } from '../../dataflow/environments/environment';
4
4
  import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
5
5
  import type { DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
6
+ import type { ReadOnlyFlowrAnalyzerGasContext } from '../../project/context/flowr-analyzer-gas-context';
6
7
  export declare class VisitingQueue {
7
8
  private readonly threshold;
8
9
  private timesHitThreshold;
@@ -15,7 +16,10 @@ export declare class VisitingQueue {
15
16
  private cachedCallTargets;
16
17
  /** whether the dataflow graph has a vertex for an id, i.e. whether the traversal could continue from it */
17
18
  private readonly isGraphVertex?;
18
- constructor(threshold: number, cache?: Map<Fingerprint, Set<NodeId>>, isGraphVertex?: (id: NodeId) => boolean);
19
+ private readonly gas?;
20
+ private stoppedEarly;
21
+ private untilGasCheck;
22
+ constructor(threshold: number, cache?: Map<Fingerprint, Set<NodeId>>, isGraphVertex?: (id: NodeId) => boolean, gas?: ReadOnlyFlowrAnalyzerGasContext);
19
23
  /**
20
24
  * Adds a node to the queue if it has not been seen before.
21
25
  * @param target - the node to add
@@ -25,8 +29,14 @@ export declare class VisitingQueue {
25
29
  */
26
30
  add(target: NodeId, env: REnvironmentInformation, envFingerprint: string, onlyForSideEffects: boolean): void;
27
31
  next(): NodeToSlice;
32
+ /** Whether there is anything left to visit, which the traversal is out of gas for as soon as it is exhausted. */
28
33
  nonEmpty(): boolean;
34
+ /**
35
+ * The traversal is synchronous, so a caller can only bound it from within. Gas is polled every
36
+ * {@link GasCheckEvery} nodes, which keeps even an enabled check off the per-node path.
37
+ */
38
+ private outOfGas;
29
39
  hasId(id: NodeId): boolean;
30
40
  memoizeCallTargets(id: NodeId, targets: () => Set<DataflowGraphVertexInfo>): Set<DataflowGraphVertexInfo>;
31
- status(): Readonly<Pick<SliceResult, 'timesHitThreshold' | 'result'>>;
41
+ status(): Readonly<Pick<SliceResult, 'timesHitThreshold' | 'result' | 'stoppedEarly'>>;
32
42
  }
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VisitingQueue = void 0;
4
4
  const fingerprint_1 = require("./fingerprint");
5
5
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
6
+ const gas_1 = require("../../gas");
7
+ const static_slicer_1 = require("./static-slicer");
8
+ /** How many nodes the traversal visits between two {@link GasFeatureKey.Slicer|gas} checks. */
9
+ const GasCheckEvery = 512;
6
10
  class VisitingQueue {
7
11
  threshold;
8
12
  timesHitThreshold = 0;
@@ -17,10 +21,14 @@ class VisitingQueue {
17
21
  cachedCallTargets = new Map();
18
22
  /** whether the dataflow graph has a vertex for an id, i.e. whether the traversal could continue from it */
19
23
  isGraphVertex;
20
- constructor(threshold, cache, isGraphVertex) {
24
+ gas;
25
+ stoppedEarly = false;
26
+ untilGasCheck = 0;
27
+ constructor(threshold, cache, isGraphVertex, gas) {
21
28
  this.threshold = threshold;
22
29
  this.cache = cache;
23
30
  this.isGraphVertex = isGraphVertex;
31
+ this.gas = gas;
24
32
  }
25
33
  /**
26
34
  * Adds a node to the queue if it has not been seen before.
@@ -58,8 +66,24 @@ class VisitingQueue {
58
66
  next() {
59
67
  return this.queue.pop();
60
68
  }
69
+ /** Whether there is anything left to visit, which the traversal is out of gas for as soon as it is exhausted. */
61
70
  nonEmpty() {
62
- return this.queue.length > 0;
71
+ return this.queue.length > 0 && !this.outOfGas();
72
+ }
73
+ /**
74
+ * The traversal is synchronous, so a caller can only bound it from within. Gas is polled every
75
+ * {@link GasCheckEvery} nodes, which keeps even an enabled check off the per-node path.
76
+ */
77
+ outOfGas() {
78
+ if (this.gas === undefined || this.untilGasCheck-- > 0) {
79
+ return this.stoppedEarly;
80
+ }
81
+ this.untilGasCheck = GasCheckEvery - 1;
82
+ if (!this.stoppedEarly && this.gas.checkGas(gas_1.GasFeatureKey.Slicer) >= 2 /* GasLevel.Critical */) {
83
+ this.stoppedEarly = true;
84
+ static_slicer_1.slicerLogger.warn(`slicing ran out of gas, the slice is incomplete (${gas_1.GasWikiRef})`);
85
+ }
86
+ return this.stoppedEarly;
63
87
  }
64
88
  hasId(id) {
65
89
  return this.idThreshold.has(id);
@@ -73,7 +97,8 @@ class VisitingQueue {
73
97
  status() {
74
98
  return {
75
99
  timesHitThreshold: this.timesHitThreshold,
76
- result: new Set([...this.seen.values(), ...this.seenByCache])
100
+ result: new Set([...this.seen.values(), ...this.seenByCache]),
101
+ ...(this.stoppedEarly ? { stoppedEarly: true } : {})
77
102
  };
78
103
  }
79
104
  }
@@ -0,0 +1,18 @@
1
+ /** the name of the special `...` parameter which collects everything that finds no formal of its own */
2
+ export declare const DotsParameterName = "...";
3
+ /**
4
+ * Bind the arguments of a call to the formal parameters of the called function, following R's argument matching
5
+ * rules (see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching):
6
+ *
7
+ * 1. every named argument that *exactly* matches a formal takes it,
8
+ * 2. every remaining named argument that is a *unique prefix* of a still-free formal takes it (`pmatch`),
9
+ * 3. the remaining unnamed arguments fill the still-free formals from left to right, stopping at `...`
10
+ * (formals behind `...` can only be matched by name), and
11
+ * 4. everything that is still unmatched goes to `...` if the function has one.
12
+ *
13
+ * Both sides are given by their names alone (`undefined` for an unnamed argument or an anonymous formal), so this
14
+ * works for the normalized AST, the dataflow graph, and a plain signature list alike. An empty argument (`f(1, ,3)`)
15
+ * is an unnamed one: it takes its formal like any other, the caller just has nothing to bind to it.
16
+ * @returns for every argument (by index) the index of the parameter it binds to, `undefined` if it stays unbound
17
+ */
18
+ export declare function matchArgumentsToParameters(argNames: readonly (string | undefined)[], paramNames: readonly (string | undefined)[]): readonly (number | undefined)[];