@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
@@ -9,6 +9,8 @@ const unnamed_call_handling_1 = require("../internal/process/functions/call/unna
9
9
  const hooks_1 = require("../hooks");
10
10
  const identifier_1 = require("./identifier");
11
11
  const built_in_proc_name_1 = require("./built-in-proc-name");
12
+ const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
13
+ const data_masking_functions_1 = require("./data-masking-functions");
12
14
  /** Which stack environment an env-returning/-transforming builtin denotes (see {@link StackEnvBuiltins}). */
13
15
  var StackEnvKind;
14
16
  (function (StackEnvKind) {
@@ -144,11 +146,34 @@ exports.DefaultBuiltinConfig = [
144
146
  value: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], assumePrimitive: true },
145
147
  { type: 'constant', names: [identifier_1.Identifier.from(['month.name', "base" /* PkgName.Base */])],
146
148
  value: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], assumePrimitive: true },
149
+ /* formula: operands are model terms/columns, not variables (NSE) */
150
+ {
151
+ type: 'function',
152
+ names: [identifier_1.Identifier.from(['~', "base" /* PkgName.Base */])],
153
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
154
+ config: { markArgsAsNSE: known_call_handling_1.NseArguments.All },
155
+ assumePrimitive: false
156
+ },
157
+ /* data-masking: the non-data arguments name columns of the (first) data object, not variables (NSE) */
158
+ {
159
+ type: 'function',
160
+ names: data_masking_functions_1.DataMaskingFunctionIdentifiers,
161
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
162
+ config: { markArgsAsNSE: known_call_handling_1.NseArguments.AllButFirst },
163
+ assumePrimitive: false
164
+ },
165
+ /* data-masking without a data argument, e.g. `aes(x, y)` */
166
+ {
167
+ type: 'function',
168
+ names: [identifier_1.Identifier.from(['aes', "ggplot2" /* PkgName.GgPlot2 */]), identifier_1.Identifier.from(['aes_string', "ggplot2" /* PkgName.GgPlot2 */]), identifier_1.Identifier.from(['vars', "ggplot2" /* PkgName.GgPlot2 */])],
169
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
170
+ config: { markArgsAsNSE: known_call_handling_1.NseArguments.All },
171
+ assumePrimitive: false
172
+ },
147
173
  {
148
174
  type: 'function',
149
175
  names: [
150
176
  /* arithmetic & comparison operators (base) */
151
- identifier_1.Identifier.from(['~', "base" /* PkgName.Base */]),
152
177
  identifier_1.Identifier.from(['+', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['-', "base" /* PkgName.Base */]),
153
178
  identifier_1.Identifier.from(['*', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['/', "base" /* PkgName.Base */]),
154
179
  identifier_1.Identifier.from(['^', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['**', "base" /* PkgName.Base */]),
@@ -182,7 +207,7 @@ exports.DefaultBuiltinConfig = [
182
207
  identifier_1.Identifier.from(['as.data.frame', "base" /* PkgName.Base */]),
183
208
  /* collections & data (base) */
184
209
  identifier_1.Identifier.from(['unique', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['intersect', "base" /* PkgName.Base */]),
185
- identifier_1.Identifier.from(['subset', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['match', "base" /* PkgName.Base */]),
210
+ identifier_1.Identifier.from(['match', "base" /* PkgName.Base */]),
186
211
  identifier_1.Identifier.from(['which', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['any', "base" /* PkgName.Base */]),
187
212
  identifier_1.Identifier.from(['length', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['expression', "base" /* PkgName.Base */]),
188
213
  identifier_1.Identifier.from(['factor', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['missing', "base" /* PkgName.Base */]),
@@ -230,9 +255,11 @@ exports.DefaultBuiltinConfig = [
230
255
  { type: 'function', names: [identifier_1.Identifier.from(['apply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['tapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Tapply', "functools" /* PkgName.Functools */])],
231
256
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 2, nameOfFunctionArgument: 'FUN' }, assumePrimitive: false },
232
257
  { type: 'function', names: [identifier_1.Identifier.from(['print', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['message', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['warning', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['warn', "rlang" /* PkgName.Rlang */]), identifier_1.Identifier.from(['warn', "R.utils" /* PkgName.Rutils */]), identifier_1.Identifier.from(['info', "msgr" /* PkgName.Msgr */])],
233
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
258
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, forceArgs: 'all', keepArgumentOut: true, hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
234
259
  { type: 'function', names: [identifier_1.Identifier.from(['invisible', "base" /* PkgName.Base */])],
235
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, forceArgs: 'all' }, assumePrimitive: true },
260
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, forceArgs: 'all', keepArgumentOut: true }, assumePrimitive: true },
261
+ { type: 'function', names: [identifier_1.Identifier.from(['force', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['identity', "base" /* PkgName.Base */])],
262
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, forceArgs: 'all', keepArgumentOut: true }, assumePrimitive: false },
236
263
  // graphics base
237
264
  { type: 'function', names: exports.PlotCreate,
238
265
  processor: built_in_proc_name_1.BuiltInProcName.Default,
@@ -321,7 +348,7 @@ exports.DefaultBuiltinConfig = [
321
348
  }, assumePrimitive: true
322
349
  },
323
350
  { type: 'function', names: ['('],
324
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0 }, assumePrimitive: true },
351
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, keepArgumentOut: true }, assumePrimitive: true },
325
352
  { type: 'function', names: [identifier_1.Identifier.from(['load_all', "pkgload" /* PkgName.PkgLoad */]), identifier_1.Identifier.from(['load_all', "devtools" /* PkgName.Devtools */]), identifier_1.Identifier.from(['setwd', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['set.seed', "base" /* PkgName.Base */])],
326
353
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true] }, assumePrimitive: false },
327
354
  { type: 'function', names: [identifier_1.Identifier.from(['body', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['formals', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['environment', "base" /* PkgName.Base */])],
@@ -333,6 +360,8 @@ exports.DefaultBuiltinConfig = [
333
360
  config: {
334
361
  hasUnknownSideEffects: true,
335
362
  forceArgs: [true],
363
+ /* first arg names a native routine (useDynLib), not a variable */
364
+ markArgsAsNSE: known_call_handling_1.NseArguments.First,
336
365
  treatAsFnCall: {
337
366
  '.Call': ['.NAME'],
338
367
  '.External': ['.NAME'],
@@ -351,7 +380,7 @@ exports.DefaultBuiltinConfig = [
351
380
  { type: 'function', names: [identifier_1.Identifier.from(['switch', "base" /* PkgName.Base */])],
352
381
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: [true] }, assumePrimitive: false },
353
382
  { type: 'function', names: ['return'],
354
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return */, useAsProcessor: built_in_proc_name_1.BuiltInProcName.Return }, assumePrimitive: true },
383
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return */, keepArgumentOut: true, useAsProcessor: built_in_proc_name_1.BuiltInProcName.Return }, assumePrimitive: true },
355
384
  {
356
385
  type: 'function',
357
386
  names: [
@@ -422,6 +451,8 @@ exports.DefaultBuiltinConfig = [
422
451
  processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { swapSourceAndTarget: true, canBeReplacement: true }, assumePrimitive: true },
423
452
  { type: 'function', names: ['->>'],
424
453
  processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { superAssignment: true, swapSourceAndTarget: true, canBeReplacement: true }, assumePrimitive: true },
454
+ { type: 'function', names: [identifier_1.Identifier.from(['data', "utils" /* PkgName.Utils */]), identifier_1.Identifier.from(['getHdata', "Hmisc" /* PkgName.Hmisc */])],
455
+ processor: built_in_proc_name_1.BuiltInProcName.DefineArgument, config: { superAssignment: true }, assumePrimitive: false },
425
456
  { type: 'function', names: [identifier_1.Identifier.from(['&&', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['&', "base" /* PkgName.Base */])],
426
457
  processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: true, evalRhsWhen: true }, assumePrimitive: true },
427
458
  { type: 'function', names: [identifier_1.Identifier.from(['||', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['|', "base" /* PkgName.Base */])],
@@ -562,13 +593,6 @@ exports.DefaultBuiltinConfig = [
562
593
  '.f': { index: 1, name: '.fns' },
563
594
  ignore: ['.names', '.unpack']
564
595
  } },
565
- { type: 'function', names: [identifier_1.Identifier.from(['filter', "dplyr" /* PkgName.Dplyr */]), identifier_1.Identifier.from(['filter_out', "janitor" /* PkgName.Janitor */])], processor: built_in_proc_name_1.BuiltInProcName.PurrrFormula, config: {
566
- args: {
567
- '.x': { index: 0, name: '.data' },
568
- },
569
- '.f': { index: 1, name: '...' },
570
- ignore: ['.by', '.preserve']
571
- } },
572
596
  { type: 'function', names: [identifier_1.Identifier.from(['rename_with', "dplyr" /* PkgName.Dplyr */])], processor: built_in_proc_name_1.BuiltInProcName.PurrrFormula, config: {
573
597
  args: {
574
598
  '.x': { index: 0, name: '.data' },
@@ -622,6 +646,16 @@ exports.DefaultBuiltinConfig = [
622
646
  processor: built_in_proc_name_1.BuiltInProcName.S7NewGeneric, config: { args: { name: 'name', dispatchArg: undefined, fun: 'fun' } }, assumePrimitive: true },
623
647
  { type: 'function', names: [identifier_1.Identifier.from(['S7_dispatch', "S7" /* PkgName.S7 */])],
624
648
  processor: built_in_proc_name_1.BuiltInProcName.S7Dispatch, config: { libFn: true }, assumePrimitive: true },
649
+ { type: 'function', names: [
650
+ identifier_1.Identifier.from(['make_constructor', "ggplot2" /* PkgName.GgPlot2 */]),
651
+ identifier_1.Identifier.from(['new_class', "S7" /* PkgName.S7 */])
652
+ ], processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: { mode: ['s7'] }, assumePrimitive: true },
653
+ { type: 'function', names: [identifier_1.Identifier.from(['setClass', "methods" /* PkgName.Methods */])],
654
+ processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: { mode: ['s4'] }, assumePrimitive: true },
655
+ { type: 'function', names: [
656
+ identifier_1.Identifier.from(['Negate', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Vectorize', "base" /* PkgName.Base */]),
657
+ identifier_1.Identifier.from(['partial', "purrr" /* PkgName.Purrr */])
658
+ ], processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: {}, assumePrimitive: true },
625
659
  { type: 'function', names: [identifier_1.Identifier.from(['.Primitive', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['.Internal', "base" /* PkgName.Base */])],
626
660
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, unquoteFunction: true, resolveInEnvironment: 'global' }, assumePrimitive: true },
627
661
  { type: 'function', names: [identifier_1.Identifier.from(['interference', "inferference" /* PkgName.Inferference */])],
@@ -662,7 +696,7 @@ exports.DefaultBuiltinConfig = [
662
696
  /* library/require/(require|load|attach)Namespace/use are handled above */
663
697
  identifier_1.Identifier.from(['asNamespace', "base" /* PkgName.Base */]),
664
698
  /* env attachment */
665
- identifier_1.Identifier.from(['unname', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['data', "utils" /* PkgName.Utils */]),
699
+ identifier_1.Identifier.from(['unname', "base" /* PkgName.Base */]),
666
700
  /* file creation/removal (base) */
667
701
  identifier_1.Identifier.from(['dir.create', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['dir_create', "fs" /* PkgName.Fs */]),
668
702
  identifier_1.Identifier.from(['Sys.chmod', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['unlink', "base" /* PkgName.Base */]),
@@ -76,7 +76,7 @@ function diffEnvironment(a, b, info, depth) {
76
76
  });
77
77
  }
78
78
  diffMemory(a, b, { ...info, position: `${info.position}[at level: ${depth}] ` });
79
- diffEnvironment(a.parent, b.parent, { ...info, position: `${info.position}Parents of ${a.id} & ${b.id}. ` }, depth--);
79
+ diffEnvironment(a.parent, b.parent, { ...info, position: `${info.position}Parents of ${a.id} & ${b.id}. ` }, depth - 1);
80
80
  }
81
81
  /**
82
82
  * Compares two REnvironmentInformation objects and reports differences.
@@ -213,8 +213,7 @@ class Environment {
213
213
  const updated = old?.slice() ?? [];
214
214
  for (const v of values) {
215
215
  const { nodeId, definedAt } = v;
216
- const index = updated.find(o => o.nodeId === nodeId && o.definedAt === definedAt);
217
- if (index) {
216
+ if (updated.some(o => o.nodeId === nodeId && o.definedAt === definedAt)) {
218
217
  continue;
219
218
  }
220
219
  if (applyCds === undefined) {
@@ -1,5 +1,5 @@
1
1
  import type { BuiltInIdentifierConstant, BuiltInIdentifierDefinition } from './built-in';
2
- import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import type { ControlDependency } from '../info';
4
4
  import type { REnvironmentInformation } from './environment';
5
5
  import type { Origin } from '../origin/dfg-get-origin';
@@ -113,12 +113,17 @@ export declare const Identifier: {
113
113
  readonly toArray: (this: void, id: Identifier) => [BrandedIdentifier, BrandedNamespace | undefined, boolean | undefined];
114
114
  /**
115
115
  * The qualified identifier of a call from its dataflow {@link Origin}s (via `getOriginInDfg`), if it
116
- * resolves to an export of a loaded package (the `flowr-pkgdb` info attached by `library()`/`use()`);
116
+ * resolves to an export of a loaded package (the signature-database info attached by `library()`/`use()`);
117
117
  * `undefined` otherwise. With `purrr` loaded, `map()` yields `Identifier.make('map', 'purrr')`.
118
+ *
119
+ * Pass the call's `name` to additionally get *edge-free* base-R qualification: a bare base call is qualified
120
+ * from the base package that exports it (`sd` yields `stats::sd`, `plot` yields `base::plot`) via the
121
+ * precomputed {@link baseRExportOwner} store -- no loaded database, no graph edges. This is suppressed when
122
+ * the call resolves to a user definition or is already namespaced, so a local `sd()` is never `stats::sd`.
118
123
  */
119
- readonly toQualified: (this: void, origins: readonly Origin[] | undefined) => Identifier | undefined;
124
+ readonly toQualified: (this: void, origins: readonly Origin[] | undefined, name?: Identifier) => Identifier | undefined;
120
125
  /** The fully qualified `package::name` of a resolved call (see {@link Identifier.toQualified}). */
121
- readonly toQualifiedName: (this: void, origins: readonly Origin[] | undefined) => string | undefined;
126
+ readonly toQualifiedName: (this: void, origins: readonly Origin[] | undefined, name?: Identifier) => string | undefined;
122
127
  };
123
128
  /**
124
129
  * Well-known R package names used in {@link DefaultBuiltinConfig}.
@@ -141,6 +146,7 @@ export declare const enum PkgName {
141
146
  Fs = "fs",
142
147
  Functools = "functools",
143
148
  GgPlot2 = "ggplot2",
149
+ Hmisc = "Hmisc",
144
150
  Import = "import",
145
151
  Inferference = "inferference",
146
152
  Janitor = "janitor",
@@ -161,6 +167,7 @@ export declare const enum PkgName {
161
167
  S7 = "S7",
162
168
  Soda = "SoDA",
163
169
  Testthat = "testthat",
170
+ TidyR = "tidyr",
164
171
  TinyPlot = "tinyplot",
165
172
  TryCatchLog = "tryCatchLog"
166
173
  }
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ReferenceTypeReverseMapping = exports.ReferenceType = exports.Identifier = void 0;
4
4
  exports.isReferenceType = isReferenceType;
5
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
5
6
  const strings_1 = require("../../util/text/strings");
7
+ const r_base_packages_1 = require("../../util/r-base-packages");
6
8
  const dotDotDotAccess = /^\.\.\d+$/;
7
9
  /**
8
10
  * Helper functions to work with {@link Identifier|identifiers}.
@@ -191,25 +193,41 @@ exports.Identifier = {
191
193
  },
192
194
  /**
193
195
  * The qualified identifier of a call from its dataflow {@link Origin}s (via `getOriginInDfg`), if it
194
- * resolves to an export of a loaded package (the `flowr-pkgdb` info attached by `library()`/`use()`);
196
+ * resolves to an export of a loaded package (the signature-database info attached by `library()`/`use()`);
195
197
  * `undefined` otherwise. With `purrr` loaded, `map()` yields `Identifier.make('map', 'purrr')`.
198
+ *
199
+ * Pass the call's `name` to additionally get *edge-free* base-R qualification: a bare base call is qualified
200
+ * from the base package that exports it (`sd` yields `stats::sd`, `plot` yields `base::plot`) via the
201
+ * precomputed {@link baseRExportOwner} store -- no loaded database, no graph edges. This is suppressed when
202
+ * the call resolves to a user definition or is already namespaced, so a local `sd()` is never `stats::sd`.
196
203
  */
197
- toQualified(origins) {
204
+ toQualified(origins, name) {
205
+ let sawUserDefinition = false;
198
206
  for (const origin of origins ?? []) {
199
- // a package-export origin carries the target builtin id `built-in:pkg:func` in `proc`
200
- if ('proc' in origin && origin.proc.startsWith('built-in:')) {
201
- const rest = origin.proc.slice('built-in:'.length);
202
- const sep = rest.indexOf(':'); // base builtins (`built-in:print`) have no separator
203
- if (sep > 0) {
204
- return exports.Identifier.make(rest.slice(sep + 1), rest.slice(0, sep));
207
+ // an attached package export carries the target builtin id `built-in:pkg:func` in `proc`
208
+ if ('proc' in origin) {
209
+ const pkgFn = node_id_1.NodeId.toPkgFn(origin.proc); // [pkg, func], or undefined for a bare/processor-level builtin
210
+ if (pkgFn) {
211
+ return exports.Identifier.make(pkgFn[1], pkgFn[0]);
205
212
  }
206
213
  }
214
+ else {
215
+ sawUserDefinition = true; // a function-call/variable origin: resolves to a user definition
216
+ }
217
+ }
218
+ // only qualify a bare base call: never override a user definition, nor an explicitly namespaced call
219
+ if (name !== undefined && !sawUserDefinition && exports.Identifier.getNamespace(name) === undefined) {
220
+ const bare = exports.Identifier.getName(name);
221
+ const owner = (0, r_base_packages_1.baseRExportOwner)(bare);
222
+ if (owner !== undefined) {
223
+ return exports.Identifier.make(bare, owner);
224
+ }
207
225
  }
208
226
  return undefined;
209
227
  },
210
228
  /** The fully qualified `package::name` of a resolved call (see {@link Identifier.toQualified}). */
211
- toQualifiedName(origins) {
212
- const qualified = exports.Identifier.toQualified(origins);
229
+ toQualifiedName(origins, name) {
230
+ const qualified = exports.Identifier.toQualified(origins, name);
213
231
  return qualified === undefined ? undefined : exports.Identifier.toString(qualified);
214
232
  }
215
233
  };
@@ -47,6 +47,11 @@ function resolveByName(id, environment, target) {
47
47
  }
48
48
  const [name, ns, internal] = identifier_1.Identifier.toArray(id);
49
49
  let current = environment.current;
50
+ /* `current` can already be the built-in environment itself (e.g. `get(x, envir=baseenv())`);
51
+ * it has no parent to walk to, so resolve directly instead of entering the loop below. */
52
+ if (current.builtInEnv) {
53
+ return current.memory.get(name);
54
+ }
50
55
  let definitions = undefined;
51
56
  const wantedType = TargetTypePredicate[target];
52
57
  do {
@@ -57,9 +62,9 @@ function resolveByName(id, environment, target) {
57
62
  let definition;
58
63
  if (target === identifier_1.ReferenceType.S3MethodPrefix || target === identifier_1.ReferenceType.S7MethodPrefix) {
59
64
  // S3 method prefixes only resolve to functions, S3s must not match the exported criteria!
60
- const infix = target === identifier_1.ReferenceType.S3MethodPrefix ? '.' : built_in_s_seven_dispatch_1.S7DispatchSeparator;
65
+ const prefix = name + (target === identifier_1.ReferenceType.S3MethodPrefix ? '.' : built_in_s_seven_dispatch_1.S7DispatchSeparator);
61
66
  definition = current.memory.entries()
62
- .filter(([defName]) => defName.startsWith(name + infix))
67
+ .filter(([defName]) => defName.startsWith(prefix))
63
68
  .flatMap(([, defs]) => defs)
64
69
  .toArray();
65
70
  }
@@ -107,6 +112,15 @@ function resolveByNameAnyType(id, environment) {
107
112
  }
108
113
  }
109
114
  const [name, ns, internal] = identifier_1.Identifier.toArray(id);
115
+ /* `current` can already be the built-in environment itself */
116
+ if (current.builtInEnv) {
117
+ const ret = current.memory.get(name);
118
+ if (ret && cacheable) {
119
+ current.cache ??= new Map();
120
+ current.cache.set(id, ret);
121
+ }
122
+ return ret;
123
+ }
110
124
  let definitions = undefined;
111
125
  do {
112
126
  if (layerSkipped(current, ns)) {
@@ -14,6 +14,7 @@ const named_call_handling_1 = require("./internal/process/functions/call/named-c
14
14
  const make_argument_1 = require("./internal/process/functions/call/argument/make-argument");
15
15
  const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
16
16
  const built_in_source_1 = require("./internal/process/functions/call/built-in/built-in-source");
17
+ const built_in_library_1 = require("./internal/process/functions/call/built-in/built-in-library");
17
18
  const extract_cfg_1 = require("../control-flow/extract-cfg");
18
19
  const edge_1 = require("./graph/edge");
19
20
  const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
@@ -38,8 +39,8 @@ exports.processors = {
38
39
  [type_1.RType.LineDirective]: process_uninteresting_leaf_1.processUninterestingLeaf,
39
40
  [type_1.RType.Symbol]: process_symbol_1.processSymbol,
40
41
  [type_1.RType.Access]: (n, d) => (0, process_named_call_1.processAsNamedCall)(n, d, n.operator, [n.accessed, ...n.access]),
41
- [type_1.RType.BinaryOp]: (n, d) => (0, process_named_call_1.processAsNamedCall)(n, d, n.operator, [n.lhs, n.rhs]),
42
- [type_1.RType.Pipe]: (n, d) => (0, process_named_call_1.processAsNamedCall)(n, d, n.lexeme, [n.lhs, n.rhs]),
42
+ [type_1.RType.BinaryOp]: process_named_call_1.processChainedCall,
43
+ [type_1.RType.Pipe]: process_named_call_1.processChainedCall,
43
44
  [type_1.RType.UnaryOp]: (n, d) => (0, process_named_call_1.processAsNamedCall)(n, d, n.operator, [n.operand]),
44
45
  [type_1.RType.ForLoop]: (n, d) => (0, process_named_call_1.processAsNamedCall)(n, d, n.lexeme, [n.variable, n.vector, n.body]),
45
46
  [type_1.RType.WhileLoop]: (n, d) => (0, process_named_call_1.processAsNamedCall)(n, d, n.lexeme, [n.condition, n.body]),
@@ -125,10 +126,12 @@ function produceDataFlowGraph(parser, completeAst, ctx) {
125
126
  ctx.files.addConsideredFile(files[0].filePath ? files[0].filePath : flowr_file_1.FlowrFile.INLINE_PATH);
126
127
  const env = ctx.env.makeCleanEnv();
127
128
  env.current.n = ctx.meta.getNamespace();
129
+ // eagerly attach the always-available base-R namespaces, then the project's declared DESCRIPTION dependencies
130
+ const environment = (0, built_in_library_1.attachDeclaredDependencies)((0, built_in_library_1.attachBaseRNamespaces)(env, ctx), ctx);
128
131
  const dfData = {
129
132
  parser,
130
133
  completeAst,
131
- environment: env,
134
+ environment,
132
135
  processors: ctx.config.solver.instrument.dataflowExtractors?.(exports.processors, ctx) ?? exports.processors,
133
136
  cds: undefined,
134
137
  referenceChain: [files[0].filePath],
@@ -42,8 +42,8 @@ export declare const CallGraph: {
42
42
  string: string;
43
43
  mermaid: import("../../util/mermaid/dfg").MermaidGraph;
44
44
  };
45
- readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
46
- readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
45
+ readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
46
+ readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
47
47
  };
48
48
  readonly quads: {
49
49
  readonly convert: typeof import("./quads").df2quads;
@@ -52,8 +52,8 @@ export declare const Dataflow: {
52
52
  string: string;
53
53
  mermaid: import("../../util/mermaid/dfg").MermaidGraph;
54
54
  };
55
- readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
56
- readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
55
+ readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
56
+ readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
57
57
  };
58
58
  readonly quads: {
59
59
  readonly convert: typeof import("./quads").df2quads;
@@ -137,8 +137,8 @@ export declare const Dataflow: {
137
137
  string: string;
138
138
  mermaid: import("../../util/mermaid/dfg").MermaidGraph;
139
139
  };
140
- readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
141
- readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
140
+ readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
141
+ readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean, qualifyBaseR?: boolean) => string;
142
142
  };
143
143
  readonly quads: {
144
144
  readonly convert: typeof import("./quads").df2quads;
@@ -115,8 +115,8 @@ function diffFunctionArguments(fn, a, b, ctx) {
115
115
  */
116
116
  function diffVertices(ctx) {
117
117
  // collect vertices from both sides
118
- const lVert = ctx.left.vertices(true).map(([id, info]) => [id, info]).toArray();
119
- const rVert = ctx.right.vertices(true).map(([id, info]) => [id, info]).toArray();
118
+ const lVert = ctx.left.vertices(true).toArray();
119
+ const rVert = ctx.right.vertices(true).toArray();
120
120
  if (lVert.length < rVert.length && !ctx.config.leftIsSubgraph
121
121
  || lVert.length > rVert.length && !ctx.config.rightIsSubgraph) {
122
122
  ctx.report.addComment(`Detected different number of vertices! ${ctx.leftname} has ${lVert.length}, ${ctx.rightname} has ${rVert.length}`);
@@ -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