@eagleoutice/flowr 2.13.8 → 2.13.10

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 (152) hide show
  1. package/config.d.ts +50 -2
  2. package/config.js +37 -6
  3. package/dataflow/cluster.js +48 -24
  4. package/dataflow/environments/apply-kill.js +4 -4
  5. package/dataflow/environments/built-in-props.d.ts +28 -4
  6. package/dataflow/environments/built-in-props.js +31 -8
  7. package/dataflow/environments/built-in.d.ts +7 -2
  8. package/dataflow/environments/built-in.js +10 -12
  9. package/dataflow/environments/default-builtin-config.d.ts +76 -6
  10. package/dataflow/environments/default-builtin-config.js +39 -16
  11. package/dataflow/environments/environment.d.ts +16 -0
  12. package/dataflow/environments/environment.js +70 -18
  13. package/dataflow/environments/identifier.d.ts +6 -0
  14. package/dataflow/environments/identifier.js +18 -5
  15. package/dataflow/environments/query-fn-props.js +34 -2
  16. package/dataflow/environments/reference-to-maybe.js +1 -1
  17. package/dataflow/eval/resolve/alias-tracking.js +45 -1
  18. package/dataflow/eval/resolve/resolve-argument.js +25 -17
  19. package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
  20. package/dataflow/eval/resolve/resolve-strings.js +16 -9
  21. package/dataflow/eval/resolve/resolve.js +3 -1
  22. package/dataflow/graph/call-graph.d.ts +7 -0
  23. package/dataflow/graph/call-graph.js +103 -0
  24. package/dataflow/graph/df-helper.d.ts +2 -0
  25. package/dataflow/graph/graph.d.ts +6 -8
  26. package/dataflow/graph/graph.js +21 -6
  27. package/dataflow/internal/linker.d.ts +5 -5
  28. package/dataflow/internal/linker.js +31 -92
  29. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  30. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
  31. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
  32. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  33. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  36. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
  39. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
  40. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
  41. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
  42. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
  43. package/documentation/doc-util/doc-sigdb.d.ts +9 -0
  44. package/documentation/doc-util/doc-sigdb.js +32 -0
  45. package/documentation/wiki-interface.js +13 -2
  46. package/documentation/wiki-query.js +3 -0
  47. package/documentation/wiki-signature-database.js +2 -5
  48. package/gas.d.ts +6 -0
  49. package/gas.js +7 -1
  50. package/package.json +2 -2
  51. package/project/attached-packages.d.ts +13 -0
  52. package/project/attached-packages.js +30 -0
  53. package/project/context/flowr-analyzer-context.d.ts +15 -0
  54. package/project/context/flowr-analyzer-context.js +14 -3
  55. package/project/context/flowr-analyzer-files-context.d.ts +11 -0
  56. package/project/context/flowr-analyzer-files-context.js +3 -0
  57. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
  58. package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
  59. package/project/dependency-version-space.d.ts +45 -8
  60. package/project/dependency-version-space.js +86 -26
  61. package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
  62. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
  63. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
  64. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
  65. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
  66. package/project/plugins/package-version-plugins/package.d.ts +2 -0
  67. package/project/plugins/package-version-plugins/package.js +4 -0
  68. package/project/plugins/plugin-registry.d.ts +2 -1
  69. package/project/plugins/plugin-registry.js +2 -0
  70. package/project/sigdb/manifest.js +9 -5
  71. package/project/sigdb/signature-match.d.ts +5 -18
  72. package/project/sigdb/signature-match.js +5 -18
  73. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +4 -2
  74. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +25 -0
  75. package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
  76. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
  77. package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
  78. package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +11 -1
  79. package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -5
  80. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +27 -1
  81. package/queries/catalog/dependencies-query/dependencies-query-format.js +69 -7
  82. package/queries/catalog/dependencies-query/function-info/library-functions.js +9 -2
  83. package/queries/catalog/dependencies-query/function-info/read-functions.js +31 -5
  84. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
  85. package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
  86. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  87. package/queries/catalog/dependencies-query/function-info/test-functions.js +33 -31
  88. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
  89. package/queries/catalog/dependencies-query/function-info/write-functions.js +28 -5
  90. package/queries/catalog/dependencies-query/link-devices.d.ts +12 -0
  91. package/queries/catalog/dependencies-query/link-devices.js +58 -0
  92. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
  93. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
  94. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +38 -7
  95. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +18 -5
  96. package/queries/catalog/happens-before-query/happens-before-query-format.js +3 -2
  97. package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
  98. package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
  99. package/queries/catalog/input-sources-query/input-types.js +10 -0
  100. package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
  101. package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
  102. package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
  103. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  104. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
  105. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  106. package/queries/query.d.ts +1 -1
  107. package/r-bridge/data/data.d.ts +1 -1
  108. package/r-bridge/data/data.js +1 -1
  109. package/r-bridge/lang-4.x/ast/model/model.d.ts +14 -2
  110. package/r-bridge/lang-4.x/ast/model/model.js +32 -0
  111. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
  112. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +2 -0
  113. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
  114. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
  115. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
  116. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
  117. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
  118. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +7 -8
  119. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
  120. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
  121. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
  122. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
  123. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
  124. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
  125. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
  126. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
  127. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
  128. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
  129. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +2 -0
  130. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
  131. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
  132. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
  133. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
  134. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
  135. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  136. package/search/flowr-search-filters.d.ts +17 -1
  137. package/search/flowr-search-filters.js +23 -0
  138. package/slicing/criterion/parse.d.ts +6 -25
  139. package/slicing/criterion/parse.js +50 -19
  140. package/slicing/static/fingerprint.d.ts +1 -1
  141. package/slicing/static/fingerprint.js +52 -8
  142. package/slicing/static/slicer-types.d.ts +10 -0
  143. package/slicing/static/static-slicer.d.ts +1 -1
  144. package/slicing/static/static-slicer.js +29 -6
  145. package/slicing/static/visiting-queue.d.ts +15 -3
  146. package/slicing/static/visiting-queue.js +37 -3
  147. package/util/arg-matching.d.ts +18 -0
  148. package/util/arg-matching.js +70 -0
  149. package/util/r-regex.js +19 -1
  150. package/util/range.d.ts +7 -8
  151. package/util/range.js +10 -11
  152. package/util/version.js +1 -1
