@eagleoutice/flowr 2.10.10 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/README.md +37 -29
  2. package/cli/common/options.d.ts +2 -108
  3. package/cli/common/options.js +3 -27
  4. package/cli/common/scripts-info.d.ts +2 -123
  5. package/cli/common/scripts-info.js +0 -17
  6. package/cli/flowr-main-options.d.ts +5 -0
  7. package/cli/flowr-main-options.js +10 -0
  8. package/cli/flowr.js +1 -1
  9. package/cli/repl/print-version.d.ts +3 -1
  10. package/cli/repl/print-version.js +21 -2
  11. package/cli/repl/server/connection.d.ts +2 -0
  12. package/cli/repl/server/connection.js +40 -31
  13. package/cli/script-core/summarizer-core.js +13 -32
  14. package/cli/wiki.d.ts +2 -1
  15. package/cli/wiki.js +2 -0
  16. package/config.d.ts +13 -0
  17. package/config.js +8 -0
  18. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  19. package/core/steps/pipeline/default-pipelines.d.ts +146 -146
  20. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  21. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  22. package/dataflow/environments/append.d.ts +1 -2
  23. package/dataflow/environments/append.js +3 -10
  24. package/dataflow/environments/apply-kill.d.ts +21 -0
  25. package/dataflow/environments/apply-kill.js +155 -0
  26. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  27. package/dataflow/environments/built-in-proc-name.js +2 -0
  28. package/dataflow/environments/built-in.d.ts +2 -0
  29. package/dataflow/environments/built-in.js +2 -0
  30. package/dataflow/environments/default-builtin-config.d.ts +63 -3
  31. package/dataflow/environments/default-builtin-config.js +40 -8
  32. package/dataflow/environments/environment.d.ts +49 -32
  33. package/dataflow/environments/environment.js +133 -18
  34. package/dataflow/environments/identifier.d.ts +10 -0
  35. package/dataflow/environments/identifier.js +23 -0
  36. package/dataflow/environments/overwrite.js +2 -10
  37. package/dataflow/environments/resolve-by-name.d.ts +1 -1
  38. package/dataflow/environments/resolve-by-name.js +10 -2
  39. package/dataflow/environments/scoping.d.ts +9 -2
  40. package/dataflow/environments/scoping.js +15 -2
  41. package/dataflow/extractor.js +23 -2
  42. package/dataflow/graph/df-helper.d.ts +8 -0
  43. package/dataflow/graph/df-helper.js +8 -0
  44. package/dataflow/graph/graph.d.ts +4 -1
  45. package/dataflow/graph/graph.js +5 -1
  46. package/dataflow/info.d.ts +26 -0
  47. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -5
  48. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -0
  49. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +1 -8
  50. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +7 -13
  51. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +9 -48
  52. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +30 -47
  53. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +17 -0
  54. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -1
  55. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +2 -2
  56. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +8 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +9 -0
  58. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +37 -3
  59. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +391 -21
  60. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +2 -1
  61. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +131 -48
  62. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +25 -0
  63. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +94 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +10 -3
  65. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +30 -0
  66. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +279 -0
  67. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  68. package/dataflow/internal/process/functions/call/named-call-handling.js +17 -0
  69. package/documentation/data/faq/faqs.js +3 -0
  70. package/documentation/data/interface/doc-writing-code.js +4 -80
  71. package/documentation/doc-util/doc-structure.js +1 -2
  72. package/documentation/wiki-core.js +2 -1
  73. package/documentation/wiki-dataflow-graph.js +35 -1
  74. package/documentation/wiki-interface.js +3 -2
  75. package/documentation/wiki-linter.js +2 -0
  76. package/documentation/wiki-overview.js +1 -14
  77. package/documentation/wiki-package-database.d.ts +9 -0
  78. package/documentation/wiki-package-database.js +63 -0
  79. package/documentation/wiki-query.js +1 -0
  80. package/linter/linter-rules.d.ts +23 -0
  81. package/linter/linter-rules.js +3 -1
  82. package/linter/rules/absolute-path.js +2 -1
  83. package/linter/rules/undefined-symbol.d.ts +39 -0
  84. package/linter/rules/undefined-symbol.js +80 -0
  85. package/package.json +3 -4
  86. package/project/cache/flowr-analyzer-cache.d.ts +2 -0
  87. package/project/cache/flowr-analyzer-cache.js +9 -1
  88. package/project/context/flowr-analyzer-dependencies-context.d.ts +16 -8
  89. package/project/context/flowr-analyzer-dependencies-context.js +36 -4
  90. package/project/context/flowr-analyzer-environment-context.d.ts +2 -4
  91. package/project/context/flowr-analyzer-environment-context.js +3 -4
  92. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  93. package/project/context/flowr-file.d.ts +2 -0
  94. package/project/context/flowr-file.js +2 -0
  95. package/project/flowr-analyzer-builder.js +3 -0
  96. package/project/flowr-analyzer.d.ts +2 -1
  97. package/project/flowr-analyzer.js +3 -1
  98. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +13 -15
  99. package/project/plugins/file-plugins/files/flowr-namespace-file.js +36 -13
  100. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +27 -0
  101. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +41 -0
  102. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +18 -0
  103. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +62 -0
  104. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +63 -0
  105. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +174 -0
  106. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +10 -0
  107. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +6 -0
  108. package/project/plugins/package-version-plugins/package.d.ts +3 -0
  109. package/project/plugins/package-version-plugins/package.js +12 -0
  110. package/project/plugins/package-version-plugins/pkgdb.d.ts +133 -0
  111. package/project/plugins/package-version-plugins/pkgdb.js +370 -0
  112. package/project/plugins/plugin-registry.d.ts +4 -1
  113. package/project/plugins/plugin-registry.js +7 -0
  114. package/queries/catalog/call-context-query/call-context-query-executor.js +8 -0
  115. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -0
  116. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  117. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +8 -0
  118. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -3
  119. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +3 -1
  120. package/queries/catalog/dependencies-query/dependencies-query-format.js +3 -2
  121. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +1 -1
  122. package/queries/catalog/dependencies-query/function-info/other-path-functions.d.ts +2 -0
  123. package/queries/catalog/dependencies-query/function-info/other-path-functions.js +27 -0
  124. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -4
  125. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +3 -1
  126. package/queries/catalog/linter-query/linter-query-executor.js +1 -0
  127. package/r-bridge/data/data.d.ts +2 -2
  128. package/r-bridge/data/data.js +2 -2
  129. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +13 -4
  130. package/search/search-executor/search-enrichers.d.ts +1 -1
  131. package/search/search-executor/search-enrichers.js +7 -4
  132. package/util/mermaid/mermaid.d.ts +4 -0
  133. package/util/mermaid/mermaid.js +8 -1
  134. package/util/version.js +10 -2
  135. package/cli/common/features.d.ts +0 -9
  136. package/cli/common/features.js +0 -35
  137. package/cli/script-core/statistics-core.d.ts +0 -6
  138. package/cli/script-core/statistics-core.js +0 -104
  139. package/cli/script-core/statistics-helper-core.d.ts +0 -6
  140. package/cli/script-core/statistics-helper-core.js +0 -86
  141. package/cli/statistics-app.d.ts +0 -11
  142. package/cli/statistics-app.js +0 -16
  143. package/cli/statistics-helper-app.d.ts +0 -11
  144. package/cli/statistics-helper-app.js +0 -14
  145. package/statistics/features/common-syntax-probability.d.ts +0 -38
  146. package/statistics/features/common-syntax-probability.js +0 -169
  147. package/statistics/features/feature.d.ts +0 -179
  148. package/statistics/features/feature.js +0 -38
  149. package/statistics/features/post-processing.d.ts +0 -18
  150. package/statistics/features/post-processing.js +0 -26
  151. package/statistics/features/supported/assignments/assignments.d.ts +0 -12
  152. package/statistics/features/supported/assignments/assignments.js +0 -56
  153. package/statistics/features/supported/assignments/post-process.d.ts +0 -6
  154. package/statistics/features/supported/assignments/post-process.js +0 -126
  155. package/statistics/features/supported/comments/comments.d.ts +0 -18
  156. package/statistics/features/supported/comments/comments.js +0 -143
  157. package/statistics/features/supported/comments/post-process.d.ts +0 -6
  158. package/statistics/features/supported/comments/post-process.js +0 -51
  159. package/statistics/features/supported/control-flow/control-flow.d.ts +0 -17
  160. package/statistics/features/supported/control-flow/control-flow.js +0 -69
  161. package/statistics/features/supported/control-flow/post-process.d.ts +0 -6
  162. package/statistics/features/supported/control-flow/post-process.js +0 -66
  163. package/statistics/features/supported/data-access/data-access.d.ts +0 -15
  164. package/statistics/features/supported/data-access/data-access.js +0 -122
  165. package/statistics/features/supported/data-access/post-process.d.ts +0 -6
  166. package/statistics/features/supported/data-access/post-process.js +0 -108
  167. package/statistics/features/supported/defined-functions/defined-functions.d.ts +0 -34
  168. package/statistics/features/supported/defined-functions/defined-functions.js +0 -145
  169. package/statistics/features/supported/defined-functions/post-process.d.ts +0 -6
  170. package/statistics/features/supported/defined-functions/post-process.js +0 -168
  171. package/statistics/features/supported/expression-list/post-process.d.ts +0 -6
  172. package/statistics/features/supported/expression-list/post-process.js +0 -45
  173. package/statistics/features/supported/expression-list/statistics-expression-list.d.ts +0 -9
  174. package/statistics/features/supported/expression-list/statistics-expression-list.js +0 -37
  175. package/statistics/features/supported/loops/loops.d.ts +0 -20
  176. package/statistics/features/supported/loops/loops.js +0 -81
  177. package/statistics/features/supported/loops/post-process.d.ts +0 -6
  178. package/statistics/features/supported/loops/post-process.js +0 -73
  179. package/statistics/features/supported/used-functions/post-process.d.ts +0 -6
  180. package/statistics/features/supported/used-functions/post-process.js +0 -176
  181. package/statistics/features/supported/used-functions/used-functions.d.ts +0 -24
  182. package/statistics/features/supported/used-functions/used-functions.js +0 -99
  183. package/statistics/features/supported/used-packages/post-process.d.ts +0 -6
  184. package/statistics/features/supported/used-packages/post-process.js +0 -122
  185. package/statistics/features/supported/used-packages/used-packages.d.ts +0 -16
  186. package/statistics/features/supported/used-packages/used-packages.js +0 -140
  187. package/statistics/features/supported/values/post-process.d.ts +0 -6
  188. package/statistics/features/supported/values/post-process.js +0 -73
  189. package/statistics/features/supported/values/values.d.ts +0 -14
  190. package/statistics/features/supported/values/values.js +0 -111
  191. package/statistics/features/supported/variables/post-process.d.ts +0 -15
  192. package/statistics/features/supported/variables/post-process.js +0 -126
  193. package/statistics/features/supported/variables/variables.d.ts +0 -15
  194. package/statistics/features/supported/variables/variables.js +0 -62
  195. package/statistics/meta-statistics.d.ts +0 -32
  196. package/statistics/meta-statistics.js +0 -16
  197. package/statistics/output/file-provider.d.ts +0 -36
  198. package/statistics/output/file-provider.js +0 -96
  199. package/statistics/output/print-stats.d.ts +0 -29
  200. package/statistics/output/print-stats.js +0 -81
  201. package/statistics/output/statistics-file.d.ts +0 -36
  202. package/statistics/output/statistics-file.js +0 -68
  203. package/statistics/statistics.d.ts +0 -29
  204. package/statistics/statistics.js +0 -108
  205. package/statistics/summarizer/auto-detect.d.ts +0 -5
  206. package/statistics/summarizer/auto-detect.js +0 -34
  207. package/statistics/summarizer/first-phase/process.d.ts +0 -6
  208. package/statistics/summarizer/first-phase/process.js +0 -81
  209. package/statistics/summarizer/post-process/clusterer.d.ts +0 -25
  210. package/statistics/summarizer/post-process/clusterer.js +0 -40
  211. package/statistics/summarizer/post-process/file-based-count.d.ts +0 -16
  212. package/statistics/summarizer/post-process/file-based-count.js +0 -47
  213. package/statistics/summarizer/post-process/histogram.d.ts +0 -57
  214. package/statistics/summarizer/post-process/histogram.js +0 -126
  215. package/statistics/summarizer/post-process/post-process-output.d.ts +0 -14
  216. package/statistics/summarizer/post-process/post-process-output.js +0 -102
  217. package/statistics/summarizer/second-phase/process.d.ts +0 -15
  218. package/statistics/summarizer/second-phase/process.js +0 -118
  219. package/statistics/summarizer/summarizer.d.ts +0 -34
  220. package/statistics/summarizer/summarizer.js +0 -141
