@eagleoutice/flowr 1.3.13 → 1.4.1

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 (221) hide show
  1. package/abstract-interpretation/domain.d.ts +27 -0
  2. package/abstract-interpretation/domain.js +146 -0
  3. package/abstract-interpretation/handler/binop/binop.d.ts +16 -0
  4. package/abstract-interpretation/handler/binop/binop.js +40 -0
  5. package/abstract-interpretation/handler/binop/operators.d.ts +2 -0
  6. package/abstract-interpretation/handler/binop/operators.js +42 -0
  7. package/abstract-interpretation/handler/handler.d.ts +6 -0
  8. package/abstract-interpretation/handler/handler.js +3 -0
  9. package/abstract-interpretation/processor.d.ts +10 -0
  10. package/abstract-interpretation/processor.js +78 -0
  11. package/benchmark/slicer.d.ts +6 -5
  12. package/benchmark/slicer.js +2 -0
  13. package/benchmark/stats/print.d.ts +1 -1
  14. package/benchmark/stats/stats.d.ts +4 -4
  15. package/benchmark/stats/stats.js +1 -1
  16. package/cli/common/features.d.ts +1 -1
  17. package/cli/common/options.d.ts +1 -1
  18. package/cli/common/script.d.ts +1 -1
  19. package/cli/common/scripts-info.d.ts +2 -2
  20. package/cli/repl/commands/cfg.d.ts +1 -1
  21. package/cli/repl/commands/cfg.js +1 -1
  22. package/cli/repl/commands/commands.d.ts +1 -1
  23. package/cli/repl/commands/dataflow.d.ts +1 -1
  24. package/cli/repl/commands/execute.d.ts +2 -2
  25. package/cli/repl/commands/main.d.ts +2 -2
  26. package/cli/repl/commands/normalize.d.ts +1 -1
  27. package/cli/repl/commands/parse.d.ts +1 -1
  28. package/cli/repl/commands/quit.d.ts +1 -1
  29. package/cli/repl/commands/version.d.ts +1 -1
  30. package/cli/repl/core.d.ts +3 -5
  31. package/cli/repl/core.js +33 -6
  32. package/cli/repl/execute.d.ts +1 -1
  33. package/cli/repl/server/connection.d.ts +2 -2
  34. package/cli/repl/server/connection.js +3 -2
  35. package/cli/repl/server/messages/analysis.d.ts +3 -3
  36. package/cli/repl/server/messages/error.d.ts +1 -1
  37. package/cli/repl/server/messages/hello.d.ts +2 -2
  38. package/cli/repl/server/messages/messages.d.ts +6 -6
  39. package/cli/repl/server/messages/messages.js +26 -6
  40. package/cli/repl/server/messages/repl.d.ts +1 -1
  41. package/cli/repl/server/messages/repl.js +28 -8
  42. package/cli/repl/server/messages/slice.d.ts +3 -3
  43. package/cli/repl/server/messages/slice.js +28 -8
  44. package/cli/repl/server/net.d.ts +16 -0
  45. package/cli/repl/server/net.js +40 -1
  46. package/cli/repl/server/send.d.ts +2 -2
  47. package/cli/repl/server/server.d.ts +2 -2
  48. package/cli/repl/server/validate.d.ts +3 -3
  49. package/cli/statistics-helper-app.js +2 -2
  50. package/core/input.d.ts +6 -6
  51. package/core/output.d.ts +3 -2
  52. package/core/print/dataflow-printer.d.ts +3 -3
  53. package/core/print/normalize-printer.d.ts +2 -2
  54. package/core/print/parse-printer.d.ts +2 -2
  55. package/core/print/print.d.ts +1 -1
  56. package/core/print/slice-diff-ansi.d.ts +1 -1
  57. package/core/slicer.d.ts +5 -4
  58. package/core/slicer.js +6 -2
  59. package/core/steps.d.ts +22 -4
  60. package/core/steps.js +10 -2
  61. package/dataflow/environments/append.d.ts +1 -1
  62. package/dataflow/environments/environment.d.ts +4 -4
  63. package/dataflow/environments/overwrite.d.ts +1 -1
  64. package/dataflow/environments/register.d.ts +2 -2
  65. package/dataflow/environments/resolve-by-name.d.ts +2 -2
  66. package/dataflow/environments/scoping.d.ts +1 -1
  67. package/dataflow/extractor.d.ts +4 -4
  68. package/dataflow/graph/diff.d.ts +3 -3
  69. package/dataflow/graph/graph.d.ts +8 -7
  70. package/dataflow/graph/quads.d.ts +2 -2
  71. package/dataflow/graph/vertex.d.ts +5 -5
  72. package/dataflow/internal/info.d.ts +2 -2
  73. package/dataflow/internal/linker.d.ts +3 -3
  74. package/dataflow/internal/process/access.d.ts +3 -3
  75. package/dataflow/internal/process/expression-list.d.ts +3 -3
  76. package/dataflow/internal/process/expression-list.js +0 -4
  77. package/dataflow/internal/process/functions/argument.d.ts +4 -4
  78. package/dataflow/internal/process/functions/exit-points.d.ts +1 -1
  79. package/dataflow/internal/process/functions/function-call.d.ts +3 -3
  80. package/dataflow/internal/process/functions/function-definition.d.ts +3 -3
  81. package/dataflow/internal/process/functions/parameter.d.ts +3 -3
  82. package/dataflow/internal/process/if-then-else.d.ts +3 -3
  83. package/dataflow/internal/process/loops/for-loop.d.ts +3 -3
  84. package/dataflow/internal/process/loops/repeat-loop.d.ts +3 -3
  85. package/dataflow/internal/process/loops/while-loop.d.ts +3 -3
  86. package/dataflow/internal/process/operators/assignment.d.ts +3 -3
  87. package/dataflow/internal/process/operators/non-assignment-binary-op.d.ts +3 -3
  88. package/dataflow/internal/process/operators/pipe.d.ts +3 -3
  89. package/dataflow/internal/process/operators/unary-op.d.ts +3 -3
  90. package/dataflow/internal/process/symbol.d.ts +3 -3
  91. package/dataflow/internal/process/uninteresting-leaf.d.ts +2 -2
  92. package/dataflow/processor.d.ts +3 -3
  93. package/flowr.d.ts +3 -2
  94. package/flowr.js +5 -3
  95. package/package.json +11 -2
  96. package/r-bridge/lang-4.x/ast/model/collect.d.ts +2 -2
  97. package/r-bridge/lang-4.x/ast/model/model.d.ts +6 -6
  98. package/r-bridge/lang-4.x/ast/model/nodes/info/index.d.ts +2 -2
  99. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +3 -3
  100. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -3
  101. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -3
  102. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -3
  103. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -2
  104. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -2
  105. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -2
  106. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +4 -4
  107. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -4
  108. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +4 -4
  109. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -3
  110. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -2
  111. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -2
  112. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -2
  113. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -3
  114. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -3
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -2
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -3
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -3
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -2
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -3
  120. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -3
  121. package/r-bridge/lang-4.x/ast/model/operators.d.ts +1 -1
  122. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
  123. package/r-bridge/lang-4.x/ast/model/processing/fold.d.ts +3 -3
  124. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +1 -1
  125. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +3 -3
  126. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +1 -1
  127. package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +2 -2
  128. package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +5 -5
  129. package/r-bridge/lang-4.x/ast/parser/xml/hooks.d.ts +5 -5
  130. package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +1 -1
  131. package/r-bridge/lang-4.x/ast/parser/xml/internal/access.d.ts +3 -3
  132. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.d.ts +3 -3
  133. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.d.ts +3 -3
  134. package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.d.ts +3 -3
  135. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.d.ts +3 -3
  136. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.d.ts +3 -3
  137. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.d.ts +3 -3
  138. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.d.ts +3 -3
  139. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.d.ts +3 -3
  140. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.d.ts +3 -3
  141. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.d.ts +3 -3
  142. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.d.ts +3 -3
  143. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.d.ts +3 -3
  144. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +4 -4
  145. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.d.ts +3 -3
  146. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/special.d.ts +1 -1
  147. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.d.ts +3 -3
  148. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.d.ts +3 -3
  149. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.d.ts +3 -3
  150. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.d.ts +4 -4
  151. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.d.ts +3 -3
  152. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.d.ts +4 -4
  153. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.d.ts +4 -4
  154. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.d.ts +3 -3
  155. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.d.ts +3 -3
  156. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +2 -2
  157. package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +4 -4
  158. package/r-bridge/retriever.d.ts +2 -2
  159. package/r-bridge/shell-executor.d.ts +25 -0
  160. package/r-bridge/shell-executor.js +119 -0
  161. package/r-bridge/shell.d.ts +8 -5
  162. package/r-bridge/shell.js +6 -3
  163. package/reconstruct/reconstruct.d.ts +1 -1
  164. package/slicing/criterion/collect-all.d.ts +3 -3
  165. package/slicing/criterion/filters/all-variables.d.ts +1 -1
  166. package/slicing/criterion/parse.d.ts +1 -1
  167. package/slicing/static/static-slicer.d.ts +3 -3
  168. package/statistics/features/common-syntax-probability.d.ts +3 -2
  169. package/statistics/features/common-syntax-probability.js +0 -3
  170. package/statistics/features/feature.d.ts +6 -6
  171. package/statistics/features/post-processing.d.ts +2 -2
  172. package/statistics/features/supported/assignments/assignments.d.ts +2 -2
  173. package/statistics/features/supported/assignments/post-process.d.ts +2 -2
  174. package/statistics/features/supported/comments/comments.d.ts +2 -2
  175. package/statistics/features/supported/comments/post-process.d.ts +2 -2
  176. package/statistics/features/supported/control-flow/control-flow.d.ts +2 -2
  177. package/statistics/features/supported/control-flow/post-process.d.ts +2 -2
  178. package/statistics/features/supported/data-access/data-access.d.ts +3 -3
  179. package/statistics/features/supported/data-access/post-process.d.ts +2 -2
  180. package/statistics/features/supported/defined-functions/defined-functions.d.ts +4 -4
  181. package/statistics/features/supported/defined-functions/post-process.d.ts +2 -2
  182. package/statistics/features/supported/expression-list/expression-list.d.ts +2 -2
  183. package/statistics/features/supported/expression-list/post-process.d.ts +2 -2
  184. package/statistics/features/supported/loops/loops.d.ts +2 -2
  185. package/statistics/features/supported/loops/post-process.d.ts +2 -2
  186. package/statistics/features/supported/used-functions/post-process.d.ts +2 -2
  187. package/statistics/features/supported/used-functions/used-functions.d.ts +3 -3
  188. package/statistics/features/supported/used-packages/post-process.d.ts +2 -2
  189. package/statistics/features/supported/used-packages/used-packages.d.ts +2 -2
  190. package/statistics/features/supported/values/post-process.d.ts +2 -2
  191. package/statistics/features/supported/values/values.d.ts +2 -2
  192. package/statistics/features/supported/variables/post-process.d.ts +3 -3
  193. package/statistics/features/supported/variables/variables.d.ts +2 -2
  194. package/statistics/meta-statistics.d.ts +1 -1
  195. package/statistics/output/print-stats.d.ts +2 -2
  196. package/statistics/output/statistics-file.d.ts +1 -1
  197. package/statistics/statistics.d.ts +4 -4
  198. package/util/{cfg.d.ts → cfg/cfg.d.ts} +18 -6
  199. package/util/{cfg.js → cfg/cfg.js} +42 -37
  200. package/util/cfg/visitor.d.ts +14 -0
  201. package/util/cfg/visitor.js +64 -0
  202. package/util/diff.d.ts +1 -1
  203. package/util/files.d.ts +1 -1
  204. package/util/mermaid/ast.d.ts +1 -1
  205. package/util/mermaid/cfg.d.ts +2 -2
  206. package/util/mermaid/dfg.d.ts +3 -3
  207. package/util/objects.d.ts +1 -1
  208. package/util/quads.d.ts +2 -2
  209. package/util/summarizer/benchmark/data.d.ts +1 -1
  210. package/util/summarizer/benchmark/first-phase/process.d.ts +3 -3
  211. package/util/summarizer/benchmark/second-phase/graph.d.ts +1 -1
  212. package/util/summarizer/benchmark/second-phase/process.d.ts +1 -1
  213. package/util/summarizer/benchmark/summarizer.d.ts +3 -2
  214. package/util/summarizer/benchmark/summarizer.js +0 -4
  215. package/util/summarizer/statistics/post-process/clusterer.d.ts +2 -2
  216. package/util/summarizer/statistics/post-process/file-based-count.d.ts +1 -1
  217. package/util/summarizer/statistics/post-process/histogram.d.ts +2 -2
  218. package/util/summarizer/statistics/post-process/post-process-output.d.ts +2 -2
  219. package/util/summarizer/statistics/second-phase/process.d.ts +2 -2
  220. package/util/summarizer/statistics/summarizer.d.ts +3 -2
  221. package/util/summarizer/summarizer.d.ts +1 -1
