@eagleoutice/flowr 2.16.3 → 2.16.5

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 (148) hide show
  1. package/README.md +14 -14
  2. package/cli/repl/core.js +13 -2
  3. package/cli/repl/parser/slice-query-parser.d.ts +21 -5
  4. package/cli/repl/parser/slice-query-parser.js +33 -13
  5. package/core/steps/all/static-slicing/10-reconstruct.d.ts +2 -2
  6. package/dataflow/environments/built-in.d.ts +2 -0
  7. package/dataflow/environments/built-in.js +10 -2
  8. package/dataflow/environments/data-masking-functions.js +2 -1
  9. package/dataflow/environments/default-builtin-config.d.ts +31 -5
  10. package/dataflow/environments/default-builtin-config.js +12 -15
  11. package/dataflow/environments/query-fn-props.js +2 -1
  12. package/dataflow/eval/resolve/alias-tracking.js +5 -2
  13. package/dataflow/eval/resolve/node-value.js +1 -1
  14. package/dataflow/eval/resolve/resolve-argument.js +2 -0
  15. package/dataflow/eval/resolve/resolve-strings.d.ts +10 -0
  16. package/dataflow/eval/resolve/resolve-strings.js +79 -12
  17. package/dataflow/eval/resolve/resolve.js +2 -6
  18. package/dataflow/extractor.js +11 -4
  19. package/dataflow/graph/applied-arguments.d.ts +5 -0
  20. package/dataflow/graph/applied-arguments.js +17 -0
  21. package/dataflow/graph/df-helper.js +2 -2
  22. package/dataflow/graph/graph.d.ts +5 -0
  23. package/dataflow/graph/graph.js +5 -0
  24. package/dataflow/info.js +8 -1
  25. package/dataflow/internal/linker.js +35 -13
  26. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +9 -1
  27. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +32 -12
  28. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -1
  29. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +7 -4
  30. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +11 -1
  31. package/dataflow/internal/process/functions/call/named-call-handling.js +4 -2
  32. package/dataflow/internal/process/functions/call/quoted.js +3 -3
  33. package/dataflow/internal/program-order.js +7 -1
  34. package/dataflow/processor.d.ts +2 -0
  35. package/documentation/doc-util/doc-query.d.ts +1 -1
  36. package/documentation/doc-util/doc-query.js +3 -1
  37. package/documentation/doc-util/doc-timings.js +3 -2
  38. package/documentation/doc-util/doc-types.js +4 -0
  39. package/documentation/wiki-create-linting-rules.js +1 -1
  40. package/documentation/wiki-linter.d.ts +14 -0
  41. package/documentation/wiki-linter.js +341 -126
  42. package/linter/linter-executor.js +7 -0
  43. package/linter/linter-rules.d.ts +47 -47
  44. package/linter/rules/absolute-path.d.ts +1 -1
  45. package/linter/rules/absolute-path.js +6 -4
  46. package/linter/rules/cmd-check/call-arguments.d.ts +1 -1
  47. package/linter/rules/cmd-check/call-arguments.js +10 -5
  48. package/linter/rules/cmd-check/compiled-code.d.ts +1 -1
  49. package/linter/rules/cmd-check/compiled-code.js +1 -1
  50. package/linter/rules/cmd-check/conformance.d.ts +5 -1
  51. package/linter/rules/cmd-check/conformance.js +64 -64
  52. package/linter/rules/cmd-check/description-metadata.d.ts +1 -1
  53. package/linter/rules/cmd-check/description-metadata.js +1 -1
  54. package/linter/rules/cmd-check/documentation-mismatch.d.ts +6 -0
  55. package/linter/rules/cmd-check/foreign-function-calls.d.ts +1 -1
  56. package/linter/rules/cmd-check/foreign-function-calls.js +1 -1
  57. package/linter/rules/cmd-check/namespace-tampering.d.ts +1 -1
  58. package/linter/rules/cmd-check/namespace-tampering.js +1 -1
  59. package/linter/rules/cmd-check/non-ascii-code.d.ts +1 -1
  60. package/linter/rules/cmd-check/non-ascii-code.js +1 -1
  61. package/linter/rules/cmd-check/package-data.d.ts +3 -1
  62. package/linter/rules/cmd-check/package-data.js +1 -1
  63. package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
  64. package/linter/rules/cmd-check/package-hooks.js +13 -5
  65. package/linter/rules/cmd-check/package-metafiles.d.ts +1 -1
  66. package/linter/rules/cmd-check/package-metafiles.js +1 -1
  67. package/linter/rules/cmd-check/package-structure.d.ts +1 -1
  68. package/linter/rules/cmd-check/package-structure.js +1 -1
  69. package/linter/rules/cmd-check/rd-files.d.ts +17 -1
  70. package/linter/rules/cmd-check/rd-files.js +1 -1
  71. package/linter/rules/cmd-check/true-false-abbreviation.d.ts +1 -1
  72. package/linter/rules/cmd-check/true-false-abbreviation.js +1 -1
  73. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  74. package/linter/rules/dataframe-access-validation.js +1 -1
  75. package/linter/rules/dead-code.d.ts +4 -4
  76. package/linter/rules/dead-code.js +19 -4
  77. package/linter/rules/deprecated-functions.d.ts +1 -1
  78. package/linter/rules/deprecated-functions.js +1 -1
  79. package/linter/rules/file-path-validity.d.ts +6 -2
  80. package/linter/rules/file-path-validity.js +7 -3
  81. package/linter/rules/namespace-access.d.ts +3 -3
  82. package/linter/rules/namespace-access.js +12 -3
  83. package/linter/rules/naming-convention.d.ts +1 -1
  84. package/linter/rules/naming-convention.js +1 -1
  85. package/linter/rules/network-functions.d.ts +1 -1
  86. package/linter/rules/network-functions.js +1 -1
  87. package/linter/rules/no-leaked-credentials.d.ts +1 -1
  88. package/linter/rules/no-leaked-credentials.js +1 -1
  89. package/linter/rules/problematic-inputs.d.ts +2 -2
  90. package/linter/rules/problematic-inputs.js +4 -4
  91. package/linter/rules/roxygen-arguments.d.ts +2 -2
  92. package/linter/rules/roxygen-arguments.js +2 -2
  93. package/linter/rules/seeded-randomness.d.ts +2 -2
  94. package/linter/rules/seeded-randomness.js +2 -2
  95. package/linter/rules/software-has-license.d.ts +2 -2
  96. package/linter/rules/software-has-license.js +2 -2
  97. package/linter/rules/software-has-tests.d.ts +2 -2
  98. package/linter/rules/software-has-tests.js +2 -2
  99. package/linter/rules/stop-with-call-arg.d.ts +3 -3
  100. package/linter/rules/stop-with-call-arg.js +22 -5
  101. package/linter/rules/syntactically-valid.d.ts +1 -1
  102. package/linter/rules/syntactically-valid.js +1 -1
  103. package/linter/rules/unclosed-connection.d.ts +2 -2
  104. package/linter/rules/unclosed-connection.js +2 -2
  105. package/linter/rules/undefined-symbol.d.ts +1 -1
  106. package/linter/rules/undefined-symbol.js +27 -4
  107. package/linter/rules/unescaped-arguments.d.ts +1 -1
  108. package/linter/rules/unescaped-arguments.js +1 -1
  109. package/linter/rules/unused-definition.d.ts +1 -1
  110. package/linter/rules/unused-definition.js +21 -2
  111. package/linter/rules/unused-import.d.ts +1 -1
  112. package/linter/rules/unused-import.js +1 -1
  113. package/linter/rules/useless-loop.d.ts +1 -1
  114. package/linter/rules/useless-loop.js +1 -1
  115. package/package.json +1 -1
  116. package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
  117. package/project/context/flowr-analyzer-environment-context.js +2 -1
  118. package/project/context/flowr-analyzer-files-context.js +12 -11
  119. package/project/dependency-version-space.js +4 -6
  120. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
  121. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +9 -8
  122. package/project/plugins/file-plugins/flowr-analyzer-test-file-plugin.js +1 -1
  123. package/project/plugins/file-plugins/flowr-analyzer-vignette-file-plugin.js +1 -1
  124. package/queries/catalog/dependencies-query/data-flow.d.ts +2 -0
  125. package/queries/catalog/dependencies-query/data-flow.js +6 -0
  126. package/queries/catalog/dependencies-query/dependencies-query-executor.js +31 -0
  127. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +5 -0
  128. package/queries/catalog/dependencies-query/implicit-echo.js +29 -30
  129. package/queries/catalog/dependencies-query/plot-objects.js +6 -2
  130. package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
  131. package/queries/catalog/dice-query/dice-query-format.js +1 -1
  132. package/queries/catalog/slice-query-options.d.ts +3 -3
  133. package/queries/catalog/slice-query-options.js +1 -1
  134. package/queries/catalog/static-slice-query/static-slice-query-executor.js +12 -1
  135. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +7 -1
  136. package/queries/catalog/static-slice-query/static-slice-query-format.js +4 -2
  137. package/queries/query.d.ts +2 -2
  138. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +19 -56
  139. package/reconstruct/inline/source-inline-map.d.ts +1 -1
  140. package/reconstruct/inline/source-inline-map.js +5 -3
  141. package/reconstruct/reconstruct.d.ts +8 -1
  142. package/reconstruct/reconstruct.js +12 -3
  143. package/slicing/static/removal-slice.d.ts +19 -0
  144. package/slicing/static/removal-slice.js +165 -0
  145. package/slicing/static/static-slicer.js +10 -5
  146. package/util/text/playground-link.d.ts +24 -1
  147. package/util/text/playground-link.js +16 -1
  148. package/util/version.js +2 -2
package/README.md CHANGED
@@ -38,7 +38,7 @@ It offers a wide variety of features, for example:
38
38
 
39
39
  ```shell
40
40
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
41
- flowR repl v2.16.2, R grammar v14 (tree-sitter engine)
41
+ flowR repl v2.16.3, R grammar v14 (tree-sitter engine)
42
42
  R> :query @linter "read.csv(\"/root/x.txt\")"
43
43
  ```
44
44
 
@@ -46,7 +46,7 @@ It offers a wide variety of features, for example:
46
46
  <summary style='color:gray'>Output</summary>
47
47
 
48
48
  ```text
49
- Query: linter (5 ms)
49
+ Query: linter (18 ms)
50
50
  ╰ Deprecated Functions (deprecated-functions): no findings
51
51
  ╰ File Path Validity (file-path-validity): no findings
52
52
  ╰ Seeded Randomness (seeded-randomness): no findings
@@ -56,8 +56,8 @@ It offers a wide variety of features, for example:
56
56
  ╰ Dataframe Access Validation (dataframe-access-validation): no findings
57
57
  ╰ Dead Code (dead-code): no findings
58
58
  ╰ Useless Loops (useless-loop): no findings
59
- ╰ Problematic inputs (problematic-inputs): no findings
60
- ╰ Stop without call.=False argument (stop-call): no findings
59
+ ╰ Problematic Inputs (problematic-inputs): no findings
60
+ ╰ Stop Without Call (stop-call): no findings
61
61
  ╰ Roxygen Arguments (roxygen-arguments): no findings
62
62
  ╰ No Leaked Credentials (no-leaked-credentials): no findings
63
63
  ╰ Undefined Symbol (undefined-symbol): no findings
@@ -65,7 +65,7 @@ It offers a wide variety of features, for example:
65
65
  ╰ Unclosed Connection (unclosed-connection): no findings
66
66
  ╰ Unescaped Arguments (unescaped-arguments): no findings
67
67
  ╰ Namespace Access Validity (namespace-access): no findings
68
- All queries together required ≈5 ms (1ms accuracy, total 5 ms)
68
+ All queries together required ≈18 ms (1ms accuracy, total 18 ms)
69
69
  ```
70
70
 
71
71
  The linter will analyze the code and return any issues found.
@@ -79,7 +79,7 @@ It offers a wide variety of features, for example:
79
79
 
80
80
  _Results (prettified and summarized):_
81
81
 
82
- Query: **linter** (8 ms)\
82
+ Query: **linter** (30 ms)\
83
83
  &nbsp;&nbsp;&nbsp;╰ **Deprecated Functions** (deprecated-functions): _no findings_\
84
84
  &nbsp;&nbsp;&nbsp;╰ **File Path Validity** (file-path-validity):\
85
85
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;╰ certain:\
@@ -93,8 +93,8 @@ It offers a wide variety of features, for example:
93
93
  &nbsp;&nbsp;&nbsp;╰ **Dataframe Access Validation** (dataframe-access-validation): _no findings_\
94
94
  &nbsp;&nbsp;&nbsp;╰ **Dead Code** (dead-code): _no findings_\
95
95
  &nbsp;&nbsp;&nbsp;╰ **Useless Loops** (useless-loop): _no findings_\
96
- &nbsp;&nbsp;&nbsp;╰ **Problematic inputs** (problematic-inputs): _no findings_\
97
- &nbsp;&nbsp;&nbsp;╰ **Stop without call.=False argument** (stop-call): _no findings_\
96
+ &nbsp;&nbsp;&nbsp;╰ **Problematic Inputs** (problematic-inputs): _no findings_\
97
+ &nbsp;&nbsp;&nbsp;╰ **Stop Without Call** (stop-call): _no findings_\
98
98
  &nbsp;&nbsp;&nbsp;╰ **Roxygen Arguments** (roxygen-arguments): _no findings_\
99
99
  &nbsp;&nbsp;&nbsp;╰ **No Leaked Credentials** (no-leaked-credentials): _no findings_\
100
100
  &nbsp;&nbsp;&nbsp;╰ **Undefined Symbol** (undefined-symbol): _no findings_\
@@ -102,7 +102,7 @@ It offers a wide variety of features, for example:
102
102
  &nbsp;&nbsp;&nbsp;╰ **Unclosed Connection** (unclosed-connection): _no findings_\
103
103
  &nbsp;&nbsp;&nbsp;╰ **Unescaped Arguments** (unescaped-arguments): _no findings_\
104
104
  &nbsp;&nbsp;&nbsp;╰ **Namespace Access Validity** (namespace-access): _no findings_\
105
- _All queries together required ≈8 ms (1ms accuracy, total 8 ms)_
105
+ _All queries together required ≈30 ms (1ms accuracy, total 30 ms)_
106
106
 
107
107
  <details> <summary style="color:gray">Show Detailed Results as Json</summary>
108
108
 
@@ -139,7 +139,7 @@ It offers a wide variety of features, for example:
139
139
  ".meta": {
140
140
  "totalFunctionCalls": 1,
141
141
  "totalVariableUses": 0,
142
- "suppressed": {"installed":0,"loadedPackage":0,"enclosingScope":0,"nonStandardEval":0,"subscript":0,"unresolvedLibrary":0}
142
+ "suppressed": {"installed":0,"loadedPackage":0,"enclosingScope":0,"nonStandardEval":0,"subscript":0,"unresolvedLibrary":0,"declaredGlobal":0}
143
143
  }
144
144
  },
145
145
  "unused-import": {"results":[],".meta":{"totalConsidered":0,"totalUnresolved":0,"totalMultiPackage":0,"totalUnused":0}},
@@ -193,7 +193,7 @@ It offers a wide variety of features, for example:
193
193
 
194
194
  ```shell
195
195
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
196
- flowR repl v2.16.2, R grammar v14 (tree-sitter engine)
196
+ flowR repl v2.16.3, R grammar v14 (tree-sitter engine)
197
197
  R> :query @static-slice (11@sum) file://test/testfiles/example.R
198
198
  ```
199
199
 
@@ -206,7 +206,7 @@ It offers a wide variety of features, for example:
206
206
  N <- 10
207
207
  for(i in 1:(N-1)) sum <- sum + i + w
208
208
  sum
209
- All queries together required ≈2 ms (1ms accuracy, total 3 ms)
209
+ All queries together required ≈6 ms (1ms accuracy, total 6 ms)
210
210
  ```
211
211
 
212
212
  </details>
@@ -214,7 +214,7 @@ It offers a wide variety of features, for example:
214
214
  </details>
215
215
 
216
216
  * 🚀 **fast call-graph, data-, and control-flow graphs**\
217
- Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">128.4 ms</span></i> (as of Oct 16, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
217
+ Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">137.3 ms</span></i> (as of Oct 19, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
218
218
  _flowR_ can analyze the data- and control-flow of the average real-world R&nbsp;script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
219
219
  and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph#perspectives-cg).
220
220
  (&nbsp;[▶&nbsp;Explore in Browser](https://flowr-analysis.github.io/flowr/wiki/playground/#c=zDYSwRgTghhCeAUATADsWECUAoLBnAxlMAKYD6ALgPakC2UAHgAQA8AtIwGYCuAdvuSEo949DIyYB6RnXojsWaAHdGKlW0aIo5KADoO0GsXghEjALyMAjAC4AbABpGANyJdi5xvngBmRwA5HAHZHACZHAE5HABYMbHwSKB5VdQ4QYHJiCHglRxdgN0YAPkYQuISeABICImJTdWqSCmoZeHjiRIq8t3lcLho6OFJcbXJcFnZe-pgQXCM2xMdDRI8l4Qba2KxeLlnEJu1gNQm%2B7KhFTtdieUUIEAydfFwneEmB2CGR3EcAIleYWAeT2%2B2FQlHIrXKVUIJEQIMoIB4owh7UqJgwQA&p=13:1 "run this script in flowR's playground, no setup")&nbsp;)
@@ -245,7 +245,7 @@ It offers a wide variety of features, for example:
245
245
 
246
246
  ```shell
247
247
  $ docker run -it --rm eagleoutice/flowr # or npm run flowr
248
- flowR repl v2.16.2, R grammar v14 (tree-sitter engine)
248
+ flowR repl v2.16.3, R grammar v14 (tree-sitter engine)
249
249
  R> :dataflow* test/testfiles/example.R
250
250
  ```
251
251
 
package/cli/repl/core.js CHANGED
@@ -81,6 +81,11 @@ function replCompleterKeywords() {
81
81
  return _replCompleterKeywords;
82
82
  }
83
83
  const defaultHistoryFile = path_1.default.join(os_1.default.tmpdir(), '.flowrhistory');
84
+ /** Lines like `[REPL Stats] ...` are printed by the repl itself, so they only reach the prompt when output is pasted back in, maybe with the prompt. */
85
+ function isReplStatsLine(line) {
86
+ const text = line.trimStart();
87
+ return (text.startsWith(prompt_1.rawPrompt) ? text.slice(prompt_1.rawPrompt.length).trimStart() : text).startsWith('[REPL Stats]');
88
+ }
84
89
  /** Labels a completion with what it does, see {@link CommandCompletions#labels|labels}. */
85
90
  function describeCompletion(insert, describe) {
86
91
  return `${insert} ${ansi_1.ansiFormatter.format(describe, { style: 2 /* FontStyles.Faint */ })}`;
@@ -390,7 +395,7 @@ async function replProcessAnswer(analyzer, output, expr, allowRSessionAccess, re
390
395
  */
391
396
  async function repl({ analyzer, historyFile = defaultHistoryFile, rl = readline.createInterface(makeDefaultReplReadline(analyzer.flowrConfig, historyFile)), output = repl_main_1.standardReplOutput, allowRSessionAccess = false }) {
392
397
  if (historyFile) {
393
- rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.join('\n'), { encoding: 'utf-8' }));
398
+ rl.on('history', h => fs_1.default.writeFileSync(historyFile, h.filter(l => !isReplStatsLine(l)).join('\n'), { encoding: 'utf-8' }));
394
399
  }
395
400
  const ghostHint = (0, ghost_hint_1.installGhostHint)(rl, analyzer.flowrConfig, {
396
401
  suggest: line => completionSuggestion(line, analyzer.flowrConfig)
@@ -429,6 +434,12 @@ async function repl({ analyzer, historyFile = defaultHistoryFile, rl = readline.
429
434
  rl.question(activeWatcher !== undefined ? '' : (0, prompt_1.prompt)(), answer => {
430
435
  ghostHint.clear();
431
436
  sigintCount = 0;
437
+ if (isReplStatsLine(answer)) {
438
+ // copied REPL output, not input: keep it out of the history and do not run it
439
+ rl.history?.shift();
440
+ resolve();
441
+ return;
442
+ }
432
443
  rl.pause();
433
444
  replProcessAnswer(analyzer, output, answer, allowRSessionAccess).then(() => {
434
445
  rl.resume();
@@ -449,7 +460,7 @@ function loadReplHistory(historyFile) {
449
460
  if (!fs_1.default.existsSync(historyFile)) {
450
461
  return undefined;
451
462
  }
452
- return fs_1.default.readFileSync(historyFile, { encoding: 'utf-8' }).split('\n');
463
+ return fs_1.default.readFileSync(historyFile, { encoding: 'utf-8' }).split('\n').filter(l => !isReplStatsLine(l));
453
464
  }
454
465
  catch (e) {
455
466
  log_1.log.error(`Failed to load repl history from ${historyFile}: ${e?.message}`);
@@ -9,11 +9,20 @@ export interface SliceFlag {
9
9
  readonly flag: string;
10
10
  /** what the flag does, kept to a few words as it is offered as a completion */
11
11
  readonly describe: string;
12
- /** the flag this one only makes sense with, if any */
13
- readonly requires?: string;
12
+ /** the flags this one only makes sense with one of, if any */
13
+ readonly requires?: readonly string[];
14
14
  /** the flags this one must not be combined with */
15
15
  readonly conflicts?: readonly string[];
16
16
  }
17
+ /** the letter of every flag a criteria argument may end with, the one place they are spelled out */
18
+ export declare const SliceFlagLetter: {
19
+ readonly Forward: "f";
20
+ readonly Removal: "r";
21
+ readonly InlineSources: "i";
22
+ readonly IncludeCallees: "c";
23
+ readonly InlineFull: "I";
24
+ readonly Banners: "B";
25
+ };
17
26
  /** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */
18
27
  export declare const SharedSliceFlags: readonly [{
19
28
  readonly flag: "i";
@@ -29,12 +38,17 @@ export declare const SharedSliceFlags: readonly [{
29
38
  }, {
30
39
  readonly flag: "B";
31
40
  readonly describe: "banners";
32
- readonly requires: "I";
41
+ readonly requires: readonly ["i", "I"];
33
42
  }];
34
43
  /** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */
35
44
  export declare const StaticSliceFlags: readonly [{
36
45
  readonly flag: "f";
37
46
  readonly describe: "slice forward";
47
+ readonly conflicts: readonly ["r"];
48
+ }, {
49
+ readonly flag: "r";
50
+ readonly describe: "removal slice";
51
+ readonly conflicts: readonly ["f"];
38
52
  }, {
39
53
  readonly flag: "i";
40
54
  readonly describe: "inline sources";
@@ -49,18 +63,20 @@ export declare const StaticSliceFlags: readonly [{
49
63
  }, {
50
64
  readonly flag: "B";
51
65
  readonly describe: "banners";
52
- readonly requires: "I";
66
+ readonly requires: readonly ["i", "I"];
53
67
  }];
54
68
  /**
55
69
  * Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
56
70
  */
57
71
  export declare function sliceDirectionParser(argument: string): SliceDirection;
72
+ /** Whether the flag suffix of `argument` asks for the removal slice (`r`) rather than the slice. */
73
+ export declare function sliceRemovalParser(argument: string): boolean;
58
74
  /**
59
75
  * The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}.
60
76
  * An absent flag is left out entirely, so the default of the query applies.
61
77
  */
62
78
  export declare function sliceQueryOptionsParser(argument: string): SliceQueryOptions;
63
- /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */
79
+ /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs i or I)` */
64
80
  export declare function describeSliceFlags(flags: readonly SliceFlag[]): string;
65
81
  /**
66
82
  * Warns about the flags of `argument` that `flags` does not know (a `f` on a dice, a typo, ...) or that
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StaticSliceFlags = exports.SharedSliceFlags = void 0;
3
+ exports.StaticSliceFlags = exports.SharedSliceFlags = exports.SliceFlagLetter = void 0;
4
4
  exports.sliceDirectionParser = sliceDirectionParser;
5
+ exports.sliceRemovalParser = sliceRemovalParser;
5
6
  exports.sliceQueryOptionsParser = sliceQueryOptionsParser;
6
7
  exports.describeSliceFlags = describeSliceFlags;
7
8
  exports.warnAboutSliceFlags = warnAboutSliceFlags;
@@ -39,20 +40,38 @@ function splitCriteriaArgument(argument) {
39
40
  function sliceFlagSuffix(argument) {
40
41
  return splitCriteriaArgument(argument)?.flags ?? '';
41
42
  }
43
+ /** the letter of every flag a criteria argument may end with, the one place they are spelled out */
44
+ exports.SliceFlagLetter = {
45
+ Forward: 'f',
46
+ Removal: 'r',
47
+ InlineSources: 'i',
48
+ IncludeCallees: 'c',
49
+ InlineFull: 'I',
50
+ Banners: 'B'
51
+ };
52
+ const { Forward, Removal, InlineSources, IncludeCallees, InlineFull, Banners } = exports.SliceFlagLetter;
42
53
  /** the flags every slicing query understands, see {@link sliceQueryOptionsParser} */
43
54
  exports.SharedSliceFlags = [
44
- { flag: 'i', describe: 'inline sources', conflicts: ['I'] },
45
- { flag: 'c', describe: 'include callees' },
46
- { flag: 'I', describe: 'inline all files', conflicts: ['i'] },
47
- { flag: 'B', describe: 'banners', requires: 'I' }
55
+ { flag: InlineSources, describe: 'inline sources', conflicts: [InlineFull] },
56
+ { flag: IncludeCallees, describe: 'include callees' },
57
+ { flag: InlineFull, describe: 'inline all files', conflicts: [InlineSources] },
58
+ { flag: Banners, describe: 'banners', requires: [InlineSources, InlineFull] }
48
59
  ];
49
60
  /** the flags of the `static-slice` query: a dice fixes both directions, so only it can be told to slice forward */
50
- exports.StaticSliceFlags = [{ flag: 'f', describe: 'slice forward' }, ...exports.SharedSliceFlags];
61
+ exports.StaticSliceFlags = [
62
+ { flag: Forward, describe: 'slice forward', conflicts: [Removal] },
63
+ { flag: Removal, describe: 'removal slice', conflicts: [Forward] },
64
+ ...exports.SharedSliceFlags
65
+ ];
51
66
  /**
52
67
  * Checks whether the given argument represents a slicing direction with an `f` suffix (in any flag order).
53
68
  */
54
69
  function sliceDirectionParser(argument) {
55
- return sliceFlagSuffix(argument).includes('f') ? slice_direction_1.SliceDirection.Forward : slice_direction_1.SliceDirection.Backward;
70
+ return sliceFlagSuffix(argument).includes(Forward) ? slice_direction_1.SliceDirection.Forward : slice_direction_1.SliceDirection.Backward;
71
+ }
72
+ /** Whether the flag suffix of `argument` asks for the removal slice (`r`) rather than the slice. */
73
+ function sliceRemovalParser(argument) {
74
+ return sliceFlagSuffix(argument).includes(Removal);
56
75
  }
57
76
  /**
58
77
  * The {@link SliceQueryOptions} the flag suffix of `argument` requests, see {@link SharedSliceFlags}.
@@ -60,15 +79,16 @@ function sliceDirectionParser(argument) {
60
79
  */
61
80
  function sliceQueryOptionsParser(argument) {
62
81
  const flags = sliceFlagSuffix(argument);
82
+ const inlining = flags.includes(Banners) ? 'banner' : true;
63
83
  return {
64
- ...(flags.includes('i') ? { inlineSources: true } : {}),
65
- ...(flags.includes('I') ? { inlineFull: flags.includes('B') ? 'banner' : true } : {}),
66
- ...(flags.includes('c') ? { includeCallees: true } : {})
84
+ ...(flags.includes(InlineSources) ? { inlineSources: inlining } : {}),
85
+ ...(flags.includes(InlineFull) ? { inlineFull: inlining } : {}),
86
+ ...(flags.includes(IncludeCallees) ? { includeCallees: true } : {})
67
87
  };
68
88
  }
69
- /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs I)` */
89
+ /** the given flags and what they do, e.g. for a help text: `f (slice forward), B (banners, needs i or I)` */
70
90
  function describeSliceFlags(flags) {
71
- return flags.map(f => `${f.flag} (${f.describe}${f.requires ? `, needs ${f.requires}` : ''})`).join(', ');
91
+ return flags.map(f => `${f.flag} (${f.describe}${f.requires ? `, needs ${f.requires.join(' or ')}` : ''})`).join(', ');
72
92
  }
73
93
  function warn(output, message) {
74
94
  output.stderr(output.formatter.format(message, { color: 3 /* Colors.Yellow */, effect: ansi_1.ColorEffect.Foreground }));
@@ -126,7 +146,7 @@ function sliceFlagCompletions(arg, flags) {
126
146
  }
127
147
  const has = (flag) => split.flags.includes(flag);
128
148
  const offered = flags.filter(f => !has(f.flag)
129
- && (f.requires === undefined || has(f.requires))
149
+ && (f.requires === undefined || f.requires.some(has))
130
150
  && !f.conflicts?.some(has));
131
151
  return {
132
152
  completions: [...offered.map(f => arg + f.flag), arg + ' '],
@@ -1,7 +1,7 @@
1
1
  import { internalPrinter } from '../../../print/print';
2
2
  import { PipelineStepStage } from '../../pipeline-step';
3
3
  import type { SliceResult } from '../../../../slicing/static/slicer-types';
4
- import { type InlineFull } from '../../../../reconstruct/reconstruct';
4
+ import { type InlineFull, type InlineSources } from '../../../../reconstruct/reconstruct';
5
5
  import type { NormalizedAst } from '../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
6
  import type { AutoSelectPredicate } from '../../../../reconstruct/auto-select/auto-select-defaults';
7
7
  import type { DataflowInformation } from '../../../../dataflow/info';
@@ -19,7 +19,7 @@ export interface ReconstructRequiredInput {
19
19
  * Inline resolvable `source()` calls into the reconstruction so the result is a single self-contained R text.
20
20
  * Cyclic and unresolvable `source()` calls are kept verbatim and reported via `reconstruct.inlineWarnings`.
21
21
  */
22
- inlineSources?: boolean;
22
+ inlineSources?: InlineSources;
23
23
  /**
24
24
  * Inline *every* file into the reconstruction, in flowR's loading order (which respects implicit sources).
25
25
  * Overrides {@link inlineSources} and {@link reconstructFiles}.
@@ -69,6 +69,8 @@ export interface BuiltInIdentifierDefinition extends IdentifierReference {
69
69
  };
70
70
  /** folds a call to this function to a constant, see {@link BuiltInEvalHandlerMapper} */
71
71
  evalHandler?: BuiltInEvalHandler;
72
+ /** the processor's name, for a call made on our behalf (`do.call(new.env, list())`) that does not run it */
73
+ processorName?: BuiltInProcName;
72
74
  }
73
75
  export interface BuiltInIdentifierConstant<T = unknown> extends IdentifierReference {
74
76
  type: ReferenceType.BuiltInConstant;
@@ -200,12 +200,19 @@ function defaultBuiltInProcessorReadallArgs(name, args, rootId, data, { useAsPro
200
200
  (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, masked, { kind: known_call_handling_1.NseKind.DataMasked, first });
201
201
  return ambient === undefined ? information : (0, built_in_ambient_state_1.applyAmbientStateAccess)(information, args, rootId, data, ambient);
202
202
  }
203
- /** A call that reads or writes the files its arguments name accesses the {@link AmbientStateName.files|files on disk} as well. */
203
+ /**
204
+ * A call that reads or writes the files its arguments name accesses the {@link AmbientStateName.files|files on disk} as well.
205
+ * Closing a device writes the file its opening already wrote, and only a device's file name may number its pages (`plot%03d.png`).
206
+ */
204
207
  function withFileAccess(config) {
205
208
  const { tags, ambient, sig } = (config ?? {});
206
209
  const type = !tags?.includes(built_in_props_1.SemanticCallTag.File) ? undefined : tags.includes(built_in_props_1.SemanticCallTag.Writes) ? "write-files" /* AmbientStateAccessType.WriteFiles */ : tags.includes(built_in_props_1.SemanticCallTag.Reads) ? "read-files" /* AmbientStateAccessType.ReadFiles */ : undefined;
207
210
  const stated = [ambient ?? []].flat();
208
- return type === undefined || stated.some(a => a.type === type) ? config : { ...config, ambient: [...stated, { type, sig: tags?.includes(built_in_props_1.SemanticCallTag.Glob) ? undefined : sig }] };
211
+ if (type === undefined || stated.some(a => a.type === type || a.type === "close-device" /* AmbientStateAccessType.CloseDevice */)) {
212
+ return config;
213
+ }
214
+ const numbered = stated.some(a => a.type === "open-device" /* AmbientStateAccessType.OpenDevice */);
215
+ return { ...config, ambient: [...stated, { type, sig: tags?.includes(built_in_props_1.SemanticCallTag.Glob) ? undefined : sig, numbered }] };
209
216
  }
210
217
  exports.BuiltInProcessorMapper = {
211
218
  [built_in_proc_name_1.BuiltInProcName.Access]: built_in_access_1.processAccess,
@@ -315,6 +322,7 @@ class BuiltIns {
315
322
  processor: (name, args, rootId, data) => mappedProcessor(name, args, rootId, data, config),
316
323
  config,
317
324
  evalHandler: mappedEval,
325
+ processorName: processor,
318
326
  name,
319
327
  nodeId: id
320
328
  }];
@@ -41,5 +41,6 @@ exports.DataMaskingFunctions = [
41
41
  /** The {@link DataMaskingFunctions} as {@link Identifier}s, for the built-in configuration. */
42
42
  exports.DataMaskingFunctionIdentifiers = exports.DataMaskingFunctions.map(([name, pkg]) => identifier_1.Identifier.from([name, pkg]));
43
43
  /** Names to treat as data-masking in the pipe: the {@link DataMaskingFunctions} plus `with`/`within` (own processor). */
44
- exports.DataMaskingFunctionNames = new Set([...exports.DataMaskingFunctions.map(([name]) => name), 'with', 'within']);
44
+ /* a formula (`~`) finds a name no data supplies where it was made, so `lm(y ~ x)` reads `x` */
45
+ exports.DataMaskingFunctionNames = new Set([...exports.DataMaskingFunctions.map(([name]) => name), 'with', 'within', '~']);
45
46
  //# sourceMappingURL=data-masking-functions.js.map
@@ -90,6 +90,8 @@ export declare const LinkToLastGgPlot: {
90
90
  readonly type: "link-to-last-call";
91
91
  readonly callName: RegExp;
92
92
  };
93
+ /** The internal generics: they dispatch in C rather than through `UseMethod`, so the list has to be written down. */
94
+ export declare const InternalGenerics: ReadonlySet<string>;
93
95
  /**
94
96
  * Contains the built-in definitions recognized by flowR, as they are written down: {@link DefaultBuiltinConfig}
95
97
  * is what {@link markGenerics} makes of them, and a test checks that this is all it changes.
@@ -169,7 +171,7 @@ export declare const WrittenBuiltinDefinitions: [{
169
171
  readonly processor: BuiltInProcName.DefaultReadAllArgs;
170
172
  readonly config: {
171
173
  readonly markArgsAsMasked: NseArguments.All;
172
- readonly sig: [["y", ArgProp.Nse], ["model", number]];
174
+ readonly sig: [["y", 0], ["model", ArgProp.NoDefault]];
173
175
  };
174
176
  readonly assumePrimitive: false;
175
177
  }, {
@@ -2273,9 +2275,14 @@ export declare const WrittenBuiltinDefinitions: [{
2273
2275
  }, {
2274
2276
  readonly type: "function";
2275
2277
  readonly names: [Identifier];
2276
- readonly processor: BuiltInProcName.DefaultReadAllArgs;
2278
+ readonly processor: BuiltInProcName.Default;
2277
2279
  readonly config: {
2278
2280
  readonly libFn: true;
2281
+ readonly readAllArguments: true;
2282
+ readonly hasUnknownSideEffects: {
2283
+ readonly type: "link-to-last-call";
2284
+ readonly callName: RegExp;
2285
+ };
2279
2286
  readonly tags: [SemanticCallTag.File, SemanticCallTag.Writes];
2280
2287
  readonly sig: [["filename", number], ["plot", number], ["device", ArgProp.Flag], ["path", ArgProp.Resource], ["scale", ArgProp.Flag], ["width", ArgProp.Flag], ["height", ArgProp.Flag], ["units", ArgProp.Flag], ["dpi", ArgProp.Flag], ["limitsize", ArgProp.Flag], ["bg", ArgProp.Flag], ["create.dir", ArgProp.Flag], ["...", ArgProp.Flag]];
2281
2288
  };
@@ -2283,9 +2290,14 @@ export declare const WrittenBuiltinDefinitions: [{
2283
2290
  }, {
2284
2291
  readonly type: "function";
2285
2292
  readonly names: [Identifier];
2286
- readonly processor: BuiltInProcName.DefaultReadAllArgs;
2293
+ readonly processor: BuiltInProcName.Default;
2287
2294
  readonly config: {
2288
2295
  readonly libFn: true;
2296
+ readonly readAllArguments: true;
2297
+ readonly hasUnknownSideEffects: {
2298
+ readonly type: "link-to-last-call";
2299
+ readonly callName: RegExp;
2300
+ };
2289
2301
  readonly tags: [SemanticCallTag.File, SemanticCallTag.Writes];
2290
2302
  readonly sig: [["filename", number], ["...", number]];
2291
2303
  };
@@ -4085,7 +4097,9 @@ export declare const WrittenBuiltinDefinitions: [{
4085
4097
  readonly names: [Identifier];
4086
4098
  readonly processor: BuiltInProcName.Default;
4087
4099
  readonly config: {
4088
- readonly hasUnknownSideEffects: true;
4100
+ readonly ambient: {
4101
+ readonly type: AmbientStateAccessType.SetWorkingDirectory;
4102
+ };
4089
4103
  readonly props: number;
4090
4104
  readonly sig: [["dir", number]];
4091
4105
  };
@@ -6278,6 +6292,18 @@ export declare const WrittenBuiltinDefinitions: [{
6278
6292
  readonly sig: [["...", ArgProp.Forced]];
6279
6293
  };
6280
6294
  readonly assumePrimitive: false;
6295
+ }, {
6296
+ readonly type: "function";
6297
+ readonly names: [Identifier];
6298
+ readonly processor: BuiltInProcName.Default;
6299
+ readonly config: {
6300
+ readonly ambient: {
6301
+ readonly type: AmbientStateAccessType.GetWorkingDirectory;
6302
+ };
6303
+ readonly props: CallProp.Ambient;
6304
+ readonly sig: [["...", ArgProp.Forced]];
6305
+ };
6306
+ readonly assumePrimitive: false;
6281
6307
  }, {
6282
6308
  readonly type: "function";
6283
6309
  readonly names: [Identifier];
@@ -6618,7 +6644,6 @@ export declare const WrittenBuiltinDefinitions: [{
6618
6644
  readonly props: CallProp.Scope;
6619
6645
  };
6620
6646
  }, {
6621
- readonly overrides: true;
6622
6647
  readonly type: "function";
6623
6648
  readonly names: [Identifier];
6624
6649
  readonly processor: BuiltInProcName.DefaultReadAllArgs;
@@ -6627,6 +6652,7 @@ export declare const WrittenBuiltinDefinitions: [{
6627
6652
  readonly sig: [["fmt", number], ["...", number]];
6628
6653
  };
6629
6654
  readonly assumePrimitive: true;
6655
+ readonly evalHandler: BuiltInEvalName.StringFn;
6630
6656
  }, {
6631
6657
  readonly overrides: true;
6632
6658
  readonly type: "function";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.LinkToLastGgPlot = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotObjectCreate = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
3
+ exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.InternalGenerics = exports.LinkToLastGgPlot = exports.BasePrimitiveTopics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotObjectCreate = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
4
4
  exports.plotFunctionOwners = plotFunctionOwners;
5
5
  exports.namespacePlotFunctions = namespacePlotFunctions;
6
6
  exports.statedSignatures = statedSignatures;
@@ -407,19 +407,19 @@ const LinkToLastPlot = {
407
407
  callName: toRegex(GraphicDeviceOpen.concat(exports.PlotCreate, PlotAddons, exports.GgPlotAddons, exports.TinyPlotAddons))
408
408
  };
409
409
  /** The internal generics: they dispatch in C rather than through `UseMethod`, so the list has to be written down. */
410
- const InternalGenerics = [
410
+ exports.InternalGenerics = new Set([
411
411
  '$', '[', '[[', '+', '-', '*', '/', '^', '%%', '%/%', '==', '!=', '<', '>', '<=', '>=', '&', '|', '!',
412
412
  'c', 'length', 'dim', 'dimnames', 'names', 'max', 'min', 'range', 'sum', 'prod', 'abs', 'sqrt', 'exp',
413
413
  'log', 'floor', 'ceiling', 'round', 'signif', 'trunc', 'cumsum', 'cumprod', 'cummax', 'cummin',
414
414
  'as.character', 'as.integer', 'as.double', 'as.logical', 'as.complex', 'as.numeric', 'as.raw',
415
415
  'is.na', 'is.nan', 'is.finite', 'is.infinite', 'is.matrix', 'is.numeric', 'cbind', 'rbind', 'anyNA', 'as.environment',
416
416
  'as.call', 'is.array', 'log2', 'log10', 'rep', 'seq.int', 'xtfrm'
417
- ];
417
+ ]);
418
418
  /**
419
419
  * Every name R dispatches on: the generated closure generics plus the {@link InternalGenerics} (no R body, so
420
420
  * {@link fnInfoFromSignature} never sees them). `npm run check:generic-labels` checks this against a synced database.
421
421
  */
422
- const RGenerics = new Set([...r_base_packages_generated_1.RBasePackageStore.generics, ...InternalGenerics]);
422
+ const RGenerics = new Set([...r_base_packages_generated_1.RBasePackageStore.generics, ...exports.InternalGenerics]);
423
423
  /** Label every {@link RGenerics} {@link CallProp.Generic}, splitting an entry that mixes them with names that do not dispatch (`&` does, `&&` does not). */
424
424
  function markGenerics(definitions) {
425
425
  const out = [];
@@ -556,7 +556,7 @@ exports.WrittenBuiltinDefinitions = [
556
556
  { type: 'constant', names: [identifier_1.Identifier.from(['month.abb', "base" /* PkgName.Base */])], value: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], assumePrimitive: true },
557
557
  { type: 'constant', names: [identifier_1.Identifier.from(['month.name', "base" /* PkgName.Base */])], value: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], assumePrimitive: true },
558
558
  /* formula: operands are model terms/columns, not variables */
559
- { type: 'function', names: [identifier_1.Identifier.from(['~', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { markArgsAsMasked: known_call_handling_1.NseArguments.All, sig: [['y', built_in_props_1.ArgProp.Nse], ['model', built_in_props_1.ArgProp.NoDefault | built_in_props_1.ArgProp.Nse]] }, assumePrimitive: false },
559
+ { type: 'function', names: [identifier_1.Identifier.from(['~', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { markArgsAsMasked: known_call_handling_1.NseArguments.All, sig: [['y', 0], ['model', built_in_props_1.ArgProp.NoDefault]] }, assumePrimitive: false },
560
560
  /* cohortBuilder has a `filter` too, and built-ins go by name, so dplyr's entry below wins in the environment
561
561
  while this one still states what cohortBuilder's does */
562
562
  { type: 'function', names: [identifier_1.Identifier.from(['filter', "cohortBuilder" /* PkgName.CohortBuilder */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, props: built_in_props_1.CallProp.Pure, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
@@ -654,7 +654,7 @@ exports.WrittenBuiltinDefinitions = [
654
654
  'solve', 'det', 'eigen', 'aperm',
655
655
  /* string */
656
656
  'grep', 'sub', 'gsub', 'substr', 'substring', 'strsplit', 'strrep', 'chartr', 'strtoi', 'shQuote',
657
- 'regexpr', 'gregexpr', 'regexec', 'format', 'sprintf', 'formatC',
657
+ 'regexpr', 'gregexpr', 'regexec', 'format', 'formatC',
658
658
  /* regmatches yields a substring of its subject, so what flows in flows out */
659
659
  'regmatches'
660
660
  ]),
@@ -840,12 +840,8 @@ exports.WrittenBuiltinDefinitions = [
840
840
  { type: 'function', names: [identifier_1.Identifier.from(['writeWorksheetToFile', "XLConnect" /* PkgName.XlConnect */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
841
841
  { type: 'function', names: [identifier_1.Identifier.from(['visSave', "visNetwork" /* PkgName.VisNetwork */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['graph', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
842
842
  { type: 'function', names: [identifier_1.Identifier.from(['save_graph', "DiagrammeR" /* PkgName.DiagrammeR */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['graph', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
843
- { type: 'function', names: [identifier_1.Identifier.from(['ggsave', "ggplot2" /* PkgName.GgPlot2 */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [
844
- ['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['plot', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['device', built_in_props_1.ArgProp.Flag], ['path', built_in_props_1.ArgProp.Resource],
845
- ['scale', built_in_props_1.ArgProp.Flag], ['width', built_in_props_1.ArgProp.Flag], ['height', built_in_props_1.ArgProp.Flag], ['units', built_in_props_1.ArgProp.Flag], ['dpi', built_in_props_1.ArgProp.Flag], ['limitsize', built_in_props_1.ArgProp.Flag],
846
- ['bg', built_in_props_1.ArgProp.Flag], ['create.dir', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Flag]
847
- ] }, assumePrimitive: false },
848
- { type: 'function', names: [identifier_1.Identifier.from(['ggsave2', "cowplot" /* PkgName.Cowplot */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
843
+ { type: 'function', names: [identifier_1.Identifier.from(['ggsave', "ggplot2" /* PkgName.GgPlot2 */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, readAllArguments: true, hasUnknownSideEffects: exports.LinkToLastGgPlot, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['plot', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['device', built_in_props_1.ArgProp.Flag], ['path', built_in_props_1.ArgProp.Resource], ['scale', built_in_props_1.ArgProp.Flag], ['width', built_in_props_1.ArgProp.Flag], ['height', built_in_props_1.ArgProp.Flag], ['units', built_in_props_1.ArgProp.Flag], ['dpi', built_in_props_1.ArgProp.Flag], ['limitsize', built_in_props_1.ArgProp.Flag], ['bg', built_in_props_1.ArgProp.Flag], ['create.dir', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
844
+ { type: 'function', names: [identifier_1.Identifier.from(['ggsave2', "cowplot" /* PkgName.Cowplot */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, readAllArguments: true, hasUnknownSideEffects: exports.LinkToLastGgPlot, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['filename', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
849
845
  { type: 'function', names: [identifier_1.Identifier.from(['write_json', "jsonlite" /* PkgName.Jsonlite */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['path', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
850
846
  { type: 'function', names: [identifier_1.Identifier.from(['fwrite', "data.table" /* PkgName.DataTable */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
851
847
  { type: 'function', names: [identifier_1.Identifier.from(['write_xlsx', "writexl" /* PkgName.Writexl */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['path', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
@@ -1026,7 +1022,7 @@ exports.WrittenBuiltinDefinitions = [
1026
1022
  { type: 'function', names: identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['dev.set', 'dev.next', 'dev.prev']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Configures, libFn: true, ambient: { type: "switch-device" /* AmbientStateAccessType.SwitchDevice */ }, tags: [built_in_props_1.SemanticCallTag.Graphics], sig: [['which', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1027
1023
  { type: 'function', names: ['('], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { keepArgumentOut: true, props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Alias]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Group },
1028
1024
  { type: 'function', names: [identifier_1.Identifier.from(['load_all', "pkgload" /* PkgName.PkgLoad */]), identifier_1.Identifier.from(['load_all', "devtools" /* PkgName.Devtools */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, props: built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.Invisible, sig: [['path', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1029
- { type: 'function', names: [identifier_1.Identifier.from(['setwd', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Ambient | built_in_props_1.CallProp.Configures, sig: [['dir', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1025
+ { type: 'function', names: [identifier_1.Identifier.from(['setwd', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "set-working-directory" /* AmbientStateAccessType.SetWorkingDirectory */ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Ambient | built_in_props_1.CallProp.Configures, sig: [['dir', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1030
1026
  { type: 'function', names: [identifier_1.Identifier.from(['set.seed', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "set-rng" /* AmbientStateAccessType.SetRng */ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Configures, tags: [built_in_props_1.SemanticCallTag.Random], sig: [['seed', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['normal.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['sample.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1031
1027
  { type: 'function', names: [identifier_1.Identifier.from(['RNGkind', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "set-rng" /* AmbientStateAccessType.SetRng */, kindFrom: 0 }, props: built_in_props_1.CallProp.Configures, tags: [built_in_props_1.SemanticCallTag.Random], sig: [['kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['normal.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced], ['sample.kind', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1032
1028
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['body', 'formals']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, props: built_in_props_1.CallProp.Lang, sig: [['fun', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: true },
@@ -1357,7 +1353,8 @@ exports.WrittenBuiltinDefinitions = [
1357
1353
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['dyn.load', 'getNativeSymbolInfo']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ffi, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1358
1354
  { type: 'function', names: [identifier_1.Identifier.from(['sourceCpp', "Rcpp" /* PkgName.Rcpp */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { libFn: true, props: built_in_props_1.CallProp.Ffi | built_in_props_1.CallProp.Invisible, tags: [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads], sig: [['file', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
1359
1355
  /* ambient state: options, environment variables, the clock, the session itself */
1360
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Sys.getenv', 'Sys.info', 'Sys.getpid', 'getwd', 'getRversion', 'R.Version', 'Sys.time', 'Sys.Date', 'Sys.timezone', 'date', 'proc.time', 'interactive']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1356
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Sys.getenv', 'Sys.info', 'Sys.getpid', 'getRversion', 'R.Version', 'Sys.time', 'Sys.Date', 'Sys.timezone', 'date', 'proc.time', 'interactive']), processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1357
+ { type: 'function', names: [identifier_1.Identifier.from(['getwd', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "get-working-directory" /* AmbientStateAccessType.GetWorkingDirectory */ }, props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1361
1358
  { type: 'function', names: [identifier_1.Identifier.from(['getOption', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { ambient: { type: "get-option" /* AmbientStateAccessType.GetOption */ }, props: built_in_props_1.CallProp.Ambient, sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1362
1359
  { type: 'function', names: [identifier_1.Identifier.from(['commandArgs', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.Default, config: { props: built_in_props_1.CallProp.Ambient, tags: [built_in_props_1.SemanticCallTag.CommandLine], sig: [['...', built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
1363
1360
  /* system commands */
@@ -1418,7 +1415,7 @@ exports.WrittenBuiltinDefinitions = [
1418
1415
  { type: 'replacement', suffixes: ['<-', '<<-'], names: ['$', '@'], config: { readIndices: false, props: built_in_props_1.CallProp.Scope } },
1419
1416
  /* the string and shape functions R declares formals for, restated one by one: the group above gives them
1420
1417
  what they do, this gives them the arguments they do it with (the names are R's own) */
1421
- { overrides: true, type: 'function', names: [identifier_1.Identifier.from(['sprintf', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['fmt', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1418
+ { type: 'function', names: [identifier_1.Identifier.from(['sprintf', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['fmt', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
1422
1419
  { overrides: true, type: 'function', names: [identifier_1.Identifier.from(['format', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { ambient: PrintDispatched, props: built_in_props_1.CallProp.Pure, sig: SigXDots }, assumePrimitive: true },
1423
1420
  { overrides: true, type: 'function', names: [identifier_1.Identifier.from(['grep', "base" /* PkgName.Base */])], processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['pattern', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['value', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['invert', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1424
1421
  { overrides: true, type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['sub', 'gsub']), processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, tags: [built_in_props_1.SemanticCallTag.Edits], sig: [['pattern', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['replacement', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Forced | built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
@@ -35,7 +35,8 @@ function statedBuiltIn(definition, environment) {
35
35
  return undefined;
36
36
  }
37
37
  const [pkg, fn] = pkgFn;
38
- const known = environment_1.REnvironment.findBuiltIn(environment.current).memory.get(fn)
38
+ const builtIn = environment_1.REnvironment.findBuiltIn(environment.current);
39
+ const known = (builtIn.namespaces?.get(pkg)?.get(fn) ?? builtIn.memory.get(fn))
39
40
  ?.filter(d => d.type === identifier_1.ReferenceType.BuiltInFunction && identifier_1.Identifier.getNamespace(d.name ?? '') === pkg);
40
41
  return known?.length ? known : undefined;
41
42
  }