@eagleoutice/flowr 1.4.2 → 1.5.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 (223) hide show
  1. package/core/print/slice-diff-ansi.js +7 -7
  2. package/core/steps.d.ts +352 -11
  3. package/core/steps.js +4 -4
  4. package/index.d.ts +0 -2
  5. package/index.js +0 -2
  6. package/package.json +76 -216
  7. package/util/{summarizer/summarizer.d.ts → summarizer.d.ts} +15 -1
  8. package/util/summarizer.js +37 -0
  9. package/util/version.d.ts +2 -0
  10. package/util/version.js +11 -0
  11. package/benchmark/index.d.ts +0 -3
  12. package/benchmark/index.js +0 -20
  13. package/benchmark/slicer.d.ts +0 -98
  14. package/benchmark/slicer.js +0 -213
  15. package/benchmark/stats/index.d.ts +0 -10
  16. package/benchmark/stats/index.js +0 -27
  17. package/benchmark/stats/print.d.ts +0 -7
  18. package/benchmark/stats/print.js +0 -155
  19. package/benchmark/stats/stats.d.ts +0 -40
  20. package/benchmark/stats/stats.js +0 -6
  21. package/benchmark/stopwatch.d.ts +0 -35
  22. package/benchmark/stopwatch.js +0 -79
  23. package/cli/benchmark-app.d.ts +0 -10
  24. package/cli/benchmark-app.js +0 -67
  25. package/cli/benchmark-helper-app.d.ts +0 -9
  26. package/cli/benchmark-helper-app.js +0 -69
  27. package/cli/common/features.d.ts +0 -3
  28. package/cli/common/features.js +0 -30
  29. package/cli/common/index.d.ts +0 -2
  30. package/cli/common/index.js +0 -19
  31. package/cli/common/options.d.ts +0 -20
  32. package/cli/common/options.js +0 -85
  33. package/cli/common/script.d.ts +0 -21
  34. package/cli/common/script.js +0 -61
  35. package/cli/common/scripts-info.d.ts +0 -25
  36. package/cli/common/scripts-info.js +0 -83
  37. package/cli/export-quads-app.d.ts +0 -7
  38. package/cli/export-quads-app.js +0 -42
  39. package/cli/repl/commands/cfg.d.ts +0 -3
  40. package/cli/repl/commands/cfg.js +0 -37
  41. package/cli/repl/commands/commands.d.ts +0 -13
  42. package/cli/repl/commands/commands.js +0 -142
  43. package/cli/repl/commands/dataflow.d.ts +0 -3
  44. package/cli/repl/commands/dataflow.js +0 -34
  45. package/cli/repl/commands/execute.d.ts +0 -4
  46. package/cli/repl/commands/execute.js +0 -27
  47. package/cli/repl/commands/index.d.ts +0 -2
  48. package/cli/repl/commands/index.js +0 -19
  49. package/cli/repl/commands/main.d.ts +0 -39
  50. package/cli/repl/commands/main.js +0 -14
  51. package/cli/repl/commands/normalize.d.ts +0 -3
  52. package/cli/repl/commands/normalize.js +0 -34
  53. package/cli/repl/commands/parse.d.ts +0 -2
  54. package/cli/repl/commands/parse.js +0 -109
  55. package/cli/repl/commands/quit.d.ts +0 -2
  56. package/cli/repl/commands/quit.js +0 -15
  57. package/cli/repl/commands/version.d.ts +0 -16
  58. package/cli/repl/commands/version.js +0 -33
  59. package/cli/repl/core.d.ts +0 -41
  60. package/cli/repl/core.js +0 -172
  61. package/cli/repl/execute.d.ts +0 -28
  62. package/cli/repl/execute.js +0 -79
  63. package/cli/repl/index.d.ts +0 -5
  64. package/cli/repl/index.js +0 -22
  65. package/cli/repl/prompt.d.ts +0 -2
  66. package/cli/repl/prompt.js +0 -9
  67. package/cli/repl/server/connection.d.ts +0 -21
  68. package/cli/repl/server/connection.js +0 -213
  69. package/cli/repl/server/messages/analysis.d.ts +0 -71
  70. package/cli/repl/server/messages/analysis.js +0 -21
  71. package/cli/repl/server/messages/error.d.ts +0 -11
  72. package/cli/repl/server/messages/error.js +0 -3
  73. package/cli/repl/server/messages/hello.d.ts +0 -20
  74. package/cli/repl/server/messages/hello.js +0 -3
  75. package/cli/repl/server/messages/index.d.ts +0 -1
  76. package/cli/repl/server/messages/index.js +0 -3
  77. package/cli/repl/server/messages/messages.d.ts +0 -35
  78. package/cli/repl/server/messages/messages.js +0 -40
  79. package/cli/repl/server/messages/repl.d.ts +0 -33
  80. package/cli/repl/server/messages/repl.js +0 -37
  81. package/cli/repl/server/messages/slice.d.ts +0 -25
  82. package/cli/repl/server/messages/slice.js +0 -37
  83. package/cli/repl/server/net.d.ts +0 -49
  84. package/cli/repl/server/net.js +0 -63
  85. package/cli/repl/server/send.d.ts +0 -4
  86. package/cli/repl/server/send.js +0 -18
  87. package/cli/repl/server/server.d.ts +0 -20
  88. package/cli/repl/server/server.js +0 -66
  89. package/cli/repl/server/validate.d.ts +0 -15
  90. package/cli/repl/server/validate.js +0 -34
  91. package/cli/slicer-app.d.ts +0 -11
  92. package/cli/slicer-app.js +0 -81
  93. package/cli/statistics-app.d.ts +0 -11
  94. package/cli/statistics-app.js +0 -98
  95. package/cli/statistics-helper-app.d.ts +0 -11
  96. package/cli/statistics-helper-app.js +0 -82
  97. package/cli/summarizer-app.d.ts +0 -18
  98. package/cli/summarizer-app.js +0 -66
  99. package/flowr.d.ts +0 -29
  100. package/flowr.js +0 -142
  101. package/statistics/features/common-syntax-probability.d.ts +0 -31
  102. package/statistics/features/common-syntax-probability.js +0 -156
  103. package/statistics/features/feature.d.ts +0 -175
  104. package/statistics/features/feature.js +0 -30
  105. package/statistics/features/index.d.ts +0 -1
  106. package/statistics/features/index.js +0 -18
  107. package/statistics/features/post-processing.d.ts +0 -12
  108. package/statistics/features/post-processing.js +0 -21
  109. package/statistics/features/supported/assignments/assignments.d.ts +0 -11
  110. package/statistics/features/supported/assignments/assignments.js +0 -53
  111. package/statistics/features/supported/assignments/index.d.ts +0 -1
  112. package/statistics/features/supported/assignments/index.js +0 -6
  113. package/statistics/features/supported/assignments/post-process.d.ts +0 -3
  114. package/statistics/features/supported/assignments/post-process.js +0 -125
  115. package/statistics/features/supported/comments/comments.d.ts +0 -18
  116. package/statistics/features/supported/comments/comments.js +0 -133
  117. package/statistics/features/supported/comments/index.d.ts +0 -1
  118. package/statistics/features/supported/comments/index.js +0 -6
  119. package/statistics/features/supported/comments/post-process.d.ts +0 -3
  120. package/statistics/features/supported/comments/post-process.js +0 -50
  121. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  122. package/statistics/features/supported/control-flow/control-flow.js +0 -67
  123. package/statistics/features/supported/control-flow/index.d.ts +0 -1
  124. package/statistics/features/supported/control-flow/index.js +0 -6
  125. package/statistics/features/supported/control-flow/post-process.d.ts +0 -3
  126. package/statistics/features/supported/control-flow/post-process.js +0 -65
  127. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  128. package/statistics/features/supported/data-access/data-access.js +0 -118
  129. package/statistics/features/supported/data-access/index.d.ts +0 -1
  130. package/statistics/features/supported/data-access/index.js +0 -6
  131. package/statistics/features/supported/data-access/post-process.d.ts +0 -3
  132. package/statistics/features/supported/data-access/post-process.js +0 -107
  133. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -35
  134. package/statistics/features/supported/defined-functions/defined-functions.js +0 -139
  135. package/statistics/features/supported/defined-functions/index.d.ts +0 -1
  136. package/statistics/features/supported/defined-functions/index.js +0 -6
  137. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  138. package/statistics/features/supported/defined-functions/post-process.js +0 -177
  139. package/statistics/features/supported/expression-list/expression-list.d.ts +0 -9
  140. package/statistics/features/supported/expression-list/expression-list.js +0 -36
  141. package/statistics/features/supported/expression-list/index.d.ts +0 -1
  142. package/statistics/features/supported/expression-list/index.js +0 -6
  143. package/statistics/features/supported/expression-list/post-process.d.ts +0 -3
  144. package/statistics/features/supported/expression-list/post-process.js +0 -44
  145. package/statistics/features/supported/index.d.ts +0 -10
  146. package/statistics/features/supported/index.js +0 -27
  147. package/statistics/features/supported/loops/index.d.ts +0 -1
  148. package/statistics/features/supported/loops/index.js +0 -6
  149. package/statistics/features/supported/loops/loops.d.ts +0 -20
  150. package/statistics/features/supported/loops/loops.js +0 -79
  151. package/statistics/features/supported/loops/post-process.d.ts +0 -3
  152. package/statistics/features/supported/loops/post-process.js +0 -72
  153. package/statistics/features/supported/used-functions/index.d.ts +0 -1
  154. package/statistics/features/supported/used-functions/index.js +0 -6
  155. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  156. package/statistics/features/supported/used-functions/post-process.js +0 -179
  157. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  158. package/statistics/features/supported/used-functions/used-functions.js +0 -95
  159. package/statistics/features/supported/used-packages/index.d.ts +0 -1
  160. package/statistics/features/supported/used-packages/index.js +0 -6
  161. package/statistics/features/supported/used-packages/post-process.d.ts +0 -3
  162. package/statistics/features/supported/used-packages/post-process.js +0 -121
  163. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  164. package/statistics/features/supported/used-packages/used-packages.js +0 -130
  165. package/statistics/features/supported/values/index.d.ts +0 -1
  166. package/statistics/features/supported/values/index.js +0 -6
  167. package/statistics/features/supported/values/post-process.d.ts +0 -3
  168. package/statistics/features/supported/values/post-process.js +0 -72
  169. package/statistics/features/supported/values/values.d.ts +0 -14
  170. package/statistics/features/supported/values/values.js +0 -101
  171. package/statistics/features/supported/variables/index.d.ts +0 -1
  172. package/statistics/features/supported/variables/index.js +0 -6
  173. package/statistics/features/supported/variables/post-process.d.ts +0 -9
  174. package/statistics/features/supported/variables/post-process.js +0 -122
  175. package/statistics/features/supported/variables/variables.d.ts +0 -15
  176. package/statistics/features/supported/variables/variables.js +0 -70
  177. package/statistics/index.d.ts +0 -6
  178. package/statistics/index.js +0 -24
  179. package/statistics/meta-statistics.d.ts +0 -33
  180. package/statistics/meta-statistics.js +0 -17
  181. package/statistics/output/file-provider.d.ts +0 -37
  182. package/statistics/output/file-provider.js +0 -97
  183. package/statistics/output/index.d.ts +0 -4
  184. package/statistics/output/index.js +0 -21
  185. package/statistics/output/print-stats.d.ts +0 -17
  186. package/statistics/output/print-stats.js +0 -69
  187. package/statistics/output/statistics-file.d.ts +0 -37
  188. package/statistics/output/statistics-file.js +0 -69
  189. package/statistics/statistics.d.ts +0 -24
  190. package/statistics/statistics.js +0 -108
  191. package/util/summarizer/auto-detect.d.ts +0 -2
  192. package/util/summarizer/auto-detect.js +0 -32
  193. package/util/summarizer/benchmark/data.d.ts +0 -66
  194. package/util/summarizer/benchmark/data.js +0 -13
  195. package/util/summarizer/benchmark/first-phase/input.d.ts +0 -3
  196. package/util/summarizer/benchmark/first-phase/input.js +0 -75
  197. package/util/summarizer/benchmark/first-phase/process.d.ts +0 -11
  198. package/util/summarizer/benchmark/first-phase/process.js +0 -217
  199. package/util/summarizer/benchmark/second-phase/graph.d.ts +0 -2
  200. package/util/summarizer/benchmark/second-phase/graph.js +0 -54
  201. package/util/summarizer/benchmark/second-phase/process.d.ts +0 -6
  202. package/util/summarizer/benchmark/second-phase/process.js +0 -126
  203. package/util/summarizer/benchmark/summarizer.d.ts +0 -31
  204. package/util/summarizer/benchmark/summarizer.js +0 -58
  205. package/util/summarizer/statistics/first-phase/process.d.ts +0 -6
  206. package/util/summarizer/statistics/first-phase/process.js +0 -81
  207. package/util/summarizer/statistics/post-process/clusterer.d.ts +0 -26
  208. package/util/summarizer/statistics/post-process/clusterer.js +0 -43
  209. package/util/summarizer/statistics/post-process/file-based-count.d.ts +0 -17
  210. package/util/summarizer/statistics/post-process/file-based-count.js +0 -49
  211. package/util/summarizer/statistics/post-process/histogram.d.ts +0 -59
  212. package/util/summarizer/statistics/post-process/histogram.js +0 -128
  213. package/util/summarizer/statistics/post-process/index.d.ts +0 -4
  214. package/util/summarizer/statistics/post-process/index.js +0 -21
  215. package/util/summarizer/statistics/post-process/post-process-output.d.ts +0 -16
  216. package/util/summarizer/statistics/post-process/post-process-output.js +0 -103
  217. package/util/summarizer/statistics/second-phase/process.d.ts +0 -11
  218. package/util/summarizer/statistics/second-phase/process.js +0 -117
  219. package/util/summarizer/statistics/summarizer.d.ts +0 -35
  220. package/util/summarizer/statistics/summarizer.js +0 -135
  221. package/util/summarizer/summarizer.js +0 -13
  222. /package/{statistics/output → util}/ansi.d.ts +0 -0
  223. /package/{statistics/output → util}/ansi.js +0 -0
