@eagleoutice/flowr 2.13.16 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/README.md +31 -31
  2. package/abstract-interpretation/absint-visitor.js +1 -1
  3. package/abstract-interpretation/data-frame/mappers/access-mapper.js +4 -4
  4. package/abstract-interpretation/data-frame/mappers/arguments.js +7 -4
  5. package/abstract-interpretation/data-frame/mappers/function-mapper.js +18 -17
  6. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +6 -6
  7. package/abstract-interpretation/data-frame/resolve-args.d.ts +9 -4
  8. package/abstract-interpretation/data-frame/resolve-args.js +10 -5
  9. package/benchmark/calibration.d.ts +12 -5
  10. package/benchmark/calibration.js +42 -14
  11. package/benchmark/slicer.d.ts +1 -1
  12. package/benchmark/slicer.js +5 -4
  13. package/benchmark/stats/size-of.js +1 -1
  14. package/benchmark/summarizer/first-phase/process.d.ts +2 -0
  15. package/benchmark/summarizer/first-phase/process.js +2 -0
  16. package/cli/common/options.d.ts +0 -31
  17. package/cli/common/options.js +1 -8
  18. package/cli/common/scripts-info.d.ts +0 -38
  19. package/cli/common/scripts-info.js +0 -8
  20. package/cli/repl/core.js +1 -1
  21. package/cli/repl/parser/slice-query-parser.js +1 -1
  22. package/cli/repl/print-version.js +2 -2
  23. package/config.d.ts +16 -0
  24. package/config.js +79 -0
  25. package/control-flow/extract-cfg.js +1 -1
  26. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  27. package/control-flow/semantic-cfg-guided-visitor.js +1 -1
  28. package/control-flow/useless-loop.js +1 -1
  29. package/core/print/slice-diff-ansi.js +1 -1
  30. package/core/steps/pipeline/create-pipeline.js +1 -1
  31. package/dataflow/cluster.js +2 -2
  32. package/dataflow/environments/built-in-props.d.ts +8 -1
  33. package/dataflow/environments/built-in-props.js +18 -0
  34. package/dataflow/environments/built-in.d.ts +7 -1
  35. package/dataflow/environments/built-in.js +42 -3
  36. package/dataflow/environments/default-builtin-config.d.ts +442 -10
  37. package/dataflow/environments/default-builtin-config.js +188 -18
  38. package/dataflow/environments/environment.d.ts +1 -1
  39. package/dataflow/environments/identifier.d.ts +7 -2
  40. package/dataflow/environments/identifier.js +6 -1
  41. package/dataflow/environments/query-fn-props.js +2 -2
  42. package/dataflow/environments/reference-to-maybe.js +5 -5
  43. package/dataflow/environments/resolve-by-name.d.ts +3 -0
  44. package/dataflow/environments/resolve-by-name.js +30 -5
  45. package/dataflow/environments/resolve-helper.d.ts +6 -0
  46. package/dataflow/environments/resolve-helper.js +6 -0
  47. package/dataflow/eval/resolve/alias-tracking.d.ts +5 -0
  48. package/dataflow/eval/resolve/alias-tracking.js +21 -14
  49. package/dataflow/eval/resolve/node-value.d.ts +6 -0
  50. package/dataflow/eval/resolve/node-value.js +15 -9
  51. package/dataflow/eval/resolve/resolve-argument.js +2 -2
  52. package/dataflow/eval/resolve/resolve-numbers.js +2 -2
  53. package/dataflow/eval/resolve/resolve-operators.js +4 -3
  54. package/dataflow/eval/resolve/resolve-strings.js +3 -3
  55. package/dataflow/eval/resolve/resolve-working-directory.js +2 -1
  56. package/dataflow/eval/resolve/resolve.d.ts +5 -5
  57. package/dataflow/eval/resolve/resolve.js +10 -11
  58. package/dataflow/eval/values/general.d.ts +4 -1
  59. package/dataflow/eval/values/general.js +1 -1
  60. package/dataflow/extractor.js +2 -1
  61. package/dataflow/fn/exceptions-of-function.js +5 -4
  62. package/dataflow/fn/higher-order-function.js +5 -4
  63. package/dataflow/graph/call-graph.js +14 -14
  64. package/dataflow/graph/df-helper.d.ts +15 -0
  65. package/dataflow/graph/df-helper.js +10 -4
  66. package/dataflow/graph/diff-dataflow-graph.js +6 -6
  67. package/dataflow/graph/edge.d.ts +27 -0
  68. package/dataflow/graph/edge.js +33 -0
  69. package/dataflow/graph/graph-helper.d.ts +3 -4
  70. package/dataflow/graph/graph-helper.js +4 -5
  71. package/dataflow/graph/graph.d.ts +11 -1
  72. package/dataflow/graph/graph.js +16 -5
  73. package/dataflow/graph/vertex.d.ts +42 -6
  74. package/dataflow/graph/vertex.js +42 -6
  75. package/dataflow/internal/linker.d.ts +1 -0
  76. package/dataflow/internal/linker.js +11 -9
  77. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  78. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +1 -1
  79. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +6 -5
  80. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +2 -2
  81. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -7
  82. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +7 -6
  83. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -0
  84. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +19 -18
  85. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +6 -1
  86. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
  87. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +2 -2
  88. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
  89. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +5 -5
  90. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +1 -1
  91. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +3 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +3 -3
  93. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
  94. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +3 -3
  96. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +3 -1
  97. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -12
  98. package/dataflow/internal/process/functions/call/common.d.ts +9 -1
  99. package/dataflow/internal/process/functions/call/common.js +17 -6
  100. package/dataflow/internal/process/functions/call/deferred.js +2 -1
  101. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -1
  102. package/dataflow/internal/process/functions/call/known-call-handling.js +6 -3
  103. package/dataflow/internal/process/functions/call/named-call-handling.js +44 -12
  104. package/dataflow/internal/process/functions/call/nse.d.ts +33 -5
  105. package/dataflow/internal/process/functions/call/nse.js +113 -6
  106. package/dataflow/internal/process/functions/call/quoted.d.ts +5 -0
  107. package/dataflow/internal/process/functions/call/quoted.js +21 -9
  108. package/dataflow/origin/dfg-get-origin.d.ts +1 -0
  109. package/dataflow/origin/dfg-get-origin.js +9 -6
  110. package/documentation/data/faq/faqs.js +88 -88
  111. package/documentation/data/faq/recommended-configs.js +1 -1
  112. package/documentation/data/faq/wiki-faq-store.js +1 -1
  113. package/documentation/doc-capabilities.js +1 -1
  114. package/documentation/doc-readme.js +1 -1
  115. package/documentation/doc-util/doc-auto-gen.js +6 -2
  116. package/documentation/doc-util/doc-functions.js +1 -1
  117. package/documentation/wiki-cfg.js +2 -2
  118. package/documentation/wiki-create-linting-rules.js +45 -45
  119. package/documentation/wiki-dataflow-graph.js +17 -18
  120. package/documentation/wiki-linting-and-testing.js +93 -5
  121. package/documentation/wiki-mk/doc-maker.js +1 -1
  122. package/documentation/wiki-overview.js +12 -1
  123. package/documentation/wiki-signature-database.js +3 -0
  124. package/linter/rules/file-path-validity.js +1 -1
  125. package/linter/rules/function-finder-util.js +1 -1
  126. package/linter/rules/naming-convention.js +1 -1
  127. package/linter/rules/no-leaked-credentials.js +2 -1
  128. package/linter/rules/stop-with-call-arg.js +4 -4
  129. package/linter/rules/undefined-symbol-util.d.ts +1 -1
  130. package/linter/rules/undefined-symbol-util.js +5 -4
  131. package/linter/rules/undefined-symbol.js +3 -3
  132. package/linter/rules/unused-definition.js +2 -1
  133. package/package.json +35 -45
  134. package/project/context/flowr-analyzer-environment-context.d.ts +23 -0
  135. package/project/context/flowr-analyzer-environment-context.js +25 -0
  136. package/project/dependency-version-space.js +1 -2
  137. package/project/flowr-analyzer.js +1 -1
  138. package/project/plugins/file-plugins/files/flowr-rda-file.js +3 -3
  139. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +2 -2
  140. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +3 -1
  141. package/project/sigdb/build.js +16 -16
  142. package/project/sigdb/codec.d.ts +1 -1
  143. package/project/sigdb/codec.js +13 -13
  144. package/project/sigdb/decompress.d.ts +1 -1
  145. package/project/sigdb/decompress.js +33 -33
  146. package/project/sigdb/index-format.js +2 -2
  147. package/project/sigdb/manifest.js +21 -21
  148. package/project/sigdb/memory-source.d.ts +64 -0
  149. package/project/sigdb/memory-source.js +133 -0
  150. package/project/sigdb/reader.js +13 -13
  151. package/queries/catalog/call-context-query/call-context-query-executor.js +1 -1
  152. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -2
  153. package/queries/catalog/dependencies-query/dependencies-query-executor.js +2 -2
  154. package/queries/catalog/dependencies-query/dependencies-query-format.js +1 -1
  155. package/queries/catalog/dependencies-query/link-devices.js +2 -2
  156. package/queries/catalog/does-call-query/does-call-query-executor.js +2 -1
  157. package/queries/catalog/input-sources-query/simple-input-classifier.js +4 -4
  158. package/queries/catalog/location-map-query/location-map-query-format.js +1 -1
  159. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
  160. package/queries/catalog/signature-query/signature-query-executor.d.ts +2 -0
  161. package/queries/catalog/signature-query/signature-query-executor.js +3 -2
  162. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +3 -3
  163. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
  164. package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
  165. package/r-bridge/retriever.d.ts +2 -1
  166. package/r-bridge/retriever.js +3 -2
  167. package/r-bridge/roxygen2/documentation-provider.d.ts +1 -0
  168. package/r-bridge/roxygen2/documentation-provider.js +1 -0
  169. package/r-bridge/roxygen2/roxygen-parse.d.ts +1 -1
  170. package/r-bridge/roxygen2/roxygen-parse.js +1 -1
  171. package/search/flowr-search-filters.d.ts +1 -1
  172. package/search/flowr-search-filters.js +2 -2
  173. package/search/search-executor/search-enrichers.js +4 -4
  174. package/search/search-executor/search-generators.js +1 -1
  175. package/slicing/criterion/parse.js +3 -3
  176. package/slicing/static/slice-call.d.ts +1 -1
  177. package/slicing/static/slice-call.js +2 -2
  178. package/slicing/static/static-slicer.js +4 -3
  179. package/util/assert.js +1 -1
  180. package/util/log.d.ts +4 -1
  181. package/util/log.js +15 -2
  182. package/util/logic.js +2 -2
  183. package/util/mermaid/cfg.js +1 -1
  184. package/util/mermaid/dfg.js +6 -6
  185. package/util/mermaid/mermaid.js +3 -1
  186. package/util/quads.js +19 -6
  187. package/util/schema.js +2 -2
  188. package/util/text/ansi.d.ts +2 -0
  189. package/util/text/ansi.js +8 -0
  190. package/util/text/name-rank.d.ts +29 -0
  191. package/util/text/name-rank.js +39 -0
  192. package/util/text/url-encoding.d.ts +15 -0
  193. package/util/text/url-encoding.js +59 -0
  194. package/util/version.js +1 -1
  195. package/cli/export-quads-app.d.ts +0 -7
  196. package/cli/export-quads-app.js +0 -44
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultBuiltinConfig = exports.WrittenBuiltinDefinitions = exports.RGroupGenerics = exports.GgPlotAddons = exports.GraphicsPlotAddons = exports.PlotFunctionsWithAddParam = exports.GgPlotImplicitAddons = exports.TinyPlotAddons = exports.PlotCreate = exports.GraphicsPlotCreate = exports.TinyPlotCrate = exports.GgPlotCreate = exports.PlotFunctionPackages = exports.StackEnvBuiltins = exports.StackEnvKind = void 0;
4
4
  exports.namespacePlotFunctions = namespacePlotFunctions;
