@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,72 +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.postProcess = void 0;
7
- const post_processing_1 = require("../../post-processing");
8
- const common_syntax_probability_1 = require("../../common-syntax-probability");
9
- const numbers_1 = require("../../../../util/numbers");
10
- const path_1 = __importDefault(require("path"));
11
- const node_fs_1 = __importDefault(require("node:fs"));
12
- const data_1 = require("../../../../util/summarizer/benchmark/data");
13
- const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
14
- function postProcess(featureRoot, info, outputPath, config) {
15
- const collected = {
16
- forLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
17
- forLoopVar: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
18
- forBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
19
- whileLoops: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
20
- whileBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
21
- repeatLoops: (0, post_processing_1.emptySummarizedWithProject)(),
22
- repeatBody: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []),
23
- breakStatements: (0, post_processing_1.emptySummarizedWithProject)(),
24
- nextStatements: (0, post_processing_1.emptySummarizedWithProject)(),
25
- implicitLoops: (0, post_processing_1.emptySummarizedWithProject)(),
26
- nestedExplicitLoops: (0, post_processing_1.emptySummarizedWithProject)(),
27
- deepestExplicitNesting: (0, post_processing_1.emptySummarizedWithProject)()
28
- };
29
- for (const [filepath, data] of info.entries()) {
30
- const value = data.loops;
31
- for (const [key, val] of Object.entries(value)) {
32
- if (typeof val !== 'object') {
33
- const get = collected[key];
34
- get.count.push(typeof val === 'number' ? Number(val) : (0, numbers_1.bigint2number)(val));
35
- if (val > 0) {
36
- (0, post_processing_1.recordFilePath)(get, filepath, config);
37
- }
38
- }
39
- else {
40
- (0, common_syntax_probability_1.appendCommonSyntaxTypeCounter)(collected[key], val);
41
- }
42
- }
43
- }
44
- const metaOut = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loops-meta.csv'));
45
- metaOut.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
46
- for (const [key, val] of Object.entries(collected)) {
47
- const data = val;
48
- if ('uniqueProjects' in data) {
49
- metaOut.write(`${JSON.stringify(key)},${data.uniqueProjects.size},${data.uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.count))}\n`);
50
- }
51
- else {
52
- // new file for each :D
53
- const out = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, `loops-type-${key}.csv`));
54
- // name is for fields like number etc to allow to group multiple entries
55
- out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
56
- for (const [name, vals] of Object.entries(data)) {
57
- if (Array.isArray(vals)) {
58
- out.write(`${JSON.stringify(name)},"",${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(vals.flat()))}\n`);
59
- }
60
- else {
61
- for (const [keyName, keyValue] of Object.entries(vals)) {
62
- out.write(`${JSON.stringify(name)},${JSON.stringify(keyName)},${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(keyValue.flat()))}\n`);
63
- }
64
- }
65
- }
66
- out.close();
67
- }
68
- }
69
- metaOut.close();
70
- }
71
- exports.postProcess = postProcess;
72
- //# sourceMappingURL=post-process.js.map
@@ -1 +0,0 @@
1
- export { usedFunctions } from './used-functions';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usedFunctions = void 0;
4
- var used_functions_1 = require("./used-functions");
5
- Object.defineProperty(exports, "usedFunctions", { enumerable: true, get: function () { return used_functions_1.usedFunctions; } });
6
- //# sourceMappingURL=index.js.map
@@ -1,6 +0,0 @@
1
- import type { FeatureStatisticsWithMeta } from '../../feature';
2
- import type { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
- /**
4
- * Note: the summary does not contain a 0 for each function that is _not_ called by a file. Hence, the minimum can not be 0 (division for mean etc. will still be performed on total file count)
5
- */
6
- export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
@@ -1,179 +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.postProcess = void 0;
7
- const data_1 = require("../../../../util/summarizer/benchmark/data");
8
- const common_syntax_probability_1 = require("../../common-syntax-probability");
9
- const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
10
- const files_1 = require("../../../../util/files");
11
- const path_1 = __importDefault(require("path"));
12
- const node_fs_1 = __importDefault(require("node:fs"));
13
- const time_1 = require("../../../../util/time");
14
- const used_functions_1 = require("./used-functions");
15
- const numbers_1 = require("../../../../util/numbers");
16
- function retrieveFunctionCallInformation(featureRoot, info, config, outputPath) {
17
- // each number[][] contains a 'number[]' per file
18
- /**
19
- * maps fn-name (including namespace) to number of arguments and their location (the number of elements in the array give the number of total call)
20
- * we use tuples to reduce the memory!
21
- * A function that is defined within the file is _always_ decorated with the filename (as second array element)!
22
- */
23
- const functionsPerFile = new Map();
24
- const importantFunctions = new Map(['parse',
25
- 'eval',
26
- 'deparse',
27
- 'quote',
28
- 'body',
29
- 'formals',
30
- 'body',
31
- 'environment',
32
- 'new.env',
33
- 'assign',
34
- 'get',
35
- 'setGeneric',
36
- 'R6Class'].map(name => [name, node_fs_1.default.createWriteStream(path_1.default.join(outputPath, `${name}.csv`))]));
37
- for (const [, value] of importantFunctions) {
38
- value.write('filepath,location,namespace,inspected by,classification,notes\n');
39
- }
40
- // we collect only `all-calls`
41
- (0, files_1.readLineByLineSync)(path_1.default.join(featureRoot, `${used_functions_1.AllCallsFileBase}.txt`), (line, lineNumber) => processNextLine(functionsPerFile, lineNumber, info, JSON.parse(String(line)), config, importantFunctions));
42
- for (const [, value] of importantFunctions) {
43
- value.close();
44
- }
45
- importantFunctions.clear();
46
- console.log(` [${(0, time_1.date2string)(new Date())}] Used functions process completed, start to write out function info`);
47
- const fnOutStream = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls.csv'));
48
- const prefixes = ['total', 'args', 'line-frac'];
49
- const others = prefixes.flatMap(data_1.summarizedMeasurement2CsvHeader).join(',');
50
- fnOutStream.write(`function,unique-projects,unique-files,${others}\n`);
51
- for (const [key, [uniqueProjects, uniqueFiles, total, args, lineFrac]] of functionsPerFile.entries()) {
52
- const totalSum = (0, process_1.summarizeMeasurement)(total.flat(), info.size);
53
- const argsSum = (0, process_1.summarizeMeasurement)(args.flat(), info.size);
54
- const lineFracSum = (0, process_1.summarizeMeasurement)(lineFrac.flat());
55
- // we write in csv style :), we escape the key in case it contains commas (with filenames)etc.
56
- fnOutStream.write(`${JSON.stringify(key ?? 'unknown')},${uniqueProjects.size},${uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)(totalSum)},${(0, data_1.summarizedMeasurement2Csv)(argsSum)},${(0, data_1.summarizedMeasurement2Csv)(lineFracSum)}\n`);
57
- }
58
- fnOutStream.close();
59
- }
60
- function writeFunctionCallsMetaInformationToCsv(outputPath, data) {
61
- const out = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls-meta.csv'));
62
- out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
63
- out.write(`average-call,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.averageCall.flat()))}\n`);
64
- out.write(`nested-calls,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.nestedCalls.flat()))}\n`);
65
- out.write(`deepest-nesting,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.deepestNesting.flat()))}\n`);
66
- out.write(`empty-args,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.emptyArgs.flat()))}\n`);
67
- out.write(`unnamed-calls,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.unnamedCalls.flat()))}\n`);
68
- out.close();
69
- }
70
- function retrieveFunctionCallMetaInformation(info, outputPath) {
71
- const data = {
72
- averageCall: [],
73
- nestedCalls: [],
74
- deepestNesting: [],
75
- emptyArgs: [],
76
- unnamedCalls: [],
77
- args: []
78
- };
79
- for (const meta of info.values()) {
80
- const us = meta.usedFunctions;
81
- data.averageCall.push([us.allFunctionCalls]);
82
- data.nestedCalls.push([us.nestedFunctionCalls]);
83
- data.deepestNesting.push([us.deepestNesting]);
84
- data.emptyArgs.push([(0, numbers_1.bigint2number)(us.args[0])]);
85
- data.unnamedCalls.push([us.unnamedCalls]);
86
- for (const [i, val] of Object.entries(us.args)) {
87
- if (Number(i) !== 0) {
88
- let get = data.args[Number(i)];
89
- if (!get) {
90
- get = (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(() => []);
91
- data.args[Number(i)] = get;
92
- }
93
- (0, common_syntax_probability_1.appendCommonSyntaxTypeCounter)(get, val);
94
- }
95
- }
96
- }
97
- console.log(` [${(0, time_1.date2string)(new Date())}] Used functions metadata reading completed, summarizing and writing to file`);
98
- writeFunctionCallsMetaInformationToCsv(outputPath, data);
99
- for (const [index, arg] of data.args.entries()) {
100
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
101
- if (!arg) {
102
- // we treat the first/0-argument entry separate for legacy reasons
103
- continue;
104
- }
105
- const out = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, `function-calls-arg-${index}.csv`));
106
- out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
107
- for (const [name, vals] of Object.entries(arg)) {
108
- if (Array.isArray(vals)) {
109
- out.write(`${JSON.stringify(name)},"",${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(vals.flat()))}\n`);
110
- }
111
- else {
112
- for (const [keyName, keyValue] of Object.entries(vals)) {
113
- out.write(`${JSON.stringify(name)},${JSON.stringify(keyName)},${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(keyValue.flat()))}\n`);
114
- }
115
- }
116
- }
117
- out.close();
118
- }
119
- }
120
- /**
121
- * Note: the summary does not contain a 0 for each function that is _not_ called by a file. Hence, the minimum can not be 0 (division for mean etc. will still be performed on total file count)
122
- */
123
- function postProcess(featureRoot, info, outputPath, config) {
124
- retrieveFunctionCallInformation(featureRoot, info, config, outputPath);
125
- console.log(` [${(0, time_1.date2string)(new Date())}] Used functions reading completed, summarizing info...`);
126
- retrieveFunctionCallMetaInformation(info, outputPath);
127
- }
128
- exports.postProcess = postProcess;
129
- function processNextLine(data, lineNumber, info, line, config, importants) {
130
- if (lineNumber % 2_500 === 0) {
131
- console.log(` [${(0, time_1.date2string)(new Date())}] Used functions processed ${lineNumber} lines`);
132
- }
133
- const [hits, context] = line;
134
- // group hits by fullname
135
- const groupedByFunctionName = new Map();
136
- for (const [name, loc, args, ns, known] of hits) {
137
- const importantWrite = name && importants.get(name);
138
- if (importantWrite) {
139
- importantWrite.write(`${JSON.stringify(context)},${loc?.[0] ?? '?'}:${loc?.[1] ?? '?'},${ns ?? '""'},,,\n`);
140
- }
141
- const fullname = ns && ns !== '' ? `${ns}::${name ?? ''}` : name;
142
- const key = (fullname ?? '') + (known === 1 ? '-' + (context ?? '') : '');
143
- const stats = info.get(context ?? '')?.stats.lines[0].length;
144
- let get = groupedByFunctionName.get(key);
145
- if (!get) {
146
- get = [new Set(), new Set(), [], [], []];
147
- groupedByFunctionName.set(key, get);
148
- }
149
- // we retrieve the first component fo the path
150
- const projectName = context?.split(path_1.default.sep)[config.projectSkip];
151
- get[0].add(projectName ?? '');
152
- get[1].add(context ?? '');
153
- get[2].push(1);
154
- get[3].push(args);
155
- if (loc && stats) {
156
- // we reduce by 1 to get flat 0% if it is the first line
157
- get[4].push(stats === 1 ? 1 : (loc[0] - 1) / (stats - 1));
158
- }
159
- }
160
- for (const [key, info] of groupedByFunctionName.entries()) {
161
- let get = data.get(key);
162
- if (!get) {
163
- get = [new Set(), new Set(), [], [], []];
164
- // an amazing empty structure :D
165
- data.set(key, get);
166
- }
167
- // for total, we only need the number of elements as it will always be one :D
168
- for (const context of info[0]) {
169
- get[0].add(context);
170
- }
171
- for (const context of info[1]) {
172
- get[1].add(context);
173
- }
174
- get[2].push([info[2].length]);
175
- get[3].push(info[3]);
176
- get[4].push(info[4]);
177
- }
178
- }
179
- //# sourceMappingURL=post-process.js.map
@@ -1,24 +0,0 @@
1
- import type { Feature } from '../../feature';
2
- import type { Writable } from 'ts-essentials';
3
- import type { CommonSyntaxTypeCounts } from '../../common-syntax-probability';
4
- declare const initialFunctionUsageInfo: {
5
- allFunctionCalls: number;
6
- args: Record<number, bigint | CommonSyntaxTypeCounts<bigint>>;
7
- /** `a(b(), c(3, d()))` has 3 (`b`, `c`, `d`) */
8
- nestedFunctionCalls: number;
9
- deepestNesting: number;
10
- unnamedCalls: number;
11
- };
12
- export type FunctionUsageInfo = Writable<typeof initialFunctionUsageInfo>;
13
- export declare const AllCallsFileBase = "all-calls";
14
- export declare const usedFunctions: Feature<FunctionUsageInfo>;
15
- export type FunctionCallInformation = [
16
- /** the name of the called function, or undefined if this was an unnamed function call */
17
- name: string | undefined,
18
- location: [line: number, character: number] | undefined,
19
- numberOfArguments: number,
20
- /** whether this was called from a namespace, like `a::b()` */
21
- namespace: string | undefined,
22
- knownDefinitionInFile: 0 | 1
23
- ];
24
- export {};
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usedFunctions = exports.AllCallsFileBase = void 0;
4
- const output_1 = require("../../../output");
5
- const r_bridge_1 = require("../../../../r-bridge");
6
- const dataflow_1 = require("../../../../dataflow");
7
- const common_syntax_probability_1 = require("../../common-syntax-probability");
8
- const post_process_1 = require("./post-process");
9
- const initialFunctionUsageInfo = {
10
- allFunctionCalls: 0,
11
- args: {
12
- // only if called without arguments
13
- 0: 0n,
14
- 1: (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)()
15
- },
16
- /** `a(b(), c(3, d()))` has 3 (`b`, `c`, `d`) */
17
- nestedFunctionCalls: 0,
18
- deepestNesting: 0,
19
- unnamedCalls: 0
20
- };
21
- exports.AllCallsFileBase = 'all-calls';
22
- exports.usedFunctions = {
23
- name: 'Used Functions',
24
- description: 'All functions called, split into various sub-categories',
25
- process(existing, input) {
26
- visitCalls(existing, input);
27
- return existing;
28
- },
29
- initialValue: initialFunctionUsageInfo,
30
- postProcess: post_process_1.postProcess
31
- };
32
- function classifyArguments(args, existing) {
33
- if (args.length === 0) {
34
- existing[0]++;
35
- return;
36
- }
37
- let i = 1;
38
- for (const arg of args) {
39
- if (arg === undefined) {
40
- existing[0]++;
41
- continue;
42
- }
43
- existing[i] = (0, common_syntax_probability_1.updateCommonSyntaxTypeCounts)(existing[i] ?? (0, common_syntax_probability_1.emptyCommonSyntaxTypeCounts)(), arg);
44
- i++;
45
- }
46
- }
47
- function visitCalls(info, input) {
48
- const calls = [];
49
- const allCalls = [];
50
- (0, r_bridge_1.visitAst)(input.normalizedRAst.ast, node => {
51
- if (node.type !== "RFunctionCall" /* RType.FunctionCall */) {
52
- return;
53
- }
54
- if (calls.length > 0) {
55
- info.nestedFunctionCalls++;
56
- (0, output_1.appendStatisticsFile)(exports.usedFunctions.name, 'nested-calls', [node.lexeme], input.filepath);
57
- info.deepestNesting = Math.max(info.deepestNesting, calls.length);
58
- }
59
- const dataflowNode = input.dataflow.graph.get(node.info.id);
60
- let hasCallsEdge = false;
61
- if (dataflowNode) {
62
- hasCallsEdge = [...dataflowNode[1].values()].some(e => e.types.has(dataflow_1.EdgeType.Calls));
63
- }
64
- if (node.flavor === 'unnamed') {
65
- info.unnamedCalls++;
66
- (0, output_1.appendStatisticsFile)(exports.usedFunctions.name, 'unnamed-calls', [node.lexeme], input.filepath);
67
- allCalls.push([
68
- undefined,
69
- [node.location.start.line, node.location.start.column],
70
- node.arguments.length,
71
- '',
72
- hasCallsEdge ? 1 : 0
73
- ]);
74
- }
75
- else {
76
- allCalls.push([
77
- node.functionName.lexeme,
78
- [node.location.start.line, node.location.start.column],
79
- node.arguments.length,
80
- node.functionName.namespace ?? '',
81
- hasCallsEdge ? 1 : 0
82
- ]);
83
- }
84
- classifyArguments(node.arguments, info.args);
85
- calls.push(node);
86
- }, node => {
87
- // drop again :D
88
- if (node.type === "RFunctionCall" /* RType.FunctionCall */) {
89
- calls.pop();
90
- }
91
- });
92
- info.allFunctionCalls += allCalls.length;
93
- (0, output_1.appendStatisticsFile)(exports.usedFunctions.name, exports.AllCallsFileBase, allCalls, input.filepath);
94
- }
95
- //# sourceMappingURL=used-functions.js.map
@@ -1 +0,0 @@
1
- export { usedPackages } from './used-packages';
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.usedPackages = void 0;
4
- var used_packages_1 = require("./used-packages");
5
- Object.defineProperty(exports, "usedPackages", { enumerable: true, get: function () { return used_packages_1.usedPackages; } });
6
- //# sourceMappingURL=index.js.map
@@ -1,3 +0,0 @@
1
- import type { FeatureStatisticsWithMeta } from '../../feature';
2
- import type { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
- export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
@@ -1,121 +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.postProcess = void 0;
7
- const post_processing_1 = require("../../post-processing");
8
- const used_packages_1 = require("./used-packages");
9
- const node_fs_1 = __importDefault(require("node:fs"));
10
- const path_1 = __importDefault(require("path"));
11
- const data_1 = require("../../../../util/summarizer/benchmark/data");
12
- const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
13
- const files_1 = require("../../../../util/files");
14
- const arrays_1 = require("../../../../util/arrays");
15
- const strings_1 = require("../../../../util/strings");
16
- function postProcess(featureRoot, info, outputPath, config) {
17
- const collected = {};
18
- for (const [filepath, data] of info.entries()) {
19
- const value = data.usedPackages;
20
- for (const [key, val] of Object.entries(value)) {
21
- let get = collected[key];
22
- if (!get) {
23
- get = (0, post_processing_1.emptySummarizedWithProject)();
24
- collected[key] = get;
25
- }
26
- get.count.push(val);
27
- if (val > 0) {
28
- (0, post_processing_1.recordFilePath)(get, filepath, config);
29
- }
30
- }
31
- }
32
- const variablesOutStream = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loading-functions.csv'));
33
- variablesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
34
- for (const [key, val] of Object.entries(collected)) {
35
- const data = val;
36
- const sum = (0, process_1.summarizeMeasurement)(data.count);
37
- variablesOutStream.write(`${JSON.stringify(key)},${data.uniqueProjects.size},${data.uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)(sum)}\n`);
38
- }
39
- variablesOutStream.close();
40
- // now we want to collect the names of the loaded libraries,
41
- // we collect and store them separately (per kind) but also, we want store the summarized results in the end!
42
- const loadedLibraries = new Map();
43
- for (const key of Object.keys(used_packages_1.initialUsedPackageInfos)) {
44
- const data = retrieveDataForLoad(key, featureRoot, outputPath, config);
45
- for (const [name, val] of data.entries()) {
46
- let get = loadedLibraries.get(name);
47
- if (!get) {
48
- get = (0, post_processing_1.emptySummarizedWithProject)();
49
- loadedLibraries.set(name, get);
50
- }
51
- get.count.push(...val.count);
52
- for (const uniqueFile of val.uniqueFiles) {
53
- get.uniqueFiles.add(uniqueFile);
54
- }
55
- for (const uniqueProject of val.uniqueProjects) {
56
- get.uniqueProjects.add(uniqueProject);
57
- }
58
- }
59
- }
60
- const output = path_1.default.join(outputPath, 'all-operators.csv');
61
- const out = node_fs_1.default.createWriteStream(output);
62
- out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
63
- for (const [key, val] of loadedLibraries.entries()) {
64
- const { count, uniqueProjects, uniqueFiles } = val;
65
- const sum = (0, process_1.summarizeMeasurement)(count);
66
- out.write(`${JSON.stringify(key)},${uniqueProjects.size},${uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)(sum)}\n`);
67
- }
68
- out.close();
69
- }
70
- exports.postProcess = postProcess;
71
- // directly writes the results to the output path
72
- function retrieveDataForLoad(operator, readFromPath, outputPath, config) {
73
- const input = path_1.default.join(readFromPath, `${operator}.txt`);
74
- if (!node_fs_1.default.existsSync(input)) {
75
- // if there is nothing with this, just return :)
76
- return new Map();
77
- }
78
- const collected = new Map();
79
- (0, files_1.readLineByLineSync)(input, (line, lineNumber) => {
80
- if (line.length === 0) {
81
- return;
82
- }
83
- if (lineNumber % 2_500 === 0) {
84
- console.log(` Processing line ${lineNumber} from ${input}`);
85
- }
86
- const [packages, context] = JSON.parse(line.toString());
87
- // first we have to collect what this file gives us
88
- // we normalize surrounding quotation marks
89
- const bag = (0, arrays_1.array2bag)(packages.map(p => {
90
- if ((0, strings_1.startAndEndsWith)(p, '"') || (0, strings_1.startAndEndsWith)(p, "'") || (0, strings_1.startAndEndsWith)(p, '`')) {
91
- return p.slice(1, -1);
92
- }
93
- else {
94
- return p;
95
- }
96
- }));
97
- // now we merge it into the global map (oh gosh this is so horrible
98
- for (const [name, count] of bag.entries()) {
99
- let get = collected.get(name);
100
- if (!get) {
101
- get = (0, post_processing_1.emptySummarizedWithProject)();
102
- collected.set(name, get);
103
- }
104
- get.count.push(count);
105
- if (count > 0) {
106
- (0, post_processing_1.recordFilePath)(get, context, config);
107
- }
108
- }
109
- });
110
- const output = path_1.default.join(outputPath, `${operator}.csv`);
111
- const out = node_fs_1.default.createWriteStream(output);
112
- out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
113
- for (const [key, val] of collected.entries()) {
114
- const { count, uniqueProjects, uniqueFiles } = val;
115
- const sum = (0, process_1.summarizeMeasurement)(count);
116
- out.write(`${JSON.stringify(key)},${uniqueProjects.size},${uniqueFiles.size},${(0, data_1.summarizedMeasurement2Csv)(sum)}\n`);
117
- }
118
- out.close();
119
- return collected;
120
- }
121
- //# sourceMappingURL=post-process.js.map
@@ -1,16 +0,0 @@
1
- import type { Feature } from '../../feature';
2
- import type { Writable } from 'ts-essentials';
3
- export declare const initialUsedPackageInfos: {
4
- library: number;
5
- require: number;
6
- loadNamespace: number;
7
- requireNamespace: number;
8
- attachNamespace: number;
9
- withinApply: number;
10
- '::': number;
11
- ':::': number;
12
- /** just contains all occurrences where it is impossible to statically determine which package is loaded */
13
- '<loadedByVariable>': number;
14
- };
15
- export type UsedPackageInfo = Writable<typeof initialUsedPackageInfos>;
16
- export declare const usedPackages: Feature<UsedPackageInfo>;