@@ -57,7 +57,8 @@ exports.GraphicsPlotCreate = [
57
57
  exports.PlotCreate = exports.GraphicsPlotCreate.concat(exports.TinyPlotCrate, exports.GgPlotCreate);
58
58
  const GraphicDeviceOpen = [
59
59
  'pdf', 'jpeg', 'png', 'windows', 'postscript', 'xfig', 'bitmap', 'pictex', 'cairo_pdf', 'svg', 'bmp', 'tiff', 'X11', 'quartz', 'image_graph',
60
- 'image_draw', 'dev.new', 'trellis.device', 'raster_pdf', 'agg_pdf'
60
+ 'image_draw', 'dev.new', 'trellis.device', 'raster_pdf',
61
+ 'agg_png', 'agg_jpeg', 'agg_tiff', 'agg_ppm', 'agg_webp', 'agg_capture'
61
62
  ];
62
63
  exports.TinyPlotAddons = [
63
64
  'tinyplot_add', 'plt_add'
@@ -212,12 +213,12 @@ exports.WrittenBuiltinDefinitions = [
212
213
  value: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], assumePrimitive: true },
213
214
  { type: 'constant', names: [identifier_1.Identifier.from(['month.name', "base" /* PkgName.Base */])],
214
215
  value: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], assumePrimitive: true },
215
- /* formula: operands are model terms/columns, not variables (NSE) */
216
+ /* formula: operands are model terms/columns, not variables */
216
217
  {
217
218
  type: 'function',
218
219
  names: [identifier_1.Identifier.from(['~', "base" /* PkgName.Base */])],
219
220
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
220
- config: { markArgsAsNSE: known_call_handling_1.NseArguments.All },
221
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.All },
221
222
  assumePrimitive: false
222
223
  },
223
224
  /* cohortBuilder has a `filter` too, and built-ins go by name, so dplyr's entry below wins in the environment
@@ -229,12 +230,12 @@ exports.WrittenBuiltinDefinitions = [
229
230
  config: { forceArgs: 'all', libFn: true, props: built_in_props_1.CallProp.Pure },
230
231
  assumePrimitive: false
231
232
  },
232
- /* data-masking: the non-data arguments name columns of the (first) data object, not variables (NSE) */
233
+ /* data-masking: the non-data arguments name columns of the (first) data object, not variables */
233
234
  {
234
235
  type: 'function',
235
236
  names: data_masking_functions_1.DataMaskingFunctionIdentifiers,
236
237
  processor: built_in_proc_name_1.BuiltInProcName.Default,
237
- config: { markArgsAsNSE: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure },
238
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Pure },
238
239
  assumePrimitive: false
239
240
  },
240
241
  /* slice_sample draws rows at random; registered after the block above, so this definition is the one that sticks */
@@ -242,7 +243,7 @@ exports.WrittenBuiltinDefinitions = [
242
243
  type: 'function',
243
244
  names: [identifier_1.Identifier.from(['slice_sample', "dplyr" /* PkgName.Dplyr */])],
244
245
  processor: built_in_proc_name_1.BuiltInProcName.Default,
245
- config: { markArgsAsNSE: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Random },
246
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.AllButFirst, props: built_in_props_1.CallProp.Random },
246
247
  assumePrimitive: false
247
248
  },
248
249
  /* data-masking without a data argument, e.g. `aes(x, y)` */
@@ -250,7 +251,7 @@ exports.WrittenBuiltinDefinitions = [
250
251
  type: 'function',
251
252
  names: identifier_1.Identifier.fromAll("ggplot2" /* PkgName.GgPlot2 */, ['aes', 'aes_string', 'vars']),
252
253
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
253
- config: { markArgsAsNSE: known_call_handling_1.NseArguments.All },
254
+ config: { markArgsAsMasked: known_call_handling_1.NseArguments.All },
254
255
  assumePrimitive: false
255
256
  },
256
257
  /* an {@link BuiltInEvalName} marks what the value solver folds; a test checks the names against the handler tables */
