@eagleoutice/flowr 2.1.8 → 2.1.10

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 (85) hide show
  1. package/README.md +3 -0
  2. package/benchmark/summarizer/first-phase/process.js +6 -5
  3. package/cli/repl/commands/repl-dataflow.js +5 -2
  4. package/cli/repl/commands/repl-normalize.js +5 -2
  5. package/cli/repl/commands/repl-query.js +2 -2
  6. package/cli/repl/server/messages/message-query.js +1 -1
  7. package/config.d.ts +21 -0
  8. package/config.js +19 -2
  9. package/dataflow/environments/built-in.d.ts +2 -0
  10. package/dataflow/environments/built-in.js +2 -0
  11. package/dataflow/environments/default-builtin-config.js +48 -8
  12. package/dataflow/environments/define.js +78 -0
  13. package/dataflow/environments/environment.d.ts +46 -8
  14. package/dataflow/environments/environment.js +24 -1
  15. package/dataflow/environments/identifier.d.ts +60 -10
  16. package/dataflow/environments/identifier.js +11 -2
  17. package/dataflow/environments/resolve-by-name.d.ts +10 -5
  18. package/dataflow/environments/resolve-by-name.js +103 -5
  19. package/dataflow/extractor.js +5 -4
  20. package/dataflow/graph/dataflowgraph-builder.d.ts +6 -0
  21. package/dataflow/graph/dataflowgraph-builder.js +8 -0
  22. package/dataflow/graph/edge.d.ts +10 -4
  23. package/dataflow/graph/edge.js +12 -5
  24. package/dataflow/graph/graph.d.ts +41 -3
  25. package/dataflow/graph/graph.js +39 -34
  26. package/dataflow/graph/vertex.d.ts +122 -8
  27. package/dataflow/graph/vertex.js +19 -0
  28. package/dataflow/info.d.ts +79 -11
  29. package/dataflow/info.js +20 -0
  30. package/dataflow/internal/linker.d.ts +4 -2
  31. package/dataflow/internal/linker.js +12 -5
  32. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +11 -0
  33. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +141 -49
  34. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +8 -3
  35. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +40 -11
  36. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +16 -0
  37. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +83 -6
  38. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +3 -3
  39. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +15 -0
  40. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +50 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
  42. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +29 -1
  43. package/dataflow/internal/process/functions/call/common.js +16 -2
  44. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +2 -1
  45. package/dataflow/internal/process/functions/call/known-call-handling.js +3 -2
  46. package/documentation/doc-util/doc-dfg.d.ts +0 -1
  47. package/documentation/doc-util/doc-dfg.js +1 -14
  48. package/documentation/print-capabilities-markdown.js +1 -1
  49. package/documentation/print-dataflow-graph-wiki.js +26 -7
  50. package/documentation/print-interface-wiki.js +6 -1
  51. package/documentation/print-linting-and-testing-wiki.js +60 -26
  52. package/documentation/print-query-wiki.js +1 -1
  53. package/package.json +17 -3
  54. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  55. package/queries/catalog/call-context-query/call-context-query-format.d.ts +13 -0
  56. package/queries/catalog/call-context-query/call-context-query-format.js +3 -1
  57. package/queries/catalog/call-context-query/cascade-action.d.ts +8 -0
  58. package/queries/catalog/call-context-query/cascade-action.js +13 -0
  59. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +11 -1
  60. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +41 -4
  61. package/queries/catalog/dependencies-query/dependencies-query-format.js +4 -0
  62. package/queries/query.d.ts +4 -4
  63. package/queries/query.js +17 -5
  64. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -0
  65. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +5 -1
  66. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
  67. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -1
  68. package/slicing/static/slice-call.d.ts +7 -2
  69. package/slicing/static/slice-call.js +33 -44
  70. package/slicing/static/static-slicer.d.ts +5 -1
  71. package/slicing/static/static-slicer.js +22 -8
  72. package/slicing/static/visiting-queue.d.ts +4 -4
  73. package/slicing/static/visiting-queue.js +5 -3
  74. package/statistics/output/print-stats.js +2 -1
  75. package/statistics/summarizer/post-process/histogram.js +2 -1
  76. package/statistics/summarizer/post-process/post-process-output.js +2 -1
  77. package/statistics/summarizer/second-phase/process.js +3 -3
  78. package/util/arrays.d.ts +1 -1
  79. package/util/arrays.js +3 -3
  80. package/util/cfg/cfg.js +4 -2
  81. package/util/list-access.d.ts +48 -0
  82. package/util/list-access.js +115 -0
  83. package/util/mermaid/cfg.js +1 -1
  84. package/util/summarizer.js +2 -2
  85. package/util/version.js +1 -1
