@eagleoutice/flowr 1.4.1 → 1.5.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 (300) hide show
  1. package/README.md +3 -3
  2. package/abstract-interpretation/processor.js +9 -3
  3. package/config.d.ts +16 -0
  4. package/config.js +75 -0
  5. package/core/input.d.ts +1 -1
  6. package/core/output.d.ts +1 -2
  7. package/core/print/parse-printer.d.ts +1 -2
  8. package/core/print/parse-printer.js +6 -4
  9. package/core/print/slice-diff-ansi.js +7 -7
  10. package/core/slicer.js +4 -8
  11. package/core/steps.d.ts +355 -31
  12. package/core/steps.js +7 -14
  13. package/dataflow/environments/environment.js +8 -0
  14. package/dataflow/environments/register.js +1 -0
  15. package/dataflow/extractor.d.ts +2 -2
  16. package/dataflow/extractor.js +10 -2
  17. package/dataflow/internal/process/functions/function-call.js +7 -1
  18. package/dataflow/internal/process/functions/source.d.ts +8 -0
  19. package/dataflow/internal/process/functions/source.js +81 -0
  20. package/dataflow/processor.d.ts +10 -1
  21. package/index.d.ts +0 -2
  22. package/index.js +0 -2
  23. package/package.json +75 -202
  24. package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
  25. package/r-bridge/lang-4.x/ast/index.js +3 -0
  26. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -0
  27. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
  28. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
  29. package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
  30. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
  31. package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
  32. package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +0 -3
  33. package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
  34. package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
  35. package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +5 -1
  36. package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
  37. package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
  38. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
  39. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
  40. package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
  41. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
  42. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
  43. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
  44. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
  45. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
  46. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
  47. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
  48. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
  49. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
  50. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
  51. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
  52. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +6 -11
  53. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
  54. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
  55. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
  56. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
  57. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
  58. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
  59. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
  60. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
  61. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
  62. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
  63. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
  64. package/r-bridge/lang-4.x/values.d.ts +0 -1
  65. package/r-bridge/lang-4.x/values.js +14 -6
  66. package/r-bridge/retriever.d.ts +25 -21
  67. package/r-bridge/retriever.js +73 -23
  68. package/r-bridge/shell-executor.d.ts +3 -17
  69. package/r-bridge/shell-executor.js +9 -78
  70. package/r-bridge/shell.d.ts +5 -27
  71. package/r-bridge/shell.js +31 -92
  72. package/{statistics/output → util}/ansi.js +1 -1
  73. package/util/args.d.ts +8 -4
  74. package/util/args.js +11 -4
  75. package/util/cfg/visitor.js +1 -1
  76. package/util/files.d.ts +6 -0
  77. package/util/files.js +11 -1
  78. package/util/log.js +3 -0
  79. package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
  80. package/util/summarizer.js +37 -0
  81. package/util/version.d.ts +2 -0
  82. package/util/version.js +10 -0
  83. package/benchmark/index.d.ts +0 -3
  84. package/benchmark/index.js +0 -20
  85. package/benchmark/slicer.d.ts +0 -101
  86. package/benchmark/slicer.js +0 -225
  87. package/benchmark/stats/index.d.ts +0 -10
  88. package/benchmark/stats/index.js +0 -27
  89. package/benchmark/stats/print.d.ts +0 -7
  90. package/benchmark/stats/print.js +0 -157
  91. package/benchmark/stats/stats.d.ts +0 -41
  92. package/benchmark/stats/stats.js +0 -6
  93. package/benchmark/stopwatch.d.ts +0 -35
  94. package/benchmark/stopwatch.js +0 -79
  95. package/cli/benchmark-app.d.ts +0 -9
  96. package/cli/benchmark-app.js +0 -52
  97. package/cli/benchmark-helper-app.d.ts +0 -7
  98. package/cli/benchmark-helper-app.js +0 -60
  99. package/cli/common/features.d.ts +0 -3
  100. package/cli/common/features.js +0 -30
  101. package/cli/common/index.d.ts +0 -2
  102. package/cli/common/index.js +0 -19
  103. package/cli/common/options.d.ts +0 -20
  104. package/cli/common/options.js +0 -82
  105. package/cli/common/script.d.ts +0 -21
  106. package/cli/common/script.js +0 -61
  107. package/cli/common/scripts-info.d.ts +0 -24
  108. package/cli/common/scripts-info.js +0 -69
  109. package/cli/export-quads-app.d.ts +0 -7
  110. package/cli/export-quads-app.js +0 -46
  111. package/cli/repl/commands/cfg.d.ts +0 -3
  112. package/cli/repl/commands/cfg.js +0 -37
  113. package/cli/repl/commands/commands.d.ts +0 -11
  114. package/cli/repl/commands/commands.js +0 -103
  115. package/cli/repl/commands/dataflow.d.ts +0 -3
  116. package/cli/repl/commands/dataflow.js +0 -34
  117. package/cli/repl/commands/execute.d.ts +0 -4
  118. package/cli/repl/commands/execute.js +0 -27
  119. package/cli/repl/commands/index.d.ts +0 -2
  120. package/cli/repl/commands/index.js +0 -19
  121. package/cli/repl/commands/main.d.ts +0 -39
  122. package/cli/repl/commands/main.js +0 -14
  123. package/cli/repl/commands/normalize.d.ts +0 -3
  124. package/cli/repl/commands/normalize.js +0 -34
  125. package/cli/repl/commands/parse.d.ts +0 -2
  126. package/cli/repl/commands/parse.js +0 -109
  127. package/cli/repl/commands/quit.d.ts +0 -2
  128. package/cli/repl/commands/quit.js +0 -12
  129. package/cli/repl/commands/version.d.ts +0 -16
  130. package/cli/repl/commands/version.js +0 -33
  131. package/cli/repl/core.d.ts +0 -39
  132. package/cli/repl/core.js +0 -116
  133. package/cli/repl/execute.d.ts +0 -28
  134. package/cli/repl/execute.js +0 -79
  135. package/cli/repl/index.d.ts +0 -5
  136. package/cli/repl/index.js +0 -22
  137. package/cli/repl/prompt.d.ts +0 -2
  138. package/cli/repl/prompt.js +0 -9
  139. package/cli/repl/server/connection.d.ts +0 -21
  140. package/cli/repl/server/connection.js +0 -218
  141. package/cli/repl/server/messages/analysis.d.ts +0 -71
  142. package/cli/repl/server/messages/analysis.js +0 -21
  143. package/cli/repl/server/messages/error.d.ts +0 -11
  144. package/cli/repl/server/messages/error.js +0 -3
  145. package/cli/repl/server/messages/hello.d.ts +0 -20
  146. package/cli/repl/server/messages/hello.js +0 -3
  147. package/cli/repl/server/messages/index.d.ts +0 -1
  148. package/cli/repl/server/messages/index.js +0 -3
  149. package/cli/repl/server/messages/messages.d.ts +0 -35
  150. package/cli/repl/server/messages/messages.js +0 -40
  151. package/cli/repl/server/messages/repl.d.ts +0 -33
  152. package/cli/repl/server/messages/repl.js +0 -37
  153. package/cli/repl/server/messages/slice.d.ts +0 -25
  154. package/cli/repl/server/messages/slice.js +0 -37
  155. package/cli/repl/server/net.d.ts +0 -49
  156. package/cli/repl/server/net.js +0 -63
  157. package/cli/repl/server/send.d.ts +0 -4
  158. package/cli/repl/server/send.js +0 -18
  159. package/cli/repl/server/server.d.ts +0 -20
  160. package/cli/repl/server/server.js +0 -66
  161. package/cli/repl/server/validate.d.ts +0 -15
  162. package/cli/repl/server/validate.js +0 -34
  163. package/cli/slicer-app.d.ts +0 -11
  164. package/cli/slicer-app.js +0 -81
  165. package/cli/statistics-app.d.ts +0 -11
  166. package/cli/statistics-app.js +0 -98
  167. package/cli/statistics-helper-app.d.ts +0 -11
  168. package/cli/statistics-helper-app.js +0 -83
  169. package/cli/summarizer-app.d.ts +0 -18
  170. package/cli/summarizer-app.js +0 -67
  171. package/flowr.d.ts +0 -27
  172. package/flowr.js +0 -137
  173. package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
  174. package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
  175. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
  176. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
  177. package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
  178. package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
  179. package/statistics/features/common-syntax-probability.d.ts +0 -31
  180. package/statistics/features/common-syntax-probability.js +0 -156
  181. package/statistics/features/feature.d.ts +0 -175
  182. package/statistics/features/feature.js +0 -30
  183. package/statistics/features/index.d.ts +0 -1
  184. package/statistics/features/index.js +0 -18
  185. package/statistics/features/post-processing.d.ts +0 -12
  186. package/statistics/features/post-processing.js +0 -21
  187. package/statistics/features/supported/assignments/assignments.d.ts +0 -11
  188. package/statistics/features/supported/assignments/assignments.js +0 -53
  189. package/statistics/features/supported/assignments/index.d.ts +0 -1
  190. package/statistics/features/supported/assignments/index.js +0 -6
  191. package/statistics/features/supported/assignments/post-process.d.ts +0 -3
  192. package/statistics/features/supported/assignments/post-process.js +0 -125
  193. package/statistics/features/supported/comments/comments.d.ts +0 -18
  194. package/statistics/features/supported/comments/comments.js +0 -133
  195. package/statistics/features/supported/comments/index.d.ts +0 -1
  196. package/statistics/features/supported/comments/index.js +0 -6
  197. package/statistics/features/supported/comments/post-process.d.ts +0 -3
  198. package/statistics/features/supported/comments/post-process.js +0 -50
  199. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  200. package/statistics/features/supported/control-flow/control-flow.js +0 -67
  201. package/statistics/features/supported/control-flow/index.d.ts +0 -1
  202. package/statistics/features/supported/control-flow/index.js +0 -6
  203. package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
  204. package/statistics/features/supported/control-flow/post-process.js +0 -65
  205. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  206. package/statistics/features/supported/data-access/data-access.js +0 -118
  207. package/statistics/features/supported/data-access/index.d.ts +0 -1
  208. package/statistics/features/supported/data-access/index.js +0 -6
  209. package/statistics/features/supported/data-access/post-process.d.ts +0 -3
  210. package/statistics/features/supported/data-access/post-process.js +0 -107
  211. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
  212. package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
  213. package/statistics/features/supported/defined-functions/index.d.ts +0 -1
  214. package/statistics/features/supported/defined-functions/index.js +0 -6
  215. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  216. package/statistics/features/supported/defined-functions/post-process.js +0 -177
  217. package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
  218. package/statistics/features/supported/expression-list/expression-list.js +0 -36
  219. package/statistics/features/supported/expression-list/index.d.ts +0 -1
  220. package/statistics/features/supported/expression-list/index.js +0 -6
  221. package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
  222. package/statistics/features/supported/expression-list/post-process.js +0 -44
  223. package/statistics/features/supported/index.d.ts +0 -10
  224. package/statistics/features/supported/index.js +0 -27
  225. package/statistics/features/supported/loops/index.d.ts +0 -1
  226. package/statistics/features/supported/loops/index.js +0 -6
  227. package/statistics/features/supported/loops/loops.d.ts +0 -20
  228. package/statistics/features/supported/loops/loops.js +0 -79
  229. package/statistics/features/supported/loops/post-process.d.ts +0 -3
  230. package/statistics/features/supported/loops/post-process.js +0 -72
  231. package/statistics/features/supported/used-functions/index.d.ts +0 -1
  232. package/statistics/features/supported/used-functions/index.js +0 -6
  233. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  234. package/statistics/features/supported/used-functions/post-process.js +0 -179
  235. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  236. package/statistics/features/supported/used-functions/used-functions.js +0 -95
  237. package/statistics/features/supported/used-packages/index.d.ts +0 -1
  238. package/statistics/features/supported/used-packages/index.js +0 -6
  239. package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
  240. package/statistics/features/supported/used-packages/post-process.js +0 -121
  241. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  242. package/statistics/features/supported/used-packages/used-packages.js +0 -130
  243. package/statistics/features/supported/values/index.d.ts +0 -1
  244. package/statistics/features/supported/values/index.js +0 -6
  245. package/statistics/features/supported/values/post-process.d.ts +0 -3
  246. package/statistics/features/supported/values/post-process.js +0 -72
  247. package/statistics/features/supported/values/values.d.ts +0 -14
  248. package/statistics/features/supported/values/values.js +0 -101
  249. package/statistics/features/supported/variables/index.d.ts +0 -1
  250. package/statistics/features/supported/variables/index.js +0 -6
  251. package/statistics/features/supported/variables/post-process.d.ts +0 -9
  252. package/statistics/features/supported/variables/post-process.js +0 -122
  253. package/statistics/features/supported/variables/variables.d.ts +0 -15
  254. package/statistics/features/supported/variables/variables.js +0 -70
  255. package/statistics/index.d.ts +0 -6
  256. package/statistics/index.js +0 -24
  257. package/statistics/meta-statistics.d.ts +0 -33
  258. package/statistics/meta-statistics.js +0 -17
  259. package/statistics/output/file-provider.d.ts +0 -37
  260. package/statistics/output/file-provider.js +0 -97
  261. package/statistics/output/index.d.ts +0 -4
  262. package/statistics/output/index.js +0 -21
  263. package/statistics/output/print-stats.d.ts +0 -17
  264. package/statistics/output/print-stats.js +0 -69
  265. package/statistics/output/statistics-file.d.ts +0 -37
  266. package/statistics/output/statistics-file.js +0 -69
  267. package/statistics/statistics.d.ts +0 -24
  268. package/statistics/statistics.js +0 -109
  269. package/util/summarizer/auto-detect.d.ts +0 -2
  270. package/util/summarizer/auto-detect.js +0 -32
  271. package/util/summarizer/benchmark/data.d.ts +0 -66
  272. package/util/summarizer/benchmark/data.js +0 -13
  273. package/util/summarizer/benchmark/first-phase/input.d.ts +0 -2
  274. package/util/summarizer/benchmark/first-phase/input.js +0 -59
  275. package/util/summarizer/benchmark/first-phase/process.d.ts +0 -10
  276. package/util/summarizer/benchmark/first-phase/process.js +0 -208
  277. package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
  278. package/util/summarizer/benchmark/second-phase/graph.js +0 -54
  279. package/util/summarizer/benchmark/second-phase/process.d.ts +0 -4
  280. package/util/summarizer/benchmark/second-phase/process.js +0 -89
  281. package/util/summarizer/benchmark/summarizer.d.ts +0 -35
  282. package/util/summarizer/benchmark/summarizer.js +0 -49
  283. package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
  284. package/util/summarizer/statistics/first-phase/process.js +0 -81
  285. package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
  286. package/util/summarizer/statistics/post-process/clusterer.js +0 -43
  287. package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
  288. package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
  289. package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
  290. package/util/summarizer/statistics/post-process/histogram.js +0 -128
  291. package/util/summarizer/statistics/post-process/index.d.ts +0 -4
  292. package/util/summarizer/statistics/post-process/index.js +0 -21
  293. package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
  294. package/util/summarizer/statistics/post-process/post-process-output.js +0 -104
  295. package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
  296. package/util/summarizer/statistics/second-phase/process.js +0 -117
  297. package/util/summarizer/statistics/summarizer.d.ts +0 -35
  298. package/util/summarizer/statistics/summarizer.js +0 -135
  299. package/util/summarizer/summarizer.js +0 -13
  300. /package/{statistics/output → util}/ansi.d.ts +0 -0
