@eagleoutice/flowr 2.13.9 → 2.13.11

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 (181) hide show
  1. package/README.md +40 -40
  2. package/config.d.ts +50 -2
  3. package/config.js +37 -6
  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 +46 -6
  10. package/dataflow/environments/default-builtin-config.js +30 -16
  11. package/dataflow/environments/environment.d.ts +16 -0
  12. package/dataflow/environments/environment.js +114 -26
  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/environments/resolve-by-name.js +16 -6
  18. package/dataflow/environments/resolve-helper.d.ts +43 -0
  19. package/dataflow/environments/resolve-helper.js +47 -0
  20. package/dataflow/eval/resolve/alias-tracking.js +45 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +25 -17
  22. package/dataflow/eval/resolve/resolve-strings.d.ts +17 -0
  23. package/dataflow/eval/resolve/resolve-strings.js +16 -9
  24. package/dataflow/eval/resolve/resolve.js +3 -1
  25. package/dataflow/graph/call-graph.d.ts +7 -0
  26. package/dataflow/graph/call-graph.js +103 -0
  27. package/dataflow/graph/df-helper.d.ts +50 -1
  28. package/dataflow/graph/df-helper.js +63 -0
  29. package/dataflow/graph/graph.d.ts +5 -8
  30. package/dataflow/graph/graph.js +24 -13
  31. package/dataflow/internal/linker.d.ts +5 -5
  32. package/dataflow/internal/linker.js +31 -92
  33. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -2
  34. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +3 -9
  35. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +4 -30
  36. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +2 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  38. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +7 -1
  39. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +3 -3
  40. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.d.ts +1 -1
  41. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +5 -1
  42. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +2 -2
  43. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +5 -6
  44. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +32 -14
  45. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +16 -4
  46. package/dataflow/internal/process/functions/call/known-call-handling.js +29 -8
  47. package/documentation/data/faq/faqs.js +1 -1
  48. package/documentation/data/faq/wiki-faq-store.js +3 -2
  49. package/documentation/data/server/doc-data-server-messages.js +1 -1
  50. package/documentation/doc-readme.js +1 -1
  51. package/documentation/doc-util/doc-files.d.ts +5 -0
  52. package/documentation/doc-util/doc-files.js +13 -3
  53. package/documentation/doc-util/doc-sigdb.d.ts +9 -0
  54. package/documentation/doc-util/doc-sigdb.js +32 -0
  55. package/documentation/wiki-analyzer.js +10 -10
  56. package/documentation/wiki-core.js +1 -1
  57. package/documentation/wiki-dataflow-graph.js +3 -3
  58. package/documentation/wiki-interface.js +13 -2
  59. package/documentation/wiki-linting-and-testing.js +13 -13
  60. package/documentation/wiki-mk/doc-context.d.ts +1 -1
  61. package/documentation/wiki-mk/doc-context.js +9 -5
  62. package/documentation/wiki-normalized-ast.js +1 -1
  63. package/documentation/wiki-overview.js +2 -2
  64. package/documentation/wiki-query.js +4 -1
  65. package/documentation/wiki-setup.js +3 -3
  66. package/documentation/wiki-signature-database.js +2 -5
  67. package/gas.d.ts +6 -0
  68. package/gas.js +7 -1
  69. package/linter/linter-rules.d.ts +1 -1
  70. package/linter/rules/syntactically-valid.d.ts +12 -1
  71. package/linter/rules/syntactically-valid.js +88 -17
  72. package/package.json +7 -8
  73. package/project/attached-packages.d.ts +13 -0
  74. package/project/attached-packages.js +30 -0
  75. package/project/context/flowr-analyzer-context.d.ts +15 -0
  76. package/project/context/flowr-analyzer-context.js +14 -3
  77. package/project/context/flowr-analyzer-files-context.d.ts +11 -0
  78. package/project/context/flowr-analyzer-files-context.js +3 -0
  79. package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +4 -0
  80. package/project/context/flowr-analyzer-incremental-analysis-context.js +69 -0
  81. package/project/context/flowr-analyzer-loading-order-context.d.ts +8 -0
  82. package/project/context/flowr-analyzer-loading-order-context.js +23 -2
  83. package/project/dependency-version-space.d.ts +33 -11
  84. package/project/dependency-version-space.js +58 -32
  85. package/project/plugins/file-plugins/files/flowr-namespace-file.js +52 -24
  86. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.d.ts +22 -0
  87. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.js +101 -0
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +30 -11
  89. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +79 -37
  90. package/project/plugins/plugin-registry.d.ts +2 -1
  91. package/project/plugins/plugin-registry.js +2 -0
  92. package/project/sigdb/manifest.js +9 -5
  93. package/project/sigdb/reader.d.ts +20 -0
  94. package/project/sigdb/reader.js +93 -10
  95. package/project/sigdb/signature-match.d.ts +5 -18
  96. package/project/sigdb/signature-match.js +5 -18
  97. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  98. package/queries/catalog/call-graph-query/call-graph-query-executor.js +3 -1
  99. package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +4 -0
  100. package/queries/catalog/call-graph-query/call-graph-query-format.js +4 -0
  101. package/queries/catalog/dependencies-query/dependencies-query-executor.js +11 -3
  102. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +25 -1
  103. package/queries/catalog/dependencies-query/dependencies-query-format.js +22 -2
  104. package/queries/catalog/dependencies-query/function-info/library-functions.js +7 -1
  105. package/queries/catalog/dependencies-query/function-info/read-functions.js +5 -5
  106. package/queries/catalog/dependencies-query/function-info/remote-functions.d.ts +18 -0
  107. package/queries/catalog/dependencies-query/function-info/remote-functions.js +46 -0
  108. package/queries/catalog/dependencies-query/function-info/visualize-functions.js +52 -2
  109. package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -4
  110. package/queries/catalog/dependencies-query/link-devices.d.ts +16 -0
  111. package/queries/catalog/dependencies-query/link-devices.js +104 -0
  112. package/queries/catalog/dice-query/dice-query-format.d.ts +2 -0
  113. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +25 -6
  114. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +37 -6
  115. package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +17 -4
  116. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -1
  117. package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +14 -0
  118. package/queries/catalog/happens-before-query/happens-before-query-format.js +18 -2
  119. package/queries/catalog/input-sources-query/input-sources-query-format.js +4 -0
  120. package/queries/catalog/input-sources-query/input-types.d.ts +10 -0
  121. package/queries/catalog/input-sources-query/input-types.js +10 -0
  122. package/queries/catalog/location-map-query/location-map-query-executor.js +16 -6
  123. package/queries/catalog/location-map-query/location-map-query-format.d.ts +15 -1
  124. package/queries/catalog/location-map-query/location-map-query-format.js +22 -5
  125. package/queries/catalog/signature-query/signature-query-executor.js +3 -0
  126. package/queries/catalog/signature-query/signature-query-format.d.ts +5 -0
  127. package/queries/catalog/slice-query-options.d.ts +11 -1
  128. package/queries/catalog/slice-query-options.js +8 -4
  129. package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -1
  130. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +5 -1
  131. package/queries/query.d.ts +1 -1
  132. package/r-bridge/lang-4.x/ast/model/model.d.ts +23 -2
  133. package/r-bridge/lang-4.x/ast/model/model.js +44 -0
  134. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -0
  135. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  136. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -0
  137. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -0
  138. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -0
  139. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -0
  140. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -0
  141. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +8 -8
  142. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +9 -46
  143. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -0
  144. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -0
  145. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -0
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -0
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -0
  156. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +0 -5
  157. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +6 -3
  158. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +1 -1
  159. package/reconstruct/reconstruct.d.ts +9 -0
  160. package/reconstruct/reconstruct.js +1 -0
  161. package/search/flowr-search-filters.d.ts +25 -1
  162. package/search/flowr-search-filters.js +42 -7
  163. package/search/search-executor/search-generators.js +7 -2
  164. package/search/search-executor/search-transformer.js +4 -1
  165. package/slicing/criterion/parse.d.ts +5 -25
  166. package/slicing/criterion/parse.js +15 -20
  167. package/slicing/static/fingerprint.js +18 -6
  168. package/slicing/static/slice-call.js +2 -2
  169. package/slicing/static/slicer-types.d.ts +10 -0
  170. package/slicing/static/static-slicer.d.ts +1 -1
  171. package/slicing/static/static-slicer.js +29 -6
  172. package/slicing/static/visiting-queue.d.ts +12 -2
  173. package/slicing/static/visiting-queue.js +28 -3
  174. package/util/arg-matching.d.ts +18 -0
  175. package/util/arg-matching.js +70 -0
  176. package/util/collections/bimap.d.ts +21 -1
  177. package/util/collections/bimap.js +43 -7
  178. package/util/r-regex.js +19 -1
  179. package/util/range.d.ts +7 -8
  180. package/util/range.js +10 -11
  181. package/util/version.js +1 -1
