@eagleoutice/flowr 2.13.2 → 2.13.4

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 (146) hide show
  1. package/README.md +45 -43
  2. package/abstract-interpretation/absint-visitor.js +2 -2
  3. package/abstract-interpretation/data-frame/mappers/access-mapper.js +1 -0
  4. package/abstract-interpretation/data-frame/mappers/arguments.js +2 -2
  5. package/abstract-interpretation/data-frame/mappers/function-mapper.d.ts +1 -1
  6. package/abstract-interpretation/data-frame/mappers/function-mapper.js +3 -0
  7. package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +1 -1
  8. package/abstract-interpretation/domains/state-domain-like.d.ts +1 -1
  9. package/abstract-interpretation/unsupported-functions.js +1 -1
  10. package/config.d.ts +8 -0
  11. package/config.js +9 -1
  12. package/control-flow/cfg-dead-code.js +72 -11
  13. package/control-flow/control-flow-graph.js +2 -1
  14. package/control-flow/extract-cfg.js +85 -8
  15. package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
  16. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  17. package/core/steps/all/core/11-normalize-tree-sitter.d.ts +1 -1
  18. package/dataflow/environments/append.d.ts +1 -1
  19. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  20. package/dataflow/environments/built-in-proc-name.js +4 -0
  21. package/dataflow/environments/built-in.d.ts +5 -1
  22. package/dataflow/environments/built-in.js +5 -1
  23. package/dataflow/environments/clone.d.ts +1 -1
  24. package/dataflow/environments/default-builtin-config.d.ts +59 -4
  25. package/dataflow/environments/default-builtin-config.js +23 -11
  26. package/dataflow/environments/environment.d.ts +28 -4
  27. package/dataflow/environments/environment.js +66 -11
  28. package/dataflow/environments/identifier.d.ts +1 -0
  29. package/dataflow/environments/overwrite.d.ts +1 -1
  30. package/dataflow/eval/resolve/alias-tracking.d.ts +3 -1
  31. package/dataflow/eval/resolve/alias-tracking.js +8 -1
  32. package/dataflow/eval/resolve/resolve.d.ts +14 -0
  33. package/dataflow/eval/resolve/resolve.js +47 -0
  34. package/dataflow/fn/higher-order-function.js +3 -3
  35. package/dataflow/fn/recursive-function.js +1 -1
  36. package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
  37. package/dataflow/graph/df-helper.js +1 -1
  38. package/dataflow/graph/vertex.d.ts +32 -25
  39. package/dataflow/graph/vertex.js +40 -36
  40. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
  41. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +7 -4
  42. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +14 -0
  43. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +28 -29
  44. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  45. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +41 -48
  46. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +1 -1
  47. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.d.ts +14 -0
  48. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +45 -0
  49. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +14 -1
  50. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +80 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
  52. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +63 -3
  53. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +1 -1
  54. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +63 -16
  55. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +29 -9
  56. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +5 -2
  57. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +15 -9
  58. package/dataflow/internal/process/functions/call/built-in/built-in-list.d.ts +4 -0
  59. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +35 -0
  60. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -2
  61. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +1 -1
  62. package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +1 -1
  63. package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.d.ts +1 -1
  64. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.d.ts +1 -1
  65. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +9 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +55 -2
  67. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
  68. package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +5 -3
  69. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +1 -1
  70. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +24 -0
  71. package/dataflow/internal/process/functions/process-parameter.js +2 -1
  72. package/documentation/doc-readme.js +14 -12
  73. package/documentation/doc-util/doc-normalized-ast.d.ts +1 -1
  74. package/documentation/wiki-dataflow-graph.js +4 -24
  75. package/documentation/wiki-query.js +47 -0
  76. package/documentation/wiki-signature-database.js +3 -2
  77. package/linter/rules/absolute-path.js +1 -1
  78. package/linter/rules/dataframe-access-validation.d.ts +1 -1
  79. package/linter/rules/function-finder-util.js +1 -1
  80. package/linter/rules/no-leaked-credentials.js +1 -1
  81. package/linter/rules/undefined-symbol-util.js +3 -1
  82. package/linter/rules/undefined-symbol.js +4 -5
  83. package/linter/rules/unused-definition.js +15 -10
  84. package/linter/rules/useless-loop.js +1 -1
  85. package/package.json +21 -9
  86. package/project/context/flowr-analyzer-context.d.ts +4 -4
  87. package/project/context/flowr-analyzer-context.js +3 -3
  88. package/project/context/flowr-analyzer-dependencies-context.d.ts +11 -5
  89. package/project/context/flowr-analyzer-dependencies-context.js +8 -3
  90. package/project/context/flowr-analyzer-meta-context.d.ts +1 -0
  91. package/project/dependency-version-space.d.ts +118 -26
  92. package/project/dependency-version-space.js +343 -87
  93. package/project/plugins/file-plugins/files/flowr-description-file.d.ts +4 -0
  94. package/project/plugins/file-plugins/files/flowr-description-file.js +8 -1
  95. package/project/plugins/file-plugins/files/flowr-rda-file.js +27 -25
  96. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +1 -1
  97. package/project/plugins/file-plugins/notebooks/flowr-analyzer-sweave-file-plugin.d.ts +1 -1
  98. package/project/plugins/package-version-plugins/flowr-analyzer-meta-description-file-plugin.js +2 -1
  99. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
  100. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -4
  101. package/project/plugins/package-version-plugins/package.d.ts +27 -10
  102. package/project/plugins/package-version-plugins/package.js +50 -25
  103. package/project/sigdb/reader.d.ts +26 -16
  104. package/project/sigdb/reader.js +52 -21
  105. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  106. package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -1
  107. package/queries/catalog/dependencies-query/dependencies-query-executor.js +1 -1
  108. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -2
  109. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -2
  110. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  111. package/queries/catalog/dependencies-query/function-info/write-functions.js +23 -24
  112. package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
  113. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +39 -77
  114. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +12 -0
  115. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +53 -23
  116. package/queries/catalog/input-sources-query/input-source-functions.d.ts +14 -0
  117. package/queries/catalog/input-sources-query/input-source-functions.js +109 -20
  118. package/queries/catalog/input-sources-query/input-sources-query-executor.js +45 -4
  119. package/queries/catalog/input-sources-query/input-sources-query-format.js +22 -3
  120. package/queries/catalog/input-sources-query/input-types.d.ts +58 -0
  121. package/queries/catalog/input-sources-query/input-types.js +64 -0
  122. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +76 -53
  123. package/queries/catalog/input-sources-query/simple-input-classifier.js +358 -101
  124. package/queries/catalog/project-query/project-query-executor.js +1 -1
  125. package/queries/catalog/signature-query/signature-query-executor.d.ts +7 -1
  126. package/queries/catalog/signature-query/signature-query-executor.js +112 -39
  127. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -1
  128. package/queries/catalog/signature-query/signature-query-format.js +1 -1
  129. package/queries/catalog/signature-query/signature-query-render.js +8 -3
  130. package/r-bridge/data/data.d.ts +2 -2
  131. package/r-bridge/data/data.js +2 -2
  132. package/r-bridge/lang-4.x/ast/parser/json/format.js +1 -1
  133. package/r-bridge/retriever.d.ts +1 -1
  134. package/reconstruct/inline/source-inline-map.js +1 -1
  135. package/search/flowr-search-printer.js +10 -8
  136. package/slicing/static/static-slicer.d.ts +2 -2
  137. package/util/mermaid/dfg.js +1 -1
  138. package/util/objects.js +6 -4
  139. package/util/r-base-packages.d.ts +2 -0
  140. package/util/r-base-packages.js +3 -0
  141. package/util/r-license.js +1 -4
  142. package/util/r-version.d.ts +12 -0
  143. package/util/r-version.js +16 -0
  144. package/util/range.d.ts +6 -2
  145. package/util/range.js +33 -15
  146. package/util/version.js +1 -1
