@eagleoutice/flowr 2.11.1 → 2.12.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 (255) hide show
  1. package/README.md +193 -263
  2. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -1
  3. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  4. package/abstract-interpretation/domains/set-upper-bound-domain.js +6 -2
  5. package/benchmark/slicer.d.ts +1 -1
  6. package/benchmark/slicer.js +3 -1
  7. package/benchmark/summarizer/second-phase/graph.js +5 -0
  8. package/cli/common/options.d.ts +8 -0
  9. package/cli/common/options.js +2 -0
  10. package/cli/common/scripts-info.d.ts +8 -0
  11. package/cli/repl/commands/repl-commands.d.ts +1 -0
  12. package/cli/repl/commands/repl-commands.js +66 -15
  13. package/cli/repl/commands/repl-dataflow.js +48 -4
  14. package/cli/repl/commands/repl-main.d.ts +2 -0
  15. package/cli/repl/commands/repl-main.js +5 -0
  16. package/cli/repl/commands/repl-query.d.ts +4 -1
  17. package/cli/repl/commands/repl-query.js +72 -22
  18. package/cli/repl/commands/repl-signature.d.ts +7 -0
  19. package/cli/repl/commands/repl-signature.js +119 -0
  20. package/cli/repl/core.d.ts +8 -1
  21. package/cli/repl/core.js +46 -6
  22. package/cli/repl/ghost-hint.d.ts +37 -0
  23. package/cli/repl/ghost-hint.js +72 -0
  24. package/cli/repl/parser/slice-query-parser.d.ts +11 -1
  25. package/cli/repl/parser/slice-query-parser.js +45 -16
  26. package/cli/repl/print-version.d.ts +2 -4
  27. package/cli/repl/print-version.js +41 -23
  28. package/cli/repl/server/connection.js +19 -17
  29. package/cli/slicer-app.d.ts +2 -0
  30. package/cli/slicer-app.js +3 -3
  31. package/cli/wiki.d.ts +2 -2
  32. package/cli/wiki.js +2 -2
  33. package/config.d.ts +63 -2
  34. package/config.js +64 -8
  35. package/control-flow/cfg-dead-code.js +0 -1
  36. package/control-flow/control-flow-graph.js +6 -6
  37. package/control-flow/diff-cfg.js +2 -2
  38. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  39. package/core/print/slice-diff-ansi.js +8 -8
  40. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  41. package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
  42. package/core/steps/all/static-slicing/00-slice.js +1 -1
  43. package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
  44. package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
  45. package/core/steps/pipeline/default-pipelines.d.ts +20 -16
  46. package/data/r-base-packages.generated.d.ts +44 -0
  47. package/data/r-base-packages.generated.js +32 -0
  48. package/data/r-base-primitives.generated.d.ts +1 -0
  49. package/data/r-base-primitives.generated.js +15 -0
  50. package/data/sigdb/sigdb.remote.json +112 -0
  51. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  52. package/dataflow/environments/built-in-proc-name.js +4 -0
  53. package/dataflow/environments/built-in.d.ts +14 -4
  54. package/dataflow/environments/built-in.js +13 -2
  55. package/dataflow/environments/data-masking-functions.d.ts +12 -0
  56. package/dataflow/environments/data-masking-functions.js +46 -0
  57. package/dataflow/environments/default-builtin-config.d.ts +72 -19
  58. package/dataflow/environments/default-builtin-config.js +48 -14
  59. package/dataflow/environments/diff.js +1 -1
  60. package/dataflow/environments/environment.js +1 -2
  61. package/dataflow/environments/identifier.d.ts +11 -4
  62. package/dataflow/environments/identifier.js +28 -10
  63. package/dataflow/environments/resolve-by-name.js +16 -2
  64. package/dataflow/extractor.js +6 -3
  65. package/dataflow/graph/call-graph.d.ts +2 -2
  66. package/dataflow/graph/df-helper.d.ts +4 -4
  67. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  68. package/dataflow/graph/edge.d.ts +3 -3
  69. package/dataflow/graph/edge.js +3 -3
  70. package/dataflow/graph/graph-helper.d.ts +2 -2
  71. package/dataflow/internal/linker.js +1 -1
  72. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
  73. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
  74. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
  76. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
  80. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
  81. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
  85. package/dataflow/internal/process/functions/call/common.js +8 -1
  86. package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
  87. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
  88. package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
  89. package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
  90. package/dataflow/internal/process/functions/process-argument.js +12 -1
  91. package/dataflow/internal/process/process-named-call.d.ts +18 -1
  92. package/dataflow/internal/process/process-named-call.js +94 -0
  93. package/dataflow/processor.d.ts +18 -0
  94. package/documentation/data/faq/faqs.js +5 -1
  95. package/documentation/doc-capabilities.js +1 -1
  96. package/documentation/doc-util/doc-cli-option.d.ts +10 -0
  97. package/documentation/doc-util/doc-cli-option.js +23 -0
  98. package/documentation/doc-util/doc-dfg.js +2 -1
  99. package/documentation/doc-util/doc-query.d.ts +9 -3
  100. package/documentation/doc-util/doc-query.js +9 -4
  101. package/documentation/wiki-dataflow-graph.js +8 -5
  102. package/documentation/wiki-interface.js +3 -1
  103. package/documentation/wiki-linter.js +1 -1
  104. package/documentation/wiki-linting-and-testing.js +4 -1
  105. package/documentation/wiki-mk/doc-context.d.ts +14 -0
  106. package/documentation/wiki-mk/doc-context.js +3 -0
  107. package/documentation/wiki-mk/doc-maker.js +3 -1
  108. package/documentation/wiki-query.js +19 -1
  109. package/documentation/wiki-setup.js +10 -7
  110. package/documentation/wiki-signature-database.d.ts +16 -0
  111. package/documentation/wiki-signature-database.js +293 -0
  112. package/linter/linter-format.d.ts +7 -0
  113. package/linter/linter-rules.d.ts +10 -9
  114. package/linter/rules/naming-convention.d.ts +1 -0
  115. package/linter/rules/naming-convention.js +2 -0
  116. package/linter/rules/no-leaked-credentials.js +1 -2
  117. package/linter/rules/roxygen-arguments.js +18 -5
  118. package/linter/rules/stop-with-call-arg.js +2 -2
  119. package/linter/rules/undefined-symbol-util.d.ts +36 -0
  120. package/linter/rules/undefined-symbol-util.js +149 -0
  121. package/linter/rules/undefined-symbol.d.ts +58 -17
  122. package/linter/rules/undefined-symbol.js +143 -33
  123. package/linter/rules/unused-definition.d.ts +8 -1
  124. package/linter/rules/unused-definition.js +126 -1
  125. package/package.json +22 -10
  126. package/project/context/abstract-flowr-analyzer-context.js +7 -1
  127. package/project/context/flowr-analyzer-context.d.ts +8 -0
  128. package/project/context/flowr-analyzer-context.js +10 -0
  129. package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
  130. package/project/context/flowr-analyzer-dependencies-context.js +51 -2
  131. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  132. package/project/context/flowr-analyzer-files-context.js +2 -1
  133. package/project/context/flowr-analyzer-functions-context.js +1 -1
  134. package/project/context/flowr-file.d.ts +5 -0
  135. package/project/context/flowr-file.js +5 -0
  136. package/project/flowr-analyzer-builder.js +12 -2
  137. package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
  138. package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
  139. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
  140. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
  141. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
  142. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
  147. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
  148. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
  149. package/project/plugins/package-version-plugins/package.d.ts +5 -3
  150. package/project/plugins/package-version-plugins/package.js +27 -25
  151. package/project/plugins/plugin-registry.d.ts +3 -2
  152. package/project/plugins/plugin-registry.js +4 -2
  153. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
  154. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
  155. package/project/sigdb/build.d.ts +131 -0
  156. package/project/sigdb/build.js +628 -0
  157. package/project/sigdb/codec.d.ts +51 -0
  158. package/project/sigdb/codec.js +122 -0
  159. package/project/sigdb/decode.d.ts +58 -0
  160. package/project/sigdb/decode.js +129 -0
  161. package/project/sigdb/decompress.d.ts +44 -0
  162. package/project/sigdb/decompress.js +176 -0
  163. package/project/sigdb/hash.d.ts +9 -0
  164. package/project/sigdb/hash.js +54 -0
  165. package/project/sigdb/index-format.d.ts +40 -0
  166. package/project/sigdb/index-format.js +28 -0
  167. package/project/sigdb/manifest.d.ts +68 -0
  168. package/project/sigdb/manifest.js +146 -0
  169. package/project/sigdb/reader.d.ts +250 -0
  170. package/project/sigdb/reader.js +692 -0
  171. package/project/sigdb/schema.d.ts +196 -0
  172. package/project/sigdb/schema.js +33 -0
  173. package/project/sigdb/sigdb-download.d.ts +65 -0
  174. package/project/sigdb/sigdb-download.js +237 -0
  175. package/project/sigdb/signature-match.d.ts +26 -0
  176. package/project/sigdb/signature-match.js +40 -0
  177. package/project/sigdb/version.d.ts +20 -0
  178. package/project/sigdb/version.js +55 -0
  179. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
  180. package/queries/catalog/config-query/config-query-format.d.ts +3 -1
  181. package/queries/catalog/config-query/config-query-format.js +68 -9
  182. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
  183. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  184. package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
  185. package/queries/catalog/linter-query/linter-query-executor.js +6 -1
  186. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
  187. package/queries/catalog/linter-query/linter-query-format.js +40 -8
  188. package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
  189. package/queries/catalog/project-query/project-query-executor.js +96 -4
  190. package/queries/catalog/project-query/project-query-format.d.ts +44 -0
  191. package/queries/catalog/project-query/project-query-format.js +33 -2
  192. package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
  193. package/queries/catalog/signature-query/signature-query-executor.js +461 -0
  194. package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
  195. package/queries/catalog/signature-query/signature-query-format.js +76 -0
  196. package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
  197. package/queries/catalog/signature-query/signature-query-render.js +155 -0
  198. package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
  199. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
  200. package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
  201. package/queries/query-print.js +5 -0
  202. package/queries/query.d.ts +10 -1
  203. package/queries/query.js +5 -2
  204. package/r-bridge/init.js +5 -1
  205. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
  207. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
  208. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
  209. package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
  210. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
  211. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
  212. package/r-bridge/parser.d.ts +2 -0
  213. package/r-bridge/retriever.js +4 -1
  214. package/r-bridge/roxygen2/documentation-provider.js +2 -1
  215. package/r-bridge/shell.d.ts +5 -0
  216. package/r-bridge/shell.js +17 -1
  217. package/reconstruct/inline/source-inline-map.d.ts +48 -0
  218. package/reconstruct/inline/source-inline-map.js +94 -0
  219. package/reconstruct/reconstruct.d.ts +19 -2
  220. package/reconstruct/reconstruct.js +79 -16
  221. package/search/search-executor/search-generators.js +5 -22
  222. package/search/search-executor/search-transformer.js +10 -6
  223. package/slicing/criterion/parse.d.ts +22 -4
  224. package/slicing/criterion/parse.js +125 -18
  225. package/slicing/static/slice-call.d.ts +24 -1
  226. package/slicing/static/slice-call.js +90 -0
  227. package/slicing/static/static-slicer.d.ts +7 -0
  228. package/slicing/static/static-slicer.js +38 -3
  229. package/util/collections/arrays.d.ts +4 -5
  230. package/util/collections/arrays.js +7 -18
  231. package/util/hash.d.ts +14 -0
  232. package/util/hash.js +31 -0
  233. package/util/mermaid/dfg.d.ts +7 -2
  234. package/util/mermaid/dfg.js +53 -13
  235. package/util/r-base-packages.d.ts +19 -0
  236. package/util/r-base-packages.js +72 -0
  237. package/util/r-license.js +2 -10
  238. package/util/r-version.d.ts +45 -15
  239. package/util/r-version.js +97 -36
  240. package/util/range.d.ts +15 -0
  241. package/util/range.js +39 -0
  242. package/util/schema.d.ts +10 -0
  243. package/util/schema.js +22 -0
  244. package/util/text/ansi.d.ts +3 -0
  245. package/util/text/ansi.js +10 -0
  246. package/util/text/args.js +1 -2
  247. package/util/version.js +28 -8
  248. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  249. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  250. package/documentation/wiki-package-database.d.ts +0 -9
  251. package/documentation/wiki-package-database.js +0 -63
  252. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
  253. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -176
  254. package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
  255. package/project/plugins/package-version-plugins/pkgdb.js +0 -370
@@ -35,10 +35,29 @@ interface AttachSpec {
35
35
  export declare function processLibrary<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: LibraryProcessorConfig): DataflowInformation;
36
36
  /** Materialize the empty built-in function-definition vertex for a package export (idempotent). */
37
37
  export declare function attachExportVertex(graph: DataflowGraph, builtInId: NodeId, environment: REnvironmentInformation, ctx: FlowrAnalyzerContext, cds?: ControlDependency[]): void;
38
+ /**
39
+ * The load calls (`library()`/`require()`) that brought package `pack` into scope without a database, collected from
40
+ * the {@link libraryLoadMarker} of every matching {@link EnvType.LoadedNamespace} layer below the global environment.
41
+ */
42
+ export declare function loadNodesForNamespace(env: REnvironmentInformation, pack: string): NodeId[];
38
43
  /**
39
44
  * Attaches `dependency`'s exports below the global environment (see {@link attachPackageBelowGlobal}) and returns the
40
45
  * enriched environment (the graph is untouched). Used by `library()`, `import::from`, `box::use`, `requireNamespace`,
41
46
  * and the transitive side-effect propagation.
42
47
  */
43
48
  export declare function attachDependencyToEnvironment(dependency: Package, envInfo: REnvironmentInformation, ctx: FlowrAnalyzerContext, spec?: AttachSpec, definedAt?: NodeId): REnvironmentInformation;
49
+ /**
50
+ * Attach the {@link baseRPackages|base-R} exports below the global so bare base calls resolve without `library()`.
51
+ * Names with a registered built-in are skipped, it is a no-op when no database resolves a base package, and the
52
+ * built layer is cached per {@link baseNamespaceCacheKey}.
53
+ */
54
+ export declare function attachBaseRNamespaces(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
55
+ /**
56
+ * Attach the exports of the project's declared `DESCRIPTION` dependencies (Imports/Depends, registered by the
57
+ * package-version plugins into {@link FlowrAnalyzerContext.deps|deps}) below the global so their bare calls resolve
58
+ * without an explicit `library()`, mirroring base-R auto-attach. A dependency whose {@link Package.namespaceInfo|
59
+ * namespaceInfo} no database resolves is skipped, and a package base-R or an earlier iteration already attached is a
60
+ * no-op via the {@link isAttached} guard inside {@link attachDependencyToEnvironment}.
61
+ */
62
+ export declare function attachDeclaredDependencies(env: REnvironmentInformation, ctx: FlowrAnalyzerContext): REnvironmentInformation;
44
63
  export {};
@@ -2,7 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processLibrary = processLibrary;
4
4
  exports.attachExportVertex = attachExportVertex;
5
+ exports.loadNodesForNamespace = loadNodesForNamespace;
5
6
  exports.attachDependencyToEnvironment = attachDependencyToEnvironment;
7
+ exports.attachBaseRNamespaces = attachBaseRNamespaces;
8
+ exports.attachDeclaredDependencies = attachDeclaredDependencies;
6
9
  const known_call_handling_1 = require("../known-call-handling");
7
10
  const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
8
11
  const r_access_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-access");
@@ -24,6 +27,7 @@ const flowr_namespace_file_1 = require("../../../../../../project/plugins/file-p
24
27
  const common_1 = require("../common");
25
28
  const linker_1 = require("../../../../linker");
26
29
  const vertex_1 = require("../../../../../graph/vertex");
30
+ const r_base_packages_1 = require("../../../../../../util/r-base-packages");
27
31
  /**
28
32
  * Process a library call like `library` or `require`
29
33
  */
@@ -150,6 +154,12 @@ function processLibrary(name, args, rootId, data, config = {}) {
150
154
  }
151
155
  else {
152
156
  info.graph.markIdForUnknownSideEffects(rootId);
157
+ // no database resolves the package, but the load is syntactically known: record it so an explicit
158
+ // `p::fn` can still link back to this call. requireNamespace/loadNamespace are recorded too, since
159
+ // they equally make `p::fn` valid.
160
+ if (info.environment.level >= 0) {
161
+ info.environment = recordUnresolvedLibraryLoad(info.environment, p, rootId, data.cds);
162
+ }
153
163
  }
154
164
  }
155
165
  if (packetName.length === 0) {
@@ -291,6 +301,43 @@ function attachExportVertex(graph, builtInId, environment, ctx, cds) {
291
301
  exitPoints: [],
292
302
  }, ctx.env.makeCleanEnv());
293
303
  }
304
+ /** Reserved marker binding recording an unresolved `library()`/`require()` load; the leading space cannot collide with a real export name. */
305
+ const libraryLoadMarker = ' library-load';
306
+ /**
307
+ * Record a syntactically known but database-unresolved package load below the global environment: a bare
308
+ * {@link EnvType.LoadedNamespace} layer for `pack` carrying only the reserved {@link libraryLoadMarker} whose
309
+ * `definedAt` is the load call. This lets an explicit `pack::fn` link back via {@link loadNodesForNamespace}
310
+ * even without a signature database.
311
+ */
312
+ function recordUnresolvedLibraryLoad(envInfo, pack, rootId, cds) {
313
+ const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define({
314
+ name: identifier_1.Identifier.make(libraryLoadMarker, pack),
315
+ type: identifier_1.ReferenceType.Function,
316
+ nodeId: rootId,
317
+ definedAt: rootId,
318
+ cds: cds?.slice()
319
+ });
320
+ return { level: envInfo.level, current: environment_1.REnvironment.attachBelowGlobal(envInfo.current, layer, layer) };
321
+ }
322
+ /**
323
+ * The load calls (`library()`/`require()`) that brought package `pack` into scope without a database, collected from
324
+ * the {@link libraryLoadMarker} of every matching {@link EnvType.LoadedNamespace} layer below the global environment.
325
+ */
326
+ function loadNodesForNamespace(env, pack) {
327
+ const nodes = [];
328
+ for (let e = environment_1.REnvironment.findGlobal(env.current).parent; e.t !== undefined && !e.builtInEnv; e = e.parent) {
329
+ if (e.n !== pack) {
330
+ continue;
331
+ }
332
+ for (const def of e.memory.get(libraryLoadMarker) ?? []) {
333
+ const definedAt = def.definedAt;
334
+ if (definedAt !== undefined) {
335
+ nodes.push(definedAt);
336
+ }
337
+ }
338
+ }
339
+ return nodes;
340
+ }
294
341
  function linkLibrary(dependency, info, rootId, data, spec = {}) {
295
342
  if (info.environment.level < 0 || (0, assert_1.isUndefined)(dependency.namespaceInfo)) {
296
343
  return;
@@ -302,9 +349,9 @@ function linkLibrary(dependency, info, rootId, data, spec = {}) {
302
349
  }
303
350
  // by default only the environment carries the exports; their built-in vertices are materialized on
304
351
  // demand when a call resolves to one (see attachExportVertex). Eager mode registers them all upfront.
305
- if (data.ctx.config.solver.pkgdb.eagerlyLoadExports) {
352
+ if (data.ctx.config.solver.sigdb.eagerlyLoadExports) {
306
353
  for (const { exported: func } of selectExports((0, flowr_namespace_file_1.getCallables)(dependency.namespaceInfo), spec)) {
307
- const builtInId = node_id_1.NodeId.toBuiltIn(package_1.Package.funcIdentif(pack, func));
354
+ const builtInId = node_id_1.NodeId.fromPkgFn(pack, func);
308
355
  attachExportVertex(info.graph, builtInId, info.environment, data.ctx, data.cds);
309
356
  info.graph.addEdge(builtInId, rootId, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
310
357
  }
@@ -324,7 +371,7 @@ function exportDefinition(pack, exp, definedAt = node_id_1.NodeId.toBuiltIn(pack
324
371
  return {
325
372
  name: identifier_1.Identifier.make(exp.as, pack),
326
373
  type: identifier_1.ReferenceType.Function,
327
- nodeId: node_id_1.NodeId.toBuiltIn(package_1.Package.funcIdentif(pack, exp.exported)),
374
+ nodeId: node_id_1.NodeId.fromPkgFn(pack, exp.exported),
328
375
  definedAt,
329
376
  };
330
377
  }
@@ -376,6 +423,64 @@ function isAttached(env, pack, namespaceOnly) {
376
423
  }
377
424
  return false;
378
425
  }
426
+ /** Immutable base-layer chains, shared across analyses (layers clone before mutating); building one is O(N^2) in exports, so cache and reparent. */
427
+ const baseNamespaceLayerCache = new Map();
428
+ function baseNamespaceCacheKey(ctx, basePackages) {
429
+ return `${String(ctx.env.getCleanEnvFingerprint())}|${ctx.resolvedRVersion}|${basePackages.join(',')}|${ctx.deps.baseRSourceFingerprint()}`;
430
+ }
431
+ /**
432
+ * Attach the {@link baseRPackages|base-R} exports below the global so bare base calls resolve without `library()`.
433
+ * Names with a registered built-in are skipped, it is a no-op when no database resolves a base package, and the
434
+ * built layer is cached per {@link baseNamespaceCacheKey}.
435
+ */
436
+ function attachBaseRNamespaces(env, ctx) {
437
+ if (!ctx.config.solver.sigdb.linkBaseR || !ctx.deps.hasBaseRSource()) {
438
+ return env;
439
+ }
440
+ const basePackages = ctx.config.project.basePackages ?? (0, r_base_packages_1.baseRPackages)(ctx.resolvedRVersion);
441
+ const key = baseNamespaceCacheKey(ctx, basePackages);
442
+ const cached = baseNamespaceLayerCache.get(key);
443
+ if (cached !== undefined) {
444
+ env.current.parent = cached;
445
+ return env;
446
+ }
447
+ let built = env;
448
+ let builtinNames;
449
+ for (const pkg of basePackages) {
450
+ const dependency = ctx.deps.getDependency(pkg);
451
+ if (dependency?.namespaceInfo === undefined) {
452
+ continue;
453
+ }
454
+ builtinNames ??= new Set([...ctx.env.builtInEnvironment.memory.keys()].map(String));
455
+ built = attachDependencyToEnvironment(dependency, built, ctx, { exclude: builtinNames }, node_id_1.NodeId.toBuiltIn(pkg));
456
+ }
457
+ if (built.current.parent !== env.current.parent) {
458
+ baseNamespaceLayerCache.set(key, built.current.parent);
459
+ }
460
+ return built;
461
+ }
462
+ /**
463
+ * Attach the exports of the project's declared `DESCRIPTION` dependencies (Imports/Depends, registered by the
464
+ * package-version plugins into {@link FlowrAnalyzerContext.deps|deps}) below the global so their bare calls resolve
465
+ * without an explicit `library()`, mirroring base-R auto-attach. A dependency whose {@link Package.namespaceInfo|
466
+ * namespaceInfo} no database resolves is skipped, and a package base-R or an earlier iteration already attached is a
467
+ * no-op via the {@link isAttached} guard inside {@link attachDependencyToEnvironment}.
468
+ */
469
+ function attachDeclaredDependencies(env, ctx) {
470
+ if (!ctx.config.solver.sigdb.linkDescriptionDependencies) {
471
+ return env;
472
+ }
473
+ let built = env;
474
+ for (const declared of ctx.deps.getDependencies()) {
475
+ // getDependency triggers lazy export resolution the raw declared record may still be missing
476
+ const dependency = ctx.deps.getDependency(declared.name);
477
+ if (dependency?.namespaceInfo === undefined) {
478
+ continue;
479
+ }
480
+ built = attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(dependency.name));
481
+ }
482
+ return built;
483
+ }
379
484
  function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
380
485
  for (const imp of namespaceInfo.importedPackages) {
381
486
  const importedDependency = ctx.deps.getDependency(imp[0]);
@@ -392,13 +497,13 @@ function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
392
497
  continue;
393
498
  }
394
499
  for (const func of funcToImport) {
395
- if (importsEnv.memory.has(package_1.Package.funcIdentif(importedDependency.name, func))) {
500
+ if (importsEnv.memory.has(package_1.Package.functionIdentifier(importedDependency.name, func))) {
396
501
  continue;
397
502
  }
398
503
  importsEnv = importsEnv.define({
399
- name: identifier_1.Identifier.make(package_1.Package.funcIdentif(importedDependency.name, func), importsEnv.n),
504
+ name: identifier_1.Identifier.make(package_1.Package.functionIdentifier(importedDependency.name, func), importsEnv.n),
400
505
  type: identifier_1.ReferenceType.Function,
401
- nodeId: node_id_1.NodeId.toBuiltIn(package_1.Package.funcIdentif(importedDependency.name, func)),
506
+ nodeId: node_id_1.NodeId.fromPkgFn(importedDependency.name, func),
402
507
  definedAt: node_id_1.NodeId.toBuiltIn(importedDependency.name)
403
508
  });
404
509
  }
@@ -4,6 +4,8 @@ exports.processPipe = processPipe;
4
4
  const known_call_handling_1 = require("../known-call-handling");
5
5
  const assert_1 = require("../../../../../../util/assert");
6
6
  const unpack_argument_1 = require("../argument/unpack-argument");
7
+ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
8
+ const data_masking_functions_1 = require("../../../../../environments/data-masking-functions");
7
9
  const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
8
10
  const logger_1 = require("../../../../../logger");
9
11
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
@@ -92,6 +94,17 @@ function processPipe(name, args, rootId, data, { pipePlaceholderName, assignLhs,
92
94
  });
93
95
  information.graph.addEdge(functionCallNode.id, argId, edge_1.EdgeType.Argument | edge_1.EdgeType.Reads);
94
96
  }
97
+ if (r_function_call_1.RFunctionCall.isNamed(rhs) && data_masking_functions_1.DataMaskingFunctionNames.has(identifier_1.Identifier.getName(rhs.functionName.content))) {
98
+ for (const arg of rhs.arguments) {
99
+ if (arg === r_function_call_1.EmptyArgument) {
100
+ continue;
101
+ }
102
+ model_1.RNode.visitAst(arg, node => {
103
+ information.graph.addEdge(rhs.info.id, node.info.id, edge_1.EdgeType.NonStandardEvaluation);
104
+ return false;
105
+ });
106
+ }
107
+ }
95
108
  }
96
109
  else {
97
110
  logger_1.dataflowLogger.warn(`Expected rhs of pipe to be a function call, but got ${rhs.type} instead.`);
@@ -99,11 +99,10 @@ args, rootId, data, config) {
99
99
  res.graph.addEdge(rootId, ref, edge_1.EdgeType.Reads);
100
100
  }
101
101
  }
102
- const fa = (0, unpack_argument_1.unpackNonameArg)(args[0]);
103
- if (fa) {
102
+ if (firstArg) {
104
103
  res = {
105
104
  ...res,
106
- in: [...res.in, { name: fa.lexeme, type: identifier_1.ReferenceType.Variable, nodeId: fa.info.id, cds: data.cds }]
105
+ in: [...res.in, { name: firstArg.lexeme, type: identifier_1.ReferenceType.Variable, nodeId: firstArg.info.id, cds: data.cds }]
107
106
  };
108
107
  }
109
108
  // dispatches actually as S3:
@@ -16,4 +16,13 @@ interface S7GenericDispatchConfig {
16
16
  * Process an S7 new generic dispatch call like `new_generic` or `setGeneric`.
17
17
  */
18
18
  export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S7GenericDispatchConfig): DataflowInformation;
19
+ /**
20
+ * Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
21
+ * `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, …). We model the result as a
22
+ * synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
23
+ * constant.
24
+ */
25
+ export declare function processMakeConstructor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config?: {
26
+ readonly mode?: readonly ('s7' | 's3' | 's4')[];
27
+ }): DataflowInformation;
19
28
  export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processS7NewGeneric = processS7NewGeneric;
4
+ exports.processMakeConstructor = processMakeConstructor;
4
5
  const known_call_handling_1 = require("../known-call-handling");
5
6
  const logger_1 = require("../../../../../logger");
6
7
  const linker_1 = require("../../../../linker");
@@ -69,6 +70,24 @@ function processS7NewGeneric(name, args, rootId, data, config) {
69
70
  }
70
71
  return info;
71
72
  }
73
+ /**
74
+ * Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
75
+ * `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, …). We model the result as a
76
+ * synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
77
+ * constant.
78
+ */
79
+ function processMakeConstructor(name, args, rootId, data, config) {
80
+ // synthesise `function(...) S7_dispatch()` and make the call return it
81
+ const [funArg, funId] = makeS7DispatchFDef(name, [], rootId, args.length, data.completeAst.idMap);
82
+ const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, forceArgs: 'all', args: [...args, funArg], rootId, data, origin: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor }).information;
83
+ info.graph.addEdge(rootId, funId, edge_1.EdgeType.Returns);
84
+ info.entryPoint = funId;
85
+ const fArg = info.graph.getVertex(funId);
86
+ if (fArg?.tag === vertex_1.VertexType.FunctionDefinition && config?.mode) {
87
+ fArg.mode ??= config.mode.slice(); // copy: mode is mutated in place later, config.mode is shared
88
+ }
89
+ return info;
90
+ }
72
91
  // 'function([dispatch_args],...) S7_dispatch()'; returns the value id
73
92
  function makeS7DispatchFDef(name, names, rootId, args, idMap) {
74
93
  const argNameId = rootId + '-s7-new-generic-fun-arg-name';
@@ -12,6 +12,12 @@ const edge_1 = require("../../../../../graph/edge");
12
12
  const linker_1 = require("../../../../linker");
13
13
  /** Formal parameter names for `with(data, expr, ...)` and `within(data, expr, ...)`. */
14
14
  const withParams = ['data', 'expr'];
15
+ /** Normal call analysis, marking the data-masked arguments (columns of the data) as NSE. */
16
+ function markAsMaskedFallback(name, args, rootId, data) {
17
+ const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With });
18
+ (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.AllButFirst);
19
+ return information;
20
+ }
15
21
  /**
16
22
  * Processes `with(data, expr)` and `within(data, expr)`.
17
23
  *
@@ -35,13 +41,15 @@ function processWithEnv(name, args, rootId, data) {
35
41
  const bound = (0, built_in_envir_utils_1.bindArgs)(args, withParams);
36
42
  const dataArg = bound.get('data');
37
43
  const exprArg = bound.get('expr');
38
- if (dataArg === undefined || dataArg === r_function_call_1.EmptyArgument || dataArg.value === undefined ||
39
- exprArg === undefined || exprArg === r_function_call_1.EmptyArgument || exprArg.value === undefined) {
40
- return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
44
+ // when we cannot resolve the data to a tracked environment, `expr` is still data-masked: its symbols name
45
+ // columns of `data`, not variables in scope, so mark the non-data arguments as non-standard-evaluated
46
+ if (dataArg === r_function_call_1.EmptyArgument || dataArg?.value === undefined ||
47
+ exprArg === r_function_call_1.EmptyArgument || exprArg?.value === undefined) {
48
+ return markAsMaskedFallback(name, args, rootId, data);
41
49
  }
42
50
  const envirResolution = (0, built_in_envir_utils_1.resolveArgToEnvir)(dataArg, data);
43
51
  if (!envirResolution) {
44
- return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With }).information;
52
+ return markAsMaskedFallback(name, args, rootId, data);
45
53
  }
46
54
  /* evaluate data arg in the caller's scope (it is just read) */
47
55
  const dfDataArg = (0, processor_1.processDataflowFor)(dataArg.value, data);
@@ -12,6 +12,7 @@ const identifier_1 = require("../../../../environments/identifier");
12
12
  const overwrite_1 = require("../../../../environments/overwrite");
13
13
  const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
14
14
  const type_1 = require("../../../../../r-bridge/lang-4.x/ast/model/type");
15
+ const process_argument_1 = require("../process-argument");
15
16
  const vertex_1 = require("../../../../graph/vertex");
16
17
  const edge_1 = require("../../../../graph/edge");
17
18
  const r_argument_1 = require("../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
@@ -96,7 +97,13 @@ function processAllArguments({ functionName, args, data, finalGraph, functionRoo
96
97
  processedArguments.push(undefined);
97
98
  continue;
98
99
  }
99
- const processed = (0, processor_1.processDataflowFor)(arg, data);
100
+ let processed;
101
+ if (i === 0 && data.precomputedFirstArg?.rootId === functionRootId) {
102
+ processed = data.precomputedFirstArg.info;
103
+ }
104
+ else {
105
+ processed = arg.type === type_1.RType.Argument ? (0, process_argument_1.processFunctionArgument)(arg, data) : (0, processor_1.processDataflowFor)(arg, data);
106
+ }
100
107
  if (r_argument_1.RArgument.isWithValue(arg) && (forceArgs === 'all' || forceArgs[i]) && !model_1.RConstant.is(arg.value)) {
101
108
  forceVertexArgumentValueReferences(functionRootId, processed, processed.graph, data.environment);
102
109
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processFunctionCall = processFunctionCall;
4
4
  const named_call_handling_1 = require("./named-call-handling");
5
5
  const unnamed_call_handling_1 = require("./unnamed-call-handling");
6
+ const process_named_call_1 = require("../../process-named-call");
6
7
  /**
7
8
  * Processes a function call, either named or unnamed.
8
9
  * @see {@link processNamedCall}
@@ -10,6 +11,11 @@ const unnamed_call_handling_1 = require("./unnamed-call-handling");
10
11
  */
11
12
  function processFunctionCall(functionCall, data) {
12
13
  if (functionCall.named) {
14
+ // magrittr-style `%op%` calls (e.g. `%>%`) are normalized as named calls, but chain left-associatively
15
+ // through their first argument just like a binary operator or pipe, so they fold instead of recursing
16
+ if (functionCall.infixSpecial === true && functionCall.arguments.length === 2) {
17
+ return (0, process_named_call_1.processChainedCall)(functionCall, data);
18
+ }
13
19
  return (0, named_call_handling_1.processNamedCall)(functionCall.functionName, functionCall.arguments, functionCall.info.id, data);
14
20
  }
15
21
  else {
@@ -45,6 +45,23 @@ export interface ProcessKnownFunctionCallResult {
45
45
  */
46
46
  readonly callArgs: readonly FunctionArgument[];
47
47
  }
48
+ /**
49
+ * Which arguments of a call {@link markArgumentsAsNonStandardEvaluation|are non-standardly evaluated}:
50
+ * every argument, all but the (data) first one, or only the first one.
51
+ */
52
+ export declare enum NseArguments {
53
+ /** every argument, e.g. the operands of a formula `~` or `aes(x, y)` */
54
+ All = "all",
55
+ /** all but the first, e.g. `subset(data, col > 1)` where the first argument is the data object */
56
+ AllButFirst = "all-but-first",
57
+ /** only the first, e.g. the native routine name in `.C(routine, ...)` */
58
+ First = "first"
59
+ }
60
+ /**
61
+ * Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
62
+ * (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
63
+ */
64
+ export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments): void;
48
65
  /**
49
66
  * Marks the given arguments as being involved in R's non-standard evaluation.
50
67
  */
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NseArguments = void 0;
4
+ exports.markArgumentsAsNonStandardEvaluation = markArgumentsAsNonStandardEvaluation;
3
5
  exports.markNonStandardEvaluationEdges = markNonStandardEvaluationEdges;
4
6
  exports.processKnownFunctionCall = processKnownFunctionCall;
5
7
  const processor_1 = require("../../../../processor");
@@ -11,6 +13,36 @@ const logger_1 = require("../../../../logger");
11
13
  const vertex_1 = require("../../../../graph/vertex");
12
14
  const unknown_side_effect_1 = require("../../../../graph/unknown-side-effect");
13
15
  const built_in_proc_name_1 = require("../../../../environments/built-in-proc-name");
16
+ /**
17
+ * Which arguments of a call {@link markArgumentsAsNonStandardEvaluation|are non-standardly evaluated}:
18
+ * every argument, all but the (data) first one, or only the first one.
19
+ */
20
+ var NseArguments;
21
+ (function (NseArguments) {
22
+ /** every argument, e.g. the operands of a formula `~` or `aes(x, y)` */
23
+ NseArguments["All"] = "all";
24
+ /** all but the first, e.g. `subset(data, col > 1)` where the first argument is the data object */
25
+ NseArguments["AllButFirst"] = "all-but-first";
26
+ /** only the first, e.g. the native routine name in `.C(routine, ...)` */
27
+ NseArguments["First"] = "first";
28
+ })(NseArguments || (exports.NseArguments = NseArguments = {}));
29
+ /**
30
+ * Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
31
+ * (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
32
+ */
33
+ function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which) {
34
+ const end = which === NseArguments.First ? 1 : processedArguments.length;
35
+ for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
36
+ const arg = processedArguments[i];
37
+ if (arg === undefined) {
38
+ continue;
39
+ }
40
+ graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
41
+ for (const [vtx] of arg.graph.vertices(true)) {
42
+ graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
43
+ }
44
+ }
45
+ }
14
46
  /**
15
47
  * Marks the given arguments as being involved in R's non-standard evaluation.
16
48
  */
@@ -9,6 +9,7 @@ const node_id_1 = require("../../../../../r-bridge/lang-4.x/ast/model/processing
9
9
  const resolve_by_name_1 = require("../../../../environments/resolve-by-name");
10
10
  const vertex_1 = require("../../../../graph/vertex");
11
11
  const identifier_1 = require("../../../../environments/identifier");
12
+ const r_base_packages_1 = require("../../../../../util/r-base-packages");
12
13
  const edge_1 = require("../../../../graph/edge");
13
14
  const built_in_library_1 = require("./built-in/built-in-library");
14
15
  function mergeInformation(info, newInfo) {
@@ -26,12 +27,6 @@ function mergeInformation(info, newInfo) {
26
27
  hooks: info.hooks.concat(newInfo.hooks)
27
28
  };
28
29
  }
29
- function processDefaultFunctionProcessor(information, name, args, rootId, data) {
30
- const resolve = (0, resolve_by_name_1.resolveByName)(name.content, data.environment, identifier_1.ReferenceType.Function);
31
- /* if we do not know where we land, we force! */
32
- const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: (resolve?.length ?? 0) > 0 ? undefined : 'all', origin: 'default' });
33
- return mergeInformation(information, call.information);
34
- }
35
30
  /**
36
31
  * Marks the given function call node as only calling built-in functions.
37
32
  */
@@ -67,7 +62,9 @@ function processNamedCall(name, args, rootId, data) {
67
62
  }
68
63
  }
69
64
  if (defaultProcessor) {
70
- information = processDefaultFunctionProcessor(information, name, args, rootId, data);
65
+ /* if we do not know where we land, we force! reuse `resolved`, data.environment did not change above */
66
+ const call = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: resolved.length > 0 ? undefined : 'all', origin: 'default' });
67
+ information = mergeInformation(information, call.information);
71
68
  }
72
69
  else if (information && builtIn) {
73
70
  // mark the function call as built in only
@@ -77,15 +74,40 @@ function processNamedCall(name, args, rootId, data) {
77
74
  // already know the loading call here, link to it (a function-local export is invisible to the later
78
75
  // top-level linkMaterializedExportsToLoaders pass, so we must catch it at the call site)
79
76
  if (information) {
77
+ const sigdb = data.ctx.config.solver.sigdb;
80
78
  for (const r of resolved) {
81
79
  if (r.type === identifier_1.ReferenceType.Function && r.nodeId !== undefined && node_id_1.NodeId.isBuiltIn(r.nodeId)) {
82
80
  (0, built_in_library_1.attachExportVertex)(information.graph, r.nodeId, data.environment, data.ctx, data.cds);
83
81
  const definedAt = r.definedAt;
84
82
  if (definedAt !== undefined && !node_id_1.NodeId.isBuiltIn(definedAt)) {
85
83
  information.graph.addEdge(r.nodeId, definedAt, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
84
+ // the call itself reads the library() load that made this export resolvable
85
+ information.graph.addEdge(rootId, definedAt, edge_1.EdgeType.Reads);
86
+ }
87
+ // opt-in: a lightweight ref edge from the call to its sigdb-backed package function vertex
88
+ if (sigdb.linkPackageCalls && node_id_1.NodeId.toPkgFn(r.nodeId) !== undefined) {
89
+ information.graph.addEdge(rootId, r.nodeId, edge_1.EdgeType.Reads);
86
90
  }
87
91
  }
88
92
  }
93
+ const ns = identifier_1.Identifier.getNamespace(name.content);
94
+ // an explicit `pkg::fn` links to a database-unresolved `library(pkg)` recorded below the global env
95
+ if (ns !== undefined) {
96
+ for (const loadNode of (0, built_in_library_1.loadNodesForNamespace)(data.environment, ns)) {
97
+ information.graph.addEdge(rootId, loadNode, edge_1.EdgeType.Reads);
98
+ }
99
+ }
100
+ // opt-in: link a bare base-R call to its sigdb function vertex (base-R qualification is edge-free otherwise);
101
+ // same guards as Identifier.toQualified -- not namespaced, not resolving to a user definition
102
+ if (sigdb.linkBaseRCalls && ns === undefined && !resolved.some(r => r.nodeId !== undefined && !node_id_1.NodeId.isBuiltIn(r.nodeId))) {
103
+ const bare = identifier_1.Identifier.getName(name.content);
104
+ const owner = (0, r_base_packages_1.baseRExportOwner)(bare);
105
+ if (owner !== undefined) {
106
+ const builtInId = node_id_1.NodeId.fromPkgFn(owner, bare);
107
+ (0, built_in_library_1.attachExportVertex)(information.graph, builtInId, data.environment, data.ctx, data.cds);
108
+ information.graph.addEdge(rootId, builtInId, edge_1.EdgeType.Reads);
109
+ }
110
+ }
89
111
  }
90
112
  return information ?? info_1.DataflowInformation.initialize(rootId, data);
91
113
  }
@@ -25,7 +25,18 @@ function linkReadsForArgument(root, ingoingRefs, graph) {
25
25
  */
26
26
  function processFunctionArgument(argument, data) {
27
27
  const name = argument.name === undefined ? undefined : (0, processor_1.processDataflowFor)(argument.name, data);
28
- const value = argument.value === undefined ? undefined : (0, processor_1.processDataflowFor)(argument.value, data);
28
+ let value;
29
+ if (argument.value === undefined) {
30
+ value = undefined;
31
+ }
32
+ else if (data.precomputedValue?.nodeId === argument.value.info.id) {
33
+ // the caller already processed this value iteratively (e.g., processChainedCall)
34
+ value = data.precomputedValue.info;
35
+ }
36
+ else {
37
+ // call the value's processor directly instead of going through processDataflowFor, safes one stack frame
38
+ value = data.processors[argument.value.type](argument.value, data);
39
+ }
29
40
  // we do not keep the graph of the name, as this is no node that should ever exist
30
41
  const graph = value?.graph ?? new graph_1.DataflowGraph(data.completeAst.idMap);
31
42
  const argumentName = argument.name?.content;
@@ -2,9 +2,26 @@ import type { DataflowProcessorInformation } from '../../processor';
2
2
  import type { DataflowInformation } from '../../info';
3
3
  import type { RAstNodeBase, RNode, Location } from '../../../r-bridge/lang-4.x/ast/model/model';
4
4
  import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
- import type { EmptyArgument } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
+ import { EmptyArgument, type RNamedFunctionCall } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
6
6
  import type { Identifier } from '../../environments/identifier';
7
+ import type { RBinaryOp } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
8
+ import type { RPipe } from '../../../r-bridge/lang-4.x/ast/model/nodes/r-pipe';
7
9
  /**
8
10
  * Helper function for {@link processNamedCall} using the given `functionName` as the name of the function.
9
11
  */
10
12
  export declare function processAsNamedCall<OtherInfo>({ info, lexeme, location }: RNode<OtherInfo & ParentInformation> & RAstNodeBase<OtherInfo> & Location, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, name: Identifier, args: readonly (RNode<OtherInfo & ParentInformation> | typeof EmptyArgument | undefined)[]): DataflowInformation;
13
+ type RBinaryOpOrPipe<OtherInfo> = (RBinaryOp<OtherInfo & ParentInformation> | RPipe<OtherInfo & ParentInformation>) & RAstNodeBase<OtherInfo> & Location;
14
+ /** A named, infix-special call, e.g. magrittr's `lhs %>% rhs`: normalized as a {@link RType#FunctionCall}, not as {@link RType#BinaryOp}. */
15
+ type RInfixSpecialCall<OtherInfo> = RNamedFunctionCall<OtherInfo & ParentInformation>;
16
+ /** Any node shape that forms a left-associative operator chain through its first/left operand. */
17
+ type ChainNode<OtherInfo> = RBinaryOpOrPipe<OtherInfo> | RInfixSpecialCall<OtherInfo>;
18
+ /**
19
+ * Processes a {@link ChainNode}: {@link RType#BinaryOp}, {@link RType#Pipe}, and magrittr-style `%op%` calls
20
+ * (infix-special {@link RType#FunctionCall}s) all nest on their left operand, so a long `a + b + c + ...` or
21
+ * `a %>% f() %>% f() %>% ...` chain buries it arbitrarily deep.
22
+ * This walks the left spine of chain nodes with an explicit loop (bounded stack usage regardless of
23
+ * chain length), processes the innermost (leftmost) node normally, and then folds outward: each level's left
24
+ * operand is wrapped via {@link processFunctionArgument}.
25
+ */
26
+ export declare function processChainedCall<OtherInfo>(node: ChainNode<OtherInfo>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): DataflowInformation;
27
+ export {};