@@ -23,7 +23,7 @@ const edge_1 = require("../graph/edge");
23
23
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
24
24
  const vertex_1 = require("../graph/vertex");
25
25
  const resolve_by_name_1 = require("../environments/resolve-by-name");
26
- const prefix_1 = require("../../util/prefix");
26
+ const arg_matching_1 = require("../../util/arg-matching");
27
27
  const info_1 = require("../info");
28
28
  const unnamed_call_handling_1 = require("./process/functions/call/unnamed-call-handling");
29
29
  const built_in_proc_name_1 = require("../environments/built-in-proc-name");
@@ -71,72 +71,40 @@ function produceNameSharedIdMap(references) {
71
71
  }
72
72
  return nameIdShares;
73
73
  }
74
+ /** the argument names as {@link matchArgumentsToParameters} wants them */
75
+ function argumentNames(args) {
76
+ return args.map(a => graph_1.FunctionArgument.isNamed(a) ? a.name : undefined);
77
+ }
74
78
  /**
75
- * Links the given arguments to the given parameters within the given graph.
76
- * This follows the `pmatch` semantics of R
77
- * @see https://cran.r-project.org/doc/manuals/R-lang.html#Argument-matching
78
- * This returns the resolved map from argument ids to parameter ids.
79
+ * {@link matchArgumentsToParameters|Matches} the arguments to the parameters and links them in the graph,
80
+ * returning the resolved map from argument ids to parameter ids.
79
81
  * If you just want to match by name, use {@link pMatch}.
80
82
  */
