@eagleoutice/flowr 2.2.16 → 2.4.0

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 (147) hide show
  1. package/README.md +48 -20
  2. package/abstract-interpretation/data-frame/absint-info.d.ts +109 -0
  3. package/abstract-interpretation/data-frame/absint-info.js +31 -0
  4. package/abstract-interpretation/data-frame/absint-visitor.d.ts +58 -0
  5. package/abstract-interpretation/data-frame/absint-visitor.js +171 -0
  6. package/abstract-interpretation/data-frame/domain.d.ts +107 -0
  7. package/abstract-interpretation/data-frame/domain.js +315 -0
  8. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +17 -0
  9. package/abstract-interpretation/data-frame/mappers/access-mapper.js +166 -0
  10. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +117 -0
  11. package/abstract-interpretation/data-frame/mappers/arguments.js +188 -0
  12. package/abstract-interpretation/data-frame/mappers/assignment-mapper.d.ts +20 -0
  13. package/abstract-interpretation/data-frame/mappers/assignment-mapper.js +34 -0
  14. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +261 -0
  15. package/abstract-interpretation/data-frame/mappers/function-mapper.js +1219 -0
  16. package/abstract-interpretation/data-frame/mappers/replacement-mapper.d.ts +12 -0
  17. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +206 -0
  18. package/abstract-interpretation/data-frame/resolve-args.d.ts +42 -0
  19. package/abstract-interpretation/data-frame/resolve-args.js +118 -0
  20. package/abstract-interpretation/data-frame/semantics.d.ts +213 -0
  21. package/abstract-interpretation/data-frame/semantics.js +363 -0
  22. package/abstract-interpretation/data-frame/shape-inference.d.ts +38 -0
  23. package/abstract-interpretation/data-frame/shape-inference.js +111 -0
  24. package/benchmark/slicer.d.ts +15 -1
  25. package/benchmark/slicer.js +137 -0
  26. package/benchmark/stats/print.js +123 -45
  27. package/benchmark/stats/size-of.d.ts +7 -0
  28. package/benchmark/stats/size-of.js +1 -0
  29. package/benchmark/stats/stats.d.ts +30 -1
  30. package/benchmark/stats/stats.js +4 -2
  31. package/benchmark/summarizer/data.d.ts +33 -2
  32. package/benchmark/summarizer/first-phase/input.js +5 -1
  33. package/benchmark/summarizer/first-phase/process.js +47 -1
  34. package/benchmark/summarizer/second-phase/graph.js +1 -1
  35. package/benchmark/summarizer/second-phase/process.js +102 -4
  36. package/cli/benchmark-app.d.ts +2 -0
  37. package/cli/benchmark-app.js +2 -0
  38. package/cli/benchmark-helper-app.d.ts +2 -0
  39. package/cli/benchmark-helper-app.js +10 -3
  40. package/cli/common/options.js +4 -0
  41. package/cli/repl/commands/repl-query.js +1 -1
  42. package/cli/repl/server/connection.js +14 -5
  43. package/config.d.ts +31 -0
  44. package/config.js +21 -1
  45. package/control-flow/basic-cfg-guided-visitor.d.ts +1 -2
  46. package/control-flow/basic-cfg-guided-visitor.js +0 -6
  47. package/control-flow/cfg-simplification.d.ts +6 -0
  48. package/control-flow/cfg-simplification.js +18 -9
  49. package/control-flow/control-flow-graph.d.ts +3 -8
  50. package/control-flow/control-flow-graph.js +5 -6
  51. package/control-flow/dfg-cfg-guided-visitor.js +1 -1
  52. package/control-flow/extract-cfg.d.ts +2 -2
  53. package/control-flow/extract-cfg.js +52 -63
  54. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  55. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  56. package/core/steps/all/static-slicing/00-slice.d.ts +7 -1
  57. package/core/steps/all/static-slicing/00-slice.js +9 -3
  58. package/core/steps/pipeline/default-pipelines.d.ts +74 -74
  59. package/dataflow/environments/built-in.d.ts +7 -5
  60. package/dataflow/environments/built-in.js +16 -13
  61. package/dataflow/eval/resolve/alias-tracking.js +2 -2
  62. package/dataflow/eval/resolve/resolve.d.ts +53 -9
  63. package/dataflow/eval/resolve/resolve.js +132 -38
  64. package/dataflow/graph/dataflowgraph-builder.js +2 -2
  65. package/dataflow/graph/graph.js +1 -1
  66. package/dataflow/graph/invert-dfg.d.ts +2 -0
  67. package/dataflow/graph/invert-dfg.js +17 -0
  68. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -0
  69. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +4 -0
  70. package/documentation/doc-util/doc-query.js +11 -1
  71. package/documentation/doc-util/doc-search.js +2 -2
  72. package/documentation/print-cfg-wiki.js +3 -4
  73. package/documentation/print-core-wiki.js +2 -2
  74. package/documentation/print-dataflow-graph-wiki.js +7 -0
  75. package/documentation/print-faq-wiki.js +4 -0
  76. package/documentation/print-interface-wiki.js +11 -0
  77. package/documentation/print-linter-wiki.js +36 -4
  78. package/documentation/print-linting-and-testing-wiki.js +13 -1
  79. package/documentation/print-onboarding-wiki.js +4 -0
  80. package/documentation/print-query-wiki.js +29 -3
  81. package/linter/linter-executor.js +1 -2
  82. package/linter/linter-format.d.ts +26 -4
  83. package/linter/linter-format.js +25 -6
  84. package/linter/linter-rules.d.ts +63 -12
  85. package/linter/linter-rules.js +5 -1
  86. package/linter/rules/absolute-path.d.ts +4 -7
  87. package/linter/rules/absolute-path.js +9 -6
  88. package/linter/rules/dataframe-access-validation.d.ts +55 -0
  89. package/linter/rules/dataframe-access-validation.js +118 -0
  90. package/linter/rules/dead-code.d.ts +43 -0
  91. package/linter/rules/dead-code.js +50 -0
  92. package/linter/rules/deprecated-functions.d.ts +3 -2
  93. package/linter/rules/deprecated-functions.js +3 -1
  94. package/linter/rules/file-path-validity.d.ts +4 -4
  95. package/linter/rules/file-path-validity.js +8 -6
  96. package/linter/rules/naming-convention.d.ts +5 -4
  97. package/linter/rules/naming-convention.js +8 -2
  98. package/linter/rules/seeded-randomness.d.ts +4 -3
  99. package/linter/rules/seeded-randomness.js +3 -1
  100. package/linter/rules/unused-definition.d.ts +2 -0
  101. package/linter/rules/unused-definition.js +3 -1
  102. package/package.json +2 -2
  103. package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -1
  104. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -0
  105. package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
  106. package/queries/catalog/df-shape-query/df-shape-query-executor.d.ts +3 -0
  107. package/queries/catalog/df-shape-query/df-shape-query-executor.js +46 -0
  108. package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +72 -0
  109. package/queries/catalog/df-shape-query/df-shape-query-format.js +31 -0
  110. package/queries/catalog/linter-query/linter-query-format.js +1 -1
  111. package/queries/catalog/location-map-query/location-map-query-executor.js +7 -5
  112. package/queries/catalog/location-map-query/location-map-query-format.d.ts +3 -0
  113. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  114. package/queries/catalog/search-query/search-query-executor.js +1 -1
  115. package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -1
  116. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +3 -0
  117. package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -1
  118. package/queries/query-print.d.ts +1 -1
  119. package/queries/query-print.js +0 -1
  120. package/queries/query.d.ts +77 -6
  121. package/queries/query.js +26 -11
  122. package/search/flowr-search-builder.d.ts +6 -6
  123. package/search/flowr-search-executor.d.ts +2 -2
  124. package/search/flowr-search-executor.js +1 -1
  125. package/search/flowr-search.d.ts +13 -8
  126. package/search/flowr-search.js +21 -0
  127. package/search/search-executor/search-enrichers.d.ts +87 -20
  128. package/search/search-executor/search-enrichers.js +44 -5
  129. package/search/search-executor/search-generators.d.ts +4 -4
  130. package/search/search-executor/search-generators.js +12 -7
  131. package/search/search-executor/search-mappers.js +3 -2
  132. package/search/search-executor/search-transformer.d.ts +3 -3
  133. package/search/search-executor/search-transformer.js +2 -2
  134. package/slicing/static/static-slicer.d.ts +4 -2
  135. package/slicing/static/static-slicer.js +10 -4
  136. package/util/collections/arrays.d.ts +2 -0
  137. package/util/collections/arrays.js +9 -0
  138. package/util/files.d.ts +8 -2
  139. package/util/files.js +22 -4
  140. package/util/mermaid/dfg.js +4 -2
  141. package/util/r-value.d.ts +23 -0
  142. package/util/r-value.js +113 -0
  143. package/util/range.d.ts +1 -0
  144. package/util/range.js +5 -1
  145. package/util/version.js +1 -1
  146. package/util/cfg/cfg.d.ts +0 -0
  147. package/util/cfg/cfg.js +0 -2
