@eagleoutice/flowr 2.2.11 → 2.2.12

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 (97) hide show
  1. package/README.md +4 -4
  2. package/benchmark/slicer.d.ts +49 -22
  3. package/benchmark/slicer.js +88 -28
  4. package/benchmark/stats/print.js +16 -10
  5. package/benchmark/stats/size-of.js +18 -1
  6. package/benchmark/stats/stats.d.ts +3 -0
  7. package/benchmark/summarizer/second-phase/process.js +8 -2
  8. package/cli/benchmark-app.d.ts +5 -0
  9. package/cli/benchmark-app.js +49 -6
  10. package/cli/benchmark-helper-app.d.ts +4 -0
  11. package/cli/benchmark-helper-app.js +20 -4
  12. package/cli/common/options.js +13 -4
  13. package/cli/repl/commands/repl-commands.js +2 -0
  14. package/cli/repl/commands/repl-dataflow.d.ts +2 -0
  15. package/cli/repl/commands/repl-dataflow.js +35 -1
  16. package/config.d.ts +18 -2
  17. package/config.js +24 -4
  18. package/dataflow/environments/built-in-config.d.ts +5 -2
  19. package/dataflow/environments/built-in-config.js +8 -2
  20. package/dataflow/environments/built-in.d.ts +8 -1
  21. package/dataflow/environments/built-in.js +8 -1
  22. package/dataflow/environments/clone.d.ts +5 -0
  23. package/dataflow/environments/clone.js +5 -0
  24. package/dataflow/environments/default-builtin-config.js +93 -9
  25. package/dataflow/environments/define.d.ts +5 -1
  26. package/dataflow/environments/define.js +36 -10
  27. package/dataflow/environments/overwrite.js +4 -0
  28. package/dataflow/environments/remove.d.ts +6 -0
  29. package/dataflow/environments/remove.js +24 -0
  30. package/dataflow/environments/resolve-by-name.js +1 -1
  31. package/dataflow/graph/dataflowgraph-builder.d.ts +76 -6
  32. package/dataflow/graph/dataflowgraph-builder.js +102 -6
  33. package/dataflow/graph/graph.d.ts +6 -1
  34. package/dataflow/graph/graph.js +24 -0
  35. package/dataflow/graph/vertex.d.ts +42 -2
  36. package/dataflow/graph/vertex.js +32 -0
  37. package/dataflow/internal/linker.js +3 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
  39. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +55 -45
  40. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -4
  41. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +27 -8
  42. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +37 -7
  43. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +10 -0
  44. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +140 -0
  45. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +51 -17
  46. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +3 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +83 -29
  48. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +7 -0
  49. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +41 -0
  50. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +17 -5
  51. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +15 -0
  52. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +75 -0
  53. package/dataflow/internal/process/functions/call/common.d.ts +1 -1
  54. package/dataflow/internal/process/functions/call/common.js +4 -2
  55. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +2 -0
  56. package/dataflow/internal/process/functions/call/named-call-handling.js +9 -5
  57. package/dataflow/internal/process/process-named-call.d.ts +3 -0
  58. package/dataflow/internal/process/process-named-call.js +3 -0
  59. package/documentation/doc-util/doc-cfg.d.ts +11 -2
  60. package/documentation/doc-util/doc-cfg.js +35 -6
  61. package/documentation/doc-util/doc-code.js +10 -2
  62. package/documentation/print-capabilities-markdown.js +1 -1
  63. package/documentation/print-cfg-wiki.d.ts +1 -0
  64. package/documentation/print-cfg-wiki.js +84 -0
  65. package/documentation/print-core-wiki.js +2 -2
  66. package/documentation/print-interface-wiki.js +1 -0
  67. package/documentation/print-query-wiki.js +2 -2
  68. package/package.json +2 -1
  69. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  70. package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -5
  71. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -25
  72. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -145
  73. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +24 -0
  74. package/queries/catalog/dependencies-query/function-info/function-info.js +10 -0
  75. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +2 -0
  76. package/queries/catalog/dependencies-query/function-info/library-functions.js +18 -0
  77. package/queries/catalog/dependencies-query/function-info/read-functions.d.ts +2 -0
  78. package/queries/catalog/dependencies-query/function-info/read-functions.js +101 -0
  79. package/queries/catalog/dependencies-query/function-info/source-functions.d.ts +2 -0
  80. package/queries/catalog/dependencies-query/function-info/source-functions.js +11 -0
  81. package/queries/catalog/dependencies-query/function-info/write-functions.d.ts +2 -0
  82. package/queries/catalog/dependencies-query/function-info/write-functions.js +87 -0
  83. package/r-bridge/data/data.d.ts +2 -2
  84. package/r-bridge/data/data.js +2 -2
  85. package/util/arrays.d.ts +23 -0
  86. package/util/arrays.js +41 -0
  87. package/util/cfg/visitor.d.ts +1 -1
  88. package/util/cfg/visitor.js +2 -2
  89. package/util/{list-access.d.ts → containers.d.ts} +24 -4
  90. package/util/{list-access.js → containers.js} +42 -12
  91. package/util/mermaid/ast.js +12 -1
  92. package/util/mermaid/cfg.js +2 -2
  93. package/util/parallel.d.ts +2 -1
  94. package/util/parallel.js +11 -2
  95. package/util/prefix.d.ts +13 -0
  96. package/util/prefix.js +34 -0
  97. package/util/version.js +1 -1