@@ -1,98 +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
- const statistics_1 = require("../statistics");
7
- const log_1 = require("../util/log");
8
- const files_1 = require("../util/files");
9
- const common_1 = require("./common");
10
- const parallel_1 = require("../util/parallel");
11
- const features_1 = require("./common/features");
12
- const path_1 = __importDefault(require("path"));
13
- const json_1 = require("../util/json");
14
- const fs_1 = __importDefault(require("fs"));
15
- const options = (0, common_1.processCommandLineArgs)('stats', [], {
16
- subtitle: 'Given input files or folders, this will collect usage statistics for the given features and write them to a file',
17
- examples: [
18
- '{bold -i} {italic example.R} {bold -i} {italic example2.R} {bold --output-dir} {italic "output-folder/"}',
19
- '{italic "folder1/"} {bold --features} {italic all} {bold --output-dir} {italic "output-folder/"}',
20
- '{bold --post-process} {italic "output-folder"} {bold --features} {italic assignments}',
21
- '{bold --help}'
22
- ]
23
- });
24
- if (options.input.length === 0) {
25
- console.error('No input files given. Nothing to do. See \'--help\' if this is an error.');
26
- process.exit(0);
27
- }
28
- if (options['no-ansi']) {
29
- log_1.log.info('disabling ansi colors');
30
- (0, statistics_1.setFormatter)(statistics_1.voidFormatter);
31
- }
32
- const processedFeatures = (0, features_1.validateFeatures)(options.features);
33
- (0, statistics_1.initFileProvider)(options['output-dir']);
34
- const testRegex = /[^/]*\/test/i;
35
- const exampleRegex = /[^/]*\/example/i;
36
- function getPrefixForFile(file) {
37
- if (testRegex.test(file)) {
38
- return 'test-';
39
- }
40
- else if (exampleRegex.test(file)) {
41
- return 'example-';
42
- }
43
- else {
44
- return '';
45
- }
46
- }
47
- function getSuffixForFile(base, file) {
48
- const subpath = path_1.default.relative(base, file);
49
- return '--' + subpath.replace(/\//g, '/');
50
- }
51
- async function collectFileArguments(verboseAdd, dumpJson, features) {
52
- const files = [];
53
- let counter = 0;
54
- let presentSteps = 5000;
55
- let skipped = 0;
56
- for await (const f of (0, files_1.allRFilesFrom)(options.input)) {
57
- const outputDir = path_1.default.join(options['output-dir'], `${getPrefixForFile(f.content)}${getSuffixForFile(options.input.length === 1 ? options.input[0] : '', f.content)}`);
58
- const target = (0, features_1.retrieveArchiveName)(outputDir);
59
- if (fs_1.default.existsSync(target)) {
60
- console.log(`Archive ${target} exists. Skip.`);
61
- skipped++;
62
- continue;
63
- }
64
- files.push(['--input', f.content, '--output-dir', outputDir, '--compress', '--root-dir', options.input.length === 1 ? options.input[0] : '""', ...verboseAdd, ...features, ...dumpJson]);
65
- if (++counter % presentSteps === 0) {
66
- console.log(`Collected ${counter} files`);
67
- if (counter >= 10 * presentSteps) {
68
- presentSteps *= 5;
69
- }
70
- }
71
- }
72
- console.log(`Total: ${counter} files (${skipped} skipped with archive existing)`);
73
- return files;
74
- }
75
- async function getStats() {
76
- console.log(`Processing features: ${JSON.stringify(processedFeatures, json_1.jsonReplacer)}`);
77
- console.log(`Using ${options.parallel} parallel executors`);
78
- const verboseAdd = options.verbose ? ['--verbose'] : [];
79
- const features = [...processedFeatures].flatMap(s => ['--features', s]);
80
- const dumpJson = options['dump-json'] ? ['--dump-json'] : [];
81
- // we do not use the limit argument to be able to pick the limit randomly
82
- const args = await collectFileArguments(verboseAdd, dumpJson, features);
83
- if (options.limit) {
84
- console.log('Shuffle...');
85
- log_1.log.info(`limiting to ${options.limit} files`);
86
- // shuffle and limit
87
- args.sort(() => Math.random() - 0.5);
88
- }
89
- console.log('Prepare Pool...');
90
- const limit = options.limit ?? args.length;
91
- const pool = new parallel_1.LimitedThreadPool(`${__dirname}/statistics-helper-app`, args, limit, options.parallel);
92
- console.log('Run Pool...');
93
- await pool.run();
94
- const stats = pool.getStats();
95
- console.log(`Processed ${stats.counter} files, skipped ${stats.skipped.length} files due to errors`);
96
- }
97
- void getStats();
98
- //# sourceMappingURL=statistics-app.js.map
@@ -1,11 +0,0 @@
1
- export interface StatsHelperCliOptions {
2
- readonly verbose: boolean;
3
- readonly help: boolean;
4
- readonly input: string;
5
- readonly compress: boolean;
6
- readonly 'dump-json': boolean;
7
- readonly 'output-dir': string;
8
- readonly 'root-dir': string;
9
- readonly 'no-ansi': boolean;
10
- readonly features: string[];
11
- }
@@ -1,82 +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
- const r_bridge_1 = require("../r-bridge");
7
- const statistics_1 = require("../statistics");
8
- const log_1 = require("../util/log");
9
- const common_1 = require("./common");
10
- const json_1 = require("../util/json");
11
- const fs_1 = __importDefault(require("fs"));
12
- const assert_1 = require("../util/assert");
13
- const features_1 = require("./common/features");
14
- const core_1 = require("../core");
15
- const time_1 = require("../util/time");
16
- const tar_1 = require("tar");
17
- const cfg_1 = require("../util/cfg/cfg");
18
- const options = (0, common_1.processCommandLineArgs)('stats-helper', [], {
19
- subtitle: 'Given a single input file, this will collect usage statistics for the given features and write them to a file',
20
- examples: [
21
- '{bold -i} {italic example.R} {bold -i} {italic example2.R} {bold --output-dir} {italic "output-folder/"}',
22
- '{bold --help}'
23
- ]
24
- });
25
- if (options['no-ansi']) {
26
- log_1.log.info('disabling ansi colors');
27
- (0, statistics_1.setFormatter)(statistics_1.voidFormatter);
28
- }
29
- let target = undefined;
30
- if (options.compress) {
31
- target = (0, features_1.retrieveArchiveName)(options['output-dir']);
32
- if (fs_1.default.existsSync(target)) {
33
- console.log(`Archive ${target} exists. Skip.`);
34
- process.exit(0);
35
- }
36
- }
37
- // assume correct
38
- const processedFeatures = new Set(options.features);
39
- const shell = new r_bridge_1.RShell();
40
- (0, statistics_1.initFileProvider)(options['output-dir']);
41
- function compressFolder(folder, target) {
42
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
43
- (0, tar_1.create)({
44
- gzip: true,
45
- file: target,
46
- portable: true,
47
- preservePaths: false
48
- }, [folder]).then(() => {
49
- // now, remove the folder
50
- fs_1.default.rmSync(folder, { recursive: true, force: true });
51
- }, () => {
52
- console.log(`failed to compress ${folder}`);
53
- });
54
- }
55
- async function getStatsForSingleFile() {
56
- await shell.obtainTmpDir();
57
- const stats = await (0, statistics_1.extractUsageStatistics)(shell, () => { }, processedFeatures, (0, statistics_1.staticRequests)({ request: 'file', content: options.input }), options['root-dir']);
58
- // console.warn(`skipped ${stats.meta.failedRequests.length} requests due to errors (run with logs to get more info)`)
59
- if (stats.outputs.size === 1) {
60
- if (options['dump-json']) {
61
- const [, output] = [...stats.outputs.entries()][0];
62
- const cfg = (0, cfg_1.extractCFG)(output.normalize);
63
- statistics_1.statisticsFileProvider.append('output-json', 'parse', await (0, core_1.printStepResult)('parse', output.parse, 2 /* StepOutputFormat.Json */));
64
- statistics_1.statisticsFileProvider.append('output-json', 'normalize', await (0, core_1.printStepResult)('normalize', output.normalize, 2 /* StepOutputFormat.Json */));
65
- statistics_1.statisticsFileProvider.append('output-json', 'dataflow', await (0, core_1.printStepResult)('dataflow', output.dataflow, 2 /* StepOutputFormat.Json */));
66
- statistics_1.statisticsFileProvider.append('output-json', 'cfg', JSON.stringify(cfg, json_1.jsonReplacer));
67
- }
68
- statistics_1.statisticsFileProvider.append('meta', 'stats', JSON.stringify({ ...stats.meta, file: options.input }, json_1.jsonReplacer));
69
- statistics_1.statisticsFileProvider.append('meta', 'features', JSON.stringify(stats.features, json_1.jsonReplacer));
70
- }
71
- else {
72
- log_1.log.error(`expected exactly one output vs. ${stats.outputs.size}, got: ${JSON.stringify([...stats.outputs.keys()], json_1.jsonReplacer, 2)}`);
73
- }
74
- if (options.compress) {
75
- (0, assert_1.guard)(target !== undefined, 'target must be defined given the compress option');
76
- console.log(`[${(0, time_1.date2string)(new Date())}] Compressing ${options['output-dir']} to ${target}`);
77
- compressFolder(options['output-dir'], target);
78
- }
79
- shell.close();
80
- }
81
- void getStatsForSingleFile();
82
- //# sourceMappingURL=statistics-helper-app.js.map
@@ -1,18 +0,0 @@
1
- /**
2
- * The summarizer intends to post-process and summarize the results of
3
- * * the benchmark tool, and
4
- * * the statistics extraction.
5
- *
6
- * @module
7
- */
8
- export interface SummarizerCliOptions {
9
- verbose: boolean;
10
- help: boolean;
11
- 'ultimate-only': boolean;
12
- categorize: boolean;
13
- input: string;
14
- type: string;
15
- output?: string;
16
- graph?: boolean;
17
- 'project-skip': number;
18
- }
@@ -1,66 +0,0 @@
1
- "use strict";
2
- /**
3
- * The summarizer intends to post-process and summarize the results of
4
- * * the benchmark tool, and
5
- * * the statistics extraction.
6
- *
7
- * @module
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- const common_1 = require("./common");
11
- const summarizer_1 = require("../util/summarizer/benchmark/summarizer");
12
- const auto_detect_1 = require("../util/summarizer/auto-detect");
13
- const summarizer_2 = require("../util/summarizer/statistics/summarizer");
14
- const statistics_1 = require("../statistics");
15
- const options = (0, common_1.processCommandLineArgs)('summarizer', ['input'], {
16
- subtitle: 'Summarize and explain the results of the benchmark tool. Summarizes in two stages: first per-request, and then overall',
17
- examples: [
18
- '{italic benchmark.json}',
19
- '{bold --help}'
20
- ]
21
- });
22
- const outputBase = (options.output ?? options.input).replace(/\.json$|\/$/, '-summary');
23
- console.log(`Writing outputs to base ${outputBase}`);
24
- function getBenchmarkSummarizer() {
25
- return new summarizer_1.BenchmarkSummarizer({
26
- graphOutputPath: options.graph ? `${outputBase}-graph.json` : undefined,
27
- inputPath: options.input,
28
- intermediateOutputPath: outputBase,
29
- outputPath: `${outputBase}-ultimate.json`,
30
- logger: console.log
31
- });
32
- }
33
- function getStatisticsSummarizer() {
34
- return new summarizer_2.StatisticsSummarizer({
35
- inputPath: options.input,
36
- outputPath: `${outputBase}-final`,
37
- intermediateOutputPath: `${outputBase}-intermediate/`,
38
- projectSkip: options['project-skip'],
39
- featuresToUse: statistics_1.allFeatureNames,
40
- logger: console.log
41
- });
42
- }
43
- async function retrieveSummarizer() {
44
- const type = options.type === 'auto' ? await (0, auto_detect_1.detectSummarizationType)(options.input) : options.type;
45
- if (type === "benchmark" /* SummarizerType.Benchmark */) {
46
- console.log('Summarizing benchmark');
47
- return getBenchmarkSummarizer();
48
- }
49
- else if (type === "statistics" /* SummarizerType.Statistics */) {
50
- console.log('Summarizing statistics');
51
- return getStatisticsSummarizer();
52
- }
53
- else {
54
- console.error('Unknown type', type, 'either give "benchmark" or "statistics"');
55
- process.exit(1);
56
- }
57
- }
58
- async function run() {
59
- const summarizer = await retrieveSummarizer();
60
- if (!options['ultimate-only']) {
61
- await summarizer.preparationPhase(options.categorize);
62
- }
63
- await summarizer.summarizePhase();
64
- }
65
- void run();
66
- //# sourceMappingURL=summarizer-app.js.map
package/flowr.d.ts DELETED
@@ -1,29 +0,0 @@
1
- import type { OptionDefinition } from 'command-line-usage';
2
- export declare const toolName = "flowr";
3
- export declare const optionDefinitions: OptionDefinition[];
4
- export interface FlowrCliOptions {
5
- verbose: boolean;
6
- version: boolean;
7
- help: boolean;
8
- server: boolean;
9
- ws: boolean;
10
- port: number;
11
- 'no-ansi': boolean;
12
- execute: string | undefined;
13
- script: string | undefined;
14
- 'config-file': string;
15
- 'r-path': string | undefined;
16
- }
17
- export declare const optionHelp: ({
18
- header: string;
19
- content: string;
20
- optionList?: undefined;
21
- } | {
22
- header: string;
23
- content: string[];
24
- optionList?: undefined;
25
- } | {
26
- header: string;
27
- optionList: OptionDefinition[];
28
- content?: undefined;
29
- })[];
package/flowr.js DELETED
@@ -1,142 +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.optionHelp = exports.optionDefinitions = exports.toolName = void 0;
7
- /**
8
- * The main script to run flowR.
9
- *
10
- * If started with arguments it may be used to run a single of the flowR scripts.
11
- * Otherwise, it will start a REPL that can call these scripts and return their results repeatedly.
12
- */
13
- const log_1 = require("./util/log");
14
- const r_bridge_1 = require("./r-bridge");
15
- const command_line_usage_1 = __importDefault(require("command-line-usage"));
16
- const command_line_args_1 = __importDefault(require("command-line-args"));
17
- const assert_1 = require("./util/assert");
18
- const statistics_1 = require("./statistics");
19
- const repl_1 = require("./cli/repl");
20
- const common_1 = require("./cli/common");
21
- const package_json_1 = require("../package.json");
22
- const version_1 = require("./cli/repl/commands/version");
23
- const server_1 = require("./cli/repl/server/server");
24
- const commands_1 = require("./cli/repl/commands");
25
- const net_1 = require("./cli/repl/server/net");
26
- const config_1 = require("./config");
27
- const scriptsText = Array.from(Object.entries(common_1.scripts).filter(([, { type }]) => type === 'master script'), ([k,]) => k).join(', ');
28
- exports.toolName = 'flowr';
29
- exports.optionDefinitions = [
30
- { name: 'verbose', alias: 'v', type: Boolean, description: 'Run with verbose logging (will be passed to the corresponding script)' },
31
- { name: 'help', alias: 'h', type: Boolean, description: 'Print this usage guide (or the guide of the corresponding script)' },
32
- { name: 'version', alias: 'V', type: Boolean, description: 'Provide information about the version of flowR as well as its underlying R system and exit.' },
33
- { name: 'server', type: Boolean, description: 'Do not drop into a repl, but instead start a server on the given port (default: 1042) and listen for messages.' },
34
- { name: 'ws', type: Boolean, description: 'If the server flag is set, use websocket for messaging' },
35
- { name: 'port', type: Number, description: 'The port to listen on, if --server is given.', defaultValue: 1042, typeLabel: '{underline port}' },
36
- { name: 'execute', alias: 'e', type: String, description: 'Execute the given command and exit. Use a semicolon ";" to separate multiple commands.', typeLabel: '{underline command}', multiple: false },
37
- { name: 'no-ansi', type: Boolean, description: 'Disable ansi-escape-sequences in the output. Useful, if you want to redirect the output to a file.' },
38
- { name: 'script', alias: 's', type: String, description: `The sub-script to run (${scriptsText})`, multiple: false, defaultOption: true, typeLabel: '{underline files}', defaultValue: undefined },
39
- { name: 'config-file', type: String, description: 'The name of the configuration file to use', multiple: false },
40
- { name: 'r-path', type: String, description: 'The path to the R executable to use. Defaults to your PATH.', multiple: false }
41
- ];
42
- exports.optionHelp = [
43
- {
44
- header: `flowR (version ${String(package_json_1.version)})`,
45
- content: 'A static dataflow analyzer and program slicer for R programs'
46
- },
47
- {
48
- header: 'Synopsis',
49
- content: [
50
- `$ ${exports.toolName} {bold --help}`,
51
- `$ ${exports.toolName} {bold --version}`,
52
- `$ ${exports.toolName} {bold --server}`,
53
- `$ ${exports.toolName} {bold --execute} {italic ":parse 2 - 4"}`,
54
- `$ ${exports.toolName} {bold slicer} {bold --help}`,
55
- ]
56
- },
57
- {
58
- header: 'Options',
59
- optionList: exports.optionDefinitions
60
- }
61
- ];
62
- const options = (0, command_line_args_1.default)(exports.optionDefinitions);
63
- log_1.log.updateSettings(l => l.settings.minLevel = options.verbose ? 1 /* LogLevel.Trace */ : 5 /* LogLevel.Error */);
64
- log_1.log.info('running with options', options);
65
- if (options['no-ansi']) {
66
- log_1.log.info('disabling ansi colors');
67
- (0, statistics_1.setFormatter)(statistics_1.voidFormatter);
68
- }
69
- (0, config_1.setConfigFile)(undefined, options['config-file'] ?? config_1.defaultConfigFile, true);
70
- function retrieveShell() {
71
- // we keep an active shell session to allow other parse investigations :)
72
- let opts = {
73
- revive: 'always',
74
- onRevive: (code, signal) => {
75
- const signalText = signal == null ? '' : ` and signal ${signal}`;
76
- console.log(statistics_1.formatter.format(`R process exited with code ${code}${signalText}. Restarting...`, { color: 5 /* Colors.Magenta */, effect: statistics_1.ColorEffect.Foreground }));
77
- console.log((0, statistics_1.italic)(`If you want to exit, press either Ctrl+C twice, or enter ${(0, statistics_1.bold)(':quit')}`));
78
- }
79
- };
80
- if (options['r-path']) {
81
- opts = { ...opts, pathToRExecutable: options['r-path'] };
82
- }
83
- return new r_bridge_1.RShell(opts);
84
- }
85
- async function mainRepl() {
86
- if (options.script) {
87
- let target = common_1.scripts[options.script].target;
88
- (0, assert_1.guard)(target !== undefined, `Unknown script ${options.script}, pick one of ${scriptsText}.`);
89
- console.log(`Running script '${statistics_1.formatter.format(options.script, { style: 1 /* FontStyles.Bold */ })}'`);
90
- target = `cli/${target}`;
91
- log_1.log.debug(`Script maps to "${target}"`);
92
- await (0, repl_1.waitOnScript)(`${__dirname}/${target}`, process.argv.slice(3), undefined, true);
93
- process.exit(0);
94
- }
95
- if (options.help) {
96
- console.log((0, command_line_usage_1.default)(exports.optionHelp));
97
- process.exit(0);
98
- }
99
- if (options.version) {
100
- await (0, version_1.printVersionInformation)(commands_1.standardReplOutput);
101
- process.exit(0);
102
- }
103
- const shell = retrieveShell();
104
- const end = () => {
105
- if (options.execute === undefined) {
106
- console.log(`\n${(0, statistics_1.italic)('Exiting...')}`);
107
- }
108
- shell.close();
109
- process.exit(0);
110
- };
111
- // hook some handlers
112
- process.on('SIGINT', end);
113
- process.on('SIGTERM', end);
114
- if (options.execute) {
115
- await (0, repl_1.replProcessAnswer)(commands_1.standardReplOutput, options.execute, shell);
116
- }
117
- else {
118
- await (0, repl_1.repl)(shell);
119
- }
120
- process.exit(0);
121
- }
122
- async function mainServer(backend = new net_1.NetServer()) {
123
- const shell = retrieveShell();
124
- const end = () => {
125
- if (options.execute === undefined) {
126
- console.log(`\n${(0, statistics_1.italic)('Exiting...')}`);
127
- }
128
- shell.close();
129
- process.exit(0);
130
- };
131
- // hook some handlers
132
- process.on('SIGINT', end);
133
- process.on('SIGTERM', end);
134
- await new server_1.FlowRServer(shell, backend).start(options.port);
135
- }
136
- if (options.server) {
137
- void mainServer(options.ws ? new net_1.WebSocketServerWrapper() : new net_1.NetServer());
138
- }
139
- else {
140
- void mainRepl();
141
- }
142
- //# sourceMappingURL=flowr.js.map
@@ -1,31 +0,0 @@
1
- /**
2
- * Defines the type of syntax constructs that we track (e.g., true, false, 0, 1, T, F, conditions...)
3
- */
4
- import type { RNodeWithParent } from '../../r-bridge';
5
- import { RFalse, RTrue } from '../../r-bridge';
6
- import type { SummarizedMeasurement } from '../../util/summarizer/benchmark/data';
7
- export interface CommonSyntaxTypeCounts<Measurement = bigint> {
8
- total: Measurement;
9
- multiple: Measurement;
10
- empty: Measurement;
11
- withArgument: Measurement;
12
- noValue: Measurement;
13
- singleVar: Record<string, Measurement>;
14
- number: Record<number, Measurement>;
15
- integer: Record<number, Measurement>;
16
- complex: Record<number, Measurement>;
17
- string: Record<string, Measurement>;
18
- logical: Record<typeof RTrue | typeof RFalse, Measurement>;
19
- call: Record<string, Measurement>;
20
- unnamedCall: Measurement;
21
- binOp: Record<string, Measurement>;
22
- unaryOp: Record<string, Measurement>;
23
- other: Record<string, Measurement>;
24
- }
25
- export declare function emptyCommonSyntaxTypeCounts<T = bigint>(init?: () => T): CommonSyntaxTypeCounts<T>;
26
- /**
27
- * Updates the given counts based on the type of the given node.
28
- */
29
- export declare function updateCommonSyntaxTypeCounts(current: CommonSyntaxTypeCounts, ...nodes: RNodeWithParent[]): CommonSyntaxTypeCounts;
30
- export declare function appendCommonSyntaxTypeCounter(a: CommonSyntaxTypeCounts<number[][]>, b: CommonSyntaxTypeCounts): void;
31
- export declare function summarizeCommonSyntaxTypeCounter(a: CommonSyntaxTypeCounts<number[][]>): CommonSyntaxTypeCounts<SummarizedMeasurement>;
@@ -1,156 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.summarizeCommonSyntaxTypeCounter = exports.appendCommonSyntaxTypeCounter = exports.updateCommonSyntaxTypeCounts = exports.emptyCommonSyntaxTypeCounts = void 0;
4
- const r_bridge_1 = require("../../r-bridge");
5
- const process_1 = require("../../util/summarizer/benchmark/first-phase/process");
6
- const numbers_1 = require("../../util/numbers");
7
- function emptyCommonSyntaxTypeCounts(init = () => 0n) {
8
- return {
9
- total: init(),
10
- multiple: init(),
11
- empty: init(),
12
- withArgument: init(),
13
- noValue: init(),
14
- singleVar: {},
15
- number: {},
16
- integer: {},
17
- complex: {},
18
- string: {},
19
- logical: {},
20
- call: {},
21
- unnamedCall: init(),
22
- binOp: {},
23
- unaryOp: {},
24
- other: {}
25
- };
26
- }
27
- exports.emptyCommonSyntaxTypeCounts = emptyCommonSyntaxTypeCounts;
28
- function incrementEntry(map, key) {
29
- map[key] = (map[key] ?? 0n) + 1n;
30
- }
31
- /**
32
- * Updates the given counts based on the type of the given node.
33
- */
34
- function updateCommonSyntaxTypeCounts(current, ...nodes) {
35
- current.total++;
36
- if (nodes.length === 0) {
37
- current.empty++;
38
- return current;
39
- }
40
- else if (nodes.length > 1) {
41
- current.multiple++;
42
- return current;
43
- }
44
- let node = nodes[0];
45
- if (node.type === "RArgument" /* RType.Argument */) {
46
- if (node.name !== undefined) {
47
- current.withArgument++;
48
- }
49
- if (node.value !== undefined) {
50
- node = node.value;
51
- }
52
- else {
53
- current.noValue++;
54
- return current;
55
- }
56
- }
57
- switch (node.type) {
58
- case "RString" /* RType.String */:
59
- incrementEntry(current.string, node.content.str);
60
- break;
61
- case "RSymbol" /* RType.Symbol */:
62
- incrementEntry(current.singleVar, node.content);
63
- break;
64
- case "RLogical" /* RType.Logical */:
65
- incrementEntry(current.logical, node.content ? r_bridge_1.RTrue : r_bridge_1.RFalse);
66
- break;
67
- case "RNumber" /* RType.Number */:
68
- if (node.content.complexNumber) {
69
- incrementEntry(current.complex, node.content.num);
70
- }
71
- else if (node.content.markedAsInt) {
72
- incrementEntry(current.integer, node.content.num);
73
- }
74
- else {
75
- incrementEntry(current.number, node.content.num);
76
- }
77
- break;
78
- case "RFunctionCall" /* RType.FunctionCall */:
79
- if (node.flavor === 'unnamed') {
80
- current.unnamedCall++;
81
- }
82
- else {
83
- incrementEntry(current.call, node.functionName.content);
84
- }
85
- break;
86
- case "RBinaryOp" /* RType.BinaryOp */:
87
- incrementEntry(current.binOp, node.operator);
88
- break;
89
- case "RUnaryOp" /* RType.UnaryOp */:
90
- incrementEntry(current.unaryOp, node.operator);
91
- break;
92
- default:
93
- // for space reasons we do not record the full lexeme!
94
- if (node.lexeme) {
95
- incrementEntry(current.other, node.lexeme);
96
- }
97
- break;
98
- }
99
- return current;
100
- }
101
- exports.updateCommonSyntaxTypeCounts = updateCommonSyntaxTypeCounts;
102
- function appendRecord(a, b) {
103
- for (const [key, val] of Object.entries(b)) {
104
- const get = a[key];
105
- // we guard with array to guard against methods like `toString` which are given in js
106
- if (!get || !Array.isArray(get)) {
107
- a[key] = [[(0, numbers_1.bigint2number)(val)]];
108
- continue;
109
- }
110
- get.push([(0, numbers_1.bigint2number)(val)]);
111
- }
112
- }
113
- function appendCommonSyntaxTypeCounter(a, b) {
114
- a.total.push([(0, numbers_1.bigint2number)(b.total)]);
115
- a.empty.push([(0, numbers_1.bigint2number)(b.empty)]);
116
- a.multiple.push([(0, numbers_1.bigint2number)(b.multiple)]);
117
- a.withArgument.push([(0, numbers_1.bigint2number)(b.withArgument)]);
118
- a.noValue.push([(0, numbers_1.bigint2number)(b.noValue)]);
119
- a.unnamedCall.push([(0, numbers_1.bigint2number)(b.unnamedCall)]);
120
- appendRecord(a.singleVar, b.singleVar);
121
- appendRecord(a.number, b.number);
122
- appendRecord(a.integer, b.integer);
123
- appendRecord(a.complex, b.complex);
124
- appendRecord(a.string, b.string);
125
- appendRecord(a.logical, b.logical);
126
- appendRecord(a.call, b.call);
127
- appendRecord(a.binOp, b.binOp);
128
- appendRecord(a.unaryOp, b.unaryOp);
129
- appendRecord(a.other, b.other);
130
- }
131
- exports.appendCommonSyntaxTypeCounter = appendCommonSyntaxTypeCounter;
132
- function summarizeRecord(a) {
133
- return Object.fromEntries(Object.entries(a).map(([key, val]) => [key, (0, process_1.summarizeMeasurement)(val.flat(), val.length)]));
134
- }
135
- function summarizeCommonSyntaxTypeCounter(a) {
136
- return {
137
- total: (0, process_1.summarizeMeasurement)(a.total.flat(), a.total.length),
138
- empty: (0, process_1.summarizeMeasurement)(a.empty.flat(), a.empty.length),
139
- multiple: (0, process_1.summarizeMeasurement)(a.multiple.flat(), a.multiple.length),
140
- withArgument: (0, process_1.summarizeMeasurement)(a.withArgument.flat(), a.withArgument.length),
141
- noValue: (0, process_1.summarizeMeasurement)(a.noValue.flat(), a.noValue.length),
142
- unnamedCall: (0, process_1.summarizeMeasurement)(a.unnamedCall.flat(), a.unnamedCall.length),
143
- singleVar: summarizeRecord(a.singleVar),
144
- number: summarizeRecord(a.number),
145
- integer: summarizeRecord(a.integer),
146
- complex: summarizeRecord(a.complex),
147
- string: summarizeRecord(a.string),
148
- logical: summarizeRecord(a.logical),
149
- call: summarizeRecord(a.call),
150
- binOp: summarizeRecord(a.binOp),
151
- unaryOp: summarizeRecord(a.unaryOp),
152
- other: summarizeRecord(a.other)
153
- };
154
- }
155
- exports.summarizeCommonSyntaxTypeCounter = summarizeCommonSyntaxTypeCounter;
156
- //# sourceMappingURL=common-syntax-probability.js.map