package/util/files.js CHANGED
@@ -124,36 +124,54 @@ function writeTableAsCsv(table, file, sep = ',', newline = '\n') {
124
124
  /**
125
125
  * Reads a file line by line and calls the given function for each line.
126
126
  * The `lineNumber` starts at `0`.
127
+ * The `maxLines` option limits the maximum number of read lines and is `Infinity` by default.
128
+ *
129
+ * @returns Whether all lines have been successfully read (`false` if `maxLines` was reached)
127
130
  *
128
131
  * See {@link readLineByLineSync} for a synchronous version.
129
132
  */
130
- async function readLineByLine(filePath, onLine) {
133
+ async function readLineByLine(filePath, onLine, maxLines = Infinity) {
134
+ if (!(await fs_1.default.promises.stat(filePath).catch(() => { }))?.isFile()) {
135
+ log_1.log.warn(`File ${filePath} does not exist`);
136
+ return false;
137
+ }
131
138
  const reader = new n_readlines_1.default(filePath);
132
139
  let line;
133
140
  let counter = 0;
134
141
  // eslint-disable-next-line no-cond-assign
135
142
  while (line = reader.next()) {
143
+ if (counter >= maxLines) {
144
+ return false;
145
+ }
136
146
  await onLine(line, counter++);
137
147
  }
148
+ return true;
138
149
  }
139
150
  /**
140
151
  * Reads a file line by line and calls the given function for each line.
141
152
  * The `lineNumber` starts at `0`.
153
+ * The `maxLines` option limits the maximum number of read lines and is `Infinity` by default.
154
+ *
155
+ * @returns Whether the file exists and all lines have been successfully read (`false` if `maxLines` was reached)
142
156
  *
143
157
  * See {@link readLineByLine} for an asynchronous version.
144
158
  */
145
- function readLineByLineSync(filePath, onLine) {
146
- if (!fs_1.default.existsSync(filePath)) {
159
+ function readLineByLineSync(filePath, onLine, maxLines = Infinity) {
160
+ if (!fs_1.default.statSync(filePath, { throwIfNoEntry: false })?.isFile()) {
147
161
  log_1.log.warn(`File ${filePath} does not exist`);
148
- return;
162
+ return false;
149
163
  }
150
164
  const reader = new n_readlines_1.default(filePath);
151
165
  let line;
152
166
  let counter = 0;
153
167
  // eslint-disable-next-line no-cond-assign
154
168
  while (line = reader.next()) {
169
+ if (counter >= maxLines) {
170
+ return false;
171
+ }
155
172
  onLine(line, counter++);
156
173
  }
174
+ return true;
157
175
  }
158
176
  /**
159
177
  * Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
@@ -6,7 +6,6 @@ exports.graphToMermaid = graphToMermaid;
6
6
  exports.graphToMermaidUrl = graphToMermaidUrl;
7
7
  exports.diffGraphsToMermaid = diffGraphsToMermaid;
8
8
  exports.diffGraphsToMermaidUrl = diffGraphsToMermaidUrl;
9
- const assert_1 = require("../assert");
10
9
  const mermaid_1 = require("./mermaid");
11
10
  const graph_1 = require("../../dataflow/graph/graph");
12
11
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
@@ -176,7 +175,10 @@ function vertexToMermaid(info, mermaid, id, idPrefix, mark) {
176
175
  mermaid.nodeLines.push(` style ${idPrefix}${id} stroke:red,stroke-width:5px; `);
177
176
  }
178
177
  const edges = mermaid.rootGraph.get((0, node_id_1.normalizeIdToNumberIfPossible)(id), true);
179
- (0, assert_1.guard)(edges !== undefined, `node ${id} must be found`);
178
+ if (edges === undefined) {
179
+ mermaid.nodeLines.push(' %% No edges found for ' + id);
180
+ return;
181
+ }
180
182
  const artificialCdEdges = (info.cds ?? []).map(x => [x.id, { types: new Set([x.when ? 'CD-True' : 'CD-False']) }]);
181
183
  // eslint-disable-next-line prefer-const
182
184
  for (let [target, edge] of [...edges[1], ...artificialCdEdges]) {
@@ -0,0 +1,23 @@
1
+ import type { Value, ValueInterval, ValueLogical, ValueNumber, ValueString, ValueVector } from '../dataflow/eval/values/r-value';
2
+ import type { RLogicalValue } from '../r-bridge/lang-4.x/ast/model/nodes/r-logical';
3
+ import { type RNumberValue, type RStringValue } from '../r-bridge/lang-4.x/convert-values';
4
+ export declare function isRStringValue(value: unknown): value is RStringValue;
5
+ export declare function isRNumberValue(value: unknown): value is RNumberValue;
6
+ export declare function isRLogicalValue(value: unknown): value is RLogicalValue;
7
+ export declare function unwrapRValue(value: RStringValue | string): string;
8
+ export declare function unwrapRValue(value: RNumberValue | number): number;
9
+ export declare function unwrapRValue(value: RLogicalValue): boolean;
10
+ export declare function unwrapRValue(value: RStringValue | RNumberValue | RLogicalValue | string | number): string | number | boolean;
11
+ export declare function unwrapRValue(value: unknown): string | number | boolean | undefined;
12
+ export declare function unwrapRVector(value: RStringValue[] | string[]): string[];
13
+ export declare function unwrapRVector(value: RNumberValue[] | number[]): number[];
14
+ export declare function unwrapRVector(value: RLogicalValue[]): boolean[];
15
+ export declare function unwrapRVector(value: RStringValue[] | RNumberValue[] | RLogicalValue[] | string[] | number[]): string[] | number[] | boolean[];
16
+ export declare function unwrapRVector(value: unknown): string[] | number[] | boolean[] | (string | number | boolean)[] | undefined;
17
+ export declare function unwrapRValueToString(value: RStringValue | RNumberValue | RLogicalValue | string | number): string;
18
+ export declare function unwrapRValueToString(value: unknown): string | undefined;
19
+ export declare function unliftRValue(value: ValueString): RStringValue | undefined;
20
+ export declare function unliftRValue(value: ValueNumber | ValueInterval): RNumberValue | undefined;
21
+ export declare function unliftRValue(value: ValueLogical): RLogicalValue | undefined;
22
+ export declare function unliftRValue(value: ValueVector): (RStringValue | RNumberValue | RLogicalValue)[] | undefined;
23
+ export declare function unliftRValue(value: Value): RStringValue | RNumberValue | boolean | (RStringValue | RNumberValue | RLogicalValue)[] | undefined;
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isRStringValue = isRStringValue;
4
+ exports.isRNumberValue = isRNumberValue;
5
+ exports.isRLogicalValue = isRLogicalValue;
6
+ exports.unwrapRValue = unwrapRValue;
7
+ exports.unwrapRVector = unwrapRVector;
8
+ exports.unwrapRValueToString = unwrapRValueToString;
9
+ exports.unliftRValue = unliftRValue;
10
+ const r_value_1 = require("../dataflow/eval/values/r-value");
11
+ const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
12
+ const assert_1 = require("./assert");
13
+ function isRValue(value) {
14
+ return isRStringValue(value) || isRNumberValue(value) || isRLogicalValue(value) || typeof value === 'string' || typeof value === 'number';
15
+ }
16
+ function isRStringValue(value) {
17
+ return typeof value === 'object' && value !== null && 'str' in value && typeof value.str === 'string';
18
+ }
19
+ function isRNumberValue(value) {
20
+ return typeof value === 'object' && value !== null && 'num' in value && typeof value.num === 'number';
21
+ }
22
+ function isRLogicalValue(value) {
23
+ return typeof value === 'boolean';
24
+ }
25
+ function unwrapRValue(value) {
26
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
27
+ return value;
28
+ }
29
+ else if (isRStringValue(value)) {
30
+ return value.str;
31
+ }
32
+ else if (isRNumberValue(value)) {
33
+ return value.num;
34
+ }
35
+ else {
36
+ return undefined;
37
+ }
38
+ }
39
+ function unwrapRVector(value) {
40
+ if (!Array.isArray(value)) {
41
+ return undefined;
42
+ }
43
+ else if (value.every(entry => typeof entry === 'string') || value.every(entry => typeof entry === 'number') || value.every(entry => typeof entry === 'boolean')) {
44
+ return value;
45
+ }
46
+ else if (value.every(isRStringValue)) {
47
+ return value.map(entry => unwrapRValue(entry));
48
+ }
49
+ else if (value.every(isRNumberValue)) {
50
+ return value.map(entry => unwrapRValue(entry));
51
+ }
52
+ else if (value.every(isRValue)) {
53
+ return value.map(entry => unwrapRValue(entry));
54
+ }
55
+ else {
56
+ return undefined;
57
+ }
58
+ }
59
+ function unwrapRValueToString(value) {
60
+ if (typeof value === 'string') {
61
+ return value;
62
+ }
63
+ else if (typeof value === 'number') {
64
+ return value.toString();
65
+ }
66
+ else if (typeof value === 'boolean') {
67
+ return value ? convert_values_1.RTrue : convert_values_1.RFalse;
68
+ }
69
+ else if (isRStringValue(value)) {
70
+ return value.str;
71
+ }
72
+ else if (isRNumberValue(value)) {
73
+ return value.num.toString();
74
+ }
75
+ else {
76
+ return undefined;
77
+ }
78
+ }
79
+ function unliftRValue(value) {
80
+ if (!(0, r_value_1.isValue)(value)) {
81
+ return undefined;
82
+ }
83
+ const type = value.type;
84
+ switch (type) {
85
+ case 'string': {
86
+ return (0, r_value_1.isValue)(value.value) ? value.value : undefined;
87
+ }
88
+ case 'number': {
89
+ return (0, r_value_1.isValue)(value.value) ? value.value : undefined;
90
+ }
91
+ case 'logical': {
92
+ return (0, r_value_1.isValue)(value.value) && typeof value.value === 'boolean' ? value.value : undefined;
93
+ }
94
+ case 'interval': {
95
+ const start = unliftRValue(value.start);
96
+ const end = unliftRValue(value.end);
97
+ return start !== undefined && end !== undefined && start.num === end.num ? start : undefined;
98
+ }
99
+ case 'vector': {
100
+ const values = (0, r_value_1.isValue)(value.elements) ? value.elements.map(unliftRValue) : undefined;
101
+ return values?.every(assert_1.isNotUndefined) ? values.flat() : undefined;
102
+ }
103
+ case 'set': {
104
+ return (0, r_value_1.isValue)(value.elements) && value.elements.length === 1 ? unliftRValue(value.elements[0]) : undefined;
105
+ }
106
+ case 'missing': {
107
+ return undefined;
108
+ }
109
+ default:
110
+ (0, assert_1.assertUnreachable)(type);
111
+ }
112
+ }
113
+ //# sourceMappingURL=r-value.js.map
package/util/range.d.ts CHANGED
@@ -68,3 +68,4 @@ export declare function rangeCompare([r1sl, r1sc, ,]: SourceRange, [r2sl, r2sc,
68
68
  * Checks if the first range is a subset of the second range.
69
69
  */
70
70
  export declare function rangeIsSubsetOf([r1sl, r1sc, r1el, r1ec]: SourceRange, [r2sl, r2sc, r2el, r2ec]: SourceRange): boolean;
71
+ export declare function combineRanges(...ranges: SourceRange[]): SourceRange[];
package/util/range.js CHANGED
@@ -9,6 +9,7 @@ exports.rangesOverlap = rangesOverlap;
9
9
  exports.addRanges = addRanges;
10
10
  exports.rangeCompare = rangeCompare;
11
11
  exports.rangeIsSubsetOf = rangeIsSubsetOf;
12
+ exports.combineRanges = combineRanges;
12
13
  const assert_1 = require("./assert");
13
14
  function getRangeStart(p) {
14
15
  return p === undefined ? undefined : [p[0], p[1]];
@@ -70,6 +71,9 @@ function rangeCompare([r1sl, r1sc, ,], [r2sl, r2sc, ,]) {
70
71
  * Checks if the first range is a subset of the second range.
71
72
  */
72
73
  function rangeIsSubsetOf([r1sl, r1sc, r1el, r1ec], [r2sl, r2sc, r2el, r2ec]) {
73
- return r1sl >= r2sl && r1sc >= r2sc && r1el <= r2el && r1ec <= r2ec;
74
+ return (r1sl > r2sl || r1sl === r2sl && r1sc >= r2sc) && (r1el < r2el || r1sl === r2sl && r1ec <= r2ec);
75
+ }
76
+ function combineRanges(...ranges) {
77
+ return ranges.filter(range => !ranges.some(other => range !== other && rangeIsSubsetOf(range, other)));
74
78
  }
75
79
  //# sourceMappingURL=range.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.16';
6
+ const version = '2.4.0';
7
7
  function flowrVersion() {
8
8
  return new semver_1.SemVer(version);
9
9
  }
package/util/cfg/cfg.d.ts DELETED
File without changes
package/util/cfg/cfg.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=cfg.js.map