@eagleoutice/flowr 1.3.14 → 1.4.2

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 (309) hide show
  1. package/README.md +3 -3
  2. package/abstract-interpretation/domain.d.ts +27 -0
  3. package/abstract-interpretation/domain.js +146 -0
  4. package/abstract-interpretation/handler/binop/binop.d.ts +16 -0
  5. package/abstract-interpretation/handler/binop/binop.js +40 -0
  6. package/abstract-interpretation/handler/binop/operators.d.ts +2 -0
  7. package/abstract-interpretation/handler/binop/operators.js +42 -0
  8. package/abstract-interpretation/handler/handler.d.ts +6 -0
  9. package/abstract-interpretation/handler/handler.js +3 -0
  10. package/abstract-interpretation/processor.d.ts +10 -0
  11. package/abstract-interpretation/processor.js +84 -0
  12. package/benchmark/slicer.d.ts +6 -8
  13. package/benchmark/slicer.js +5 -15
  14. package/benchmark/stats/print.d.ts +1 -1
  15. package/benchmark/stats/print.js +0 -2
  16. package/benchmark/stats/stats.d.ts +3 -4
  17. package/benchmark/stats/stats.js +1 -1
  18. package/cli/benchmark-app.d.ts +1 -0
  19. package/cli/benchmark-app.js +21 -6
  20. package/cli/benchmark-helper-app.d.ts +2 -0
  21. package/cli/benchmark-helper-app.js +15 -6
  22. package/cli/common/features.d.ts +1 -1
  23. package/cli/common/options.d.ts +1 -1
  24. package/cli/common/options.js +4 -1
  25. package/cli/common/script.d.ts +1 -1
  26. package/cli/common/scripts-info.d.ts +3 -2
  27. package/cli/common/scripts-info.js +15 -1
  28. package/cli/export-quads-app.js +1 -5
  29. package/cli/repl/commands/cfg.d.ts +1 -1
  30. package/cli/repl/commands/cfg.js +3 -3
  31. package/cli/repl/commands/commands.d.ts +4 -2
  32. package/cli/repl/commands/commands.js +67 -28
  33. package/cli/repl/commands/dataflow.d.ts +1 -1
  34. package/cli/repl/commands/dataflow.js +2 -2
  35. package/cli/repl/commands/execute.d.ts +2 -2
  36. package/cli/repl/commands/main.d.ts +2 -2
  37. package/cli/repl/commands/normalize.d.ts +1 -1
  38. package/cli/repl/commands/normalize.js +2 -2
  39. package/cli/repl/commands/parse.d.ts +1 -1
  40. package/cli/repl/commands/parse.js +12 -12
  41. package/cli/repl/commands/quit.d.ts +1 -1
  42. package/cli/repl/commands/quit.js +4 -1
  43. package/cli/repl/commands/version.d.ts +1 -1
  44. package/cli/repl/core.d.ts +5 -3
  45. package/cli/repl/core.js +63 -7
  46. package/cli/repl/execute.d.ts +1 -1
  47. package/cli/repl/execute.js +3 -3
  48. package/cli/repl/server/connection.d.ts +2 -2
  49. package/cli/repl/server/connection.js +4 -8
  50. package/cli/repl/server/messages/analysis.d.ts +3 -3
  51. package/cli/repl/server/messages/analysis.js +12 -32
  52. package/cli/repl/server/messages/error.d.ts +1 -1
  53. package/cli/repl/server/messages/hello.d.ts +2 -2
  54. package/cli/repl/server/messages/messages.d.ts +5 -5
  55. package/cli/repl/server/messages/repl.d.ts +1 -1
  56. package/cli/repl/server/messages/slice.d.ts +3 -3
  57. package/cli/repl/server/net.d.ts +16 -0
  58. package/cli/repl/server/net.js +42 -3
  59. package/cli/repl/server/send.d.ts +2 -2
  60. package/cli/repl/server/server.d.ts +2 -2
  61. package/cli/repl/server/validate.d.ts +3 -3
  62. package/cli/statistics-helper-app.js +2 -3
  63. package/cli/summarizer-app.js +1 -2
  64. package/config.d.ts +16 -0
  65. package/config.js +75 -0
  66. package/core/input.d.ts +5 -5
  67. package/core/output.d.ts +1 -1
  68. package/core/print/dataflow-printer.d.ts +3 -3
  69. package/core/print/normalize-printer.d.ts +2 -2
  70. package/core/print/parse-printer.d.ts +2 -3
  71. package/core/print/parse-printer.js +6 -4
  72. package/core/print/print.d.ts +1 -1
  73. package/core/print/slice-diff-ansi.d.ts +1 -1
  74. package/core/slicer.d.ts +5 -4
  75. package/core/slicer.js +2 -2
  76. package/core/steps.d.ts +10 -9
  77. package/core/steps.js +5 -4
  78. package/dataflow/environments/append.d.ts +1 -1
  79. package/dataflow/environments/environment.d.ts +4 -4
  80. package/dataflow/environments/environment.js +8 -0
  81. package/dataflow/environments/overwrite.d.ts +1 -1
  82. package/dataflow/environments/register.d.ts +2 -2
  83. package/dataflow/environments/register.js +1 -0
  84. package/dataflow/environments/resolve-by-name.d.ts +2 -2
  85. package/dataflow/environments/scoping.d.ts +1 -1
  86. package/dataflow/extractor.d.ts +5 -5
  87. package/dataflow/extractor.js +10 -2
  88. package/dataflow/graph/diff.d.ts +3 -3
  89. package/dataflow/graph/graph.d.ts +8 -7
  90. package/dataflow/graph/quads.d.ts +2 -2
  91. package/dataflow/graph/vertex.d.ts +5 -5
  92. package/dataflow/internal/info.d.ts +2 -2
  93. package/dataflow/internal/linker.d.ts +3 -3
  94. package/dataflow/internal/process/access.d.ts +3 -3
  95. package/dataflow/internal/process/expression-list.d.ts +3 -3
  96. package/dataflow/internal/process/expression-list.js +0 -4
  97. package/dataflow/internal/process/functions/argument.d.ts +4 -4
  98. package/dataflow/internal/process/functions/exit-points.d.ts +1 -1
  99. package/dataflow/internal/process/functions/function-call.d.ts +3 -3
  100. package/dataflow/internal/process/functions/function-call.js +7 -1
  101. package/dataflow/internal/process/functions/function-definition.d.ts +3 -3
  102. package/dataflow/internal/process/functions/parameter.d.ts +3 -3
  103. package/dataflow/internal/process/functions/source.d.ts +8 -0
  104. package/dataflow/internal/process/functions/source.js +81 -0
  105. package/dataflow/internal/process/if-then-else.d.ts +3 -3
  106. package/dataflow/internal/process/loops/for-loop.d.ts +3 -3
  107. package/dataflow/internal/process/loops/repeat-loop.d.ts +3 -3
  108. package/dataflow/internal/process/loops/while-loop.d.ts +3 -3
  109. package/dataflow/internal/process/operators/assignment.d.ts +3 -3
  110. package/dataflow/internal/process/operators/non-assignment-binary-op.d.ts +3 -3
  111. package/dataflow/internal/process/operators/pipe.d.ts +3 -3
  112. package/dataflow/internal/process/operators/unary-op.d.ts +3 -3
  113. package/dataflow/internal/process/symbol.d.ts +3 -3
  114. package/dataflow/internal/process/uninteresting-leaf.d.ts +2 -2
  115. package/dataflow/processor.d.ts +12 -3
  116. package/flowr.d.ts +5 -2
  117. package/flowr.js +19 -12
  118. package/package.json +50 -18
  119. package/r-bridge/lang-4.x/ast/index.d.ts +1 -0
  120. package/r-bridge/lang-4.x/ast/index.js +3 -0
  121. package/r-bridge/lang-4.x/ast/model/collect.d.ts +2 -2
  122. package/r-bridge/lang-4.x/ast/model/model.d.ts +6 -6
  123. package/r-bridge/lang-4.x/ast/model/nodes/info/index.d.ts +2 -2
  124. package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +3 -3
  125. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -3
  126. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -3
  127. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -3
  128. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -2
  129. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -2
  130. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -2
  131. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +4 -4
  132. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +4 -4
  133. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +4 -4
  134. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -3
  135. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -2
  136. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -2
  137. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -2
  138. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -3
  139. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -3
  140. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -2
  141. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -3
  142. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -3
  143. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -2
  144. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -3
  145. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -3
  146. package/r-bridge/lang-4.x/ast/model/operators.d.ts +1 -1
  147. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +4 -2
  148. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +6 -1
  149. package/r-bridge/lang-4.x/ast/model/processing/fold.d.ts +3 -3
  150. package/r-bridge/lang-4.x/ast/model/processing/role.d.ts +1 -1
  151. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +3 -3
  152. package/r-bridge/lang-4.x/ast/model/processing/visitor.d.ts +1 -1
  153. package/r-bridge/lang-4.x/ast/parser/json/format.d.ts +14 -0
  154. package/r-bridge/lang-4.x/ast/parser/json/format.js +26 -0
  155. package/r-bridge/lang-4.x/ast/parser/json/parser.d.ts +7 -0
  156. package/r-bridge/lang-4.x/ast/parser/json/parser.js +57 -0
  157. package/r-bridge/lang-4.x/ast/parser/xml/data.d.ts +4 -7
  158. package/r-bridge/lang-4.x/ast/parser/xml/hooks.d.ts +5 -5
  159. package/r-bridge/lang-4.x/ast/parser/xml/index.d.ts +0 -2
  160. package/r-bridge/lang-4.x/ast/parser/xml/index.js +0 -2
  161. package/r-bridge/lang-4.x/ast/parser/xml/input-format.d.ts +6 -2
  162. package/r-bridge/lang-4.x/ast/parser/xml/input-format.js +7 -10
  163. package/r-bridge/lang-4.x/ast/parser/xml/internal/access.d.ts +3 -3
  164. package/r-bridge/lang-4.x/ast/parser/xml/internal/access.js +2 -2
  165. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.d.ts +3 -3
  166. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then-else.js +1 -1
  167. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.d.ts +3 -3
  168. package/r-bridge/lang-4.x/ast/parser/xml/internal/control/if-then.js +2 -2
  169. package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.d.ts +3 -3
  170. package/r-bridge/lang-4.x/ast/parser/xml/internal/expression/expression.js +4 -4
  171. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.d.ts +3 -3
  172. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.js +2 -2
  173. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.d.ts +3 -3
  174. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/call.js +4 -4
  175. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.d.ts +3 -3
  176. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/definition.js +2 -2
  177. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.d.ts +3 -3
  178. package/r-bridge/lang-4.x/ast/parser/xml/internal/functions/parameter.js +2 -2
  179. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.d.ts +0 -1
  180. package/r-bridge/lang-4.x/ast/parser/xml/internal/index.js +0 -1
  181. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.d.ts +3 -3
  182. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/break.js +2 -2
  183. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.d.ts +3 -3
  184. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/for.js +3 -6
  185. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.d.ts +3 -3
  186. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/next.js +2 -2
  187. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.d.ts +3 -3
  188. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/repeat.js +2 -2
  189. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.d.ts +3 -3
  190. package/r-bridge/lang-4.x/ast/parser/xml/internal/loops/while.js +2 -2
  191. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.d.ts +9 -14
  192. package/r-bridge/lang-4.x/ast/parser/xml/internal/meta.js +15 -23
  193. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.d.ts +3 -3
  194. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/binary.js +6 -6
  195. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/special.d.ts +1 -1
  196. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.d.ts +3 -3
  197. package/r-bridge/lang-4.x/ast/parser/xml/internal/operators/unary.js +3 -3
  198. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.d.ts +3 -3
  199. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/comment.js +2 -2
  200. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.d.ts +3 -3
  201. package/r-bridge/lang-4.x/ast/parser/xml/internal/other/line-directive.js +2 -2
  202. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.d.ts +4 -4
  203. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/elements.js +3 -3
  204. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.d.ts +3 -3
  205. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/root.js +3 -4
  206. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.d.ts +4 -4
  207. package/r-bridge/lang-4.x/ast/parser/xml/internal/structure/single-element.js +2 -2
  208. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.d.ts +4 -4
  209. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/number.js +2 -2
  210. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.d.ts +3 -3
  211. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/string.js +2 -2
  212. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.d.ts +3 -3
  213. package/r-bridge/lang-4.x/ast/parser/xml/internal/values/symbol.js +4 -4
  214. package/r-bridge/lang-4.x/values.d.ts +0 -1
  215. package/r-bridge/lang-4.x/values.js +14 -6
  216. package/r-bridge/retriever.d.ts +26 -22
  217. package/r-bridge/retriever.js +73 -23
  218. package/r-bridge/shell-executor.d.ts +11 -0
  219. package/r-bridge/shell-executor.js +50 -0
  220. package/r-bridge/shell.d.ts +12 -31
  221. package/r-bridge/shell.js +36 -94
  222. package/reconstruct/reconstruct.d.ts +1 -1
  223. package/slicing/criterion/collect-all.d.ts +3 -3
  224. package/slicing/criterion/filters/all-variables.d.ts +1 -1
  225. package/slicing/criterion/parse.d.ts +1 -1
  226. package/slicing/static/static-slicer.d.ts +3 -3
  227. package/statistics/features/common-syntax-probability.d.ts +3 -2
  228. package/statistics/features/common-syntax-probability.js +0 -3
  229. package/statistics/features/feature.d.ts +6 -6
  230. package/statistics/features/post-processing.d.ts +2 -2
  231. package/statistics/features/supported/assignments/assignments.d.ts +2 -2
  232. package/statistics/features/supported/assignments/post-process.d.ts +2 -2
  233. package/statistics/features/supported/assignments/post-process.js +6 -6
  234. package/statistics/features/supported/comments/comments.d.ts +2 -2
  235. package/statistics/features/supported/comments/post-process.d.ts +2 -2
  236. package/statistics/features/supported/comments/post-process.js +2 -2
  237. package/statistics/features/supported/control-flow/control-flow.d.ts +2 -2
  238. package/statistics/features/supported/control-flow/post-process.d.ts +2 -2
  239. package/statistics/features/supported/data-access/data-access.d.ts +3 -3
  240. package/statistics/features/supported/data-access/post-process.d.ts +2 -2
  241. package/statistics/features/supported/data-access/post-process.js +4 -4
  242. package/statistics/features/supported/defined-functions/defined-functions.d.ts +4 -4
  243. package/statistics/features/supported/defined-functions/post-process.d.ts +2 -2
  244. package/statistics/features/supported/defined-functions/post-process.js +4 -4
  245. package/statistics/features/supported/expression-list/expression-list.d.ts +2 -2
  246. package/statistics/features/supported/expression-list/post-process.d.ts +2 -2
  247. package/statistics/features/supported/expression-list/post-process.js +3 -3
  248. package/statistics/features/supported/loops/loops.d.ts +2 -2
  249. package/statistics/features/supported/loops/post-process.d.ts +2 -2
  250. package/statistics/features/supported/loops/post-process.js +3 -3
  251. package/statistics/features/supported/used-functions/post-process.d.ts +2 -2
  252. package/statistics/features/supported/used-functions/post-process.js +5 -5
  253. package/statistics/features/supported/used-functions/used-functions.d.ts +3 -3
  254. package/statistics/features/supported/used-packages/post-process.d.ts +2 -2
  255. package/statistics/features/supported/used-packages/post-process.js +5 -5
  256. package/statistics/features/supported/used-packages/used-packages.d.ts +2 -2
  257. package/statistics/features/supported/values/post-process.d.ts +2 -2
  258. package/statistics/features/supported/values/post-process.js +3 -3
  259. package/statistics/features/supported/values/values.d.ts +2 -2
  260. package/statistics/features/supported/variables/post-process.d.ts +3 -3
  261. package/statistics/features/supported/variables/post-process.js +3 -3
  262. package/statistics/features/supported/variables/variables.d.ts +2 -2
  263. package/statistics/meta-statistics.d.ts +1 -1
  264. package/statistics/output/ansi.js +1 -1
  265. package/statistics/output/print-stats.d.ts +2 -2
  266. package/statistics/output/statistics-file.d.ts +1 -1
  267. package/statistics/statistics.d.ts +4 -4
  268. package/statistics/statistics.js +7 -8
  269. package/util/args.d.ts +8 -4
  270. package/util/args.js +11 -4
  271. package/util/{cfg.d.ts → cfg/cfg.d.ts} +18 -6
  272. package/util/{cfg.js → cfg/cfg.js} +42 -37
  273. package/util/cfg/visitor.d.ts +14 -0
  274. package/util/cfg/visitor.js +64 -0
  275. package/util/diff.d.ts +1 -1
  276. package/util/files.d.ts +7 -1
  277. package/util/files.js +11 -1
  278. package/util/log.js +3 -0
  279. package/util/mermaid/ast.d.ts +1 -1
  280. package/util/mermaid/cfg.d.ts +2 -2
  281. package/util/mermaid/dfg.d.ts +3 -3
  282. package/util/objects.d.ts +1 -1
  283. package/util/quads.d.ts +2 -2
  284. package/util/summarizer/benchmark/data.d.ts +1 -1
  285. package/util/summarizer/benchmark/first-phase/input.d.ts +2 -1
  286. package/util/summarizer/benchmark/first-phase/input.js +20 -4
  287. package/util/summarizer/benchmark/first-phase/process.d.ts +4 -3
  288. package/util/summarizer/benchmark/first-phase/process.js +14 -5
  289. package/util/summarizer/benchmark/second-phase/graph.d.ts +1 -1
  290. package/util/summarizer/benchmark/second-phase/graph.js +1 -1
  291. package/util/summarizer/benchmark/second-phase/process.d.ts +3 -1
  292. package/util/summarizer/benchmark/second-phase/process.js +48 -11
  293. package/util/summarizer/benchmark/summarizer.d.ts +3 -6
  294. package/util/summarizer/benchmark/summarizer.js +16 -11
  295. package/util/summarizer/statistics/first-phase/process.js +8 -8
  296. package/util/summarizer/statistics/post-process/clusterer.d.ts +2 -2
  297. package/util/summarizer/statistics/post-process/file-based-count.d.ts +1 -1
  298. package/util/summarizer/statistics/post-process/histogram.d.ts +2 -2
  299. package/util/summarizer/statistics/post-process/post-process-output.d.ts +2 -2
  300. package/util/summarizer/statistics/post-process/post-process-output.js +4 -5
  301. package/util/summarizer/statistics/second-phase/process.d.ts +2 -2
  302. package/util/summarizer/statistics/summarizer.d.ts +3 -2
  303. package/util/summarizer/summarizer.d.ts +1 -1
  304. package/r-bridge/lang-4.x/ast/parser/xml/config.d.ts +0 -25
  305. package/r-bridge/lang-4.x/ast/parser/xml/config.js +0 -16
  306. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.d.ts +0 -9
  307. package/r-bridge/lang-4.x/ast/parser/xml/internal/xml-to-json.js +0 -51
  308. package/r-bridge/lang-4.x/ast/parser/xml/parser.d.ts +0 -17
  309. package/r-bridge/lang-4.x/ast/parser/xml/parser.js +0 -30
@@ -1,5 +1,5 @@
1
- import { FeatureStatisticsWithMeta } from '../../feature';
2
- import { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
1
+ import type { FeatureStatisticsWithMeta } from '../../feature';
2
+ import type { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
3
  /**
4
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
5
  */
@@ -9,7 +9,7 @@ const common_syntax_probability_1 = require("../../common-syntax-probability");
9
9
  const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
10
10
  const files_1 = require("../../../../util/files");
11
11
  const path_1 = __importDefault(require("path"));
12
- const node_fs_1 = __importDefault(require("node:fs"));
12
+ const fs_1 = __importDefault(require("fs"));
13
13
  const time_1 = require("../../../../util/time");
14
14
  const used_functions_1 = require("./used-functions");
15
15
  const numbers_1 = require("../../../../util/numbers");
@@ -33,7 +33,7 @@ function retrieveFunctionCallInformation(featureRoot, info, config, outputPath)
33
33
  'assign',
34
34
  'get',
35
35
  'setGeneric',
36
- 'R6Class'].map(name => [name, node_fs_1.default.createWriteStream(path_1.default.join(outputPath, `${name}.csv`))]));
36
+ 'R6Class'].map(name => [name, fs_1.default.createWriteStream(path_1.default.join(outputPath, `${name}.csv`))]));
37
37
  for (const [, value] of importantFunctions) {
38
38
  value.write('filepath,location,namespace,inspected by,classification,notes\n');
39
39
  }
@@ -44,7 +44,7 @@ function retrieveFunctionCallInformation(featureRoot, info, config, outputPath)
44
44
  }
45
45
  importantFunctions.clear();
46
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'));
47
+ const fnOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls.csv'));
48
48
  const prefixes = ['total', 'args', 'line-frac'];
49
49
  const others = prefixes.flatMap(data_1.summarizedMeasurement2CsvHeader).join(',');
50
50
  fnOutStream.write(`function,unique-projects,unique-files,${others}\n`);
@@ -58,7 +58,7 @@ function retrieveFunctionCallInformation(featureRoot, info, config, outputPath)
58
58
  fnOutStream.close();
59
59
  }
60
60
  function writeFunctionCallsMetaInformationToCsv(outputPath, data) {
61
- const out = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls-meta.csv'));
61
+ const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'function-calls-meta.csv'));
62
62
  out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
63
63
  out.write(`average-call,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.averageCall.flat()))}\n`);
64
64
  out.write(`nested-calls,${(0, data_1.summarizedMeasurement2Csv)((0, process_1.summarizeMeasurement)(data.nestedCalls.flat()))}\n`);
@@ -102,7 +102,7 @@ function retrieveFunctionCallMetaInformation(info, outputPath) {
102
102
  // we treat the first/0-argument entry separate for legacy reasons
103
103
  continue;
104
104
  }