@@ -0,0 +1,27 @@
1
+ interface IntervalBound {
2
+ readonly value: number;
3
+ readonly inclusive: boolean;
4
+ }
5
+ export declare class Interval {
6
+ readonly min: IntervalBound;
7
+ readonly max: IntervalBound;
8
+ constructor(min: IntervalBound, max: IntervalBound);
9
+ toString(): string;
10
+ }
11
+ export declare class Domain {
12
+ private readonly _intervals;
13
+ private constructor();
14
+ static bottom(): Domain;
15
+ static fromIntervals(intervals: Interval[] | Set<Interval>): Domain;
16
+ static fromScalar(n: number): Domain;
17
+ get intervals(): Set<Interval>;
18
+ private set intervals(value);
19
+ addInterval(interval: Interval): void;
20
+ toString(): string;
21
+ }
22
+ export declare function doIntervalsOverlap(interval1: Interval, interval2: Interval): boolean;
23
+ export declare function unifyDomains(domains: Domain[]): Domain;
24
+ export declare function unifyOverlappingIntervals(intervals: Interval[]): Interval[];
25
+ export declare function addDomains(domain1: Domain, domain2: Domain): Domain;
26
+ export declare function subtractDomains(domain1: Domain, domain2: Domain): Domain;
27
+ export {};
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.subtractDomains = exports.addDomains = exports.unifyOverlappingIntervals = exports.unifyDomains = exports.doIntervalsOverlap = exports.Domain = exports.Interval = void 0;
4
+ const assert_1 = require("../util/assert");
5
+ class Interval {
6
+ min;
7
+ max;
8
+ constructor(min, max) {
9
+ this.min = min;
10
+ this.max = max;
11
+ (0, assert_1.guard)(min.value <= max.value, () => `The interval ${this.toString()} has a minimum that is greater than its maximum`);
12
+ (0, assert_1.guard)(min.value !== max.value || (min.inclusive === max.inclusive), `The bound ${min.value} cannot be in- and exclusive at the same time`);
13
+ }
14
+ toString() {
15
+ return `${this.min.inclusive ? '[' : '('}${this.min.value}, ${this.max.value}${this.max.inclusive ? ']' : ')'}`;
16
+ }
17
+ }
18
+ exports.Interval = Interval;
19
+ class Domain {
20
+ _intervals;
21
+ constructor(intervals = []) {
22
+ this._intervals = new Set(unifyOverlappingIntervals(intervals));
23
+ }
24
+ static bottom() {
25
+ return new Domain();
26
+ }
27
+ static fromIntervals(intervals) {
28
+ return new Domain(Array.from(intervals));
29
+ }
30
+ static fromScalar(n) {
31
+ return new Domain([new Interval({ value: n, inclusive: true }, { value: n, inclusive: true })]);
32
+ }
33
+ get intervals() {
34
+ return this._intervals;
35
+ }
36
+ set intervals(intervals) {
37
+ this._intervals.clear();
38
+ for (const interval of intervals) {
39
+ this._intervals.add(interval);
40
+ }
41
+ }
42
+ addInterval(interval) {
43
+ this.intervals = unifyOverlappingIntervals([...this.intervals, interval]);
44
+ }
45
+ toString() {
46
+ return `{${Array.from(this.intervals).join(', ')}}`;
47
+ }
48
+ }
49
+ exports.Domain = Domain;
50
+ function compareIntervals(compareType, interval1, interval2) {
51
+ const diff = interval1.value - interval2.value;
52
+ if (diff !== 0 || compareType === 2 /* CompareType.IgnoreInclusivity */) {
53
+ return diff;
54
+ }
55
+ switch (compareType) {
56
+ case 0 /* CompareType.Min */:
57
+ return Number(!interval1.inclusive) - Number(!interval2.inclusive);
58
+ case 1 /* CompareType.Max */:
59
+ return Number(interval1.inclusive) - Number(interval2.inclusive);
60
+ default:
61
+ (0, assert_1.assertUnreachable)(compareType);
62
+ }
63
+ }
64
+ function compareIntervalsByTheirMinimum(interval1, interval2) {
65
+ return compareIntervals(0 /* CompareType.Min */, interval1.min, interval2.min);
66
+ }
67
+ function compareIntervalsByTheirMaximum(interval1, interval2) {
68
+ return compareIntervals(1 /* CompareType.Max */, interval1.max, interval2.max);
69
+ }
70
+ function doIntervalsOverlap(interval1, interval2) {
71
+ const diff1 = compareIntervals(2 /* CompareType.IgnoreInclusivity */, interval1.max, interval2.min);
72
+ const diff2 = compareIntervals(2 /* CompareType.IgnoreInclusivity */, interval2.max, interval1.min);
73
+ // If one interval ends before the other starts, they don't overlap
74
+ if (diff1 < 0 || diff2 < 0) {
75
+ return false;
76
+ }
77
+ // If their end and start are equal, they only overlap if both are inclusive
78
+ if (diff1 === 0) {
79
+ return interval1.max.inclusive && interval2.min.inclusive;
80
+ }
81
+ if (diff2 === 0) {
82
+ return interval2.max.inclusive && interval1.min.inclusive;
83
+ }
84
+ return true;
85
+ }
86
+ exports.doIntervalsOverlap = doIntervalsOverlap;
87
+ function unifyDomains(domains) {
88
+ const unifiedIntervals = unifyOverlappingIntervals(domains.flatMap(domain => Array.from(domain.intervals)));
89
+ return Domain.fromIntervals(unifiedIntervals);
90
+ }
91
+ exports.unifyDomains = unifyDomains;
92
+ function unifyOverlappingIntervals(intervals) {
93
+ if (intervals.length === 0) {
94
+ return [];
95
+ }
96
+ const sortedIntervals = intervals.sort(compareIntervalsByTheirMinimum);
97
+ const unifiedIntervals = [];
98
+ let currentInterval = sortedIntervals[0];
99
+ for (const nextInterval of sortedIntervals) {
100
+ if (doIntervalsOverlap(currentInterval, nextInterval)) {
101
+ const intervalWithEarlierStart = compareIntervalsByTheirMinimum(currentInterval, nextInterval) < 0 ? currentInterval : nextInterval;
102
+ const intervalWithLaterEnd = compareIntervalsByTheirMaximum(currentInterval, nextInterval) > 0 ? currentInterval : nextInterval;
103
+ currentInterval = new Interval(intervalWithEarlierStart.min, intervalWithLaterEnd.max);
104
+ }
105
+ else {
106
+ unifiedIntervals.push(currentInterval);
107
+ currentInterval = nextInterval;
108
+ }
109
+ }
110
+ unifiedIntervals.push(currentInterval);
111
+ return unifiedIntervals;
112
+ }
113
+ exports.unifyOverlappingIntervals = unifyOverlappingIntervals;
114
+ function addDomains(domain1, domain2) {
115
+ const intervals = new Set();
116
+ for (const interval1 of domain1.intervals) {
117
+ for (const interval2 of domain2.intervals) {
118
+ intervals.add(new Interval({
119
+ value: interval1.min.value + interval2.min.value,
120
+ inclusive: interval1.min.inclusive && interval2.min.inclusive
121
+ }, {
122
+ value: interval1.max.value + interval2.max.value,
123
+ inclusive: interval1.max.inclusive && interval2.max.inclusive
124
+ }));
125
+ }
126
+ }
127
+ return Domain.fromIntervals(intervals);
128
+ }
129
+ exports.addDomains = addDomains;
130
+ function subtractDomains(domain1, domain2) {
131
+ const intervals = new Set();
132
+ for (const interval1 of domain1.intervals) {
133
+ for (const interval2 of domain2.intervals) {
134
+ intervals.add(new Interval({
135
+ value: interval1.min.value - interval2.max.value,
136
+ inclusive: interval1.min.inclusive && interval2.max.inclusive
137
+ }, {
138
+ value: interval1.max.value - interval2.min.value,
139
+ inclusive: interval1.max.inclusive && interval2.min.inclusive
140
+ }));
141
+ }
142
+ }
143
+ return Domain.fromIntervals(intervals);
144
+ }
145
+ exports.subtractDomains = subtractDomains;
146
+ //# sourceMappingURL=domain.js.map
@@ -0,0 +1,16 @@
1
+ import type { Handler } from '../handler';
2
+ import type { AINode } from '../../processor';
3
+ import type { BinaryOperatorFlavor, ParentInformation, RBinaryOp } from '../../../r-bridge';
4
+ export type BinOpOperators = {
5
+ [key in BinaryOperatorFlavor]: (lhs: AINode, rhs: AINode, node: RBinaryOp<ParentInformation>) => AINode;
6
+ };
7
+ export declare class BinOp implements Handler<AINode> {
8
+ readonly node: RBinaryOp<ParentInformation>;
9
+ lhs: AINode | undefined;
10
+ rhs: AINode | undefined;
11
+ constructor(node: RBinaryOp<ParentInformation>);
12
+ getName(): string;
13
+ enter(): void;
14
+ exit(): AINode;
15
+ next(node: AINode): void;
16
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BinOp = void 0;
4
+ const processor_1 = require("../../processor");
5
+ const assert_1 = require("../../../util/assert");
6
+ const operators_1 = require("./operators");
7
+ class BinOp {
8
+ node;
9
+ lhs;
10
+ rhs;
11
+ constructor(node) {
12
+ this.node = node;
13
+ }
14
+ getName() {
15
+ return `Bin Op (${this.node.flavor})`;
16
+ }
17
+ enter() {
18
+ processor_1.aiLogger.trace(`Entered ${this.getName()}`);
19
+ }
20
+ exit() {
21
+ processor_1.aiLogger.trace(`Exited ${this.getName()}`);
22
+ (0, assert_1.guard)(this.lhs !== undefined, `No LHS found for assignment ${this.node.info.id}`);
23
+ (0, assert_1.guard)(this.rhs !== undefined, `No RHS found for assignment ${this.node.info.id}`);
24
+ return operators_1.operators[this.node.flavor](this.lhs, this.rhs, this.node);
25
+ }
26
+ next(node) {
27
+ processor_1.aiLogger.trace(`${this.getName()} received`);
28
+ if (this.lhs === undefined) {
29
+ this.lhs = node;
30
+ }
31
+ else if (this.rhs === undefined) {
32
+ this.rhs = node;
33
+ }
34
+ else {
35
+ (0, assert_1.guard)(false, `BinOp ${this.node.info.id} already has both LHS and RHS`);
36
+ }
37
+ }
38
+ }
39
+ exports.BinOp = BinOp;
40
+ //# sourceMappingURL=binop.js.map
@@ -0,0 +1,2 @@
1
+ import type { BinOpOperators } from './binop';
2
+ export declare const operators: BinOpOperators;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.operators = void 0;
4
+ const assert_1 = require("../../../util/assert");
5
+ const domain_1 = require("../../domain");
6
+ exports.operators = {
7
+ 'assignment': (lhs, rhs, node) => {
8
+ return {
9
+ id: lhs.id,
10
+ domain: rhs.domain,
11
+ astNode: node.lhs,
12
+ };
13
+ },
14
+ 'arithmetic': (lhs, rhs, node) => {
15
+ switch (node.operator) {
16
+ case '+':
17
+ return {
18
+ id: lhs.id,
19
+ domain: (0, domain_1.addDomains)(lhs.domain, rhs.domain),
20
+ astNode: node,
21
+ };
22
+ case '-':
23
+ return {
24
+ id: lhs.id,
25
+ domain: (0, domain_1.subtractDomains)(lhs.domain, rhs.domain),
26
+ astNode: node,
27
+ };
28
+ default:
29
+ (0, assert_1.guard)(false, `Unknown binary operator ${node.operator}`);
30
+ }
31
+ },
32
+ 'logical': () => {
33
+ (0, assert_1.guard)(false, 'Not implemented yet');
34
+ },
35
+ 'model formula': () => {
36
+ (0, assert_1.guard)(false, 'Not implemented yet');
37
+ },
38
+ 'comparison': () => {
39
+ (0, assert_1.guard)(false, 'Not implemented yet');
40
+ },
41
+ };
42
+ //# sourceMappingURL=operators.js.map
@@ -0,0 +1,6 @@
1
+ export interface Handler<ValueType> {
2
+ getName: () => string;
3
+ enter: () => void;
4
+ exit: () => ValueType;
5
+ next: (value: ValueType) => void;
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=handler.js.map
@@ -0,0 +1,10 @@
1
+ import type { DataflowInformation } from '../dataflow/internal/info';
2
+ import type { NodeId, NormalizedAst, ParentInformation, RNodeWithParent } from '../r-bridge';
3
+ import { Domain } from './domain';
4
+ export declare const aiLogger: import("tslog").Logger<import("tslog").ILogObj>;
5
+ export interface AINode {
6
+ readonly id: NodeId;
7
+ readonly domain: Domain;
8
+ readonly astNode: RNodeWithParent<ParentInformation>;
9
+ }
10
+ export declare function runAbstractInterpretation(ast: NormalizedAst, dfg: DataflowInformation): DataflowInformation;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runAbstractInterpretation = exports.aiLogger = void 0;
4
+ const cfg_1 = require("../util/cfg/cfg");
5
+ const visitor_1 = require("../util/cfg/visitor");
6
+ const assert_1 = require("../util/assert");
7
+ const dataflow_1 = require("../dataflow");
8
+ const binop_1 = require("./handler/binop/binop");
9
+ const domain_1 = require("./domain");
10
+ const log_1 = require("../util/log");
11
+ exports.aiLogger = log_1.log.getSubLogger({ name: 'abstract-interpretation' });
12
+ class Stack {
13
+ backingStore = [];
14
+ size() { return this.backingStore.length; }
15
+ peek() { return this.backingStore[this.size() - 1]; }
16
+ pop() { return this.backingStore.pop(); }
17
+ push(item) {
18
+ this.backingStore.push(item);
19
+ return item;
20
+ }
21
+ }
22
+ function getDomainOfDfgChild(node, dfg, nodeMap) {
23
+ const dfgNode = dfg.graph.get(node);
24
+ (0, assert_1.guard)(dfgNode !== undefined, `No DFG-Node found with ID ${node}`);
25
+ const [_, children] = dfgNode;
26
+ const ids = Array.from(children.entries())
27
+ .filter(([_, edge]) => edge.types.has(dataflow_1.EdgeType.Reads))
28
+ .map(([id, _]) => id);
29
+ const domains = [];
30
+ for (const id of ids) {
31
+ const domain = nodeMap.get(id)?.domain;
32
+ (0, assert_1.guard)(domain !== undefined, `No domain found for ID ${id}`);
33
+ domains.push(domain);
34
+ }
35
+ return (0, domain_1.unifyDomains)(domains);
36
+ }
37
+ function runAbstractInterpretation(ast, dfg) {
38
+ const cfg = (0, cfg_1.extractCFG)(ast);
39
+ const operationStack = new Stack();
40
+ const nodeMap = new Map();
41
+ (0, visitor_1.visitCfg)(cfg, (node, _) => {
42
+ const astNode = ast.idMap.get(node.id);
43
+ if (astNode?.type === "RBinaryOp" /* RType.BinaryOp */) {
44
+ operationStack.push(new binop_1.BinOp(astNode)).enter();
45
+ }
46
+ else if (astNode?.type === "RSymbol" /* RType.Symbol */) {
47
+ operationStack.peek()?.next({
48
+ id: astNode.info.id,
49
+ domain: getDomainOfDfgChild(node.id, dfg, nodeMap),
50
+ astNode: astNode,
51
+ });
52
+ }
53
+ else if (astNode?.type === "RNumber" /* RType.Number */) {
54
+ const num = astNode.content.num;
55
+ operationStack.peek()?.next({
56
+ id: astNode.info.id,
57
+ domain: domain_1.Domain.fromScalar(num),
58
+ astNode: astNode,
59
+ });
60
+ }
61
+ else if (node.type === "end-marker" /* CfgVertexType.EndMarker */) {
62
+ const operation = operationStack.pop();
63
+ if (operation === undefined) {
64
+ return;
65
+ }
66
+ const operationResult = operation.exit();
67
+ (0, assert_1.guard)(!nodeMap.has(operationResult.id), `Domain for ID ${operationResult.id} already exists`);
68
+ nodeMap.set(operationResult.id, operationResult);
69
+ operationStack.peek()?.next(operationResult);
70
+ }
71
+ else {
72
+ exports.aiLogger.warn(`Unknown node type ${node.type}`);
73
+ }
74
+ });
75
+ return dfg;
76
+ }
77
+ exports.runAbstractInterpretation = runAbstractInterpretation;
78
+ //# sourceMappingURL=processor.js.map
@@ -2,11 +2,11 @@
2
2
  * Provides a top-level slicer that can be used to slice code *and* retrieve stats.
3
3
  * @module
4
4
  */
5
- import { NormalizedAst, RParseRequestFromFile, RParseRequestFromText } from '../r-bridge';
6
- import { DataflowInformation } from '../dataflow/internal/info';
7
- import { SlicingCriteria, SlicingCriteriaFilter, SliceResult, ReconstructionResult } from '../slicing';
8
- import { PerSliceStats, SlicerStats } from './stats';
9
- import { MergeableRecord } from '../util/objects';
5
+ import type { NormalizedAst, RParseRequestFromFile, RParseRequestFromText } from '../r-bridge';
6
+ import type { DataflowInformation } from '../dataflow/internal/info';
7
+ import type { SlicingCriteria, SlicingCriteriaFilter, SliceResult, ReconstructionResult } from '../slicing';
8
+ import type { PerSliceStats, SlicerStats } from './stats';
9
+ import type { MergeableRecord } from '../util/objects';
10
10
  export declare const benchmarkLogger: import("tslog").Logger<import("tslog").ILogObj>;
11
11
  /**
12
12
  * Returns the stats but also the result of all setup steps (parsing, normalization, and the dataflow analysis) during the slicing.
@@ -54,6 +54,7 @@ export declare class BenchmarkSlicer {
54
54
  private loadedXml;
55
55
  private tokenMap;
56
56
  private dataflow;
57
+ private ai;
57
58
  private normalizedAst;
58
59
  private totalStopwatch;
59
60
  private finished;
@@ -35,6 +35,7 @@ class BenchmarkSlicer {
35
35
  loadedXml;
36
36
  tokenMap;
37
37
  dataflow;
38
+ ai;
38
39
  normalizedAst;
39
40
  totalStopwatch;
40
41
  finished = false;
@@ -68,6 +69,7 @@ class BenchmarkSlicer {
68
69
  this.loadedXml = await this.measureCommonStep('parse', 'retrieve AST from R code');
69
70
  this.normalizedAst = await this.measureCommonStep('normalize', 'normalize R AST');
70
71
  this.dataflow = await this.measureCommonStep('dataflow', 'produce dataflow information');
72
+ this.ai = await this.measureCommonStep('ai', 'run abstract interpretation');
71
73
  this.stepper.switchToSliceStage();
72
74
  await this.calculateStatsAfterInit(request);
73
75
  }
@@ -1,4 +1,4 @@
1
- import { SummarizedSlicerStats, UltimateSlicerStats } from '../../util/summarizer/benchmark/data';
1
+ import type { SummarizedSlicerStats, UltimateSlicerStats } from '../../util/summarizer/benchmark/data';
2
2
  /**
3
3
  * Converts the given stats to a human-readable string.
4
4
  * You may have to {@link summarizeSlicerStats | summarize} the stats first.
@@ -1,7 +1,7 @@
1
- import { SingleSlicingCriterion, SlicingCriteria } from '../../slicing';
2
- import { NodeId, RParseRequestFromFile, RParseRequestFromText } from '../../r-bridge';
3
- import { ReconstructionResult } from '../../slicing';
4
- export declare const CommonSlicerMeasurements: readonly ["initialize R session", "inject home path", "ensure installation of xmlparsedata", "retrieve token map", "retrieve AST from R code", "normalize R AST", "produce dataflow information", "close R session", "total"];
1
+ import type { SingleSlicingCriterion, SlicingCriteria } from '../../slicing';
2
+ import type { NodeId, RParseRequestFromFile, RParseRequestFromText } from '../../r-bridge';
3
+ import type { ReconstructionResult } from '../../slicing';
4
+ export declare const CommonSlicerMeasurements: readonly ["initialize R session", "inject home path", "ensure installation of xmlparsedata", "retrieve token map", "retrieve AST from R code", "normalize R AST", "produce dataflow information", "run abstract interpretation", "close R session", "total"];
5
5
  export type CommonSlicerMeasurements = typeof CommonSlicerMeasurements[number];
6
6
  export declare const PerSliceMeasurements: readonly ["static slicing", "reconstruct code", "total"];
7
7
  export type PerSliceMeasurements = typeof PerSliceMeasurements[number];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PerSliceMeasurements = exports.CommonSlicerMeasurements = void 0;
4
- exports.CommonSlicerMeasurements = ['initialize R session', 'inject home path', 'ensure installation of xmlparsedata', 'retrieve token map', 'retrieve AST from R code', 'normalize R AST', 'produce dataflow information', 'close R session', 'total'];
4
+ exports.CommonSlicerMeasurements = ['initialize R session', 'inject home path', 'ensure installation of xmlparsedata', 'retrieve token map', 'retrieve AST from R code', 'normalize R AST', 'produce dataflow information', 'run abstract interpretation', 'close R session', 'total'];
5
5
  exports.PerSliceMeasurements = ['static slicing', 'reconstruct code', 'total'];
6
6
  //# sourceMappingURL=stats.js.map
@@ -1,3 +1,3 @@
1
- import { FeatureKey } from '../../statistics';
1
+ import type { FeatureKey } from '../../statistics';
2
2
  export declare function validateFeatures(features: (string[] | ['all'] | FeatureKey[])): Set<FeatureKey>;
3
3
  export declare function retrieveArchiveName(p: string): string;
@@ -1,4 +1,4 @@
1
- import { OptionDefinition } from 'command-line-usage';
1
+ import type { OptionDefinition } from 'command-line-usage';
2
2
  /**
3
3
  * This interface describes options, that every script *must* provide.
4
4
  */
@@ -4,7 +4,7 @@
4
4
  * @module
5
5
  */
6
6
  import { scripts } from './scripts-info';
7
- import { CommonOptions } from './options';
7
+ import type { CommonOptions } from './options';
8
8
  /**
9
9
  * Just a helping data structure to allow the user to provide example usages of the respective script.
10
10
  * The subtitle will be displayed next to the title.
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { MergeableRecord } from '../../util/objects';
7
- import { OptionDefinition } from 'command-line-usage';
6
+ import type { MergeableRecord } from '../../util/objects';
7
+ import type { OptionDefinition } from 'command-line-usage';
8
8
  interface BaseScriptInformation extends MergeableRecord {
9
9
  toolName: string;
10
10
  target: string;
@@ -1,3 +1,3 @@
1
- import { ReplCommand } from './main';
1
+ import type { ReplCommand } from './main';
2
2
  export declare const controlflowCommand: ReplCommand;
3
3
  export declare const controlflowStarCommand: ReplCommand;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.controlflowStarCommand = exports.controlflowCommand = void 0;
4
4
  const core_1 = require("../../../core");
5
5
  const r_bridge_1 = require("../../../r-bridge");
6
- const cfg_1 = require("../../../util/cfg");
6
+ const cfg_1 = require("../../../util/cfg/cfg");
7
7
  const mermaid_1 = require("../../../util/mermaid");
8
8
  async function controlflow(shell, remainingLine) {
9
9
  return await new core_1.SteppingSlicer({
@@ -1,4 +1,4 @@
1
- import { ReplCommand } from './main';
1
+ import type { ReplCommand } from './main';
2
2
  export declare const helpCommand: ReplCommand;
3
3
  /**
4
4
  * The names of all commands including their aliases (but without the leading `:`)
@@ -1,3 +1,3 @@
1
- import { ReplCommand } from './main';
1
+ import type { ReplCommand } from './main';
2
2
  export declare const dataflowCommand: ReplCommand;
3
3
  export declare const dataflowStarCommand: ReplCommand;
@@ -1,4 +1,4 @@
1
- import { RShell } from '../../../r-bridge';
2
- import { ReplCommand, ReplOutput } from './main';
1
+ import type { RShell } from '../../../r-bridge';
2
+ import type { ReplCommand, ReplOutput } from './main';
3
3
  export declare function executeRShellCommand(output: ReplOutput, shell: RShell, statement: string): Promise<void>;
4
4
  export declare const executeCommand: ReplCommand;
@@ -1,5 +1,5 @@
1
- import { RShell } from '../../../r-bridge';
2
- import { OutputFormatter } from '../../../statistics';
1
+ import type { RShell } from '../../../r-bridge';
2
+ import type { OutputFormatter } from '../../../statistics';
3
3
  /**
4
4
  * Defines the main interface for output of the repl.
5
5
  * This allows us to redirect it (e.g., in the case of a server connection or tests).
@@ -1,3 +1,3 @@
1
- import { ReplCommand } from './main';
1
+ import type { ReplCommand } from './main';
2
2
  export declare const normalizeCommand: ReplCommand;
3
3
  export declare const normalizeStarCommand: ReplCommand;
@@ -1,2 +1,2 @@
1
- import { ReplCommand } from './main';
1
+ import type { ReplCommand } from './main';
2
2
  export declare const parseCommand: ReplCommand;
@@ -1,2 +1,2 @@
1
- import { ReplCommand } from './main';
1
+ import type { ReplCommand } from './main';
2
2
  export declare const quitCommand: ReplCommand;
@@ -1,4 +1,4 @@
1
- import { ReplCommand, ReplOutput } from './main';
1
+ import type { ReplCommand, ReplOutput } from './main';
2
2
  import { RShell } from '../../../r-bridge';
3
3
  type Version = `${number}.${number}.${number}`;
4
4
  /**
@@ -1,19 +1,17 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  /**
4
3
  * Basically a helper file to allow the main 'flowr' script (located in the source root) to provide its repl
5
4
  *
6
5
  * @module
7
6
  */
8
7
  import { RShell } from '../../r-bridge';
9
- import readline from 'readline/promises';
10
- import { ReplOutput } from './commands';
11
- import { ReadLineOptions } from 'node:readline';
8
+ import type { ReplOutput } from './commands';
9
+ import * as readline from 'node:readline';
12
10
  /**
13
11
  * Used by the repl to provide automatic completions for a given (partial) input line
14
12
  */
15
13
  export declare function replCompleter(line: string): [string[], string];
16
- export declare const DEFAULT_REPL_READLINE_CONFIGURATION: ReadLineOptions;
14
+ export declare const DEFAULT_REPL_READLINE_CONFIGURATION: readline.ReadLineOptions;
17
15
  /**
18
16
  * This function interprets the given `expr` as a REPL command (see {@link repl} for more on the semantics).
19
17
  *
package/cli/repl/core.js CHANGED
@@ -1,6 +1,26 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
4
24
  };
5
25
  Object.defineProperty(exports, "__esModule", { value: true });
6
26
  exports.repl = exports.replProcessAnswer = exports.DEFAULT_REPL_READLINE_CONFIGURATION = exports.replCompleter = void 0;
@@ -10,10 +30,10 @@ exports.repl = exports.replProcessAnswer = exports.DEFAULT_REPL_READLINE_CONFIGU
10
30
  * @module
11
31
  */
12
32
  const r_bridge_1 = require("../../r-bridge");
13
- const promises_1 = __importDefault(require("readline/promises"));
14
33
  const statistics_1 = require("../../statistics");
15
34
  const prompt_1 = require("./prompt");
16
35
  const commands_1 = require("./commands");
36
+ const readline = __importStar(require("node:readline"));
17
37
  const args_1 = require("../../util/args");
18
38
  const execute_1 = require("./commands/execute");
19
39
  const replCompleterKeywords = Array.from(commands_1.commandNames, s => `:${s}`);
@@ -77,12 +97,19 @@ exports.replProcessAnswer = replProcessAnswer;
77
97
  * For the execution, this function makes use of {@link replProcessAnswer}
78
98
  *
79
99
  */
80
- async function repl(shell = new r_bridge_1.RShell({ revive: 'always' }), rl = promises_1.default.createInterface(exports.DEFAULT_REPL_READLINE_CONFIGURATION), output = commands_1.standardReplOutput) {
100
+ async function repl(shell = new r_bridge_1.RShell({ revive: 'always' }), rl = readline.createInterface(exports.DEFAULT_REPL_READLINE_CONFIGURATION), output = commands_1.standardReplOutput) {
81
101
  // the incredible repl :D, we kill it with ':quit'
82
102
  // eslint-disable-next-line no-constant-condition,@typescript-eslint/no-unnecessary-condition
83
103
  while (true) {
84
- const answer = await rl.question((0, prompt_1.prompt)());
85
- await replProcessAnswer(output, answer, shell);
104
+ await new Promise((resolve, reject) => {
105
+ rl.question((0, prompt_1.prompt)(), answer => {
106
+ rl.pause();
107
+ replProcessAnswer(output, answer, shell).then(() => {
108
+ rl.resume();
109
+ resolve();
110
+ }).catch(reject);
111
+ });
112
+ });
86
113
  }
87
114
  }
88
115
  exports.repl = repl;