@eagleoutice/flowr 2.13.13 → 2.13.15

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 (186) hide show
  1. package/README.md +31 -28
  2. package/abstract-interpretation/data-frame/resolve-args.js +11 -12
  3. package/benchmark/calibration.d.ts +18 -0
  4. package/benchmark/calibration.js +63 -0
  5. package/benchmark/slicer.d.ts +19 -0
  6. package/benchmark/slicer.js +84 -1
  7. package/benchmark/stats/feature-counts.d.ts +6 -0
  8. package/benchmark/stats/feature-counts.js +61 -0
  9. package/benchmark/stats/print.js +20 -0
  10. package/benchmark/stats/sigdb-counts.d.ts +7 -0
  11. package/benchmark/stats/sigdb-counts.js +219 -0
  12. package/benchmark/stats/size-of.d.ts +6 -0
  13. package/benchmark/stats/size-of.js +8 -0
  14. package/benchmark/stats/stats.d.ts +79 -0
  15. package/benchmark/stats/stats.js +7 -1
  16. package/benchmark/stopwatch.d.ts +4 -0
  17. package/benchmark/stopwatch.js +12 -1
  18. package/benchmark/summarizer/data.d.ts +17 -1
  19. package/benchmark/summarizer/first-phase/input.js +5 -0
  20. package/benchmark/summarizer/first-phase/process.js +12 -2
  21. package/benchmark/summarizer/second-phase/graph.d.ts +24 -1
  22. package/benchmark/summarizer/second-phase/graph.js +249 -18
  23. package/benchmark/summarizer/second-phase/process.js +56 -0
  24. package/benchmark/summarizer/summarizer.js +1 -2
  25. package/cli/benchmark-app.d.ts +1 -0
  26. package/cli/benchmark-app.js +2 -1
  27. package/cli/benchmark-helper-app.d.ts +1 -0
  28. package/cli/benchmark-helper-app.js +12 -2
  29. package/cli/common/options.d.ts +10 -0
  30. package/cli/common/options.js +3 -1
  31. package/cli/common/scripts-info.d.ts +10 -0
  32. package/cli/repl/commands/repl-cfg.js +2 -42
  33. package/cli/repl/commands/repl-clipboard.d.ts +7 -0
  34. package/cli/repl/commands/repl-clipboard.js +53 -0
  35. package/cli/repl/commands/repl-dataflow.js +5 -70
  36. package/cli/repl/commands/repl-normalize.js +3 -51
  37. package/control-flow/cfg-builder.d.ts +30 -0
  38. package/control-flow/cfg-builder.js +79 -0
  39. package/control-flow/cfg-dead-code.js +5 -29
  40. package/control-flow/diff-cfg.js +2 -56
  41. package/control-flow/extract-cfg.js +17 -10
  42. package/control-flow/semantic-cfg-guided-visitor.d.ts +7 -0
  43. package/control-flow/semantic-cfg-guided-visitor.js +14 -0
  44. package/control-flow/useless-loop.js +4 -26
  45. package/core/steps/all/core/10-normalize.d.ts +8 -0
  46. package/core/steps/all/core/10-normalize.js +10 -8
  47. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +5 -7
  48. package/core/steps/all/core/11-normalize-tree-sitter.js +2 -9
  49. package/data/r-base-packages.generated.d.ts +1 -0
  50. package/data/r-base-packages.generated.js +5 -3
  51. package/dataflow/environments/apply-kill.d.ts +3 -3
  52. package/dataflow/environments/apply-kill.js +60 -31
  53. package/dataflow/environments/built-in-config.d.ts +9 -1
  54. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  55. package/dataflow/environments/built-in-proc-name.js +2 -0
  56. package/dataflow/environments/built-in-props.d.ts +4 -0
  57. package/dataflow/environments/built-in-props.js +3 -3
  58. package/dataflow/environments/built-in.d.ts +4 -2
  59. package/dataflow/environments/built-in.js +53 -3
  60. package/dataflow/environments/data-masking-functions.d.ts +3 -4
  61. package/dataflow/environments/data-masking-functions.js +7 -8
  62. package/dataflow/environments/default-builtin-config.d.ts +92 -12
  63. package/dataflow/environments/default-builtin-config.js +86 -43
  64. package/dataflow/environments/environment.d.ts +5 -0
  65. package/dataflow/environments/environment.js +17 -12
  66. package/dataflow/environments/identifier.d.ts +3 -0
  67. package/dataflow/environments/reference-to-maybe.d.ts +5 -3
  68. package/dataflow/environments/reference-to-maybe.js +17 -52
  69. package/dataflow/environments/resolve-helper.d.ts +2 -1
  70. package/dataflow/environments/resolve-helper.js +2 -1
  71. package/dataflow/eval/resolve/alias-tracking.js +4 -7
  72. package/dataflow/eval/resolve/node-value.d.ts +51 -0
  73. package/dataflow/eval/resolve/node-value.js +71 -0
  74. package/dataflow/eval/resolve/resolve-argument.js +10 -7
  75. package/dataflow/eval/resolve/resolve-operators.js +1 -2
  76. package/dataflow/eval/values/general.d.ts +4 -0
  77. package/dataflow/eval/values/general.js +11 -0
  78. package/dataflow/eval/values/r-value.d.ts +15 -0
  79. package/dataflow/eval/values/r-value.js +27 -1
  80. package/dataflow/extractor.js +2 -0
  81. package/dataflow/fn/higher-order-function.js +2 -3
  82. package/dataflow/graph/df-helper.d.ts +2 -1
  83. package/dataflow/graph/diff-dataflow-graph.js +3 -55
  84. package/dataflow/graph/graph.d.ts +5 -0
  85. package/dataflow/graph/graph.js +27 -0
  86. package/dataflow/info.d.ts +7 -1
  87. package/dataflow/info.js +36 -7
  88. package/dataflow/internal/linker.d.ts +23 -0
  89. package/dataflow/internal/linker.js +70 -1
  90. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +4 -1
  91. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +2 -0
  92. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -29
  93. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +39 -6
  94. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +10 -22
  95. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +29 -53
  96. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +33 -10
  97. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +4 -1
  98. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -5
  99. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -7
  100. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +2 -3
  101. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +6 -2
  102. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +19 -12
  103. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +2 -1
  104. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +3 -0
  105. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +69 -52
  106. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
  107. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +2 -8
  108. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -1
  109. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +7 -2
  110. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -8
  111. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +2 -2
  112. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -2
  113. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +5 -0
  114. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +23 -3
  115. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.d.ts +5 -4
  116. package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +7 -10
  117. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +6 -1
  118. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +20 -3
  119. package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +6 -8
  120. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.d.ts +25 -0
  121. package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +105 -0
  122. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +9 -28
  123. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
  124. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +1 -1
  125. package/dataflow/internal/process/functions/call/deferred.d.ts +41 -0
  126. package/dataflow/internal/process/functions/call/deferred.js +127 -0
  127. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +13 -12
  128. package/dataflow/internal/process/functions/call/known-call-handling.js +35 -35
  129. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
  130. package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
  131. package/dataflow/internal/process/functions/call/nse.d.ts +28 -0
  132. package/dataflow/internal/process/functions/call/nse.js +87 -0
  133. package/dataflow/internal/process/functions/call/quoted.d.ts +29 -0
  134. package/dataflow/internal/process/functions/call/quoted.js +188 -0
  135. package/documentation/doc-readme.js +5 -2
  136. package/documentation/doc-util/doc-issue.d.ts +2 -0
  137. package/documentation/doc-util/doc-issue.js +3 -1
  138. package/documentation/doc-util/doc-types.js +15 -9
  139. package/documentation/wiki-dataflow-graph.js +4 -0
  140. package/documentation/wiki-faq.js +6 -2
  141. package/documentation/wiki-onboarding.js +11 -1
  142. package/documentation/wiki-setup.js +2 -1
  143. package/linter/rules/deprecated-functions.js +9 -3
  144. package/linter/rules/seeded-randomness.js +2 -3
  145. package/linter/rules/undefined-symbol.js +10 -1
  146. package/package.json +9 -4
  147. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.d.ts +6 -0
  148. package/project/plugins/file-plugins/flowr-analyzer-description-file-plugin.js +17 -1
  149. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +2 -11
  150. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +3 -15
  151. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.d.ts +16 -0
  152. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmarkdown-file-plugin.js +26 -0
  153. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -11
  154. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +3 -15
  155. package/project/plugins/loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin.js +4 -10
  156. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -9
  157. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +2 -9
  158. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +1 -1
  159. package/project/sigdb/reader.d.ts +9 -0
  160. package/project/sigdb/reader.js +30 -0
  161. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -1
  162. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +0 -12
  163. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -37
  164. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -23
  165. package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
  166. package/queries/query-function-filter.d.ts +21 -0
  167. package/queries/query-function-filter.js +48 -0
  168. package/r-bridge/data/data.d.ts +13 -3
  169. package/r-bridge/data/data.js +15 -3
  170. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +2 -0
  171. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +4 -0
  172. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -9
  173. package/search/flowr-search-filters.d.ts +5 -1
  174. package/search/flowr-search-filters.js +31 -21
  175. package/search/search-executor/search-enrichers.d.ts +24 -4
  176. package/search/search-executor/search-enrichers.js +22 -9
  177. package/search/search-executor/search-transformer.js +1 -1
  178. package/slicing/static/slice-call.js +4 -4
  179. package/util/diff-graph.d.ts +13 -0
  180. package/util/diff-graph.js +64 -1
  181. package/util/files.js +9 -8
  182. package/util/node-version.d.ts +4 -0
  183. package/util/node-version.js +29 -0
  184. package/util/r-base-packages.d.ts +2 -0
  185. package/util/r-base-packages.js +3 -1
  186. package/util/version.js +1 -1
@@ -12,9 +12,11 @@ const identifier_1 = require("./identifier");
12
12
  const built_in_proc_name_1 = require("./built-in-proc-name");
13
13
  const built_in_eval_name_1 = require("./built-in-eval-name");
14
14
  const known_call_handling_1 = require("../internal/process/functions/call/known-call-handling");
15
+ const nse_1 = require("../internal/process/functions/call/nse");
15
16
  const data_masking_functions_1 = require("./data-masking-functions");
16
17
  const built_in_props_1 = require("./built-in-props");
17
18
  const r_base_packages_1 = require("../../util/r-base-packages");
19
+ const r_base_packages_generated_1 = require("../../data/r-base-packages.generated");
18
20
  /** Which stack environment an env-returning/-transforming builtin denotes (see {@link StackEnvBuiltins}). */
19
21
  var StackEnvKind;
20
22
  (function (StackEnvKind) {
@@ -36,6 +38,8 @@ exports.StackEnvBuiltins = {
36
38
  'parent.env': StackEnvKind.Parent,
37
39
  'parent.frame': StackEnvKind.CallerFrame,
38
40
  'as.environment': StackEnvKind.Named,
41
+ /* `.env$x` reaches past the data mask */
42
+ '.env': StackEnvKind.Current,
39
43
  '.GlobalEnv': StackEnvKind.Global,
40
44
  '.BaseEnv': StackEnvKind.Base,
41
45
  '.BaseNamespaceEnv': StackEnvKind.Base
@@ -200,35 +204,49 @@ exports.RGroupGenerics = {
200
204
  * The `<-` forms are left out, one replacement definition covers many names.
201
205
  * `npm run check:generic-labels` (part of `checkup`) compares this against a synced database.
202
206
  */
203
- const RGenerics = new Set([
204
- ...Object.values(exports.RGroupGenerics).flat(), '%*%',
205
- 'c', 'length', 'dim', 'dimnames', 'names', 'rep', 'seq.int', '[', '[[', '$', '@',
206
- 'as.call', 'as.character', 'as.complex', 'as.double', 'as.environment', 'as.integer', 'as.logical',
207
- 'as.numeric', 'as.raw', 'is.na', 'is.nan', 'is.finite', 'is.infinite', 'is.matrix', 'is.numeric',
208
- 'aperm', 'as.array', 'as.data.frame', 'as.expression', 'as.list', 'as.matrix', 'cbind', 'rbind', 'diff',
209
- 'duplicated', 'format', 'head', 'tail', 'mean', 'median', 'na.omit', 'print', 'quantile', 'rev', 'seq',
210
- 'simulate', 'solve', 'sort', 'subset', 't', 'transform', 'unique', 'with', 'within',
211
- 'plot', 'lines', 'points', 'text', 'image', 'contour', 'persp', 'hist', 'barplot', 'boxplot', 'density',
212
- 'pairs', 'qqnorm', 'mosaicplot', 'spineplot', 'stripchart', 'sunflowerplot'
213
- ]);
207
+ /**
208
+ * The internal generics: they dispatch in C rather than through `UseMethod`, so no signature can state it and
209
+ * the list has to be written down. Everything that dispatches from R is generated, see {@link RBasePackageStore}.
210
+ */
211
+ const InternalGenerics = [
212
+ '$', '[', '[[', '+', '-', '*', '/', '^', '%%', '%/%', '==', '!=', '<', '>', '<=', '>=', '&', '|', '!',
213
+ 'c', 'length', 'dim', 'dimnames', 'names', 'max', 'min', 'range', 'sum', 'prod', 'abs', 'sqrt', 'exp',
214
+ 'log', 'floor', 'ceiling', 'round', 'signif', 'trunc', 'cumsum', 'cumprod', 'cummax', 'cummin',
215
+ 'as.character', 'as.integer', 'as.double', 'as.logical', 'as.complex', 'as.numeric', 'as.raw',
216
+ 'is.na', 'is.nan', 'is.finite', 'is.infinite', 'is.matrix', 'is.numeric', 'cbind', 'rbind'
217
+ ];
218
+ /** Every name R dispatches on: the generated closure generics plus the {@link InternalGenerics}. */
219
+ const RGenerics = new Set([...r_base_packages_generated_1.RBasePackageStore.generics, ...InternalGenerics]);
214
220
  /** Label every {@link RGenerics} {@link CallProp.Generic}, splitting an entry that mixes them with names that do not dispatch (`&` does, `&&` does not). */
215
221
  function markGenerics(definitions) {
216
- return definitions.flatMap((def) => {
222
+ const out = [];
223
+ for (const def of definitions) {
217
224
  if (def.type !== 'function') {
218
- return [def];
225
+ out.push(def);
226
+ continue;
219
227
  }
220
228
  /* the attached base packages are the ones whose namespace layer a registered built-in hides, so their
221
229
  * label is the only thing left stating the dispatch */
222
- const dispatches = (name) => RGenerics.has(identifier_1.Identifier.getName(name))
223
- && r_base_packages_1.AttachedBasePackages.includes(identifier_1.Identifier.getNamespace(name) ?? "base" /* PkgName.Base */);
224
- const generics = def.names.filter(dispatches);
225
- if (generics.length === 0) {
226
- return [def];
230
+ let generics = undefined;
231
+ let rest = undefined;
232
+ for (const name of def.names) {
233
+ if (RGenerics.has(identifier_1.Identifier.getName(name)) && r_base_packages_1.AttachedBasePackageSet.has(identifier_1.Identifier.getNamespace(name) ?? "base" /* PkgName.Base */)) {
234
+ (generics ??= []).push(name);
235
+ }
236
+ else {
237
+ (rest ??= []).push(name);
238
+ }
227
239
  }
228
- const rest = def.names.filter(n => !dispatches(n));
229
- const labeled = { ...def, names: generics, config: { ...def.config, props: (def.config?.props ?? 0) | built_in_props_1.CallProp.Generic } };
230
- return rest.length === 0 ? [labeled] : [labeled, { ...def, names: rest }];
231
- });
240
+ if (generics === undefined) {
241
+ out.push(def);
242
+ continue;
243
+ }
244
+ out.push({ ...def, names: generics, config: { ...def.config, props: (def.config?.props ?? 0) | built_in_props_1.CallProp.Generic } });
245
+ if (rest !== undefined) {
246
+ out.push({ ...def, names: rest });
247
+ }
248
+ }
249
+ return out;
232
250
  }
233
251
  /**
234
252
  * Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
@@ -287,7 +305,8 @@ exports.WrittenBuiltinDefinitions = [
287
305
  /* data-masking without a data argument, e.g. `aes(x, y)` */
288
306
  {
289
307
  type: 'function',
290
- names: identifier_1.Identifier.fromAll("ggplot2" /* PkgName.GgPlot2 */, ['aes', 'aes_string', 'vars']),
308
+ names: [...identifier_1.Identifier.fromAll("ggplot2" /* PkgName.GgPlot2 */, ['aes', 'vars']), identifier_1.Identifier.from(['join_by', "dplyr" /* PkgName.Dplyr */]),
309
+ ...identifier_1.Identifier.fromAll("tibble" /* PkgName.Tibble */, ['tibble', 'tribble'])],
291
310
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
292
311
  config: { markArgsAsMasked: known_call_handling_1.NseArguments.All },
293
312
  assumePrimitive: false
@@ -536,8 +555,9 @@ exports.WrittenBuiltinDefinitions = [
536
555
  hasUnknownSideEffects: {
537
556
  type: 'link-to-last-call',
538
557
  ignoreIf: (source, graph) => {
558
+ const sourceVertex = graph.getVertex(source);
539
559
  /* map with add = true appends to an existing plot */
540
- return (exports.PlotFunctionsWithAddParam.has(identifier_1.Identifier.getName(source.name)) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, source, {
560
+ return (exports.PlotFunctionsWithAddParam.has(identifier_1.Identifier.getName(sourceVertex.name)) && (0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, sourceVertex, {
541
561
  index: -1,
542
562
  name: 'add'
543
563
  }, [type_1.RType.Logical])?.content === true);
@@ -564,7 +584,8 @@ exports.WrittenBuiltinDefinitions = [
564
584
  name: 'add'
565
585
  }, [type_1.RType.Logical])?.content !== true);
566
586
  },
567
- cascadeIf: (target, _, graph) => {
587
+ cascadeIf: (targetVertex, _, graph) => {
588
+ const target = targetVertex;
568
589
  /* map with add = true appends to an existing plot */
569
590
  return identifier_1.Identifier.getName(target.name) ? ((0, identify_link_to_last_call_relation_1.getValueOfArgument)(graph, target, {
570
591
  index: 11,
@@ -641,8 +662,8 @@ exports.WrittenBuiltinDefinitions = [
641
662
  config: {
642
663
  hasUnknownSideEffects: true,
643
664
  forceArgs: [true],
644
- /* first arg names a native routine (useDynLib), not a variable */
645
- markArgsAsNSE: known_call_handling_1.NseArguments.First,
665
+ /* the routine usually comes from useDynLib, but it may be a variable holding a symbol */
666
+ markArgsAsMasked: known_call_handling_1.NseArguments.First,
646
667
  treatAsFnCall: {
647
668
  '.Call': ['.NAME'],
648
669
  '.External': ['.NAME'],
@@ -654,9 +675,9 @@ exports.WrittenBuiltinDefinitions = [
654
675
  assumePrimitive: true
655
676
  },
656
677
  { type: 'function', names: [identifier_1.Identifier.from(['eval', "base" /* PkgName.Base */])],
657
- processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: false }, assumePrimitive: true },
678
+ processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: false, keepEnvironment: true }, assumePrimitive: true },
658
679
  { type: 'function', names: [identifier_1.Identifier.from(['evalText', "SoDA" /* PkgName.Soda */])],
659
- processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: true }, assumePrimitive: true },
680
+ processor: built_in_proc_name_1.BuiltInProcName.Eval, config: { includeFunctionCall: true, supportFunctionCall: true, keepEnvironment: true }, assumePrimitive: true },
660
681
  { type: 'function', names: [identifier_1.Identifier.from(['cat', "base" /* PkgName.Base */])],
661
682
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes | built_in_props_1.CallProp.Prints, sig: [['...', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
662
683
  { type: 'function', names: [identifier_1.Identifier.from(['switch', "base" /* PkgName.Base */])],
@@ -672,7 +693,7 @@ exports.WrittenBuiltinDefinitions = [
672
693
  ...identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['stop_bad_type', 'stop_bad_element_type', 'stop_bad_element_length'])
673
694
  ],
674
695
  processor: built_in_proc_name_1.BuiltInProcName.Default,
675
- config: { useAsProcessor: built_in_proc_name_1.BuiltInProcName.Stop, cfg: 4 /* ExitPointType.Error */, forceArgs: ['all'], props: built_in_props_1.CallProp.Throws },
696
+ config: { useAsProcessor: built_in_proc_name_1.BuiltInProcName.Stop, cfg: 4 /* ExitPointType.Error */, forceArgs: 'all', props: built_in_props_1.CallProp.Throws },
676
697
  assumePrimitive: false
677
698
  },
678
699
  { type: 'function', names: [identifier_1.Identifier.from(['try', "base" /* PkgName.Base */])],
@@ -739,15 +760,18 @@ exports.WrittenBuiltinDefinitions = [
739
760
  processor: built_in_proc_name_1.BuiltInProcName.Assignment, config: { superAssignment: true, swapSourceAndTarget: true, canBeReplacement: true, props: built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.Invisible }, assumePrimitive: true },
740
761
  { type: 'function', names: [identifier_1.Identifier.from(['data', "utils" /* PkgName.Utils */]), identifier_1.Identifier.from(['getHdata', "Hmisc" /* PkgName.Hmisc */])],
741
762
  processor: built_in_proc_name_1.BuiltInProcName.DefineArgument, config: { superAssignment: true }, assumePrimitive: false },
742
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['&&', '&']),
763
+ /* only `&&`/`||` short-circuit */
764
+ { type: 'function', names: [identifier_1.Identifier.from(['&&', "base" /* PkgName.Base */])],
743
765
  processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: true, evalRhsWhen: true, props: built_in_props_1.CallProp.Pure }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
744
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['||', '|']),
766
+ { type: 'function', names: [identifier_1.Identifier.from(['||', "base" /* PkgName.Base */])],
745
767
  processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: true, evalRhsWhen: false, props: built_in_props_1.CallProp.Pure }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
768
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['&', '|']),
769
+ processor: built_in_proc_name_1.BuiltInProcName.SpecialBinOp, config: { lazy: false, props: built_in_props_1.CallProp.Pure }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
746
770
  { type: 'function', names: ['|>'],
747
- processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '_' }, assumePrimitive: true },
748
- { type: 'function', names: [identifier_1.Identifier.from(['%>%', "magrittr" /* PkgName.Magrittr */]), '%!>%'], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', rhsMightBeSymbol: true }, assumePrimitive: true },
749
- { type: 'function', names: [identifier_1.Identifier.from(['%<>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: true, rhsMightBeSymbol: true }, assumePrimitive: true },
750
- { type: 'function', names: [identifier_1.Identifier.from(['%T>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', returnLhs: true, rhsMightBeSymbol: true }, assumePrimitive: true },
771
+ processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '_', assignLhs: false, returnLhs: false }, assumePrimitive: true },
772
+ { type: 'function', names: [identifier_1.Identifier.from(['%>%', "magrittr" /* PkgName.Magrittr */]), '%!>%'], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: false, returnLhs: false, rhsMightBeSymbol: true }, assumePrimitive: true },
773
+ { type: 'function', names: [identifier_1.Identifier.from(['%<>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: true, returnLhs: false, rhsMightBeSymbol: true }, assumePrimitive: true },
774
+ { type: 'function', names: [identifier_1.Identifier.from(['%T>%', "magrittr" /* PkgName.Magrittr */])], processor: built_in_proc_name_1.BuiltInProcName.Pipe, config: { pipePlaceholderName: '.', assignLhs: false, returnLhs: true, rhsMightBeSymbol: true }, assumePrimitive: true },
751
775
  { type: 'function', names: identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['map', 'map_lgl', 'map_int', 'map_dbl', 'map_chr']), processor: built_in_proc_name_1.BuiltInProcName.PurrrFormula, config: {
752
776
  args: {
753
777
  '.x': { index: 0, name: '.x' }
@@ -888,12 +912,29 @@ exports.WrittenBuiltinDefinitions = [
888
912
  } },
889
913
  { type: 'function', names: ['function', '\\'],
890
914
  processor: built_in_proc_name_1.BuiltInProcName.FunctionDefinition, config: {}, assumePrimitive: true },
891
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['quote', 'bquote']),
892
- processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
915
+ { type: 'function', names: [identifier_1.Identifier.from(['quote', "base" /* PkgName.Base */])],
916
+ processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, keepEnvironment: true, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
917
+ /* `bquote` evaluates the operand of `.()` */
918
+ { type: 'function', names: [identifier_1.Identifier.from(['bquote', "base" /* PkgName.Base */])],
919
+ processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, unquote: nse_1.Unquote.Bquote, keepEnvironment: true, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
893
920
  { type: 'function', names: [identifier_1.Identifier.from(['substitute', "base" /* PkgName.Base */])],
894
- processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, envArgIndex: 1, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
895
- { type: 'function', names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['enquo', 'enquos', 'quo', 'quos', 'sym', 'syms', 'ensym', 'ensyms', 'expr', 'exprs', 'quo_name', 'as_name', 'as_label', 'as_string']), processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, libFn: true, props: built_in_props_1.CallProp.Lang }, assumePrimitive: true },
896
- { type: 'function', names: [...identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['call2', 'exec']), ...identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['invoke', 'invoke_map'])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, hasUnknownSideEffects: true, unquoteFunction: true }, assumePrimitive: false },
921
+ processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, envArgIndex: 1, keepEnvironment: true, props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
922
+ /* the rlang functions that capture unevaluated, the rest take a value */
923
+ { type: 'function', names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['quo', 'quos', 'expr', 'exprs']), processor: built_in_proc_name_1.BuiltInProcName.Quote, config: { quoteArgumentsWithIndex: 0, unquote: nse_1.Unquote.Rlang, keepEnvironment: true, libFn: true, props: built_in_props_1.CallProp.Lang }, assumePrimitive: true },
924
+ { type: 'function', names: [identifier_1.Identifier.from(['exec', "rlang" /* PkgName.Rlang */])],
925
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: '.fn', unquoteFunction: true, hasUnknownSideEffects: true, libFn: true, props: built_in_props_1.CallProp.MayPure, sig: [['.fn', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
926
+ { type: 'function', names: identifier_1.Identifier.fromAll("purrr" /* PkgName.Purrr */, ['invoke', 'invoke_map']),
927
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: '.f', unquoteFunction: true, hasUnknownSideEffects: true, libFn: true, props: built_in_props_1.CallProp.MayPure, sig: [['.f', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
928
+ /* the `{...}` of a template holds R code, evaluated where the call is; `cli_abort` stays with the other
929
+ * error exits, as terminating a branch matters more than interpolating its message */
930
+ { type: 'function', names: [...identifier_1.Identifier.fromAll("glue" /* PkgName.Glue */, ['glue', 'glue_safe', 'glue_collapse']), identifier_1.Identifier.from(['str_glue', "stringr" /* PkgName.Stringr */])],
931
+ processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
932
+ { type: 'function', names: identifier_1.Identifier.fromAll("cli" /* PkgName.Cli */, ['cli_text', 'cli_alert', 'cli_alert_info', 'cli_alert_success',
933
+ 'cli_alert_warning', 'cli_alert_danger', 'cli_h1', 'cli_h2', 'cli_h3', 'cli_li', 'cli_bullets', 'cli_inform', 'cli_warn',
934
+ 'format_inline', 'cli_verbatim']),
935
+ processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { markup: true, props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
936
+ { type: 'function', names: [identifier_1.Identifier.from(['str_interp', "stringr" /* PkgName.Stringr */])],
937
+ processor: built_in_proc_name_1.BuiltInProcName.StringTemplate, config: { open: '${', props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
897
938
  { type: 'function', names: [identifier_1.Identifier.from(['local', "base" /* PkgName.Base */])],
898
939
  processor: built_in_proc_name_1.BuiltInProcName.Local, config: { args: { env: 'envir', expr: 'expr' } }, assumePrimitive: false },
899
940
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['with', 'within']),
@@ -1071,8 +1112,10 @@ exports.WrittenBuiltinDefinitions = [
1071
1112
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Lang, sig: [['expr', built_in_props_1.ArgProp.Nse], ['envir', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1072
1113
  {
1073
1114
  type: 'function',
1074
- names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['enexpr', 'enexprs', 'inject', 'enquo0', 'enquos0', 'new_formula',
1075
- 'f_rhs', 'f_lhs', 'fn_body', 'fn_fmls', 'fn_fmls_names']),
1115
+ names: identifier_1.Identifier.fromAll("rlang" /* PkgName.Rlang */, ['enexpr', 'enexprs', 'inject', 'enquo', 'enquos', 'enquo0', 'enquos0',
1116
+ 'ensym', 'ensyms', 'new_formula',
1117
+ 'f_rhs', 'f_lhs', 'fn_body', 'fn_fmls', 'fn_fmls_names', 'call2', 'sym', 'syms', 'quo_name', 'as_name',
1118
+ 'as_label', 'as_string']),
1076
1119
  processor: built_in_proc_name_1.BuiltInProcName.Default,
1077
1120
  config: { forceArgs: 'all', libFn: true, props: built_in_props_1.CallProp.Lang },
1078
1121
  assumePrimitive: false
@@ -102,6 +102,11 @@ export declare class Environment implements IEnvironment {
102
102
  * Adds all writes of `other` to this environment (`other`'s operations *might* happen). Always recurses parents.
103
103
  */
104
104
  append(other: Environment | undefined): Environment;
105
+ /**
106
+ * The environment a merge with `other` settles on without touching either memory, `undefined` if the
107
+ * memories have to be merged. Package blocks are always unioned, never overwritten or appended to.
108
+ */
109
+ private mergeShortcut;
105
110
  /**
106
111
  * Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
107
112
  */
@@ -237,12 +237,9 @@ class Environment {
237
237
  if (!other || this === other) {
238
238
  return this;
239
239
  }
240
- // package blocks are unioned, never overwritten (see mergePackageBlocks)
241
- if (this.t !== undefined || other.t !== undefined) {
242
- return this.mergePackageBlocks(other);
243
- }
244
- if (this.builtInEnv || this.n !== other.n) {
245
- return this;
240
+ const shortcut = this.mergeShortcut(other);
241
+ if (shortcut !== undefined) {
242
+ return shortcut;
246
243
  }
247
244
  const map = new Map(this.memory);
248
245
  for (const [key, values] of other.memory) {
@@ -291,12 +288,9 @@ class Environment {
291
288
  if (!other || this === other) {
292
289
  return this;
293
290
  }
294
- // package blocks may diverge between branches; union them before the built-in guard
295
- if (this.t !== undefined || other.t !== undefined) {
296
- return this.mergePackageBlocks(other);
297
- }
298
- if (this.builtInEnv || this.n !== other.n) {
299
- return this;
291
+ const shortcut = this.mergeShortcut(other);
292
+ if (shortcut !== undefined) {
293
+ return shortcut;
300
294
  }
301
295
  const map = new Map(this.memory);
302
296
  for (const [key, value] of other.memory) {
@@ -309,12 +303,23 @@ class Environment {
309
303
  }
310
304
  }
311
305
  const out = new Environment(this.parent.append(other.parent));
306
+ out.c = this.c;
312
307
  out.n = this.n;
313
308
  out.t = this.t;
314
309
  out.globalEnv = this.globalEnv;
315
310
  out.memory = map;
316
311
  return out;
317
312
  }
313
+ /**
314
+ * The environment a merge with `other` settles on without touching either memory, `undefined` if the
315
+ * memories have to be merged. Package blocks are always unioned, never overwritten or appended to.
316
+ */
317
+ mergeShortcut(other) {
318
+ if (this.t !== undefined || other.t !== undefined) {
319
+ return this.mergePackageBlocks(other);
320
+ }
321
+ return this.builtInEnv || this.n !== other.n ? this : undefined;
322
+ }
318
323
  /**
319
324
  * Unions two attached-package blocks, keeping every package once (memory merged for a package in both).
320
325
  */
@@ -192,6 +192,9 @@ export declare const enum PkgName {
192
192
  Tcltk = "tcltk",
193
193
  Testthat = "testthat",
194
194
  TidyR = "tidyr",
195
+ Tibble = "tibble",
196
+ Glue = "glue",
197
+ Stringr = "stringr",
195
198
  TinyPlot = "tinyplot",
196
199
  TryCatchLog = "tryCatchLog",
197
200
  Withr = "withr"
@@ -1,11 +1,13 @@
1
- import type { IdentifierReference } from './identifier';
1
+ import type { IdentifierDefinition, IdentifierReference } from './identifier';
2
2
  import type { DataflowGraph } from '../graph/graph';
3
3
  import type { ControlDependency } from '../info';
4
4
  import type { REnvironmentInformation } from './environment';
5
+ /** copy of the definition with the given cds attached, marking it as maybe */
6
+ export declare function withAppliedCds(definition: IdentifierDefinition, defaultCd: readonly ControlDependency[] | undefined): IdentifierDefinition;
5
7
  /**
6
8
  * Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#cds|control dependencies}).
7
- * With `includeDefs`, the cds are also attached (copy-on-write) to the definitions the reference
8
- * resolves to, see {@link applyCdsToDefinitions}.
9
+ * With `includeDefs`, the cds are also attached (copy-on-write) to the definition the reference
10
+ * itself made, see {@link applyCdsToDefinitions}.
9
11
  */
10
12
  export declare function makeReferenceMaybe(ref: IdentifierReference, graph: DataflowGraph, environments: REnvironmentInformation, includeDefs: boolean, defaultCd?: ControlDependency[] | undefined): IdentifierReference;
11
13
  /**
@@ -1,55 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withAppliedCds = withAppliedCds;
3
4
  exports.makeReferenceMaybe = makeReferenceMaybe;
4
5
  exports.makeAllMaybe = makeAllMaybe;
5
6
  exports.applyCdsToAllInGraphButConstants = applyCdsToAllInGraphButConstants;
6
7
  exports.applyCdToReferences = applyCdToReferences;
7
8
  const identifier_1 = require("./identifier");
9
+ const info_1 = require("../info");
8
10
  const resolve_by_name_1 = require("./resolve-by-name");
9
11
  const vertex_1 = require("../graph/vertex");
10
12
  const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
11
- function appToCdsUnique(target, toAdd) {
12
- if (!toAdd) {
13
- return;
14
- }
15
- for (const c of toAdd) {
16
- let found = false;
17
- for (const tc of target) {
18
- if (tc.id === c.id && tc.when === c.when) {
19
- found = true;
20
- break;
21
- }
22
- }
23
- if (!found) {
24
- target.push(c);
25
- }
26
- }
27
- }
28
- function concatCdsUnique(target, toAdd) {
29
- if (!toAdd) {
30
- return target;
31
- }
32
- const result = Array.from(target);
33
- for (const c of toAdd) {
34
- let found = false;
35
- for (const tc of target) {
36
- if (tc.id === c.id && tc.when === c.when) {
37
- found = true;
38
- break;
39
- }
40
- }
41
- if (!found) {
42
- result.push(c);
43
- }
44
- }
45
- return result;
46
- }
47
- /** copy of the definition with the given cds attached */
13
+ /** copy of the definition with the given cds attached, marking it as maybe */
48
14
  function withAppliedCds(definition, defaultCd) {
49
- return {
50
- ...definition,
51
- cds: definition.cds ? concatCdsUnique(definition.cds, defaultCd) : (defaultCd ? Array.from(defaultCd) : [])
52
- };
15
+ return { ...definition, cds: (0, info_1.withCds)(definition.cds, defaultCd) };
53
16
  }
54
17
  /** replaces the definitions stored under the given key by copies carrying the additional cds */
55
18
  function replaceDefinitions(env, key, toUpdate, defaultCd) {
@@ -60,14 +23,16 @@ function replaceDefinitions(env, key, toUpdate, defaultCd) {
60
23
  env.cache?.delete(key);
61
24
  }
62
25
  /**
63
- * Attaches the given control dependencies to the given definitions within the environment chain.
26
+ * Attaches the given control dependencies to the definition made by `nodeId` within the environment chain.
27
+ * Definitions of the same name made elsewhere survive whenever the conditional definition does not happen.
64
28
  * Copy-on-write: definitions are replaced, never mutated in place, so previously cloned
65
29
  * environments (e.g., snapshots stored in the dataflow graph) keep their state.
66
30
  */
67
- function applyCdsToDefinitions(environments, name, type, definitions, defaultCd) {
31
+ function applyCdsToDefinitions(environments, name, type, definitions, nodeId, defaultCd) {
68
32
  const toUpdate = new Set();
69
33
  for (const definition of definitions) {
70
- if (definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant
34
+ if (definition.nodeId === nodeId
35
+ && definition.type !== identifier_1.ReferenceType.BuiltInFunction && definition.type !== identifier_1.ReferenceType.BuiltInConstant
71
36
  && (defaultCd !== undefined || definition.cds === undefined)) {
72
37
  toUpdate.add(definition);
73
38
  }
@@ -95,20 +60,20 @@ function applyCdsToDefinitions(environments, name, type, definitions, defaultCd)
95
60
  }
96
61
  /**
97
62
  * Marks the reference as maybe (i.e., as controlled by a set of {@link IdentifierReference#cds|control dependencies}).
98
- * With `includeDefs`, the cds are also attached (copy-on-write) to the definitions the reference
99
- * resolves to, see {@link applyCdsToDefinitions}.
63
+ * With `includeDefs`, the cds are also attached (copy-on-write) to the definition the reference
64
+ * itself made, see {@link applyCdsToDefinitions}.
100
65
  */
101
66
  function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = undefined) {
102
67
  if (includeDefs && ref.name) {
103
68
  const definitions = (0, resolve_by_name_1.resolveByName)(ref.name, environments, ref.type);
104
69
  if (definitions && definitions.length > 0) {
105
- applyCdsToDefinitions(environments, ref.name, ref.type, definitions, defaultCd);
70
+ applyCdsToDefinitions(environments, ref.name, ref.type, definitions, ref.nodeId, defaultCd);
106
71
  }
107
72
  }
108
73
  const node = graph.getVertex(ref.nodeId);
109
74
  if (node) {
110
75
  if (node.cds) {
111
- appToCdsUnique(node.cds, defaultCd);
76
+ (0, info_1.appendCds)(node.cds, defaultCd);
112
77
  }
113
78
  else {
114
79
  node.cds = defaultCd ? Array.from(defaultCd) : [];
@@ -116,7 +81,7 @@ function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = u
116
81
  }
117
82
  if (ref.cds) {
118
83
  if (defaultCd) {
119
- return { ...ref, cds: concatCdsUnique(ref.cds, defaultCd) };
84
+ return { ...ref, cds: (0, info_1.withCds)(ref.cds, defaultCd) };
120
85
  }
121
86
  }
122
87
  else {
@@ -143,7 +108,7 @@ function applyCdsToAllInGraphButConstants(graph, references, cds) {
143
108
  continue;
144
109
  }
145
110
  if (v.cds) {
146
- appToCdsUnique(v.cds, cds);
111
+ (0, info_1.appendCds)(v.cds, cds);
147
112
  }
148
113
  else {
149
114
  v.cds = Array.from(cds);
@@ -151,7 +116,7 @@ function applyCdsToAllInGraphButConstants(graph, references, cds) {
151
116
  }
152
117
  for (const ref of references) {
153
118
  if (ref.cds) {
154
- appToCdsUnique(ref.cds, cds);
119
+ (0, info_1.appendCds)(ref.cds, cds);
155
120
  }
156
121
  else {
157
122
  ref.cds = Array.from(cds);
@@ -167,7 +132,7 @@ function applyCdToReferences(references, cds) {
167
132
  }
168
133
  for (const ref of references) {
169
134
  if (ref.cds) {
170
- appToCdsUnique(ref.cds, cds);
135
+ (0, info_1.appendCds)(ref.cds, cds);
171
136
  }
172
137
  else {
173
138
  ref.cds = Array.from(cds);
@@ -29,8 +29,9 @@ export declare const Resolve: {
29
29
  readonly toSingleString: typeof resolveIdToSingleString;
30
30
  /** The same, for the arguments of a call. */
31
31
  readonly argument: {
32
+ readonly name: "argument";
32
33
  /** The argument's name. */
33
- readonly name: typeof resolveIdToArgName;
34
+ readonly toName: typeof resolveIdToArgName;
34
35
  /** The argument's value. */
35
36
  readonly value: typeof resolveIdToArgValue;
36
37
  /** The argument's value as a vector of strings. */
@@ -32,8 +32,9 @@ exports.Resolve = {
32
32
  toSingleString: alias_tracking_1.resolveIdToSingleString,
33
33
  /** The same, for the arguments of a call. */
34
34
  argument: {
35
+ name: 'argument',
35
36
  /** The argument's name. */
36
- name: resolve_args_1.resolveIdToArgName,
37
+ toName: resolve_args_1.resolveIdToArgName,
37
38
  /** The argument's value. */
38
39
  value: resolve_args_1.resolveIdToArgValue,
39
40
  /** The argument's value as a vector of strings. */
@@ -137,10 +137,8 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
137
137
  blocked.add(node.info.id);
138
138
  switch (node.type) {
139
139
  case type_1.RType.Argument:
140
- if (node.value) {
141
- return resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve, ctx, blocked });
142
- }
143
- // eslint-disable-next-line no-fallthrough
140
+ /* a missing argument (`f(x=)`) carries no value, and it is no symbol to resolve either */
141
+ return node.value ? resolveIdToValue(node.value.info.id, { environment, graph, idMap, full, resolve, ctx, blocked }) : r_value_1.Top;
144
142
  case type_1.RType.Symbol:
145
143
  if (full) {
146
144
  if (environment) {
@@ -170,9 +168,8 @@ function resolveIdToValue(id, { environment, graph, idMap, full = true, ctx, res
170
168
  }
171
169
  /** Resolves an id to a single constant string value, or `undefined` if it is not a unique string constant. */
172
170
  function resolveIdToSingleString(id, info) {
173
- const resolved = (0, general_1.valueSetGuard)(resolveIdToValue(id, info));
174
- const element = resolved?.elements.length === 1 ? resolved.elements[0] : undefined;
175
- return element?.type === 'string' && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
171
+ const element = (0, general_1.soleValue)((0, general_1.valueSetGuard)(resolveIdToValue(id, info)), 'string');
172
+ return element !== undefined && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
176
173
  }
177
174
  /** the values one element of a sequence may take: a vector contributes its elements, a set what its members do */
178
175
  function iteratedElements(value) {
@@ -0,0 +1,51 @@
1
+ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
2
+ import type { ParentInformation, RNodeWithParent } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
+ import type { DataflowProcessorInformation } from '../../processor';
4
+ import type { DataflowGraph } from '../../graph/graph';
5
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
6
+ import type { ResolveInfo, ResolveResult } from './alias-tracking';
7
+ import { soleValue } from '../values/general';
8
+ import type { Value, ValueSet } from '../values/r-value';
9
+ /** The node to resolve, given either by id or directly. */
10
+ type Target = NodeId | RNodeWithParent | undefined;
11
+ declare function infoOf<OtherInfo>(this: void, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>): ResolveInfo;
12
+ /**
13
+ * The value(s) a node may hold, resolved against the state the current processor sees.
14
+ * Use {@link NodeValue.inGraph} to resolve against a finished {@link DataflowGraph} instead.
15
+ * Every entry point accepts overrides for the cases that deviate (e.g. another environment).
16
+ *
17
+ * This is constant propagation over the dataflow graph, not abstract interpretation: it follows definitions to
18
+ * constants and gives up wherever a value is not statically pinned down, with no fixpoint and no widening.
19
+ * Anything needing an abstract state lives in `src/abstract-interpretation/`.
20
+ */
21
+ export declare const NodeValue: {
22
+ readonly name: "NodeValue";
23
+ /** The resolve info the processor's state stands for, for repeated resolutions. */
24
+ readonly infoOf: typeof infoOf;
25
+ /** The value(s) the node may hold. */
26
+ readonly of: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ResolveResult;
27
+ /** The value set the node may hold, `undefined` if it resolves to top or bottom. */
28
+ readonly setOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
29
+ /** The strings the node may hold, `undefined` if it does not resolve to strings. */
30
+ readonly stringsOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string[] | undefined;
31
+ /** The single string the node resolves to, `undefined` if it is not exactly one. */
32
+ readonly singleStringOf: <OtherInfo>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, overrides?: Partial<ResolveInfo>) => string | undefined;
33
+ /** The one value a set holds, `undefined` unless it holds exactly one, optionally of the given kind. */
34
+ readonly sole: typeof soleValue;
35
+ /** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
36
+ readonly soleOf: <OtherInfo, T extends Value["type"]>(this: void, id: Target, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, {
37
+ type: T;
38
+ }> | undefined;
39
+ /** The same questions, asked of a finished dataflow graph instead of a running processor. */
40
+ readonly inGraph: {
41
+ /** The value set the node may hold, `undefined` if it resolves to top or bottom. */
42
+ readonly setOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => ValueSet<Value[]> | undefined;
43
+ /** The single string the node resolves to, `undefined` if it is not exactly one. */
44
+ readonly singleStringOf: (this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, overrides?: Partial<ResolveInfo>) => string | undefined;
45
+ /** The one value the node resolves to, `undefined` unless it is exactly one, optionally of the given kind. */
46
+ readonly soleOf: <T extends Value["type"]>(this: void, id: Target, graph: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext, type?: T, overrides?: Partial<ResolveInfo>) => Extract<Value, {
47
+ type: T;
48
+ }> | undefined;
49
+ };
50
+ };
51
+ export {};