@eagleoutice/flowr 2.2.12 → 2.2.13

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 (256) hide show
  1. package/README.md +82 -20
  2. package/benchmark/slicer.js +2 -2
  3. package/benchmark/summarizer/first-phase/input.js +1 -1
  4. package/benchmark/summarizer/first-phase/process.js +3 -3
  5. package/benchmark/summarizer/second-phase/process.js +1 -1
  6. package/benchmark/summarizer/summarizer.js +1 -1
  7. package/cli/common/options.js +4 -4
  8. package/cli/common/script.js +1 -1
  9. package/cli/flowr.js +1 -1
  10. package/cli/repl/commands/repl-cfg.d.ts +2 -0
  11. package/cli/repl/commands/repl-cfg.js +38 -24
  12. package/cli/repl/commands/repl-commands.js +4 -2
  13. package/cli/repl/commands/repl-dataflow.js +3 -3
  14. package/cli/repl/commands/repl-execute.js +1 -1
  15. package/cli/repl/commands/repl-main.d.ts +1 -1
  16. package/cli/repl/commands/repl-main.js +1 -1
  17. package/cli/repl/commands/repl-normalize.js +1 -1
  18. package/cli/repl/commands/repl-query.js +2 -2
  19. package/cli/repl/core.js +1 -1
  20. package/cli/repl/prompt.js +1 -1
  21. package/cli/repl/server/connection.js +4 -4
  22. package/cli/repl/server/messages/message-analysis.d.ts +1 -1
  23. package/cli/script-core/statistics-core.js +1 -1
  24. package/cli/script-core/statistics-helper-core.js +4 -4
  25. package/config.d.ts +47 -24
  26. package/config.js +3 -3
  27. package/control-flow/basic-cfg-guided-visitor.d.ts +39 -0
  28. package/control-flow/basic-cfg-guided-visitor.js +114 -0
  29. package/control-flow/cfg-properties.d.ts +26 -0
  30. package/control-flow/cfg-properties.js +100 -0
  31. package/control-flow/cfg-simplification.d.ts +18 -0
  32. package/control-flow/cfg-simplification.js +55 -0
  33. package/control-flow/cfg-to-basic-blocks.d.ts +5 -0
  34. package/control-flow/cfg-to-basic-blocks.js +81 -0
  35. package/control-flow/control-flow-graph.d.ts +247 -0
  36. package/control-flow/control-flow-graph.js +290 -0
  37. package/control-flow/dfg-cfg-guided-visitor.d.ts +32 -0
  38. package/control-flow/dfg-cfg-guided-visitor.js +71 -0
  39. package/control-flow/diff-cfg.d.ts +11 -0
  40. package/control-flow/diff-cfg.js +161 -0
  41. package/control-flow/extract-cfg.d.ts +30 -0
  42. package/control-flow/extract-cfg.js +475 -0
  43. package/control-flow/happens-before.d.ts +7 -0
  44. package/{util/cfg → control-flow}/happens-before.js +3 -3
  45. package/control-flow/semantic-cfg-guided-visitor.d.ts +452 -0
  46. package/control-flow/semantic-cfg-guided-visitor.js +492 -0
  47. package/control-flow/simple-visitor.d.ts +25 -0
  48. package/control-flow/simple-visitor.js +80 -0
  49. package/control-flow/syntax-cfg-guided-visitor.d.ts +128 -0
  50. package/control-flow/syntax-cfg-guided-visitor.js +166 -0
  51. package/core/print/print.d.ts +1 -1
  52. package/core/print/slice-diff-ansi.js +1 -1
  53. package/core/steps/pipeline/create-pipeline.js +1 -1
  54. package/dataflow/environments/built-in-config.js +9 -6
  55. package/dataflow/environments/built-in.d.ts +8 -4
  56. package/dataflow/environments/built-in.js +47 -5
  57. package/dataflow/environments/default-builtin-config.d.ts +2 -0
  58. package/dataflow/environments/default-builtin-config.js +81 -14
  59. package/dataflow/environments/resolve-by-name.js +15 -4
  60. package/dataflow/extractor.js +2 -2
  61. package/dataflow/graph/dataflowgraph-builder.d.ts +3 -1
  62. package/dataflow/graph/dataflowgraph-builder.js +4 -2
  63. package/dataflow/graph/diff-dataflow-graph.d.ts +16 -0
  64. package/dataflow/graph/{diff.js → diff-dataflow-graph.js} +30 -56
  65. package/dataflow/graph/graph.d.ts +11 -3
  66. package/dataflow/graph/graph.js +27 -12
  67. package/dataflow/graph/vertex.d.ts +17 -2
  68. package/dataflow/internal/linker.d.ts +3 -2
  69. package/dataflow/internal/linker.js +33 -24
  70. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +1 -1
  72. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +12 -9
  73. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +84 -16
  75. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +23 -16
  76. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +5 -5
  77. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -4
  78. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -2
  79. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +15 -4
  80. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -3
  81. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +4 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -1
  84. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  85. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -7
  86. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
  87. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -0
  88. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +19 -4
  89. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -4
  91. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +4 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +3 -3
  93. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
  94. package/dataflow/internal/process/functions/call/common.d.ts +4 -1
  95. package/dataflow/internal/process/functions/call/common.js +5 -3
  96. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -2
  97. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  98. package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
  99. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -0
  100. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
  101. package/dataflow/internal/process/process-named-call.d.ts +1 -1
  102. package/dataflow/internal/process/process-named-call.js +5 -5
  103. package/dataflow/origin/dfg-get-origin.d.ts +82 -0
  104. package/dataflow/origin/dfg-get-origin.js +116 -0
  105. package/documentation/doc-util/doc-cfg.d.ts +13 -6
  106. package/documentation/doc-util/doc-cfg.js +19 -14
  107. package/documentation/doc-util/doc-cli-option.js +4 -2
  108. package/documentation/doc-util/doc-dfg.js +3 -3
  109. package/documentation/doc-util/doc-escape.d.ts +7 -0
  110. package/documentation/doc-util/doc-escape.js +19 -0
  111. package/documentation/doc-util/doc-files.d.ts +1 -0
  112. package/documentation/doc-util/doc-files.js +2 -1
  113. package/documentation/doc-util/doc-normalized-ast.js +3 -3
  114. package/documentation/doc-util/doc-query.js +2 -2
  115. package/documentation/doc-util/doc-repl.js +1 -1
  116. package/documentation/doc-util/doc-search.js +1 -1
  117. package/documentation/doc-util/doc-server-message.js +2 -2
  118. package/documentation/doc-util/doc-structure.d.ts +1 -0
  119. package/documentation/doc-util/doc-structure.js +5 -0
  120. package/documentation/doc-util/doc-types.d.ts +7 -1
  121. package/documentation/doc-util/doc-types.js +13 -2
  122. package/documentation/print-capabilities-markdown.js +27 -1
  123. package/documentation/print-cfg-wiki.js +505 -17
  124. package/documentation/print-dataflow-graph-wiki.js +180 -25
  125. package/documentation/print-engines-wiki.js +1 -1
  126. package/documentation/print-faq-wiki.d.ts +1 -0
  127. package/documentation/print-faq-wiki.js +75 -0
  128. package/documentation/print-interface-wiki.js +1 -1
  129. package/documentation/print-linting-and-testing-wiki.js +52 -36
  130. package/documentation/print-normalized-ast-wiki.js +1 -1
  131. package/documentation/print-onboarding-wiki.d.ts +1 -0
  132. package/documentation/print-onboarding-wiki.js +42 -0
  133. package/documentation/print-query-wiki.js +21 -1
  134. package/documentation/print-readme.js +10 -3
  135. package/package.json +9 -6
  136. package/queries/catalog/call-context-query/call-context-query-executor.js +5 -5
  137. package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
  138. package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
  139. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -2
  140. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +24 -21
  141. package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
  142. package/queries/catalog/cluster-query/cluster-query-format.js +1 -1
  143. package/queries/catalog/config-query/config-query-format.d.ts +1 -1
  144. package/queries/catalog/config-query/config-query-format.js +2 -2
  145. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
  146. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
  147. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
  148. package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
  149. package/queries/catalog/dependencies-query/dependencies-query-executor.js +4 -2
  150. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -1
  151. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
  152. package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
  153. package/queries/catalog/happens-before-query/happens-before-query-executor.js +4 -4
  154. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
  155. package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
  156. package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
  157. package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
  158. package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
  159. package/queries/catalog/lineage-query/lineage-query-format.js +2 -2
  160. package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
  161. package/queries/catalog/location-map-query/location-map-query-format.js +2 -2
  162. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
  163. package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -2
  164. package/queries/catalog/origin-query/origin-query-executor.d.ts +5 -0
  165. package/queries/catalog/origin-query/origin-query-executor.js +33 -0
  166. package/queries/catalog/origin-query/origin-query-format.d.ts +71 -0
  167. package/queries/catalog/origin-query/origin-query-format.js +27 -0
  168. package/queries/catalog/project-query/project-query-format.d.ts +1 -1
  169. package/queries/catalog/project-query/project-query-format.js +2 -2
  170. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
  171. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -2
  172. package/queries/catalog/search-query/search-query-format.d.ts +1 -1
  173. package/queries/catalog/search-query/search-query-format.js +2 -2
  174. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
  175. package/queries/catalog/static-slice-query/static-slice-query-format.js +2 -2
  176. package/queries/query-print.d.ts +1 -1
  177. package/queries/query-print.js +4 -4
  178. package/queries/query.d.ts +61 -2
  179. package/queries/query.js +3 -1
  180. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -2
  181. package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +5 -0
  182. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -2
  183. package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +5 -0
  184. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  185. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -1
  186. package/r-bridge/lang-4.x/ast/model/processing/fold.js +3 -1
  187. package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
  188. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
  189. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +1 -1
  190. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  191. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  192. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -1
  193. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +1 -1
  194. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
  195. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -1
  196. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  197. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
  198. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +26 -8
  199. package/r-bridge/retriever.js +1 -1
  200. package/search/search-executor/search-generators.d.ts +1 -1
  201. package/search/search-executor/search-transformer.d.ts +1 -1
  202. package/slicing/criterion/collect-all.js +1 -1
  203. package/slicing/static/slice-call.js +13 -3
  204. package/statistics/features/supported/assignments/post-process.js +1 -1
  205. package/statistics/features/supported/defined-functions/post-process.js +2 -2
  206. package/statistics/features/supported/used-functions/post-process.js +1 -1
  207. package/statistics/features/supported/used-packages/post-process.js +2 -2
  208. package/statistics/features/supported/values/post-process.js +2 -2
  209. package/statistics/output/print-stats.js +2 -2
  210. package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
  211. package/statistics/summarizer/post-process/clusterer.js +1 -1
  212. package/statistics/summarizer/post-process/histogram.js +3 -3
  213. package/statistics/summarizer/post-process/post-process-output.js +3 -3
  214. package/statistics/summarizer/second-phase/process.js +2 -2
  215. package/statistics/summarizer/summarizer.js +2 -2
  216. package/util/assert.js +36 -1
  217. package/util/cfg/cfg.d.ts +0 -80
  218. package/util/cfg/cfg.js +0 -549
  219. package/util/{arrays.d.ts → collections/arrays.d.ts} +1 -1
  220. package/util/{arrays.js → collections/arrays.js} +3 -3
  221. package/util/collections/set.js +17 -0
  222. package/util/diff-graph.d.ts +47 -0
  223. package/util/diff-graph.js +61 -0
  224. package/util/diff.d.ts +6 -6
  225. package/util/diff.js +1 -1
  226. package/util/mermaid/cfg.d.ts +9 -2
  227. package/util/mermaid/cfg.js +64 -12
  228. package/util/mermaid/dfg.d.ts +2 -1
  229. package/util/mermaid/dfg.js +26 -10
  230. package/util/mermaid/mermaid.d.ts +2 -0
  231. package/util/mermaid/mermaid.js +6 -0
  232. package/util/quads.js +1 -1
  233. package/util/schema.d.ts +1 -1
  234. package/util/schema.js +1 -1
  235. package/util/summarizer.js +1 -1
  236. package/util/{text.js → text/text.js} +1 -1
  237. package/util/{time.js → text/time.js} +1 -1
  238. package/util/version.js +1 -1
  239. package/dataflow/graph/diff.d.ts +0 -36
  240. package/util/cfg/happens-before.d.ts +0 -7
  241. package/util/cfg/visitor.d.ts +0 -9
  242. package/util/cfg/visitor.js +0 -30
  243. package/util/set.js +0 -31
  244. /package/util/{bimap.d.ts → collections/bimap.d.ts} +0 -0
  245. /package/util/{bimap.js → collections/bimap.js} +0 -0
  246. /package/util/{defaultmap.d.ts → collections/defaultmap.d.ts} +0 -0
  247. /package/util/{defaultmap.js → collections/defaultmap.js} +0 -0
  248. /package/util/{set.d.ts → collections/set.d.ts} +0 -0
  249. /package/util/{ansi.d.ts → text/ansi.d.ts} +0 -0
  250. /package/util/{ansi.js → text/ansi.js} +0 -0
  251. /package/util/{args.d.ts → text/args.d.ts} +0 -0
  252. /package/util/{args.js → text/args.js} +0 -0
  253. /package/util/{strings.d.ts → text/strings.d.ts} +0 -0
  254. /package/util/{strings.js → text/strings.js} +0 -0
  255. /package/util/{text.d.ts → text/text.d.ts} +0 -0
  256. /package/util/{time.d.ts → text/time.d.ts} +0 -0
