@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
@@ -149,7 +149,7 @@ export declare const flowrCapabilities: {
149
149
  }, {
150
150
  readonly name: "Resolve Arguments";
151
151
  readonly id: "resolve-arguments";
152
- readonly supported: "partially";
152
+ readonly supported: "fully";
153
153
  readonly description: "_Correctly bind arguments (including [`pmatch`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/pmatch))._ Currently, we do not have a correct implementation for `pmatch`. Furthermore, more tests would be nice.";
154
154
  }, {
155
155
  readonly name: "Side-Effects in Argument";
@@ -418,7 +418,7 @@ export declare const flowrCapabilities: {
418
418
  }, {
419
419
  readonly name: "Internal and Primitive Functions";
420
420
  readonly id: "built-in-internal-and-primitive-functions";
421
- readonly supported: "not";
421
+ readonly supported: "partially";
422
422
  readonly description: "_Handle `.Internal`, `.Primitive`, ..._ In general we can not handle them as they refer to non-R code. We currently do not support them when used with the function.";
423
423
  }, {
424
424
  readonly name: "Options";
@@ -200,7 +200,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
200
200
  {
201
201
  name: 'Resolve Arguments',
202
202
  id: 'resolve-arguments',
203
- supported: 'partially',
203
+ supported: 'fully',
204
204
  description: '_Correctly bind arguments (including [`pmatch`](https://www.rdocumentation.org/packages/base/versions/3.6.2/topics/pmatch))._ Currently, we do not have a correct implementation for `pmatch`. Furthermore, more tests would be nice.'
205
205
  },
206
206
  {
@@ -532,7 +532,7 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true })}
532
532
  {
533
533
  name: 'Internal and Primitive Functions',
534
534
  id: 'built-in-internal-and-primitive-functions',
535
- supported: 'not',
535
+ supported: 'partially',
536
536
  description: '_Handle `.Internal`, `.Primitive`, ..._ In general we can not handle them as they refer to non-R code. We currently do not support them when used with the function.'
537
537
  },
