@eagleoutice/flowr 2.8.15 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +20 -21
  2. package/abstract-interpretation/data-frame/mappers/access-mapper.d.ts +4 -3
  3. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -3
  4. package/abstract-interpretation/data-frame/mappers/arguments.d.ts +2 -1
  5. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -1
  6. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +4 -3
  7. package/abstract-interpretation/data-frame/mappers/function-mapper.js +13 -10
  8. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +7 -6
  9. package/abstract-interpretation/data-frame/resolve-args.js +2 -1
  10. package/benchmark/slicer.d.ts +0 -16
  11. package/benchmark/slicer.js +1 -48
  12. package/benchmark/stats/print.js +0 -6
  13. package/benchmark/stats/stats.d.ts +0 -3
  14. package/benchmark/summarizer/first-phase/process.js +1 -1
  15. package/benchmark/summarizer/second-phase/process.js +0 -6
  16. package/cli/benchmark-app.d.ts +0 -1
  17. package/cli/benchmark-app.js +0 -1
  18. package/cli/benchmark-helper-app.d.ts +0 -1
  19. package/cli/benchmark-helper-app.js +1 -5
  20. package/cli/common/options.d.ts +0 -10
  21. package/cli/common/options.js +0 -2
  22. package/cli/common/scripts-info.d.ts +0 -10
  23. package/cli/repl/server/connection.js +1 -1
  24. package/config.d.ts +0 -15
  25. package/config.js +0 -21
  26. package/control-flow/cfg-dead-code.js +0 -3
  27. package/control-flow/extract-cfg.js +4 -0
  28. package/control-flow/semantic-cfg-guided-visitor.d.ts +32 -0
  29. package/control-flow/semantic-cfg-guided-visitor.js +36 -4
  30. package/dataflow/cluster.js +2 -2
  31. package/dataflow/environments/built-in-config.d.ts +1 -0
  32. package/dataflow/environments/built-in.d.ts +19 -3
  33. package/dataflow/environments/built-in.js +25 -7
  34. package/dataflow/environments/default-builtin-config.d.ts +59 -8
  35. package/dataflow/environments/default-builtin-config.js +20 -6
  36. package/dataflow/environments/define.d.ts +4 -11
  37. package/dataflow/environments/define.js +16 -96
  38. package/dataflow/environments/diff.js +3 -2
  39. package/dataflow/environments/environment.d.ts +17 -6
  40. package/dataflow/environments/environment.js +69 -18
  41. package/dataflow/environments/identifier.d.ts +95 -7
  42. package/dataflow/environments/identifier.js +161 -1
  43. package/dataflow/environments/resolve-by-name.d.ts +4 -4
  44. package/dataflow/environments/resolve-by-name.js +29 -10
  45. package/dataflow/eval/resolve/alias-tracking.js +8 -1
  46. package/dataflow/eval/resolve/resolve.d.ts +10 -6
  47. package/dataflow/eval/resolve/resolve.js +12 -7
  48. package/dataflow/eval/values/general.js +1 -1
  49. package/dataflow/eval/values/r-value.d.ts +4 -1
  50. package/dataflow/eval/values/r-value.js +2 -0
  51. package/dataflow/extractor.js +6 -3
  52. package/dataflow/fn/higher-order-function.js +4 -4
  53. package/dataflow/graph/call-graph.d.ts +1 -1
  54. package/dataflow/graph/call-graph.js +10 -8
  55. package/dataflow/graph/diff-dataflow-graph.js +6 -4
  56. package/dataflow/graph/edge.d.ts +48 -31
  57. package/dataflow/graph/edge.js +66 -60
  58. package/dataflow/graph/graph.d.ts +7 -7
  59. package/dataflow/graph/quads.js +1 -1
  60. package/dataflow/graph/resolve-graph.js +1 -1
  61. package/dataflow/graph/unknown-replacement.d.ts +2 -1
  62. package/dataflow/graph/vertex.d.ts +2 -103
  63. package/dataflow/graph/vertex.js +0 -44
  64. package/dataflow/internal/linker.d.ts +2 -2
  65. package/dataflow/internal/linker.js +35 -19
  66. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +3 -65
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -6
  68. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +18 -51
  69. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +2 -1
  70. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -4
  71. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -2
  72. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +34 -9
  73. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -4
  74. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +2 -2
  75. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -2
  76. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +1 -69
  77. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-recall.d.ts +11 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +46 -0
  81. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -2
  83. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +30 -72
  84. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +12 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +27 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +19 -0
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +204 -0
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +2 -0
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +25 -4
  90. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +2 -1
  91. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +4 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -2
  93. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +1 -60
  94. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
  95. package/dataflow/internal/process/functions/call/common.d.ts +3 -1
  96. package/dataflow/internal/process/functions/call/common.js +4 -16
  97. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +6 -2
  98. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -3
  99. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -0
  100. package/dataflow/internal/process/functions/call/named-call-handling.js +1 -0
  101. package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +2 -1
  102. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -1
  103. package/dataflow/internal/process/functions/process-parameter.js +1 -1
  104. package/dataflow/internal/process/process-named-call.d.ts +2 -1
  105. package/dataflow/internal/process/process-named-call.js +0 -1
  106. package/dataflow/internal/process/process-symbol.d.ts +3 -1
  107. package/dataflow/internal/process/process-symbol.js +8 -5
  108. package/dataflow/origin/dfg-get-origin.d.ts +2 -2
  109. package/dataflow/origin/dfg-get-origin.js +4 -4
  110. package/dataflow/origin/dfg-get-symbol-refs.js +2 -2
  111. package/documentation/data/interface/doc-writing-code.d.ts +6 -0
  112. package/documentation/data/interface/doc-writing-code.js +175 -0
  113. package/documentation/doc-util/doc-types.d.ts +3 -1
  114. package/documentation/doc-util/doc-types.js +4 -2
  115. package/documentation/wiki-absint.js +2 -1
  116. package/documentation/wiki-analyzer.js +17 -2
  117. package/documentation/wiki-cfg.js +2 -2
  118. package/documentation/wiki-dataflow-graph.js +9 -8
  119. package/documentation/wiki-interface.js +8 -164
  120. package/documentation/wiki-mk/doc-context.d.ts +12 -1
  121. package/documentation/wiki-mk/doc-context.js +21 -4
  122. package/documentation/wiki-normalized-ast.js +5 -0
  123. package/linter/linter-rules.d.ts +3 -3
  124. package/linter/rules/absolute-path.js +23 -23
  125. package/linter/rules/dataframe-access-validation.js +2 -1
  126. package/linter/rules/deprecated-functions.d.ts +1 -1
  127. package/linter/rules/deprecated-functions.js +1 -1
  128. package/linter/rules/function-finder-util.d.ts +2 -2
  129. package/linter/rules/naming-convention.d.ts +9 -2
  130. package/linter/rules/naming-convention.js +38 -36
  131. package/linter/rules/network-functions.d.ts +1 -1
  132. package/linter/rules/seeded-randomness.d.ts +2 -2
  133. package/linter/rules/seeded-randomness.js +5 -4
  134. package/linter/rules/unused-definition.js +4 -4
  135. package/package.json +6 -5
  136. package/project/context/flowr-analyzer-context.d.ts +17 -1
  137. package/project/context/flowr-analyzer-context.js +17 -1
  138. package/project/context/flowr-analyzer-meta-context.d.ts +51 -0
  139. package/project/context/flowr-analyzer-meta-context.js +47 -0
  140. package/project/flowr-analyzer.d.ts +17 -1
  141. package/project/flowr-analyzer.js +18 -0
  142. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +15 -0
  143. package/project/plugins/file-plugins/files/flowr-description-file.js +26 -0
  144. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +40 -3
  145. package/project/plugins/file-plugins/files/flowr-namespace-file.js +352 -9
  146. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.d.ts +1 -1
  147. package/project/plugins/file-plugins/flowr-analyzer-namespace-files-plugin.js +2 -2
  148. package/project/plugins/flowr-analyzer-plugin-defaults.js +2 -0
  149. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +1 -1
  150. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.d.ts +12 -0
  151. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +42 -0
  152. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +1 -1
  153. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -2
  154. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.d.ts +1 -1
  155. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +2 -2
  156. package/project/plugins/plugin-registry.d.ts +2 -1
  157. package/project/plugins/plugin-registry.js +2 -0
  158. package/queries/catalog/call-context-query/call-context-query-executor.js +6 -4
  159. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -1
  160. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -3
  161. package/queries/catalog/dependencies-query/dependencies-query-format.js +5 -3
  162. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  163. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -2
  164. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -1
  165. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -1
  166. package/r-bridge/data/data.d.ts +12 -7
  167. package/r-bridge/data/data.js +13 -7
  168. package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -12
  169. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -1
  170. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -1
  171. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +7 -3
  172. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +2 -1
  173. package/r-bridge/lang-4.x/ast/model/type.d.ts +1 -1
  174. package/r-bridge/lang-4.x/ast/model/type.js +1 -1
  175. package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -1
  176. package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +5 -5
  177. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -3
  178. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -5
  179. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  180. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +2 -2
  181. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-break.js +1 -1
  182. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-for.js +1 -1
  183. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -1
  184. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -1
  185. package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +1 -1
  186. package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +2 -2
  187. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -3
  188. package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +1 -1
  189. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-comment.js +1 -1
  190. package/r-bridge/lang-4.x/ast/parser/main/internal/other/normalize-line-directive.js +2 -2
  191. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -3
  192. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
  193. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -2
  194. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  195. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.d.ts +1 -2
  196. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +13 -14
  197. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +24 -31
  198. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  199. package/reconstruct/auto-select/magic-comments.js +1 -1
  200. package/reconstruct/reconstruct.js +6 -5
  201. package/search/flowr-search-filters.js +2 -1
  202. package/search/search-executor/search-enrichers.d.ts +1 -2
  203. package/search/search-executor/search-enrichers.js +2 -1
  204. package/slicing/static/slice-call.d.ts +1 -1
  205. package/slicing/static/slice-call.js +8 -8
  206. package/slicing/static/static-slicer.js +2 -2
  207. package/statistics/features/common-syntax-probability.js +3 -2
  208. package/statistics/features/supported/defined-functions/defined-functions.js +3 -3
  209. package/statistics/features/supported/used-functions/used-functions.js +3 -2
  210. package/util/mermaid/dfg.js +3 -3
  211. package/util/r-value.d.ts +3 -2
  212. package/util/r-value.js +3 -0
  213. package/util/simple-df/dfg-ascii.js +5 -5
  214. package/util/version.js +1 -1
  215. package/util/containers.d.ts +0 -66
  216. package/util/containers.js +0 -143
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * An edge consist of only of the type (source and target are encoded with the Dataflow Graph).
3
3
  * Multiple edges are encoded by joining the respective type bits.