@@ -0,0 +1,128 @@
1
+ import type { CfgExpressionVertex, CfgStatementVertex, ControlFlowInformation } from './control-flow-graph';
2
+ import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
3
+ import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
+ import type { BasicCfgGuidedVisitorConfiguration } from './basic-cfg-guided-visitor';
5
+ import { BasicCfgGuidedVisitor } from './basic-cfg-guided-visitor';
6
+ import type { RAccess } from '../r-bridge/lang-4.x/ast/model/nodes/r-access';
7
+ import type { RArgument } from '../r-bridge/lang-4.x/ast/model/nodes/r-argument';
8
+ import type { RBinaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
9
+ import type { RExpressionList } from '../r-bridge/lang-4.x/ast/model/nodes/r-expression-list';
10
+ import type { RForLoop } from '../r-bridge/lang-4.x/ast/model/nodes/r-for-loop';
11
+ import type { RFunctionCall } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
12
+ import type { RFunctionDefinition } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-definition';
13
+ import type { RIfThenElse } from '../r-bridge/lang-4.x/ast/model/nodes/r-if-then-else';
14
+ import type { RParameter } from '../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
15
+ import type { RPipe } from '../r-bridge/lang-4.x/ast/model/nodes/r-pipe';
16
+ import type { RRepeatLoop } from '../r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop';
17
+ import type { RUnaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-unary-op';
18
+ import type { RWhileLoop } from '../r-bridge/lang-4.x/ast/model/nodes/r-while-loop';
19
+ import type { RBreak } from '../r-bridge/lang-4.x/ast/model/nodes/r-break';
20
+ import type { RComment } from '../r-bridge/lang-4.x/ast/model/nodes/r-comment';
21
+ import type { RLineDirective } from '../r-bridge/lang-4.x/ast/model/nodes/r-line-directive';
22
+ import type { RLogical } from '../r-bridge/lang-4.x/ast/model/nodes/r-logical';
23
+ import type { RString } from '../r-bridge/lang-4.x/ast/model/nodes/r-string';
24
+ import type { RNext } from '../r-bridge/lang-4.x/ast/model/nodes/r-next';
25
+ import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
26
+ import type { RSymbol } from '../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
27
+ import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
28
+ export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, Cfg extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>> extends BasicCfgGuidedVisitorConfiguration<Cfg> {
29
+ readonly normalizedAst: Ast;
30
+ }
31
+ /**
32
+ * This visitor extends on the {@link BasicCfgGuidedVisitor} by dispatching visitors based on the AST type of the node.
33
+ *
34
+ * Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
35
+ */
36
+ export declare class SyntaxAwareCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Config extends SyntaxCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast> = SyntaxCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast>> extends BasicCfgGuidedVisitor<Cfg, Config> {
37
+ /**
38
+ * Get the normalized AST node for the given id or fail if it does not exist.
39
+ */
40
+ protected getNormalizedAst(id: NodeId): RNode<OtherInfo & ParentInformation> | undefined;
41
+ protected onStatementNode(node: CfgStatementVertex): void;
42
+ protected onExpressionNode(node: CfgExpressionVertex): void;
43
+ private onExprOrStmtNode;
44
+ /**
45
+ * {@link RAccess}
46
+ */
47
+ protected visitRAccess(_node: RAccess<OtherInfo & ParentInformation>): void;
48
+ /**
49
+ * {@link RArgument}
50
+ */
51
+ protected visitRArgument(_node: RArgument<OtherInfo & ParentInformation>): void;
52
+ /**
53
+ * {@link RBinaryOp}
54
+ */
55
+ protected visitRBinaryOp(_node: RBinaryOp<OtherInfo & ParentInformation>): void;
56
+ /**
57
+ * {@link RExpressionList}
58
+ */
59
+ protected visitRExpressionList(_node: RExpressionList<OtherInfo & ParentInformation>): void;
60
+ /**
61
+ * {@link RForLoop}
62
+ */
63
+ protected visitRForLoop(_node: RForLoop<OtherInfo & ParentInformation>): void;
64
+ /**
65
+ * {@link RFunctionCall}
66
+ */
67
+ protected visitRFunctionCall(_node: RFunctionCall<OtherInfo & ParentInformation>): void;
68
+ /**
69
+ * {@link RFunctionDefinition}
70
+ */
71
+ protected visitRFunctionDefinition(_node: RFunctionDefinition<OtherInfo & ParentInformation>): void;
72
+ /**
73
+ * {@link RIfThenElse}
74
+ */
75
+ protected visitRIfThenElse(_node: RIfThenElse<OtherInfo & ParentInformation>): void;
76
+ /**
77
+ * {@link RParameter}
78
+ */
79
+ protected visitRParameter(_node: RParameter<OtherInfo & ParentInformation>): void;
80
+ /**
81
+ * {@link RPipe}
82
+ */
83
+ protected visitRPipe(_node: RPipe<OtherInfo & ParentInformation>): void;
84
+ /**
85
+ * {@link RRepeatLoop}
86
+ */
87
+ protected visitRRepeatLoop(_node: RRepeatLoop<OtherInfo & ParentInformation>): void;
88
+ /**
89
+ * {@link RUnaryOp}
90
+ */
91
+ protected visitRUnaryOp(_node: RUnaryOp<OtherInfo & ParentInformation>): void;
92
+ /**
93
+ * {@link RWhileLoop}
94
+ */
95
+ protected visitRWhileLoop(_node: RWhileLoop<OtherInfo & ParentInformation>): void;
96
+ /**
97
+ * {@link RBreak}
98
+ */
99
+ protected visitRBreak(_node: RBreak<OtherInfo & ParentInformation>): void;
100
+ /**
101
+ * {@link RComment}
102
+ */
103
+ protected visitRComment(_node: RComment<OtherInfo & ParentInformation>): void;
104
+ /**
105
+ * {@link RLineDirective}
106
+ */
107
+ protected visitRLineDirective(_node: RLineDirective<OtherInfo & ParentInformation>): void;
108
+ /**
109
+ * {@link RLogical}
110
+ */
111
+ protected visitRLogical(_node: RLogical<OtherInfo & ParentInformation>): void;
112
+ /**
113
+ * {@link RNext}
114
+ */
115
+ protected visitRNext(_node: RNext<OtherInfo & ParentInformation>): void;
116
+ /**
117
+ * {@link RNumber}
118
+ */
119
+ protected visitRNumber(_node: RNumber<OtherInfo & ParentInformation>): void;
120
+ /**
121
+ * {@link RString}
122
+ */
123
+ protected visitRString(_node: RString<OtherInfo & ParentInformation>): void;
124
+ /**
125
+ * {@link RSymbol}
126
+ */
127
+ protected visitRSymbol(_node: RSymbol<OtherInfo & ParentInformation>): void;
128
+ }
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SyntaxAwareCfgGuidedVisitor = void 0;
4
+ const basic_cfg_guided_visitor_1 = require("./basic-cfg-guided-visitor");
5
+ const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
6
+ const assert_1 = require("../util/assert");
7
+ /**
8
+ * This visitor extends on the {@link BasicCfgGuidedVisitor} by dispatching visitors based on the AST type of the node.
9
+ *
10
+ * Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
11
+ */
12
+ class SyntaxAwareCfgGuidedVisitor extends basic_cfg_guided_visitor_1.BasicCfgGuidedVisitor {
13
+ /**
14
+ * Get the normalized AST node for the given id or fail if it does not exist.
15
+ */
16
+ getNormalizedAst(id) {
17
+ return this.config.normalizedAst.idMap.get(id);
18
+ }
19
+ onStatementNode(node) {
20
+ super.onStatementNode(node);
21
+ this.onExprOrStmtNode(node);
22
+ }
23
+ onExpressionNode(node) {
24
+ super.onExpressionNode(node);
25
+ this.onExprOrStmtNode(node);
26
+ }
27
+ onExprOrStmtNode(node) {
28
+ const astVertex = this.getNormalizedAst(node.id);
29
+ if (!astVertex) {
30
+ return;
31
+ }
32
+ const type = astVertex.type;
33
+ switch (type) {
34
+ case type_1.RType.Access:
35
+ return this.visitRAccess(astVertex);
36
+ case type_1.RType.Argument:
37
+ return this.visitRArgument(astVertex);
38
+ case type_1.RType.BinaryOp:
39
+ return this.visitRBinaryOp(astVertex);
40
+ case type_1.RType.ExpressionList:
41
+ return this.visitRExpressionList(astVertex);
42
+ case type_1.RType.ForLoop:
43
+ return this.visitRForLoop(astVertex);
44
+ case type_1.RType.FunctionCall:
45
+ return this.visitRFunctionCall(astVertex);
46
+ case type_1.RType.FunctionDefinition:
47
+ return this.visitRFunctionDefinition(astVertex);
48
+ case type_1.RType.IfThenElse:
49
+ return this.visitRIfThenElse(astVertex);
50
+ case type_1.RType.Parameter:
51
+ return this.visitRParameter(astVertex);
52
+ case type_1.RType.Pipe:
53
+ return this.visitRPipe(astVertex);
54
+ case type_1.RType.RepeatLoop:
55
+ return this.visitRRepeatLoop(astVertex);
56
+ case type_1.RType.UnaryOp:
57
+ return this.visitRUnaryOp(astVertex);
58
+ case type_1.RType.WhileLoop:
59
+ return this.visitRWhileLoop(astVertex);
60
+ case type_1.RType.Break:
61
+ return this.visitRBreak(astVertex);
62
+ case type_1.RType.Comment:
63
+ return this.visitRComment(astVertex);
64
+ case type_1.RType.LineDirective:
65
+ return this.visitRLineDirective(astVertex);
66
+ case type_1.RType.Logical:
67
+ return this.visitRLogical(astVertex);
68
+ case type_1.RType.Next:
69
+ return this.visitRNext(astVertex);
70
+ case type_1.RType.Number:
71
+ return this.visitRNumber(astVertex);
72
+ case type_1.RType.String:
73
+ return this.visitRString(astVertex);
74
+ case type_1.RType.Symbol:
75
+ return this.visitRSymbol(astVertex);
76
+ default:
77
+ (0, assert_1.assertUnreachable)(type);
78
+ }
79
+ }
80
+ /**
81
+ * {@link RAccess}
82
+ */
83
+ visitRAccess(_node) { }
84
+ /**
85
+ * {@link RArgument}
86
+ */
87
+ visitRArgument(_node) { }
88
+ /**
89
+ * {@link RBinaryOp}
90
+ */
91
+ visitRBinaryOp(_node) { }
92
+ /**
93
+ * {@link RExpressionList}
94
+ */
95
+ visitRExpressionList(_node) { }
96
+ /**
97
+ * {@link RForLoop}
98
+ */
99
+ visitRForLoop(_node) { }
100
+ /**
101
+ * {@link RFunctionCall}
102
+ */
103
+ visitRFunctionCall(_node) { }
104
+ /**
105
+ * {@link RFunctionDefinition}
106
+ */
107
+ visitRFunctionDefinition(_node) { }
108
+ /**
109
+ * {@link RIfThenElse}
110
+ */
111
+ visitRIfThenElse(_node) { }
112
+ /**
113
+ * {@link RParameter}
114
+ */
115
+ visitRParameter(_node) { }
116
+ /**
117
+ * {@link RPipe}
118
+ */
119
+ visitRPipe(_node) { }
120
+ /**
121
+ * {@link RRepeatLoop}
122
+ */
123
+ visitRRepeatLoop(_node) { }
124
+ /**
125
+ * {@link RUnaryOp}
126
+ */
127
+ visitRUnaryOp(_node) { }
128
+ /**
129
+ * {@link RWhileLoop}
130
+ */
131
+ visitRWhileLoop(_node) { }
132
+ /**
133
+ * {@link RBreak}
134
+ */
135
+ visitRBreak(_node) { }
136
+ /**
137
+ * {@link RComment}
138
+ */
139
+ visitRComment(_node) { }
140
+ /**
141
+ * {@link RLineDirective}
142
+ */
143
+ visitRLineDirective(_node) { }
144
+ /**
145
+ * {@link RLogical}
146
+ */
147
+ visitRLogical(_node) { }
148
+ /**
149
+ * {@link RNext}
150
+ */
151
+ visitRNext(_node) { }
152
+ /**
153
+ * {@link RNumber}
154
+ */
155
+ visitRNumber(_node) { }
156
+ /**
157
+ * {@link RString}
158
+ */
159
+ visitRString(_node) { }
160
+ /**
161
+ * {@link RSymbol}
162
+ */
163
+ visitRSymbol(_node) { }
164
+ }
165
+ exports.SyntaxAwareCfgGuidedVisitor = SyntaxAwareCfgGuidedVisitor;
166
+ //# sourceMappingURL=syntax-cfg-guided-visitor.js.map
@@ -1,5 +1,5 @@
1
1
  import type { IPipelineStep, StepProcessingFunction } from '../steps/pipeline-step';
2
- import type { TailOfArray } from '../../util/arrays';
2
+ import type { TailOfArray } from '../../util/collections/arrays';
3
3
  /**
4
4
  * Defines the output format of a step that you are interested in.
5
5
  */
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sliceDiffAnsi = sliceDiffAnsi;
4
4
  const range_1 = require("../../util/range");
5
5
  const assert_1 = require("../../util/assert");
6
- const ansi_1 = require("../../util/ansi");
6
+ const ansi_1 = require("../../util/text/ansi");
7
7
  function grayOut() {
8
8
  return ansi_1.ansiFormatter.getFormatString({ color: 7 /* Colors.White */, effect: ansi_1.ColorEffect.Foreground, style: 2 /* FontStyles.Faint */ });
9
9
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.verifyAndBuildPipeline = verifyAndBuildPipeline;
4
4
  const invalid_pipeline_error_1 = require("./invalid-pipeline-error");
5
5
  const json_1 = require("../../../util/json");
6
- const arrays_1 = require("../../../util/arrays");
6
+ const arrays_1 = require("../../../util/collections/arrays");
7
7
  /**
8
8
  * Given a set of {@link IPipelineStep|steps} with their dependencies, this function verifies all requirements of {@link createPipeline}.
9
9
  */
@@ -9,13 +9,14 @@ const identifier_1 = require("./identifier");
9
9
  const assert_1 = require("../../util/assert");
10
10
  function registerBuiltInConstant({ names, value, assumePrimitive }) {
11
11
  for (const name of names) {
12
+ const id = (0, built_in_1.builtInId)(name);
12
13
  const d = [{
13
14
  type: identifier_1.ReferenceType.BuiltInConstant,
14
- definedAt: built_in_1.BuiltIn,
15
+ definedAt: id,
15
16
  controlDependencies: undefined,
16
17
  value,
17
18
  name,
18
- nodeId: built_in_1.BuiltIn
19
+ nodeId: id
19
20
  }];
20
21
  built_in_1.BuiltInMemory.set(name, d);
21
22
  if (assumePrimitive) {
@@ -28,15 +29,16 @@ function registerBuiltInFunctions({ names, processor, config, assumePrimitive })
28
29
  (0, assert_1.guard)(mappedProcessor !== undefined, () => `Processor for ${processor} is undefined! Please pass a valid builtin name ${JSON.stringify(Object.keys(built_in_1.BuiltInProcessorMapper))}!`);
29
30
  for (const name of names) {
30
31
  (0, assert_1.guard)(processor !== undefined, `Processor for ${name} is undefined, maybe you have an import loop? You may run 'npm run detect-circular-deps' - although by far not all are bad`);
32
+ const id = (0, built_in_1.builtInId)(name);
31
33
  const d = [{
32
34
  type: identifier_1.ReferenceType.BuiltInFunction,
33
- definedAt: built_in_1.BuiltIn,
35
+ definedAt: id,
34
36
  controlDependencies: undefined,
35
37
  /* eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument */
36
38
  processor: (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config),
37
39
  config,
38
40
  name,
39
- nodeId: built_in_1.BuiltIn
41
+ nodeId: id
40
42
  }];
41
43
  built_in_1.BuiltInMemory.set(name, d);
42
44
  if (assumePrimitive) {
@@ -51,9 +53,10 @@ function registerReplacementFunctions({ names, suffixes, assumePrimitive, config
51
53
  for (const assignment of names) {
52
54
  for (const suffix of suffixes) {
53
55
  const effectiveName = `${assignment}${suffix}`;
56
+ const id = (0, built_in_1.builtInId)(effectiveName);
54
57
  const d = [{
55
58
  type: identifier_1.ReferenceType.BuiltInFunction,
56
- definedAt: built_in_1.BuiltIn,
59
+ definedAt: id,
57
60
  processor: (name, args, rootId, data) => replacer(name, args, rootId, data, { makeMaybe: true, assignmentOperator: suffix, readIndices: config.readIndices }),
58
61
  config: {
59
62
  ...config,
@@ -62,7 +65,7 @@ function registerReplacementFunctions({ names, suffixes, assumePrimitive, config
62
65
  },
63
66
  name: effectiveName,
64
67
  controlDependencies: undefined,
65
- nodeId: built_in_1.BuiltIn
68
+ nodeId: id
66
69
  }];
67
70
  built_in_1.BuiltInMemory.set(effectiveName, d);
68
71
  if (assumePrimitive) {
@@ -1,5 +1,5 @@
1
1
  import type { DataflowProcessorInformation } from '../processor';
2
- import type { ExitPointType, DataflowInformation } from '../info';
2
+ import type { DataflowInformation, ExitPointType } from '../info';
3
3
  import { processAccess } from '../internal/process/functions/call/built-in/built-in-access';
4
4
  import { processIfThenElse } from '../internal/process/functions/call/built-in/built-in-if-then-else';
5
5
  import { processAssignment } from '../internal/process/functions/call/built-in/built-in-assignment';
@@ -28,18 +28,20 @@ import { processList } from '../internal/process/functions/call/built-in/built-i
28
28
  import { processVector } from '../internal/process/functions/call/built-in/built-in-vector';
29
29
  import { processRm } from '../internal/process/functions/call/built-in/built-in-rm';
30
30
  import { processEvalCall } from '../internal/process/functions/call/built-in/built-in-eval';
31
- export declare const BuiltIn = "built-in";
31
+ export type BuiltIn = `built-in:${string}`;
32
+ export declare function builtInId(name: string): BuiltIn;
33
+ export declare function isBuiltIn(name: NodeId | string): name is BuiltIn;
32
34
  export type BuiltInIdentifierProcessor = <OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>) => DataflowInformation;
33
35
  export type BuiltInIdentifierProcessorWithConfig<Config> = <OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: Config) => DataflowInformation;
34
36
  export interface BuiltInIdentifierDefinition extends IdentifierReference {
35
37
  type: ReferenceType.BuiltInFunction;
36
- definedAt: typeof BuiltIn;
38
+ definedAt: BuiltIn;
37
39
  processor: BuiltInIdentifierProcessor;
38
40
  config?: object;
39
41
  }
40
42
  export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierReference {
41
43
  type: ReferenceType.BuiltInConstant;
42
- definedAt: typeof BuiltIn;
44
+ definedAt: BuiltIn;
43
45
  value: T;
44
46
  }
45
47
  export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
@@ -47,6 +49,8 @@ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
47
49
  readonly cfg?: ExitPointType;
48
50
  readonly readAllArguments?: boolean;
49
51
  readonly hasUnknownSideEffects?: boolean | LinkTo<RegExp | string>;
52
+ /** record mapping the actual function name called to the arguments that should be treated as function calls */
53
+ readonly treatAsFnCall?: Record<string, readonly string[]>;
50
54
  }
51
55
  declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: DefaultBuiltInProcessorConfiguration): DataflowInformation;
52
56
  export declare function registerBuiltInFunctions<Config extends object, Proc extends BuiltInIdentifierProcessorWithConfig<Config>>(both: boolean, names: readonly Identifier[], processor: Proc, config: Config): void;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptyBuiltInMemory = exports.BuiltInMemory = exports.BuiltInProcessorMapper = exports.BuiltIn = void 0;
3
+ exports.EmptyBuiltInMemory = exports.BuiltInMemory = exports.BuiltInProcessorMapper = void 0;
4
+ exports.builtInId = builtInId;
5
+ exports.isBuiltIn = isBuiltIn;
4
6
  exports.registerBuiltInFunctions = registerBuiltInFunctions;
5
7
  const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
6
8
  const built_in_access_1 = require("../internal/process/functions/call/built-in/built-in-access");
@@ -18,6 +20,7 @@ const built_in_quote_1 = require("../internal/process/functions/call/built-in/bu
18
20
  const built_in_function_definition_1 = require("../internal/process/functions/call/built-in/built-in-function-definition");
19
21
  const built_in_expression_list_1 = require("../internal/process/functions/call/built-in/built-in-expression-list");
20
22
  const built_in_get_1 = require("../internal/process/functions/call/built-in/built-in-get");
23
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
21
24
  const edge_1 = require("../graph/edge");
22
25
  const built_in_library_1 = require("../internal/process/functions/call/built-in/built-in-library");
23
26
  const built_in_source_1 = require("../internal/process/functions/call/built-in/built-in-source");
@@ -28,9 +31,16 @@ const built_in_list_1 = require("../internal/process/functions/call/built-in/bui
28
31
  const built_in_vector_1 = require("../internal/process/functions/call/built-in/built-in-vector");
29
32
  const built_in_rm_1 = require("../internal/process/functions/call/built-in/built-in-rm");
30
33
  const built_in_eval_1 = require("../internal/process/functions/call/built-in/built-in-eval");
31
- exports.BuiltIn = 'built-in';
34
+ const vertex_1 = require("../graph/vertex");
35
+ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
36
+ function builtInId(name) {
37
+ return `built-in:${name}`;
38
+ }
39
+ function isBuiltIn(name) {
40
+ return String(name).startsWith('built-in:');
41
+ }
32
42
  function defaultBuiltInProcessor(name, args, rootId, data, config) {
33
- const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs });
43
+ const { information: res, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: 'builtin:default' });
34
44
  if (config.returnsNthArgument !== undefined) {
35
45
  const arg = config.returnsNthArgument === 'last' ? processedArguments[args.length - 1] : processedArguments[config.returnsNthArgument];
36
46
  if (arg !== undefined) {
@@ -52,6 +62,37 @@ function defaultBuiltInProcessor(name, args, rootId, data, config) {
52
62
  res.graph.markIdForUnknownSideEffects(rootId);
53
63
  }
54
64
  }
65
+ const fnCallNames = config.treatAsFnCall?.[name.content];
66
+ if (fnCallNames) {
67
+ for (const arg of args) {
68
+ if (arg !== r_function_call_1.EmptyArgument && arg.value && fnCallNames.includes(arg.name?.content)) {
69
+ const rhs = arg.value;
70
+ let fnName;
71
+ let fnId;
72
+ if (rhs.type === type_1.RType.String) {
73
+ fnName = rhs.content.str;
74
+ fnId = rhs.info.id;
75
+ }
76
+ else if (rhs.type === type_1.RType.Symbol) {
77
+ fnName = rhs.content;
78
+ fnId = rhs.info.id;
79
+ }
80
+ else {
81
+ continue;
82
+ }
83
+ res.graph.updateToFunctionCall({
84
+ tag: vertex_1.VertexType.FunctionCall,
85
+ id: fnId,
86
+ name: fnName,
87
+ args: [],
88
+ environment: data.environment,
89
+ onlyBuiltin: false,
90
+ cds: data.controlDependencies,
91
+ origin: ['builtin:default']
92
+ });
93
+ }
94
+ }
95
+ }
55
96
  if (config.cfg !== undefined) {
56
97
  res.exitPoints = [...res.exitPoints, { type: config.cfg, nodeId: rootId, controlDependencies: data.controlDependencies }];
57
98
  }
@@ -60,14 +101,15 @@ function defaultBuiltInProcessor(name, args, rootId, data, config) {
60
101
  function registerBuiltInFunctions(both, names, processor, config) {
61
102
  for (const name of names) {
62
103
  (0, assert_1.guard)(processor !== undefined, `Processor for ${name} is undefined, maybe you have an import loop? You may run 'npm run detect-circular-deps' - although by far not all are bad`);
104
+ const id = builtInId(name);
63
105
  const d = [{
64
106
  type: identifier_1.ReferenceType.BuiltInFunction,
65
- definedAt: exports.BuiltIn,
107
+ definedAt: id,
66
108
  controlDependencies: undefined,
67
109
  processor: (name, args, rootId, data) => processor(name, args, rootId, data, config),
68
110
  config,
69
111
  name,
70
- nodeId: exports.BuiltIn
112
+ nodeId: id
71
113
  }];
72
114
  exports.BuiltInMemory.set(name, d);
73
115
  if (both) {
@@ -1,5 +1,7 @@
1
1
  import type { BuiltInDefinitions } from './built-in-config';
2
+ import type { BuiltInMappingName } from './built-in';
2
3
  /**
3
4
  * Contains the built-in definitions recognized by flowR
4
5
  */
5
6
  export declare const DefaultBuiltinConfig: BuiltInDefinitions;
7
+ export declare function getDefaultProcessor(name: string): BuiltInMappingName | 'unnamed' | undefined;