@@ -286,6 +287,9 @@ exports.WrittenBuiltinDefinitions = [
286
287
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['...', built_in_props_1.ArgProp.Value], ['sep', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
287
288
  { type: 'function', names: [identifier_1.Identifier.from(['file.path', "base" /* PkgName.Base */])],
288
289
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure, sig: [['...', built_in_props_1.ArgProp.Value], ['fsep', built_in_props_1.ArgProp.Value]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
290
+ /* `here` joins its arguments below the project root, which stays implicit */
291
+ { type: 'function', names: [identifier_1.Identifier.from(['here', "here" /* PkgName.Here */])],
292
+ processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { libFn: true, props: built_in_props_1.CallProp.Pure, sig: [['...', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false, evalHandler: built_in_eval_name_1.BuiltInEvalName.StringFn },
289
293
  /* `x` carries the data, whatever follows only tunes the result */
290
294
  {
291
295
  type: 'function',
@@ -377,7 +381,7 @@ exports.WrittenBuiltinDefinitions = [
377
381
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['which', 'which.max', 'which.min', 'seq_len', 'seq_along']),
378
382
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Pure | built_in_props_1.CallProp.Narrows }, assumePrimitive: true },
379
383
  /* they open a device that writes the plot to the file they are given, under the name each of them uses */
380
- { 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.from(['agg_pdf', "ragg" /* PkgName.Ragg */])],
384
+ { 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'])],
381
385
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs,
382
386
  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 },
383
387
  { type: 'function', names: identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['pdf', 'postscript', 'xfig', 'bitmap', 'pictex']),
@@ -458,8 +462,12 @@ exports.WrittenBuiltinDefinitions = [
458
462
  processor: built_in_proc_name_1.BuiltInProcName.DefaultReadAllArgs, config: { props: built_in_props_1.CallProp.Lang }, assumePrimitive: true },
459
463
  { type: 'function', names: [identifier_1.Identifier.from(['rm', "base" /* PkgName.Base */])],
460
464
  processor: built_in_proc_name_1.BuiltInProcName.Rm, config: { props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope }, assumePrimitive: true },
465
+ /* they read the state they set, so both bits apply */
461
466
  { type: 'function', names: [identifier_1.Identifier.from(['options', "base" /* PkgName.Base */])],
462
- 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.Ambient }, assumePrimitive: false },
467
+ 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.Ambient | built_in_props_1.CallProp.Configures }, assumePrimitive: false },
468
+ /* `Sys.putenv` is defunct in current R, older scripts still use it */
469
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['Sys.setenv', 'Sys.unsetenv', 'Sys.setlocale', 'Sys.putenv', 'Sys.setLanguage']),
470
+ 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 },
463
471
  { type: 'function', names: [identifier_1.Identifier.from(['mapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Mapply', "functools" /* PkgName.Functools */])],
464
472
  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 },
465
473
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['lapply', 'sapply', 'vapply']),
@@ -572,18 +580,18 @@ exports.WrittenBuiltinDefinitions = [
572
580
  processor: built_in_proc_name_1.BuiltInProcName.Default,
573
581
  config: { libFn: true, forceArgs: 'all', hasUnknownSideEffects: LinkToLastPlot, props: built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes, sig: [['image', built_in_props_1.ArgProp.Value], ['path', built_in_props_1.ArgProp.Resource]] },
574
582
  assumePrimitive: true },
575
- { type: 'function', names: [identifier_1.Identifier.from(['dev.off', "grDevices" /* PkgName.GrDevices */])],
583
+ { type: 'function', names: identifier_1.Identifier.fromAll("grDevices" /* PkgName.GrDevices */, ['dev.off', 'graphics.off']),
576
584
  processor: built_in_proc_name_1.BuiltInProcName.Default,
577
- config: { libFn: true, forceArgs: 'all', hasUnknownSideEffects: LinkToLastPlot, props: built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes },
585
+ config: { libFn: true, forceArgs: 'all', hasUnknownSideEffects: LinkToLastPlot, props: built_in_props_1.CallProp.Graphics | built_in_props_1.CallProp.Closes | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Writes },
578
586
  assumePrimitive: true },
579
587
  { type: 'function', names: ['('],
580
588
  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.Alias]] }, assumePrimitive: true, evalHandler: built_in_eval_name_1.BuiltInEvalName.Group },
581
589
  { type: 'function', names: [identifier_1.Identifier.from(['load_all', "pkgload" /* PkgName.PkgLoad */]), identifier_1.Identifier.from(['load_all', "devtools" /* PkgName.Devtools */])],
582
590
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true], props: built_in_props_1.CallProp.Scope }, assumePrimitive: false },
583
591
  { type: 'function', names: [identifier_1.Identifier.from(['setwd', "base" /* PkgName.Base */])],
584
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true], props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Ambient }, assumePrimitive: false },
592
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true], props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Ambient | built_in_props_1.CallProp.Configures }, assumePrimitive: false },
585
593
  { type: 'function', names: [identifier_1.Identifier.from(['set.seed', "base" /* PkgName.Base */])],
586
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true], props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Random }, assumePrimitive: false },
594
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true], props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Random | built_in_props_1.CallProp.Configures }, assumePrimitive: false },
587
595
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['body', 'formals']),
588
596
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: [true], props: built_in_props_1.CallProp.Lang }, assumePrimitive: true },
589
597
  { type: 'function', names: [identifier_1.Identifier.from(['environment', "base" /* PkgName.Base */])],
@@ -990,12 +998,25 @@ exports.WrittenBuiltinDefinitions = [
990
998
  },
991
999
  assumePrimitive: true
992
1000
  },