538
538
  {
package/util/arrays.d.ts CHANGED
@@ -65,3 +65,26 @@ export declare function arraySum(arr: readonly number[]): number;
65
65
  */
66
66
  export declare function array2bag<T>(arr: T[]): Map<T, number>;
67
67
  export declare function arrayEqual<T>(a: readonly T[] | undefined, b: readonly T[] | undefined): boolean;
68
+ /**
69
+ * Samples elements from a list such that the distance between the sampled elements is as equal as possible.
70
+ *
71
+ * If the number of elements to sample is greater or equal to the number of elements in the list, the list is returned as is.
72
+ * If the number of elements to sample is less than or equal to 0, an empty list is returned.
73
+ *
74
+ * @param list - list of elements
75
+ * @param sampleCount - number of elements to sample
76
+ * @param rounding - rounding mode to use for the index calculation
77
+ * @returns - a list of elements equidistantly sampled from the input list
78
+ */
79
+ export declare function equidistantSampling<T>(list: readonly T[], sampleCount: number, rounding?: 'floor' | 'ceil'): T[];
80
+ /**
81
+ * Returns the cartesian product of the given arrays.
82
+ * @example
83
+ *
84
+ * ```ts
85
+ * cartesianProduct([1, 2], ['a', 'b', 'c'], [true, false])
86
+ * // -> [[1, 'a', true], [1, 'a', false], [1, 'b', true], [1, 'b', false], [1, 'c', true], [1, 'c', false], [2, 'a', true], [2, 'a', false], [2, 'b', true], [2, 'b', false], [2, 'c', true], [2, 'c', false]]
87
+ * ```
88
+ *
89
+ */
90
+ export declare function cartesianProduct<T>(...arrays: T[][]): T[][];
package/util/arrays.js CHANGED
@@ -8,6 +8,8 @@ exports.getUniqueCombinationsOfSize = getUniqueCombinationsOfSize;
8
8
  exports.arraySum = arraySum;
9
9
  exports.array2bag = array2bag;
10
10
  exports.arrayEqual = arrayEqual;
11
+ exports.equidistantSampling = equidistantSampling;
12
+ exports.cartesianProduct = cartesianProduct;
11
13
  const assert_1 = require("./assert");
12
14
  /**
13
15
  * Splits the array every time the given predicate fires.
@@ -174,4 +176,43 @@ function arrayEqual(a, b) {
174
176
  }
175
177
  return true;
176
178
  }
179
+ /**
180
+ * Samples elements from a list such that the distance between the sampled elements is as equal as possible.
181
+ *
182
+ * If the number of elements to sample is greater or equal to the number of elements in the list, the list is returned as is.
183
+ * If the number of elements to sample is less than or equal to 0, an empty list is returned.
184
+ *
185
+ * @param list - list of elements
186
+ * @param sampleCount - number of elements to sample
187
+ * @param rounding - rounding mode to use for the index calculation
188
+ * @returns - a list of elements equidistantly sampled from the input list
189
+ */
190
+ function equidistantSampling(list, sampleCount, rounding = 'ceil') {
191
+ if (sampleCount >= list.length) {
192
+ return list.slice();
193
+ }
194
+ else if (sampleCount <= 0) {
195
+ return [];
196
+ }
197
+ const result = [];
198
+ const step = list.length / sampleCount;
199
+ for (let i = 0; i < sampleCount; i++) {
200
+ const index = rounding === 'floor' ? Math.floor(i * step) : Math.ceil(i * step);
201
+ result.push(list[index]);
202
+ }
203
+ return result;
204
+ }
205
+ /**
206
+ * Returns the cartesian product of the given arrays.
207
+ * @example
208
+ *
209
+ * ```ts
210
+ * cartesianProduct([1, 2], ['a', 'b', 'c'], [true, false])
211
+ * // -> [[1, 'a', true], [1, 'a', false], [1, 'b', true], [1, 'b', false], [1, 'c', true], [1, 'c', false], [2, 'a', true], [2, 'a', false], [2, 'b', true], [2, 'b', false], [2, 'c', true], [2, 'c', false]]
212
+ * ```
213
+ *
214
+ */
215
+ function cartesianProduct(...arrays) {
216
+ return arrays.reduce((a, b) => a.flatMap(x => b.map(y => x.concat(y))), [[]]);
217
+ }
177
218
  //# sourceMappingURL=arrays.js.map
@@ -6,4 +6,4 @@ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-i
6
6
  * @param startNode - The node to start the traversal from.
7
7
  * @param visitor - The visitor function to call for each node, if you return true the traversal from this node will be stopped.
8
8
  */
9
- export declare function visitInReverseOrder(graph: ControlFlowGraph, startNode: NodeId, visitor: (node: NodeId) => boolean | void): void;
9
+ export declare function visitCfgInReverseOrder(graph: ControlFlowGraph, startNode: NodeId, visitor: (node: NodeId) => boolean | void): void;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.visitInReverseOrder = visitInReverseOrder;
3
+ exports.visitCfgInReverseOrder = visitCfgInReverseOrder;
4
4
  /**
5
5
  * Visit all nodes reachable from the start node in the control flow graph, traversing the dependencies but ignoring cycles.
6
6
  * @param graph - The control flow graph.
7
7
  * @param startNode - The node to start the traversal from.
8
8
  * @param visitor - The visitor function to call for each node, if you return true the traversal from this node will be stopped.
9
9
  */
10
- function visitInReverseOrder(graph, startNode,
10
+ function visitCfgInReverseOrder(graph, startNode,
11
11
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type -- void is used to indicate that the return value is ignored/we never stop
12
12
  visitor) {
13
13
  const visited = new Set();
@@ -1,10 +1,30 @@
1
1
  import type { REnvironmentInformation } from '../dataflow/environments/environment';
2
- import type { ContainerIndices, ContainerIndicesCollection } from '../dataflow/graph/vertex';
2
+ import type { Identifier } from '../dataflow/environments/identifier';
3
+ import type { ContainerIndices, ContainerIndicesCollection, IndexIdentifier } from '../dataflow/graph/vertex';
3
4
  import type { RAccess } from '../r-bridge/lang-4.x/ast/model/nodes/r-access';
5
+ import type { RArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-argument';
6
+ import type { RFunctionArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
4
7
  import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
8
+ /**
9
+ * Returns the accessed and access argument of an access operation by filtering the operation arguments.
10
+ */
11
+ export declare function getAccessOperands<OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[]): {
12
+ accessedArg: RArgument<OtherInfo & ParentInformation> | undefined;
13
+ accessArg: RArgument<OtherInfo & ParentInformation> | undefined;
14
+ };
15
+ /**
16
+ * Resolves the passed name in the passed environment and returns the indicesCollection of the resolved definitions.
17
+ *
18
+ * @param name - Name to resolve
19
+ * @param environment - Environment in which name is resolved
20
+ * @returns The indicesCollection of the resolved definitions
21
+ */
22
+ export declare function resolveIndicesByName(name: Identifier, environment: REnvironmentInformation): ContainerIndices[] | undefined;
5
23
  /**
6
24
  * Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}.
7
25
  *
26
+ * If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation.
27
+ *
8
28
  * @param accessedArg - The argument to resolve
9
29
  * @param accessArg - The argument which is used to filter the indices
10
30
  * @param environment - The environment in which {@link accessedArg} is resolved
@@ -14,7 +34,7 @@ export declare function resolveSingleIndex(accessedArg: {
14
34
  lexeme: string;
15
35
  }, accessArg: {
16
36
  lexeme: string;
17
- }, environment: REnvironmentInformation): ContainerIndicesCollection;
37
+ }, environment: REnvironmentInformation, isIndexBasedAccess: boolean): ContainerIndicesCollection;
18
38
  /**
19
39
  * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
20
40
  *
@@ -24,7 +44,7 @@ export declare function resolveSingleIndex(accessedArg: {
24
44
  */
25
45
  export declare function filterIndices(indicesCollection: ContainerIndicesCollection, accessArg: {
26
46
  lexeme: string;
27
- }): ContainerIndicesCollection;
47
+ }, isIndexBasedAccess: boolean): ContainerIndicesCollection;
28
48
  /**
29
49
  * Constructs the definition of a nested access.
30
50
  *
@@ -38,7 +58,7 @@ export declare function filterIndices(indicesCollection: ContainerIndicesCollect
38
58
  * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
39
59
  * @returns The constructed nested access
40
60
  */
41
- export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<OtherInfo & ParentInformation>, leafIndices: ContainerIndices): ContainerIndices[];
61
+ export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<OtherInfo & ParentInformation>, leafIndices: ContainerIndices, constructIdentifier: (arg: RArgument<OtherInfo & ParentInformation>) => IndexIdentifier): ContainerIndices[];
42
62
  /**
43
63
  * Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
44
64
  *
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAccessOperands = getAccessOperands;
4
+ exports.resolveIndicesByName = resolveIndicesByName;
3
5
  exports.resolveSingleIndex = resolveSingleIndex;
4
6
  exports.filterIndices = filterIndices;
5
7
  exports.constructNestedAccess = constructNestedAccess;
@@ -8,19 +10,47 @@ const resolve_by_name_1 = require("../dataflow/environments/resolve-by-name");
8
10
  const vertex_1 = require("../dataflow/graph/vertex");
9
11
  const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
10
12
  const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
13
+ /**
14
+ * Returns the accessed and access argument of an access operation by filtering the operation arguments.
15
+ */
16
+ function getAccessOperands(args) {
17
+ const nonEmptyArgs = args.filter(arg => arg !== r_function_call_1.EmptyArgument);
18
+ const accessedArg = nonEmptyArgs.find(arg => arg.info.role === "accessed" /* RoleInParent.Accessed */);
19
+ const accessArg = nonEmptyArgs.find(arg => arg.info.role === "index-access" /* RoleInParent.IndexAccess */);
20
+ return { accessedArg, accessArg };
21
+ }
22
+ /**
23
+ * Resolves the passed name in the passed environment and returns the indicesCollection of the resolved definitions.
24
+ *
25
+ * @param name - Name to resolve
26
+ * @param environment - Environment in which name is resolved
27
+ * @returns The indicesCollection of the resolved definitions
28
+ */
29
+ function resolveIndicesByName(name, environment) {
30
+ const definitions = (0, resolve_by_name_1.resolveByName)(name, environment);
31
+ return definitions?.flatMap(def => def?.indicesCollection ?? []);
32
+ }
11
33
  /**
12
34
  * Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}.
13
35
  *
36
+ * If no indices could be found that match the `accessArg`, the original indices are returned as overapproximation.
37
+ *
14
38
  * @param accessedArg - The argument to resolve
15
39
  * @param accessArg - The argument which is used to filter the indices
16
40
  * @param environment - The environment in which {@link accessedArg} is resolved
17
41
  * @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
18
42
  */