@@ -13,6 +13,7 @@ const vertex_1 = require("../dataflow/graph/vertex");
13
13
  const control_flow_graph_1 = require("./control-flow-graph");
14
14
  const cfg_simplification_1 = require("./cfg-simplification");
15
15
  const assert_1 = require("../util/assert");
16
+ const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
16
17
  const stateful_fold_1 = require("../r-bridge/lang-4.x/ast/model/processing/stateful-fold");
17
18
  const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
18
19
  const built_in_proc_name_1 = require("../dataflow/environments/built-in-proc-name");
@@ -99,7 +100,7 @@ function getCallsInCfg(cfg, graph) {
99
100
  const calls = new Map();
100
101
  for (const vertexId of cfg.graph.vertices().keys()) {
101
102
  const vertex = graph.getVertex(vertexId);
102
- if ((0, vertex_1.isFunctionCallVertex)(vertex)) {
103
+ if (vertex_1.FunctionCallVertex.is(vertex)) {
103
104
  calls.set(vertexId, vertex);
104
105
  }
105
106
  }
@@ -333,10 +334,6 @@ function cfgFunctionDefinition(fn, params, body) {
333
334
  return { graph: graph, breaks: [], nexts: [], returns: [], exitPoints: [fnId], entryPoints: [fnId] };
334
335
  }
335
336
  function cfgFunctionCall(call, name, args, down) {
336
- if (call.named && call.functionName.content === 'ifelse' && args.length > 1) {
337
- // special built-in handling for ifelse as it is an expression that does not short-circuit
338
- return cfgIfThenElse(call, args[0] === r_function_call_1.EmptyArgument ? (0, control_flow_graph_1.emptyControlFlowInformation)() : args[0], args[1] === r_function_call_1.EmptyArgument ? (0, control_flow_graph_1.emptyControlFlowInformation)() : args[1], args[2] === r_function_call_1.EmptyArgument ? (0, control_flow_graph_1.emptyControlFlowInformation)() : args[2]);
339
- }
340
337
  const callId = call.info.id;
341
338
  const graph = name.graph;
342
339
  const info = {
@@ -380,6 +377,72 @@ function cfgFunctionCall(call, name, args, down) {
380
377
  // should not contain any breaks, nexts, or returns, (except for the body if something like 'break()')
381
378
  return info;
382
379
  }
380
+ function cfgSwitch(call, name, args) {
381
+ const callId = call.info.id;
382
+ const exitId = control_flow_graph_1.CfgVertex.toExitId(callId);
383
+ const graph = name.graph;
384
+ const info = {
385
+ graph,
386
+ breaks: Array.from(name.breaks),
387
+ nexts: Array.from(name.nexts),
388
+ returns: Array.from(name.returns),
389
+ exitPoints: [exitId],
390
+ entryPoints: [callId]
391
+ };
392
+ graph.addVertex(control_flow_graph_1.CfgVertex.makeExprOrStm(callId, identifyMayStatementType(call), { mid: name.exitPoints, end: [exitId] }));
393
+ graph.addVertex(control_flow_graph_1.CfgVertex.makeExitMarker(callId));
394
+ for (const entry of name.entryPoints) {
395
+ graph.addEdge(entry, callId, control_flow_graph_1.CfgEdge.makeFd());
396
+ }
397
+ let selectorExits = name.exitPoints;
398
+ const selector = args[0];
399
+ if (selector !== undefined && selector !== r_function_call_1.EmptyArgument) {
400
+ graph.mergeWith(selector.graph);
401
+ info.breaks = info.breaks.concat(selector.breaks);
402
+ info.nexts = info.nexts.concat(selector.nexts);
403
+ info.returns = info.returns.concat(selector.returns);
404
+ for (const entry of selector.entryPoints) {
405
+ for (const exit of name.exitPoints) {
406
+ graph.addEdge(entry, exit, control_flow_graph_1.CfgEdge.makeFd());
407
+ }
408
+ }
409
+ selectorExits = selector.exitPoints;
410
+ }
411
+ const cd = control_flow_graph_1.CfgEdge.makeCdTrue(callId);
412
+ for (const arm of args.slice(1)) {
413
+ if (arm === r_function_call_1.EmptyArgument) {
414
+ continue;
415
+ }
416
+ graph.mergeWith(arm.graph);
417
+ info.breaks = info.breaks.concat(arm.breaks);
418
+ info.nexts = info.nexts.concat(arm.nexts);
419
+ info.returns = info.returns.concat(arm.returns);
420
+ for (const entry of arm.entryPoints) {
421
+ for (const exit of selectorExits) {
422
+ graph.addEdge(entry, exit, cd);
423
+ }
424
+ }
425
+ for (const exit of arm.exitPoints) {
426
+ graph.addEdge(exitId, exit, control_flow_graph_1.CfgEdge.makeFd());
427
+ }
428
+ }
429
+ const hasDefault = call.arguments.slice(1).some(a => a !== r_function_call_1.EmptyArgument && a.name === undefined);
430
+ if (!hasDefault) {
431
+ for (const exit of selectorExits) {
432
+ graph.addEdge(exitId, exit, control_flow_graph_1.CfgEdge.makeCdFalse(callId));
433
+ }
434
+ }
435
+ return info;
436
+ }
437
+ // on.exit defers its expr, so seal a return/break/next inside it from escaping into enclosing control flow
438
+ function cfgRegisterHook(call, name, args, down) {
439
+ const base = cfgFunctionCall(call, name, args, down);
440
+ const exitId = control_flow_graph_1.CfgVertex.toExitId(call.info.id);
441
+ for (const escape of base.returns.concat(base.breaks, base.nexts)) {
442
+ base.graph.addEdge(exitId, escape, control_flow_graph_1.CfgEdge.makeFd());
443
+ }
444
+ return { ...base, returns: [], breaks: [], nexts: [], exitPoints: base.exitPoints.length > 0 ? base.exitPoints : [exitId] };
445
+ }
383
446
  exports.ResolvedCallSuffix = control_flow_graph_1.CfgVertex.toExitId('-resolved-call');
384
447
  const OriginToFoldTypeMap = {
385
448
  [built_in_proc_name_1.BuiltInProcName.IfThenElse]: (folds, call, args, down) => {
@@ -392,10 +455,18 @@ function cfgFunctionCallWithDataflow(graph, folds) {
392
455
  return (call, name, args, down) => {
393
456
  const vtx = graph.getVertex(call.info.id);
394
457
  if (vtx?.tag === vertex_1.VertexType.FunctionCall && vtx.onlyBuiltin && vtx.origin.length === 1) {
395
- const mayMap = OriginToFoldTypeMap[vtx.origin[0]];
396
- if (mayMap) {
458
+ const origin = vtx.origin[0];
459
+ const mayMap = OriginToFoldTypeMap[origin];
460
+ // ifelse/fifelse/if_else share the IfThenElse origin but are eager calls, so only fold a real `if` node
461
+ if (mayMap && call.type === type_1.RType.IfThenElse) {
397
462
  return mayMap(folds, call, args, down, vtx);
398
463
  }
464
+ if (origin === built_in_proc_name_1.BuiltInProcName.Switch) {
465
+ return cfgSwitch(call, name, args);
466
+ }
467
+ if (origin === built_in_proc_name_1.BuiltInProcName.RegisterHook) {
468
+ return cfgRegisterHook(call, name, args, down);
469
+ }
399
470
  }
400
471
  const baseCfg = cfgFunctionCall(call, name, args, down);
401
472
  /* try to resolve the call and link the target definitions */
@@ -405,7 +476,7 @@ function cfgFunctionCallWithDataflow(graph, folds) {
405
476
  (0, assert_1.guard)(callVertex !== undefined, 'cfgFunctionCallWithDataflow: call vertex not found');
406
477
  for (const target of targets) {
407
478
  // we have to filter out non-func-call targets as the call targets contains names and call ids
408
- if ((0, vertex_1.isFunctionDefinitionVertex)(graph.getVertex(target))) {
479
+ if (vertex_1.FunctionDefinitionVertex.is(graph.getVertex(target))) {
409
480
  const ct = control_flow_graph_1.CfgVertex.getCallTargets(callVertex);
410
481
  if (!ct) {
411
482
  control_flow_graph_1.CfgVertex.setCallTargets(callVertex, new Set([target]));
@@ -485,6 +556,12 @@ function cfgBinaryOp(binOp, lhs, rhs) {
485
556
  for (const exitPoint of rhs.exitPoints) {
486
557
  graph.addEdge(binExit, exitPoint, fd);
487
558
  }
559
+ // `&&`/`||` short-circuit: the exit stays reachable via the lhs even when the rhs jumps
560
+ if (binOp.type === type_1.RType.BinaryOp && (binOp.operator === '&&' || binOp.operator === '||')) {
561
+ for (const exitPoint of lhs.exitPoints) {
562
+ graph.addEdge(binExit, exitPoint, fd);
563
+ }
564
+ }
488
565
  return result;
489
566
  }
490
567
  function cfgAccess(access, name, accessors) {
@@ -3,7 +3,7 @@ import { DataflowAwareCfgGuidedVisitor, type DataflowCfgGuidedVisitorConfigurati
3
3
  import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { SyntaxCfgGuidedVisitorConfiguration } from './syntax-cfg-guided-visitor';
5
5
  import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
6
- import { type Origin } from '../dataflow/origin/dfg-get-origin';
6
+ import type { Origin } from '../dataflow/origin/dfg-get-origin';
7
7
  import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition, DataflowGraphVertexUse, DataflowGraphVertexValue, DataflowGraphVertexVariableDefinition } from '../dataflow/graph/vertex';
8
8
  import type { RString } from '../r-bridge/lang-4.x/ast/model/nodes/r-string';
9
9
  import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
@@ -263,7 +263,9 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
263
263
  case built_in_proc_name_1.BuiltInProcName.Function:
264
264
  case built_in_proc_name_1.BuiltInProcName.FunctionDefinition:
265
265
  case built_in_proc_name_1.BuiltInProcName.S7MakeConstructor:
266
+ case built_in_proc_name_1.BuiltInProcName.ClassGenerator:
266
267
  case built_in_proc_name_1.BuiltInProcName.DefineArgument:
268
+ case built_in_proc_name_1.BuiltInProcName.Switch:
267
269
  return this.onDefaultFunctionCall({ call });
268
270
  case built_in_proc_name_1.BuiltInProcName.Load:
269
271
  return this.onLoadCall({ call });
@@ -1,7 +1,7 @@
1
1
  import { internalPrinter } from '../../../print/print';
2
2
  import { normalizedAstToJson, normalizedAstToQuads, printNormalizedAstToMermaid, printNormalizedAstToMermaidUrl } from '../../../print/normalize-printer';
3
3
  import { PipelineStepStage } from '../../pipeline-step';
4
- import { type NormalizeRequiredInput } from './10-normalize';
4
+ import type { NormalizeRequiredInput } from './10-normalize';
5
5
  import type { ParseStepOutput } from '../../../../r-bridge/parser';
6
6
  import type { Tree } from 'web-tree-sitter';
7
7
  declare function processor(results: {
@@ -1,4 +1,4 @@
1
- import { type REnvironmentInformation } from './environment';
1
+ import type { REnvironmentInformation } from './environment';
2
2
  import type { IdentifierDefinition } from './identifier';
3
3
  /**
4
4
  * Merges two arrays of identifier definitions into a fresh array, unique by `nodeId` and `definedAt`.
@@ -86,6 +86,8 @@ export declare enum BuiltInProcName {
86
86
  StackEnv = "builtin:stack-env",
87
87
  /** for `stop` calls */
88
88
  Stop = "builtin:stop",
89
+ /** for `switch` calls */
90
+ Switch = "builtin:switch",
89
91
  /** for `stopifnot` calls, see {@link processStopIfNot} */
90
92
  StopIfNot = "builtin:stopifnot",
91
93
  /** support for `:=` in subsetting assignments, see {@link processAccess} */
@@ -96,6 +98,8 @@ export declare enum BuiltInProcName {
96
98
  Attach = "builtin:attach",
97
99
  /** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
98
100
  NewEnv = "builtin:nenv",
101
+ /** for `R6Class`/`setRefClass` class generators whose methods back `$new()`-instance dispatch */
102
+ ClassGenerator = "builtin:class-gen",
99
103
  /** for unnamed directly-linked function calls */
100
104
  Unnamed = "unnamed",
101
105
  /** for vector construction calls, see {@link processVector} */
@@ -90,6 +90,8 @@ var BuiltInProcName;
90
90
  BuiltInProcName["StackEnv"] = "builtin:stack-env";
91
91
  /** for `stop` calls */
92
92
  BuiltInProcName["Stop"] = "builtin:stop";
93
+ /** for `switch` calls */
94
+ BuiltInProcName["Switch"] = "builtin:switch";
93
95
  /** for `stopifnot` calls, see {@link processStopIfNot} */
94
96
  BuiltInProcName["StopIfNot"] = "builtin:stopifnot";
95
97
  /** support for `:=` in subsetting assignments, see {@link processAccess} */
@@ -100,6 +102,8 @@ var BuiltInProcName;
100
102
  BuiltInProcName["Attach"] = "builtin:attach";
101
103
  /** for `new.env` and related environment-creation calls, see {@link processNewEnv} */
102
104
  BuiltInProcName["NewEnv"] = "builtin:nenv";
105
+ /** for `R6Class`/`setRefClass` class generators whose methods back `$new()`-instance dispatch */
106
+ BuiltInProcName["ClassGenerator"] = "builtin:class-gen";
103
107
  /** for unnamed directly-linked function calls */
104
108
  BuiltInProcName["Unnamed"] = "unnamed";
105
109
  /** for vector construction calls, see {@link processVector} */
@@ -30,7 +30,7 @@ import { processRm } from '../internal/process/functions/call/built-in/built-in-
30
30
  import { processEvalCall } from '../internal/process/functions/call/built-in/built-in-eval';
31
31
  import type { REnvironmentInformation } from './environment';
32
32
  import type { Value } from '../eval/values/r-value';
33
- import { resolveAsMinus, resolveAsPlus, resolveAsSeq, resolveAsVector } from '../eval/resolve/resolve';
33
+ import { resolveAsMinus, resolveAsPaste, resolveAsPlus, resolveAsSeq, resolveAsVector } from '../eval/resolve/resolve';
34
34
  import type { DataflowGraph } from '../graph/graph';
35
35
  import type { VariableResolve } from '../../config';
36
36
  import type { BuiltInConstantDefinition, BuiltInDefinition, BuiltInFunctionDefinition, BuiltInReplacementDefinition } from './built-in-config';
@@ -46,6 +46,7 @@ import { processS7Dispatch } from '../internal/process/functions/call/built-in/b
46
46
  import { BuiltInProcName } from './built-in-proc-name';
47
47
  import { processPurrrFormula } from '../internal/process/functions/call/built-in/built-in-purrr-formula';
48
48
  import { processNewEnv } from '../internal/process/functions/call/built-in/built-in-new-env';
49
+ import { processClassGenerator } from '../internal/process/functions/call/built-in/built-in-class-generator';
49
50
  import { processStackEnv } from '../internal/process/functions/call/built-in/built-in-stack-env';
50
51
  import { processAttach } from '../internal/process/functions/call/built-in/built-in-attach';
51
52
  import { processWithEnv } from '../internal/process/functions/call/built-in/built-in-with';
@@ -135,6 +136,7 @@ export declare const BuiltInProcessorMapper: {
135
136
  readonly "builtin:try": typeof processTryCatch;
136
137
  readonly "builtin:attach": typeof processAttach;
137
138
  readonly "builtin:nenv": typeof processNewEnv;
139
+ readonly "builtin:class-gen": typeof processClassGenerator;
138
140
  readonly "builtin:stack-env": typeof processStackEnv;
139
141
  readonly "builtin:with": typeof processWithEnv;
140
142
  readonly "builtin:vector": typeof processVector;
@@ -145,6 +147,8 @@ export declare const BuiltInEvalHandlerMapper: {
145
147
  readonly 'built-in::': typeof resolveAsSeq;
146
148
  readonly 'built-in:+': typeof resolveAsPlus;
147
149
  readonly 'built-in:-': typeof resolveAsMinus;
150
+ readonly 'built-in:paste': typeof resolveAsPaste;
151
+ readonly 'built-in:paste0': typeof resolveAsPaste;
148
152
  };
149
153
  export type ConfigOfBuiltInMappingName<N extends keyof typeof BuiltInProcessorMapper> = Parameters<typeof BuiltInProcessorMapper[N]>[4];
150
154
  export type BuiltInMemory = Map<BrandedIdentifier, IdentifierDefinition[]>;
@@ -43,6 +43,7 @@ const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
43
43
  const built_in_proc_name_1 = require("./built-in-proc-name");
44
44
  const built_in_purrr_formula_1 = require("../internal/process/functions/call/built-in/built-in-purrr-formula");
45
45
  const built_in_new_env_1 = require("../internal/process/functions/call/built-in/built-in-new-env");
46
+ const built_in_class_generator_1 = require("../internal/process/functions/call/built-in/built-in-class-generator");
46
47
  const built_in_stack_env_1 = require("../internal/process/functions/call/built-in/built-in-stack-env");
47
48
  const built_in_attach_1 = require("../internal/process/functions/call/built-in/built-in-attach");
48
49
  const built_in_with_1 = require("../internal/process/functions/call/built-in/built-in-with");
@@ -163,6 +164,7 @@ exports.BuiltInProcessorMapper = {
163
164
  [built_in_proc_name_1.BuiltInProcName.Try]: built_in_try_catch_1.processTryCatch,
164
165
  [built_in_proc_name_1.BuiltInProcName.Attach]: built_in_attach_1.processAttach,
165
166
  [built_in_proc_name_1.BuiltInProcName.NewEnv]: built_in_new_env_1.processNewEnv,
167
+ [built_in_proc_name_1.BuiltInProcName.ClassGenerator]: built_in_class_generator_1.processClassGenerator,
166
168
  [built_in_proc_name_1.BuiltInProcName.StackEnv]: built_in_stack_env_1.processStackEnv,
167
169
  [built_in_proc_name_1.BuiltInProcName.With]: built_in_with_1.processWithEnv,
168
170
  [built_in_proc_name_1.BuiltInProcName.Vector]: built_in_vector_1.processVector,
@@ -172,7 +174,9 @@ exports.BuiltInEvalHandlerMapper = {
172
174
  'built-in:c': resolve_1.resolveAsVector,
173
175
  'built-in::': resolve_1.resolveAsSeq,
174
176
  'built-in:+': resolve_1.resolveAsPlus,
175
- 'built-in:-': resolve_1.resolveAsMinus
177
+ 'built-in:-': resolve_1.resolveAsMinus,
178
+ 'built-in:paste': resolve_1.resolveAsPaste,
179
+ 'built-in:paste0': resolve_1.resolveAsPaste
176
180
  };
177
181
  class BuiltIns {
178
182
  /**
@@ -1,4 +1,4 @@
1
- import { type REnvironmentInformation } from './environment';
1
+ import type { REnvironmentInformation } from './environment';
2
2
  /**
3
3
  * Produce a clone of the given environment information.
4
4
  * @param environment - The environment information to clone.
@@ -14,7 +14,9 @@ export declare enum StackEnvKind {
14
14
  Empty = 2,
15
15
  Current = 3,
16
16
  Parent = 4,
17
- Named = 5
17
+ /** `parent.frame()`: the dynamic caller's frame, over-approximated to the global env (exact at a top-level call). */
18
+ CallerFrame = 5,
19
+ Named = 6
18
20
  }
19
21
  /** Maps the env-returning/-transforming base builtins and constants to the stack environment each denotes. */
20
22
  export declare const StackEnvBuiltins: {
@@ -23,6 +25,7 @@ export declare const StackEnvBuiltins: {
23
25
  readonly emptyenv: StackEnvKind.Empty;
24
26
  readonly environment: StackEnvKind.Current;
25
27
  readonly 'parent.env': StackEnvKind.Parent;
28
+ readonly 'parent.frame': StackEnvKind.CallerFrame;
26
29
  readonly 'as.environment': StackEnvKind.Named;
27
30
  readonly '.GlobalEnv': StackEnvKind.Global;
28
31
  readonly '.BaseEnv': StackEnvKind.Base;
@@ -158,6 +161,7 @@ export declare const DefaultBuiltinConfig: [{
158
161
  readonly config: {
159
162
  readonly indexOfFunction: 0;
160
163
  readonly nameOfFunctionArgument: "FUN";
164
+ readonly unquoteFunction: true;
161
165
  };
162
166
  readonly assumePrimitive: false;
163
167
  }, {
@@ -167,6 +171,7 @@ export declare const DefaultBuiltinConfig: [{
167
171
  readonly config: {
168
172
  readonly indexOfFunction: 1;
169
173
  readonly nameOfFunctionArgument: "FUN";
174
+ readonly unquoteFunction: true;
170
175
  };
171
176
  readonly assumePrimitive: false;
172
177
  }, {
@@ -176,6 +181,7 @@ export declare const DefaultBuiltinConfig: [{
176
181
  readonly config: {
177
182
  readonly indexOfFunction: 1;
178
183
  readonly nameOfFunctionArgument: "FUN";
184
+ readonly unquoteFunction: true;
179
185
  };
180
186
  readonly assumePrimitive: false;
181
187
  }, {
@@ -185,6 +191,27 @@ export declare const DefaultBuiltinConfig: [{
185
191
  readonly config: {
186
192
  readonly indexOfFunction: 2;
187
193
  readonly nameOfFunctionArgument: "FUN";
194
+ readonly unquoteFunction: true;
195
+ };
196
+ readonly assumePrimitive: false;
197
+ }, {
198
+ readonly type: "function";
199
+ readonly names: [Identifier, Identifier];
200
+ readonly processor: BuiltInProcName.Apply;
201
+ readonly config: {
202
+ readonly indexOfFunction: 0;
203
+ readonly nameOfFunctionArgument: "f";
204
+ readonly unquoteFunction: true;
205
+ };
206
+ readonly assumePrimitive: false;
207
+ }, {
208
+ readonly type: "function";
209
+ readonly names: [Identifier];
210
+ readonly processor: BuiltInProcName.Apply;
211
+ readonly config: {
212
+ readonly indexOfFunction: 0;
213
+ readonly nameOfFunctionArgument: "f";
214
+ readonly unquoteFunction: true;
188
215
  };
189
216
  readonly assumePrimitive: false;
190
217
  }, {
@@ -369,6 +396,7 @@ export declare const DefaultBuiltinConfig: [{
369
396
  readonly processor: BuiltInProcName.Default;
370
397
  readonly config: {
371
398
  readonly forceArgs: readonly [true];
399
+ readonly useAsProcessor: BuiltInProcName.Switch;
372
400
  };
373
401
  readonly assumePrimitive: false;
374
402
  }, {
@@ -453,10 +481,19 @@ export declare const DefaultBuiltinConfig: [{
453
481
  readonly assumePrimitive: false;
454
482
  }, {
455
483
  readonly type: "function";
456
- readonly names: ["[", "[["];
484
+ readonly names: ["["];
485
+ readonly processor: BuiltInProcName.Access;
486
+ readonly config: {
487
+ readonly treatIndicesAsString: false;
488
+ };
489
+ readonly assumePrimitive: true;
490
+ }, {
491
+ readonly type: "function";
492
+ readonly names: ["[["];
457
493
  readonly processor: BuiltInProcName.Access;
458
494
  readonly config: {
459
495
  readonly treatIndicesAsString: false;
496
+ readonly resolveField: true;
460
497
  };
461
498
  readonly assumePrimitive: true;
462
499
  }, {
@@ -465,6 +502,7 @@ export declare const DefaultBuiltinConfig: [{
465
502
  readonly processor: BuiltInProcName.Access;
466
503
  readonly config: {
467
504
  readonly treatIndicesAsString: true;
505
+ readonly resolveField: true;
468
506
  };
469
507
  readonly assumePrimitive: true;
470
508
  }, {
@@ -1107,6 +1145,12 @@ export declare const DefaultBuiltinConfig: [{
1107
1145
  readonly processor: BuiltInProcName.NewEnv;
1108
1146
  readonly config: {};
1109
1147
  readonly assumePrimitive: true;
1148
+ }, {
1149
+ readonly type: "function";
1150
+ readonly names: [Identifier, Identifier];
1151
+ readonly processor: BuiltInProcName.ClassGenerator;
1152
+ readonly config: {};
1153
+ readonly assumePrimitive: false;
1110
1154
  }, {
1111
1155
  readonly type: "function";
1112
1156
  readonly names: Identifier[];
@@ -1231,9 +1275,20 @@ export declare const DefaultBuiltinConfig: [{
1231
1275
  readonly assumePrimitive: true;
1232
1276
  }, {
1233
1277
  readonly type: "function";
1234
- readonly names: [Identifier, Identifier, Identifier];
1278
+ readonly names: [Identifier, Identifier];
1235
1279
  readonly processor: BuiltInProcName.S7MakeConstructor;
1236
- readonly config: {};
1280
+ readonly config: {
1281
+ readonly wrapIndex: 0;
1282
+ };
1283
+ readonly assumePrimitive: true;
1284
+ }, {
1285
+ readonly type: "function";
1286
+ readonly names: [Identifier];
1287
+ readonly processor: BuiltInProcName.S7MakeConstructor;
1288
+ readonly config: {
1289
+ readonly wrapIndex: 0;
1290
+ readonly wrapName: ".f";
1291
+ };
1237
1292
  readonly assumePrimitive: true;
1238
1293
  }, {
1239
1294
  readonly type: "function";
@@ -19,7 +19,9 @@ var StackEnvKind;
19
19
  StackEnvKind[StackEnvKind["Empty"] = 2] = "Empty";
20
20
  StackEnvKind[StackEnvKind["Current"] = 3] = "Current";
21
21
  StackEnvKind[StackEnvKind["Parent"] = 4] = "Parent";
22
- StackEnvKind[StackEnvKind["Named"] = 5] = "Named";
22
+ /** `parent.frame()`: the dynamic caller's frame, over-approximated to the global env (exact at a top-level call). */
23
+ StackEnvKind[StackEnvKind["CallerFrame"] = 5] = "CallerFrame";
24
+ StackEnvKind[StackEnvKind["Named"] = 6] = "Named";
23
25
  })(StackEnvKind || (exports.StackEnvKind = StackEnvKind = {}));
24
26
  /** Maps the env-returning/-transforming base builtins and constants to the stack environment each denotes. */
25
27
  exports.StackEnvBuiltins = {
@@ -28,6 +30,7 @@ exports.StackEnvBuiltins = {
28
30
  emptyenv: StackEnvKind.Empty,
29
31
  environment: StackEnvKind.Current,
30
32
  'parent.env': StackEnvKind.Parent,
33
+ 'parent.frame': StackEnvKind.CallerFrame,
31
34
  'as.environment': StackEnvKind.Named,
32
35
  '.GlobalEnv': StackEnvKind.Global,
33
36
  '.BaseEnv': StackEnvKind.Base,
@@ -247,13 +250,17 @@ exports.DefaultBuiltinConfig = [
247
250
  { type: 'function', names: [identifier_1.Identifier.from(['options', "base" /* PkgName.Base */])],
248
251
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { hasUnknownSideEffects: true, forceArgs: 'all' }, assumePrimitive: false },
249
252
  { type: 'function', names: [identifier_1.Identifier.from(['mapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Mapply', "functools" /* PkgName.Functools */])],
250
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'FUN' }, assumePrimitive: false },
253
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'FUN', unquoteFunction: true }, assumePrimitive: false },
251
254
  { type: 'function', names: [identifier_1.Identifier.from(['lapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['sapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['vapply', "base" /* PkgName.Base */])],
252
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN' }, assumePrimitive: false },
255
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true }, assumePrimitive: false },
253
256
  { type: 'function', names: [identifier_1.Identifier.from(['Lapply', "functools" /* PkgName.Functools */]), identifier_1.Identifier.from(['Sapply', "functools" /* PkgName.Functools */]), identifier_1.Identifier.from(['Vapply', "functools" /* PkgName.Functools */])],
254
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN' }, assumePrimitive: false },
257
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 1, nameOfFunctionArgument: 'FUN', unquoteFunction: true }, assumePrimitive: false },
255
258
  { type: 'function', names: [identifier_1.Identifier.from(['apply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['tapply', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Tapply', "functools" /* PkgName.Functools */])],
256
- processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 2, nameOfFunctionArgument: 'FUN' }, assumePrimitive: false },
259
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 2, nameOfFunctionArgument: 'FUN', unquoteFunction: true }, assumePrimitive: false },
260
+ { type: 'function', names: [identifier_1.Identifier.from(['Map', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Filter', "base" /* PkgName.Base */])],
261
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true }, assumePrimitive: false },
262
+ { type: 'function', names: [identifier_1.Identifier.from(['Reduce', "base" /* PkgName.Base */])],
263
+ processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, nameOfFunctionArgument: 'f', unquoteFunction: true }, assumePrimitive: false },
257
264
  { type: 'function', names: [identifier_1.Identifier.from(['print', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['message', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['warning', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['warn', "rlang" /* PkgName.Rlang */]), identifier_1.Identifier.from(['warn', "R.utils" /* PkgName.Rutils */]), identifier_1.Identifier.from(['info', "msgr" /* PkgName.Msgr */])],
258
265
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, forceArgs: 'all', keepArgumentOut: true, hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
259
266
  { type: 'function', names: [identifier_1.Identifier.from(['invisible', "base" /* PkgName.Base */])],
@@ -378,7 +385,7 @@ exports.DefaultBuiltinConfig = [
378
385
  { type: 'function', names: [identifier_1.Identifier.from(['cat', "base" /* PkgName.Base */])],
379
386
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: 'all', hasUnknownSideEffects: { type: 'link-to-last-call', callName: /^sink$/ } }, assumePrimitive: false },
380
387
  { type: 'function', names: [identifier_1.Identifier.from(['switch', "base" /* PkgName.Base */])],
381
- processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: [true] }, assumePrimitive: false },
388
+ processor: built_in_proc_name_1.BuiltInProcName.Default, config: { forceArgs: [true], useAsProcessor: built_in_proc_name_1.BuiltInProcName.Switch }, assumePrimitive: false },
382
389
  { type: 'function', names: ['return'],
383
390
  processor: built_in_proc_name_1.BuiltInProcName.Default, config: { returnsNthArgument: 0, cfg: 1 /* ExitPointType.Return */, keepArgumentOut: true, useAsProcessor: built_in_proc_name_1.BuiltInProcName.Return }, assumePrimitive: true },
384
391
  {
@@ -407,10 +414,12 @@ exports.DefaultBuiltinConfig = [
407
414
  processor: built_in_proc_name_1.BuiltInProcName.ExpressionList, config: {}, assumePrimitive: true },
408
415
  { type: 'function', names: [identifier_1.Identifier.from(['source', "base" /* PkgName.Base */])],
409
416
  processor: built_in_proc_name_1.BuiltInProcName.Source, config: { includeFunctionCall: true, forceFollow: false }, assumePrimitive: false },
410
- { type: 'function', names: ['[', '[['],
417
+ { type: 'function', names: ['['],
411
418
  processor: built_in_proc_name_1.BuiltInProcName.Access, config: { treatIndicesAsString: false }, assumePrimitive: true },
419
+ { type: 'function', names: ['[['],
420
+ processor: built_in_proc_name_1.BuiltInProcName.Access, config: { treatIndicesAsString: false, resolveField: true }, assumePrimitive: true },
412
421
  { type: 'function', names: ['$', '@'],
413
- processor: built_in_proc_name_1.BuiltInProcName.Access, config: { treatIndicesAsString: true }, assumePrimitive: true },
422
+ processor: built_in_proc_name_1.BuiltInProcName.Access, config: { treatIndicesAsString: true, resolveField: true }, assumePrimitive: true },
414
423
  { type: 'function', names: ['::'],
415
424
  processor: built_in_proc_name_1.BuiltInProcName.NamespaceAccess, config: { internal: false }, assumePrimitive: true },
416
425
  { type: 'function', names: [':::'],
@@ -614,6 +623,8 @@ exports.DefaultBuiltinConfig = [
614
623
  processor: built_in_proc_name_1.BuiltInProcName.With, config: {}, assumePrimitive: false },
615
624
  { type: 'function', names: [identifier_1.Identifier.from(['new.env', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['new_environment', "rlang" /* PkgName.Rlang */])],
616
625
  processor: built_in_proc_name_1.BuiltInProcName.NewEnv, config: {}, assumePrimitive: true },
626
+ { type: 'function', names: [identifier_1.Identifier.from(['R6Class', "R6" /* PkgName.R6 */]), identifier_1.Identifier.from(['setRefClass', "methods" /* PkgName.Methods */])],
627
+ processor: built_in_proc_name_1.BuiltInProcName.ClassGenerator, config: {}, assumePrimitive: false },
617
628
  /* env-returning builtins pointing into the current search-path stack (`e <- globalenv(); e$x`) */
618
629
  { type: 'function', names: Object.entries(exports.StackEnvBuiltins)
619
630
  .filter(([n, kind]) => !n.startsWith('.') && (kind === StackEnvKind.Global || kind === StackEnvKind.Base || kind === StackEnvKind.Empty))
@@ -653,9 +664,10 @@ exports.DefaultBuiltinConfig = [
653
664
  { type: 'function', names: [identifier_1.Identifier.from(['setClass', "methods" /* PkgName.Methods */])],
654
665
  processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: { mode: ['s4'] }, assumePrimitive: true },
655
666
  { type: 'function', names: [
656
- identifier_1.Identifier.from(['Negate', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Vectorize', "base" /* PkgName.Base */]),
657
- identifier_1.Identifier.from(['partial', "purrr" /* PkgName.Purrr */])
658
- ], processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: {}, assumePrimitive: true },
667
+ identifier_1.Identifier.from(['Negate', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['Vectorize', "base" /* PkgName.Base */])
668
+ ], processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: { wrapIndex: 0 }, assumePrimitive: true },
669
+ { type: 'function', names: [identifier_1.Identifier.from(['partial', "purrr" /* PkgName.Purrr */])],
670
+ processor: built_in_proc_name_1.BuiltInProcName.S7MakeConstructor, config: { wrapIndex: 0, wrapName: '.f' }, assumePrimitive: true },
659
671
  { type: 'function', names: [identifier_1.Identifier.from(['.Primitive', "base" /* PkgName.Base */]), identifier_1.Identifier.from(['.Internal', "base" /* PkgName.Base */])],
660
672
  processor: built_in_proc_name_1.BuiltInProcName.Apply, config: { indexOfFunction: 0, unquoteFunction: true, resolveInEnvironment: 'global' }, assumePrimitive: true },
661
673
  { type: 'function', names: [identifier_1.Identifier.from(['interference', "inferference" /* PkgName.Inferference */])],
@@ -102,10 +102,30 @@ export declare class Environment implements IEnvironment {
102
102
  }
103
103
  /** Walks up to the global environment (see {@link Environment#globalEnv}), falling back to the last non-builtin env. */
104
104
  declare function findGlobalEnvironment(this: void, env: Environment): Environment;
105
+ /** The `search()` position directly below the global environment; where R attaches by default. */
106
+ export declare const DefaultAttachPosition = 2;
107
+ /** Prefix of a package's entry in R's `search()` list. */
108
+ export declare const SearchPathPackagePrefix = "package:";
109
+ /** Name of the global environment in R's `search()` list. */
110
+ export declare const GlobalEnvEntryName = ".GlobalEnv";
105
111
  /**
106
- * Splices a package block (`blockTop`..`blockBottom`) directly below the global environment. Returns a fresh `current`, cloning only the path down to global.
112
+ * Splices a package block (`blockTop`..`blockBottom`) into the search path at the 1-based `search()` position `pos`
113
+ * ({@link DefaultAttachPosition|2} being directly below the global environment, the default). A position past the end
114
+ * of the search path attaches directly above the built-in environment, mirroring R's clamping. Returns a fresh
115
+ * `current`, cloning only the path down to the insertion point.
107
116
  */
108
- declare function attachPackageBelowGlobal(this: void, current: Environment, blockTop: Environment, blockBottom: Environment): Environment;
117
+ declare function attachPackageAt(this: void, current: Environment, blockTop: Environment, blockBottom: Environment, pos?: number): Environment;
118
+ /**
119
+ * The 1-based `search()` position of the entry called `name` (`.GlobalEnv`, `package:x`, or a bare package name),
120
+ * or `undefined` if no such entry is on the search path. `package:base` resolves to the built-in environment at the
121
+ * very bottom if base R is not attached as its own layer.
122
+ */
123
+ declare function searchPositionOf(this: void, env: Environment, name: string): number | undefined;
124
+ /**
125
+ * The packages attached below the global environment, i.e. those whose exports R resolves without a namespace.
126
+ * Base is always among them, as it backs the built-in environment even when it is no layer of its own.
127
+ */
128
+ declare function attachedPackagesOf(this: void, env: Environment): Set<string>;
109
129
  /**
110
130
  * Helpers for navigating and manipulating {@link REnvironmentInformation|environments} around the global environment and attached-package search path.
111
131
  */
@@ -113,8 +133,12 @@ export declare const REnvironment: {
113
133
  readonly name: "REnvironment";
114
134
  /** Walks up to the global environment (`.GlobalEnv`); see {@link findGlobalEnvironment}. */
115
135
  readonly findGlobal: typeof findGlobalEnvironment;
116
- /** Attaches a package block below the global environment; see {@link attachPackageBelowGlobal}. */
117
- readonly attachBelowGlobal: typeof attachPackageBelowGlobal;
136
+ /** Attaches a package block at a `search()` position, below the global by default; see {@link attachPackageAt}. */
137
+ readonly attachAt: typeof attachPackageAt;
138
+ /** The `search()` position of a named entry; see {@link searchPositionOf}. */
139
+ readonly searchPosition: typeof searchPositionOf;
140
+ /** The packages on the search path; see {@link attachedPackagesOf}. */
141
+ readonly attachedPackages: typeof attachedPackagesOf;
118
142
  };
119
143
  /**
120
144
  * An environment describes a ({@link IEnvironment#parent|scoped}) mapping of names to their definitions ({@link BuiltIns}).