81
83
  function linkArgumentsOnCall(args, params, graph) {
82
- const nameArgMap = new Map(args.filter(graph_1.FunctionArgument.isNamed).map(a => [a.name, a]));
83
- const nameParamMap = new Map(params.filter(p => p?.name?.content !== undefined)
84
- .map(p => [p.name.content, p]));
84
+ const matched = (0, arg_matching_1.matchArgumentsToParameters)(argumentNames(args), params.map(p => p?.special ? arg_matching_1.DotsParameterName : p?.name?.content));
85
85
  const maps = new Map();
86
- const specialDotParameter = params.find(p => p.special);
87
- const sid = specialDotParameter?.name.info.id;
88
- // all parameters matched by name
89
- const matchedParameters = new Set();
90
- const paramNames = nameParamMap.keys().toArray();
91
- // first map names
92
- for (const [name, { nodeId: argId }] of nameArgMap) {
93
- const pmatchName = (0, prefix_1.findByPrefixIfUnique)(name, paramNames) ?? name;
94
- const param = nameParamMap.get(pmatchName);
95
- if (param?.name) {
96
- const pid = param.name.info.id;
97
- graph.addEdge(argId, pid, edge_1.EdgeType.DefinesOnCall);
98
- graph.addEdge(pid, argId, edge_1.EdgeType.DefinedByOnCall);
99
- maps.set(argId, pid);
100
- matchedParameters.add(name);
101
- }
102
- else if (sid) {
103
- graph.addEdge(argId, sid, edge_1.EdgeType.DefinesOnCall);
104
- graph.addEdge(sid, argId, edge_1.EdgeType.DefinedByOnCall);
105
- maps.set(argId, sid);
106
- }
107
- }
108
- const remainingParameter = params.filter(p => !p?.name || !matchedParameters.has(p.name.content));
109
- const remainingArguments = args.filter(graph_1.FunctionArgument.isUnnamed);
110
- for (let i = 0; i < remainingArguments.length; i++) {
111
- const arg = remainingArguments[i];
86
+ for (let i = 0; i < args.length; i++) {
87
+ const arg = args[i];
112
88
  if (arg === r_function_call_1.EmptyArgument) {
113
89
  continue;
114
90
  }
91
+ const param = matched[i];
92
+ const pid = param === undefined ? undefined : params[param].name?.info.id;
115
93
  const aid = arg.nodeId;
116
- if (remainingParameter.length <= i) {
117
- if (sid) {
118
- graph.addEdge(aid, sid, edge_1.EdgeType.DefinesOnCall);
119
- graph.addEdge(sid, aid, edge_1.EdgeType.DefinedByOnCall);
120
- maps.set(aid, sid);
121
- }
122
- else {
123
- logger_1.dataflowLogger.warn(`skipping argument ${i} as there is no corresponding parameter - R should block that`);
124
- }
94
+ if (pid === undefined) {
95
+ logger_1.dataflowLogger.warn(`skipping argument ${i} (id: ${aid}) as there is no corresponding parameter - R should block that`);
125
96
  continue;
126
97
  }
127
- const param = remainingParameter[i];
128
- logger_1.dataflowLogger.trace(`mapping unnamed argument ${i} (id: ${aid}) to parameter "${param.name?.content ?? '??'}"`);
129
- if (param.name) {
130
- const pid = param.name.info.id;
131
- graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
132
- graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
133
- maps.set(aid, pid);
134
- }
98
+ graph.addEdge(aid, pid, edge_1.EdgeType.DefinesOnCall);
99
+ graph.addEdge(pid, aid, edge_1.EdgeType.DefinedByOnCall);
100
+ maps.set(aid, pid);
135
101
  }
136
102
  return maps;
137
103
  }
138
104
  /**
139
- * Links the given arguments to the given parameters within the given graph by name only.
105
+ * {@link matchArgumentsToParameters|Matches} the arguments against a parameter specification, returning the
106
+ * arguments bound to each target. Unlike {@link linkArgumentsOnCall} this touches no graph, so it also works
107
+ * for a specification without parameters in the AST.
140
108
  * @example
141
109
  * ```ts
142
110
  * const parameterSpec = {
@@ -155,50 +123,21 @@ function linkArgumentsOnCall(args, params, graph) {
155
123
  * or convert them with {@link convertFnArguments}.
156
124
  */
157
125
  function pMatch(args, params) {
158
- const nameArgMap = new Map(args.filter(graph_1.FunctionArgument.isNamed).map(a => [a.name, a]));
159
- const maps = new Map();
160
- function addToMaps(key, value) {
161
- const e = maps.get(key);
162
- if (e) {
163
- e.push(value);
164
- }
165
- else {
166
- maps.set(key, [value]);
167
- }
168
- }
169
- const sid = params['...'];
170
126
  const paramNames = Object.keys(params);
171
- // all parameters matched by name
172
- const matchedParameters = new Set();
173
- // first map names
174
- for (const [name, { nodeId: argId }] of nameArgMap) {
175
- const pmatchName = (0, prefix_1.findByPrefixIfUnique)(name, paramNames) ?? name;
176
- const param = params[pmatchName];
177
- if (param) {
178
- addToMaps(param, argId);
179
- matchedParameters.add(name);
180
- }
181
- else if (sid) {
182
- addToMaps(sid, argId);
183
- }
184
- }
185
- const remainingParameter = paramNames.filter(p => !matchedParameters.has(p));
186
- const remainingArguments = args.filter(graph_1.FunctionArgument.isUnnamed);
187
- for (let i = 0; i < remainingArguments.length; i++) {
188
- const arg = remainingArguments[i];
189
- if (arg === r_function_call_1.EmptyArgument) {
127
+ const matched = (0, arg_matching_1.matchArgumentsToParameters)(argumentNames(args), paramNames);
128
+ const maps = new Map();
129
+ for (let i = 0; i < args.length; i++) {
130
+ const arg = args[i], param = matched[i];
131
+ if (arg === r_function_call_1.EmptyArgument || param === undefined) {
190
132
  continue;
191
133
  }
192
- const aid = arg.nodeId;
193
- if (remainingParameter.length <= i) {
194
- if (sid) {
195
- addToMaps(sid, aid);
196
- }
197
- continue;
134
+ const target = params[paramNames[param]];
135
+ const known = maps.get(target);
136
+ if (known) {
137
+ known.push(arg.nodeId);
198
138
  }
199
- const param = params[remainingParameter[i]];
200
- if (param) {
201
- addToMaps(param, aid);
139
+ else {
140
+ maps.set(target, [arg.nodeId]);
202
141
  }
203
142
  }
204
143
  return maps;
@@ -117,7 +117,7 @@ function processNumberBasedAccess(data, name, args, rootId, config, head) {
117
117
  const existing = data.environment.current.memory.get(':=');
118
118
  const outInfo = { definitionRootNodes: [] };
119
119
  const tableAssignId = node_id_1.NodeId.toBuiltIn(':=-table');
120
- data.environment.current.memory.set(':=', [{
120
+ data.environment.current.writableMemory.set(':=', [{
121
121
  type: identifier_1.ReferenceType.BuiltInFunction,
122
122
  definedAt: tableAssignId,
123
123
  cds: undefined,
@@ -128,7 +128,7 @@ function processNumberBasedAccess(data, name, args, rootId, config, head) {
128
128
  const fnCall = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, forceArgs: config.forceArgs, origin: built_in_proc_name_1.BuiltInProcName.Access });
129
129
  /* recover the environment */
130
130
  if (existing !== undefined) {
131
- data.environment.current.memory.set(':=', existing);
131
+ data.environment.current.writableMemory.set(':=', existing);
132
132
  }
133
133
  if (head.value && outInfo.definitionRootNodes.length > 0) {
134
134
  (0, built_in_assignment_1.markAsAssignment)(fnCall.information, { type: identifier_1.ReferenceType.Variable, name: head.value.lexeme ?? '', nodeId: head.value.info.id, definedAt: rootId, cds: [] }, outInfo.definitionRootNodes, rootId, data);
@@ -21,12 +21,6 @@ export interface EnvirResolution<OtherInfo> {
21
21
  /** `true` when this resolves to a real stack environment (`globalenv()`/`.GlobalEnv`), not a tracked custom env. */
22
22
  readonly isStackEnv?: boolean;
23
23
  }
24
- /**
25
- * Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
26
- * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
27
- * Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
28
- */
29
- export declare function bindArgs<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], paramNames: readonly string[]): ReadonlyMap<string, PotentiallyEmptyRArgument<OtherInfo & ParentInformation>>;
30
24
  /**
31
25
  * The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
32
26
  * database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
@@ -38,10 +32,10 @@ export declare function signatureParamNames<OtherInfo>(data: DataflowProcessorIn
38
32
  export declare function resolveConstantString<OtherInfo>(node: RNode<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): string | undefined;
39
33
  /** The `returnsEnvState` of the first reaching definition that carries one, else `undefined`. */
40
34
  export declare function findReturnsEnvState(defs: readonly IdentifierDefinition[] | undefined): REnvironmentInformation | undefined;
41
- /** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
35
+ /** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
42
36
  export declare function resolveArgToEnvir<OtherInfo>(arg: PotentiallyEmptyRArgument<OtherInfo & ParentInformation>, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
43
- /** Resolves the `argName` argument (default `'envir'`, pmatch against `allParamNames`), falling back to `positionalFallbackIndex`, to an {@link EnvirResolution}. */
44
- export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string, positionalFallbackIndex?: number, allParamNames?: readonly string[]): EnvirResolution<OtherInfo> | undefined;
37
+ /** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
38
+ export declare function resolveEnvirArg<OtherInfo>(args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], data: DataflowProcessorInformation<OtherInfo & ParentInformation>, argName?: string): EnvirResolution<OtherInfo> | undefined;
45
39
  /** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
46
40
  export declare function resolveSymbolToEnvir<OtherInfo>(symbolName: Identifier, nodeId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>): EnvirResolution<OtherInfo> | undefined;
47
41
  /** Moves definitions written into a custom environment from the caller's scope into `envDef`'s tracked `envState`, re-defining the holder variable. */
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bindArgs = bindArgs;
4
3
  exports.signatureParamNames = signatureParamNames;
5
4
  exports.resolveConstantString = resolveConstantString;
6
5
  exports.findReturnsEnvState = findReturnsEnvState;
@@ -61,14 +60,6 @@ function resolveDefsToEnvirResolution(defs, nodeId, data) {
61
60
  };
62
61
  return { envirData: { ...data, environment: mergedEnvState }, envDef, envirNodeId: nodeId };
63
62
  }
64
- /**
65
- * Binds call arguments to formal parameter names using R's matching rules: exact name, then partial (pmatch) name, then remaining unnamed args left-to-right.
66
- * Pass `paramNames` as the full formal parameter list (excluding `...`) so ambiguous prefixes are rejected.
67
- * Thin alias for {@link RFunctionCall.matchArgumentsToParameters}, which owns the (pure) matching logic.
68
- */
69
- function bindArgs(args, paramNames) {
70
- return r_function_call_1.RFunctionCall.matchArgsToParams(args, paramNames);
71
- }
72
63
  /**
73
64
  * The formal parameter names of the qualified call `id` (a `pkg::fn` {@link Identifier}) from the signature
74
65
  * database (excluding `...`), or `fallback` when the database is disabled or does not carry the function. Lets a
@@ -107,7 +98,7 @@ function resolveConstantString(node, data) {
107
98
  function findReturnsEnvState(defs) {
108
99
  return defs?.find((d) => d.returnsEnvState !== undefined)?.returnsEnvState;
109
100
  }
110
- /** Resolves a single already-found argument (e.g. from {@link bindArgs}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
101
+ /** Resolves a single already-found argument (e.g. from {@link RFunctionCall.matchArgsToParams}) to an {@link EnvirResolution} when it is a symbol holding a tracked envState. */
111
102
  function resolveArgToEnvir(arg, data) {
112
103
  if (arg === r_function_call_1.EmptyArgument) {
113
104
  return undefined;
@@ -135,30 +126,13 @@ function stackEnvirResolution(envState, nodeId, lexeme, data) {
135
126
  };
136
127
  return { envirData: { ...data, environment: envState }, envDef, envirNodeId: nodeId, isStackEnv: true };
137
128
  }
138
- /** Resolves the `argName` argument (default `'envir'`, pmatch against `allParamNames`), falling back to `positionalFallbackIndex`, to an {@link EnvirResolution}. */
139
- function resolveEnvirArg(args, data, argName = 'envir', positionalFallbackIndex, allParamNames = [argName]) {
140
- /* named pass: pmatch against the full parameter list */
129
+ /** Resolves the `argName` argument (default `'envir'`), named with pmatch, to an {@link EnvirResolution}. */
130
+ function resolveEnvirArg(args, data, argName = 'envir') {
141
131
  for (const arg of args) {
142
- if (arg === r_function_call_1.EmptyArgument || arg.name === undefined) {
143
- continue;
144
- }
145
- if ((0, prefix_1.findByPrefixIfUnique)(arg.name.content, allParamNames) === argName) {
132
+ if (arg !== r_function_call_1.EmptyArgument && arg.name !== undefined && (0, prefix_1.findByPrefixIfUnique)(arg.name.content, [argName]) === argName) {
146
133
  return resolveArgToEnvir(arg, data);
147
134
  }
148
135
  }
149
- /* positional fallback (only when no named match existed) */
150
- if (positionalFallbackIndex !== undefined) {
151
- let pos = 0;
152
- for (const arg of args) {
153
- if (arg === r_function_call_1.EmptyArgument || arg.name !== undefined) {
154
- continue;
155
- }
156
- if (pos === positionalFallbackIndex) {
157
- return resolveArgToEnvir(arg, data);
158
- }
159
- pos++;
160
- }
161
- }
162
136
  return undefined;
163
137
  }
164
138
  /** Resolves a symbol by name to an {@link EnvirResolution} when it holds a tracked environment. */
@@ -47,7 +47,8 @@ function processForLoop(name, args, rootId, data) {
47
47
  const writtenIds = new Set();
48
48
  for (const write of writtenVariable) {
49
49
  writtenIds.add(write.nodeId);
50
- headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, type: identifier_1.ReferenceType.Variable }, false, headEnvironments);
50
+ headEnvironments = (0, define_1.define)({ ...write, definedAt: name.info.id, type: identifier_1.ReferenceType.Variable,
51
+ value: [vectorArg.info.id], iterated: true }, false, headEnvironments);
51
52
  }
52
53
  data.environment = headEnvironments;
53
54
  const body = (0, processor_1.processDataflowFor)(bodyArg, data);
@@ -484,7 +484,7 @@ function groupBodyWrites(out) {
484
484
  }
485
485
  }
486
486
  for (const writes of byName.values()) {
487
- writes.sort((a, b) => String(a.nodeId) < String(b.nodeId) ? 1 : -1);
487
+ writes.sort((a, b) => String(b.nodeId).localeCompare(String(a.nodeId)));
488
488
  }
489
489
  return byName;
490
490
  }
@@ -25,6 +25,7 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
25
25
  const alias_tracking_1 = require("../../../../../eval/resolve/alias-tracking");
26
26
  const general_1 = require("../../../../../eval/values/general");
27
27
  const package_1 = require("../../../../../../project/plugins/package-version-plugins/package");
28
+ const attached_packages_1 = require("../../../../../../project/attached-packages");
28
29
  const flowr_namespace_file_1 = require("../../../../../../project/plugins/file-plugins/files/flowr-namespace-file");
29
30
  const common_1 = require("../common");
30
31
  const linker_1 = require("../../../../linker");
@@ -406,7 +407,12 @@ function attachDependencyToEnvironment(dependency, envInfo, ctx, spec = {}, defi
406
407
  importsEnv = recImports(importsEnv, dependency.namespaceInfo, ctx, new Set());
407
408
  const namespaceEnv = new environment_1.Environment(importsEnv).asLibrary(pack, environment_1.EnvType.Namespace)
408
409
  .defineAll(exports.map(exp => exportDefinition(pack, exp, definedAt)));
409
- return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
410
+ const attached = { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, namespaceEnv, importsEnv, spec.pos) };
411
+ /* whatever R puts on the search path with it, `pack` first so a dependency cycle stays finite (the guard above stops it) */
412
+ return (0, attached_packages_1.attachedAlongside)(pack, ctx.deps.signatureSources()).reduce((env, alongside) => {
413
+ const dependency = ctx.deps.getDependency(alongside);
414
+ return dependency === undefined ? env : attachDependencyToEnvironment(dependency, env, ctx, spec, definedAt);
415
+ }, attached);
410
416
  }
411
417
  /** A namespace-only load is subsumed by any layer for `pack`; a full attach ignores a mere {@link EnvType.LoadedNamespace}. */
412
418
  function blocksAttach(layer, namespaceOnly) {
@@ -222,12 +222,12 @@ function sexpTypeToReferenceType(type) {
222
222
  function getArguments(args, data) {
223
223
  // prefer R's real `base::load` signature from the database, falling back to the known formals when it is absent
224
224
  const loadParams = (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make('load', "base" /* PkgName.Base */), ['file', 'envir', 'verbose']);
225
- const bound = (0, built_in_envir_utils_1.bindArgs)(args, loadParams);
225
+ const bound = r_function_call_1.RFunctionCall.matchArgsToParams(args, loadParams);
226
226
  const fileArgBound = bound.get('file');
227
227
  const envirArg = bound.get('envir');
228
228
  const verboseArgBound = bound.get('verbose');
229
- const fileArg = fileArgBound && fileArgBound !== r_function_call_1.EmptyArgument ? (0, unpack_argument_1.unpackArg)(fileArgBound) : undefined;
230
- const verboseArg = verboseArgBound && verboseArgBound !== r_function_call_1.EmptyArgument ? (0, unpack_argument_1.unpackArg)(verboseArgBound) : undefined;
229
+ const fileArg = fileArgBound ? (0, unpack_argument_1.unpackArg)(fileArgBound) : undefined;
230
+ const verboseArg = verboseArgBound ? (0, unpack_argument_1.unpackArg)(verboseArgBound) : undefined;
231
231
  return { fileArg, envirArg, verboseArg };
232
232
  }
233
233
  //# sourceMappingURL=built-in-load.js.map
@@ -2,7 +2,7 @@ import type { DataflowProcessorInformation } from '../../../../../processor';
2
2
  import type { DataflowInformation } from '../../../../../info';
3
3
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
4
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
- import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
5
+ import { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
6
6
  import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { BrandedIdentifier } from '../../../../../environments/identifier';
8
8
  /**
@@ -6,6 +6,7 @@ const assert_1 = require("../../../../../../util/assert");
6
6
  const unpack_argument_1 = require("../argument/unpack-argument");
7
7
  const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
8
8
  const data_masking_functions_1 = require("../../../../../environments/data-masking-functions");
9
+ const r_symbol_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
9
10
  const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
10
11
  const logger_1 = require("../../../../../logger");
11
12
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
@@ -99,8 +100,11 @@ function processPipe(name, args, rootId, data, { pipePlaceholderName, assignLhs,
99
100
  if (arg === r_function_call_1.EmptyArgument) {
100
101
  continue;
101
102
  }
103
+ /* only the symbols may name columns, the rest is evaluated in the caller's frame */
102
104
  model_1.RNode.visitAst(arg, node => {
103
- information.graph.addEdge(rhs.info.id, node.info.id, edge_1.EdgeType.NonStandardEvaluation);
105
+ if (r_symbol_1.RSymbol.is(node)) {
106
+ information.graph.addEdge(rhs.info.id, node.info.id, edge_1.EdgeType.NonStandardEvaluation);
107
+ }
104
108
  return false;
105
109
  });
106
110
  }
@@ -14,8 +14,8 @@ import type { NodeId } from '../../../../../../r-bridge/lang-4.x/ast/model/proce
14
14
  * - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
15
15
  * - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
16
16
  *
17
- * Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
18
- * args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
17
+ * Arguments are resolved with {@link RFunctionCall.matchArgsToParams}, so `with(expr=x, data=e)` and
18
+ * `with(dat=e, x)` are handled correctly.
19
19
  *
20
20
  * Falls back to a normal function-call analysis when the data argument cannot be resolved
21
21
  * to a tracked environment.
@@ -15,7 +15,7 @@ const withParamsFallback = ['data', 'expr'];
15
15
  /** Normal call analysis, marking the data-masked arguments (columns of the data) as NSE. */
16
16
  function markAsMaskedFallback(name, args, rootId, data) {
17
17
  const { information, processedArguments } = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.With });
18
- (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.AllButFirst);
18
+ (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, known_call_handling_1.NseArguments.AllButFirst, known_call_handling_1.NseKind.DataMasked);
19
19
  return information;
20
20
  }
21
21
  /**
@@ -28,8 +28,8 @@ function markAsMaskedFallback(name, args, rootId, data) {
28
28
  * - `with`: writes in `expr` are ephemeral (R's `with` uses a temporary scope and discards them).
29
29
  * - `within`: writes in `expr` are persisted back into the tracked envState of `data`.
30
30
  *
31
- * Arguments are resolved using R's standard matching rules ({@link bindArgs}: pmatch for named
32
- * args, positional fallback), so `with(expr=x, data=e)` and `with(dat=e, x)` are handled correctly.
31
+ * Arguments are resolved with {@link RFunctionCall.matchArgsToParams}, so `with(expr=x, data=e)` and
32
+ * `with(dat=e, x)` are handled correctly.
33
33
  *
34
34
  * Falls back to a normal function-call analysis when the data argument cannot be resolved
35
35
  * to a tracked environment.
@@ -40,13 +40,12 @@ function processWithEnv(name, args, rootId, data) {
40
40
  }
41
41
  // prefer R's real `base::with` signature from the database, falling back to the known formals when it is absent
42
42
  // use the call's own name (`with` or `within`) qualified to base, so each gets its real signature
43
- const bound = (0, built_in_envir_utils_1.bindArgs)(args, (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make(identifier_1.Identifier.getName(name.content), "base" /* PkgName.Base */), withParamsFallback));
43
+ const bound = r_function_call_1.RFunctionCall.matchArgsToParams(args, (0, built_in_envir_utils_1.signatureParamNames)(data, identifier_1.Identifier.make(identifier_1.Identifier.getName(name.content), "base" /* PkgName.Base */), withParamsFallback));
44
44
  const dataArg = bound.get('data');
45
45
  const exprArg = bound.get('expr');
46
46
  // when we cannot resolve the data to a tracked environment, `expr` is still data-masked: its symbols name
47
47
  // columns of `data`, not variables in scope, so mark the non-data arguments as non-standard-evaluated
48
- if (dataArg === r_function_call_1.EmptyArgument || dataArg?.value === undefined ||
49
- exprArg === r_function_call_1.EmptyArgument || exprArg?.value === undefined) {
48
+ if (dataArg?.value === undefined || exprArg?.value === undefined) {
50
49
  return markAsMaskedFallback(name, args, rootId, data);
51
50
  }
52
51
  const envirResolution = (0, built_in_envir_utils_1.resolveArgToEnvir)(dataArg, data);
@@ -136,24 +136,37 @@ function attachedPackages(_id, fdef) {
136
136
  }
137
137
  return packages;
138
138
  }
139
- /** The non-built-in definitions a function body lets escape to an outer scope (e.g. a `<<-` super-assignment). */
140
- function escapedDefinitions(_id, fdef) {
141
- const defs = [];
142
- // skip the function's own frame; outer-scope definitions escaped
139
+ /** The scopes outside a function's own frame, i.e. those a definition of its body can have escaped into. */
140
+ function* escapeTargetFrames(fdef) {
143
141
  for (let e = fdef.subflow.environment.current.parent; e !== undefined && !e.builtInEnv; e = e.parent) {
144
- for (const definitions of e.memory.values()) {
145
- for (const def of definitions) {
146
- if (!node_id_1.NodeId.isBuiltIn(def.nodeId)) {
147
- defs.push(def.nodeId);
148
- }
142
+ yield e;
143
+ }
144
+ }
145
+ /**
146
+ * The non-built-in definitions a function body lets escape to an outer scope (e.g. a `<<-` super-assignment),
147
+ * as a callback for {@link computeCallGraphSummaries}. Nested definitions share their outer frames, and a frame is
148
+ * dominated by the built-ins it holds, so filtering each frame once per pass saves the bulk of the work.
149
+ */
150
+ function escapedDefinitions() {
151
+ const perFrame = new Map();
152
+ return (_id, fdef) => {
153
+ const defs = [];
154
+ for (const e of escapeTargetFrames(fdef)) {
155
+ let escaped = perFrame.get(e.memory);
156
+ if (escaped === undefined) {
157
+ escaped = [...e.memory.values()].flatMap(ds => ds.filter(d => !node_id_1.NodeId.isBuiltIn(d.nodeId)).map(d => d.nodeId));
158
+ perFrame.set(e.memory, escaped);
159
+ }
160
+ for (const d of escaped) {
161
+ defs.push(d);
149
162
  }
150
163
  }
151
- }
152
- return defs;
164
+ return defs;
165
+ };
153
166
  }
154
167
  /** Emits {@link EdgeType.SideEffectOnCall} edges for definitions that escape a function transitively. */
155
168
  function propagateTransitiveDefinitions(graph, environment, ctx) {
156
- const summary = computeCallGraphSummaries(graph, escapedDefinitions);
169
+ const summary = computeCallGraphSummaries(graph, escapedDefinitions());
157
170
  for (const [id, vertex] of graph.vertices(true)) {
158
171
  if (vertex.tag !== vertex_1.VertexType.FunctionCall) {
159
172
  continue;
@@ -206,11 +219,16 @@ function propagateTransitivePackages(graph, environment, ctx) {
206
219
  /** Maps each escaped definition's node id to its full (name-carrying) definition. */
207
220
  function escapedDefinitionMap(graph) {
208
221
  const map = new Map();
222
+ const seen = new Set();
209
223
  for (const [, vertex] of graph.vertices(true)) {
210
224
  if (vertex.tag !== vertex_1.VertexType.FunctionDefinition) {
211
225
  continue;
212
226
  }
213
- for (let e = vertex.subflow.environment.current.parent; e !== undefined && !e.builtInEnv; e = e.parent) {
227
+ for (const e of escapeTargetFrames(vertex)) {
228
+ if (seen.has(e.memory)) {
229
+ continue; // a frame shared with an already-visited definition contributes the same entries
230
+ }
231
+ seen.add(e.memory);
214
232
  for (const definitions of e.memory.values()) {
215
233
  for (const def of definitions) {
216
234
  if (!node_id_1.NodeId.isBuiltIn(def.nodeId) && def.name !== undefined) {
@@ -228,7 +246,7 @@ function escapedDefinitionMap(graph) {
228
246
  * @returns the enriched environment and whether it grew (so the extractor can re-resolve open reads and re-run).
229
247
  */
230
248
  function propagateTransitiveEscapedDefinitions(graph, environment) {
231
- const summary = computeCallGraphSummaries(graph, escapedDefinitions);
249
+ const summary = computeCallGraphSummaries(graph, escapedDefinitions());
232
250
  const defs = escapedDefinitionMap(graph);
233
251
  const names = new Set();
234
252
  let grew = false;
@@ -58,11 +58,23 @@ export declare enum NseArguments {
58
58
  First = "first"
59
59
  }
60
60
  /**
61
- * Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
62
- * (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
63
- * Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
61
+ * How an argument escapes standard evaluation, which decides what is marked
62
+ * {@link EdgeType.NonStandardEvaluation}.
64
63
  */
65
- export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[]): void;
64
+ export declare enum NseKind {
65
+ /** the argument is not evaluated at all (`quote(x + y)`), so nothing within it is */
66
+ Quoted = "quoted",
67
+ /** the argument is evaluated in a data mask (`subset(d, a > k)`), where only its symbols may name columns */
68
+ DataMasked = "data-masked"
69
+ }
70
+ /**
71
+ * Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}, so they are recognised as not being
72
+ * evaluated the standard way. A {@link NseKind.Quoted|quoted} argument is marked entirely, as none of it is
73
+ * evaluated. A {@link NseKind.DataMasked|data-masked} one is evaluated in the caller's frame, with only the
74
+ * names the mask supplies (those that resolve to nothing else) taken from the data, so only those are marked.
75
+ * Besides the {@link NseArguments} shorthands, the positions may be listed explicitly, `undefined` marks nothing.
76
+ */
77
+ export declare function markArgumentsAsNonStandardEvaluation(graph: DataflowGraph, rootId: NodeId, processedArguments: readonly (DataflowInformation | undefined)[], which: NseArguments | readonly number[] | undefined, kind?: NseKind): void;
66
78
  /**
67
79
  * Marks the given arguments as being involved in R's non-standard evaluation.
68
80
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NseArguments = void 0;
3
+ exports.NseKind = exports.NseArguments = void 0;
4
4
  exports.markArgumentsAsNonStandardEvaluation = markArgumentsAsNonStandardEvaluation;
5
5
  exports.markNonStandardEvaluationEdges = markNonStandardEvaluationEdges;
6
6
  exports.processKnownFunctionCall = processKnownFunctionCall;
@@ -27,20 +27,41 @@ var NseArguments;
27
27
  NseArguments["First"] = "first";
28
28
  })(NseArguments || (exports.NseArguments = NseArguments = {}));
29
29
  /**
30
- * Marks the selected arguments - and everything within them - as {@link EdgeType.NonStandardEvaluation}
31
- * (as `quote` does), so their nested symbols are recognised as non-standardly evaluated too.
32
- * Besides the {@link NseArguments} shorthands, the positions may be listed explicitly.
30
+ * How an argument escapes standard evaluation, which decides what is marked
31
+ * {@link EdgeType.NonStandardEvaluation}.
33
32
  */
34
- function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which) {
33
+ var NseKind;
34
+ (function (NseKind) {
35
+ /** the argument is not evaluated at all (`quote(x + y)`), so nothing within it is */
36
+ NseKind["Quoted"] = "quoted";
37
+ /** the argument is evaluated in a data mask (`subset(d, a > k)`), where only its symbols may name columns */
38
+ NseKind["DataMasked"] = "data-masked";
39
+ })(NseKind || (exports.NseKind = NseKind = {}));
40
+ /**
41
+ * Marks the selected arguments as {@link EdgeType.NonStandardEvaluation}, so they are recognised as not being
42
+ * evaluated the standard way. A {@link NseKind.Quoted|quoted} argument is marked entirely, as none of it is
43
+ * evaluated. A {@link NseKind.DataMasked|data-masked} one is evaluated in the caller's frame, with only the
44
+ * names the mask supplies (those that resolve to nothing else) taken from the data, so only those are marked.
45
+ * Besides the {@link NseArguments} shorthands, the positions may be listed explicitly, `undefined` marks nothing.
46
+ */
47
+ function markArgumentsAsNonStandardEvaluation(graph, rootId, processedArguments, which, kind = NseKind.Quoted) {
48
+ if (which === undefined) {
49
+ return;
50
+ }
35
51
  const end = which === NseArguments.First ? 1 : processedArguments.length;
36
52
  for (let i = which === NseArguments.AllButFirst ? 1 : 0; i < end; i++) {
37
53
  const arg = processedArguments[i];
38
54
  if (arg === undefined || (typeof which !== 'string' && !which.includes(i))) {
39
55
  continue;
40
56
  }
41
- graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
42
- for (const [vtx] of arg.graph.vertices(true)) {
43
- graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
57
+ if (kind === NseKind.Quoted) {
58
+ graph.addEdge(rootId, arg.entryPoint, edge_1.EdgeType.NonStandardEvaluation);
59
+ }
60
+ for (const [vtx, info] of arg.graph.vertices(true)) {
61
+ /* a masked name the caller does not bind is the one the data supplies */
62
+ if (kind === NseKind.Quoted || (vertex_1.UseVertex.is(info) && !arg.graph.outgoingEdges(vtx)?.values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Reads)))) {
63
+ graph.addEdge(rootId, vtx, edge_1.EdgeType.NonStandardEvaluation);
64
+ }
44
65
  }
45
66
  }
46
67
  }
@@ -51,7 +51,7 @@ ${(0, doc_code_1.codeBlock)('shell', 'npm run wiki:watch')}
51
51
  `)
52
52
  .addFaq('Why can\'t I pass *arguments* when running flowR *with npm*?', `
53
53
  With \`npm\` you have to pass arguments in a specific way. The \`--\` operator is used to separate the \`npm\` arguments from the script arguments. For example, if you want to run \`flowR\` with the \`--help\` argument, you can use the following command:
54
- ${(0, doc_code_1.codeBlock)('shell', 'npm run flowR -- --help')}
54
+ ${(0, doc_code_1.codeBlock)('shell', 'npm run flowr -- --help')}
55
55
  `)
56
56
  .addFaq('How to do *logging* in flowR?', `
57
57
  Check out the ${ctx.linkPage('wiki/Linting and Testing', 'Logging Section in the Linting and Testing wiki page', 'logging')} for more information on how to do logging in *flowR*.
@@ -10,6 +10,7 @@ const FlowrFaqTopics = {
10
10
  'r.packages': '📦 R Packages',
11
11
  'editor.configs': '⚙️ Recommended Editor Configs'
12
12
  };
13
+ const FlowrFaqMainTitle = '💮 <i>flowR</i> FAQ';
13
14
  /**
14
15
  * Manage all questions and answers by topic.
15
16
  */
@@ -50,7 +51,7 @@ class FaqStore {
50
51
  toMarkdown() {
51
52
  return `
52
53
  ${(0, doc_structure_1.collapsibleToc)({
53
- ['💮 *flowR* FAQ']: {
54
+ [FlowrFaqMainTitle]: {
54
55
  [FlowrFaqTopics['flowr.development']]: {},
55
56
  [FlowrFaqTopics['flowr.use']]: {}
56
57
  },
@@ -62,7 +63,7 @@ ${(0, doc_structure_1.collapsibleToc)({
62
63
  }
63
64
  })}
64
65
 
65
- ${(0, doc_structure_1.section)('💮 <i>flowR</i> FAQ', 2)}
66
+ ${(0, doc_structure_1.section)(FlowrFaqMainTitle, 2)}
66
67
 
67
68
  ${this.printAllTopics(/^flowr.*$/)}
68
69