@@ -4,6 +4,7 @@ exports.overwriteIEnvironmentWith = overwriteIEnvironmentWith;
4
4
  exports.overwriteEnvironment = overwriteEnvironment;
5
5
  const assert_1 = require("../../util/assert");
6
6
  const environment_1 = require("./environment");
7
+ const log_1 = require("../../util/log");
7
8
  function anyIsMaybeOrEmpty(values) {
8
9
  if (values.length === 0) {
9
10
  return true;
@@ -19,6 +20,9 @@ function overwriteIEnvironmentWith(base, next, includeParent = true, applyCds) {
19
20
  (0, assert_1.guard)(base !== undefined && next !== undefined, 'can not overwrite environments with undefined');
20
21
  const map = new Map(base.memory);
21
22
  for (const [key, values] of next.memory) {
23
+ if (values.length > 1_000_000) {
24
+ log_1.log.warn(`Overwriting environment with ${values.length} definitions for ${key}`);
25
+ }
22
26
  const hasMaybe = applyCds?.length === 0 || applyCds !== undefined ? true : anyIsMaybeOrEmpty(values);
23
27
  if (hasMaybe) {
24
28
  const old = map.get(key);
@@ -0,0 +1,6 @@
1
+ import type { REnvironmentInformation } from './environment';
2
+ import type { Identifier } from './identifier';
3
+ /**
4
+ * Removes all definitions of a given name from the environment.
5
+ */
6
+ export declare function remove(name: Identifier, environment: REnvironmentInformation): REnvironmentInformation;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remove = remove;
4
+ const environment_1 = require("./environment");
5
+ const info_1 = require("../info");
6
+ /**
7
+ * Removes all definitions of a given name from the environment.
8
+ */
9
+ function remove(name, environment) {
10
+ let current = environment.current;
11
+ do {
12
+ const definition = current.memory.get(name);
13
+ if (definition !== undefined) {
14
+ current.memory.delete(name);
15
+ if (definition.every(d => (0, info_1.happensInEveryBranch)(d.controlDependencies))) {
16
+ break;
17
+ }
18
+ }
19
+ current = current.parent;
20
+ } while (current.id !== environment_1.BuiltInEnvironment.id);
21
+ // we never remove built ins
22
+ return environment;
23
+ }
24
+ //# sourceMappingURL=remove.js.map
@@ -58,7 +58,7 @@ function resolveByName(name, environment, target = identifier_1.ReferenceType.Un
58
58
  }
59
59
  else if (filtered.length > 0) {
60
60
  definitions ??= [];
61
- definitions.push(...filtered);
61
+ definitions = definitions.concat(filtered);
62
62
  }
63
63
  }
64
64
  current = current.parent;
@@ -6,6 +6,9 @@ import type { REnvironmentInformation } from '../environments/environment';
6
6
  import type { DataflowGraphVertexUse } from './vertex';
7
7
  import type { ControlDependency } from '../info';
8
8
  import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
9
+ import type { FlowrSearchLike } from '../../search/flowr-search-builder';
10
+ import type { Pipeline } from '../../core/steps/pipeline/pipeline';
11
+ import type { FlowrSearchInput } from '../../search/flowr-search';
9
12
  export declare function emptyGraph(idMap?: AstIdMap): DataflowGraphBuilder;
10
13
  export type DataflowGraphEdgeTarget = NodeId | (readonly NodeId[]);
11
14
  /**
@@ -82,8 +85,9 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
82
85
  controlDependencies?: ControlDependency[];
83
86
  }, asRoot?: boolean): this;
84
87
  private edgeHelper;
88
+ private queryHelper;
85
89
  /**
86
- * Adds a **read edge** (E1).
90
+ * Adds a **read edge**.
87
91
  *
88
92
  * @param from - NodeId of the source vertex
89
93
  * @param to - Either a single or multiple target ids.
@@ -91,30 +95,62 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
91
95
  */
92
96
  reads(from: NodeId, to: DataflowGraphEdgeTarget): this;
93
97
  /**
94
- * Adds a **defined-by edge** (E2), with from as defined variable, and to
98
+ * Adds a **read edge** with a query for the from and/or to vertices.
99
+ *
100
+ * @param from - Either a node id or a query to find the node id.
101
+ * @param to - Either a node id or a query to find the node id.
102
+ * @param data - The data to search in i.e. the dataflow graph.
103
+ */
104
+ readsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
105
+ /**
106
+ * Adds a **defined-by edge** with from as defined variable, and to
95
107
  * as a variable/function contributing to its definition.
96
108
  *
97
109
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
98
110
  */
99
111
  definedBy(from: NodeId, to: DataflowGraphEdgeTarget): this;
100
112
  /**
101
- * Adds a **call edge** (E5) with from as caller, and to as callee.
113
+ * Adds a **defined-by edge** with a query for the from and/or to vertices.
114
+ *
115
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
116
+ */
117
+ definedByQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
118
+ /**
119
+ * Adds a **call edge** with from as caller, and to as callee.
102
120
  *
103
121
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
104
122
  */
105
123
  calls(from: NodeId, to: DataflowGraphEdgeTarget): this;
106
124
  /**
107
- * Adds a **return edge** (E6) with from as function, and to as exit point.
125
+ * Adds a **call edge** with a query for the from and/or to vertices.
126
+ *
127
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
128
+ */
129
+ callsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
130
+ /**
131
+ * Adds a **return edge** with from as function, and to as exit point.
108
132
  *
109
133
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
110
134
  */
111
135
  returns(from: NodeId, to: DataflowGraphEdgeTarget): this;
112
136
  /**
113
- * Adds a **defines-on-call edge** (E7) with from as variable, and to as its definition
137
+ * Adds a **return edge** with a query for the from and/or to vertices.
138
+ *
139
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
140
+ */
141
+ returnsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
142
+ /**
143
+ * Adds a **defines-on-call edge** with from as variable, and to as its definition
114
144
  *
115
145
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
116
146
  */
117
147
  definesOnCall(from: NodeId, to: DataflowGraphEdgeTarget): this;
148
+ /**
149
+ * Adds a **defines-on-call edge** with a query for the from and/or to vertices.
150
+ *
151
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
152
+ */
153
+ definesOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
118
154
  /**
119
155
  * Adds a **defined-by-on-call edge** with from as definition, and to as variable.
120
156
  *
@@ -122,23 +158,47 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
122
158
  */
123
159
  definedByOnCall(from: NodeId, to: DataflowGraphEdgeTarget): this;
124
160
  /**
125
- * Adds an **argument edge** (E9) with from as function call, and to as argument.
161
+ * Adds a **defined-by-on-call edge** with a query for the from and/or to vertices.
162
+ *
163
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
164
+ */
165
+ definedByOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
166
+ /**
167
+ * Adds an **argument edge** with from as function call, and to as argument.
126
168
  *
127
169
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
128
170
  */
129
171
  argument(from: NodeId, to: DataflowGraphEdgeTarget): this;
172
+ /**
173
+ * Adds a **argument edge** with a query for the from and/or to vertices.
174
+ *
175
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
176
+ */
177
+ argumentQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
130
178
  /**
131
179
  * Adds a **non-standard evaluation edge** with from as vertex, and to as vertex.
132
180
  *
133
181
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
134
182
  */
135
183
  nse(from: NodeId, to: DataflowGraphEdgeTarget): this;
184
+ /**
185
+ * Adds a **non-standard evaluation edge** with a query for the from and/or to vertices.
186
+ *
187
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
188
+ */
189
+ nseQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
136
190
  /**
137
191
  * Adds a **side-effect-on-call edge** with from as vertex, and to as vertex.
138
192
  *
139
193
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
140
194
  */
141
195
  sideEffectOnCall(from: NodeId, to: DataflowGraphEdgeTarget): this;
196
+ /**
197
+ * Adds a **side-effect-on-call edge** with a query for the from and/or to vertices.
198
+ *
199
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
200
+ */
201
+ sideEffectOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
142
202
  /**
143
203
  * explicitly overwrite the root ids of the graph,
144
204
  * this is just an easier variant in case you working with a lot of functions this saves you a lot of `false` flags.
@@ -146,3 +206,13 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
146
206
  overwriteRootIds(ids: readonly NodeId[]): this;
147
207
  }
148
208
  export declare function getBuiltInSideEffect(name: string): LinkTo<RegExp> | undefined;
209
+ interface Query {
210
+ query: FlowrSearchLike;
211
+ }
212
+ type FromQueryParam = {
213
+ nodeId: NodeId;
214
+ } | Query;
215
+ type ToQueryParam = {
216
+ target: DataflowGraphEdgeTarget;
217
+ } | Query;
218
+ export {};
@@ -12,6 +12,8 @@ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-fun
12
12
  const built_in_1 = require("../environments/built-in");
13
13
  const edge_1 = require("./edge");
14
14
  const default_builtin_config_1 = require("../environments/default-builtin-config");
15
+ const flowr_search_executor_1 = require("../../search/flowr-search-executor");
16
+ const assert_1 = require("../../util/assert");
15
17
  function emptyGraph(idMap) {
16
18
  return new DataflowGraphBuilder(idMap);
17
19
  }
@@ -170,8 +172,28 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
170
172
  }
171
173
  return this.addEdge((0, node_id_1.normalizeIdToNumberIfPossible)(from), (0, node_id_1.normalizeIdToNumberIfPossible)(to), type);
172
174
  }
175
+ queryHelper(from, to, data, type) {
176
+ let fromId;
177
+ if ('nodeId' in from) {
178
+ fromId = from.nodeId;
179
+ }
180
+ else {
181
+ const result = (0, flowr_search_executor_1.runSearch)(from.query, data);
182
+ (0, assert_1.guard)(result.length === 1, `from query result should yield exactly one node, but yielded ${result.length}`);
183
+ fromId = result[0].node.info.id;
184
+ }
185
+ let toIds;
186
+ if ('target' in to) {
187
+ toIds = to.target;
188
+ }
189
+ else {
190
+ const result = (0, flowr_search_executor_1.runSearch)(to.query, data);
191
+ toIds = result.map(r => r.node.info.id);
192
+ }
193
+ return this.edgeHelper(fromId, toIds, type);
194
+ }
173
195
  /**
174
- * Adds a **read edge** (E1).
196
+ * Adds a **read edge**.
175
197
  *
176
198
  * @param from - NodeId of the source vertex
177
199
  * @param to - Either a single or multiple target ids.
@@ -181,7 +203,17 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
181
203
  return this.edgeHelper(from, to, edge_1.EdgeType.Reads);
182
204
  }
183
205
  /**
184
- * Adds a **defined-by edge** (E2), with from as defined variable, and to
206
+ * Adds a **read edge** with a query for the from and/or to vertices.
207
+ *
208
+ * @param from - Either a node id or a query to find the node id.
209
+ * @param to - Either a node id or a query to find the node id.
210
+ * @param data - The data to search in i.e. the dataflow graph.
211
+ */
212
+ readsQuery(from, to, data) {
213
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Reads);
214
+ }
215
+ /**
216
+ * Adds a **defined-by edge** with from as defined variable, and to
185
217
  * as a variable/function contributing to its definition.
186
218
  *
187
219
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
@@ -190,7 +222,15 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
190
222
  return this.edgeHelper(from, to, edge_1.EdgeType.DefinedBy);
191
223
  }
192
224
  /**
193
- * Adds a **call edge** (E5) with from as caller, and to as callee.
225
+ * Adds a **defined-by edge** with a query for the from and/or to vertices.
226
+ *
227
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
228
+ */
229
+ definedByQuery(from, to, data) {
230
+ return this.queryHelper(from, to, data, edge_1.EdgeType.DefinedBy);
231
+ }
232
+ /**
233
+ * Adds a **call edge** with from as caller, and to as callee.
194
234
  *
195
235
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
196
236
  */
@@ -198,7 +238,15 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
198
238
  return this.edgeHelper(from, to, edge_1.EdgeType.Calls);
199
239
  }
200
240
  /**
201
- * Adds a **return edge** (E6) with from as function, and to as exit point.
241
+ * Adds a **call edge** with a query for the from and/or to vertices.
242
+ *
243
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
244
+ */
245
+ callsQuery(from, to, data) {
246
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Calls);
247
+ }
248
+ /**
249
+ * Adds a **return edge** with from as function, and to as exit point.
202
250
  *
203
251
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
204
252
  */
@@ -206,13 +254,29 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
206
254
  return this.edgeHelper(from, to, edge_1.EdgeType.Returns);
207
255
  }