@@ -0,0 +1,48 @@
1
+ import type { REnvironmentInformation } from '../dataflow/environments/environment';
2
+ import type { ContainerIndices, ContainerIndicesCollection } from '../dataflow/graph/vertex';
3
+ import type { RAccess } from '../r-bridge/lang-4.x/ast/model/nodes/r-access';
4
+ import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
5
+ /**
6
+ * Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}.
7
+ *
8
+ * @param accessedArg - The argument to resolve
9
+ * @param accessArg - The argument which is used to filter the indices
10
+ * @param environment - The environment in which {@link accessedArg} is resolved
11
+ * @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
12
+ */
13
+ export declare function resolveSingleIndex(accessedArg: {
14
+ lexeme: string;
15
+ }, accessArg: {
16
+ lexeme: string;
17
+ }, environment: REnvironmentInformation): ContainerIndicesCollection;
18
+ /**
19
+ * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
20
+ *
21
+ * @param indicesCollection - The {@link ContainerIndicesCollection} to filter
22
+ * @param accessArg - The argument which is used to filter {@link indicesCollection}
23
+ * @returns The filtered copy of {@link indicesCollection}
24
+ */
25
+ export declare function filterIndices(indicesCollection: ContainerIndicesCollection, accessArg: {
26
+ lexeme: string;
27
+ }): ContainerIndicesCollection;
28
+ /**
29
+ * Constructs the definition of a nested access.
30
+ *
31
+ * Example:
32
+ * ```r
33
+ * person$credentials$username
34
+ * ```
35
+ * would result in a list with the index `credentials`, which has the subIndex `username`.
36
+ *
37
+ * @param accessedArg - The top level argument that is accessed
38
+ * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
39
+ * @returns The constructed nested access
40
+ */
41
+ export declare function constructNestedAccess<OtherInfo>(accessedArg: RAccess<OtherInfo & ParentInformation>, leafIndices: ContainerIndices): ContainerIndices[];
42
+ /**
43
+ * Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
44
+ *
45
+ * @param indicesCollection - Indices where to add the sub indices.
46
+ * @param leafSubIndices - Indices that are added to the leaf indices.
47
+ */
48
+ export declare function addSubIndicesToLeafIndices(indicesCollection: ContainerIndices[], leafSubIndices: ContainerIndices[]): ContainerIndices[];
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSingleIndex = resolveSingleIndex;
4
+ exports.filterIndices = filterIndices;
5
+ exports.constructNestedAccess = constructNestedAccess;
6
+ exports.addSubIndicesToLeafIndices = addSubIndicesToLeafIndices;
7
+ const resolve_by_name_1 = require("../dataflow/environments/resolve-by-name");
8
+ const vertex_1 = require("../dataflow/graph/vertex");
9
+ const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
10
+ const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
11
+ /**
12
+ * Resolves {@link accessedArg} in the {@link environment} and filters its indices according to {@link accessArg}.
13
+ *
14
+ * @param accessedArg - The argument to resolve
15
+ * @param accessArg - The argument which is used to filter the indices
16
+ * @param environment - The environment in which {@link accessedArg} is resolved
17
+ * @returns The filtered {@link ContainerIndicesCollection} of the resolved {@link accessedArg}
18
+ */
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;
24
+ }
25
+ /**
26
+ * Filters the single indices of the {@link indicesCollection} according to the lexeme of the {@link accessArg}.
27
+ *
28
+ * @param indicesCollection - The {@link ContainerIndicesCollection} to filter
29
+ * @param accessArg - The argument which is used to filter {@link indicesCollection}
30
+ * @returns The filtered copy of {@link indicesCollection}
31
+ */
32
+ function filterIndices(indicesCollection, accessArg) {
33
+ let accessedIndicesCollection = undefined;
34
+ for (const indices of indicesCollection ?? []) {
35
+ const filteredIndices = indices.indices.filter(index => accessArg.lexeme === index.lexeme);
36
+ if (filteredIndices.length == 0) {
37
+ continue;
38
+ }
39
+ accessedIndicesCollection ??= [];
40
+ accessedIndicesCollection.push({
41
+ indices: filteredIndices,
42
+ isContainer: indices.isContainer
43
+ });
44
+ }
45
+ return accessedIndicesCollection;
46
+ }
47
+ /**
48
+ * Constructs the definition of a nested access.
49
+ *
50
+ * Example:
51
+ * ```r
52
+ * person$credentials$username
53
+ * ```
54
+ * would result in a list with the index `credentials`, which has the subIndex `username`.
55
+ *
56
+ * @param accessedArg - The top level argument that is accessed
57
+ * @param leafIndices - The index at the end of the nested access i.e. `c` in `a$b$c`.
58
+ * @returns The constructed nested access
59
+ */
60
+ function constructNestedAccess(accessedArg, leafIndices) {
61
+ const accessed = accessedArg.accessed;
62
+ const accesses = accessedArg.access.filter(arg => arg !== r_function_call_1.EmptyArgument).map(arg => arg);
63
+ const indices = [];
64
+ for (const access of accesses) {
65
+ const newIndices = {
66
+ indices: [
67
+ {
68
+ lexeme: access.lexeme,
69
+ nodeId: access.info.id,
70
+ subIndices: [leafIndices],
71
+ }
72
+ ],
73
+ isContainer: false,
74
+ };
75
+ if (accessed.type === type_1.RType.Access) {
76
+ const nestedIndices = constructNestedAccess(accessed, newIndices);
77
+ indices.push(...nestedIndices);
78
+ }
79
+ else {
80
+ indices.push(newIndices);
81
+ }
82
+ }
83
+ return indices;
84
+ }
85
+ /**
86
+ * Adds the passed list of {@link leafSubIndices} to the leaf (sub-)indices of {@link indicesCollection}.
87
+ *
88
+ * @param indicesCollection - Indices where to add the sub indices.
89
+ * @param leafSubIndices - Indices that are added to the leaf indices.
90
+ */
91
+ function addSubIndicesToLeafIndices(indicesCollection, leafSubIndices) {
92
+ const result = [];
93
+ for (const indices of indicesCollection) {
94
+ const newIndices = [];
95
+ for (const index of indices.indices) {
96
+ let newSubIndices = [];
97
+ if ((0, vertex_1.isParentContainerIndex)(index)) {
98
+ newSubIndices = addSubIndicesToLeafIndices(index.subIndices, leafSubIndices);
99
+ }
100
+ else {
101
+ newSubIndices = leafSubIndices;
102
+ }
103
+ newIndices.push({
104
+ ...index,
105
+ subIndices: newSubIndices,
106
+ });
107
+ }
108
+ result.push({
109
+ ...indices,
110
+ indices: newIndices,
111
+ });
112
+ }
113
+ return result;
114
+ }
115
+ //# sourceMappingURL=list-access.js.map
@@ -16,7 +16,7 @@ function cfgToMermaid(cfg, normalizedAst, prefix = '') {
16
16
  output += ` n${id}[${name}]\n`;
17
17
  }