@@ -1,37 +0,0 @@
1
- export type AppendFnType = string | number | symbol;
2
- export interface StatisticAppendProvider {
3
- append(name: string, fn: AppendFnType, content: string): void;
4
- }
5
- export type DummyAppendMemoryMap = Map<string, Map<AppendFnType, string[]>>;
6
- export declare class DummyAppendProvider implements StatisticAppendProvider {
7
- private readonly map;
8
- /**
9
- * If you pass a map the dummy will log all append calls to the map, using the feature name and the appendage type as keys
10
- *
11
- * @param map - The map to log to
12
- */
13
- constructor(map?: DummyAppendMemoryMap | undefined);
14
- append(name: string, fn: AppendFnType, content: string): void;
15
- }
16
- export declare const defaultStatisticsFileSuffix = ".txt";
17
- /**
18
- * Provides cached open connections for all files to connect.
19
- * allowing to append to the same file often.
20
- * <p>
21
- * While we could simply reopen these files, it is safer/more performant to keep the connection open.
22
- */
23
- export declare class StatisticFileProvider implements StatisticAppendProvider {
24
- readonly statisticsDirectory: string;
25
- private readonly connections;
26
- constructor(statisticsDirectory: string | undefined);
27
- /**
28
- * @param name - the name of the feature {@link Feature#name}
29
- * @param fn - the name of the feature-aspect to record
30
- */
31
- private statisticsFile;
32
- /**
33
- * Append the given content to the information for a feature of the given name and function.
34
- */
35
- append(name: string, fn: AppendFnType, content: string): void;
36
- private getHandle;
37
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.StatisticFileProvider = exports.defaultStatisticsFileSuffix = exports.DummyAppendProvider = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const assert_1 = require("../../util/assert");
10
- const log_1 = require("../../util/log");
11
- class DummyAppendProvider {
12
- map;
13
- /**
14
- * If you pass a map the dummy will log all append calls to the map, using the feature name and the appendage type as keys
15
- *
16
- * @param map - The map to log to
17
- */
18
- constructor(map = undefined) {
19
- this.map = map;
20
- }
21
- append(name, fn, content) {
22
- if (log_1.log.settings.minLevel >= 1 /* LogLevel.Trace */) {
23
- log_1.log.trace(`DummyAppendProvider: ${name} ${String(fn)} ${content}`);
24
- }
25
- if (this.map) {
26
- const fnMap = this.map.get(name);
27
- const contentArr = content.split('\n');
28
- if (fnMap) {
29
- const contentList = fnMap.get(fn);
30
- if (contentList) {
31
- contentList.push(...contentArr);
32
- }
33
- else {
34
- // just in case the map already had some entries
35
- fnMap.set(fn, contentArr);
36
- }
37
- }
38
- else {
39
- this.map.set(name, new Map([[fn, contentArr]]));
40
- }
41
- }
42
- }
43
- }
44
- exports.DummyAppendProvider = DummyAppendProvider;
45
- exports.defaultStatisticsFileSuffix = '.txt';
46
- /**
47
- * Provides cached open connections for all files to connect.
48
- * allowing to append to the same file often.
49
- * <p>
50
- * While we could simply reopen these files, it is safer/more performant to keep the connection open.
51
- */
52
- class StatisticFileProvider {
53
- statisticsDirectory;
54
- connections = new Map();
55
- constructor(statisticsDirectory) {
56
- (0, assert_1.guard)(statisticsDirectory !== undefined, 'Please supply an output directory!');
57
- this.statisticsDirectory = statisticsDirectory;
58
- // just to make sure, that they are closed
59
- process.on('beforeExit', () => {
60
- this.connections.forEach(fd => {
61
- fs_1.default.closeSync(fd);
62
- });
63
- });
64
- }
65
- /**
66
- * @param name - the name of the feature {@link Feature#name}
67
- * @param fn - the name of the feature-aspect to record
68
- */
69
- statisticsFile(name, fn) {
70
- return path_1.default.join(this.statisticsDirectory, name, `${fn}${exports.defaultStatisticsFileSuffix}`);
71
- }
72
- /**
73
- * Append the given content to the information for a feature of the given name and function.
74
- */
75
- append(name, fn, content) {
76
- const descriptor = this.getHandle(name, String(fn));
77
- fs_1.default.appendFileSync(descriptor, content + '\n', 'utf8');
78
- }
79
- getHandle(name, fn) {
80
- const key = `${name}-${fn}`;
81
- const fileHandle = this.connections.get(key);
82
- if (fileHandle) {
83
- return fileHandle;
84
- }
85
- // open the connection and ensure the location
86
- const filepath = this.statisticsFile(name, String(fn));
87
- const dirpath = path_1.default.dirname(filepath);
88
- if (!fs_1.default.existsSync(dirpath)) {
89
- fs_1.default.mkdirSync(dirpath, { recursive: true });
90
- }
91
- const fileDescriptor = fs_1.default.openSync(filepath, 'a');
92
- this.connections.set(key, fileDescriptor);
93
- return fileDescriptor;
94
- }
95
- }
96
- exports.StatisticFileProvider = StatisticFileProvider;
97
- //# sourceMappingURL=file-provider.js.map
@@ -1,4 +0,0 @@
1
- export * from './print-stats';
2
- export * from './file-provider';
3
- export * from './statistics-file';
4
- export * from './ansi';
@@ -1,21 +0,0 @@
1
- "use strict";
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./print-stats"), exports);
18
- __exportStar(require("./file-provider"), exports);
19
- __exportStar(require("./statistics-file"), exports);
20
- __exportStar(require("./ansi"), exports);
21
- //# sourceMappingURL=index.js.map
@@ -1,17 +0,0 @@
1
- import type { FeatureKey, FeatureStatistics } from '../features';
2
- import type { MetaStatistics } from '../meta-statistics';
3
- interface MinMaxAvgMedian {
4
- sum: number;
5
- min: number;
6
- max: number;
7
- avg: number;
8
- median: number;
9
- }
10
- export declare function minMaxAvgAndMedian(data: number[]): MinMaxAvgMedian;
11
- export declare function statsString(data: MinMaxAvgMedian, suffix?: string): string;
12
- export declare function printFeatureStatistics(statistics: {
13
- features: FeatureStatistics;
14
- meta: MetaStatistics;
15
- }, features?: 'all' | Set<FeatureKey>): void;
16
- export declare function printFeatureStatisticsEntry(info: Record<string, unknown>): void;
17
- export {};
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printFeatureStatisticsEntry = exports.printFeatureStatistics = exports.statsString = exports.minMaxAvgAndMedian = void 0;
4
- const features_1 = require("../features");
5
- const ansi_1 = require("./ansi");
6
- const json_1 = require("../../util/json");
7
- function minMaxAvgAndMedian(data) {
8
- data = data.sort((a, b) => a - b);
9
- const sum = data.reduce((a, b) => a + b, 0);
10
- return {
11
- sum,
12
- min: data[0],
13
- max: data[data.length - 1],
14
- avg: sum / data.length,
15
- median: data[Math.floor(data.length / 2)]
16
- };
17
- }
18
- exports.minMaxAvgAndMedian = minMaxAvgAndMedian;
19
- function formatStatNumber(num) {
20
- return num === undefined ? '<?>' : Number(num.toFixed(3)).toLocaleString();
21
- }
22
- function statsString(data, suffix = '') {
23
- return `[${formatStatNumber(data.min)}${suffix} .. ${formatStatNumber(data.max)}${suffix}] (avg: ${formatStatNumber(data.avg)}${suffix}, median: ${formatStatNumber(data.median)}${suffix})`;
24
- }
25
- exports.statsString = statsString;
26
- function printFeatureStatistics(statistics, features = 'all') {
27
- for (const feature of Object.keys(statistics.features)) {
28
- if (features !== 'all' && !features.has(feature)) {
29
- continue;
30
- }
31
- const meta = features_1.ALL_FEATURES[feature];
32
- console.log(`\n\n-----${meta.name}-------------`);
33
- console.log(ansi_1.formatter.format(meta.description, { color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground }));
34
- printFeatureStatisticsEntry(statistics.features[feature]);
35
- console.log('\n\n');
36
- }
37
- const linesPerFile = minMaxAvgAndMedian(statistics.meta.lines.map(l => l.length));
38
- const lineLengths = minMaxAvgAndMedian(statistics.meta.lines.flat());
39
- const processingTimesPerFile = minMaxAvgAndMedian(statistics.meta.processingTimeMs);
40
- console.log(`processed ${statistics.meta.successfulParsed} files (skipped ${statistics.meta.failedRequests.length} due to errors):
41
- \ttotal processing time: ${processingTimesPerFile.sum} ms
42
- \t\tprocessing time range: ${statsString(processingTimesPerFile, ' ms')}
43
- \ttotal number of lines: ${lineLengths.sum}
44
- \t\tline range: ${statsString(linesPerFile)}
45
- \t\tline length range: ${statsString(lineLengths, ' chars')}
46
- `);
47
- }
48
- exports.printFeatureStatistics = printFeatureStatistics;
49
- const pad = 3;
50
- function printFeatureStatisticsEntry(info) {
51
- let longestKey = 0;
52
- let longestValue = 0;
53
- const out = new Map();
54
- for (const [key, value] of Object.entries(info)) {
55
- if (key.length > longestKey) {
56
- longestKey = key.length;
57
- }
58
- const valueString = JSON.stringify(value, json_1.jsonReplacer);
59
- out.set(key, valueString);
60
- if (valueString.length > longestValue) {
61
- longestValue = valueString.length;
62
- }
63
- }
64
- for (const [key, value] of out.entries()) {
65
- console.log(`${key.padEnd(longestKey + pad)} ${value.padStart(longestValue)}`);
66
- }
67
- }
68
- exports.printFeatureStatisticsEntry = printFeatureStatisticsEntry;
69
- //# sourceMappingURL=print-stats.js.map
@@ -1,37 +0,0 @@
1
- import type { DummyAppendMemoryMap, StatisticAppendProvider } from './file-provider';
2
- /**
3
- * Requires source information to be attached on parsing!
4
- * <p>
5
- * Returns the content of the node (i.e., the text content excluding the children)
6
- */
7
- export declare function extractNodeContent(node: Node): string;
8
- /** by default, we do not write to anything */
9
- export declare let statisticsFileProvider: StatisticAppendProvider;
10
- /**
11
- * Make the statistics write to a given output directory.
12
- */
13
- export declare function initFileProvider(outputDirectory: string): void;
14
- /**
15
- * Either ignore the statistics or write them to a given map (e.g., for testing).
16
- *
17
- * @param map - The map to write to, will not persist calls if no map is given
18
- */
19
- export declare function initDummyFileProvider(map?: DummyAppendMemoryMap): void;
20
- /**
21
- * Format used to dump each entry of a feature during collection.
22
- */
23
- export type StatisticsOutputFormat<T = string> = [
24
- /** the collected value (like the assignment operator lexeme, ...) */
25
- value: T,
26
- /** the context of the information retrieval (e.g. the name of the file that contained the R source code) */
27
- context: string | undefined
28
- ];
29
- /**
30
- * Append the content of all nodes to the storage file for the given feature
31
- * @param name - The name of the feature {@link Feature#name}
32
- * @param fn - The name of the feature-aspect to record
33
- * @param nodes - The nodes to append, you may pass already transformed string contents
34
- * @param context - The context of the information retrieval (e.g. the name of the file that contained the R source code)
35
- * @param unique - Should duplicate entries be removed on addition
36
- */
37
- export declare function appendStatisticsFile<T>(name: string, fn: keyof T, nodes: string[] | Node[] | object[], context: string | undefined, unique?: boolean): void;
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appendStatisticsFile = exports.initDummyFileProvider = exports.initFileProvider = exports.statisticsFileProvider = exports.extractNodeContent = void 0;
4
- const file_provider_1 = require("./file-provider");
5
- const log_1 = require("../../util/log");
6
- /**
7
- * Requires source information to be attached on parsing!
8
- * <p>
9
- * Returns the content of the node (i.e., the text content excluding the children)
10
- */
11
- function extractNodeContent(node) {
12
- let result = node.textContent;
13
- if (node.hasChildNodes()) {
14
- const firstChild = node.childNodes.item(0);
15
- if (firstChild.nodeType === 3 /* text node */) {
16
- result = firstChild.textContent;
17
- }
18
- }
19
- return result?.trim()?.replaceAll('\n', '\\n') ?? '<unknown>';
20
- }
21
- exports.extractNodeContent = extractNodeContent;
22
- initDummyFileProvider();
23
- /**
24
- * Make the statistics write to a given output directory.
25
- */
26
- function initFileProvider(outputDirectory) {
27
- log_1.log.debug(`Initializing file provider for output directory ${outputDirectory}`);
28
- exports.statisticsFileProvider = new file_provider_1.StatisticFileProvider(outputDirectory);
29
- }
30
- exports.initFileProvider = initFileProvider;
31
- /**
32
- * Either ignore the statistics or write them to a given map (e.g., for testing).
33
- *
34
- * @param map - The map to write to, will not persist calls if no map is given
35
- */
36
- function initDummyFileProvider(map) {
37
- exports.statisticsFileProvider = new file_provider_1.DummyAppendProvider(map);
38
- }
39
- exports.initDummyFileProvider = initDummyFileProvider;
40
- /**
41
- * Append the content of all nodes to the storage file for the given feature
42
- * @param name - The name of the feature {@link Feature#name}
43
- * @param fn - The name of the feature-aspect to record
44
- * @param nodes - The nodes to append, you may pass already transformed string contents
45
- * @param context - The context of the information retrieval (e.g. the name of the file that contained the R source code)
46
- * @param unique - Should duplicate entries be removed on addition
47
- */
48
- function appendStatisticsFile(name, fn, nodes, context, unique = false) {
49
- if (nodes.length === 0) {
50
- return;
51
- }
52
- let values;
53
- if (typeof nodes[0] === 'string') {
54
- values = nodes;
55
- }
56
- else if ('nodeType' in nodes[0]) {
57
- values = nodes.map(extractNodeContent);
58
- }
59
- else {
60
- values = nodes;
61
- }
62
- if (unique) {
63
- values = [...new Set(values)];
64
- }
65
- values = values.map(value => JSON.stringify(context === undefined ? [value] : [value, context]));
66
- exports.statisticsFileProvider.append(name, fn, values.join('\n'));
67
- }
68
- exports.appendStatisticsFile = appendStatisticsFile;
69
- //# sourceMappingURL=statistics-file.js.map
@@ -1,24 +0,0 @@
1
- import type { RParseRequestFromFile, RParseRequestFromText, RShell } from '../r-bridge';
2
- import type { FeatureSelection, FeatureStatistics } from './features';
3
- import type { MetaStatistics } from './meta-statistics';
4
- import type { StepResults } from '../core';
5
- /**
6
- * By default, {@link extractUsageStatistics} requires a generator, but sometimes you already know all the files
7
- * that you want to process. This function simply reps your requests as a generator.
8
- */
9
- export declare function staticRequests(...requests: (RParseRequestFromText | RParseRequestFromFile)[]): AsyncGenerator<RParseRequestFromText | RParseRequestFromFile>;
10
- /**
11
- * Extract all wanted statistic information from a set of requests using the presented R session.
12
- *
13
- * @param shell - The R session to use
14
- * @param onRequest - A callback that is called at the beginning of each request, this may be used to debug the requests.
15
- * @param features - The features to extract (see {@link allFeatureNames}).
16
- * @param requests - The requests to extract the features from. May generate them on demand (e.g., by traversing a folder).
17
- * If your request is statically known, you can use {@link staticRequests} to create this generator.
18
- * @param rootPath - The root path to the project, this is used to relativize the file paths in the statistics.
19
- */
20
- export declare function extractUsageStatistics<T extends RParseRequestFromText | RParseRequestFromFile>(shell: RShell, onRequest: (request: T) => void, features: FeatureSelection, requests: AsyncGenerator<T>, rootPath?: string): Promise<{
21
- features: FeatureStatistics;
22
- meta: MetaStatistics;
23
- outputs: Map<T, StepResults<'dataflow'>>;
24
- }>;
@@ -1,109 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.extractUsageStatistics = exports.staticRequests = void 0;
7
- const features_1 = require("./features");
8
- const xmldom_1 = require("@xmldom/xmldom");
9
- const fs_1 = __importDefault(require("fs"));
10
- const log_1 = require("../util/log");
11
- const meta_statistics_1 = require("./meta-statistics");
12
- const core_1 = require("../core");
13
- const json_1 = require("../util/json");
14
- /**
15
- * By default, {@link extractUsageStatistics} requires a generator, but sometimes you already know all the files
16
- * that you want to process. This function simply reps your requests as a generator.
17
- */
18
- function staticRequests(...requests) {
19
- // eslint-disable-next-line @typescript-eslint/require-await
20
- return async function* () {
21
- for (const request of requests) {
22
- yield request;
23
- }
24
- }();
25
- }
26
- exports.staticRequests = staticRequests;
27
- /**
28
- * Extract all wanted statistic information from a set of requests using the presented R session.
29
- *
30
- * @param shell - The R session to use
31
- * @param onRequest - A callback that is called at the beginning of each request, this may be used to debug the requests.
32
- * @param features - The features to extract (see {@link allFeatureNames}).
33
- * @param requests - The requests to extract the features from. May generate them on demand (e.g., by traversing a folder).
34
- * If your request is statically known, you can use {@link staticRequests} to create this generator.
35
- * @param rootPath - The root path to the project, this is used to relativize the file paths in the statistics.
36
- */
37
- async function extractUsageStatistics(shell, onRequest, features, requests, rootPath) {
38
- let result = initializeFeatureStatistics();
39
- const meta = (0, meta_statistics_1.initialMetaStatistics)();
40
- let first = true;
41
- const outputs = new Map();
42
- for await (const request of requests) {
43
- onRequest(request);
44
- const start = performance.now();
45
- const suffix = request.request === 'file' ? request.content.replace(new RegExp('^' + (rootPath ?? '')), '') : undefined;
46
- try {
47
- let output;
48
- ({ stats: result, output } = await extractSingle(result, shell, {
49
- ...request,
50
- ensurePackageInstalled: first
51
- }, features, suffix));
52
- outputs.set(request, output);
53
- processMetaOnSuccessful(meta, request);
54
- meta.numberOfNormalizedNodes.push(output.normalize.idMap.size);
55
- first = false;
56
- }
57
- catch (e) {
58
- log_1.log.error('for request: ', request, e);
59
- processMetaOnUnsuccessful(meta, request);
60
- }
61
- meta.processingTimeMs.push(performance.now() - start);
62
- }
63
- return { features: result, meta, outputs };
64
- }
65
- exports.extractUsageStatistics = extractUsageStatistics;
66
- function initializeFeatureStatistics() {
67
- const result = {};
68
- for (const key of features_1.allFeatureNames) {
69
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
70
- result[key] = JSON.parse(JSON.stringify(features_1.ALL_FEATURES[key].initialValue, json_1.jsonReplacer), json_1.jsonRetriever);
71
- }
72
- return result;
73
- }
74
- function processMetaOnUnsuccessful(meta, request) {
75
- meta.failedRequests.push(request);
76
- }
77
- function processMetaOnSuccessful(meta, request) {
78
- meta.successfulParsed++;
79
- if (request.request === 'text') {
80
- meta.lines.push(request.content.split('\n').map(l => l.length));
81
- }
82
- else {
83
- meta.lines.push(fs_1.default.readFileSync(request.content, 'utf-8').split('\n').map(l => l.length));
84
- }
85
- }
86
- const parser = new xmldom_1.DOMParser();
87
- async function extractSingle(result, shell, request, features, suffixFilePath) {
88
- const slicerOutput = await new core_1.SteppingSlicer({
89
- stepOfInterest: 'dataflow',
90
- request, shell
91
- }).allRemainingSteps();
92
- // await retrieveXmlFromRCode(from, shell)
93
- const doc = parser.parseFromString(slicerOutput.parse, 'text/xml');
94
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
- for (const [key, feature] of Object.entries(features_1.ALL_FEATURES)) {
96
- if (features !== 'all' && !features.has(key)) {
97
- continue;
98
- }
99
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
100
- result[key] = feature.process(result[key], {
101
- parsedRAst: doc,
102
- dataflow: slicerOutput.dataflow,
103
- normalizedRAst: slicerOutput.normalize,
104
- filepath: suffixFilePath
105
- });
106
- }
107
- return { stats: result, output: slicerOutput };
108
- }
109
- //# sourceMappingURL=statistics.js.map
@@ -1,2 +0,0 @@
1
- import { SummarizerType } from './summarizer';
2
- export declare function detectSummarizationType(inputPath: string): Promise<SummarizerType>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.detectSummarizationType = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const log_1 = require("../log");
9
- const summarizer_1 = require("./statistics/summarizer");
10
- async function detectSummarizationType(inputPath) {
11
- if (fs_1.default.statSync(inputPath).isFile()) {
12
- log_1.log.info(`Detected benchmark summarization with single file ${inputPath}`);
13
- return "benchmark" /* SummarizerType.Benchmark */;
14
- }
15
- // current heuristic: search for a tar.gz with two minus signs :D
16
- const dir = await fs_1.default.promises.opendir(inputPath);
17
- const thresholdInit = 60;
18
- let threshold = thresholdInit;
19
- for await (const dirent of dir) {
20
- if (summarizer_1.statisticsFileNameRegex.test(dirent.name)) {
21
- log_1.log.info(`Detected statistics summarization by file ${dirent.name} matching ${summarizer_1.statisticsFileNameRegex.source}`);
22
- return "statistics" /* SummarizerType.Statistics */;
23
- }
24
- else if (threshold-- < 0) {
25
- break;
26
- }
27
- }
28
- log_1.log.info(`Detected benchmark summarization with no file (first ${thresholdInit}) matching ${summarizer_1.statisticsFileNameRegex.source}`);
29
- return "benchmark" /* SummarizerType.Benchmark */;
30
- }
31
- exports.detectSummarizationType = detectSummarizationType;
32
- //# sourceMappingURL=auto-detect.js.map
@@ -1,66 +0,0 @@
1
- import type { CommonSlicerMeasurements, PerSliceMeasurements, SlicerStats, SlicerStatsDataflow, SlicerStatsInput } from '../../../benchmark';
2
- export interface SummarizedMeasurement<T = number> {
3
- min: T;
4
- max: T;
5
- median: T;
6
- /** total may be useless for some measurements, especially if they are weighted before (it is just the sum...)*/
7
- total: T;
8
- /** average */
9
- mean: number;
10
- /** standard deviation */
11
- std: number;
12
- }
13
- export declare function summarizedMeasurement2Csv(a: SummarizedMeasurement): string;
14
- export declare function summarizedMeasurement2CsvHeader(prefix?: string): string;
15
- export interface SliceSizeCollection {
16
- lines: number[];
17
- characters: number[];
18
- nonWhitespaceCharacters: number[];
19
- /** like library statements during reconstruction */
20
- autoSelected: number[];
21
- dataflowNodes: number[];
22
- tokens: number[];
23
- normalizedTokens: number[];
24
- }
25
- /**
26
- * @see SlicerStats
27
- * @see summarizeSlicerStats
28
- */
29
- export type SummarizedSlicerStats = {
30
- perSliceMeasurements: SummarizedPerSliceStats;
31
- } & Omit<SlicerStats, 'perSliceMeasurements'>;
32
- export interface Reduction<T = number> {
33
- numberOfLines: T;
34
- numberOfLinesNoAutoSelection: T;
35
- numberOfCharacters: T;
36
- numberOfNonWhitespaceCharacters: T;
37
- numberOfRTokens: T;
38
- numberOfNormalizedTokens: T;
39
- numberOfDataflowNodes: T;
40
- }
41
- export interface SummarizedPerSliceStats {
42
- /** number of total slicing calls */
43
- numberOfSlices: number;
44
- /** statistics on the used slicing criteria (number of ids within criteria etc.) */
45
- sliceCriteriaSizes: SummarizedMeasurement;
46
- measurements: Map<PerSliceMeasurements, SummarizedMeasurement>;
47
- reduction: Reduction<SummarizedMeasurement>;
48
- failedToRepParse: number;
49
- timesHitThreshold: number;
50
- sliceSize: {
51
- [K in keyof SliceSizeCollection]: SummarizedMeasurement;
52
- };
53
- }
54
- export interface UltimateSlicerStats {
55
- totalRequests: number;
56
- totalSlices: number;
57
- commonMeasurements: Map<CommonSlicerMeasurements, SummarizedMeasurement>;
58
- perSliceMeasurements: Map<PerSliceMeasurements, SummarizedMeasurement>;
59
- /** sum */
60
- failedToRepParse: number;
61
- /** sum */
62
- timesHitThreshold: number;
63
- reduction: Reduction<SummarizedMeasurement>;
64
- input: SlicerStatsInput<SummarizedMeasurement>;
65
- dataflow: SlicerStatsDataflow<SummarizedMeasurement>;
66
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.summarizedMeasurement2CsvHeader = exports.summarizedMeasurement2Csv = void 0;
4
- function summarizedMeasurement2Csv(a) {
5
- return `${a.min},${a.max},${a.median},${a.mean},${a.std},${a.total}`;
6
- }
7
- exports.summarizedMeasurement2Csv = summarizedMeasurement2Csv;
8
- const summarizedKeys = ['min', 'max', 'median', 'mean', 'std', 'total'];
9
- function summarizedMeasurement2CsvHeader(prefix) {
10
- return summarizedKeys.map(k => prefix ? `${prefix}-${k}` : k).join(',');
11
- }
12
- exports.summarizedMeasurement2CsvHeader = summarizedMeasurement2CsvHeader;
13
- //# sourceMappingURL=data.js.map
@@ -1,2 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function processNestMeasurement(line: Buffer, counter: number, summarizedText: string, outputPath: string): Promise<void>;