208
256
  /**
209
- * Adds a **defines-on-call edge** (E7) with from as variable, and to as its definition
257
+ * Adds a **return edge** with a query for the from and/or to vertices.
258
+ *
259
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
260
+ */
261
+ returnsQuery(from, to, data) {
262
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Returns);
263
+ }
264
+ /**
265
+ * Adds a **defines-on-call edge** with from as variable, and to as its definition
210
266
  *
211
267
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
212
268
  */
213
269
  definesOnCall(from, to) {
214
270
  return this.edgeHelper(from, to, edge_1.EdgeType.DefinesOnCall);
215
271
  }
272
+ /**
273
+ * Adds a **defines-on-call edge** with a query for the from and/or to vertices.
274
+ *
275
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
276
+ */
277
+ definesOnCallQuery(from, to, data) {
278
+ return this.queryHelper(from, to, data, edge_1.EdgeType.DefinesOnCall);
279
+ }
216
280
  /**
217
281
  * Adds a **defined-by-on-call edge** with from as definition, and to as variable.
218
282
  *
@@ -222,13 +286,29 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
222
286
  return this.edgeHelper(from, to, edge_1.EdgeType.DefinedByOnCall);
223
287
  }
224
288
  /**
225
- * Adds an **argument edge** (E9) with from as function call, and to as argument.
289
+ * Adds a **defined-by-on-call edge** with a query for the from and/or to vertices.
290
+ *
291
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
292
+ */
293
+ definedByOnCallQuery(from, to, data) {
294
+ return this.queryHelper(from, to, data, edge_1.EdgeType.DefinedByOnCall);
295
+ }
296
+ /**
297
+ * Adds an **argument edge** with from as function call, and to as argument.
226
298
  *
227
299
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
228
300
  */