18
18
  else {
19
- output += ` n${id}(( ))\n`;
19
+ output += String(id).endsWith('-exit') ? ` n${id}((${id}))\n` : ` n${id}[[${id}]]\n`;
20
20
  }
21
21
  }
22
22
  for (const [from, targets] of cfg.graph.edges()) {
@@ -27,11 +27,11 @@ function summarizeMeasurement(data, totalNumberOfDataPoints) {
27
27
  const min = sorted[0];
28
28
  const max = sorted[sorted.length - 1];
29
29
  const median = sorted[Math.floor(sorted.length / 2)];
30
- const total = (0, arrays_1.sum)(sorted);
30
+ const total = (0, arrays_1.arraySum)(sorted);
31
31
  const length = totalNumberOfDataPoints ?? sorted.length;
32
32
  const mean = total / length;
33
33
  // sqrt(sum(x-mean)^2 / n)
34
- const std = Math.sqrt(sorted.map(x => (x - mean) ** 2).reduce((a, b) => a + b, 0) / length);
34
+ const std = Math.sqrt((0, arrays_1.arraySum)(sorted.map(x => (x - mean) ** 2)) / length);
35
35
  return { min, max, median, mean, std, total };
36
36
  }
37
37
  //# sourceMappingURL=summarizer.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.1.8';
6
+ const version = '2.1.10';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }