@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
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseToQuads = void 0;
4
4
  const quads_1 = require("../../util/quads");
5
- const internal_1 = require("../../r-bridge/lang-4.x/ast/parser/xml/internal");
5
+ const r_bridge_1 = require("../../r-bridge");
6
+ const format_1 = require("../../r-bridge/lang-4.x/ast/parser/json/format");
7
+ const parser_1 = require("../../r-bridge/lang-4.x/ast/parser/json/parser");
6
8
  function filterObject(obj, keys) {
7
9
  if (typeof obj !== 'object') {
8
10
  return obj;
@@ -20,10 +22,10 @@ function filterObject(obj, keys) {
20
22
  .map(([k, v]) => [k, filterObject(v, keys)]));
21
23
  }
22
24
  }
23
- async function parseToQuads(code, config, parseConfig) {
24
- const obj = await (0, internal_1.xlm2jsonObject)(parseConfig, code);
25
+ function parseToQuads(code, config) {
26
+ const obj = (0, parser_1.convertPreparedParsedData)((0, format_1.prepareParsedData)(code));
25
27
  // recursively filter so that if the object contains one of the keys 'a', 'b' or 'c', all other keys are ignored
26
- return (0, quads_1.serialize2quads)(filterObject(obj, new Set([parseConfig.attributeName, parseConfig.childrenName, parseConfig.contentName])), config);
28
+ return (0, quads_1.serialize2quads)(filterObject(obj, new Set([r_bridge_1.attributesKey, r_bridge_1.childrenKey, r_bridge_1.contentKey])), config);
27
29
  }
28
30
  exports.parseToQuads = parseToQuads;
29
31
  //# sourceMappingURL=parse-printer.js.map
@@ -1,4 +1,4 @@
1
- import { StepFunction } from '../steps';
1
+ import type { StepFunction } from '../steps';
2
2
  /**
3
3
  * Defines the output format of a step that you are interested in.
4
4
  */
@@ -1,2 +1,2 @@
1
- import { NodeId, NormalizedAst } from '../../r-bridge';
1
+ import type { NodeId, NormalizedAst } from '../../r-bridge';
2
2
  export declare function sliceDiffAnsi(slice: Set<NodeId>, normalized: NormalizedAst, criteriaIds: Set<NodeId>, originalCode: string): string;
package/core/slicer.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { LAST_PER_FILE_STEP, LAST_STEP, StepRequired, STEPS_PER_SLICE, StepName, StepResult } from './steps';
2
- import { SlicingCriteria } from '../slicing';
3
- import { SteppingSlicerInput } from './input';
4
- import { StepResults } from './output';
1
+ import type { LAST_PER_FILE_STEP, StepRequired, StepName, StepResult } from './steps';
2
+ import { LAST_STEP, STEPS_PER_SLICE } from './steps';
3
+ import type { SlicingCriteria } from '../slicing';
4
+ import type { SteppingSlicerInput } from './input';
5
+ import type { StepResults } from './output';
5
6
  /**
6
7
  * This is ultimately the root of flowR's static slicing procedure.
7
8
  * It clearly defines the steps that are to be executed and splits them into two stages.
package/core/slicer.js CHANGED
@@ -162,11 +162,11 @@ class SteppingSlicer {
162
162
  break;
163
163
  case 1:
164
164
  step = guardStep('normalize');
165
- result = await (0, steps_1.executeSingleSubStep)(step, this.results.parse, await this.shell.tokenMap(), this.hooks, this.getId);
165
+ result = (0, steps_1.executeSingleSubStep)(step, this.results.parse, this.hooks, this.getId);
166
166
  break;
167
167
  case 2:
168
168
  step = guardStep('dataflow');
169
- result = (0, steps_1.executeSingleSubStep)(step, this.results.normalize);
169
+ result = (0, steps_1.executeSingleSubStep)(step, this.request, this.results.normalize);
170
170
  break;
171
171
  case 3:
172
172
  (0, assert_1.guard)(this.criterion !== undefined, 'Cannot decode criteria without a criterion');
package/core/steps.d.ts CHANGED
@@ -12,14 +12,15 @@
12
12
  *
13
13
  * @module
14
14
  */
15
- import { MergeableRecord } from '../util/objects';
16
- import { normalize, retrieveXmlFromRCode } from '../r-bridge';
17
- import { produceDataFlowGraph } from '../dataflow';
15
+ import type { MergeableRecord } from '../util/objects';
16
+ import { retrieveParseDataFromRCode } from '../r-bridge';
18
17
  import { reconstructToCode, staticSlicing } from '../slicing';
19
- import { internalPrinter, IStepPrinter, StepOutputFormat } from './print/print';
18
+ import type { IStepPrinter } from './print/print';
19
+ import { internalPrinter, StepOutputFormat } from './print/print';
20
20
  import { normalizedAstToJson, normalizedAstToQuads, printNormalizedAstToMermaid, printNormalizedAstToMermaidUrl } from './print/normalize-printer';
21
- import { dataflowGraphToJson, dataflowGraphToMermaid, dataflowGraphToMermaidUrl, dataflowGraphToQuads } from './print/dataflow-printer';
22
21
  import { parseToQuads } from './print/parse-printer';
22
+ import { dataflowGraphToJson, dataflowGraphToMermaid, dataflowGraphToMermaidUrl, dataflowGraphToQuads } from './print/dataflow-printer';
23
+ import { normalize } from '../r-bridge/lang-4.x/ast/parser/json/parser';
23
24
  /**
24
25
  * This represents close a function that we know completely nothing about.
25
26
  * Nevertheless, this is the basis of what a step processor should look like.
@@ -47,7 +48,7 @@ export interface IStep<Fn extends StepFunction> extends MergeableRecord {
47
48
  export declare const STEPS_PER_FILE: {
48
49
  readonly parse: {
49
50
  description: string;
50
- processor: typeof retrieveXmlFromRCode;
51
+ processor: typeof retrieveParseDataFromRCode;
51
52
  required: "once-per-file";
52
53
  printer: {
53
54
  0: typeof internalPrinter;
@@ -69,7 +70,7 @@ export declare const STEPS_PER_FILE: {
69
70
  };
70
71
  readonly dataflow: {
71
72
  description: string;
72
- processor: typeof produceDataFlowGraph;
73
+ processor: (r: import("../r-bridge").RParseRequest, a: import("../r-bridge").NormalizedAst<import("../r-bridge").ParentInformation>) => import("../dataflow/internal/info").DataflowInformation;
73
74
  required: "once-per-file";
74
75
  printer: {
75
76
  0: typeof internalPrinter;
@@ -117,7 +118,7 @@ export declare const STEPS: {
117
118
  };
118
119
  readonly parse: {
119
120
  description: string;
120
- processor: typeof retrieveXmlFromRCode;
121
+ processor: typeof retrieveParseDataFromRCode;
121
122
  required: "once-per-file";
122
123
  printer: {
123
124
  0: typeof internalPrinter;
@@ -139,7 +140,7 @@ export declare const STEPS: {
139
140
  };
140
141
  readonly dataflow: {
141
142
  description: string;
142
- processor: typeof produceDataFlowGraph;
143
+ processor: (r: import("../r-bridge").RParseRequest, a: import("../r-bridge").NormalizedAst<import("../r-bridge").ParentInformation>) => import("../dataflow/internal/info").DataflowInformation;
143
144
  required: "once-per-file";
144
145
  printer: {
145
146
  0: typeof internalPrinter;
package/core/steps.js CHANGED
@@ -21,12 +21,13 @@ const slicing_1 = require("../slicing");
21
21
  const print_1 = require("./print/print");
22
22
  const normalize_printer_1 = require("./print/normalize-printer");
23
23
  const assert_1 = require("../util/assert");
24
- const dataflow_printer_1 = require("./print/dataflow-printer");
25
24
  const parse_printer_1 = require("./print/parse-printer");
25
+ const dataflow_printer_1 = require("./print/dataflow-printer");
26
+ const parser_1 = require("../r-bridge/lang-4.x/ast/parser/json/parser");
26
27
  exports.STEPS_PER_FILE = {
27
28
  'parse': {
28
29
  description: 'Parse the given R code into an AST',
29
- processor: r_bridge_1.retrieveXmlFromRCode,
30
+ processor: r_bridge_1.retrieveParseDataFromRCode,
30
31
  required: 'once-per-file',
31
32
  printer: {
32
33
  [0 /* StepOutputFormat.Internal */]: print_1.internalPrinter,
@@ -36,7 +37,7 @@ exports.STEPS_PER_FILE = {
36
37
  },
37
38
  'normalize': {
38
39
  description: 'Normalize the AST to flowR\'s AST (first step of the normalization)',
39
- processor: r_bridge_1.normalize,
40
+ processor: parser_1.normalize,
40
41
  required: 'once-per-file',
41
42
  printer: {
42
43
  [0 /* StepOutputFormat.Internal */]: print_1.internalPrinter,
@@ -48,7 +49,7 @@ exports.STEPS_PER_FILE = {
48
49
  },
49
50
  'dataflow': {
50
51
  description: 'Construct the dataflow graph',
51
- processor: dataflow_1.produceDataFlowGraph,
52
+ processor: (r, a) => (0, dataflow_1.produceDataFlowGraph)(r, a),
52
53
  required: 'once-per-file',
53
54
  printer: {
54
55
  [0 /* StepOutputFormat.Internal */]: print_1.internalPrinter,
@@ -1,4 +1,4 @@
1
- import { REnvironmentInformation } from './environment';
1
+ import type { REnvironmentInformation } from './environment';
2
2
  /**
3
3
  * Adds all writes of `next` to `base` (i.e., the operations of `next` *might* happen).
4
4
  */
@@ -4,10 +4,10 @@
4
4
  *
5
5
  * @module
6
6
  */
7
- import { NodeId } from '../../r-bridge';
8
- import { DataflowGraph, DataflowGraphEdgeAttribute } from '../graph';
9
- import { DataflowScopeName } from './scopes';
10
- import { GenericDifferenceInformation } from '../../util/diff';
7
+ import type { NodeId } from '../../r-bridge';
8
+ import type { DataflowGraph, DataflowGraphEdgeAttribute } from '../graph';
9
+ import type { DataflowScopeName } from './scopes';
10
+ import type { GenericDifferenceInformation } from '../../util/diff';
11
11
  /** identifiers are branded to avoid confusion with other string-like types */
12
12
  export type Identifier = string & {
13
13
  __brand?: 'identifier';
@@ -77,6 +77,14 @@ exports.DefaultEnvironmentMemory = new Map([
77
77
  definedAt: exports.BuiltIn,
78
78
  name: 'print',
79
79
  nodeId: exports.BuiltIn
80
+ }]],
81
+ ['source', [{
82
+ kind: 'built-in-function',
83
+ scope: scopes_1.GlobalScope,
84
+ used: 'always',
85
+ definedAt: exports.BuiltIn,
86
+ name: 'source',
87
+ nodeId: exports.BuiltIn
80
88
  }]]
81
89
  ]);
82
90
  function initializeCleanEnvironments() {
@@ -1,4 +1,4 @@
1
- import { REnvironmentInformation, IEnvironment } from './environment';
1
+ import type { REnvironmentInformation, IEnvironment } from './environment';
2
2
  export declare function overwriteIEnvironmentWith(base: IEnvironment | undefined, next: IEnvironment | undefined, includeParent?: boolean): IEnvironment;
3
3
  export declare function overwriteEnvironments(base: REnvironmentInformation, next: REnvironmentInformation | undefined): REnvironmentInformation;
4
4
  export declare function overwriteEnvironments(base: REnvironmentInformation | undefined, next: REnvironmentInformation): REnvironmentInformation;
@@ -1,5 +1,5 @@
1
- import { IdentifierDefinition, REnvironmentInformation } from './environment';
2
- import { DataflowScopeName } from './scopes';
1
+ import type { IdentifierDefinition, REnvironmentInformation } from './environment';
2
+ import type { DataflowScopeName } from './scopes';
3
3
  /**
4
4
  * Insert the given `definition` --- defined within the given scope --- into the passed along `environments` will take care of propagation.
5
5
  * Does not modify the passed along `environments` in-place! It returns the new reference.
@@ -10,6 +10,7 @@ const assert_1 = require("../../util/assert");
10
10
  */
11
11
  function define(definition, withinScope, environments) {
12
12
  let newEnvironments = environments;
13
+ (0, assert_1.guard)(withinScope === definition.scope, 'Mismatching scopes');
13
14
  if (withinScope === scopes_1.LocalScope) {
14
15
  newEnvironments = (0, environment_1.cloneEnvironments)(environments, false);
15
16
  newEnvironments.current.memory.set(definition.name, [definition]);
@@ -1,5 +1,5 @@
1
- import { Identifier, IdentifierDefinition, REnvironmentInformation } from './environment';
2
- import { DataflowScopeName } from './scopes';
1
+ import type { Identifier, IdentifierDefinition, REnvironmentInformation } from './environment';
2
+ import type { DataflowScopeName } from './scopes';
3
3
  /**
4
4
  * Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
5
5
  *
@@ -1,4 +1,4 @@
1
- import { REnvironmentInformation } from './environment';
1
+ import type { REnvironmentInformation } from './environment';
2
2
  /** Add a new local environment scope to the stack, returns the modified variant - sharing the original environments in the stack (no deep-clone) */
3
3
  export declare function pushLocalEnvironment(base: REnvironmentInformation): REnvironmentInformation;
4
4
  export declare function popLocalEnvironment(base: REnvironmentInformation): REnvironmentInformation;
@@ -1,6 +1,6 @@
1
- import { NormalizedAst, ParentInformation, RBinaryOp } from '../r-bridge';
2
- import { DataflowInformation } from './internal/info';
3
- import { DataflowProcessorInformation } from './processor';
4
- import { DataflowScopeName } from './environments';
5
- export declare function produceDataFlowGraph<OtherInfo>(ast: NormalizedAst<OtherInfo & ParentInformation>, initialScope?: DataflowScopeName): DataflowInformation;
1
+ import type { NormalizedAst, ParentInformation, RBinaryOp, RParseRequest } from '../r-bridge';
2
+ import type { DataflowInformation } from './internal/info';
3
+ import type { DataflowProcessorInformation } from './processor';
4
+ import type { DataflowScopeName } from './environments';
5
+ export declare function produceDataFlowGraph<OtherInfo>(request: RParseRequest, ast: NormalizedAst<OtherInfo & ParentInformation>, initialScope?: DataflowScopeName): DataflowInformation;
6
6
  export declare function processBinaryOp<OtherInfo>(node: RBinaryOp<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processBinaryOp = exports.produceDataFlowGraph = void 0;
4
+ const r_bridge_1 = require("../r-bridge");
4
5
  const processor_1 = require("./processor");
5
6
  const uninteresting_leaf_1 = require("./internal/process/uninteresting-leaf");
6
7
  const symbol_1 = require("./internal/process/symbol");
@@ -44,8 +45,15 @@ const processors = {
44
45
  ["RArgument" /* RType.Argument */]: argument_1.processFunctionArgument,
45
46
  ["RExpressionList" /* RType.ExpressionList */]: expression_list_1.processExpressionList,
46
47
  };
47
- function produceDataFlowGraph(ast, initialScope = scopes_1.LocalScope) {
48
- return (0, processor_1.processDataflowFor)(ast.ast, { completeAst: ast, activeScope: initialScope, environments: (0, environments_1.initializeCleanEnvironments)(), processors: processors });
48
+ function produceDataFlowGraph(request, ast, initialScope = scopes_1.LocalScope) {
49
+ return (0, processor_1.processDataflowFor)(ast.ast, {
50
+ completeAst: ast,
51
+ activeScope: initialScope,
52
+ environments: (0, environments_1.initializeCleanEnvironments)(),
53
+ processors: processors,
54
+ currentRequest: request,
55
+ referenceChain: [(0, r_bridge_1.requestFingerprint)(request)]
56
+ });
49
57
  }
50
58
  exports.produceDataFlowGraph = produceDataFlowGraph;
51
59
  function processBinaryOp(node, data) {
@@ -1,6 +1,6 @@
1
- import { NodeId } from '../../r-bridge';
2
- import { DataflowGraph, FunctionArgument, OutgoingEdges } from './graph';
3
- import { GenericDifferenceInformation, DifferenceReport } from '../../util/diff';
1
+ import type { NodeId } from '../../r-bridge';
2
+ import type { DataflowGraph, FunctionArgument, OutgoingEdges } from './graph';
3
+ import type { GenericDifferenceInformation, DifferenceReport } from '../../util/diff';
4
4
  export interface NamedGraph {
5
5
  name: string;
6
6
  graph: DataflowGraph;
@@ -1,10 +1,11 @@
1
- import { NodeId, NoInfo, RNodeWithParent } from '../../r-bridge';
2
- import { IdentifierDefinition, IdentifierReference } from '../environments';
3
- import { BiMap } from '../../util/bimap';
4
- import { DataflowGraphEdge, DataflowGraphEdgeAttribute, EdgeType } from './edge';
5
- import { DataflowInformation } from '../internal/info';
6
- import { DataflowGraphVertexArgument, DataflowGraphVertexInfo } from './vertex';
7
- import { DifferenceReport } from '../../util/diff';
1
+ import type { NodeId, NoInfo, RNodeWithParent } from '../../r-bridge';
2
+ import type { IdentifierDefinition, IdentifierReference } from '../environments';
3
+ import type { BiMap } from '../../util/bimap';
4
+ import type { DataflowGraphEdge, DataflowGraphEdgeAttribute } from './edge';
5
+ import { EdgeType } from './edge';
6
+ import type { DataflowInformation } from '../internal/info';
7
+ import type { DataflowGraphVertexArgument, DataflowGraphVertexInfo } from './vertex';
8
+ import type { DifferenceReport } from '../../util/diff';
8
9
  /** Used to get an entry point for every id, after that it allows reference-chasing of the graph */
9
10
  export type DataflowMap<OtherInfo = NoInfo> = BiMap<NodeId, RNodeWithParent<OtherInfo>>;
10
11
  export type DataflowFunctionFlowInformation = Omit<DataflowInformation, 'graph'> & {
@@ -1,5 +1,5 @@
1
- import { QuadSerializationConfiguration } from '../../util/quads';
2
- import { DataflowGraph } from './graph';
1
+ import type { QuadSerializationConfiguration } from '../../util/quads';
2
+ import type { DataflowGraph } from './graph';
3
3
  /**
4
4
  * @see cfg2quads
5
5
  * @see serialize2quads
@@ -1,8 +1,8 @@
1
- import { MergeableRecord } from '../../util/objects';
2
- import { NodeId } from '../../r-bridge';
3
- import { DataflowScopeName, REnvironmentInformation } from '../environments';
4
- import { DataflowGraphEdgeAttribute } from './edge';
5
- import { DataflowFunctionFlowInformation, FunctionArgument } from './graph';
1
+ import type { MergeableRecord } from '../../util/objects';
2
+ import type { NodeId } from '../../r-bridge';
3
+ import type { DataflowScopeName, REnvironmentInformation } from '../environments';
4
+ import type { DataflowGraphEdgeAttribute } from './edge';
5
+ import type { DataflowFunctionFlowInformation, FunctionArgument } from './graph';
6
6
  export type DataflowGraphVertices = Map<NodeId, DataflowGraphVertexInfo>;
7
7
  /**
8
8
  * Arguments required to construct a vertex in the dataflow graph.
@@ -1,6 +1,6 @@
1
1
  import { DataflowGraph } from '../graph';
2
- import { REnvironmentInformation, IdentifierReference, DataflowScopeName } from '../environments';
3
- import { DataflowProcessorInformation } from '../processor';
2
+ import type { REnvironmentInformation, IdentifierReference, DataflowScopeName } from '../environments';
3
+ import type { DataflowProcessorInformation } from '../processor';
4
4
  /**
5
5
  * Continuously updated during the dataflow analysis to hold the current state.
6
6
  */
@@ -1,7 +1,7 @@
1
- import { DataflowGraph, DataflowGraphVertexInfo, FunctionArgument } from '../graph';
2
- import { DataflowScopeName, IdentifierReference, REnvironmentInformation } from '../environments';
1
+ import type { DataflowGraph, DataflowGraphVertexInfo, FunctionArgument } from '../graph';
2
+ import type { DataflowScopeName, IdentifierReference, REnvironmentInformation } from '../environments';
3
3
  import { DefaultMap } from '../../util/defaultmap';
4
- import { DecoratedAstMap, NodeId, ParentInformation, RParameter } from '../../r-bridge';
4
+ import type { DecoratedAstMap, NodeId, ParentInformation, RParameter } from '../../r-bridge';
5
5
  export declare function linkIngoingVariablesInSameScope(graph: DataflowGraph, references: IdentifierReference[]): void;
6
6
  export type NameIdMap = DefaultMap<string, IdentifierReference[]>;
7
7
  export declare function produceNameSharedIdMap(references: IdentifierReference[]): NameIdMap;
@@ -1,4 +1,4 @@
1
- import { ParentInformation, RAccess } from '../../../r-bridge';
2
- import { DataflowInformation } from '../info';
3
- import { DataflowProcessorInformation } from '../../processor';
1
+ import type { ParentInformation, RAccess } from '../../../r-bridge';
2
+ import type { DataflowInformation } from '../info';
3
+ import type { DataflowProcessorInformation } from '../../processor';
4
4
  export declare function processAccess<OtherInfo>(node: RAccess<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -2,7 +2,7 @@
2
2
  * Processes a list of expressions joining their dataflow graphs accordingly.
3
3
  * @module
4
4
  */
5
- import { DataflowInformation } from '../info';
6
- import { ParentInformation, RExpressionList } from '../../../r-bridge';
7
- import { DataflowProcessorInformation } from '../../processor';
5
+ import type { DataflowInformation } from '../info';
6
+ import type { ParentInformation, RExpressionList } from '../../../r-bridge';
7
+ import type { DataflowProcessorInformation } from '../../processor';
8
8
  export declare function processExpressionList<OtherInfo>(exprList: RExpressionList<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processExpressionList = void 0;
4
- /**
5
- * Processes a list of expressions joining their dataflow graphs accordingly.
6
- * @module
7
- */
8
4
  const info_1 = require("../info");
9
5
  const r_bridge_1 = require("../../../r-bridge");
10
6
  const processor_1 = require("../../processor");
@@ -1,8 +1,8 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RArgument, RNode } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RArgument, RNode } from '../../../../r-bridge';
4
4
  import { DataflowGraph } from '../../../graph';
5
- import { IdentifierReference } from '../../../environments';
5
+ import type { IdentifierReference } from '../../../environments';
6
6
  export declare const UnnamedArgumentPrefix = "unnamed-argument-";
7
7
  export declare function linkReadsForArgument<OtherInfo>(root: RNode<OtherInfo & ParentInformation>, ingoingRefs: IdentifierReference[], graph: DataflowGraph): void;
8
8
  export declare function processFunctionArgument<OtherInfo>(argument: RArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,2 +1,2 @@
1
- import { NodeId, ParentInformation, RFunctionDefinition } from '../../../../r-bridge';
1
+ import type { NodeId, ParentInformation, RFunctionDefinition } from '../../../../r-bridge';
2
2
  export declare function retrieveExitPointsOfFunctionDefinition<OtherInfo>(functionDefinition: RFunctionDefinition<OtherInfo & ParentInformation>): NodeId[];
@@ -1,5 +1,5 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RFunctionCall } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RFunctionCall } from '../../../../r-bridge';
4
4
  export declare const UnnamedFunctionCallPrefix = "unnamed-function-call-";
5
5
  export declare function processFunctionCall<OtherInfo>(functionCall: RFunctionCall<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -7,6 +7,7 @@ const assert_1 = require("../../../../util/assert");
7
7
  const index_1 = require("../../../index");
8
8
  const linker_1 = require("../../linker");
9
9
  const scopes_1 = require("../../../environments/scopes");
10
+ const source_1 = require("./source");
10
11
  exports.UnnamedFunctionCallPrefix = 'unnamed-function-call-';
11
12
  function processFunctionCall(functionCall, data) {
12
13
  const named = functionCall.flavor === 'named';
@@ -86,7 +87,7 @@ function processFunctionCall(functionCall, data) {
86
87
  // push the called function to the ids:
87
88
  inIds.push(...functionName.in, ...functionName.unknownReferences);
88
89
  }
89
- return {
90
+ let info = {
90
91
  unknownReferences: [],
91
92
  in: inIds,
92
93
  out: functionName.out, // we do not keep argument out as it has been linked by the function
@@ -94,6 +95,11 @@ function processFunctionCall(functionCall, data) {
94
95
  environments: finalEnv,
95
96
  scope: data.activeScope
96
97
  };
98
+ // parse a source call and analyze the referenced code
99
+ if ((0, source_1.isSourceCall)(functionCallName, data.activeScope, finalEnv)) {
100
+ info = (0, source_1.processSourceCall)(functionCall, data, info);
101
+ }
102
+ return info;
97
103
  }
98
104
  exports.processFunctionCall = processFunctionCall;
99
105
  //# sourceMappingURL=function-call.js.map
@@ -1,4 +1,4 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RFunctionDefinition } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RFunctionDefinition } from '../../../../r-bridge';
4
4
  export declare function processFunctionDefinition<OtherInfo>(functionDefinition: RFunctionDefinition<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,4 +1,4 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RParameter } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RParameter } from '../../../../r-bridge';
4
4
  export declare function processFunctionParameter<OtherInfo>(parameter: RParameter<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -0,0 +1,8 @@
1
+ import type { IdGenerator, NoInfo, RParseRequest, RParseRequestProvider, ParentInformation, RFunctionCall } from '../../../../r-bridge';
2
+ import { type DataflowProcessorInformation } from '../../../processor';
3
+ import { type DataflowScopeName, type Identifier, type REnvironmentInformation } from '../../../environments';
4
+ import type { DataflowInformation } from '../../info';
5
+ export declare function setSourceProvider(provider: RParseRequestProvider): void;
6
+ export declare function isSourceCall(name: Identifier, scope: DataflowScopeName, environments: REnvironmentInformation): boolean;
7
+ export declare function processSourceCall<OtherInfo>(functionCall: RFunctionCall<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation): DataflowInformation;
8
+ export declare function sourceRequest<OtherInfo>(request: RParseRequest, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, information: DataflowInformation, getId: IdGenerator<NoInfo>): DataflowInformation;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sourceRequest = exports.processSourceCall = exports.isSourceCall = exports.setSourceProvider = void 0;
4
+ const r_bridge_1 = require("../../../../r-bridge");
5
+ const shell_executor_1 = require("../../../../r-bridge/shell-executor");
6
+ const core_1 = require("../../../../core");
7
+ const processor_1 = require("../../../processor");
8
+ const environments_1 = require("../../../environments");
9
+ const index_1 = require("../../../index");
10
+ const config_1 = require("../../../../config");
11
+ let sourceProvider = (0, r_bridge_1.requestProviderFromFile)();
12
+ function setSourceProvider(provider) {
13
+ sourceProvider = provider;
14
+ }
15
+ exports.setSourceProvider = setSourceProvider;
16
+ function isSourceCall(name, scope, environments) {
17
+ const definitions = (0, environments_1.resolveByName)(name, scope, environments);
18
+ if (definitions === undefined) {
19
+ return false;
20
+ }
21
+ // fail if there are multiple definitions because then we must treat the complete import as a maybe because it might do something different
22
+ if (definitions.length !== 1) {
23
+ return false;
24
+ }
25
+ const def = definitions[0];
26
+ return def.name == 'source' && def.kind == 'built-in-function';
27
+ }
28
+ exports.isSourceCall = isSourceCall;
29
+ function processSourceCall(functionCall, data, information) {
30
+ const sourceFile = functionCall.arguments[0];
31
+ if ((0, config_1.getConfig)().ignoreSourceCalls) {
32
+ index_1.dataflowLogger.info(`Skipping source call ${JSON.stringify(sourceFile)} (disabled in config file)`);
33
+ return information;
34
+ }
35
+ if (sourceFile?.value?.type == "RString" /* RType.String */) {
36
+ const path = (0, r_bridge_1.removeRQuotes)(sourceFile.lexeme);
37
+ const request = sourceProvider.createRequest(path);
38
+ // check if the sourced file has already been dataflow analyzed, and if so, skip it
39
+ if (data.referenceChain.includes((0, r_bridge_1.requestFingerprint)(request))) {
40
+ index_1.dataflowLogger.info(`Found loop in dataflow analysis for ${JSON.stringify(request)}: ${JSON.stringify(data.referenceChain)}, skipping further dataflow analysis`);
41
+ return information;
42
+ }
43
+ return sourceRequest(request, data, information, (0, r_bridge_1.sourcedDeterministicCountingIdGenerator)(path, functionCall.location));
44
+ }
45
+ else {
46
+ index_1.dataflowLogger.info(`Non-constant argument ${JSON.stringify(sourceFile)} for source is currently not supported, skipping`);
47
+ return information;
48
+ }
49
+ }
50
+ exports.processSourceCall = processSourceCall;
51
+ function sourceRequest(request, data, information, getId) {
52
+ const executor = new shell_executor_1.RShellExecutor();
53
+ // parse, normalize and dataflow the sourced file
54
+ let normalized;
55
+ let dataflow;
56
+ try {
57
+ const parsed = (0, core_1.executeSingleSubStep)('parse', request, executor);
58
+ normalized = (0, core_1.executeSingleSubStep)('normalize', parsed, undefined, getId);
59
+ dataflow = (0, processor_1.processDataflowFor)(normalized.ast, {
60
+ ...data,
61
+ currentRequest: request,
62
+ environments: information.environments,
63
+ referenceChain: [...data.referenceChain, (0, r_bridge_1.requestFingerprint)(request)]
64
+ });
65
+ }
66
+ catch (e) {
67
+ index_1.dataflowLogger.warn(`Failed to analyze sourced file ${JSON.stringify(request)}, skipping: ${e.message}`);
68
+ return information;
69
+ }
70
+ // update our graph with the sourced file's information
71
+ const newInformation = { ...information };
72
+ newInformation.environments = (0, environments_1.overwriteEnvironments)(information.environments, dataflow.environments);
73
+ newInformation.graph.mergeWith(dataflow.graph);
74
+ // this can be improved, see issue #628
75
+ for (const [k, v] of normalized.idMap) {
76
+ data.completeAst.idMap.set(k, v);
77
+ }
78
+ return newInformation;
79
+ }
80
+ exports.sourceRequest = sourceRequest;
81
+ //# sourceMappingURL=source.js.map
@@ -1,4 +1,4 @@
1
- import { DataflowInformation } from '../info';
2
- import { DataflowProcessorInformation } from '../../processor';
3
- import { ParentInformation, RIfThenElse } from '../../../r-bridge';
1
+ import type { DataflowInformation } from '../info';
2
+ import type { DataflowProcessorInformation } from '../../processor';
3
+ import type { ParentInformation, RIfThenElse } from '../../../r-bridge';
4
4
  export declare function processIfThenElse<OtherInfo>(ifThen: RIfThenElse<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,4 +1,4 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RForLoop } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RForLoop } from '../../../../r-bridge';
4
4
  export declare function processForLoop<OtherInfo>(loop: RForLoop<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,4 +1,4 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RRepeatLoop } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RRepeatLoop } from '../../../../r-bridge';
4
4
  export declare function processRepeatLoop<OtherInfo>(loop: RRepeatLoop<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,4 +1,4 @@
1
- import { DataflowInformation } from '../../info';
2
- import { DataflowProcessorInformation } from '../../../processor';
3
- import { ParentInformation, RWhileLoop } from '../../../../r-bridge';
1
+ import type { DataflowInformation } from '../../info';
2
+ import type { DataflowProcessorInformation } from '../../../processor';
3
+ import type { ParentInformation, RWhileLoop } from '../../../../r-bridge';
4
4
  export declare function processWhileLoop<OtherInfo>(loop: RWhileLoop<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
@@ -1,4 +1,4 @@
1
- import { ParentInformation, RAssignmentOp } from '../../../../r-bridge';
2
- import { DataflowInformation } from '../../info';
3
- import { DataflowProcessorInformation } from '../../../processor';
1
+ import type { ParentInformation, RAssignmentOp } from '../../../../r-bridge';
2
+ import type { DataflowInformation } from '../../info';
3
+ import type { DataflowProcessorInformation } from '../../../processor';
4
4
  export declare function processAssignment<OtherInfo>(op: RAssignmentOp<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;