@@ -0,0 +1,25 @@
1
+ import type { DataflowProcessorInformation } from '../../../../../processor';
2
+ import type { DataflowInformation } from '../../../../../info';
3
+ import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
+ import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
+ import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
+ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
+ import { type REnvironmentInformation } from '../../../../../environments/environment';
8
+ import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model';
9
+ /** The context needed to resolve a stack env: the current environment (for the global) and the built-in environment. */
10
+ type StackEnvContext = Pick<DataflowProcessorInformation<never>, 'environment' | 'ctx'>;
11
+ /**
12
+ * Processes the env-returning builtins (`globalenv`/`baseenv`/`emptyenv`), tagging the call with the
13
+ * {@link BuiltInProcName.StackEnv} origin so an assignment (`e <- globalenv()`) attaches the stack env as the
14
+ * variable's `envState`. Direct forms (`globalenv()$x`, `.GlobalEnv`) go through {@link resolveNodeToStackEnv}.
15
+ */
16
+ export declare function processStackEnv<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
17
+ /**
18
+ * The stack environment an AST `node` denotes directly: a `.GlobalEnv`/`.BaseEnv` symbol, a
19
+ * `globalenv()`/`baseenv()`/`emptyenv()` call, the current env via `environment()`, the parent via `parent.env(e)`,
20
+ * or a named search-path entry via `as.environment("package:x")`. Returns `undefined` otherwise.
21
+ */
22
+ export declare function resolveNodeToStackEnv<Info>(node: RNode<Info> | undefined, data: StackEnvContext): REnvironmentInformation | undefined;
23
+ /** If `sourceInfo`'s entry is a {@link BuiltInProcName.StackEnv} call, the stack environment it refers to; else `undefined`. */
24
+ export declare function stackEnvStateFromSource(sourceInfo: DataflowInformation, data: StackEnvContext): REnvironmentInformation | undefined;
25
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.processStackEnv = processStackEnv;
4
+ exports.resolveNodeToStackEnv = resolveNodeToStackEnv;
5
+ exports.stackEnvStateFromSource = stackEnvStateFromSource;
6
+ const known_call_handling_1 = require("../known-call-handling");
7
+ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
8
+ const environment_1 = require("../../../../../environments/environment");
9
+ const vertex_1 = require("../../../../../graph/vertex");
10
+ const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
11
+ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
12
+ const default_builtin_config_1 = require("../../../../../environments/default-builtin-config");
13
+ /** The stack env kind a builtin/constant `name` denotes, or `undefined`. */
14
+ function stackEnvKind(name) {
15
+ return default_builtin_config_1.StackEnvBuiltins[name];
16
+ }
17
+ /**
18
+ * Processes the env-returning builtins (`globalenv`/`baseenv`/`emptyenv`), tagging the call with the
19
+ * {@link BuiltInProcName.StackEnv} origin so an assignment (`e <- globalenv()`) attaches the stack env as the
20
+ * variable's `envState`. Direct forms (`globalenv()$x`, `.GlobalEnv`) go through {@link resolveNodeToStackEnv}.
21
+ */
22
+ function processStackEnv(name, args, rootId, data) {
23
+ return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.StackEnv }).information;
24
+ }
25
+ /** The fixed stack environment for a `Global`/`Base`/`Empty` kind; `undefined` for kinds that need the call's arguments. */
26
+ function fixedStackEnv(kind, data) {
27
+ switch (kind) {
28
+ case default_builtin_config_1.StackEnvKind.Global:
29
+ return { current: environment_1.REnvironment.findGlobal(data.environment.current), level: 0 };
30
+ case default_builtin_config_1.StackEnvKind.Base:
31
+ return { current: data.ctx.env.builtInEnvironment, level: 0 };
32
+ case default_builtin_config_1.StackEnvKind.Empty:
33
+ return data.ctx.env.makeEmptyEnv();
34
+ default:
35
+ return undefined;
36
+ }
37
+ }
38
+ /**
39
+ * The stack environment an AST `node` denotes directly: a `.GlobalEnv`/`.BaseEnv` symbol, a
40
+ * `globalenv()`/`baseenv()`/`emptyenv()` call, the current env via `environment()`, the parent via `parent.env(e)`,
41
+ * or a named search-path entry via `as.environment("package:x")`. Returns `undefined` otherwise.
42
+ */
43
+ function resolveNodeToStackEnv(node, data) {
44
+ if (node === undefined) {
45
+ return undefined;
46
+ }
47
+ const name = node.type === type_1.RType.Symbol ? String(node.content)
48
+ : r_function_call_1.RFunctionCall.isNamed(node) && node.functionName.type === type_1.RType.Symbol ? String(node.functionName.content)
49
+ : undefined;
50
+ const kind = name !== undefined ? stackEnvKind(name) : undefined;
51
+ if (kind === undefined) {
52
+ return undefined;
53
+ }
54
+ const firstArg = node.type === type_1.RType.FunctionCall && node.arguments.length > 0 && node.arguments[0] !== r_function_call_1.EmptyArgument ? node.arguments[0].value : undefined;
55
+ switch (kind) {
56
+ case default_builtin_config_1.StackEnvKind.Global:
57
+ case default_builtin_config_1.StackEnvKind.Base:
58
+ case default_builtin_config_1.StackEnvKind.Empty:
59
+ return fixedStackEnv(kind, data);
60
+ case default_builtin_config_1.StackEnvKind.Current: // environment() with no argument is the current environment
61
+ return firstArg === undefined ? { current: data.environment.current, level: data.environment.level } : undefined;
62
+ case default_builtin_config_1.StackEnvKind.Parent: {
63
+ const inner = resolveNodeToStackEnv(firstArg, data);
64
+ return inner !== undefined && !inner.current.builtInEnv ? { current: inner.current.parent, level: inner.level } : undefined;
65
+ }
66
+ case default_builtin_config_1.StackEnvKind.Named:
67
+ return firstArg?.type === type_1.RType.String ? asSearchPathEnv(firstArg.content.str, data) : undefined;
68
+ }
69
+ }
70
+ /** Resolves a named search-path entry: a `.GlobalEnv`/`.BaseEnv` name, or `package:<name>` to that package's namespace layer. */
71
+ function asSearchPathEnv(name, data) {
72
+ const fixed = fixedStackEnv(stackEnvKind(name), data);
73
+ if (fixed !== undefined) {
74
+ return fixed;
75
+ }
76
+ if (name.startsWith('package:')) {
77
+ const pkg = name.slice('package:'.length);
78
+ for (let env = environment_1.REnvironment.findGlobal(data.environment.current).parent; env !== undefined && !env.builtInEnv; env = env.parent) {
79
+ if (env.n === pkg && env.t === environment_1.EnvType.Namespace) {
80
+ return { current: env, level: 0 };
81
+ }
82
+ }
83
+ }
84
+ return undefined;
85
+ }
86
+ /** If `sourceInfo`'s entry is a {@link BuiltInProcName.StackEnv} call, the stack environment it refers to; else `undefined`. */
87
+ function stackEnvStateFromSource(sourceInfo, data) {
88
+ const vertex = sourceInfo.graph.getVertex(sourceInfo.entryPoint);
89
+ if (!(0, vertex_1.isFunctionCallVertex)(vertex) || vertex.name === undefined || !vertex.origin.includes(built_in_proc_name_1.BuiltInProcName.StackEnv)) {
90
+ return undefined;
91
+ }
92
+ return fixedStackEnv(stackEnvKind(String(vertex.name)), data);
93
+ }
94
+ //# sourceMappingURL=built-in-stack-env.js.map
@@ -13,6 +13,7 @@ const identifier_1 = require("../../../../../environments/identifier");
13
13
  const general_1 = require("../../../../../eval/values/general");
14
14
  const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
15
15
  const reference_to_maybe_1 = require("../../../../../environments/reference-to-maybe");
16
+ const apply_kill_1 = require("../../../../../environments/apply-kill");
16
17
  const append_1 = require("../../../../../environments/append");
17
18
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
18
19
  /**
@@ -78,6 +79,12 @@ function processWhileLoop(name, args, rootId, data) {
78
79
  (0, linker_1.reapplyLoopExitPoints)(body.exitPoints, body.in.concat(body.out, body.unknownReferences), information.graph);
79
80
  // as the while-loop always evaluates its condition
80
81
  information.graph.addEdge(nameId, condition.entryPoint, edge_1.EdgeType.Reads);
82
+ // the body's environment carries its side effects (e.g. a `library()` call), which must survive the loop
83
+ const bodyEnvironment = (0, append_1.appendEnvironment)(information.environment, body.environment);
84
+ // as we do not know whether the loop executes at all, we merge the original environment back in (the body may never run)
85
+ const loopEnvironment = conditionIsAlwaysTrue ? bodyEnvironment : (0, append_1.appendEnvironment)(origEnv, bodyEnvironment);
86
+ // unless the loop always runs, a body removal only happens maybe; apply it as the merge cannot represent it
87
+ const loopKill = body.kill?.length ? (conditionIsAlwaysTrue ? body.kill : (0, apply_kill_1.makeKillsMaybe)(body.kill, cdTrue)) : undefined;
81
88
  return {
82
89
  unknownReferences: [],
83
90
  in: [{ nodeId: nameId, name: name.lexeme, cds: originalDependency, type: identifier_1.ReferenceType.Function }, ...remainingInputs],
@@ -85,9 +92,9 @@ function processWhileLoop(name, args, rootId, data) {
85
92
  entryPoint: nameId,
86
93
  exitPoints: (0, info_1.filterOutLoopExitPoints)(body.exitPoints),
87
94
  graph: information.graph,
88
- // as we do not know whether the loop executes at all, we have to merge the environments of the condition and the body, as both may be relevant
89
- environment: conditionIsAlwaysTrue ? information.environment : (0, append_1.appendEnvironment)(origEnv, information.environment),
90
- hooks: condition.hooks.concat(body.hooks)
95
+ environment: loopKill ? (0, apply_kill_1.applyKills)(loopEnvironment, loopKill) : loopEnvironment,
96
+ hooks: condition.hooks.concat(body.hooks),
97
+ kill: loopKill,
91
98
  };
92
99
  }
93
100
  //# sourceMappingURL=built-in-while-loop.js.map
@@ -0,0 +1,30 @@
1
+ import type { DataflowGraph } from '../../../../../graph/graph';
2
+ import { type DataflowGraphVertexFunctionDefinition } from '../../../../../graph/vertex';
3
+ import { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
4
+ import { type REnvironmentInformation } from '../../../../../environments/environment';
5
+ import type { FlowrAnalyzerContext } from '../../../../../../project/context/flowr-analyzer-context';
6
+ import type { IdentifierReference } from '../../../../../environments/identifier';
7
+ /**
8
+ * Computes, for every function-definition vertex `F`, `summary(F) = own(F)` unioned with `summary(G)` over every transitive callee `G`.
9
+ * @param graph - the fully linked dataflow graph
10
+ * @param own - the effects a single function definition produces itself (its contribution to the summary)
11
+ * @returns a map from each function-definition vertex to its transitive-effect summary
12
+ */
13
+ export declare function computeCallGraphSummaries<T>(this: void, graph: DataflowGraph, own: (id: NodeId, fdef: DataflowGraphVertexFunctionDefinition) => Iterable<T>): Map<NodeId, Set<T>>;
14
+ /**
15
+ * Links every materialized package-export vertex back to the `library()`/`use()` call that loaded it,
16
+ * reading the loading call from the export binding's `definedAt` in the (final, authoritative) environment.
17
+ * Only vertices created on demand (exports actually referenced) get an edge, keeping the graph small.
18
+ */
19
+ export declare function linkMaterializedExportsToLoaders(graph: DataflowGraph, environment: REnvironmentInformation): void;
20
+ /** Re-resolves still-open reads whose name is one of the transitively escaped `<<-` definitions in `escapedNames`, adding {@link EdgeType.Reads} edges. */
21
+ export declare function reResolveOpenReferences(this: void, graph: DataflowGraph, environment: REnvironmentInformation, references: readonly IdentifierReference[], escapedNames: ReadonlySet<string>): void;
22
+ /**
23
+ * Propagates every function's escaped side effects (attached packages and `<<-` definitions) to its transitive callers.
24
+ * @returns the enriched top-level environment and whether it grew (so the extractor can re-link and re-run to a fixpoint).
25
+ */
26
+ export declare function propagateTransitiveSideEffects(this: void, graph: DataflowGraph, environment: REnvironmentInformation, ctx: FlowrAnalyzerContext): {
27
+ environment: REnvironmentInformation;
28
+ grew: boolean;
29
+ escapedNames: Set<string>;
30
+ };
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeCallGraphSummaries = computeCallGraphSummaries;
4
+ exports.linkMaterializedExportsToLoaders = linkMaterializedExportsToLoaders;
5
+ exports.reResolveOpenReferences = reResolveOpenReferences;
6
+ exports.propagateTransitiveSideEffects = propagateTransitiveSideEffects;
7
+ const vertex_1 = require("../../../../../graph/vertex");
8
+ const edge_1 = require("../../../../../graph/edge");
9
+ const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
10
+ const environment_1 = require("../../../../../environments/environment");
11
+ const built_in_library_1 = require("./built-in-library");
12
+ const define_1 = require("../../../../../environments/define");
13
+ const resolve_by_name_1 = require("../../../../../environments/resolve-by-name");
14
+ /**
15
+ * The function-definition vertices a `call` resolves to (via {@link EdgeType.Calls}).
16
+ */
17
+ function calledDefinitions(graph, call) {
18
+ const targets = [];
19
+ for (const [target, edge] of graph.outgoingEdges(call) ?? []) {
20
+ if ((edge.types & edge_1.EdgeType.Calls) !== 0 && graph.getVertex(target)?.tag === vertex_1.VertexType.FunctionDefinition) {
21
+ targets.push(target);
22
+ }
23
+ }
24
+ return targets;
25
+ }
26
+ /**
27
+ * Computes, for every function-definition vertex `F`, `summary(F) = own(F)` unioned with `summary(G)` over every transitive callee `G`.
28
+ * @param graph - the fully linked dataflow graph
29
+ * @param own - the effects a single function definition produces itself (its contribution to the summary)
30
+ * @returns a map from each function-definition vertex to its transitive-effect summary
31
+ */
32
+ function computeCallGraphSummaries(graph, own) {
33
+ const summary = new Map();
34
+ const callees = new Map();
35
+ for (const [id, vertex] of graph.vertices(true)) {
36
+ if (vertex.tag !== vertex_1.VertexType.FunctionDefinition) {
37
+ continue;
38
+ }
39
+ summary.set(id, new Set(own(id, vertex)));
40
+ const targets = [];
41
+ for (const node of vertex.subflow.graph) {
42
+ if (graph.getVertex(node)?.tag === vertex_1.VertexType.FunctionCall) {
43
+ targets.push(...calledDefinitions(graph, node));
44
+ }
45
+ }
46
+ callees.set(id, targets);
47
+ }
48
+ if (summary.size === 0) {
49
+ return summary;
50
+ }
51
+ // reverse edges: callers of each function
52
+ const callers = new Map();
53
+ for (const [id, targets] of callees) {
54
+ for (const callee of targets) {
55
+ const existing = callers.get(callee);
56
+ if (existing === undefined) {
57
+ callers.set(callee, [id]);
58
+ }
59
+ else {
60
+ existing.push(id);
61
+ }
62
+ }
63
+ }
64
+ // worklist fixpoint: pull each callee's summary, re-enqueue callers when a function grew
65
+ const queue = [...summary.keys()];
66
+ const queued = new Set(queue);
67
+ while (queue.length > 0) {
68
+ const id = queue.pop();
69
+ queued.delete(id);
70
+ const effects = summary.get(id);
71
+ let grew = false;
72
+ for (const callee of callees.get(id) ?? []) {
73
+ for (const effect of summary.get(callee) ?? []) {
74
+ if (!effects.has(effect)) {
75
+ effects.add(effect);
76
+ grew = true;
77
+ }
78
+ }
79
+ }
80
+ if (grew) {
81
+ for (const caller of callers.get(id) ?? []) {
82
+ if (!queued.has(caller)) {
83
+ queued.add(caller);
84
+ queue.push(caller);
85
+ }
86
+ }
87
+ }
88
+ }
89
+ return summary;
90
+ }
91
+ /**
92
+ * Links every materialized package-export vertex back to the `library()`/`use()` call that loaded it,
93
+ * reading the loading call from the export binding's `definedAt` in the (final, authoritative) environment.
94
+ * Only vertices created on demand (exports actually referenced) get an edge, keeping the graph small.
95
+ */
96
+ function linkMaterializedExportsToLoaders(graph, environment) {
97
+ // export node id -> its loading `library()`/`use()` call, from the final environment
98
+ const loaders = new Map();
99
+ for (let e = environment.current; e !== undefined && !e.builtInEnv; e = e.parent) {
100
+ if (e.t !== environment_1.EnvType.Namespace) {
101
+ continue;
102
+ }
103
+ for (const defs of e.memory.values()) {
104
+ for (const d of defs) {
105
+ if (!node_id_1.NodeId.isBuiltIn(d.definedAt)) {
106
+ loaders.set(d.nodeId, d.definedAt);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ // only exports actually called (a materialized vertex or the target of a `calls` edge) get a loader edge
112
+ for (const [id, loadedAt] of loaders) {
113
+ const called = graph.hasVertex(id)
114
+ || [...graph.ingoingEdges(id)?.values() ?? []].some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Calls));
115
+ if (called) {
116
+ graph.addEdge(id, loadedAt, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
117
+ }
118
+ }
119
+ }
120
+ /** The packages (see {@link EnvType}) attached directly within a function body, i.e. its own `library()` calls. */
121
+ function attachedPackages(_id, fdef) {
122
+ const packages = [];
123
+ for (let e = fdef.subflow.environment.current; e !== undefined && !e.builtInEnv; e = e.parent) {
124
+ if (e.t === environment_1.EnvType.Namespace && e.n !== undefined) {
125
+ // an export binding carries the loading `library()` call in `definedAt`
126
+ let definedAt = node_id_1.NodeId.toBuiltIn(e.n);
127
+ for (const defs of e.memory.values()) {
128
+ const real = defs.find(d => !node_id_1.NodeId.isBuiltIn(d.definedAt));
129
+ if (real !== undefined) {
130
+ definedAt = real.definedAt;
131
+ break;
132
+ }
133
+ }
134
+ packages.push({ pack: e.n, definedAt });
135
+ }
136
+ }
137
+ return packages;
138
+ }
139
+ /** The non-built-in definitions a function body lets escape to an outer scope (e.g. a `<<-` super-assignment). */
140
+ function escapedDefinitions(_id, fdef) {
141
+ const defs = [];
142
+ // skip the function's own frame; outer-scope definitions escaped
143
+ for (let e = fdef.subflow.environment.current.parent; e !== undefined && !e.builtInEnv; e = e.parent) {
144
+ for (const definitions of e.memory.values()) {
145
+ for (const def of definitions) {
146
+ if (!node_id_1.NodeId.isBuiltIn(def.nodeId)) {
147
+ defs.push(def.nodeId);
148
+ }
149
+ }
150
+ }
151
+ }
152
+ return defs;
153
+ }
154
+ /** Emits {@link EdgeType.SideEffectOnCall} edges for definitions that escape a function transitively. */
155
+ function propagateTransitiveDefinitions(graph, environment, ctx) {
156
+ const summary = computeCallGraphSummaries(graph, escapedDefinitions);
157
+ for (const [id, vertex] of graph.vertices(true)) {
158
+ if (vertex.tag !== vertex_1.VertexType.FunctionCall) {
159
+ continue;
160
+ }
161
+ for (const target of calledDefinitions(graph, id)) {
162
+ for (const def of summary.get(target) ?? []) {
163
+ // an escaping package export is only in the environment; materialize its vertex on demand
164
+ if (node_id_1.NodeId.isBuiltIn(def)) {
165
+ (0, built_in_library_1.attachExportVertex)(graph, def, environment, ctx);
166
+ }
167
+ graph.addEdge(def, id, edge_1.EdgeType.SideEffectOnCall);
168
+ }
169
+ }
170
+ }
171
+ }
172
+ /**
173
+ * Attaches packages transitively loaded by top-level calls to `environment`.
174
+ * `g <- function() library(A); f <- function() g(); f()` makes `A` available after `f()`.
175
+ * @returns the enriched environment and whether it grew (so the caller can re-link and re-run to a fixpoint).
176
+ */
177
+ function propagateTransitivePackages(graph, environment, ctx) {
178
+ const summary = computeCallGraphSummaries(graph, attachedPackages);
179
+ const reachable = new Map(); // package -> its loading `library()` call
180
+ for (const [id, vertex] of graph.vertices(true)) {
181
+ if (vertex.tag !== vertex_1.VertexType.FunctionCall || !graph.isRoot(id)) {
182
+ continue;
183
+ }
184
+ for (const target of calledDefinitions(graph, id)) {
185
+ for (const { pack, definedAt } of summary.get(target) ?? []) {
186
+ if (!reachable.has(pack)) {
187
+ reachable.set(pack, definedAt);
188
+ }
189
+ }
190
+ }
191
+ }
192
+ let grew = false;
193
+ for (const [pack, definedAt] of reachable) {
194
+ const dependency = ctx.deps.getDependency(pack);
195
+ if (dependency === undefined) {
196
+ continue;
197
+ }
198
+ const next = (0, built_in_library_1.attachDependencyToEnvironment)(dependency, environment, ctx, {}, definedAt);
199
+ if (next !== environment) {
200
+ environment = next;
201
+ grew = true;
202
+ }
203
+ }
204
+ return { environment, grew };
205
+ }
206
+ /** Maps each escaped definition's node id to its full (name-carrying) definition. */
207
+ function escapedDefinitionMap(graph) {
208
+ const map = new Map();
209
+ for (const [, vertex] of graph.vertices(true)) {
210
+ if (vertex.tag !== vertex_1.VertexType.FunctionDefinition) {
211
+ continue;
212
+ }
213
+ for (let e = vertex.subflow.environment.current.parent; e !== undefined && !e.builtInEnv; e = e.parent) {
214
+ for (const definitions of e.memory.values()) {
215
+ for (const def of definitions) {
216
+ if (!node_id_1.NodeId.isBuiltIn(def.nodeId) && def.name !== undefined) {
217
+ map.set(def.nodeId, def);
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ return map;
224
+ }
225
+ /**
226
+ * Folds the `<<-` definitions that escape transitively from top-level calls into `environment`.
227
+ * `f <- function() x <<- 1; g <- function() f(); g(); print(x)` makes `x` resolvable.
228
+ * @returns the enriched environment and whether it grew (so the extractor can re-resolve open reads and re-run).
229
+ */
230
+ function propagateTransitiveEscapedDefinitions(graph, environment) {
231
+ const summary = computeCallGraphSummaries(graph, escapedDefinitions);
232
+ const defs = escapedDefinitionMap(graph);
233
+ const names = new Set();
234
+ let grew = false;
235
+ for (const [id, vertex] of graph.vertices(true)) {
236
+ if (vertex.tag !== vertex_1.VertexType.FunctionCall || !graph.isRoot(id)) {
237
+ continue;
238
+ }
239
+ for (const target of calledDefinitions(graph, id)) {
240
+ for (const nodeId of summary.get(target) ?? []) {
241
+ const def = defs.get(nodeId);
242
+ if (def === undefined) {
243
+ continue;
244
+ }
245
+ names.add(def.name);
246
+ if ((0, resolve_by_name_1.resolveByName)(def.name, environment, def.type)?.some(d => d.nodeId === nodeId)) {
247
+ continue;
248
+ }
249
+ environment = (0, define_1.define)(def, false, environment);
250
+ grew = true;
251
+ }
252
+ }
253
+ }
254
+ return { environment, grew, names };
255
+ }
256
+ /** Re-resolves still-open reads whose name is one of the transitively escaped `<<-` definitions in `escapedNames`, adding {@link EdgeType.Reads} edges. */
257
+ function reResolveOpenReferences(graph, environment, references, escapedNames) {
258
+ for (const ref of references) {
259
+ if (ref.name === undefined || !escapedNames.has(String(ref.name))) {
260
+ continue;
261
+ }
262
+ for (const { nodeId } of (0, resolve_by_name_1.resolveByName)(ref.name, environment, ref.type) ?? []) {
263
+ if (!node_id_1.NodeId.isBuiltIn(nodeId) && nodeId !== ref.nodeId) {
264
+ graph.addEdge(ref.nodeId, nodeId, edge_1.EdgeType.Reads);
265
+ }
266
+ }
267
+ }
268
+ }
269
+ /**
270
+ * Propagates every function's escaped side effects (attached packages and `<<-` definitions) to its transitive callers.
271
+ * @returns the enriched top-level environment and whether it grew (so the extractor can re-link and re-run to a fixpoint).
272
+ */
273
+ function propagateTransitiveSideEffects(graph, environment, ctx) {
274
+ propagateTransitiveDefinitions(graph, environment, ctx);
275
+ const packages = propagateTransitivePackages(graph, environment, ctx);
276
+ const escaped = propagateTransitiveEscapedDefinitions(graph, packages.environment);
277
+ return { environment: escaped.environment, grew: packages.grew || escaped.grew, escapedNames: escaped.names };
278
+ }
279
+ //# sourceMappingURL=transitive-side-effects.js.map
@@ -3,7 +3,7 @@ import { DataflowInformation } from '../../../../info';
3
3
  import type { ParentInformation } from '../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { PotentiallyEmptyRArgument } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
5
  import type { RSymbol } from '../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
- import type { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
+ import { NodeId } from '../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { DataflowGraph } from '../../../../graph/graph';
8
8
  /**
9
9
  * Marks the given function call node as only calling built-in functions.
@@ -5,9 +5,12 @@ exports.processNamedCall = processNamedCall;
5
5
  const info_1 = require("../../../../info");
6
6
  const known_call_handling_1 = require("./known-call-handling");
7
7
  const append_1 = require("../../../../environments/append");
8
+ const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
8
9
  const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
9
10
  const vertex_1 = require("../../../../graph/vertex");
10
11
  const identifier_1 = require("../../../../environments/identifier");
12
+ const edge_1 = require("../../../../graph/edge");
13
+ const built_in_library_1 = require("./built-in/built-in-library");
11
14
  function mergeInformation(info, newInfo) {
12
15
  if (info === undefined) {
13
16
  return newInfo;
@@ -70,6 +73,20 @@ function processNamedCall(name, args, rootId, data) {
70
73
  // mark the function call as built in only
71
74
  markAsOnlyBuiltIn(information.graph, rootId);
72
75
  }
76
+ // on demand: materialize the built-in vertex for any package export this call resolves to and, when we
77
+ // already know the loading call here, link to it (a function-local export is invisible to the later
78
+ // top-level linkMaterializedExportsToLoaders pass, so we must catch it at the call site)
79
+ if (information) {
80
+ for (const r of resolved) {
81
+ if (r.type === identifier_1.ReferenceType.Function && r.nodeId !== undefined && node_id_1.NodeId.isBuiltIn(r.nodeId)) {
82
+ (0, built_in_library_1.attachExportVertex)(information.graph, r.nodeId, data.environment, data.ctx, data.cds);
83
+ const definedAt = r.definedAt;
84
+ if (definedAt !== undefined && !node_id_1.NodeId.isBuiltIn(definedAt)) {
85
+ information.graph.addEdge(r.nodeId, definedAt, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
86
+ }
87
+ }
88
+ }
89
+ }
73
90
  return information ?? info_1.DataflowInformation.initialize(rootId, data);
74
91
  }
75
92
  //# sourceMappingURL=named-call-handling.js.map
@@ -93,6 +93,9 @@ relevant documentation. If you don't know the origin of the package, you can use
93
93
  🌐 Secondly, if you don't have or don't want to install the package you can simply google the fully qualified name of the function. Good sources include [rdrr.io](https://rdrr.io/)
94
94
  or [rdocumentation.org](https://rdocumentation.org/). Additionally, the package documentation PDF can also
95
95
  be downloaded directly from [cran](https://cran.r-project.org/).
96
+ `)
97
+ .addFaq('How does flowR know a *package\'s exports*?', `
98
+ See the ${ctx.linkPage('wiki/Package Database', 'Package Database')} wiki page.
96
99
  `);
97
100
  wikiFaq.withTopic('editor.configs')
98
101
  .addFaq('How can I make eslint and ZED work together?', `Use this project config (\`.zed/settings.json\`) to disable all formatters except eslint:
@@ -39,7 +39,6 @@ ${ctx.code(staticSliceExample, { dropLinesEnd: 2, dropLinesStart: 1, hideDefined
39
39
 
40
40
  For more information, please have a look at the ${ctx.linkPage('wiki/Analyzer')} wiki page, which explains how to construct and use the ${ctx.link(flowr_analyzer_1.FlowrAnalyzer)} in more detail.
41
41
  To work with specific perspectives, you can also consult the respective pages like the ${ctx.linkPage('wiki/Dataflow Graph')} or the ${ctx.linkPage('wiki/Abstract Interpretation')} wiki pages.
42
-
43
42
  ### The Pipeline Executor (Low-Level Interface)
44
43
 
45
44
  Once, in the beginning, _flowR_ was meant to produce a dataflow graph merely to provide *program slices*.
@@ -71,7 +70,7 @@ The ${ctx.link(pipeline_executor_1.PipelineExecutor)}...
71
70
 
72
71
  See the in-code documentation for more information.
73
72
 
74
- `)}
73
+ `)}
75
74
 
76
75
  ### Using the ${ctx.link(shell_1.RShell)} to Interact with R
77
76
 
@@ -90,86 +89,11 @@ You can start a new "session" simply by constructing a new object with ${(0, doc
90
89
  However, there are several options that may be of interest
91
90
  (e.g., to automatically revive the shell in case of errors or to control the name location of the R process on the system).
92
91
 
93
- With a shell object (let's call it \`shell\`), you can execute R code by using ${ctx.linkM(shell_1.RShell, 'sendCommand', { realNameWrapper: 'i' })},
94
- for example ${(0, doc_code_1.codeInline)('shell.' + ctx.linkM(shell_1.RShell, 'sendCommand', { codeFont: false, hideClass: true }) + '("1 + 1")')}.
92
+ With a shell object (let's call it \`shell\`), you can execute R code by using ${ctx.linkM(shell_1.RShell, 'sendCommand', { realNameWrapper: 'i' })},
93
+ for example ${(0, doc_code_1.codeInline)('shell.' + ctx.linkM(shell_1.RShell, 'sendCommand', { codeFont: false, hideClass: true }) + '("1 + 1")')}.
95
94
  However, this does not return anything, so if you want to collect the output of your command, use
96
95
  ${ctx.linkM(shell_1.RShell, 'sendCommandWithOutput', { realNameWrapper: 'i' })} instead.
97
96
 
98
- Besides that, the command ${ctx.linkM(shell_1.RShell, 'tryToInjectHomeLibPath')} may be of interest, as it enables all libraries available on the host system.
99
-
100
-
101
- ### Generate Statistics (No longer a Focus of flowR)
102
-
103
-
104
- <details>
105
-
106
- <summary>Adding a New Feature to Extract</summary>
107
-
108
- In this example, we construct a new feature to extract, with the name "*example*".
109
- Whenever this name appears, you may substitute this with whatever name fits your feature best (as long as the name is unique).
110
-
111
- 1. **Create a new file in \`src/statistics/features/supported\`**\\
112
- Create the file \`example.ts\`, and add its export to the \`index.ts\` file in the same directory (if not done automatically).
113
-
114
- 2. **Create the basic structure**\\
115
- To get a better feel of what a feature must have, let's look
116
- at the basic structure (of course, due to TypeScript syntax,
117
- there are other ways to achieve the same goal):
118
-
119
- \`\`\`ts
120
- const initialExampleInfo = {
121
- /* whatever start value is good for you */
122
- someCounter: 0
123
- }
124
-
125
- export type ExampleInfo = Writable<typeof initialExampleInfo>
126
-
127
- export const example: Feature<ExampleInfo> = {
128
- name: 'Example Feature',
129
- description: 'A longer example description',
130
-
131
- process(existing: ExampleInfo, input: FeatureProcessorInput): ExampleInfo {
132
- /* perform analysis on the input */
133
- return existing
134
- },
135
-
136
- initialValue: initialExampleInfo
137
- }
138
- \`\`\`
139
-
140
- The \`initialExampleInfo\` type holds the initial values for each counter that you want to maintain during the feature extraction (they will usually be initialized with 0). The resulting \`ExampleInfo\` type holds the structure of the data that is to be counted. Due to the vast amount of data processed, information like the name and location of a function call is not stored here, but instead written to disk (see below).
141
-
142
- Every new feature must be of the \`Feature<Info>\` type, with \`Info\` referring to a \`FeatureInfo\` (like \`ExampleInfo\` in this example). Next to a \`name\` and a \`description\`, each Feature must provide:
143
-
144
- - a processor that extracts the information from the input, adding it to the existing information.
145
- - a function returning the initial value of the information (in this case, \`initialExampleInfo\`).
146
-
147
- 3. **Add it to the feature-mapping**\\
148
- Now, in the \`feature.ts\` file in \`src/statistics/features\`, add your feature to the \`ALL_FEATURES\` object.
149
-
150
- Now, we want to extract something. For the *example* feature created in the previous steps, we choose to count the amount of \`COMMENT\` tokens.
151
- So we define a corresponding [XPath](https://developer.mozilla.org/en-US/docs/Web/XPath) query:
152
-
153
- \`\`\`ts
154
- const commentQuery: Query = xpath.parse('//COMMENT')
155
- \`\`\`
156
-
157
- Within our feature's \`process\` function, running the query is as simple as:
158
-
159
- \`\`\`ts
160
- const comments = commentQuery.select({ node: input.parsedRAst })
161
- \`\`\`
162
-
163
- Now we could do a lot of further processing, but for simplicity, we only record every comment found this way:
164
-
165
- \`\`\`ts
166
- appendStatisticsFile(example.name, 'comments', comments, input.filepath)
167
- \`\`\`
168
-
169
- We use \`example.name\` to avoid duplication with the name that we’ve assigned to the feature. It corresponds to the name of the folder in the statistics output.
170
- \`'comments'\` refers to a freely chosen (but unique) name, that will be used as the name for the output file within the folder. The \`comments\` variable holds the result of the query, which is an array of nodes. Finally, we pass the \`filepath\` of the file that was analyzed (if known), so that it can be added to the statistics file (as additional information).
171
-
172
- </details>
173
- `;
97
+ `;
174
98
  }
175
99
  //# sourceMappingURL=doc-writing-code.js.map
@@ -16,8 +16,7 @@ ${prefixInit}<details${open ? ' open' : ''}><summary${color ? ' style="color:' +
16
16
 
17
17
  ${content}
18
18
 
19
- ${prefixInit}</details>
20
- `;
19
+ ${prefixInit}</details>`;
21
20
  }
22
21
  /**
23
22
  *
@@ -405,7 +405,8 @@ to produce a new dataflow information to pass upwards in the fold. The ${ctx.lin
405
405
  * the ${ctx.link(graph_1.DataflowGraph)} of the current subtree
406
406
  * the currently active ${ctx.link('REnvironmentInformation')} as an abstraction of all active definitions linking to potential definition locations (see [Advanced R::Environments](https://adv-r.hadley.nz/environments.html))
407
407
  * control flow information in ${ctx.link('DataflowCfgInformation')} which is used to enrich the dataflow information with control flow information
408
- * and sets of currently ingoing (read), outgoing (write) and unknown ${ctx.link('IdentifierReference')}s.
408
+ * sets of currently ingoing (read), outgoing (write) and unknown ${ctx.link('IdentifierReference')}s.
409
+ * and a set of ${ctx.link('KillReference')}s which tracks variables that go out of scope within the current subtree (e.g., due to \`rm\`). Just like the reference sets above, kills are carried upwards in the fold so that the enclosing scope (expression list, branch, loop, or function body) can apply the removal (via ${ctx.link('applyKills')}) at the correct location, even when the \`rm\` happens nested within a branch or block. This also covers clearing the whole environment with \`rm(list=ls())\` and conservatively handling removals whose target cannot be resolved statically.
409
410
 
410
411
  While all of them are essentially empty when processing an “uninteresting leaf”, handling a constant is slightly more interesting with ${ctx.link(process_value_1.processValue)}:
411
412