105
- const out = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, `function-calls-arg-${index}.csv`));
105
+ const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, `function-calls-arg-${index}.csv`));
106
106
  out.write(`kind,name,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
107
107
  for (const [name, vals] of Object.entries(arg)) {
108
108
  if (Array.isArray(vals)) {
@@ -1,6 +1,6 @@
1
- import { Feature } from '../../feature';
2
- import { Writable } from 'ts-essentials';
3
- import { CommonSyntaxTypeCounts } from '../../common-syntax-probability';
1
+ import type { Feature } from '../../feature';
2
+ import type { Writable } from 'ts-essentials';
3
+ import type { CommonSyntaxTypeCounts } from '../../common-syntax-probability';
4
4
  declare const initialFunctionUsageInfo: {
5
5
  allFunctionCalls: number;
6
6
  args: Record<number, bigint | CommonSyntaxTypeCounts<bigint>>;
@@ -1,3 +1,3 @@
1
- import { FeatureStatisticsWithMeta } from '../../feature';
2
- import { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
1
+ import type { FeatureStatisticsWithMeta } from '../../feature';
2
+ import type { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
3
  export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.postProcess = void 0;
7
7
  const post_processing_1 = require("../../post-processing");
8
8
  const used_packages_1 = require("./used-packages");
9
- const node_fs_1 = __importDefault(require("node:fs"));
9
+ const fs_1 = __importDefault(require("fs"));
10
10
  const path_1 = __importDefault(require("path"));
11
11
  const data_1 = require("../../../../util/summarizer/benchmark/data");
12
12
  const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
@@ -29,7 +29,7 @@ function postProcess(featureRoot, info, outputPath, config) {
29
29
  }
30
30
  }
31
31
  }
32
- const variablesOutStream = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loading-functions.csv'));
32
+ const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'loading-functions.csv'));
33
33
  variablesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
34
34
  for (const [key, val] of Object.entries(collected)) {
35
35
  const data = val;
@@ -58,7 +58,7 @@ function postProcess(featureRoot, info, outputPath, config) {
58
58
  }
59
59
  }
60
60
  const output = path_1.default.join(outputPath, 'all-operators.csv');
61
- const out = node_fs_1.default.createWriteStream(output);
61
+ const out = fs_1.default.createWriteStream(output);
62
62
  out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
63
63
  for (const [key, val] of loadedLibraries.entries()) {
64
64
  const { count, uniqueProjects, uniqueFiles } = val;
@@ -71,7 +71,7 @@ exports.postProcess = postProcess;
71
71
  // directly writes the results to the output path
72
72
  function retrieveDataForLoad(operator, readFromPath, outputPath, config) {
73
73
  const input = path_1.default.join(readFromPath, `${operator}.txt`);
74
- if (!node_fs_1.default.existsSync(input)) {
74
+ if (!fs_1.default.existsSync(input)) {
75
75
  // if there is nothing with this, just return :)
76
76
  return new Map();
77
77
  }
@@ -108,7 +108,7 @@ function retrieveDataForLoad(operator, readFromPath, outputPath, config) {
108
108
  }
109
109
  });
110
110
  const output = path_1.default.join(outputPath, `${operator}.csv`);
111
- const out = node_fs_1.default.createWriteStream(output);
111
+ const out = fs_1.default.createWriteStream(output);
112
112
  out.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
113
113
  for (const [key, val] of collected.entries()) {
114
114
  const { count, uniqueProjects, uniqueFiles } = val;
@@ -1,5 +1,5 @@
1
- import { Feature } from '../../feature';
2
- import { Writable } from 'ts-essentials';
1
+ import type { Feature } from '../../feature';
2
+ import type { Writable } from 'ts-essentials';
3
3
  export declare const initialUsedPackageInfos: {
4
4
  library: number;
5
5
  require: number;
@@ -1,3 +1,3 @@
1
- import { FeatureStatisticsWithMeta } from '../../feature';
2
- import { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
1
+ import type { FeatureStatisticsWithMeta } from '../../feature';
2
+ import type { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
3
  export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.postProcess = void 0;
7
7
  const data_1 = require("../../../../util/summarizer/benchmark/data");
8
- const node_fs_1 = __importDefault(require("node:fs"));
8
+ const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
11
11
  const files_1 = require("../../../../util/files");
@@ -28,7 +28,7 @@ function postProcess(featureRoot, info, outputPath, config) {
28
28
  }
29
29
  }
30
30
  }
31
- const valuesOutStream = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'values.csv'));
31
+ const valuesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'values.csv'));
32
32
  valuesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
33
33
  for (const [key, val] of Object.entries(collected)) {
34
34
  const data = val;
@@ -60,7 +60,7 @@ function postProcess(featureRoot, info, outputPath, config) {
60
60
  }
61
61
  }
62
62
  });
63
- const magicNumbersOutStream = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'magic-numbers.csv'));
63
+ const magicNumbersOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'magic-numbers.csv'));
64
64
  magicNumbersOutStream.write(`num,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
65
65
  for (const [key, val] of valueMap.entries()) {
66
66
  const sum = (0, process_1.summarizeMeasurement)(val.count);
@@ -1,5 +1,5 @@
1
- import { Feature } from '../../feature';
2
- import { Writable } from 'ts-essentials';
1
+ import type { Feature } from '../../feature';
2
+ import type { Writable } from 'ts-essentials';
3
3
  declare const initialValueInfo: {
4
4
  allNumerics: number;
5
5
  imaginaryNumbers: number;
@@ -1,6 +1,6 @@
1
- import { FeatureStatisticsWithMeta } from '../../feature';
2
- import { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
- import { SummarizedWithProject } from '../../post-processing';
1
+ import type { FeatureStatisticsWithMeta } from '../../feature';
2
+ import type { StatisticsSummarizerConfiguration } from '../../../../util/summarizer/statistics/summarizer';
3
+ import type { SummarizedWithProject } from '../../post-processing';
4
4
  export declare function postProcess(featureRoot: string, info: Map<string, FeatureStatisticsWithMeta>, outputPath: string, config: StatisticsSummarizerConfiguration): void;
5
5
  type VariableInfoMap = Map<string, SummarizedWithProject & {
6
6
  linePercentageInFile: number[][];
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.writeVariableInfoToCsv = exports.postProcess = void 0;
7
7
  const post_processing_1 = require("../../post-processing");
8
- const node_fs_1 = __importDefault(require("node:fs"));
8
+ const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const data_1 = require("../../../../util/summarizer/benchmark/data");
11
11
  const process_1 = require("../../../../util/summarizer/benchmark/first-phase/process");
@@ -27,7 +27,7 @@ function collectRedefinedVariables(featureRoot, info, config, outputPath) {
27
27
  redefined.clear();
28
28
  }
29
29
  function writeVariableCountsToCsv(outputPath, collected) {
30
- const variablesOutStream = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, 'variable-counts.csv'));
30
+ const variablesOutStream = fs_1.default.createWriteStream(path_1.default.join(outputPath, 'variable-counts.csv'));
31
31
  variablesOutStream.write(`kind,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)()}\n`);
32
32
  for (const [key, val] of Object.entries(collected)) {
33
33
  if (key === 'unknownVariables') {
@@ -67,7 +67,7 @@ function postProcess(featureRoot, info, outputPath, config) {
67
67
  }
68
68
  exports.postProcess = postProcess;
69
69
  function writeVariableInfoToCsv(outputPath, filename, data) {
70
- const out = node_fs_1.default.createWriteStream(path_1.default.join(outputPath, filename));
70
+ const out = fs_1.default.createWriteStream(path_1.default.join(outputPath, filename));
71
71
  out.write(`variable,unique-projects,unique-files,${(0, data_1.summarizedMeasurement2CsvHeader)('count')},${(0, data_1.summarizedMeasurement2CsvHeader)('line-frac')}\n`);
72
72
  for (const [key, val] of data.entries()) {
73
73
  const { count, uniqueProjects, uniqueFiles, linePercentageInFile } = val;
@@ -1,5 +1,5 @@
1
- import { Feature } from '../../feature';
2
- import { Writable } from 'ts-essentials';
1
+ import type { Feature } from '../../feature';
2
+ import type { Writable } from 'ts-essentials';
3
3
  declare const initialVariableInfo: {
4
4
  numberOfVariableUses: number;
5
5
  numberOfDefinitions: number;
@@ -1,4 +1,4 @@
1
- import { RParseRequestFromFile, RParseRequestFromText } from '../r-bridge';
1
+ import type { RParseRequestFromFile, RParseRequestFromText } from '../r-bridge';
2
2
  /**
3
3
  * Statistics on skipped files, the time required, and more.
4
4
  *
@@ -17,7 +17,7 @@ exports.voidFormatter = new class {
17
17
  reset() {
18
18
  return '';
19
19
  }
20
- };
20
+ }();
21
21
  /**
22
22
  * This does not work if the {@link setFormatter | formatter} is void. Tries to format the text with a bold font weight.
23
23
  */
@@ -1,5 +1,5 @@
1
- import { FeatureKey, FeatureStatistics } from '../features';
2
- import { MetaStatistics } from '../meta-statistics';
1
+ import type { FeatureKey, FeatureStatistics } from '../features';
2
+ import type { MetaStatistics } from '../meta-statistics';
3
3
  interface MinMaxAvgMedian {
4
4
  sum: number;
5
5
  min: number;
@@ -1,4 +1,4 @@
1
- import { DummyAppendMemoryMap, StatisticAppendProvider } from './file-provider';
1
+ import type { DummyAppendMemoryMap, StatisticAppendProvider } from './file-provider';
2
2
  /**
3
3
  * Requires source information to be attached on parsing!
4
4
  * <p>
@@ -1,7 +1,7 @@
1
- import { RParseRequestFromFile, RParseRequestFromText, RShell } from '../r-bridge';
2
- import { FeatureSelection, FeatureStatistics } from './features';
3
- import { MetaStatistics } from './meta-statistics';
4
- import { StepResults } from '../core';
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
5
  /**
6
6
  * By default, {@link extractUsageStatistics} requires a generator, but sometimes you already know all the files
7
7
  * that you want to process. This function simply reps your requests as a generator.
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.extractUsageStatistics = exports.staticRequests = void 0;
7
+ const r_bridge_1 = require("../r-bridge");
7
8
  const features_1 = require("./features");
8
9
  const xmldom_1 = require("@xmldom/xmldom");
9
10
  const fs_1 = __importDefault(require("fs"));
@@ -37,7 +38,6 @@ exports.staticRequests = staticRequests;
37
38
  async function extractUsageStatistics(shell, onRequest, features, requests, rootPath) {
38
39
  let result = initializeFeatureStatistics();
39
40
  const meta = (0, meta_statistics_1.initialMetaStatistics)();
40
- let first = true;
41
41
  const outputs = new Map();
42
42
  for await (const request of requests) {
43
43
  onRequest(request);
@@ -45,14 +45,10 @@ async function extractUsageStatistics(shell, onRequest, features, requests, root
45
45
  const suffix = request.request === 'file' ? request.content.replace(new RegExp('^' + (rootPath ?? '')), '') : undefined;
46
46
  try {
47
47
  let output;
48
- ({ stats: result, output } = await extractSingle(result, shell, {
49
- ...request,
50
- ensurePackageInstalled: first
51
- }, features, suffix));
48
+ ({ stats: result, output } = await extractSingle(result, shell, request, features, suffix));
52
49
  outputs.set(request, output);
53
50
  processMetaOnSuccessful(meta, request);
54
51
  meta.numberOfNormalizedNodes.push(output.normalize.idMap.size);
55
- first = false;
56
52
  }
57
53
  catch (e) {
58
54
  log_1.log.error('for request: ', request, e);
@@ -89,8 +85,11 @@ async function extractSingle(result, shell, request, features, suffixFilePath) {
89
85
  stepOfInterest: 'dataflow',
90
86
  request, shell
91
87
  }).allRemainingSteps();
92
- // await retrieveXmlFromRCode(from, shell)
93
- const doc = parser.parseFromString(slicerOutput.parse, 'text/xml');
88
+ // retrieve parsed xml through (legacy) xmlparsedata
89
+ const suffix = request.request === 'file' ? ', encoding="utf-8"' : '';
90
+ shell.sendCommands(`try(flowr_parsed<-parse(${request.request}=${JSON.stringify(request.content)},keep.source=TRUE${suffix}),silent=FALSE)`, 'try(flowr_output<-xmlparsedata::xml_parse_data(flowr_parsed,includeText=TRUE,pretty=FALSE),silent=FALSE)');
91
+ const parsed = (await shell.sendCommandWithOutput(`cat(flowr_output,${(0, r_bridge_1.ts2r)(shell.options.eol)})`)).join(shell.options.eol);
92
+ const doc = parser.parseFromString(parsed, 'text/xml');
94
93
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
94
  for (const [key, feature] of Object.entries(features_1.ALL_FEATURES)) {
96
95
  if (features !== 'all' && !features.has(key)) {
package/util/args.d.ts CHANGED
@@ -4,11 +4,15 @@
4
4
  * @module
5
5
  */
6
6
  /**
7
- * This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
7
+ * This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
8
8
  *
9
- * Given an input string like `a "b c" d` with a space character as split this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
9
+ * Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
10
+ * this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
11
+ *
12
+ * When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
10
13
  *
11
14
  * @param inputString - The string to split
12
- * @param split - The **single** character to split on (can not be the backslash or quote)
15
+ * @param escapeQuote - Keep quotes in args
16
+ * @param split - The **single** character to split on (can not be backslash or quote)
13
17
  */
14
- export declare function splitAtEscapeSensitive(inputString: string, split?: string): string[];
18
+ export declare function splitAtEscapeSensitive(inputString: string, escapeQuote?: boolean, split?: string): string[];
package/util/args.js CHANGED
@@ -7,14 +7,18 @@
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.splitAtEscapeSensitive = void 0;
9
9
  /**
10
- * This splits an input string on the given split string (e.g., ` `) but checks if the string is quoted or escaped.
10
+ * This splits an input string on the given split string (e.g., ` `), but checks if the string is quoted or escaped.
11
11
  *
12
- * Given an input string like `a "b c" d` with a space character as split this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
12
+ * Given an input string like `a "b c" d`, with a space character as split, and escapeQuote set to true,
13
+ * this splits the arguments similar to common shell interpreters (i.e., `a`, `b c`, and `d`).
14
+ *
15
+ * When escapeQuote is set to false instead, we keep quotation marks in the result (i.e., `a`, `"b c"`, and `d`.).
13
16
  *
14
17
  * @param inputString - The string to split
15
- * @param split - The **single** character to split on (can not be the backslash or quote)
18
+ * @param escapeQuote - Keep quotes in args
19
+ * @param split - The **single** character to split on (can not be backslash or quote)
16
20
  */
17
- function splitAtEscapeSensitive(inputString, split = ' ') {
21
+ function splitAtEscapeSensitive(inputString, escapeQuote = true, split = ' ') {
18
22
  const args = [];
19
23
  let current = '';
20
24
  let inQuotes = false;
@@ -50,6 +54,9 @@ function splitAtEscapeSensitive(inputString, split = ' ') {
50
54
  }
51
55
  else if (c === '"' || c === "'") {
52
56
  inQuotes = !inQuotes;
57
+ if (!escapeQuote) {
58
+ current += c;
59
+ }
53
60
  }
54
61
  else if (c === '\\') {
55
62
  escaped = true;
@@ -1,8 +1,20 @@
1
- import { NodeId, NormalizedAst, ParentInformation, RFalse, RTrue } from '../r-bridge';
2
- import { MergeableRecord } from './objects';
3
- import { QuadSerializationConfiguration } from './quads';
1
+ import type { NodeId, NormalizedAst, ParentInformation } from '../../r-bridge';
2
+ import { RFalse, RTrue } from '../../r-bridge';
3
+ import type { MergeableRecord } from '../objects';
4
+ import type { QuadSerializationConfiguration } from '../quads';
5
+ export declare const enum CfgVertexType {
6
+ /** Marks a break point in a construct (e.g., between the name and the value of an argument, or the formals and the body of a function) */
7
+ MidMarker = "mid-marker",
8
+ /** The explicit exit-nodes to ensure the hammock property */
9
+ EndMarker = "end-marker",
10
+ /** something like an if, assignment, ... even though in the classical sense of R they are still expressions */
11
+ Statement = "statement",
12
+ /** something like an addition, ... */
13
+ Expression = "expression"
14
+ }
4
15
  export interface CfgVertex {
5
16
  id: NodeId;
17
+ type: CfgVertexType;
6
18
  name: string;
7
19
  /** in case of a function definition */
8
20
  children?: NodeId[];
@@ -14,7 +26,7 @@ interface CfgControlDependencyEdge extends MergeableRecord {
14
26
  label: 'CD';
15
27
  when: typeof RTrue | typeof RFalse;
16
28
  }
17
- export type CFGEdge = CfgFlowDependencyEdge | CfgControlDependencyEdge;
29
+ export type CfgEdge = CfgFlowDependencyEdge | CfgControlDependencyEdge;
18
30
  /**
19
31
  * This class represents the control flow graph of an R program.
20
32
  * The control flow may be hierarchical when confronted with function definitions (see {@link CfgVertex} and {@link CFG#rootVertexIds|rootVertexIds()}).
@@ -24,10 +36,10 @@ export declare class ControlFlowGraph {
24
36
  private vertexInformation;
25
37
  private edgeInformation;
26
38
  addVertex(vertex: CfgVertex, rootVertex?: boolean): this;
27
- addEdge(from: NodeId, to: NodeId, edge: CFGEdge): this;
39
+ addEdge(from: NodeId, to: NodeId, edge: CfgEdge): this;
28
40
  rootVertexIds(): ReadonlySet<NodeId>;
29
41
  vertices(): ReadonlyMap<NodeId, CfgVertex>;
30
- edges(): ReadonlyMap<NodeId, ReadonlyMap<NodeId, CFGEdge>>;
42
+ edges(): ReadonlyMap<NodeId, ReadonlyMap<NodeId, CfgEdge>>;
31
43
  merge(other: ControlFlowGraph, forceNested?: boolean): this;
32
44
  }
33
45
  export interface ControlFlowInformation extends MergeableRecord {
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cfg2quads = exports.equalCfg = exports.extractCFG = exports.emptyControlFlowInformation = exports.ControlFlowGraph = void 0;
4
- const r_bridge_1 = require("../r-bridge");
5
- const set_1 = require("./set");
6
- const quads_1 = require("./quads");
7
- const log_1 = require("./log");
8
- const json_1 = require("./json");
4
+ const r_bridge_1 = require("../../r-bridge");
5
+ const set_1 = require("../set");
6
+ const quads_1 = require("../quads");
7
+ const log_1 = require("../log");
8
+ const json_1 = require("../json");
9
9
  /**
10
10
  * This class represents the control flow graph of an R program.
11
11
  * The control flow may be hierarchical when confronted with function definitions (see {@link CfgVertex} and {@link CFG#rootVertexIds|rootVertexIds()}).
@@ -65,10 +65,10 @@ function emptyControlFlowInformation() {
65
65
  }
66
66
  exports.emptyControlFlowInformation = emptyControlFlowInformation;
67
67
  const cfgFolds = {
68
- foldNumber: cfgLeaf,
69
- foldString: cfgLeaf,
70
- foldLogical: cfgLeaf,
71
- foldSymbol: cfgLeaf,
68
+ foldNumber: cfgLeaf("expression" /* CfgVertexType.Expression */),
69
+ foldString: cfgLeaf("expression" /* CfgVertexType.Expression */),
70
+ foldLogical: cfgLeaf("expression" /* CfgVertexType.Expression */),
71
+ foldSymbol: cfgLeaf("expression" /* CfgVertexType.Expression */),
72
72
  foldAccess: cfgAccess,
73
73
  binaryOp: {
74
74
  foldLogicalOp: cfgBinaryOp,
@@ -107,24 +107,29 @@ function extractCFG(ast) {
107
107
  return (0, r_bridge_1.foldAst)(ast.ast, cfgFolds);
108
108
  }
109
109
  exports.extractCFG = extractCFG;
110
- function cfgLeaf(leaf) {
111
- const graph = new ControlFlowGraph();
112
- graph.addVertex({ id: leaf.info.id, name: leaf.type });
113
- return { graph, breaks: [], nexts: [], returns: [], exitPoints: [leaf.info.id], entryPoints: [leaf.info.id] };
110
+ function cfgLeaf(type) {
111
+ return (leaf) => {
112
+ const graph = new ControlFlowGraph();
113
+ graph.addVertex({ id: leaf.info.id, name: leaf.type, type });
114
+ return { graph, breaks: [], nexts: [], returns: [], exitPoints: [leaf.info.id], entryPoints: [leaf.info.id] };
115
+ };
114
116
  }
115
117
  function cfgBreak(leaf) {
116
- return { ...cfgLeaf(leaf), breaks: [leaf.info.id] };
118
+ return { ...cfgLeaf("statement" /* CfgVertexType.Statement */)(leaf), breaks: [leaf.info.id] };
117
119
  }
118
120
  function cfgNext(leaf) {
119
- return { ...cfgLeaf(leaf), nexts: [leaf.info.id] };
121
+ return { ...cfgLeaf("statement" /* CfgVertexType.Statement */)(leaf), nexts: [leaf.info.id] };
120
122
  }
121
123
  function cfgIgnore(_leaf) {
122
124
  return { graph: new ControlFlowGraph(), breaks: [], nexts: [], returns: [], exitPoints: [], entryPoints: [] };
123
125
  }
126
+ function identifyMayStatementType(node) {
127
+ return node.info.role === "expr-list-child" /* RoleInParent.ExpressionListChild */ ? "statement" /* CfgVertexType.Statement */ : "expression" /* CfgVertexType.Expression */;
128
+ }
124
129
  function cfgIfThenElse(ifNode, condition, then, otherwise) {
125
130
  const graph = new ControlFlowGraph();
126
- graph.addVertex({ id: ifNode.info.id, name: ifNode.type });
127
- graph.addVertex({ id: ifNode.info.id + '-exit', name: 'if-exit' });
131
+ graph.addVertex({ id: ifNode.info.id, name: ifNode.type, type: identifyMayStatementType(ifNode) });
132
+ graph.addVertex({ id: ifNode.info.id + '-exit', name: 'if-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
128
133
  graph.merge(condition.graph);
129
134
  graph.merge(then.graph);
130
135
  if (otherwise) {
@@ -160,8 +165,8 @@ function cfgIfThenElse(ifNode, condition, then, otherwise) {
160
165
  }
161
166
  function cfgRepeat(repeat, body) {
162
167
  const graph = body.graph;
163
- graph.addVertex({ id: repeat.info.id, name: repeat.type });
164
- graph.addVertex({ id: repeat.info.id + '-exit', name: 'repeat-exit' });
168
+ graph.addVertex({ id: repeat.info.id, name: repeat.type, type: identifyMayStatementType(repeat) });
169
+ graph.addVertex({ id: repeat.info.id + '-exit', name: 'repeat-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
165
170
  for (const entryPoint of body.entryPoints) {
166
171
  graph.addEdge(repeat.info.id, entryPoint, { label: 'FD' });
167
172
  }
@@ -176,8 +181,8 @@ function cfgRepeat(repeat, body) {
176
181
  }
177
182
  function cfgWhile(whileLoop, condition, body) {
178
183
  const graph = condition.graph;
179
- graph.addVertex({ id: whileLoop.info.id, name: whileLoop.type });
180
- graph.addVertex({ id: whileLoop.info.id + '-exit', name: 'while-exit' });
184
+ graph.addVertex({ id: whileLoop.info.id, name: whileLoop.type, type: identifyMayStatementType(whileLoop) });
185
+ graph.addVertex({ id: whileLoop.info.id + '-exit', name: 'while-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
181
186
  graph.merge(body.graph);
182
187
  for (const entry of condition.entryPoints) {
183
188
  graph.addEdge(entry, whileLoop.info.id, { label: 'FD' });
@@ -204,8 +209,8 @@ function cfgWhile(whileLoop, condition, body) {
204
209
  }
205
210
  function cfgFor(forLoop, variable, vector, body) {
206
211
  const graph = variable.graph;
207
- graph.addVertex({ id: forLoop.info.id, name: forLoop.type });
208
- graph.addVertex({ id: forLoop.info.id + '-exit', name: 'for-exit' });
212
+ graph.addVertex({ id: forLoop.info.id, name: forLoop.type, type: identifyMayStatementType(forLoop) });
213
+ graph.addVertex({ id: forLoop.info.id + '-exit', name: 'for-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
209
214
  graph.merge(vector.graph);
210
215
  graph.merge(body.graph);
211
216
  for (const entry of vector.entryPoints) {
@@ -236,9 +241,9 @@ function cfgFor(forLoop, variable, vector, body) {
236
241
  function cfgFunctionDefinition(fn, params, body) {
237
242
  const graph = new ControlFlowGraph();
238
243
  const children = [fn.info.id + '-params', fn.info.id + '-exit'];
239
- graph.addVertex({ id: fn.info.id + '-params', name: 'function-parameters' }, false);
240
- graph.addVertex({ id: fn.info.id + '-exit', name: 'function-exit' }, false);
241
- graph.addVertex({ id: fn.info.id, name: fn.type, children });
244
+ graph.addVertex({ id: fn.info.id + '-params', name: 'function-parameters', type: "mid-marker" /* CfgVertexType.MidMarker */ }, false);
245
+ graph.addVertex({ id: fn.info.id + '-exit', name: 'function-exit', type: "end-marker" /* CfgVertexType.EndMarker */ }, false);
246
+ graph.addVertex({ id: fn.info.id, name: fn.type, children, type: identifyMayStatementType(fn) });
242
247
  graph.merge(body.graph, true);
243
248
  children.push(...body.graph.rootVertexIds());
244
249
  for (const param of params) {
@@ -263,15 +268,15 @@ function cfgFunctionDefinition(fn, params, body) {
263
268
  function cfgFunctionCall(call, name, args) {
264
269
  const graph = name.graph;
265
270
  const info = { graph, breaks: [...name.breaks], nexts: [...name.nexts], returns: [...name.returns], exitPoints: [call.info.id + '-exit'], entryPoints: [call.info.id] };
266
- graph.addVertex({ id: call.info.id, name: call.type });
271
+ graph.addVertex({ id: call.info.id, name: call.type, type: identifyMayStatementType(call) });
267
272
  for (const entryPoint of name.entryPoints) {
268
273
  graph.addEdge(entryPoint, call.info.id, { label: 'FD' });
269
274
  }
270
- graph.addVertex({ id: call.info.id + '-name', name: 'call-name' });
275
+ graph.addVertex({ id: call.info.id + '-name', name: 'call-name', type: "mid-marker" /* CfgVertexType.MidMarker */ });
271
276
  for (const exitPoint of name.exitPoints) {
272
277
  graph.addEdge(call.info.id + '-name', exitPoint, { label: 'FD' });
273
278
  }
274
- graph.addVertex({ id: call.info.id + '-exit', name: 'call-exit' });
279
+ graph.addVertex({ id: call.info.id + '-exit', name: 'call-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
275
280
  let lastArgExits = [call.info.id + '-name'];
276
281
  for (const arg of args) {
277
282
  if (arg === undefined) {
@@ -297,7 +302,7 @@ function cfgFunctionCall(call, name, args) {
297
302
  function cfgArgumentOrParameter(node, name, value) {
298
303
  const graph = new ControlFlowGraph();
299
304
  const info = { graph, breaks: [], nexts: [], returns: [], exitPoints: [node.info.id + '-exit'], entryPoints: [node.info.id] };
300
- graph.addVertex({ id: node.info.id, name: node.type });
305
+ graph.addVertex({ id: node.info.id, name: node.type, type: "expression" /* CfgVertexType.Expression */ });
301
306
  let currentExitPoint = [node.info.id];
302
307
  if (name) {
303
308
  graph.merge(name.graph);
@@ -309,7 +314,7 @@ function cfgArgumentOrParameter(node, name, value) {
309
314
  }
310
315
  currentExitPoint = name.exitPoints;
311
316
  }
312
- graph.addVertex({ id: node.info.id + '-before-value', name: 'before-value' });
317
+ graph.addVertex({ id: node.info.id + '-before-value', name: 'before-value', type: "mid-marker" /* CfgVertexType.MidMarker */ });
313
318
  for (const exitPoints of currentExitPoint) {
314
319
  graph.addEdge(node.info.id + '-before-value', exitPoints, { label: 'FD' });
315
320
  }
@@ -326,7 +331,7 @@ function cfgArgumentOrParameter(node, name, value) {
326
331
  }
327
332
  currentExitPoint = value.exitPoints;
328
333
  }
329
- graph.addVertex({ id: node.info.id + '-exit', name: 'exit' });
334
+ graph.addVertex({ id: node.info.id + '-exit', name: 'exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
330
335
  for (const exit of currentExitPoint) {
331
336
  graph.addEdge(node.info.id + '-exit', exit, { label: 'FD' });
332
337
  }
@@ -335,8 +340,8 @@ function cfgArgumentOrParameter(node, name, value) {
335
340
  function cfgBinaryOp(binOp, lhs, rhs) {
336
341
  const graph = new ControlFlowGraph().merge(lhs.graph).merge(rhs.graph);
337
342
  const result = { graph, breaks: [...lhs.breaks, ...rhs.breaks], nexts: [...lhs.nexts, ...rhs.nexts], returns: [...lhs.returns, ...rhs.returns], entryPoints: [binOp.info.id], exitPoints: [binOp.info.id + '-exit'] };
338
- graph.addVertex({ id: binOp.info.id, name: binOp.type });
339
- graph.addVertex({ id: binOp.info.id + '-exit', name: 'binOp-exit' });
343
+ graph.addVertex({ id: binOp.info.id, name: binOp.type, type: binOp.flavor === 'assignment' ? "statement" /* CfgVertexType.Statement */ : "expression" /* CfgVertexType.Expression */ });
344
+ graph.addVertex({ id: binOp.info.id + '-exit', name: 'binOp-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
340
345
  for (const exitPoint of lhs.exitPoints) {
341
346
  for (const entryPoint of rhs.entryPoints) {
342
347
  result.graph.addEdge(entryPoint, exitPoint, { label: 'FD' });
@@ -353,8 +358,8 @@ function cfgBinaryOp(binOp, lhs, rhs) {
353
358
  function cfgAccess(access, name, accessors) {
354
359
  const result = name;
355
360
  const graph = result.graph;
356
- graph.addVertex({ id: access.info.id, name: access.type });
357
- graph.addVertex({ id: access.info.id + '-exit', name: 'access-exit' });
361
+ graph.addVertex({ id: access.info.id, name: access.type, type: "expression" /* CfgVertexType.Expression */ });
362
+ graph.addVertex({ id: access.info.id + '-exit', name: 'access-exit', type: "end-marker" /* CfgVertexType.EndMarker */ });
358
363
  for (const entry of name.entryPoints) {
359
364
  graph.addEdge(entry, access.info.id, { label: 'FD' });
360
365
  }
@@ -383,7 +388,7 @@ function cfgAccess(access, name, accessors) {
383
388
  function cfgUnaryOp(unary, operand) {
384
389
  const graph = operand.graph;
385
390
  const result = { ...operand, graph, exitPoints: [unary.info.id] };
386
- graph.addVertex({ id: unary.info.id, name: unary.type });
391
+ graph.addVertex({ id: unary.info.id, name: unary.type, type: "end-marker" /* CfgVertexType.EndMarker */ });
387
392
  return result;
388
393
  }
389
394
  function cfgExprList(_node, expressions) {
@@ -0,0 +1,14 @@
1
+ import type { NodeId } from '../../r-bridge';
2
+ import type { CfgEdge, CfgVertex, ControlFlowInformation } from './cfg';
3
+ export interface NodeVisitingContext {
4
+ parent: {
5
+ vertex: NodeId;
6
+ edge: CfgEdge;
7
+ } | 'root';
8
+ cfg: ControlFlowInformation;
9
+ visited: Set<NodeId>;
10
+ /** contains the current vertex as well */
11
+ siblings: NodeId[];
12
+ }
13
+ export type OnEnterVisitNode = (node: CfgVertex, context: NodeVisitingContext) => void;
14
+ export declare function visitCfg(cfg: ControlFlowInformation, onVisit: OnEnterVisitNode): void;