229
301
  argument(from, to) {
230
302
  return this.edgeHelper(from, to, edge_1.EdgeType.Argument);
231
303
  }
304
+ /**
305
+ * Adds a **argument edge** with a query for the from and/or to vertices.
306
+ *
307
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
308
+ */
309
+ argumentQuery(from, to, data) {
310
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Argument);
311
+ }
232
312
  /**
233
313
  * Adds a **non-standard evaluation edge** with from as vertex, and to as vertex.
234
314
  *
@@ -237,6 +317,14 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
237
317
  nse(from, to) {
238
318
  return this.edgeHelper(from, to, edge_1.EdgeType.NonStandardEvaluation);
239
319
  }
320
+ /**
321
+ * Adds a **non-standard evaluation edge** with a query for the from and/or to vertices.
322
+ *
323
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
324
+ */
325
+ nseQuery(from, to, data) {
326
+ return this.queryHelper(from, to, data, edge_1.EdgeType.NonStandardEvaluation);
327
+ }
240
328
  /**
241
329
  * Adds a **side-effect-on-call edge** with from as vertex, and to as vertex.
242
330
  *
@@ -245,6 +333,14 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
245
333
  sideEffectOnCall(from, to) {
246
334
  return this.edgeHelper(from, to, edge_1.EdgeType.SideEffectOnCall);
247
335
  }
336
+ /**
337
+ * Adds a **side-effect-on-call edge** with a query for the from and/or to vertices.
338
+ *
339
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
340
+ */
341
+ sideEffectOnCallQuery(from, to, data) {
342
+ return this.queryHelper(from, to, data, edge_1.EdgeType.SideEffectOnCall);
343
+ }
248
344
  /**
249
345
  * explicitly overwrite the root ids of the graph,
250
346
  * this is just an easier variant in case you working with a lot of functions this saves you a lot of `false` flags.
@@ -2,7 +2,7 @@ import type { DataflowGraphEdge, EdgeType } from './edge';
2
2
  import type { DataflowInformation } from '../info';
3
3
  import type { DataflowGraphVertexArgument, DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from './vertex';
4
4
  import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
- import type { IdentifierDefinition, IdentifierReference } from '../environments/identifier';
5
+ import type { Identifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
6
6
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
8
8
  import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
@@ -219,4 +219,9 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
219
219
  */