4
+ * @see {@link EdgeType} for the basis.
5
+ * @see {@link DfEdge} for helper functions.
4
6
  */
5
- export interface DataflowGraphEdge {
7
+ export interface DfEdge {
6
8
  types: EdgeTypeBits;
7
9
  }
8
10
  /**
9
11
  * Represents the relationship between the source and the target vertex in the dataflow graph.
10
- * The actual value is represented as a bitmask so use {@link edgeTypesToNames} to get something more human-readable.
11
- * Similarly, you can access {@link EdgeTypeName} to access the name counterpart.
12
+ * The actual value is represented as a bitmask, so please refer to {@link DfEdge} for helpful functions.
12
13
  */
13
14
  export declare enum EdgeType {
14
15
  /** The edge determines that source reads target */
@@ -51,19 +52,50 @@ export declare const enum EdgeTypeName {
51
52
  NonStandardEvaluation = "non-standard-evaluation"
52
53
  }
53
54
  export type EdgeTypeBits = number;
55
+ type DfEdgeLike = {
56
+ types: number;
57
+ };
54
58
  /**
55
- * Only use this function to retrieve a human-readable name if you know that it is a single bitmask.
56
- * Otherwise, use {@link edgeTypesToNames} which handles these cases.
59
+ * Helper Functions to work with {@link DfEdge} and {@link EdgeType}.
57
60
  */
58
- export declare function edgeTypeToName(type: EdgeType): string;
59
- /**
60
- * Takes joint edge types and splits them into their individual components.
61
- */
62
- export declare function splitEdgeTypes(types: EdgeTypeBits): EdgeType[];
63
- /**
64
- * Takes joint edge types and returns their human-readable names.
65
- */
66
- export declare function edgeTypesToNames(bits: EdgeTypeBits): Set<EdgeTypeName>;
61
+ export declare const DfEdge: {
62
+ /**
63
+ * Takes joint edge types and returns their human-readable names.
64
+ */
65
+ readonly typesToNames: (this: void, { types }: DfEdgeLike) => Set<EdgeTypeName>;
66
+ /**
67
+ * Takes joint edge types and splits them into their individual components.
68
+ * @example
69
+ * ```ts
70
+ * DfEdge.splitTypes({ types: EdgeType.Reads | EdgeType.DefinedBy });
71
+ * // returns [EdgeType.Reads, EdgeType.DefinedBy]
72
+ * ```
73
+ */
74
+ readonly splitTypes: (this: void, { types }: DfEdgeLike) => EdgeType[];
75
+ /**
76
+ * Only use this function to retrieve a human-readable name if you know that it is a single bitmask.
77
+ * Otherwise, use {@link DfEdge#typesToNames} which handles these cases.
78
+ */
79
+ readonly typeToName: (this: void, type: EdgeType) => string;
80
+ /**
81
+ * Check if the given-edge type has any of the given types.
82
+ * As types are bitmasks, you can combine multiple types with a bitwise OR (`|`).
83
+ * @example
84
+ *
85
+ * ```ts
86
+ * edgeIncludesType({ types: EdgeType.Reads }, EdgeType.Reads | EdgeType.DefinedBy) // true
87
+ *```
88
+ *
89
+ * Counterpart of {@link DfEdge#doesNotIncludeType}.
90
+ */
91
+ readonly includesType: (this: void, { types }: DfEdgeLike, typesToInclude: EdgeType) => boolean;
92
+ /**
93
+ * Check if the given-edge type does not include the given type.
94
+ * As types are bitmasks, you can combine multiple types with a bitwise OR (`|`).
95
+ * Counterpart of {@link DfEdge#includesType}.
96
+ */
97
+ readonly doesNotIncludeType: (this: void, { types }: DfEdgeLike, any: EdgeType) => boolean;
98
+ };
67
99
  export declare const enum TraverseEdge {
68
100
  /** Do not traverse this edge */
69
101
  Never = 0,
@@ -74,23 +106,8 @@ export declare const enum TraverseEdge {
74
106
  /** Always traverse this edge */
75
107
  Always = 3
76
108
  }
77
- /**
78
- * Check if the given-edge type has any of the given types.
79
- * @example
80
- *
81
- * ```typescript
82
- * edgeIncludesType(EdgeType.Reads, EdgeType.Reads | EdgeType.DefinedBy) // true
83
- *```
84
- *
85
- * Counterpart of {@link edgeDoesNotIncludeType}.
86
- */
87
- export declare function edgeIncludesType(type: EdgeTypeBits, typesToInclude: EdgeTypeBits): boolean;
88
- /**
89
- * Check if the given-edge type does not include the given type.
90
- * Counterpart of {@link edgeIncludesType}.
91
- */
92
- export declare function edgeDoesNotIncludeType(type: EdgeTypeBits, types: EdgeTypeBits): boolean;
93
109
  /**
94
110
  * Determines whether an edge should be traversed during dataflow analysis.
95
111
  */
96
- export declare function shouldTraverseEdge(types: EdgeTypeBits): TraverseEdge;
112
+ export declare function shouldTraverseEdge(e: DfEdge): TraverseEdge;
113
+ export {};
@@ -1,16 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EdgeType = void 0;
4
- exports.edgeTypeToName = edgeTypeToName;
5
- exports.splitEdgeTypes = splitEdgeTypes;
6
- exports.edgeTypesToNames = edgeTypesToNames;
7
- exports.edgeIncludesType = edgeIncludesType;
8
- exports.edgeDoesNotIncludeType = edgeDoesNotIncludeType;
3
+ exports.DfEdge = exports.EdgeType = void 0;
9
4
  exports.shouldTraverseEdge = shouldTraverseEdge;
10
5
  /**
11
6
  * Represents the relationship between the source and the target vertex in the dataflow graph.
12
- * The actual value is represented as a bitmask so use {@link edgeTypesToNames} to get something more human-readable.
13
- * Similarly, you can access {@link EdgeTypeName} to access the name counterpart.
7
+ * The actual value is represented as a bitmask, so please refer to {@link DfEdge} for helpful functions.
14
8
  */
15
9
  var EdgeType;
16
10
  (function (EdgeType) {
@@ -51,72 +45,84 @@ const edgeTypeToHumanReadableName = new Map([
51
45
  [EdgeType.NonStandardEvaluation, "non-standard-evaluation" /* EdgeTypeName.NonStandardEvaluation */]
52
46
  ]);
53
47
  /**
54
- * Only use this function to retrieve a human-readable name if you know that it is a single bitmask.
55
- * Otherwise, use {@link edgeTypesToNames} which handles these cases.
48
+ * Helper Functions to work with {@link DfEdge} and {@link EdgeType}.
56
49
  */
57
- function edgeTypeToName(type) {
58
- return edgeTypeToHumanReadableName.get(type);
59
- }
60
- /**
61
- * Takes joint edge types and splits them into their individual components.
62
- */
63
- function splitEdgeTypes(types) {
64
- const split = [];
65
- for (const bit of edgeTypeToHumanReadableName.keys()) {
66
- if ((types & bit) !== 0) {
67
- split.push(bit);
50
+ exports.DfEdge = {
51
+ /**
52
+ * Takes joint edge types and returns their human-readable names.
53
+ */
54
+ typesToNames({ types }) {
55
+ const rTypes = new Set();
56
+ for (const [bit, name] of edgeTypeToHumanReadableName.entries()) {
57
+ if ((types & bit) !== 0) {
58
+ rTypes.add(name);
59
+ }
68
60
  }
69
- }
70
- return split;
71
- }
72
- /**
73
- * Takes joint edge types and returns their human-readable names.
74
- */
75
- function edgeTypesToNames(bits) {
76
- const types = new Set();
77
- for (const [bit, name] of edgeTypeToHumanReadableName.entries()) {
78
- if ((bits & bit) !== 0) {
79
- types.add(name);
61
+ return rTypes;
62
+ },
63
+ /**
64
+ * Takes joint edge types and splits them into their individual components.
65
+ * @example
66
+ * ```ts
67
+ * DfEdge.splitTypes({ types: EdgeType.Reads | EdgeType.DefinedBy });
68
+ * // returns [EdgeType.Reads, EdgeType.DefinedBy]
69
+ * ```
70
+ */
71
+ splitTypes({ types }) {
72
+ const split = [];
73
+ for (const bit of edgeTypeToHumanReadableName.keys()) {
74
+ if ((types & bit) !== 0) {
75
+ split.push(bit);
76
+ }
80
77
  }
81
- }
82
- return types;
83
- }
84
- /**
85
- * Check if the given-edge type has any of the given types.
86
- * @example
87
- *
88
- * ```typescript
89
- * edgeIncludesType(EdgeType.Reads, EdgeType.Reads | EdgeType.DefinedBy) // true
90
- *```
91
- *
92
- * Counterpart of {@link edgeDoesNotIncludeType}.
93
- */
94
- function edgeIncludesType(type, typesToInclude) {
95
- return (typesToInclude & type) !== 0;
96
- }
97
- /**
98
- * Check if the given-edge type does not include the given type.
99
- * Counterpart of {@link edgeIncludesType}.
100
- */
101
- function edgeDoesNotIncludeType(type, types) {
102
- return (types & type) === 0;
103
- }
78
+ return split;
79
+ },
80
+ /**
81
+ * Only use this function to retrieve a human-readable name if you know that it is a single bitmask.
82
+ * Otherwise, use {@link DfEdge#typesToNames} which handles these cases.
83
+ */
84
+ typeToName(type) {
85
+ return edgeTypeToHumanReadableName.get(type);
86
+ },
87
+ /**
88
+ * Check if the given-edge type has any of the given types.
89
+ * As types are bitmasks, you can combine multiple types with a bitwise OR (`|`).
90
+ * @example
91
+ *
92
+ * ```ts
93
+ * edgeIncludesType({ types: EdgeType.Reads }, EdgeType.Reads | EdgeType.DefinedBy) // true
94
+ *```
95
+ *
96
+ * Counterpart of {@link DfEdge#doesNotIncludeType}.
97
+ */
98
+ includesType({ types }, typesToInclude) {
99
+ return (typesToInclude & types) !== 0;
100
+ },
101
+ /**
102
+ * Check if the given-edge type does not include the given type.
103
+ * As types are bitmasks, you can combine multiple types with a bitwise OR (`|`).
104
+ * Counterpart of {@link DfEdge#includesType}.
105
+ */
106
+ doesNotIncludeType({ types }, any) {
107
+ return (any & types) === 0;
108
+ },
109
+ };
104
110
  const alwaysTraverseEdgeTypes = EdgeType.Reads | EdgeType.DefinedBy | EdgeType.Argument | EdgeType.Calls;
105
111
  const definedByOnCallTypes = EdgeType.DefinesOnCall | EdgeType.DefinedByOnCall;
106
112
  /**
107
113
  * Determines whether an edge should be traversed during dataflow analysis.
108
114
  */
109
- function shouldTraverseEdge(types) {
110
- if (edgeIncludesType(types, EdgeType.NonStandardEvaluation)) {
115
+ function shouldTraverseEdge(e) {
116
+ if (exports.DfEdge.includesType(e, EdgeType.NonStandardEvaluation)) {
111
117
  return 0 /* TraverseEdge.Never */;
112
118
  }
113
- else if (edgeIncludesType(types, alwaysTraverseEdgeTypes)) {
119
+ else if (exports.DfEdge.includesType(e, alwaysTraverseEdgeTypes)) {
114
120
  return 3 /* TraverseEdge.Always */;
115
121
  }
116
- else if (edgeIncludesType(types, definedByOnCallTypes)) {
122
+ else if (exports.DfEdge.includesType(e, definedByOnCallTypes)) {
117
123
  return 2 /* TraverseEdge.OnlyIfBoth */;
118
124
  }
119
- else if (edgeIncludesType(types, EdgeType.SideEffectOnCall)) {
125
+ else if (exports.DfEdge.includesType(e, EdgeType.SideEffectOnCall)) {
120
126
  return 1 /* TraverseEdge.SideEffect */;
121
127
  }
122
128
  return 0 /* TraverseEdge.Never */;
@@ -1,8 +1,8 @@
1
- import type { DataflowGraphEdge, EdgeType } from './edge';
1
+ import type { DfEdge, EdgeType } from './edge';
2
2
  import type { DataflowInformation } from '../info';
3
3
  import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall, type DataflowGraphVertexInfo } from './vertex';
4
4
  import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
- import type { Identifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
5
+ import type { BrandedIdentifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
6
6
  import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import { type REnvironmentInformation } from '../environments/environment';
8
8
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -55,19 +55,19 @@ export declare function getReferenceOfArgument(arg: FunctionArgument): NodeId |
55
55
  /**
56
56
  * Maps the edges target to the edge information
57
57
  */
58
- export type OutgoingEdges<Edge extends DataflowGraphEdge = DataflowGraphEdge> = Map<NodeId, Edge>;
58
+ export type OutgoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
59
59
  /**
60
60
  * Similar to {@link OutgoingEdges}, but inverted regarding the edge direction.
61
61
  * In other words, it maps the source to the edge information.
62
62
  */
63
- export type IngoingEdges<Edge extends DataflowGraphEdge = DataflowGraphEdge> = Map<NodeId, Edge>;
63
+ export type IngoingEdges<Edge extends DfEdge = DfEdge> = Map<NodeId, Edge>;
64
64
  /**
65
65
  * The structure of the serialized {@link DataflowGraph}.
66
66
  */
67
67
  export interface DataflowGraphJson {
68
68
  readonly rootVertices: NodeId[];
69
69
  readonly vertexInformation: [NodeId, DataflowGraphVertexInfo][];
70
- readonly edgeInformation: [NodeId, [NodeId, DataflowGraphEdge][]][];
70
+ readonly edgeInformation: [NodeId, [NodeId, DfEdge][]][];
71
71
  readonly _unknownSideEffects: UnknownSideEffect[];
72
72
  }
73
73
  /**
@@ -95,7 +95,7 @@ export type UnknownSideEffect = NodeId | {
95
95
  * @see {@link DataflowGraph#fromJson|`fromJson`} - to construct a dataflow graph object from a deserialized JSON object.
96
96
  * @see {@link emptyGraph|`emptyGraph`} - to create an empty graph (useful in tests)
97
97
  */
98
- export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo, Edge extends DataflowGraphEdge = DataflowGraphEdge> {
98
+ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo, Edge extends DfEdge = DfEdge> {
99
99
  private _idMap;
100
100
  private readonly _unknownSideEffects;
101
101
  constructor(idMap: AstIdMap | undefined);
@@ -219,6 +219,6 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
219
219
  export interface IEnvironmentJson {
220
220
  readonly id: number;
221
221
  parent: IEnvironmentJson;
222
- memory: Record<Identifier, IdentifierDefinition[]>;
222
+ memory: Record<BrandedIdentifier, IdentifierDefinition[]>;
223
223
  builtInEnv: true | undefined;
224
224
  }
@@ -19,7 +19,7 @@ function df2quads(graph, config) {
19
19
  edges: graph.edges().flatMap(([fromId, targets]) => [...targets].map(([toId, info]) => ({
20
20
  from: fromId,
21
21
  to: toId,
22
- type: [...(0, edge_1.edgeTypesToNames)(info.types)],
22
+ type: Array.from(edge_1.DfEdge.typesToNames(info)),
23
23
  }))).toArray()
24
24
  }, config);
25
25
  }
@@ -41,7 +41,7 @@ function resolveDataflowGraph(graph, ctx, idMap) {
41
41
  /* recreate edges */
42
42
  for (const [from, targets] of graph.edges()) {
43
43
  for (const [to, info] of targets) {
44
- for (const type of (0, edge_1.splitEdgeTypes)(info.types)) {
44
+ for (const type of edge_1.DfEdge.splitTypes(info)) {
45
45
  resultGraph.addEdge(resolve(from), resolve(to), type);
46
46
  }
47
47
  }
@@ -1,7 +1,8 @@
1
1
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
2
  import type { REnvironmentInformation } from '../environments/environment';
3
+ import type { Identifier } from '../environments/identifier';
3
4
  export type ReplacementOperatorHandlerArgs = {
4
- operator: string;
5
+ operator: Identifier;
5
6
  target: string | undefined;
6
7
  env: REnvironmentInformation;
7
8
  id: NodeId;
@@ -4,6 +4,7 @@ import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-i
4
4
  import type { REnvironmentInformation } from '../environments/environment';
5
5
  import type { ControlDependency, ExitPoint } from '../info';
6
6
  import type { BuiltInProcName } from '../environments/built-in';
7
+ import type { Identifier } from '../environments/identifier';
7
8
  export declare enum VertexType {
8
9
  Value = "value",
9
10
  Use = "use",
@@ -15,104 +16,6 @@ export declare const ValidVertexTypes: Set<string>;
15
16
  export declare const ValidVertexTypeReverse: {
16
17
  [k: string]: string;
17
18
  };
18
- /**
19
- * Identifier for arguments e.g. for `3` in `c(2, 3, 5)` the identifier would be
20
- * ```ts
21
- * {
22
- * index: 2
23
- * }
24
- * ```
25
- */
26
- export interface UnnamedArgumentId {
27
- readonly index: number;
28
- }
29
- /**
30
- * Identifier for named arguments e.g. for `age` in `list(name = 'John', age = 8)`
31
- * the indentifier would be
32
- * ```ts
33
- * {
34
- * index: 2,
35
- * lexeme: 'age'
36
- * }
37
- * ```
38
- */
39
- export interface NamedArgumentId {
40
- /**
41
- * Index may be undefined, when no index information is available.
42
- */
43
- readonly index: number | undefined;
44
- readonly lexeme: string;
45
- }
46
- /**
47
- * Type guard to check whether {@link identifier} is a {@link NamedArgumentId}.
48
- */
49
- export declare function isNamedArgumentId(identifier: IndexIdentifier): identifier is NamedArgumentId;
50
- export type IndexIdentifier = UnnamedArgumentId | NamedArgumentId;
51
- /**
52
- * A single index of a container, which is not a container itself.
53
- *
54
- * This can be e.g. a string, number or boolean index.
55
- */
56
- export interface ContainerLeafIndex {
57
- /**
58
- * Distinctive identifier of index, see {@link IndexIdentifier}.
59
- */
60
- readonly identifier: IndexIdentifier;
61
- /**
62
- * NodeId of index in graph.
63
- */
64
- readonly nodeId: NodeId;
65
- }
66
- /**
67
- * A single index of a container, which is a container itself.
68
- *
69
- * This can be, e.g., a list, vector, or data frame.
70
- * @see {@link ContainerLeafIndex} - for a single index of a container which is not a container itself
71
- * @see {@link isParentContainerIndex} - to check if an index is a parent container index
72
- */
73
- export interface ContainerParentIndex extends ContainerLeafIndex {
74
- /**
75
- * Sub-indices of index.
76
- */
77
- readonly subIndices: ContainerIndices[];
78
- }
79
- /**
80
- * Type guard to check whether {@link index} is a {@link ContainerParentIndex}.
81
- */
82
- export declare function isParentContainerIndex(index: ContainerIndex): index is ContainerParentIndex;
83
- /**
84
- * A single index of a container.
85
- */
86
- export type ContainerIndex = ContainerLeafIndex | ContainerParentIndex;
87
- /**
88
- * Checks whether {@link index} is accessed by {@link accessLexeme}.
89
- * @param index - The {@link ContainerIndex}, which is accessed
90
- * @param accessLexeme - The access lexeme
91
- * @param isIndexBasedAccess - Whether the index of the {@link ContainerIndex} is accessed i.e. the position in the container and not e.g. the name of the index
92
- * @returns true, when {@link accessLexeme} accesses the {@link index}, false otherwise
93
- */
94
- export declare function isAccessed(index: ContainerIndex, accessLexeme: string, isIndexBasedAccess: boolean): boolean;
95
- /**
96
- * Checks whether two {@link ContainerIndex|container indices} are the same.
97
- */
98
- export declare function isSameIndex(a: ContainerIndex, b: ContainerIndex): boolean;
99
- /**
100
- * List of indices of a single statement like `list(a=3, b=2)`
101
- */
102
- export interface ContainerIndices {
103
- readonly indices: ContainerIndex[];
104
- /**
105
- * Differentiate between single and multiple indices.
106
- *
107
- * For `list(name = 'John')` `isContainer` would be true, because a list may define more than one index.
108
- * `isContainer` is true for e.g. single index assignments like `person$name <- 'John'`.
109
- */
110
- readonly isContainer: boolean;
111
- }
112
- /**
113
- * Collection of Indices of several statements.
114
- */
115
- export type ContainerIndicesCollection = ContainerIndices[] | undefined;
116
19
  /**
117
20
  * Arguments required to construct a vertex in the {@link DataflowGraph|dataflow graph}.
118
21
  * @see DataflowGraphVertexUse
@@ -138,10 +41,6 @@ interface DataflowGraphVertexBase extends MergeableRecord {
138
41
  * @see {@link ControlDependency} - the collection of control dependencies which have an influence on whether the vertex is executed.
139
42
  */
140
43
  cds: ControlDependency[] | undefined;
141
- /**
142
- * this attribute links a vertex to indices (pointer links) it may be affected by or related to
143
- */
144
- indicesCollection?: ContainerIndicesCollection;
145
44
  /**
146
45
  * Describes the collection of AST vertices that contributed to this vertex.
147
46
  * For example, this is useful with replacement operators, telling you which assignment operator caused them
@@ -198,7 +97,7 @@ export interface DataflowGraphVertexFunctionCall extends DataflowGraphVertexBase
198
97
  * For example, if the function is a replacement function, in this case, the actually called fn will
199
98
  * have the compound name (e.g., `[<-`).
200
99
  */
201
- readonly name: string;
100
+ readonly name: Identifier;
202
101
  /** The arguments of the function call, in order (as they are passed to the respective call if executed in R). */
203
102
  args: FunctionArgument[];
204
103
  /** a performance flag to indicate that the respective call is _only_ calling a builtin function without any df graph attached */
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0;
4
- exports.isNamedArgumentId = isNamedArgumentId;
5
- exports.isParentContainerIndex = isParentContainerIndex;
6
- exports.isAccessed = isAccessed;
7
- exports.isSameIndex = isSameIndex;
8
4
  exports.isValueVertex = isValueVertex;
9
5
  exports.isUseVertex = isUseVertex;
10
6
  exports.isFunctionCallVertex = isFunctionCallVertex;
@@ -20,46 +16,6 @@ var VertexType;
20
16
  })(VertexType || (exports.VertexType = VertexType = {}));
21
17
  exports.ValidVertexTypes = new Set(Object.values(VertexType));
22
18
  exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
23
- /**
24
- * Type guard to check whether {@link identifier} is a {@link NamedArgumentId}.
25
- */
26
- function isNamedArgumentId(identifier) {
27
- return 'lexeme' in identifier;
28
- }
29
- /**
30
- * Type guard to check whether {@link index} is a {@link ContainerParentIndex}.
31
- */
32
- function isParentContainerIndex(index) {
33
- return 'subIndices' in index;
34
- }
35
- /**
36
- * Checks whether {@link index} is accessed by {@link accessLexeme}.
37
- * @param index - The {@link ContainerIndex}, which is accessed
38
- * @param accessLexeme - The access lexeme
39
- * @param isIndexBasedAccess - Whether the index of the {@link ContainerIndex} is accessed i.e. the position in the container and not e.g. the name of the index
40
- * @returns true, when {@link accessLexeme} accesses the {@link index}, false otherwise
41
- */
42
- function isAccessed(index, accessLexeme, isIndexBasedAccess) {
43
- if (isIndexBasedAccess) {
44
- return index.identifier.index === Number(accessLexeme);
45
- }
46
- if (isNamedArgumentId(index.identifier)) {
47
- return index.identifier.lexeme === accessLexeme;
48
- }
49
- return false;
50
- }
51
- /**
52
- * Checks whether two {@link ContainerIndex|container indices} are the same.
53
- */
54
- function isSameIndex(a, b) {
55
- if (isNamedArgumentId(a.identifier) && isNamedArgumentId(b.identifier)) {
56
- return a.identifier.lexeme === b.identifier.lexeme;
57
- }
58
- if (a.identifier.index === undefined || b.identifier.index === undefined) {
59
- return false;
60
- }
61
- return a.identifier.index === b.identifier.index;
62
- }
63
19
  /**
64
20
  * Check if the given vertex is a {@link DataflowGraphVertexValue|value vertex}.
65
21
  */
@@ -1,6 +1,6 @@
1
1
  import { DefaultMap } from '../../util/collections/defaultmap';
2
2
  import { type NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
- import { type IdentifierReference } from '../environments/identifier';
3
+ import { Identifier, type IdentifierReference } from '../environments/identifier';
4
4
  import { type DataflowGraph, type FunctionArgument } from '../graph/graph';
5
5
  import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
6
6
  import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -8,7 +8,7 @@ import { type DataflowGraphVertexFunctionCall, type DataflowGraphVertexFunctionD
8
8
  import { type BuiltIn } from '../environments/built-in';
9
9
  import type { REnvironmentInformation } from '../environments/environment';
10
10
  import type { ExitPoint } from '../info';
11
- export type NameIdMap = DefaultMap<string, IdentifierReference[]>;
11
+ export type NameIdMap = DefaultMap<Identifier, IdentifierReference[]>;
12
12
  /**
13
13
  * Find all reads within the graph that do not reference a local definition in the graph.
14
14
  */