5
+ exports.statedSignatures = statedSignatures;
6
+ exports.statedSignatureOf = statedSignatureOf;
5
7
  exports.getDefaultProcessor = getDefaultProcessor;
6
8
  const identify_link_to_last_call_relation_1 = require("../../queries/catalog/call-context-query/identify-link-to-last-call-relation");
7
9
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
@@ -162,13 +164,47 @@ exports.GgPlotAddons = [
162
164
  'ggdraw', 'last_plot'
163
165
  ];
164
166
  const PlotAddons = exports.GraphicsPlotAddons.concat(exports.GgPlotImplicitAddons, ...exports.PlotFunctionsWithAddParam);
165
- /* the argument shapes that repeat below: what the call computes its result from */
166
- const SigBinOp = [['e1', built_in_props_1.ArgProp.Value], ['e2', built_in_props_1.ArgProp.Value]];
167
+ const SigAtomicBinOp = [['e1', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Atomic], ['e2', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Atomic]];
168
+ const SigAtomicX = [['x', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Atomic]];
167
169
  const SigXY = [['x', built_in_props_1.ArgProp.Value], ['y', built_in_props_1.ArgProp.Value]];
168
170
  const SigX = [['x', built_in_props_1.ArgProp.Value]];
171
+ /* `f(x, ...)`, the shape of most of R's summarizing and coercing functions */
172
+ const SigXDots = [['x', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]];
173
+ /* `verb(.data, ...)`, the shape of the tidyverse verbs: the data first, the columns after */
174
+ const SigDataDots = [['.data', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]];
169
175
  const SigShape = [['x', built_in_props_1.ArgProp.Shape]];