220
220
  static fromJson(data: DataflowGraphJson): DataflowGraph;
221
221
  }
222
+ export interface IEnvironmentJson {
223
+ readonly id: number;
224
+ parent: IEnvironmentJson;
225
+ memory: Record<Identifier, IdentifierDefinition[]>;
226
+ }
222
227
  export {};
@@ -335,6 +335,11 @@ class DataflowGraph {
335
335
  const graph = new DataflowGraph(undefined);
336
336
  graph.rootVertices = new Set(data.rootVertices);
337
337
  graph.vertexInformation = new Map(data.vertexInformation);
338
+ for (const [, vertex] of graph.vertexInformation) {
339
+ if (vertex.environment) {
340
+ vertex.environment = renvFromJson(vertex.environment);
341
+ }
342
+ }
338
343
  graph.edgeInformation = new Map(data.edgeInformation.map(([id, edges]) => [id, new Map(edges)]));
339
344
  if (data.sourced) {
340
345
  graph._sourced = data.sourced;
@@ -368,4 +373,23 @@ function extractEdgeIds(from, to) {
368
373
  const toId = typeof to === 'object' ? to.nodeId : to;
369
374
  return [fromId, toId];
370
375
  }
376
+ function envFromJson(json) {
377
+ const parent = json.parent ? envFromJson(json.parent) : undefined;
378
+ const memory = new Map();
379
+ for (const [key, value] of Object.entries(json.memory)) {
380
+ memory.set(key, value);
381
+ }
382
+ return {
383
+ id: json.id,
384
+ parent: parent,
385
+ memory
386
+ };
387
+ }
388
+ function renvFromJson(json) {
389
+ const current = envFromJson(json.current);
390
+ return {
391
+ current,
392
+ level: json.level
393
+ };
394
+ }
371
395
  //# sourceMappingURL=graph.js.map
@@ -14,6 +14,36 @@ export declare const ValidVertexTypes: Set<string>;
14
14
  export declare const ValidVertexTypeReverse: {
15
15
  [k: string]: string;
16
16
  };
17
+ /**
18
+ * Identifier for arguments e.g. for `3` in `c(2, 3, 5)` the identifier would be
19
+ * ```ts
20
+ * {
21
+ * index: 2
22
+ * }
23
+ * ```
24
+ */
25
+ export interface UnnamedArgumentId {
26
+ readonly index: number;
27
+ }
28
+ /**
29
+ * Identifier for named arguments e.g. for `age` in `list(name = 'John', age = 8)`
30
+ * the indentifier would be
31
+ * ```ts
32
+ * {
33
+ * index: 2,
34
+ * lexeme: 'age'
35
+ * }
36
+ * ```
37
+ */
38
+ export interface NamedArgumentId {
39
+ /**
40
+ * Index may be undefined, when no index information is available.
41
+ */
42
+ readonly index: number | undefined;
43
+ readonly lexeme: string;
44
+ }
45
+ export declare function isNamedArgumentId(identifier: IndexIdentifier): identifier is NamedArgumentId;
46
+ export type IndexIdentifier = UnnamedArgumentId | NamedArgumentId;
17
47
  /**
18
48
  * A single index of a container, which is not a container itself.
19
49
  *
@@ -21,9 +51,9 @@ export declare const ValidVertexTypeReverse: {
21
51
  */
22
52
  export interface ContainerLeafIndex {
23
53
  /**
24
- * Distinctive lexeme of index e.g. 'name' for `list(name = 'John')`
54
+ * Distinctive identifier of index, see {@link IndexIdentifier}.
25
55
  */
26
- readonly lexeme: string;
56
+ readonly identifier: IndexIdentifier;
27
57
  /**
28
58
  * NodeId of index in graph.
29
59
  */
@@ -48,6 +78,16 @@ export declare function isParentContainerIndex(index: ContainerIndex): index is
48
78
  * A single index of a container.
49
79
  */
50
80
  export type ContainerIndex = ContainerLeafIndex | ContainerParentIndex;
81
+ /**
82
+ * Checks whether {@link index} is accessed by {@link accessLexeme}.
83
+ *
84
+ * @param index - The {@link ContainerIndex}, which is accessed
85
+ * @param accessLexeme - The access lexeme
86
+ * @param isIndexBasedAccess - Whether the index of the {@link ContainerIndex} is accessed i.e. the position in the container and not e.g. the name of the index
87
+ * @returns true, when {@link accessLexeme} accesses the {@link index}, false otherwise
88
+ */
89
+ export declare function isAccessed(index: ContainerIndex, accessLexeme: string, isIndexBasedAccess: boolean): boolean;
90
+ export declare function isSameIndex(a: ContainerIndex, b: ContainerIndex): boolean;
51
91
  /**
52
92
  * List of indices of a single statement like `list(a=3, b=2)`
53
93
  */
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0;
4
+ exports.isNamedArgumentId = isNamedArgumentId;
4
5
  exports.isParentContainerIndex = isParentContainerIndex;
6
+ exports.isAccessed = isAccessed;
7
+ exports.isSameIndex = isSameIndex;
5
8
  exports.isValueVertex = isValueVertex;
6
9
  exports.isUseVertex = isUseVertex;
7
10
  exports.isFunctionCallVertex = isFunctionCallVertex;
@@ -17,9 +20,38 @@ var VertexType;
17
20
  })(VertexType || (exports.VertexType = VertexType = {}));
18
21
  exports.ValidVertexTypes = new Set(Object.values(VertexType));
19
22
  exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
23
+ function isNamedArgumentId(identifier) {
24
+ return 'lexeme' in identifier;
25
+ }
20
26
  function isParentContainerIndex(index) {
21
27
  return 'subIndices' in index;
22
28
  }
29
+ /**
30
+ * Checks whether {@link index} is accessed by {@link accessLexeme}.
31
+ *
32
+ * @param index - The {@link ContainerIndex}, which is accessed
33
+ * @param accessLexeme - The access lexeme
34
+ * @param isIndexBasedAccess - Whether the index of the {@link ContainerIndex} is accessed i.e. the position in the container and not e.g. the name of the index
35
+ * @returns true, when {@link accessLexeme} accesses the {@link index}, false otherwise
36
+ */
37
+ function isAccessed(index, accessLexeme, isIndexBasedAccess) {
38
+ if (isIndexBasedAccess) {
39
+ return index.identifier.index === Number(accessLexeme);
40
+ }
41
+ if (isNamedArgumentId(index.identifier)) {
42
+ return index.identifier.lexeme === accessLexeme;
43
+ }
44
+ return false;
45
+ }
46
+ function isSameIndex(a, b) {
47
+ if (isNamedArgumentId(a.identifier) && isNamedArgumentId(b.identifier)) {
48
+ return a.identifier.lexeme === b.identifier.lexeme;
49
+ }
50
+ if (a.identifier.index === undefined || b.identifier.index === undefined) {
51
+ return false;
52
+ }
53
+ return a.identifier.index === b.identifier.index;
54
+ }
23
55
  /**
24
56
  * Check if the given vertex is a {@link DataflowGraphVertexValue|value vertex}.
25
57
  */
@@ -23,6 +23,7 @@ const vertex_1 = require("../graph/vertex");
23
23
  const resolve_by_name_1 = require("../environments/resolve-by-name");
24
24
  const built_in_1 = require("../environments/built-in");
25
25
  const static_slicer_1 = require("../../slicing/static/static-slicer");
26
+ const prefix_1 = require("../../util/prefix");
26
27
  function findNonLocalReads(graph, ignore) {
27
28
  const ignores = new Set(ignore.map(i => i.nodeId));
28
29
  const ids = new Set([...graph.vertices(true)]
@@ -80,7 +81,8 @@ function linkArgumentsOnCall(args, params, graph) {
80
81
  const matchedParameters = new Set();
81
82
  // first map names
82
83
  for (const [name, arg] of nameArgMap) {
83
- const param = nameParamMap.get(name);
84
+ const pmatchName = (0, prefix_1.findByPrefixIfUnique)(name, [...nameParamMap.keys()]) ?? name;
85
+ const param = nameParamMap.get(pmatchName);
84
86
  if (param !== undefined) {
85
87
  logger_1.dataflowLogger.trace(`mapping named argument "${name}" to parameter "${param.name.content}"`);
86
88
  graph.addEdge(arg.nodeId, param.name.info.id, edge_1.EdgeType.DefinesOnCall);
@@ -19,3 +19,4 @@ import type { ForceArguments } from '../common';
19
19
  export declare function processAccess<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
20
20
  treatIndicesAsString: boolean;
21
21
  } & ForceArguments): DataflowInformation;
22
+ export declare function symbolArgumentsToStrings<OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], firstIndexInclusive?: number, lastIndexInclusive?: number): RFunctionArgument<OtherInfo & ParentInformation>[];