1001
+ { type: 'function', names: [identifier_1.Identifier.from(['on_load', "rlang" /* PkgName.Rlang */])],
1002
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1003
+ config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['expr', built_in_props_1.ArgProp.Forced], ['env', built_in_props_1.ArgProp.Value], ['ns', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1004
+ { type: 'function', names: [identifier_1.Identifier.from(['on_package_load', "rlang" /* PkgName.Rlang */])],
1005
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1006
+ config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['pkg', built_in_props_1.ArgProp.Value], ['expr', built_in_props_1.ArgProp.Forced], ['env', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
1007
+ { type: 'function', names: [identifier_1.Identifier.from(['run_on_load', "rlang" /* PkgName.Rlang */])],
1008
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1009
+ config: { libFn: true, props: built_in_props_1.CallProp.Invisible | built_in_props_1.CallProp.Scope | built_in_props_1.CallProp.MayPure, sig: [['ns', built_in_props_1.ArgProp.Value]] }, assumePrimitive: false },
993
1010
  /* `parse(text=)` turns text into an expression, with `file=` it reads that file */
994
1011
  { type: 'function', names: [identifier_1.Identifier.from(['parse', "base" /* PkgName.Base */])],
995
1012
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', props: built_in_props_1.CallProp.Pure }, assumePrimitive: false },
996
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['list.files', 'dir']),
1013
+ /* they answer with whatever is on disk when they run */
1014
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['list.files', 'dir', 'list.dirs']),
1015
+ processor: built_in_proc_name_1.BuiltInProcName.Default,
1016
+ config: { forceArgs: 'all', props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads | built_in_props_1.CallProp.Glob, sig: [['path', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
1017
+ { type: 'function', names: [identifier_1.Identifier.from(['Sys.glob', "base" /* PkgName.Base */])],
997
1018
  processor: built_in_proc_name_1.BuiltInProcName.Default,
998
- config: { forceArgs: 'all', props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, sig: [['path', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
1019
+ config: { forceArgs: 'all', props: built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads | built_in_props_1.CallProp.Glob, sig: [['paths', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
999
1020
  /* language objects */
1000
1021
  {
1001
1022
  type: 'function',
@@ -1025,8 +1046,10 @@ exports.WrittenBuiltinDefinitions = [
1025
1046
  processor: built_in_proc_name_1.BuiltInProcName.Default,
1026
1047
  config: { forceArgs: 'all', libFn: true, props: built_in_props_1.CallProp.Ffi | built_in_props_1.CallProp.File | built_in_props_1.CallProp.Reads, sig: [['file', built_in_props_1.ArgProp.Resource]] }, assumePrimitive: false },
1027
1048
  /* ambient state: options, environment variables, the clock, the session itself */
1028
- { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['getOption', 'Sys.getenv', 'Sys.info', 'Sys.getpid', 'getwd', 'getRversion', 'R.Version', 'Sys.time', 'Sys.Date', 'Sys.timezone', 'date', 'proc.time']),
1049
+ { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['getOption', 'Sys.getenv', 'Sys.info', 'Sys.getpid', 'getwd', 'getRversion', 'R.Version', 'Sys.time', 'Sys.Date', 'Sys.timezone', 'date', 'proc.time', 'interactive']),
1029
1050
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', props: built_in_props_1.CallProp.Ambient }, assumePrimitive: false },
1051
+ { type: 'function', names: [identifier_1.Identifier.from(['commandArgs', "base" /* PkgName.Base */])],
1052
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', props: built_in_props_1.CallProp.Ambient | built_in_props_1.CallProp.CommandLine }, assumePrimitive: false },
1030
1053
  /* system commands */
1031
1054
  { type: 'function', names: identifier_1.Identifier.fromAll("base" /* PkgName.Base */, ['system', 'system2', 'pipe', 'shell', 'shell.exec']),
1032
1055
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', props: built_in_props_1.CallProp.Process }, assumePrimitive: false },
@@ -46,6 +46,8 @@ export declare class Environment implements IEnvironment {
46
46
  memory: BuiltInMemory;
47
47
  cache?: Map<Identifier, IdentifierDefinition[]>;
48
48
  builtInEnv?: true;
49
+ /** {@link memory} is shared with a clone; writing needs {@link writableMemory} to unshare it first */
50
+ private sharedMemory?;
49
51
  /** marks the global environment (`.GlobalEnv`); attached packages (see {@link EnvType}) live below it */
50
52
  globalEnv?: true;
51
53
  constructor(parent: Environment, isBuiltInDefault?: true | undefined);
@@ -57,8 +59,18 @@ export declare class Environment implements IEnvironment {
57
59
  setClosureNodeId(nodeId: NodeId): void;
58
60
  /** Provides the closure linked to this environment. */
59
61
  get closure(): NodeId | undefined;
62
+ /**
63
+ * This environment's {@link memory}, ready to be written to. Every in-place write must go through this
64
+ * rather than through {@link memory} directly, as {@link clone} hands the map itself to the clone and only
65
+ * the first writer of either side copies it (copy-on-write).
66
+ */
67
+ get writableMemory(): BuiltInMemory;
60
68
  /**
61
69
  * Create a clone of this environment.
70
+ *
71
+ * The clone shares this environment's {@link memory} until either side writes to it (see
72
+ * {@link writableMemory}); cloning a frame is therefore independent of how many definitions it holds, which
73
+ * matters because attached packages contribute frames with thousands of them.
62
74
  * @param recurseParents - Whether to also clone parent environments
63
75
  */
64
76
  clone(recurseParents: boolean): Environment;
@@ -102,6 +114,8 @@ export declare class Environment implements IEnvironment {
102
114
  }
103
115
  /** Walks up to the global environment (see {@link Environment#globalEnv}), falling back to the last non-builtin env. */
104
116
  declare function findGlobalEnvironment(this: void, env: Environment): Environment;
117
+ /** Walks up to the built-in environment. */
118
+ declare function findBuiltInEnvironment(this: void, env: Environment): Environment;
105
119
  /** The `search()` position directly below the global environment; where R attaches by default. */
106
120
  export declare const DefaultAttachPosition = 2;
107
121
  /** Prefix of a package's entry in R's `search()` list. */
@@ -133,6 +147,8 @@ export declare const REnvironment: {
133
147
  readonly name: "REnvironment";
134
148
  /** Walks up to the global environment (`.GlobalEnv`); see {@link findGlobalEnvironment}. */
135
149
  readonly findGlobal: typeof findGlobalEnvironment;
150
+ /** Walks up to the built-in environment; see {@link findBuiltInEnvironment}. */
151
+ readonly findBuiltIn: typeof findBuiltInEnvironment;
136
152
  /** Attaches a package block at a `search()` position, below the global by default; see {@link attachPackageAt}. */
137
153
  readonly attachAt: typeof attachPackageAt;
138
154
  /** The `search()` position of a named entry; see {@link searchPositionOf}. */
@@ -40,6 +40,8 @@ class Environment {
40
40
  memory;
41
41
  cache;
42
42
  builtInEnv;
43
+ /** {@link memory} is shared with a clone; writing needs {@link writableMemory} to unshare it first */
44
+ sharedMemory;
43
45
  /** marks the global environment (`.GlobalEnv`); attached packages (see {@link EnvType}) live below it */
44
46
  globalEnv;
45
47
  constructor(parent, isBuiltInDefault = undefined) {
@@ -70,8 +72,24 @@ class Environment {
70
72
  get closure() {
71
73
  return this.c;
72
74
  }
75
+ /**
76
+ * This environment's {@link memory}, ready to be written to. Every in-place write must go through this
77
+ * rather than through {@link memory} directly, as {@link clone} hands the map itself to the clone and only
78
+ * the first writer of either side copies it (copy-on-write).
79
+ */
80
+ get writableMemory() {
81
+ if (this.sharedMemory) {
82
+ this.memory = new Map(this.memory);
83
+ this.sharedMemory = undefined;
84
+ }
85
+ return this.memory;
86
+ }
73
87
  /**
74
88
  * Create a clone of this environment.
89
+ *
90
+ * The clone shares this environment's {@link memory} until either side writes to it (see
91
+ * {@link writableMemory}); cloning a frame is therefore independent of how many definitions it holds, which
92
+ * matters because attached packages contribute frames with thousands of them.
75
93
  * @param recurseParents - Whether to also clone parent environments
76
94
  */
77
95
  clone(recurseParents) {
@@ -84,7 +102,8 @@ class Environment {
84
102
  clone.n = this.n;
85
103
  clone.t = this.t;
86
104
  clone.globalEnv = this.globalEnv;
87
- clone.memory = new Map(this.memory);
105
+ clone.memory = this.memory;
106
+ clone.sharedMemory = this.sharedMemory = true;
88
107
  return clone;
89
108
  }
90
109
  /**
@@ -125,21 +144,21 @@ class Environment {
125
144
  }
126
145
  // When there are defined indices, merge the definitions
127
146
  if (definition.cds === undefined) {
128
- this.memory.set(name, [definition]);
147
+ this.writableMemory.set(name, [definition]);
129
148
  }
130
149
  else {
131
150
  const existing = this.memory.get(name);
132
151
  const inGraphDefinition = definition;
133
152
  if (existing !== undefined &&
134
153
  inGraphDefinition.cds === undefined) {
135
- this.memory.set(name, [inGraphDefinition]);
154
+ this.writableMemory.set(name, [inGraphDefinition]);
136
155
  }
137
156
  else if (existing === undefined || definition.cds === undefined) {
138
- this.memory.set(name, [definition]);
157
+ this.writableMemory.set(name, [definition]);
139
158
  }
140
159
  else {
141
160
  /* the array may be shared with clones, so replace instead of push */
142
- this.memory.set(name, [...existing, definition]);
161
+ this.writableMemory.set(name, [...existing, definition]);
143
162
  }
144
163
  }
145
164
  }
@@ -187,13 +206,13 @@ class Environment {
187
206
  let found = false;
188
207
  do {
189
208
  if (current.memory.has(name)) {
190
- current.memory.set(name, [definition]);
209
+ current.writableMemory.set(name, [definition]);
191
210
  found = true;
192
211
  break;
193
212
  }
194
213
  // `<<-` falls back to the global env, never an attached package below it
195
214
  if (current.globalEnv) {
196
- current.memory.set(name, [definition]);
215
+ current.writableMemory.set(name, [definition]);
197
216
  found = true;
198
217
  break;
199
218
  }
@@ -203,7 +222,7 @@ class Environment {
203
222
  } while (!current.builtInEnv);
204
223
  if (!found) {
205
224
  (0, assert_1.guard)(last !== undefined, () => `Could not find global scope for ${name}`);
206
- last.memory.set(name, [definition]);
225
+ last.writableMemory.set(name, [definition]);
207
226
  }
208
227
  return newEnvironment;
209
228
  }
@@ -298,6 +317,16 @@ class Environment {
298
317
  mergePackageBlocks(other) {
299
318
  const [thisLayers, thisBase] = splitLibraryLayers(this);
300
319
  const [otherLayers, otherBase] = splitLibraryLayers(other);
320
+ // Neither branch changed the block, so the union below would rebuild an identical chain -- at the price of a
321
+ // fresh frame per attached package. This is the common case (every statement after a `library` call merges
322
+ // two environments that still hold its layers), so the check pays for itself many times over.
323
+ if (otherLayers.length === 0 || sameLayers(thisLayers, otherLayers)) {
324
+ const base = thisBase.append(otherBase);
325
+ if (base === thisBase) {
326
+ return this;
327
+ }
328
+ return relinkLayers(thisLayers.map(l => l.clone(false)), base);
329
+ }
301
330
  // `other` first so its packages end up nearest global (most recently attached is nearest, cf. R `search()`)
302
331
  const merged = new Map();
303
332
  for (const layers of [otherLayers, thisLayers]) {
@@ -307,21 +336,17 @@ class Environment {
307
336
  if (existing === undefined) {
308
337
  merged.set(key, layer.clone(false));
309
338
  }
310
- else {
339
+ else if (existing.memory !== layer.memory) {
311
340
  for (const [name, value] of layer.memory) {
312
341
  const old = existing.memory.get(name);
313
- existing.memory.set(name, old ? (0, append_1.uniqueMergeValuesInDefinitions)(old, value) : value);
342
+ if (old !== value) {
343
+ existing.writableMemory.set(name, old ? (0, append_1.uniqueMergeValuesInDefinitions)(old, value) : value);
344
+ }
314
345
  }
315
346
  }
316
347
  }
317
348
  }
318
- const uniqueLayers = Array.from(merged.values());
319
- let current = thisBase.append(otherBase);
320
- for (let i = uniqueLayers.length - 1; i >= 0; i--) {
321
- uniqueLayers[i].parent = current;
322
- current = uniqueLayers[i];
323
- }
324
- return current;
349
+ return relinkLayers(Array.from(merged.values()), thisBase.append(otherBase));
325
350
  }
326
351
  remove(id) {
327
352
  if (this.builtInEnv) {
@@ -335,7 +360,7 @@ class Environment {
335
360
  const definition = this.memory.get(name);
336
361
  let cont = true;
337
362
  if (definition !== undefined) {
338
- this.memory.delete(name);
363
+ this.writableMemory.delete(name);
339
364
  this.cache?.delete(name);
340
365
  cont = !definition.every(d => (0, info_1.happensInEveryBranch)(d.cds));
341
366
  }
@@ -381,6 +406,14 @@ function findGlobalEnvironment(env) {
381
406
  }
382
407
  return current;
383
408
  }
409
+ /** Walks up to the built-in environment. */
410
+ function findBuiltInEnvironment(env) {
411
+ let current = env;
412
+ while (!current.builtInEnv) {
413
+ current = current.parent;
414
+ }
415
+ return current;
416
+ }
384
417
  /** The `search()` position directly below the global environment; where R attaches by default. */
385
418
  exports.DefaultAttachPosition = 2;
386
419
  /** Prefix of a package's entry in R's `search()` list. */
@@ -453,6 +486,8 @@ exports.REnvironment = {
453
486
  name: 'REnvironment',
454
487
  /** Walks up to the global environment (`.GlobalEnv`); see {@link findGlobalEnvironment}. */
455
488
  findGlobal: findGlobalEnvironment,
489
+ /** Walks up to the built-in environment; see {@link findBuiltInEnvironment}. */
490
+ findBuiltIn: findBuiltInEnvironment,
456
491
  /** Attaches a package block at a `search()` position, below the global by default; see {@link attachPackageAt}. */
457
492
  attachAt: attachPackageAt,
458
493
  /** The `search()` position of a named entry; see {@link searchPositionOf}. */
@@ -460,6 +495,23 @@ exports.REnvironment = {
460
495
  /** The packages on the search path; see {@link attachedPackagesOf}. */
461
496
  attachedPackages: attachedPackagesOf,
462
497
  };
498
+ /**
499
+ * Whether two package blocks hold the same packages, in the same order, with the same definitions. Frames cloned
500
+ * from one another keep the same {@link Environment#memory} map until one of them is written to (see
501
+ * {@link Environment#clone}), so comparing the maps by identity recognizes untouched blocks without scanning them.
502
+ */
503
+ function sameLayers(a, b) {
504
+ return a.length === b.length && a.every((l, i) => l === b[i] || (l.t === b[i].t && l.n === b[i].n && l.memory === b[i].memory));
505
+ }
506
+ /** Stacks `layers` (top first) on top of `base`, returning the new top of the chain. The layers must not be shared. */
507
+ function relinkLayers(layers, base) {
508
+ let current = base;
509
+ for (let i = layers.length - 1; i >= 0; i--) {
510
+ layers[i].parent = current;
511
+ current = layers[i];
512
+ }
513
+ return current;
514
+ }
463
515
  /** Splits a package block (a contiguous run of attached-package layers, see {@link EnvType}) into its layers and the env below them. */
464
516
  function splitLibraryLayers(env) {
465
517
  const layers = [];
@@ -160,6 +160,7 @@ export declare const enum PkgName {
160
160
  Fs = "fs",
161
161
  Functools = "functools",
162
162
  GgPlot2 = "ggplot2",
163
+ Here = "here",
163
164
  Hmisc = "Hmisc",
164
165
  Import = "import",
165
166
  Inferference = "inferference",
@@ -304,6 +305,11 @@ export interface InGraphIdentifierDefinition extends IdentifierReference {
304
305
  * that the function returns (best-effort: only set when statically detectable).
305
306
  */
306
307
  readonly returnsEnvState?: REnvironmentInformation;
308
+ /**
309
+ * Whether {@link value} names the sequence this identifier iterates over rather than what it holds, as a
310
+ * `for` loop's variable does: it takes one element of that sequence at a time.
311
+ */
312
+ readonly iterated?: boolean;
307
313
  }
308
314
  /**
309
315
  * A narrowed variant of {@link InGraphIdentifierDefinition} that is guaranteed to have a non-undefined `name`.
@@ -85,12 +85,12 @@ exports.Identifier = {
85
85
  * In this scenario, see {@link Identifier.make} instead.
86
86
  */
87
87
  parse(str) {
88
- const internal = str.includes(':::');
89
- const parts = str.split(internal ? ':::' : '::');
90
- if (parts.length === 2) {
91
- return [parts[1], parts[0], internal];
88
+ const at = namespaceSeparatorAt(str);
89
+ if (at < 0) {
90
+ return str;
92
91
  }
93
- return parts[0];
92
+ const internal = str[at + 2] === ':';
93
+ return [str.slice(at + (internal ? 3 : 2)), str.slice(0, at), internal];
94
94
  },
95
95
  /**
96
96
  * Get the name part of the identifier
@@ -257,6 +257,19 @@ exports.Identifier = {
257
257
  return undefined;
258
258
  }
259
259
  };
260
+ /** The index of the `::` separating namespace from name, skipping backtick-quoted spans; `-1` if there is none. */
261
+ function namespaceSeparatorAt(str) {
262
+ let quoted = false;
263
+ for (let i = 0; i < str.length; i++) {
264
+ if (str[i] === '`') {
265
+ quoted = !quoted;
266
+ }
267
+ else if (!quoted && str[i] === ':' && str[i + 1] === ':') {
268
+ return i;
269
+ }
270
+ }
271
+ return -1;
272
+ }
260
273
  /**
261
274
  * Each reference has exactly one reference type, stored as the respective number.
262
275
  * However, when checking, we may want to allow for one of several types,
@@ -6,8 +6,39 @@ exports.inferFnProps = inferFnProps;
6
6
  exports.builtInNames = builtInNames;
7
7
  const built_in_props_1 = require("./built-in-props");
8
8
  const default_builtin_config_1 = require("./default-builtin-config");
9
+ const environment_1 = require("./environment");
9
10
  const identifier_1 = require("./identifier");
11
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
10
12
  const resolve_by_name_1 = require("./resolve-by-name");
13
+ /**
14
+ * What flowR states about the package export `definition` binds, `undefined` if it binds none or if flowR
15
+ * states nothing about it. `library(pkg)` binds every export itself, and that binding hides the built-in layer.
16
+ */
17
+ function statedBuiltIn(definition, environment) {
18
+ const pkgFn = definition.type === identifier_1.ReferenceType.Function ? node_id_1.NodeId.toPkgFn(definition.nodeId) : undefined;
19
+ if (pkgFn === undefined) {
20
+ return undefined;
21
+ }
22
+ const [pkg, fn] = pkgFn;
23
+ const known = environment_1.REnvironment.findBuiltIn(environment.current).memory.get(fn)
24
+ ?.filter(d => d.type === identifier_1.ReferenceType.BuiltInFunction && identifier_1.Identifier.getNamespace(d.name ?? '') === pkg);
25
+ return known?.length ? known : undefined;
26
+ }
27
+ /** `definitions` with every package export replaced by what flowR states about it, the array itself if none is one. */
28
+ function withStatedBuiltIns(definitions, environment) {
29
+ let replaced;
30
+ for (const [at, definition] of definitions.entries()) {
31
+ const stated = statedBuiltIn(definition, environment);
32
+ if (stated === undefined) {
33
+ replaced?.push(definition);
34
+ }
35
+ else {
36
+ replaced ??= definitions.slice(0, at);
37
+ replaced.push(...stated);
38
+ }
39
+ }
40
+ return replaced ?? definitions;
41
+ }
11
42
  function ofDefinitions(definitions) {
12
43
  let sig, props;
13
44
  for (const d of definitions ?? []) {
@@ -30,10 +61,11 @@ function queryFnProps(name, { environment, builtIns, signatures, version }) {
30
61
  let info;
31
62
  if (environment !== undefined) {
32
63
  const resolved = (0, resolve_by_name_1.resolveByName)(name, environment, identifier_1.ReferenceType.Function);
33
- if (resolved?.some(d => d.type !== identifier_1.ReferenceType.BuiltInFunction)) {
64
+ const stated = resolved === undefined ? undefined : withStatedBuiltIns(resolved, environment);
65
+ if (stated?.some(d => d.type !== identifier_1.ReferenceType.BuiltInFunction)) {
34
66
  return undefined;
35
67
  }
36
- info = ofDefinitions(resolved);
68
+ info = ofDefinitions(stated);
37
69
  }
38
70
  else if (builtIns !== undefined) {
39
71
  info = ofDefinitions(builtIns.builtInMemory.get(identifier_1.Identifier.getName(name)));
@@ -55,7 +55,7 @@ function withAppliedCds(definition, defaultCd) {
55
55
  function replaceDefinitions(env, key, toUpdate, defaultCd) {
56
56
  const defs = env.memory.get(key);
57
57
  if (defs?.some(d => toUpdate.has(d))) {
58
- env.memory.set(key, defs.map(d => toUpdate.has(d) ? withAppliedCds(d, defaultCd) : d));
58
+ env.writableMemory.set(key, defs.map(d => toUpdate.has(d) ? withAppliedCds(d, defaultCd) : d));
59
59
  }
60
60
  env.cache?.delete(key);
61
61
  }
@@ -14,6 +14,7 @@ const assert_1 = require("../../../util/assert");
14
14
  const identifier_1 = require("../../environments/identifier");
15
15
  const resolve_by_name_1 = require("../../environments/resolve-by-name");
16
16
  const edge_1 = require("../../graph/edge");
17
+ const r_for_loop_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-for-loop");
17
18
  const unknown_replacement_1 = require("../../graph/unknown-replacement");
18
19
  const unknown_side_effect_1 = require("../../graph/unknown-side-effect");
19
20
  const vertex_1 = require("../../graph/vertex");
@@ -173,6 +174,16 @@ function resolveIdToSingleString(id, info) {
173
174
  const element = resolved?.elements.length === 1 ? resolved.elements[0] : undefined;
174
175
  return element?.type === 'string' && (0, r_value_1.isValue)(element.value) ? element.value.str : undefined;
175
176
  }
177
+ /** the values one element of a sequence may take: a vector contributes its elements, a set what its members do */
178
+ function iteratedElements(value) {
179
+ if (value.type === 'vector' && (0, r_value_1.isValue)(value.elements)) {
180
+ return value.elements.flatMap(iteratedElements);
181
+ }
182
+ else if (value.type === 'set' && (0, r_value_1.isValue)(value.elements)) {
183
+ return value.elements.flatMap(iteratedElements);
184
+ }
185
+ return [value];
186
+ }
176
187
  /**
177
188
  * Please use {@link resolveIdToValue}
178
189
  *
@@ -219,7 +230,13 @@ function trackAliasInEnvironments(identifier, environment, { blocked, idMap, res
219
230
  if ((0, r_value_1.isTop)(value)) {
220
231
  return r_value_1.Top;
221
232
  }
222
- values.add(value);
233
+ /* the sequence is what it runs over, so what the name holds is one of its elements */
234
+ if (def.iterated) {
235
+ iteratedElements(value).forEach(e => values.add(e));
236
+ }
237
+ else {
238
+ values.add(value);
239
+ }
223
240
  }
224
241
  }
225
242
  }
@@ -271,6 +288,27 @@ function isParameterDefault(node, idMap) {
271
288
  return node !== undefined && (node.info.role === "param-v" /* RoleInParent.ParameterDefaultValue */
272
289
  || model_1.RNode.iterateParents(node, idMap).some(p => p.info.role === "param-v" /* RoleInParent.ParameterDefaultValue */));
273
290
  }
291
+ /**
292
+ * The sequence a use of a `for` loop's variable runs over, `undefined` when `id` is no such use. Every
293
+ * definition it reads has to be that variable: once anything else writes the name (`i <- i + 1` in the body),
294
+ * the sequence no longer states what the name holds.
295
+ */
296
+ function iteratedSequence(id, graph, idMap) {
297
+ let sequence;
298
+ for (const [target, edge] of graph.outgoingEdges(id) ?? []) {
299
+ if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads)) {
300
+ continue;
301
+ }
302
+ const definition = idMap.get(target);
303
+ const loop = definition?.info.parent === undefined ? undefined : idMap.get(definition.info.parent);
304
+ if (!r_for_loop_1.RForLoop.is(loop) || loop.variable.info.id !== definition?.info.id
305
+ || (sequence !== undefined && sequence.info.id !== loop.vector.info.id)) {
306
+ return undefined;
307
+ }
308
+ sequence = loop.vector;
309
+ }
310
+ return sequence;
311
+ }
274
312
  /**
275
313
  * Please use {@link resolveIdToValue}
276
314
  *
@@ -288,6 +326,12 @@ function trackAliasesInGraph(id, graph, ctx, idMap, blocked) {
288
326
  }
289
327
  idMap ??= graph.idMap;
290
328
  (0, assert_1.guard)(idMap !== undefined, 'The ID map is required to get the lineage of a node');
329
+ /* a loop makes the walk below give up, yet the variable of a `for` is precisely its sequence, elementwise */
330
+ const sequence = iteratedSequence(id, graph, idMap);
331
+ if (sequence !== undefined) {
332
+ const value = resolveIdToValue(sequence.info.id, { graph, idMap, ctx, blocked });
333
+ return (0, r_value_1.isTop)(value) ? r_value_1.Top : (0, set_constants_1.setFrom)(...iteratedElements(value));
334
+ }
291
335
  const queue = new visiting_queue_1.VisitingQueue(10);
292
336
  const clean = ctx.env.makeCleanEnv();
293
337
  const cleanFingerprint = ctx.env.getCleanEnvFingerprint();