170
176
  const SigXTable = [['x', built_in_props_1.ArgProp.Value], ['table', built_in_props_1.ArgProp.Value]];
171
177
  const SigDots = [['...', built_in_props_1.ArgProp.Value]];
178
+ /**
179
+ * What flowR states about every function it carries a definition for, as `name -> signatures`. A name may be
180
+ * defined for several packages (`filter` is dplyr's and cohortBuilder's), so all of them are here and the
181
+ * caller picks by package; {@link statedSignatureOf} does that. The signature browser and the playground both
182
+ * show this next to what a database says, so both read it from here.
183
+ */
184
+ function statedSignatures(definitions = exports.DefaultBuiltinConfig) {
185
+ const stated = new Map();
186
+ for (const definition of definitions) {
187
+ const info = definition.config;
188
+ for (const id of definition.names) {
189
+ const name = String(identifier_1.Identifier.getName(id));
190
+ const pkg = String(identifier_1.Identifier.getNamespace(id) ?? "base" /* PkgName.Base */);
191
+ const declared = (info?.sig ?? []).map(([param]) => param);
192
+ const entry = { pkg, params: declared.length > 0 ? declared.join(', ') : undefined, props: (0, built_in_props_1.callPropWords)(info?.props) };
193
+ const known = stated.get(name) ?? [];
194
+ /* the last definition for a package is the one that resolves, so it is the one stated */
195
+ stated.set(name, [...known.filter(other => other.pkg !== pkg), entry]);
196
+ }
197
+ }
198
+ return stated;
199
+ }
200
+ /**
201
+ * The one of {@link statedSignatures} a reader means: the definition for `pkg` when there is one, else base
202
+ * R's, else whichever came first. `undefined` when flowR states nothing about the name at all.
203
+ */
204
+ function statedSignatureOf(stated, name, pkg) {
205
+ const known = stated.get(name);
206
+ return known?.find(entry => entry.pkg === pkg) ?? known?.find(entry => entry.pkg === "base" /* PkgName.Base */) ?? known?.[0];
207
+ }
172
208
  const RegexConvIn = /[-/\\^$*+?.()|[\]{}]/g;
173
209
  /** Builds a regex from an array of plain names or namespaced {@link Identifier}s, deduplicating by name. */
174
210
  function toRegex(n) {
@@ -313,17 +349,17 @@ exports.WrittenBuiltinDefinitions = [
313
349
  },
314
350
  /* an {@link BuiltInEvalName} marks what the value solver folds; a test checks the names against the handler tables */
315
351
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['+', '-', '*', '/', '^', '**', '%%', '%/%']),
316
- processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigBinOp }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Numeric },
352
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigAtomicBinOp }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Numeric },
317
353
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['==', '!=', '>', '<', '>=', '<=']),
318
- processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigBinOp }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Comparison },
354
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigAtomicBinOp }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Comparison },
319
355
  { type: 'function', names: [identifier_1.Identifier.from(['%*%', "base" /* PkgName.Base */])],
320
356
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigXY }, assumePrimitive: true },
321
357
  { type: 'function', names: [identifier_1.Identifier.from(['%in%', "base" /* PkgName.Base */])],
322
358
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigXTable }, assumePrimitive: true },
323
359
  { type: 'function', names: [identifier_1.Identifier.from([':', "base" /* PkgName.Base */])],
324
- processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['from', built_in_props_1.ArgProp.Value], ['to', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Seq },
360
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['from', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Atomic], ['to', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Atomic]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Seq },
325
361
  { type: 'function', names: [identifier_1.Identifier.from(['!', "base" /* PkgName.Base */])],
326
- processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigX }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
362
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigAtomicX }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Logical },
327
363
  { type: 'function', names: [identifier_1.Identifier.from(['?', "utils" /* PkgName.Utils */])], /* shows the help page of what it is given */
328
364
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { sig: [['e1', built_in_props_1.ArgProp.Nse], ['e2', built_in_props_1.ArgProp.Nse]] }, assumePrimitive: true },
329
365
  /* the result follows from how large the argument is, not from what is in it, so it is bounded (`Narrows`) */
@@ -364,7 +400,7 @@ exports.WrittenBuiltinDefinitions = [
364
400
  ...identifier_1.Identifier.fromAll("stats" /* PkgName.Stats */, ['var', 'sd', 'median', 'quantile']),
365
401
  ],
366
402
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
367
- config: { props: built_in_props_1.CallProp.Pure, sig: SigX },
403
+ config: { props: built_in_props_1.CallProp.Pure, sig: SigXDots },
368
404
  assumePrimitive: true
369
405
  },
370
406
  /* they read the values but answer only with a logical, so nothing those values carry reaches the result */