19
- function resolveSingleIndex(accessedArg, accessArg, environment) {
20
- const definitions = (0, resolve_by_name_1.resolveByName)(accessedArg.lexeme, environment);
21
- const indicesCollection = definitions?.flatMap(def => def?.indicesCollection ?? []);
22
- const accessedIndicesCollection = filterIndices(indicesCollection, accessArg);
23
- return accessedIndicesCollection;
43
+ function resolveSingleIndex(accessedArg, accessArg, environment, isIndexBasedAccess) {
44
+ const indicesCollection = resolveIndicesByName(accessedArg.lexeme, environment);
45
+ const accessedIndicesCollection = filterIndices(indicesCollection, accessArg, isIndexBasedAccess);
46
+ // If the accessed indices couldn't be resolved, overapproximate by returning the original indices.
47
+ // This could also be the case, when nothing is acccessed, but we better be safe.
48
+ if (accessedIndicesCollection === undefined) {
49
+ return indicesCollection;
50
+ }
51
+ else {
52
+ return accessedIndicesCollection;
53
+ }
24
54
  }
25
55
  /**
26
56
  * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
@@ -29,11 +59,11 @@ function resolveSingleIndex(accessedArg, accessArg, environment) {
29
59
  * @param accessArg - The argument which is used to filter {@link indicesCollection}
30
60
  * @returns The filtered copy of {@link indicesCollection}
31
61
  */
32
- function filterIndices(indicesCollection, accessArg) {
62
+ function filterIndices(indicesCollection, accessArg, isIndexBasedAccess) {
33
63
  let accessedIndicesCollection = undefined;
34
64
  for (const indices of indicesCollection ?? []) {
35
- const filteredIndices = indices.indices.filter(index => accessArg.lexeme === index.lexeme);
36
- if (filteredIndices.length == 0) {
65
+ const filteredIndices = indices.indices.filter(index => (0, vertex_1.isAccessed)(index, accessArg.lexeme, isIndexBasedAccess));
66
+ if (filteredIndices.length === 0) {
37
67
  continue;
38
68
  }
39
69
  accessedIndicesCollection ??= [];
@@ -57,7 +87,7 @@ function filterIndices(indicesCollection, accessArg) {
57
87
  * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
58
88
  * @returns The constructed nested access
59
89
  */
60
- function constructNestedAccess(accessedArg, leafIndices) {
90
+ function constructNestedAccess(accessedArg, leafIndices, constructIdentifier) {
61
91
  const accessed = accessedArg.accessed;
62
92
  const accesses = accessedArg.access.filter(arg => arg !== r_function_call_1.EmptyArgument).map(arg => arg);
63
93
  const indices = [];
@@ -65,7 +95,7 @@ function constructNestedAccess(accessedArg, leafIndices) {
65
95
  const newIndices = {
66
96
  indices: [
67
97
  {
68
- lexeme: access.lexeme,
98
+ identifier: constructIdentifier(access),
69
99
  nodeId: access.info.id,
70
100
  subIndices: [leafIndices],
71
101
  }
@@ -73,7 +103,7 @@ function constructNestedAccess(accessedArg, leafIndices) {
73
103
  isContainer: false,
74
104
  };
75
105
  if (accessed.type === type_1.RType.Access) {
76
- const nestedIndices = constructNestedAccess(accessed, newIndices);
106
+ const nestedIndices = constructNestedAccess(accessed, newIndices, constructIdentifier);
77
107
  indices.push(...nestedIndices);
78
108
  }
79
109
  else {
@@ -112,4 +142,4 @@ function addSubIndicesToLeafIndices(indicesCollection, leafSubIndices) {
112
142
  }
113
143
  return result;
114
144
  }
115
- //# sourceMappingURL=list-access.js.map
145
+ //# sourceMappingURL=containers.js.map
@@ -5,9 +5,10 @@ exports.normalizedAstToMermaidUrl = normalizedAstToMermaidUrl;
5
5
  const mermaid_1 = require("./mermaid");
6
6
  const visitor_1 = require("../../r-bridge/lang-4.x/ast/model/processing/visitor");
7
7
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
8
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
8
9
  function normalizedAstToMermaid(ast, prefix = 'flowchart TD\n') {
9
10
  let output = prefix;
10
- (0, visitor_1.visitAst)(ast, n => {
11
+ function showNode(n) {
11
12
  const name = `${n.type} (${n.info.id})\\n${n.lexeme ?? ' '}`;
12
13
  output += ` n${n.info.id}(["${(0, mermaid_1.escapeMarkdown)(name)}"])\n`;
13
14
  if (n.info.parent !== undefined) {
@@ -19,6 +20,16 @@ function normalizedAstToMermaid(ast, prefix = 'flowchart TD\n') {
19
20
  output += ` n${n.info.id} -.-|"group-open"| n${n.grouping[0].info.id}\n`;
20
21
  output += ` n${n.info.id} -.-|"group-close"| n${n.grouping[1].info.id}\n`;
21
22
  }
23
+ }
24
+ (0, visitor_1.visitAst)(ast, n => {
25
+ showNode(n);
26
+ if (n.type === 'RAccess' && (n.operator !== '[' && n.operator !== '[[')) {
27
+ for (const k of n.access) {
28
+ if (k !== r_function_call_1.EmptyArgument) {
29
+ showNode(k);
30
+ }
31
+ }
32
+ }
22
33
  return false;
23
34
  });
24
35
  return output;
@@ -6,8 +6,8 @@ const mermaid_1 = require("./mermaid");
6
6
  function getLexeme(n) {
7
7
  return n ? n.info.fullLexeme ?? n.lexeme ?? '<unknown>' : '';
8
8
  }
9
- function cfgToMermaid(cfg, normalizedAst, prefix = '') {
10
- let output = prefix + 'flowchart BT\n';
9
+ function cfgToMermaid(cfg, normalizedAst, prefix = 'flowchart BT\n') {
10
+ let output = prefix;
11
11
  for (const [id, vertex] of cfg.graph.vertices()) {
12
12
  const normalizedVertex = normalizedAst.idMap.get(id);
13
13
  const content = getLexeme(normalizedVertex);
@@ -13,12 +13,13 @@ export declare class LimitedThreadPool {
13
13
  private skipped;
14
14
  private currentlyRunning;
15
15
  private reportingInterval;
16
+ private readonly timeLimitInMs;
16
17
  /**
17
18
  * Create a new parallel helper that runs the given `module` once for each list of {@link Arguments} in the `queue`.
18
19
  * The `limit` stops the execution if `<limit>` number of runs exited successfully.
19
20
  * The `parallel` parameter limits the number of parallel executions.
20
21
  */
21
- constructor(module: string, queue: WorkingQueue, limit: number, parallel: number);
22
+ constructor(module: string, queue: WorkingQueue, limit: number, parallel: number, timeLimitInMs?: number);
22
23
  run(): Promise<void>;
23
24
  getStats(): {
24
25
  counter: number;
package/util/parallel.js CHANGED
@@ -56,16 +56,18 @@ class LimitedThreadPool {
56
56
  skipped = [];
57
57
  currentlyRunning = new Set();
58
58
  reportingInterval = undefined;
59
+ timeLimitInMs;
59
60
  /**
60
61
  * Create a new parallel helper that runs the given `module` once for each list of {@link Arguments} in the `queue`.
61
62
  * The `limit` stops the execution if `<limit>` number of runs exited successfully.
62
63
  * The `parallel` parameter limits the number of parallel executions.
63
64
  */
64
- constructor(module, queue, limit, parallel) {
65
+ constructor(module, queue, limit, parallel, timeLimitInMs) {
65
66
  this.workingQueue = queue;
66
67
  this.limit = limit;
67
68
  this.module = module;
68
69
  this.parallel = parallel;
70
+ this.timeLimitInMs = timeLimitInMs;
69
71
  }
70
72
  async run() {
71
73
  this.reportingInterval = setInterval(() => {
@@ -93,8 +95,15 @@ class LimitedThreadPool {
93
95
  console.log(`[${this.counter}/${this.limit}] Running next, currently running: ${this.currentlyRunning.size}, queue: ${this.workingQueue.length} [args: ${args.join(' ')}]`);
94
96
  const child = cp.fork(this.module, args);
95
97
  child.on('exit', this.onChildExit(args));
98
+ let timeout;
99
+ if (this.timeLimitInMs) {
100
+ timeout = setTimeout(() => {
101
+ log_1.log.error(`Killing child process with '${JSON.stringify(args)}' after ${this.timeLimitInMs}ms`);
102
+ child.kill();
103
+ }, this.timeLimitInMs);
104
+ }
96
105
  // schedule re-schedule
97
- await new Promise(resolve => child.on('exit', resolve)).then(() => this.runNext());
106
+ await new Promise(resolve => child.on('exit', resolve)).then(() => clearTimeout(timeout)).then(() => this.runNext());
98
107
  }
99
108
  onChildExit(args) {
100
109
  return (code, signal) => {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * given a potentially partial prefix like `hell`, this finds the matching name in the map, but only
3
+ * if it is unique!
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * findByPrefixIfUnique('hell', { 'hello', 'bar' }) // => 'hello'
8
+ * findByPrefixIfUnique('hell', { 'hello', 'hell' }) // => 'hell' (full match)
9
+ * findByPrefixIfUnique('h', { 'hello', 'hell' }) // => undefined (not unique)
10
+ * findByPrefixIfUnique('', { 'hello', 'hell' }) // => undefined (empty prefix)
11
+ * ```
12
+ */
13
+ export declare function findByPrefixIfUnique(prefix: string, keys: readonly string[]): string | undefined;
package/util/prefix.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findByPrefixIfUnique = findByPrefixIfUnique;
4
+ /**
5
+ * given a potentially partial prefix like `hell`, this finds the matching name in the map, but only
6
+ * if it is unique!
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * findByPrefixIfUnique('hell', { 'hello', 'bar' }) // => 'hello'
11
+ * findByPrefixIfUnique('hell', { 'hello', 'hell' }) // => 'hell' (full match)
12
+ * findByPrefixIfUnique('h', { 'hello', 'hell' }) // => undefined (not unique)
13
+ * findByPrefixIfUnique('', { 'hello', 'hell' }) // => undefined (empty prefix)
14
+ * ```
15
+ */
16
+ function findByPrefixIfUnique(prefix, keys) {
17
+ if (prefix === '') {
18
+ return undefined;
19
+ }
20
+ let found = undefined;
21
+ for (const key of keys) {
22
+ if (key === prefix) {
23
+ return key;
24
+ }
25
+ if (key.startsWith(prefix)) {
26
+ if (found) {
27
+ return undefined;
28
+ }
29
+ found = key;
30
+ }
31
+ }
32
+ return found;
33
+ }
34
+ //# sourceMappingURL=prefix.js.map
package/util/version.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.flowrVersion = flowrVersion;
4
4
  const semver_1 = require("semver");
5
5
  // this is automatically replaced with the current version by release-it
6
- const version = '2.2.11';
6
+ const version = '2.2.12';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }