@eagleoutice/flowr 2.11.0 → 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 (256) hide show
  1. package/README.md +190 -260
  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/flowr.js +1 -1
  12. package/cli/repl/commands/repl-commands.d.ts +1 -0
  13. package/cli/repl/commands/repl-commands.js +69 -17
  14. package/cli/repl/commands/repl-dataflow.js +48 -4
  15. package/cli/repl/commands/repl-main.d.ts +2 -0
  16. package/cli/repl/commands/repl-main.js +5 -0
  17. package/cli/repl/commands/repl-query.d.ts +4 -1
  18. package/cli/repl/commands/repl-query.js +72 -22
  19. package/cli/repl/commands/repl-signature.d.ts +7 -0
  20. package/cli/repl/commands/repl-signature.js +119 -0
  21. package/cli/repl/core.d.ts +8 -1
  22. package/cli/repl/core.js +46 -6
  23. package/cli/repl/ghost-hint.d.ts +37 -0
  24. package/cli/repl/ghost-hint.js +72 -0
  25. package/cli/repl/parser/slice-query-parser.d.ts +11 -1
  26. package/cli/repl/parser/slice-query-parser.js +45 -16
  27. package/cli/repl/print-version.d.ts +2 -4
  28. package/cli/repl/print-version.js +41 -23
  29. package/cli/repl/server/connection.js +19 -17
  30. package/cli/slicer-app.d.ts +2 -0
  31. package/cli/slicer-app.js +3 -3
  32. package/cli/wiki.d.ts +2 -2
  33. package/cli/wiki.js +2 -2
  34. package/config.d.ts +70 -13
  35. package/config.js +65 -7
  36. package/control-flow/cfg-dead-code.js +0 -1
  37. package/control-flow/control-flow-graph.js +6 -6
  38. package/control-flow/diff-cfg.js +2 -2
  39. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  40. package/core/print/slice-diff-ansi.js +8 -8
  41. package/core/steps/all/core/20-dataflow.d.ts +2 -2
  42. package/core/steps/all/static-slicing/00-slice.d.ts +5 -0
  43. package/core/steps/all/static-slicing/00-slice.js +1 -1
  44. package/core/steps/all/static-slicing/10-reconstruct.d.ts +7 -0
  45. package/core/steps/all/static-slicing/10-reconstruct.js +6 -2
  46. package/core/steps/pipeline/default-pipelines.d.ts +20 -16
  47. package/data/r-base-packages.generated.d.ts +44 -0
  48. package/data/r-base-packages.generated.js +32 -0
  49. package/data/r-base-primitives.generated.d.ts +1 -0
  50. package/data/r-base-primitives.generated.js +15 -0
  51. package/data/sigdb/sigdb.remote.json +112 -0
  52. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  53. package/dataflow/environments/built-in-proc-name.js +4 -0
  54. package/dataflow/environments/built-in.d.ts +14 -4
  55. package/dataflow/environments/built-in.js +13 -2
  56. package/dataflow/environments/data-masking-functions.d.ts +12 -0
  57. package/dataflow/environments/data-masking-functions.js +46 -0
  58. package/dataflow/environments/default-builtin-config.d.ts +72 -19
  59. package/dataflow/environments/default-builtin-config.js +48 -14
  60. package/dataflow/environments/diff.js +1 -1
  61. package/dataflow/environments/environment.js +1 -2
  62. package/dataflow/environments/identifier.d.ts +11 -4
  63. package/dataflow/environments/identifier.js +28 -10
  64. package/dataflow/environments/resolve-by-name.js +16 -2
  65. package/dataflow/extractor.js +6 -3
  66. package/dataflow/graph/call-graph.d.ts +2 -2
  67. package/dataflow/graph/df-helper.d.ts +4 -4
  68. package/dataflow/graph/diff-dataflow-graph.js +2 -2
  69. package/dataflow/graph/edge.d.ts +3 -3
  70. package/dataflow/graph/edge.js +3 -3
  71. package/dataflow/graph/graph-helper.d.ts +2 -2
  72. package/dataflow/internal/linker.js +1 -1
  73. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +7 -0
  74. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +20 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +1 -0
  76. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +2 -49
  77. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +7 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +19 -0
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +111 -6
  81. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +13 -0
  82. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +2 -3
  83. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +19 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +12 -4
  86. package/dataflow/internal/process/functions/call/common.js +8 -1
  87. package/dataflow/internal/process/functions/call/default-call-handling.js +6 -0
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +17 -0
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +32 -0
  90. package/dataflow/internal/process/functions/call/named-call-handling.js +29 -7
  91. package/dataflow/internal/process/functions/process-argument.js +12 -1
  92. package/dataflow/internal/process/process-named-call.d.ts +18 -1
  93. package/dataflow/internal/process/process-named-call.js +94 -0
  94. package/dataflow/processor.d.ts +18 -0
  95. package/documentation/data/faq/faqs.js +5 -1
  96. package/documentation/doc-capabilities.js +1 -1
  97. package/documentation/doc-util/doc-cli-option.d.ts +10 -0
  98. package/documentation/doc-util/doc-cli-option.js +23 -0
  99. package/documentation/doc-util/doc-dfg.js +2 -1
  100. package/documentation/doc-util/doc-query.d.ts +9 -3
  101. package/documentation/doc-util/doc-query.js +9 -4
  102. package/documentation/wiki-dataflow-graph.js +8 -5
  103. package/documentation/wiki-interface.js +3 -2
  104. package/documentation/wiki-linter.js +1 -1
  105. package/documentation/wiki-linting-and-testing.js +4 -1
  106. package/documentation/wiki-mk/doc-context.d.ts +14 -0
  107. package/documentation/wiki-mk/doc-context.js +3 -0
  108. package/documentation/wiki-mk/doc-maker.js +3 -1
  109. package/documentation/wiki-query.js +19 -1
  110. package/documentation/wiki-setup.js +10 -7
  111. package/documentation/wiki-signature-database.d.ts +16 -0
  112. package/documentation/wiki-signature-database.js +293 -0
  113. package/linter/linter-format.d.ts +7 -0
  114. package/linter/linter-rules.d.ts +10 -9
  115. package/linter/rules/naming-convention.d.ts +1 -0
  116. package/linter/rules/naming-convention.js +2 -0
  117. package/linter/rules/no-leaked-credentials.js +1 -2
  118. package/linter/rules/roxygen-arguments.js +18 -5
  119. package/linter/rules/stop-with-call-arg.js +2 -2
  120. package/linter/rules/undefined-symbol-util.d.ts +36 -0
  121. package/linter/rules/undefined-symbol-util.js +149 -0
  122. package/linter/rules/undefined-symbol.d.ts +58 -17
  123. package/linter/rules/undefined-symbol.js +143 -33
  124. package/linter/rules/unused-definition.d.ts +8 -1
  125. package/linter/rules/unused-definition.js +126 -1
  126. package/package.json +23 -10
  127. package/project/context/abstract-flowr-analyzer-context.js +7 -1
  128. package/project/context/flowr-analyzer-context.d.ts +8 -0
  129. package/project/context/flowr-analyzer-context.js +10 -0
  130. package/project/context/flowr-analyzer-dependencies-context.d.ts +28 -4
  131. package/project/context/flowr-analyzer-dependencies-context.js +53 -1
  132. package/project/context/flowr-analyzer-files-context.d.ts +1 -0
  133. package/project/context/flowr-analyzer-files-context.js +2 -1
  134. package/project/context/flowr-analyzer-functions-context.js +1 -1
  135. package/project/context/flowr-file.d.ts +5 -0
  136. package/project/context/flowr-file.js +5 -0
  137. package/project/flowr-analyzer-builder.js +12 -2
  138. package/project/plugins/file-plugins/files/flowr-description-file.js +6 -3
  139. package/project/plugins/file-plugins/files/flowr-namespace-file.js +9 -3
  140. package/project/plugins/file-plugins/files/flowr-news-file.js +1 -3
  141. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.d.ts +26 -0
  142. package/project/plugins/file-plugins/flowr-analyzer-inst-file-plugin.js +39 -0
  143. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -1
  144. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
  145. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -0
  146. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +18 -2
  147. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +19 -0
  148. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +120 -0
  149. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +518 -0
  150. package/project/plugins/package-version-plugins/package.d.ts +5 -3
  151. package/project/plugins/package-version-plugins/package.js +27 -25
  152. package/project/plugins/plugin-registry.d.ts +3 -2
  153. package/project/plugins/plugin-registry.js +4 -2
  154. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +7 -2
  155. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +3 -1
  156. package/project/sigdb/build.d.ts +131 -0
  157. package/project/sigdb/build.js +628 -0
  158. package/project/sigdb/codec.d.ts +51 -0
  159. package/project/sigdb/codec.js +122 -0
  160. package/project/sigdb/decode.d.ts +58 -0
  161. package/project/sigdb/decode.js +129 -0
  162. package/project/sigdb/decompress.d.ts +44 -0
  163. package/project/sigdb/decompress.js +176 -0
  164. package/project/sigdb/hash.d.ts +9 -0
  165. package/project/sigdb/hash.js +54 -0
  166. package/project/sigdb/index-format.d.ts +40 -0
  167. package/project/sigdb/index-format.js +28 -0
  168. package/project/sigdb/manifest.d.ts +68 -0
  169. package/project/sigdb/manifest.js +146 -0
  170. package/project/sigdb/reader.d.ts +250 -0
  171. package/project/sigdb/reader.js +692 -0
  172. package/project/sigdb/schema.d.ts +196 -0
  173. package/project/sigdb/schema.js +33 -0
  174. package/project/sigdb/sigdb-download.d.ts +65 -0
  175. package/project/sigdb/sigdb-download.js +237 -0
  176. package/project/sigdb/signature-match.d.ts +26 -0
  177. package/project/sigdb/signature-match.js +40 -0
  178. package/project/sigdb/version.d.ts +20 -0
  179. package/project/sigdb/version.js +55 -0
  180. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -3
  181. package/queries/catalog/config-query/config-query-format.d.ts +3 -1
  182. package/queries/catalog/config-query/config-query-format.js +68 -9
  183. package/queries/catalog/dataflow-query/dataflow-query-format.js +11 -1
  184. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  185. package/queries/catalog/linter-query/linter-query-executor.d.ts +2 -0
  186. package/queries/catalog/linter-query/linter-query-executor.js +6 -1
  187. package/queries/catalog/linter-query/linter-query-format.d.ts +2 -1
  188. package/queries/catalog/linter-query/linter-query-format.js +40 -8
  189. package/queries/catalog/project-query/project-query-executor.d.ts +15 -0
  190. package/queries/catalog/project-query/project-query-executor.js +96 -4
  191. package/queries/catalog/project-query/project-query-format.d.ts +44 -0
  192. package/queries/catalog/project-query/project-query-format.js +33 -2
  193. package/queries/catalog/signature-query/signature-query-executor.d.ts +29 -0
  194. package/queries/catalog/signature-query/signature-query-executor.js +461 -0
  195. package/queries/catalog/signature-query/signature-query-format.d.ts +138 -0
  196. package/queries/catalog/signature-query/signature-query-format.js +76 -0
  197. package/queries/catalog/signature-query/signature-query-render.d.ts +15 -0
  198. package/queries/catalog/signature-query/signature-query-render.js +155 -0
  199. package/queries/catalog/static-slice-query/static-slice-query-executor.js +9 -3
  200. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +10 -0
  201. package/queries/catalog/static-slice-query/static-slice-query-format.js +19 -1
  202. package/queries/query-print.js +5 -0
  203. package/queries/query.d.ts +10 -1
  204. package/queries/query.js +5 -2
  205. package/r-bridge/init.js +5 -1
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +10 -0
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +55 -0
  208. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +16 -0
  209. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +27 -0
  210. package/r-bridge/lang-4.x/ast/parser/json/format.js +89 -2
  211. package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +2 -4
  212. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +2 -1
  213. package/r-bridge/parser.d.ts +2 -0
  214. package/r-bridge/retriever.js +4 -1
  215. package/r-bridge/roxygen2/documentation-provider.js +2 -1
  216. package/r-bridge/shell.d.ts +5 -0
  217. package/r-bridge/shell.js +17 -1
  218. package/reconstruct/inline/source-inline-map.d.ts +48 -0
  219. package/reconstruct/inline/source-inline-map.js +94 -0
  220. package/reconstruct/reconstruct.d.ts +19 -2
  221. package/reconstruct/reconstruct.js +79 -16
  222. package/search/search-executor/search-generators.js +5 -22
  223. package/search/search-executor/search-transformer.js +10 -6
  224. package/slicing/criterion/parse.d.ts +22 -4
  225. package/slicing/criterion/parse.js +125 -18
  226. package/slicing/static/slice-call.d.ts +24 -1
  227. package/slicing/static/slice-call.js +90 -0
  228. package/slicing/static/static-slicer.d.ts +7 -0
  229. package/slicing/static/static-slicer.js +38 -3
  230. package/util/collections/arrays.d.ts +4 -5
  231. package/util/collections/arrays.js +7 -18
  232. package/util/hash.d.ts +14 -0
  233. package/util/hash.js +31 -0
  234. package/util/mermaid/dfg.d.ts +7 -2
  235. package/util/mermaid/dfg.js +53 -13
  236. package/util/r-base-packages.d.ts +19 -0
  237. package/util/r-base-packages.js +72 -0
  238. package/util/r-license.js +2 -10
  239. package/util/r-version.d.ts +45 -15
  240. package/util/r-version.js +97 -36
  241. package/util/range.d.ts +15 -0
  242. package/util/range.js +39 -0
  243. package/util/schema.d.ts +10 -0
  244. package/util/schema.js +22 -0
  245. package/util/text/ansi.d.ts +13 -1
  246. package/util/text/ansi.js +27 -4
  247. package/util/text/args.js +1 -2
  248. package/util/version.js +28 -8
  249. package/data/pkgdb/pkgdb-latest.json.br +0 -0
  250. package/data/pkgdb/pkgdb-tiny.json.br +0 -0
  251. package/documentation/wiki-package-database.d.ts +0 -9
  252. package/documentation/wiki-package-database.js +0 -63
  253. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.d.ts +0 -63
  254. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-pkgdb-plugin.js +0 -174
  255. package/project/plugins/package-version-plugins/pkgdb.d.ts +0 -133
  256. package/project/plugins/package-version-plugins/pkgdb.js +0 -370
@@ -45,9 +45,9 @@ export declare const enum EdgeTypeName {
45
45
  DefinedBy = "defined-by",
46
46
  Calls = "calls",
47
47
  Returns = "returns",
48
- DefinesOnCall = "defines-on-call",
49
- DefinedByOnCall = "defined-by-on-call",
50
- Argument = "argument",
48
+ DefinesOnCall = "def-on-call",
49
+ DefinedByOnCall = "def-by-on-call",
50
+ Argument = "arg",
51
51
  SideEffectOnCall = "side-effect-on-call",
52
52
  NonStandardEvaluation = "non-standard-evaluation"
53
53
  }
@@ -38,9 +38,9 @@ const edgeTypeToHumanReadableName = new Map([
38
38
  [EdgeType.DefinedBy, "defined-by" /* EdgeTypeName.DefinedBy */],
39
39
  [EdgeType.Calls, "calls" /* EdgeTypeName.Calls */],
40
40
  [EdgeType.Returns, "returns" /* EdgeTypeName.Returns */],
41
- [EdgeType.DefinesOnCall, "defines-on-call" /* EdgeTypeName.DefinesOnCall */],
42
- [EdgeType.DefinedByOnCall, "defined-by-on-call" /* EdgeTypeName.DefinedByOnCall */],
43
- [EdgeType.Argument, "argument" /* EdgeTypeName.Argument */],
41
+ [EdgeType.DefinesOnCall, "def-on-call" /* EdgeTypeName.DefinesOnCall */],
42
+ [EdgeType.DefinedByOnCall, "def-by-on-call" /* EdgeTypeName.DefinedByOnCall */],
43
+ [EdgeType.Argument, "arg" /* EdgeTypeName.Argument */],
44
44
  [EdgeType.SideEffectOnCall, "side-effect-on-call" /* EdgeTypeName.SideEffectOnCall */],
45
45
  [EdgeType.NonStandardEvaluation, "non-standard-evaluation" /* EdgeTypeName.NonStandardEvaluation */]
46
46
  ]);
@@ -29,8 +29,8 @@ export declare const GraphHelper: {
29
29
  string: string;
30
30
  mermaid: import("../../util/mermaid/dfg").MermaidGraph;
31
31
  };
32
- readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
33
- readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
32
+ readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
33
+ readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
34
34
  };
35
35
  readonly quads: {
36
36
  readonly convert: typeof df2quads;
@@ -292,7 +292,7 @@ function linkFunctionCall(graph, id, info, idMap, thisGraph, calledFunctionDefin
292
292
  functionDefinitionReadIds.add(t);
293
293
  }
294
294
  }
295
- const [functionDefs] = getAllLinkedFunctionDefinitions(new Set(functionDefinitionReadIds), graph);
295
+ const [functionDefs] = getAllLinkedFunctionDefinitions(functionDefinitionReadIds, graph);
296
296
  const propagateExitPoints = [];
297
297
  for (const def of functionDefs.values()) {
298
298
  // we can skip this if we already linked it
@@ -68,6 +68,13 @@ export interface AssignmentToSymbolParameters<OtherInfo> extends AssignmentConfi
68
68
  * @param data - The dataflow analysis fold backpack
69
69
  * @param assignmentConfig - configuration for the assignment processing
70
70
  */
71
+ /**
72
+ * Model a call like `Hmisc::getHdata(x)` that loads a dataset into the variable it is *given*: the argument symbol
73
+ * `x` is both **read** (as the call's argument, its value comes from outside the code) and **defined** by the call.
74
+ * Unlike {@link markAsAssignment} we keep the read edge.
75
+ */
76
+ export declare function processDefineArgument<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: AssignmentConfiguration): DataflowInformation;
77
+ /** Define `nodeToDefine` in the environment and wire the `DefinedBy` edges from it to its sources and the assignment root (dropping the child-added read edges). */
71
78
  export declare function markAsAssignment<OtherInfo>(information: {
72
79
  environment: REnvironmentInformation;
73
80
  graph: DataflowGraph;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processAssignmentLike = processAssignmentLike;
4
4
  exports.processAssignment = processAssignment;
5
+ exports.processDefineArgument = processDefineArgument;
5
6
  exports.markAsAssignment = markAsAssignment;
6
7
  const known_call_handling_1 = require("../known-call-handling");
7
8
  const log_1 = require("../../../../../../util/log");
@@ -389,6 +390,25 @@ function tryRouteToCustomEnv(name, args, rootId, data, config) {
389
390
  * @param data - The dataflow analysis fold backpack
390
391
  * @param assignmentConfig - configuration for the assignment processing
391
392
  */
393
+ /**
394
+ * Model a call like `Hmisc::getHdata(x)` that loads a dataset into the variable it is *given*: the argument symbol
395
+ * `x` is both **read** (as the call's argument, its value comes from outside the code) and **defined** by the call.
396
+ * Unlike {@link markAsAssignment} we keep the read edge.
397
+ */
398
+ function processDefineArgument(name, args, rootId, data, config) {
399
+ const res = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: built_in_proc_name_1.BuiltInProcName.DefineArgument });
400
+ const info = res.information;
401
+ const targetArg = res.processedArguments[0]; // the read argument, e.g. `prostate`
402
+ if (targetArg !== undefined) {
403
+ for (const node of produceWrittenNodes(rootId, targetArg, identifier_1.ReferenceType.Variable, data, false, undefined)) {
404
+ info.environment = (0, define_1.define)(node, config.superAssignment, info.environment);
405
+ info.graph.setDefinitionOfVertex(node, [rootId]);
406
+ info.graph.addEdge(node.nodeId, rootId, edge_1.EdgeType.DefinedBy); // defined by the call; the read edge is left intact
407
+ }
408
+ }
409
+ return info;
410
+ }
411
+ /** Define `nodeToDefine` in the environment and wire the `DefinedBy` edges from it to its sources and the assignment root (dropping the child-added read edges). */
392
412
  function markAsAssignment(information, nodeToDefine, sourceIds, rootIdOfAssignment, data, assignmentConfig) {
393
413
  information.environment = (0, define_1.define)(nodeToDefine, assignmentConfig?.superAssignment, information.environment);
394
414
  information.graph.setDefinitionOfVertex(nodeToDefine, sourceIds);
@@ -22,6 +22,7 @@ export interface EnvirResolution<OtherInfo> {
22
22
  /**
23
23
  * Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
24
24
  * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
25
+ * Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
25
26
  */
26
27
  export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], paramNames: readonly string[]): ReadonlyMap<string, PotentiallyEmptyRArgument<OtherInfo & ParentInformation>>;
27
28
  /** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
@@ -54,57 +54,10 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
54
54
  /**
55
55
  * Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
56
56
  * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
57
+ * Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
57
58
  */
58
59
  function bindArgs(args, paramNames) {
59
- const bound = new Map();
60
- const used = new Set();
61
- /* pass 1: exact name matches */
62
- for (let i = 0; i < args.length; i++) {
63
- const arg = args[i];
64
- if (arg === r_function_call_1.EmptyArgument || arg.name === undefined) {
65
- continue;
66
- }
67
- const n = arg.name.content;
68
- if (paramNames.includes(n) && !bound.has(n)) {
69
- bound.set(n, arg);
70
- used.add(i);
71
- }
72
- }
73
- /* pass 2: partial (pmatch) name matches */
74
- for (let i = 0; i < args.length; i++) {
75
- if (used.has(i)) {
76
- continue;
77
- }
78
- const arg = args[i];
79
- if (arg === r_function_call_1.EmptyArgument || arg.name === undefined) {
80
- continue;
81
- }
82
- const matched = (0, prefix_1.findByPrefixIfUnique)(arg.name.content, paramNames);
83
- if (matched !== undefined && !bound.has(matched)) {
84
- bound.set(matched, arg);
85
- used.add(i);
86
- }
87
- }
88
- /* pass 3: remaining unnamed args fill remaining formal params left-to-right */
89
- let formalIdx = 0;
90
- for (let i = 0; i < args.length; i++) {
91
- if (used.has(i)) {
92
- continue;
93
- }
94
- const arg = args[i];
95
- if (arg === r_function_call_1.EmptyArgument || arg.name !== undefined) {
96
- continue;
97
- }
98
- while (formalIdx < paramNames.length && bound.has(paramNames[formalIdx])) {
99
- formalIdx++;
100
- }
101
- if (formalIdx < paramNames.length) {
102
- bound.set(paramNames[formalIdx], arg);
103
- used.add(i);
104
- formalIdx++;
105
- }
106
- }
107
- return bound;
60
+ return r_function_call_1.RFunctionCall.matchArgsToParams(args, paramNames);
108
61
  }
109
62
  /** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
110
63
  function resolveArgToEnvir(arg, data) {
@@ -104,7 +104,12 @@ function processFunctionDefinition(name, args, rootId, data) {
104
104
  /* theoretically, we should just check if there is a global effect-write somewhere within */
105
105
  if (remainingRead.length > 0) {
106
106
  const nameIdShares = (0, linker_1.produceNameSharedIdMap)(remainingRead);
107
- const definedInLocalEnvironment = new Set(Array.from(bodyEnvironment.current.memory.values()).flat().map(d => d.nodeId));
107
+ const definedInLocalEnvironment = new Set();
108
+ for (const defs of bodyEnvironment.current.memory.values()) {
109
+ for (const d of defs) {
110
+ definedInLocalEnvironment.add(d.nodeId);
111
+ }
112
+ }
108
113
  // Everything that is in body.out but not within the local environment populated for the function scope is a potential escape ~> global definition
109
114
  const globalBodyOut = body.out.filter(d => !definedInLocalEnvironment.has(d.nodeId));
110
115
  (0, linker_1.linkCircularRedefinitionsWithinALoop)(body.graph, nameIdShares, globalBodyOut);
@@ -55,7 +55,13 @@ function processGet(name, args, rootId, data) {
55
55
  if (resolution) {
56
56
  information.graph.addEdge(rootId, resolution.envirNodeId, edge_1.EdgeType.Reads);
57
57
  }
58
+ const isolatedTarget = resolution?.envirData.environment.current.builtInEnv === true;
59
+ const readsToDrop = isolatedTarget && firstProcessed ? new Set([firstProcessed.entryPoint]) : undefined;
58
60
  /* restore the caller's (global) environment so we don't leak envState upward */
59
- return { ...information, environment: data.environment };
61
+ return {
62
+ ...information,
63
+ in: readsToDrop ? information.in.filter(({ nodeId }) => !readsToDrop.has(nodeId)) : information.in,
64
+ environment: data.environment
65
+ };
60
66
  }
61
67
  //# sourceMappingURL=built-in-get.js.map
@@ -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.eagerlyLoadPackages) {
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
  */