@@ -388,7 +424,7 @@ exports.WrittenBuiltinDefinitions = [
388
424
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['numeric', 'character', 'logical', 'integer', 'double', 'raw']),
389
425
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['length', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
390
426
  { type: 'function', names: [identifier_1.Identifier.from(['na.omit', "stats" /* PkgName.Stats */])],
391
- processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['object', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
427
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['object', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
392
428
  /* two data arguments, under the names R gives them */
393
429
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['xor', 'crossprod', 'tcrossprod', 'intersect', 'union', 'setdiff']),
394
430
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigXY }, assumePrimitive: true },
@@ -440,16 +476,16 @@ exports.WrittenBuiltinDefinitions = [
440
476
  /* they open a device that writes the plot to the file they are given, under the name each of them uses */
441
477
  { type: 'function', names: [...identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['png', 'jpeg', 'bmp', 'tiff', 'svg', 'cairo_pdf']), identifier_1.Identifier.from(['raster_pdf', "rasterpdf" /* PkgName.RasterPdf */]), ...identifier_1.Identifier.fromAll("ragg" /* PkgName.Ragg */, ['agg_png', 'agg_jpeg', 'agg_tiff', 'agg_ppm', 'agg_webp'])],
442
478
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
443
- config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['filename', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: true },
479
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['filename', built_in_props_1.ArgProp.Resource], ['width', built_in_props_1.ArgProp.Value], ['height', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
444
480
  { type: 'function', names: identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['pdf', 'postscript', 'xfig', 'bitmap', 'pictex']),
445
481
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
446
- config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: true },
482
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['file', built_in_props_1.ArgProp.Resource], ['type', built_in_props_1.ArgProp.Value], ['height', built_in_props_1.ArgProp.Value], ['width', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
447
483
  /* devices that draw on the screen or into memory instead */
448
484
  { type: 'function', names: [...identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['X11', 'windows', 'quartz', 'dev.new']), identifier_1.Identifier.from(['trellis.device', "lattice" /* PkgName.Lattice */]), ...identifier_1.Identifier.fromAll("magick" /* PkgName.Magick */, ['image_graph', 'image_draw'])],
449
485
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Graphics }, assumePrimitive: true },
450
486
  { type: 'function', names: [identifier_1.Identifier.from(['read.csv', "utils" /* PkgName.Utils */])],
451
487
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
452
- config: { props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, sig: [['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: true },
488
+ config: { props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, sig: [['file', built_in_props_1.ArgProp.Resource], ['header', built_in_props_1.ArgProp.Flag], ['sep', built_in_props_1.ArgProp.Value], ['quote', built_in_props_1.ArgProp.Value], ['dec', built_in_props_1.ArgProp.Value], ['fill', built_in_props_1.ArgProp.Flag], ['comment.char', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
453
489
  { type: 'function', names: [identifier_1.Identifier.from(['scan', "base" /* PkgName.Base */])],
454
490
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
455
491
  config: { props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads | built_in_props_1.CallProp.User, sig: [['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
@@ -480,19 +516,22 @@ exports.WrittenBuiltinDefinitions = [
480
516
  config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['object', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
481
517
  { type: 'function', names: [identifier_1.Identifier.from(['save', "base" /* PkgName.Base */])],
482
518
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
483
- config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['...', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
519
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['...', built_in_props_1.ArgProp.Value], ['list', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
484
520
  { type: 'function', names: [identifier_1.Identifier.from(['save.image', "base" /* PkgName.Base */])],
485
521
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
486
522
  config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
487
523
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['dput', 'write']),
488
524
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
489
525
  config: { 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: [['x', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
526
+ { type: 'function', names: [identifier_1.Identifier.from(['write.dcf', "base" /* PkgName.Base */])],
527
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
528
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['x', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
490
529
  { type: 'function', names: [identifier_1.Identifier.from(['write.table', "utils" /* PkgName.Utils */])],
491
530
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
492
531
  config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['x', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
493
532
  { type: 'function', names: identifier_1.Identifier.fromAll("utils" /* PkgName.Utils */, ['write.csv', 'write.csv2']),
494
533
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
495
- config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes }, assumePrimitive: false },
534
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['x', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
496
535
  { type: 'function', names: identifier_1.Identifier.fromAll("utils" /* PkgName.Utils */, ['read.table', 'read.delim', 'read.csv2', 'read.delim2']),
497
536
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
498
537
  config: { props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, sig: [['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
@@ -526,21 +565,28 @@ exports.WrittenBuiltinDefinitions = [
526
565
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Sys.setenv', 'Sys.unsetenv', 'Sys.setlocale', 'Sys.putenv', 'Sys.setLanguage']),
527
566
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: 'all', props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Configures }, assumePrimitive: false },
528
567
  { type: 'function', names: [identifier_1.Identifier.from(['mapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Mapply', "functools" /* PkgName.Functools */])],
529
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['FUN', built_in_props_1.ArgProp.Callee]] }, assumePrimitive: false },
568
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['FUN', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
530
569
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['lapply', 'sapply', 'vapply']),
531
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['X', built_in_props_1.ArgProp.Value], ['FUN', built_in_props_1.ArgProp.Callee]] }, assumePrimitive: false },
570
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['X', built_in_props_1.ArgProp.Value], ['FUN', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
571
+ /* `vapply` takes the shape of the result before its `...`, so naming it keeps the positions honest */
572
+ { type: 'function', names: [identifier_1.Identifier.from(['vapply', "base" /* PkgName.Base */])],
573
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['X', built_in_props_1.ArgProp.Value], ['FUN', built_in_props_1.ArgProp.Callee], ['FUN.VALUE', built_in_props_1.ArgProp.Shape], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
532
574
  { type: 'function', names: identifier_1.Identifier.fromAll("functools" /* PkgName.Functools */, ['Lapply', 'Sapply', 'Vapply']),
533
575
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
534
576
  { type: 'function', names: [...identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['apply', 'tapply']), identifier_1.Identifier.from(['Tapply', "functools" /* PkgName.Functools */])],
535
577
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 2, nameOfFunctionArgument: 'FUN', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
536
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Map', 'Filter', 'Find', 'Position']),
537
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['f', built_in_props_1.ArgProp.Callee]] }, assumePrimitive: false },
578
+ { type: 'function', names: [identifier_1.Identifier.from(['Map', "base" /* PkgName.Base */])],
579
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['f', built_in_props_1.ArgProp.Callee], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
580
+ { type: 'function', names: [identifier_1.Identifier.from(['Filter', "base" /* PkgName.Base */])],
581
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['f', built_in_props_1.ArgProp.Callee], ['x', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
582
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Find', 'Position']),
583
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['f', built_in_props_1.ArgProp.Callee], ['x', built_in_props_1.ArgProp.Value], ['right', built_in_props_1.ArgProp.Flag], ['nomatch', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
538
584
  { type: 'function', names: [identifier_1.Identifier.from(['Reduce', "base" /* PkgName.Base */])],
539
585
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure, sig: [['f', built_in_props_1.ArgProp.Callee]] }, assumePrimitive: false },
540
586
  { type: 'function', names: [identifier_1.Identifier.from(['rapply', "base" /* PkgName.Base */])],
541
587
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'f', unquoteFunction: true, props: built_in_props_1.CallProp.MayPure }, assumePrimitive: false },
542
588
  { type: 'function', names: [identifier_1.Identifier.from(['print', "base" /* PkgName.Base */])],
543
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', keepArgumentOut: true, hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Generic | built_in_props_1.CallProp.Prints, sig: [['x', built_in_props_1.ArgProp.Alias | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
589
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', keepArgumentOut: true, hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Generic | built_in_props_1.CallProp.Prints, sig: [['x', built_in_props_1.ArgProp.Alias | built_in_props_1.ArgProp.Forced], ['...', built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
544
590
  { type: 'function', names: [...identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['message', 'warning']), identifier_1.Identifier.from(['warn', "rlang" /* PkgName.Rlang */]), identifier_1.Identifier.from(['warn', "R.utils" /* PkgName.Rutils */]), identifier_1.Identifier.from(['info', "msgr" /* PkgName.Msgr */])],
545
591
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', keepArgumentOut: true, hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ }, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Prints, sig: [['...', built_in_props_1.ArgProp.Alias | built_in_props_1.ArgProp.Forced]] }, assumePrimitive: false },
546
592
  { type: 'function', names: [identifier_1.Identifier.from(['invisible', "base" /* PkgName.Base */])],
@@ -1217,6 +1263,130 @@ exports.WrittenBuiltinDefinitions = [
1217
1263
  names: ['$', '@'],
1218
1264
  config: { readIndices: false, props: built_in_props_1.CallProp.Scope }
1219
1265
  },
1266
+ /* the string and shape functions R declares formals for, restated one by one: the group above gives them
1267
+ what they do, this gives them the arguments they do it with (the names are R's own) */
1268
+ { type: 'function', names: [identifier_1.Identifier.from(['sprintf', "base" /* PkgName.Base */])],
1269
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['fmt', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1270
+ { type: 'function', names: [identifier_1.Identifier.from(['format', "base" /* PkgName.Base */])],
1271
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: SigXDots }, assumePrimitive: true },
1272
+ { type: 'function', names: [identifier_1.Identifier.from(['grep', "base" /* PkgName.Base */])],
1273
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['pattern', built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Flag], ['value', built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Flag], ['invert', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1274
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['sub', 'gsub']),
1275
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['pattern', built_in_props_1.ArgProp.Value], ['replacement', built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1276
+ { type: 'function', names: [identifier_1.Identifier.from(['substr', "base" /* PkgName.Base */])],
1277
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['start', built_in_props_1.ArgProp.Value], ['stop', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1278
+ { type: 'function', names: [identifier_1.Identifier.from(['substring', "base" /* PkgName.Base */])],
1279
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['text', built_in_props_1.ArgProp.Value], ['first', built_in_props_1.ArgProp.Value], ['last', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1280
+ { type: 'function', names: [identifier_1.Identifier.from(['strsplit', "base" /* PkgName.Base */])],
1281
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['split', built_in_props_1.ArgProp.Value], ['fixed', built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1282
+ { type: 'function', names: [identifier_1.Identifier.from(['trimws', "base" /* PkgName.Base */])],
1283
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['which', built_in_props_1.ArgProp.Flag], ['whitespace', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
1284
+ { type: 'function', names: [identifier_1.Identifier.from(['strtoi', "base" /* PkgName.Base */])],
1285
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['base', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1286
+ { type: 'function', names: [identifier_1.Identifier.from(['matrix', "base" /* PkgName.Base */])],
1287
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['data', built_in_props_1.ArgProp.Value], ['nrow', built_in_props_1.ArgProp.Value], ['ncol', built_in_props_1.ArgProp.Value], ['byrow', built_in_props_1.ArgProp.Flag], ['dimnames', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1288
+ /* the tidyverse verbs, under the names R declares them with. They keep the data mask the group above
1289
+ gives them; what this adds is which argument is the data and what the further ones are called */
1290
+ { type: 'function', names: identifier_1.Identifier.fromAll("dplyr" /* PkgName.Dplyr */, ['mutate', 'transmute', 'select', 'rename']),
1291
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1292
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure, sig: SigDataDots }, assumePrimitive: false },
1293
+ { type: 'function', names: [identifier_1.Identifier.from(['filter', "dplyr" /* PkgName.Dplyr */]), identifier_1.Identifier.from(['slice', "dplyr" /* PkgName.Dplyr */])],
1294
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1295
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1296
+ sig: [...SigDataDots, ['.by', built_in_props_1.ArgProp.Value], ['.preserve', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1297
+ { type: 'function', names: identifier_1.Identifier.fromAll("dplyr" /* PkgName.Dplyr */, ['summarise', 'summarize']),
1298
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1299
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1300
+ sig: [...SigDataDots, ['.by', built_in_props_1.ArgProp.Value], ['.groups', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1301
+ { type: 'function', names: [identifier_1.Identifier.from(['arrange', "dplyr" /* PkgName.Dplyr */])],
1302
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1303
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1304
+ sig: [...SigDataDots, ['.by_group', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1305
+ { type: 'function', names: [identifier_1.Identifier.from(['group_by', "dplyr" /* PkgName.Dplyr */])],
1306
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1307
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1308
+ sig: [...SigDataDots, ['.add', built_in_props_1.ArgProp.Flag], ['.drop', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1309
+ { type: 'function', names: [identifier_1.Identifier.from(['distinct', "dplyr" /* PkgName.Dplyr */])],
1310
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1311
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1312
+ sig: [...SigDataDots, ['.keep_all', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1313
+ { type: 'function', names: [identifier_1.Identifier.from(['relocate', "dplyr" /* PkgName.Dplyr */])],
1314
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1315
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1316
+ sig: [...SigDataDots, ['.before', built_in_props_1.ArgProp.Value], ['.after', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1317
+ { type: 'function', names: [identifier_1.Identifier.from(['count', "dplyr" /* PkgName.Dplyr */])],
1318
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1319
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1320
+ sig: [['x', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value], ['wt', built_in_props_1.ArgProp.Value], ['sort', built_in_props_1.ArgProp.Flag], ['name', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1321
+ { type: 'function', names: [identifier_1.Identifier.from(['pull', "dplyr" /* PkgName.Dplyr */])],
1322
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1323
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1324
+ sig: [['.data', built_in_props_1.ArgProp.Value], ['var', built_in_props_1.ArgProp.Value], ['name', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1325
+ { type: 'function', names: [identifier_1.Identifier.from(['nest', "tidyr" /* PkgName.TidyR */])],
1326
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1327
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure, sig: SigDataDots }, assumePrimitive: false },
1328
+ /* `drop_na` names its first argument `data`, not `.data`, so it gets a line of its own */
1329
+ { type: 'function', names: [identifier_1.Identifier.from(['drop_na', "tidyr" /* PkgName.TidyR */])],
1330
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1331
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure, sig: [['data', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1332
+ { type: 'function', names: [identifier_1.Identifier.from(['pivot_longer', "tidyr" /* PkgName.TidyR */])],
1333
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1334
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1335
+ sig: [['data', built_in_props_1.ArgProp.Value], ['cols', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value], ['names_to', built_in_props_1.ArgProp.Value], ['values_to', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1336
+ { type: 'function', names: [identifier_1.Identifier.from(['pivot_wider', "tidyr" /* PkgName.TidyR */])],
1337
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1338
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1339
+ sig: [['data', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value], ['names_from', built_in_props_1.ArgProp.Value], ['values_from', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1340
+ { type: 'function', names: [identifier_1.Identifier.from(['separate', "tidyr" /* PkgName.TidyR */])],
1341
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1342
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1343
+ sig: [['data', built_in_props_1.ArgProp.Value], ['col', built_in_props_1.ArgProp.Value], ['into', built_in_props_1.ArgProp.Value], ['sep', built_in_props_1.ArgProp.Value], ['remove', built_in_props_1.ArgProp.Flag], ['convert', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1344
+ { type: 'function', names: [identifier_1.Identifier.from(['unite', "tidyr" /* PkgName.TidyR */])],
1345
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1346
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure,
1347
+ sig: [['data', built_in_props_1.ArgProp.Value], ['col', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value], ['sep', built_in_props_1.ArgProp.Value], ['remove', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1348
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['subset', 'transform']),
1349
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1350
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1351
+ /* these share the `f(x, ...)` shape above, but R puts one more formal before the `...`: leaving it out
1352
+ would shift every position after it, so each names its own */
1353
+ { type: 'function', names: [identifier_1.Identifier.from(['sort', "base" /* PkgName.Base */])],
1354
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1355
+ config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['decreasing', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1356
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['unique', 'duplicated']),
1357
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1358
+ config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['incomparables', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1359
+ { type: 'function', names: [identifier_1.Identifier.from(['as.data.frame', "base" /* PkgName.Base */])],
1360
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1361
+ config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['row.names', built_in_props_1.ArgProp.Value], ['optional', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1362
+ { type: 'function', names: [identifier_1.Identifier.from(['median', "stats" /* PkgName.Stats */])],
1363
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1364
+ config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['na.rm', built_in_props_1.ArgProp.Flag], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1365
+ /* the ones the earlier list left short where a reader would notice */
1366
+ { type: 'function', names: [identifier_1.Identifier.from(['nchar', "base" /* PkgName.Base */])],
1367
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1368
+ config: { props: built_in_props_1.CallProp.Pure | built_in_props_1.CallProp.Narrows, sig: [['x', built_in_props_1.ArgProp.Shape], ['type', built_in_props_1.ArgProp.Value], ['allowNA', built_in_props_1.ArgProp.Flag], ['keepNA', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
1369
+ { type: 'function', names: [identifier_1.Identifier.from(['grepl', "base" /* PkgName.Base */])],
1370
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1371
+ config: { props: built_in_props_1.CallProp.Pure, sig: [['pattern', built_in_props_1.ArgProp.Value], ['x', built_in_props_1.ArgProp.Value], ['ignore.case', built_in_props_1.ArgProp.Flag], ['perl', built_in_props_1.ArgProp.Flag], ['fixed', built_in_props_1.ArgProp.Flag], ['useBytes', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1372
+ { type: 'function', names: [identifier_1.Identifier.from(['match', "base" /* PkgName.Base */])],
1373
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1374
+ config: { props: built_in_props_1.CallProp.Pure, sig: [['x', built_in_props_1.ArgProp.Value], ['table', built_in_props_1.ArgProp.Value], ['nomatch', built_in_props_1.ArgProp.Value], ['incomparables', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true },
1375
+ { type: 'function', names: [identifier_1.Identifier.from(['lengths', "base" /* PkgName.Base */])],
1376
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1377
+ config: { props: built_in_props_1.CallProp.Pure | built_in_props_1.CallProp.Narrows, sig: [['x', built_in_props_1.ArgProp.Shape], ['use.names', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: true },
1378
+ { type: 'function', names: [identifier_1.Identifier.from(['readLines', "base" /* PkgName.Base */])],
1379
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1380
+ config: { props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, sig: [['con', built_in_props_1.ArgProp.Resource], ['n', built_in_props_1.ArgProp.Value], ['ok', built_in_props_1.ArgProp.Flag], ['warn', built_in_props_1.ArgProp.Flag], ['encoding', built_in_props_1.ArgProp.Value], ['skipNul', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1381
+ { type: 'function', names: [identifier_1.Identifier.from(['writeLines', "base" /* PkgName.Base */])],
1382
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1383
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['text', built_in_props_1.ArgProp.Value], ['con', built_in_props_1.ArgProp.Resource], ['sep', built_in_props_1.ArgProp.Value], ['useBytes', built_in_props_1.ArgProp.Flag]] }, assumePrimitive: false },
1384
+ { type: 'function', names: [identifier_1.Identifier.from(['write.table', "utils" /* PkgName.Utils */])],
1385
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1386
+ config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['x', built_in_props_1.ArgProp.Value], ['file', built_in_props_1.ArgProp.Resource], ['append', built_in_props_1.ArgProp.Flag], ['quote', built_in_props_1.ArgProp.Flag], ['sep', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1387
+ { type: 'function', names: [identifier_1.Identifier.from(['download.file', "utils" /* PkgName.Utils */])],
1388
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
1389
+ config: { props: built_in_props_1.CallProp.Network | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['url', built_in_props_1.ArgProp.Resource], ['destfile', built_in_props_1.ArgProp.Resource], ['method', built_in_props_1.ArgProp.Value], ['quiet', built_in_props_1.ArgProp.Flag], ['mode', built_in_props_1.ArgProp.Value], ['cacheOK', built_in_props_1.ArgProp.Flag], ['extra', built_in_props_1.ArgProp.Value], ['headers', built_in_props_1.ArgProp.Value], ['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1220
1390
  ];
1221
1391
  /**
1222
1392
  * Contains the built-in definitions recognized by flowR
@@ -166,7 +166,7 @@ export declare const REnvironment: {
166
166
  *
167
167
  * The {@link BuiltIns|BuiltInEnvironment} holds R's built-in functions and constants; during serialization use {@link builtInEnvJsonReplacer} to avoid inlining it.
168
168
  * @see {@link define} - to define a new {@link IdentifierDefinition|identifier definition} within an environment
169
- * @see {@link resolveByName} - to resolve an {@link Identifier|identifier/name} to its {@link IdentifierDefinition|definitions} within an environment
169
+ * @see {@link Resolve.byNameAndType} - to resolve an {@link Identifier|identifier/name} to its {@link IdentifierDefinition|definitions} within an environment
170
170
  * @see {@link makeReferenceMaybe} - to attach control dependencies to a reference
171
171
  * @see {@link pushLocalEnvironment} - to create a new local scope
172
172
  * @see {@link popLocalEnvironment} - to remove the current local scope
@@ -231,7 +231,12 @@ export declare enum ReferenceType {
231
231
  /** Prefix to identify S3 methods, use this, to for example dispatch a call to `f` which will then link to `f.*` */
232
232
  S3MethodPrefix = 256,
233
233
  /** Prefix to identify S7 methods, use this, to for example dispatch a call to `f` which will then link to `f<7>*` */
234
- S7MethodPrefix = 512
234
+ S7MethodPrefix = 512,
235
+ /**
236
+ * Only ever a lookup target, never the type of a definition: everything a value position may see.
237
+ * `id` in `id > 2` names data, so a function `id` in scope is not what the comparison reads.
238
+ */
239
+ NonFunction = 1024
235
240
  }
236
241
  /** Reverse mapping of the reference types so you can get the name from the bitmask (useful for debugging) */
237
242
  export declare const ReferenceTypeReverseMapping: Map<ReferenceType, string>;
@@ -244,7 +249,7 @@ export declare function isReferenceType(t: ReferenceType, target: ReferenceType)
244
249
  * default definition for the assignment operator `<-`).
245
250
  * @see {@link InGraphIdentifierDefinition} - for the definition of an identifier within the graph
246
251
  */
247
- export type InGraphReferenceType = Exclude<ReferenceType, ReferenceType.BuiltInConstant | ReferenceType.BuiltInFunction>;
252
+ export type InGraphReferenceType = Exclude<ReferenceType, ReferenceType.BuiltInConstant | ReferenceType.BuiltInFunction | ReferenceType.NonFunction>;
248
253
  /**
249
254
  * An identifier reference points to a variable like `a` in `b <- a`.
250
255
  * Without any surrounding code, `a` will produce the identifier reference `a`.
@@ -26,7 +26,7 @@ exports.Identifier = {
26
26
  */
27
27
  make(name, namespace, internal = false) {
28
28
  if ((0, strings_1.startAndEndsWith)(name, '`')) {
29
- name = name.substring(1, name.length - 1);
29
+ name = name.slice(1, -1);
30
30
  }
31
31
  if (namespace) {
32
32
  return [name, namespace, internal];
@@ -304,6 +304,11 @@ var ReferenceType;
304
304
  ReferenceType[ReferenceType["S3MethodPrefix"] = 256] = "S3MethodPrefix";
305
305
  /** Prefix to identify S7 methods, use this, to for example dispatch a call to `f` which will then link to `f<7>*` */
306
306
  ReferenceType[ReferenceType["S7MethodPrefix"] = 512] = "S7MethodPrefix";
307
+ /**
308
+ * Only ever a lookup target, never the type of a definition: everything a value position may see.
309
+ * `id` in `id > 2` names data, so a function `id` in scope is not what the comparison reads.
310
+ */
311
+ ReferenceType[ReferenceType["NonFunction"] = 1024] = "NonFunction";
307
312
  })(ReferenceType || (exports.ReferenceType = ReferenceType = {}));
308
313
  /** Reverse mapping of the reference types so you can get the name from the bitmask (useful for debugging) */
309
314
  exports.ReferenceTypeReverseMapping = new Map(Object.entries(ReferenceType).map(([k, v]) => [v, k]));
@@ -9,7 +9,7 @@ const default_builtin_config_1 = require("./default-builtin-config");
9
9
  const environment_1 = require("./environment");
10
10
  const identifier_1 = require("./identifier");
11
11
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
12
- const resolve_by_name_1 = require("./resolve-by-name");
12
+ const resolve_helper_1 = require("./resolve-helper");
13
13
  /**
14
14
  * What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR
15
15
  * states nothing about it. `library(pkg)` binds every export itself, and that binding hides the built-in layer.
@@ -60,7 +60,7 @@ function ofDefinitions(definitions) {
60
60
  function queryFnProps(name, { environment, builtIns, signatures, version }) {
61
61
  let info;
62
62
  if (environment !== undefined) {
63
- const resolved = (0, resolve_by_name_1.resolveByName)(name, environment, identifier_1.ReferenceType.Function);
63
+ const resolved = resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.Function);
64
64
  const stated = resolved === undefined ? undefined : withStatedBuiltIns(resolved, environment);
65
65
  if (stated?.some(d => d.type !== identifier_1.ReferenceType.BuiltInFunction)) {
66
66
  return undefined;
@@ -7,9 +7,9 @@ exports.applyCdsToAllInGraphButConstants = applyCdsToAllInGraphButConstants;
7
7
  exports.applyCdToReferences = applyCdToReferences;
8
8
  const identifier_1 = require("./identifier");
9
9
  const info_1 = require("../info");
10
- const resolve_by_name_1 = require("./resolve-by-name");
11
- const vertex_1 = require("../graph/vertex");
12
10
  const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
11
+ const vertex_1 = require("../graph/vertex");
12
+ const resolve_helper_1 = require("./resolve-helper");
13
13
  /** copy of the definition with the given cds attached, marking it as maybe */
14
14
  function withAppliedCds(definition, defaultCd) {
15
15
  return { ...definition, cds: (0, info_1.withCds)(definition.cds, defaultCd) };
@@ -49,7 +49,7 @@ function applyCdsToDefinitions(environments, name, type, definitions, nodeId, de
49
49
  replaceDefinitions(current, plainName, toUpdate, defaultCd);
50
50
  }
51
51
  else {
52
- for (const key of [...current.memory.keys()]) {
52
+ for (const key of current.memory.keys()) {
53
53
  if (key.startsWith(prefix)) {
54
54
  replaceDefinitions(current, key, toUpdate, defaultCd);
55
55
  }
@@ -65,7 +65,7 @@ function applyCdsToDefinitions(environments, name, type, definitions, nodeId, de
65
65
  */
66
66
  function makeReferenceMaybe(ref, graph, environments, includeDefs, defaultCd = undefined) {
67
67
  if (includeDefs && ref.name) {
68
- const definitions = (0, resolve_by_name_1.resolveByName)(ref.name, environments, ref.type);
68
+ const definitions = resolve_helper_1.Resolve.byNameAndType(ref.name, environments, ref.type);
69
69
  if (definitions && definitions.length > 0) {
70
70
  applyCdsToDefinitions(environments, ref.name, ref.type, definitions, ref.nodeId, defaultCd);
71
71
  }
@@ -104,7 +104,7 @@ function makeAllMaybe(references, graph, environments, includeDefs, applyCds = u
104
104
  */
105
105
  function applyCdsToAllInGraphButConstants(graph, references, cds) {
106
106
  for (const [, v] of graph.vertices(true)) {
107
- if (v.tag === vertex_1.VertexType.Value) {
107
+ if (vertex_1.ValueVertex.is(v)) {
108
108
  continue;
109
109
  }
110
110
  if (v.cds) {
@@ -9,10 +9,12 @@ import { Identifier, type IdentifierDefinition, ReferenceType } from './identifi
9
9
  * @param target - The target (meta) type of the identifier to resolve
10
10
  * @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
11
11
  * if the identifier is undefined in the current scope/with the current environment information.
12
+ * @useInstead {@link Resolve.byNameAndType}
12
13
  */
13
14
  export declare function resolveByName(id: Identifier, environment: REnvironmentInformation, target: ReferenceType): readonly IdentifierDefinition[] | undefined;
14
15
  /**
15
16
  * The more performant version of {@link resolveByName} when the target type is unknown.
17
+ * @useInstead {@link Resolve.byName}
16
18
  */
17
19
  export declare function resolveByNameAnyType(id: Identifier, environment: REnvironmentInformation): IdentifierDefinition[] | undefined;
18
20
  /**
@@ -21,5 +23,6 @@ export declare function resolveByNameAnyType(id: Identifier, environment: REnvir
21
23
  * @param environment - The current environment used for name resolution
22
24
  * @param wantedValue - The built-in constant value to check for
23
25
  * @returns Whether the identifier always, never, or maybe resolves to the given built-in constant value
26
+ * @useInstead {@link Resolve.toBuiltIn}
24
27
  */
25
28
  export declare function resolvesToBuiltInConstant(name: Identifier | undefined, environment: REnvironmentInformation, wantedValue: unknown): Ternary;
@@ -8,6 +8,7 @@ const logic_1 = require("../../util/logic");
8
8
  const identifier_1 = require("./identifier");
9
9
  const info_1 = require("../info");
10
10
  const built_in_s_seven_dispatch_1 = require("../internal/process/functions/call/built-in/built-in-s-seven-dispatch");
11
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
11
12
  /** A namespaced lookup only sees its matching layer; a bare lookup skips loaded-but-unattached namespaces (`requireNamespace`). */
12
13
  function layerSkipped(layer, ns) {
13
14
  if (ns !== undefined) {
@@ -20,6 +21,8 @@ const VariableTargetTypes = identifier_1.ReferenceType.Variable | identifier_1.R
20
21
  const ConstantTargetTypes = identifier_1.ReferenceType.Constant | identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.Unknown;
21
22
  const BuiltInConstantTargetTypes = identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.Unknown;
22
23
  const BuiltInFunctionTargetTypes = identifier_1.ReferenceType.BuiltInFunction | identifier_1.ReferenceType.Unknown;
24
+ const NonFunctionTargetTypes = identifier_1.ReferenceType.Variable | identifier_1.ReferenceType.Parameter | identifier_1.ReferenceType.Argument | identifier_1.ReferenceType.Unknown
25
+ | identifier_1.ReferenceType.Constant | identifier_1.ReferenceType.BuiltInConstant;
23
26
  const inEveryBranch = (d) => (0, info_1.happensInEveryBranch)(d.cds);
24
27
  const notAParameter = (d) => d.type !== identifier_1.ReferenceType.Parameter;
25
28
  const TargetTypePredicate = {
@@ -33,7 +36,20 @@ const TargetTypePredicate = {
33
36
  [identifier_1.ReferenceType.BuiltInFunction]: ({ type }) => (0, identifier_1.isReferenceType)(type, BuiltInFunctionTargetTypes),
34
37
  [identifier_1.ReferenceType.S3MethodPrefix]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
35
38
  [identifier_1.ReferenceType.S7MethodPrefix]: ({ type }) => (0, identifier_1.isReferenceType)(type, FunctionTargetTypes),
39
+ [identifier_1.ReferenceType.NonFunction]: ({ type }) => (0, identifier_1.isReferenceType)(type, NonFunctionTargetTypes),
36
40
  };
41
+ /**
42
+ * What the script itself defines under `id`, ignoring everything flowR carries or a database attached.
43
+ * This is the fallback of a value position ({@link ReferenceType.NonFunction}), and the two halves answer
44
+ * the two ways a value position meets a function of its name. In a project that attaches packages,
45
+ * `library(dplyr)` puts a function `id` in scope, and `filter(df, id > 2)` means the column, never that
46
+ * function. A script writing `x <- function() 1` and then `x > 2` has only that one `x` to mean, wrong as
47
+ * the comparison is, so the read stays: dropping it would leave the definition looking unused.
48
+ */
49
+ function ownDefinitions(id, environment) {
50
+ const own = resolveByNameAnyType(id, environment)?.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId));
51
+ return own !== undefined && own.length > 0 ? own : undefined;
52
+ }
37
53
  /**
38
54
  * Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
39
55
  * If the type you want to reference is unknown, please use {@link resolveByNameAnyType} instead.
@@ -42,11 +58,17 @@ const TargetTypePredicate = {
42
58
  * @param target - The target (meta) type of the identifier to resolve
43
59
  * @returns A list of possible identifier definitions (one if the definition location is exactly and always known), or `undefined`
44
60
  * if the identifier is undefined in the current scope/with the current environment information.
61
+ * @useInstead {@link Resolve.byNameAndType}
45
62
  */
46
63
  function resolveByName(id, environment, target) {
47
64
  if (target === identifier_1.ReferenceType.Unknown) {
48
65
  return resolveByNameAnyType(id, environment);
49
66
  }
67
+ const found = resolveByTargetType(id, environment, target);
68
+ return found === undefined && target === identifier_1.ReferenceType.NonFunction ? ownDefinitions(id, environment) : found;
69
+ }
70
+ /** {@link resolveByName} without its two special targets, i.e. the plain walk up the environments. */
71
+ function resolveByTargetType(id, environment, target) {
50
72
  /* read piecewise, `Identifier.toArray` would allocate a tuple per resolution */
51
73
  const name = identifier_1.Identifier.getName(id);
52
74
  const ns = identifier_1.Identifier.getNamespace(id);
@@ -98,16 +120,18 @@ function resolveByName(id, environment, target) {
98
120
  }
99
121
  current = current.parent;
100
122
  } while (!current.builtInEnv);
101
- const builtIns = current.memory.get(name);
123
+ /* the built-in layer is handed over as it is, except to a value position: `filter(df, c > 2)` means the
124
+ column `c`, never `base::c`, and only with nothing left does `ownDefinitions` have its say */
125
+ const known = current.memory.get(name);
126
+ const builtIns = target === identifier_1.ReferenceType.NonFunction ? known?.filter(wantedType) : known;
102
127
  if (definitions) {
103
- return builtIns === undefined ? definitions : definitions.concat(builtIns);
104
- }
105
- else {
106
- return builtIns;
128
+ return builtIns === undefined || builtIns.length === 0 ? definitions : definitions.concat(builtIns);
107
129
  }
130
+ return builtIns === undefined || builtIns.length > 0 ? builtIns : undefined;
108
131
  }
109
132
  /**
110
133
  * The more performant version of {@link resolveByName} when the target type is unknown.
134
+ * @useInstead {@link Resolve.byName}
111
135
  */
112
136
  function resolveByNameAnyType(id, environment) {
113
137
  let current = environment.current;
@@ -180,6 +204,7 @@ function resolveByNameAnyType(id, environment) {
180
204
  * @param environment - The current environment used for name resolution
181
205
  * @param wantedValue - The built-in constant value to check for
182
206
  * @returns Whether the identifier always, never, or maybe resolves to the given built-in constant value
207
+ * @useInstead {@link Resolve.toBuiltIn}
183
208
  */
184
209
  function resolvesToBuiltInConstant(name, environment, wantedValue) {
185
210
  if (name === undefined) {
@@ -12,6 +12,12 @@ import { resolveIdToArgName, resolveIdToArgStringVector, resolveIdToArgValue, re
12
12
  * - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
13
13
  * Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
14
14
  * - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
15
+ * @example
16
+ * ```ts
17
+ * Resolve.byName('x', environment); // every definition `x` may refer to
18
+ * Resolve.toValue(id, { graph, ctx }); // the value(s) the node may hold
19
+ * Resolve.argument.value(call, 'file', ...); // the value of a named argument
20
+ * ```
15
21
  */
16
22
  export declare const Resolve: {
17
23
  readonly name: "Resolve";
@@ -15,6 +15,12 @@ const resolve_args_1 = require("../../abstract-interpretation/data-frame/resolve
15
15
  * - {@link Resolve.byNameAndType} additionally filters and merges the definitions of every layer it passes.
16
16
  * Given the unknown reference type it only forwards to {@link Resolve.byName}, so ask that one directly instead.
17
17
  * - {@link Resolve.toValue} and the {@link Resolve.argument} family run the evaluator on top of a resolution.
18
+ * @example
19
+ * ```ts
20
+ * Resolve.byName('x', environment); // every definition `x` may refer to
21
+ * Resolve.toValue(id, { graph, ctx }); // the value(s) the node may hold
22
+ * Resolve.argument.value(call, 'file', ...); // the value of a named argument
23
+ * ```
18
24
  */
19
25
  exports.Resolve = {
20
26
  name: 'Resolve',