@eagleoutice/flowr 2.15.10 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +23 -26
  2. package/abstract-interpretation/data-frame/arguments.js +11 -7
  3. package/control-flow/happens-before.d.ts +5 -0
  4. package/control-flow/happens-before.js +48 -34
  5. package/control-flow/useless-loop.d.ts +1 -1
  6. package/control-flow/useless-loop.js +29 -42
  7. package/dataflow/environments/built-in-props.d.ts +9 -0
  8. package/dataflow/environments/built-in-props.js +25 -19
  9. package/dataflow/environments/built-in.d.ts +2 -2
  10. package/dataflow/environments/built-in.js +41 -77
  11. package/dataflow/environments/default-builtin-config.d.ts +181 -29
  12. package/dataflow/environments/default-builtin-config.js +38 -24
  13. package/dataflow/environments/environment.d.ts +6 -4
  14. package/dataflow/environments/environment.js +54 -121
  15. package/dataflow/environments/identifier.d.ts +4 -2
  16. package/dataflow/environments/identifier.js +23 -69
  17. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  18. package/dataflow/environments/reference-to-maybe.js +23 -51
  19. package/dataflow/environments/resolve-by-name.js +37 -76
  20. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  22. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  23. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  24. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  25. package/dataflow/eval/resolve/resolve.js +23 -14
  26. package/dataflow/extractor.js +176 -59
  27. package/dataflow/fn/class-declaration.d.ts +8 -2
  28. package/dataflow/fn/class-declaration.js +96 -97
  29. package/dataflow/fn/exceptions-of-function.js +68 -37
  30. package/dataflow/fn/frame-reflection.d.ts +12 -4
  31. package/dataflow/fn/frame-reflection.js +51 -41
  32. package/dataflow/fn/function-props.js +15 -33
  33. package/dataflow/fn/function-semantics.d.ts +11 -3
  34. package/dataflow/fn/function-semantics.js +6 -0
  35. package/dataflow/fn/higher-order-function.js +13 -17
  36. package/dataflow/fn/strict-function.d.ts +13 -0
  37. package/dataflow/fn/strict-function.js +285 -122
  38. package/dataflow/graph/call-graph.d.ts +7 -6
  39. package/dataflow/graph/call-graph.js +35 -46
  40. package/dataflow/graph/graph.d.ts +6 -1
  41. package/dataflow/graph/graph.js +57 -66
  42. package/dataflow/info.d.ts +8 -1
  43. package/dataflow/info.js +24 -30
  44. package/dataflow/internal/control-flow.d.ts +31 -4
  45. package/dataflow/internal/control-flow.js +61 -39
  46. package/dataflow/internal/linker.d.ts +15 -9
  47. package/dataflow/internal/linker.js +253 -241
  48. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
  49. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
  50. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
  52. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
  54. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  55. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  56. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
  57. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
  58. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
  59. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  61. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  62. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
  63. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  64. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
  65. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  66. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  67. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  68. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
  70. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
  72. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  73. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
  74. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  76. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  77. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  78. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  79. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
  80. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  81. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  83. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  84. package/dataflow/internal/process/functions/call/common.d.ts +1 -3
  85. package/dataflow/internal/process/functions/call/common.js +36 -76
  86. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
  87. package/dataflow/internal/process/functions/call/deferred.js +54 -57
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  90. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  91. package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
  92. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  93. package/dataflow/internal/process/functions/call/quoted.js +162 -172
  94. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  95. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  96. package/dataflow/internal/process/process-symbol.js +3 -6
  97. package/dataflow/internal/program-order.d.ts +26 -0
  98. package/dataflow/internal/program-order.js +49 -0
  99. package/documentation/wiki-setup.js +23 -0
  100. package/linter/linter-rules.d.ts +17 -8
  101. package/linter/rules/absolute-path.js +63 -87
  102. package/linter/rules/file-path-validity.d.ts +4 -2
  103. package/linter/rules/file-path-validity.js +114 -80
  104. package/linter/rules/namespace-access.js +21 -33
  105. package/linter/rules/naming-convention.d.ts +1 -1
  106. package/linter/rules/naming-convention.js +60 -48
  107. package/linter/rules/network-functions.js +11 -7
  108. package/linter/rules/no-leaked-credentials.js +15 -18
  109. package/linter/rules/problematic-inputs.d.ts +2 -1
  110. package/linter/rules/problematic-inputs.js +39 -59
  111. package/linter/rules/roxygen-arguments.d.ts +9 -4
  112. package/linter/rules/roxygen-arguments.js +29 -48
  113. package/linter/rules/seeded-randomness.d.ts +7 -4
  114. package/linter/rules/seeded-randomness.js +128 -89
  115. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  116. package/linter/rules/stop-with-call-arg.js +25 -22
  117. package/linter/rules/unclosed-connection.js +31 -24
  118. package/linter/rules/undefined-symbol.d.ts +4 -6
  119. package/linter/rules/undefined-symbol.js +58 -75
  120. package/linter/rules/unescaped-arguments.js +18 -44
  121. package/linter/rules/unused-definition.d.ts +6 -0
  122. package/linter/rules/unused-definition.js +105 -145
  123. package/linter/rules/unused-import.d.ts +3 -0
  124. package/linter/rules/unused-import.js +25 -43
  125. package/package.json +5 -2
  126. package/project/flowr-analyzer.js +6 -2
  127. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  128. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  129. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  130. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  131. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
  132. package/queries/base-query-format.js +1 -2
  133. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  134. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  135. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  136. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  137. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  138. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  139. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  140. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  141. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  142. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  143. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  144. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  145. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  156. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  157. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  158. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  159. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  160. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  161. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  162. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  163. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  164. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  165. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  166. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  167. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  168. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  169. package/r-bridge/shell.js +6 -0
  170. package/search/search-executor/search-enrichers.js +25 -37
  171. package/slicing/static/slice-call.d.ts +4 -3
  172. package/slicing/static/slice-call.js +56 -88
  173. package/slicing/static/static-slicer.js +115 -79
  174. package/slicing/static/visiting-queue.d.ts +4 -6
  175. package/slicing/static/visiting-queue.js +9 -13
  176. package/util/proc.js +2 -1
  177. package/util/r-base-packages.d.ts +2 -0
  178. package/util/r-base-packages.js +23 -13
  179. package/util/text/playground-link.d.ts +12 -3
  180. package/util/text/playground-link.js +18 -27
  181. package/util/version.js +4 -10
@@ -109,44 +109,23 @@ function processLibrary(name, args, rootId, data, config = {}) {
109
109
  isCharacterOnly = seenMaybe || seenTrue === seenFalse ? 'maybe' : seenTrue;
110
110
  }
111
111
  }
112
- const packetName = [];
113
- if (isCharacterOnly) {
114
- for (const nameToLoad of namesToLoad) {
115
- const values = node_value_1.NodeValue.setOf(nameToLoad.info.id, data);
116
- if (values?.type === 'set' && values.elements.length !== 0) {
117
- for (const elem of values.elements) {
118
- const name = r_value_1.RValue.stringOf(elem);
119
- if (name !== undefined) {
120
- packetName.push(name);
121
- }
122
- }
123
- }
124
- }
125
- }
112
+ const packetName = isCharacterOnly ? namesToLoad.flatMap(nameToLoad => {
113
+ const values = node_value_1.NodeValue.setOf(nameToLoad.info.id, data);
114
+ return values?.type === 'set' ? values.elements.map(elem => r_value_1.RValue.stringOf(elem)).filter(assert_1.isNotUndefined) : [];
115
+ }) : [];
126
116
  if (!isCharacterOnly || isCharacterOnly === 'maybe') {
127
117
  // treat as a function call but convert the argument(s) to a string; a quoted literal carries its name in `content.str`, not `lexeme`
128
- const newArgs = [];
129
- for (const nameToLoad of namesToLoad) {
130
- const packageName = r_string_1.RString.is(nameToLoad) ? nameToLoad.content.str : nameToLoad.lexeme;
131
- if ((0, assert_1.isNotUndefined)(packageName)) {
132
- packetName.push(packageName);
133
- }
134
- newArgs.push(r_string_1.RString.is(nameToLoad) ? nameToLoad : {
135
- type: type_1.RType.String,
136
- info: nameToLoad.info,
137
- lexeme: nameToLoad.lexeme,
138
- location: nameToLoad.location,
139
- content: { quotes: 'none', str: identifier_1.Identifier.getName(nameToLoad.content) }
140
- });
141
- }
118
+ packetName.push(...namesToLoad.map(n => r_string_1.RString.is(n) ? n.content.str : n.lexeme).filter(assert_1.isNotUndefined));
119
+ const newArgs = namesToLoad.map((n) => r_string_1.RString.is(n) ? n : {
120
+ type: type_1.RType.String,
121
+ info: n.info,
122
+ lexeme: n.lexeme,
123
+ location: n.location,
124
+ content: { quotes: 'none', str: identifier_1.Identifier.getName(n.content) }
125
+ });
142
126
  args = (0, make_argument_1.wrapArgumentsUnnamed)([...newArgs, ...args.slice(1)], data.completeAst.idMap);
143
127
  }
144
- const info = (0, known_call_handling_1.processKnownFunctionCall)({
145
- name,
146
- args, rootId, data,
147
- hasUnknownSideEffect: false,
148
- origin: built_in_proc_name_1.BuiltInProcName.Library
149
- }).information;
128
+ const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: false, origin: built_in_proc_name_1.BuiltInProcName.Library }).information;
150
129
  for (const p of packetName) {
151
130
  const dependency = data.ctx.deps.loadDependency(p);
152
131
  if (dependency) {
@@ -175,7 +154,7 @@ function symbolOrStringName(node) {
175
154
  if (r_symbol_1.RSymbol.is(node)) {
176
155
  return identifier_1.Identifier.getName(node.content);
177
156
  }
178
- if (r_string_1.RString.is(node)) {
157
+ else if (r_string_1.RString.is(node)) {
179
158
  return node.content.str;
180
159
  }
181
160
  return undefined;
@@ -185,50 +164,40 @@ function stringLiterals(node) {
185
164
  if (r_string_1.RString.is(node)) {
186
165
  return [node.content.str];
187
166
  }
188
- if (r_function_call_1.RFunctionCall.isNamed(node) && identifier_1.Identifier.getName(node.functionName.content) === 'c') {
189
- return node.arguments.flatMap(a => a !== r_function_call_1.EmptyArgument && r_string_1.RString.is(a.value) ? [a.value.content.str] : []);
190
- }
191
- return [];
167
+ return r_function_call_1.RFunctionCall.isNamed(node) && identifier_1.Identifier.getName(node.functionName.content) === 'c'
168
+ ? node.arguments.flatMap(a => a !== r_function_call_1.EmptyArgument && r_string_1.RString.is(a.value) ? [a.value.content.str] : [])
169
+ : [];
192
170
  }
193
171
  /** Parse `import::from(pkg, a, keep = filter, .all = TRUE, .except = c(...))` into which exports to attach. */
194
172
  function parseFromSpec(args) {
195
173
  const include = new Map();
196
174
  const exclude = new Set();
197
175
  let all = false;
198
- for (let i = 1; i < args.length; i++) {
199
- const arg = args[i];
176
+ for (const arg of args.slice(1)) {
200
177
  if (r_argument_1.RArgument.isEmpty(arg) || arg.value === undefined) {
201
178
  continue;
202
179
  }
203
180
  const argName = arg.name?.lexeme;
204
181
  if (argName === '.all') {
205
182
  all ||= r_logical_1.RLogical.isTrue(arg.value);
206
- continue;
207
183
  }
208
- if (argName === '.except') {
209
- for (const s of stringLiterals(arg.value)) {
210
- exclude.add(s);
211
- }
184
+ else if (argName === '.except') {
185
+ stringLiterals(arg.value).forEach(s => exclude.add(s));
212
186
  all = true;
213
- continue;
214
187
  }
215
- if (argName?.startsWith('.')) {
216
- continue; // other control args (.into, .library, ...) do not affect which exports resolve
217
- }
218
- const exported = symbolOrStringName(arg.value);
219
- if (exported !== undefined) {
220
- include.set(argName ?? exported, exported);
188
+ else if (!argName?.startsWith('.')) {
189
+ /* other control args (.into, .library, ...) do not affect which exports resolve */
190
+ const exported = symbolOrStringName(arg.value);
191
+ if (exported !== undefined) {
192
+ include.set(argName ?? exported, exported);
193
+ }
221
194
  }
222
195
  }
223
- return {
224
- include: include.size > 0 ? include : undefined,
225
- exclude: exclude.size > 0 ? exclude : undefined,
226
- all: all || exclude.size > 0
227
- };
196
+ return { include: include.size > 0 ? include : undefined, exclude: exclude.size > 0 ? exclude : undefined, all };
228
197
  }
229
198
  /** Parse a `box::use` bracket argument (`pkg[a, b]` or `pkg[...]`) into a package and its attach spec; `undefined` if not a bracket. */
230
199
  function parseBoxSpec(first) {
231
- if (first === undefined || !r_access_1.RAccess.isIndex(first)) {
200
+ if (!r_access_1.RAccess.isIndex(first)) {
232
201
  return undefined;
233
202
  }
234
203
  const pack = symbolOrStringName(first.accessed);
@@ -238,16 +207,18 @@ function parseBoxSpec(first) {
238
207
  const include = new Map();
239
208
  let all = false;
240
209
  for (const el of first.access) {
241
- if (r_argument_1.RArgument.isEmpty(el) || el.value === undefined) {
210
+ if (r_argument_1.RArgument.isEmpty(el)) {
242
211
  continue;
243
212
  }
244
- if (r_symbol_1.RSymbol.is(el.value) && identifier_1.Identifier.getName(el.value.content) === '...') {
245
- all = true; // use(pkg[...]) attaches every export
246
- continue;
213
+ else if (r_symbol_1.RSymbol.is(el.value) && identifier_1.Identifier.getName(el.value.content) === '...') {
214
+ /* use(pkg[...]) attaches every export */
215
+ all = true;
247
216
  }
248
- const exported = symbolOrStringName(el.value);
249
- if (exported !== undefined) {
250
- include.set(el.name?.lexeme ?? exported, exported);
217
+ else {
218
+ const exported = symbolOrStringName(el.value);
219
+ if (exported !== undefined) {
220
+ include.set(el.name?.lexeme ?? exported, exported);
221
+ }
251
222
  }
252
223
  }
253
224
  return { pack, spec: { include: include.size > 0 ? include : undefined, all } };
@@ -258,8 +229,7 @@ function parseBoxSpec(first) {
258
229
  */
259
230
  function processUse(name, args, rootId, data) {
260
231
  const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, hasUnknownSideEffect: false, origin: built_in_proc_name_1.BuiltInProcName.Library }).information;
261
- const first = r_argument_1.RArgument.isEmpty(args[0]) ? undefined : args[0]?.value;
262
- const parsed = parseUseSpec(name, first, args, data);
232
+ const parsed = parseUseSpec(name, r_argument_1.RArgument.valueOf(args[0]), args, data);
263
233
  const dependency = parsed && data.ctx.deps.getDependency(parsed.pack);
264
234
  if (parsed && dependency) {
265
235
  linkLibrary(dependency, info, rootId, data, parsed.spec);
@@ -297,24 +267,22 @@ function attachExportVertex(graph, builtInId, environment, ctx, cds) {
297
267
  tag: vertex_1.VertexType.FunctionDefinition,
298
268
  id: builtInId,
299
269
  environment, cds, params: {},
300
- subflow: { graph: new Set(), unknownReferences: [], in: [], out: [], environment, entryPoint: builtInId, hooks: [] },
270
+ subflow: { graph: new Set(), unknownReferences: [], in: [], out: [], environment: ctx.env.makeCleanEnv(), entryPoint: builtInId, hooks: [] },
301
271
  exitPoints: [],
302
272
  }, ctx.env.cleanEnv);
303
273
  }
304
274
  /** Reserved marker binding recording an unresolved `library()`/`require()` load; the leading space cannot collide with a real export name. */
305
275
  const libraryLoadMarker = ' library-load';
276
+ /** The {@link libraryLoadMarker} binding of loading `pack` at `loadedAt`, so `pack::fn` links back via {@link loadNodesForNamespace}. */
277
+ function loadMarkerOf(pack, loadedAt, cds) {
278
+ return { name: identifier_1.Identifier.make(libraryLoadMarker, pack), type: identifier_1.ReferenceType.Function, nodeId: loadedAt, definedAt: loadedAt, cds: cds?.slice() };
279
+ }
306
280
  /**
307
281
  * Record a syntactically known but database-unresolved package load: a bare {@link EnvType.LoadedNamespace} layer
308
282
  * carrying only the reserved {@link libraryLoadMarker}, so an explicit `pack::fn` still links back via {@link loadNodesForNamespace}.
309
283
  */
310
284
  function recordUnresolvedLibraryLoad(envInfo, pack, rootId, pos, cds) {
311
- const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define({
312
- name: identifier_1.Identifier.make(libraryLoadMarker, pack),
313
- type: identifier_1.ReferenceType.Function,
314
- nodeId: rootId,
315
- definedAt: rootId,
316
- cds: cds?.slice()
317
- });
285
+ const layer = new environment_1.Environment(envInfo.current).asLibrary(pack, environment_1.EnvType.LoadedNamespace).define(loadMarkerOf(pack, rootId, cds));
318
286
  return { level: envInfo.level, current: environment_1.REnvironment.attachAt(envInfo.current, layer, layer, pos) };
319
287
  }
320
288
  /**
@@ -371,10 +339,7 @@ function selectExports(callables, spec) {
371
339
  * and a script mentions a few dozen, so the definitions are only made for the ones something asks about.
372
340
  */
373
341
  function lazyExports(pack, exports, ctx, definedAt) {
374
- const byName = new Map();
375
- for (const exp of exports) {
376
- byName.set(identifier_1.Identifier.getName(identifier_1.Identifier.make(exp.as, pack)), exp);
377
- }
342
+ const byName = new Map(exports.map(exp => [identifier_1.Identifier.getName(identifier_1.Identifier.make(exp.as, pack)), exp]));
378
343
  return new frame_memory_1.LazyBindings(new Set(byName.keys()), name => [exportDefinition(pack, byName.get(name), ctx, definedAt)]);
379
344
  }
380
345
  /**
@@ -388,7 +353,9 @@ function exportDefinition(pack, exp, ctx, definedAt = node_id_1.NodeId.toBuiltIn
388
353
  nodeId: node_id_1.NodeId.fromPkgFn(pack, exp.exported),
389
354
  definedAt,
390
355
  };
391
- const stated = ctx.env.statedFor(pack)?.get(identifier_1.Identifier.make(exp.exported))?.[0];
356
+ /* an export named like a primitive is a method registered for it (lubridate's `$`), the primitive still evaluates the call */
357
+ const exported = identifier_1.Identifier.make(exp.exported);
358
+ const stated = ctx.env.statedFor(pack)?.get(exported)?.[0] ?? ctx.env.emptyBuiltInEnvironment.memory.get(exported)?.[0];
392
359
  if (stated === undefined) {
393
360
  return identity;
394
361
  }
@@ -508,11 +475,10 @@ function attachBaseRNamespaces(env, ctx) {
508
475
  let builtinNames;
509
476
  for (const pkg of basePackages) {
510
477
  const dependency = ctx.deps.getDependency(pkg);
511
- if (dependency?.namespaceInfo === undefined) {
512
- continue;
478
+ if (dependency?.namespaceInfo !== undefined) {
479
+ builtinNames ??= new Set([...ctx.env.builtInEnvironment.memory.keys()].map(String));
480
+ built = attachDependencyToEnvironment(dependency, built, ctx, { exclude: builtinNames }, node_id_1.NodeId.toBuiltIn(pkg));
513
481
  }
514
- builtinNames ??= new Set([...ctx.env.builtInEnvironment.memory.keys()].map(String));
515
- built = attachDependencyToEnvironment(dependency, built, ctx, { exclude: builtinNames }, node_id_1.NodeId.toBuiltIn(pkg));
516
482
  }
517
483
  if (built.current.parent !== env.current.parent) {
518
484
  baseNamespaceLayerCache.set(key, built.current.parent);
@@ -529,12 +495,11 @@ function attachDeclaredDependencies(env, ctx) {
529
495
  }
530
496
  let built = env;
531
497
  for (const declared of ctx.deps.getDependencies()) {
532
- // getDependency triggers lazy export resolution the raw declared record may still be missing
498
+ /* getDependency triggers lazy export resolution the raw declared record may still be missing */
533
499
  const dependency = ctx.deps.getDependency(declared.name);
534
- if (dependency?.namespaceInfo === undefined) {
535
- continue;
500
+ if (dependency?.namespaceInfo !== undefined) {
501
+ built = attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(dependency.name));
536
502
  }
537
- built = attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(dependency.name));
538
503
  }
539
504
  return built;
540
505
  }
@@ -559,14 +524,12 @@ function attachProjectImports(env, ctx) {
559
524
  else {
560
525
  names = funcs;
561
526
  }
562
- for (const fn of names) {
563
- toDefine.push({
564
- name: identifier_1.Identifier.make(fn, layerNamespace),
565
- type: identifier_1.ReferenceType.Function,
566
- nodeId: node_id_1.NodeId.fromPkgFn(pkg, fn),
567
- definedAt: node_id_1.NodeId.toBuiltIn(pkg)
568
- });
569
- }
527
+ toDefine.push(...names.map((fn) => ({
528
+ name: identifier_1.Identifier.make(fn, layerNamespace),
529
+ type: identifier_1.ReferenceType.Function,
530
+ nodeId: node_id_1.NodeId.fromPkgFn(pkg, fn),
531
+ definedAt: node_id_1.NodeId.toBuiltIn(pkg)
532
+ })));
570
533
  }
571
534
  if (toDefine.length === 0) {
572
535
  return env;
@@ -590,13 +553,7 @@ function attachStatedDefinitions(pack, envInfo, ctx, spec, as, loadedAt, cds) {
590
553
  : [...stated].filter(([key]) => (spec.all || spec.include === undefined || spec.include.has(key)) && !spec.exclude?.has(key)));
591
554
  if (loadedAt !== undefined) {
592
555
  /* the marker an unresolved load leaves behind, so a call links back to the `library()` that made it resolve */
593
- memory.set(libraryLoadMarker, [{
594
- name: identifier_1.Identifier.make(libraryLoadMarker, pack),
595
- type: identifier_1.ReferenceType.Function,
596
- nodeId: loadedAt,
597
- definedAt: loadedAt,
598
- cds: cds?.slice()
599
- }]);
556
+ memory.set(libraryLoadMarker, [loadMarkerOf(pack, loadedAt, cds)]);
600
557
  }
601
558
  const layer = new environment_1.Environment(envInfo.current)
602
559
  .asLibrary(pack, as ?? (spec.namespaceOnly ? environment_1.EnvType.LoadedNamespace : environment_1.EnvType.Namespace));
@@ -622,11 +579,9 @@ function attachAssumedPackages(env, ctx) {
622
579
  for (let i = assumed.length - 1; i >= 0; i--) {
623
580
  const pkg = assumed[i];
624
581
  const dependency = ctx.deps.getDependency(pkg);
625
- if (dependency?.namespaceInfo !== undefined) {
626
- built = attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(pkg));
627
- continue;
628
- }
629
- built = attachStatedDefinitions(pkg, built, ctx, { pos: AssumedAttachPosition }, environment_1.EnvType.AssumedNamespace);
582
+ built = dependency?.namespaceInfo !== undefined
583
+ ? attachDependencyToEnvironment(dependency, built, ctx, {}, node_id_1.NodeId.toBuiltIn(pkg))
584
+ : attachStatedDefinitions(pkg, built, ctx, { pos: AssumedAttachPosition }, environment_1.EnvType.AssumedNamespace);
630
585
  }
631
586
  return built;
632
587
  }
@@ -658,23 +613,17 @@ function attachProject(env, ctx) {
658
613
  return defineProjectSysdata(attachAssumedPackages(attachDeclaredDependencies(attachProjectImports(attachBaseRNamespaces(env, ctx), ctx), ctx), ctx), ctx);
659
614
  }
660
615
  function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
661
- for (const imp of namespaceInfo.importedPackages) {
662
- const importedDependency = ctx.deps.getDependency(imp[0]);
663
- if ((0, assert_1.isUndefined)(importedDependency)) {
664
- continue;
665
- }
666
- const importedNs = importedDependency.namespaceInfo;
667
- const funcToImport = importedNs === undefined ? undefined
668
- : imp[1] === 'all' ? (0, flowr_namespace_file_1.getCallables)(importedNs) : (0, flowr_namespace_file_1.getCallables)(importedNs).filter(v => imp[1].includes(v));
669
- if ((0, assert_1.isUndefined)(funcToImport)) {
670
- continue;
671
- }
672
- if (alreadyImportedAll.has(importedDependency.name)) {
616
+ for (const [pkg, imported] of namespaceInfo.importedPackages) {
617
+ const importedDependency = ctx.deps.getDependency(pkg);
618
+ const importedNs = importedDependency?.namespaceInfo;
619
+ if (importedDependency === undefined || importedNs === undefined || alreadyImportedAll.has(importedDependency.name)) {
673
620
  continue;
674
621
  }
675
622
  /* collect first and define in one go, as defining one by one copies the (growing) memory every time */
676
623
  const toDefine = [];
677
624
  const queued = new Set();
625
+ const callables = (0, flowr_namespace_file_1.getCallables)(importedNs);
626
+ const funcToImport = imported === 'all' ? callables : callables.filter(v => imported.includes(v));
678
627
  for (const func of funcToImport) {
679
628
  const identifier = package_1.Package.functionIdentifier(importedDependency.name, func);
680
629
  if (importsEnv.memory.has(identifier) || queued.has(identifier)) {
@@ -691,12 +640,9 @@ function recImports(importsEnv, namespaceInfo, ctx, alreadyImportedAll) {
691
640
  if (toDefine.length > 0) {
692
641
  importsEnv = importsEnv.defineAll(toDefine);
693
642
  }
694
- if (imp[1] === 'all') {
643
+ if (imported === 'all') {
695
644
  alreadyImportedAll.add(importedDependency.name);
696
- }
697
- //if only importFrom() we don't have to recursively import
698
- if (imp[1] === 'all' && importedDependency?.namespaceInfo) {
699
- importsEnv = recImports(importsEnv, importedDependency.namespaceInfo, ctx, alreadyImportedAll);
645
+ importsEnv = recImports(importsEnv, importedNs, ctx, alreadyImportedAll);
700
646
  }
701
647
  }
702
648
  return importsEnv;
@@ -12,7 +12,5 @@ export interface LocalFunctionConfiguration {
12
12
  env: string;
13
13
  };
14
14
  }
15
- /**
16
- * Processes a built-in 'local' function call.
17
- */
15
+ /** Processes a built-in 'local' function call. */
18
16
  export declare function processLocal<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: LocalFunctionConfiguration): DataflowInformation;
@@ -16,19 +16,16 @@ const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/node
16
16
  const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-name");
17
17
  const built_in_envir_utils_1 = require("./built-in-envir-utils");
18
18
  const resolve_helper_1 = require("../../../../../environments/resolve-helper");
19
- /**
20
- * Processes a built-in 'local' function call.
21
- */
19
+ /** Processes a built-in 'local' function call. */
22
20
  function processLocal(name, args, rootId, data, config) {
23
21
  if (args.length === 0) {
24
22
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
25
23
  }
26
- const params = {
24
+ const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
27
25
  [config.args.expr]: 'expr',
28
26
  [config.args.env]: 'env',
29
27
  '...': '...'
30
- };
31
- const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
28
+ });
32
29
  const envArg = r_argument_1.RArgument.getWithId(args, argMaps.get('env')?.[0]);
33
30
  const env = (0, unpack_argument_1.unpackArg)(envArg);
34
31
  const expr = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('expr')?.[0]));
@@ -39,7 +36,7 @@ function processLocal(name, args, rootId, data, config) {
39
36
  const envirRouting = envArg ? (0, built_in_envir_utils_1.resolveArgToEnvirOrAmbiguous)(envArg, data) : undefined;
40
37
  const envirResolution = (0, built_in_envir_utils_1.envirOf)(envirRouting);
41
38
  const dfEnv = env ? (0, processor_1.processDataflowFor)(env, data) : info_1.DataflowInformation.initialize(rootId, data);
42
- if (control_flow_1.ControlFlow.alwaysExits(dfEnv)) {
39
+ if (control_flow_1.ControlFlow.alwaysExits(dfEnv, data.cds)) {
43
40
  (0, common_1.patchFunctionCall)({
44
41
  nextGraph: dfEnv.graph,
45
42
  rootId,
@@ -65,9 +62,8 @@ function processLocal(name, args, rootId, data, config) {
65
62
  const resultEnvironment = envirResolution ? data.environment : (0, scoping_1.popLocalEnvironment)(dfExpr.environment);
66
63
  /* definitions of the local scope vanish with it, only what escaped it (e.g. via `<<-`) may bubble up */
67
64
  const escaping = envirResolution ? dfExpr.out : dfExpr.out.filter(o => o.name !== undefined && resolve_helper_1.Resolve.byNameAndType(o.name, resultEnvironment, o.type)?.some(d => d.nodeId === o.nodeId));
68
- const ingoing = dfEnv.in.concat(dfExpr.in, dfEnv.unknownReferences, dfExpr.unknownReferences);
69
- ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
70
65
  const graph = dfEnv.graph.mergeWith(dfExpr.graph);
66
+ graph.addEdge(rootId, expr.info.id, edge_1.EdgeType.Returns);
71
67
  /* the body only runs because `local` runs it */
72
68
  for (const [id, vertex] of dfExpr.graph.vertices(false)) {
73
69
  if (!vertex_1.DfgVertex.isUse(vertex) && !vertex_1.DfgVertex.isValue(vertex)) {
@@ -75,10 +71,14 @@ function processLocal(name, args, rootId, data, config) {
75
71
  }
76
72
  }
77
73
  const cfgEntry = control_flow_1.ControlFlow.inSequence(graph, env ? [dfEnv, dfExpr] : [dfExpr], rootId);
74
+ /* `return` only leaves the evaluation that local opens */
75
+ control_flow_1.ControlFlow.jumpsTo(graph, dfExpr, 1 /* ExitPointType.Return */, rootId);
76
+ const ingoing = dfEnv.in.concat(dfExpr.in, dfEnv.unknownReferences, dfExpr.unknownReferences);
77
+ ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
78
78
  const baseResult = {
79
79
  hooks: dfExpr.hooks.concat(dfEnv.hooks),
80
80
  environment: resultEnvironment,
81
- exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints),
81
+ exitPoints: dfEnv.exitPoints.concat(dfExpr.exitPoints.filter(e => e.type !== 1 /* ExitPointType.Return */)),
82
82
  graph,
83
83
  entryPoint: rootId,
84
84
  cfgEntry,
@@ -1,5 +1,6 @@
1
1
  import type { DataflowProcessorInformation } from '../../../../../processor';
2
- import { type DataflowInformation } from '../../../../../info';
2
+ import type { FnSig } from '../../../../../environments/built-in-props';
3
+ import type { DataflowInformation } from '../../../../../info';
3
4
  import type { ParentInformation } from '../../../../../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
5
  import type { PotentiallyEmptyRArgument } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
6
  import type { RSymbol } from '../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
@@ -10,9 +11,8 @@ interface QuoteConfig {
10
11
  envArgIndex?: number;
11
12
  /** which unquote escape the function supports, {@link Unquote.None} if unset */
12
13
  unquote?: Unquote;
14
+ readonly sig?: FnSig;
13
15
  }
14
- /**
15
- * Process a call to `quote` or similar nse/substitution functions.
16
- */
16
+ /** Process a call to `quote` or similar nse/substitution functions. */
17
17
  export declare function processQuote<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: QuoteConfig): DataflowInformation;
18
18
  export {};
@@ -14,14 +14,12 @@ const nse_1 = require("../nse");
14
14
  const linker_1 = require("../../../../linker");
15
15
  const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
16
16
  const scoping_1 = require("../../../../../environments/scoping");
17
- /**
18
- * Process a call to `quote` or similar nse/substitution functions.
19
- */
17
+ /** Process a call to `quote` or similar nse/substitution functions. */
20
18
  function processQuote(name, args, rootId, data, config) {
21
19
  const startEnv = data.environment;
22
20
  let lastEnv = startEnv;
23
21
  const { information, processedArguments, fnRef } = (0, known_call_handling_1.processKnownFunctionCall)({
24
- name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Quote,
22
+ name, args, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.Quote, sig: config.sig,
25
23
  patchData(data, index) {
26
24
  if (index === config.quoteArgumentsWithIndex) {
27
25
  lastEnv = data.environment;
@@ -32,30 +30,12 @@ function processQuote(name, args, rootId, data, config) {
32
30
  }
33
31
  }
34
32
  });
35
- const inRefs = [fnRef];
36
- const outRefs = [];
37
- const unknownRefs = [];
33
+ const others = processedArguments.filter((p, i) => p !== undefined && i !== config.quoteArgumentsWithIndex);
34
+ const inRefs = [fnRef, ...others.flatMap(p => p.in)];
38
35
  const quotedArg = args[config.quoteArgumentsWithIndex];
39
36
  const evaluated = function_semantics_1.FunctionSemantics.call.nse.unquoted(r_argument_1.RArgument.isEmpty(quotedArg) ? undefined : quotedArg?.value, config.unquote ?? nse_1.Unquote.None);
40
- for (let i = 0; i < args.length; i++) {
41
- const processedArg = processedArguments[i];
42
- if (processedArg && i !== config.quoteArgumentsWithIndex) {
43
- inRefs.push(...processedArg.in);
44
- outRefs.push(...processedArg.out);
45
- unknownRefs.push(...processedArg.unknownReferences);
46
- }
47
- }
48
37
  const quotedProcessed = processedArguments[config.quoteArgumentsWithIndex];
49
38
  if (quotedProcessed) {
50
- /*
51
- * The expression is held on to rather than evaluated, so a `return` within it never runs and control
52
- * arrives at the call. Every other jump the call catches already.
53
- */
54
- for (const exit of quotedProcessed.exitPoints) {
55
- if (exit.type === 1 /* ExitPointType.Return */) {
56
- information.graph.addEdge(exit.nodeId, rootId, edge_1.EdgeType.FlowEdge);
57
- }
58
- }
59
39
  (0, known_call_handling_1.markArgumentsAsNonStandardEvaluation)(information.graph, rootId, processedArguments, [config.quoteArgumentsWithIndex], { evaluated });
60
40
  if (evaluated) {
61
41
  /* the argument was processed in a clean env, so the escaped reads need linking by hand */
@@ -63,19 +43,16 @@ function processQuote(name, args, rootId, data, config) {
63
43
  (0, linker_1.linkInputs)(escaped, lastEnv, inRefs, information.graph, false);
64
44
  }
65
45
  }
66
- if (config.envArgIndex !== undefined) {
67
- const envProcessed = processedArguments[config.envArgIndex];
68
- const exprProcessed = processedArguments[config.quoteArgumentsWithIndex];
69
- if (envProcessed && exprProcessed) {
70
- applyEnvListReplacement(information, envProcessed, exprProcessed);
71
- }
46
+ const envProcessed = config.envArgIndex === undefined ? undefined : processedArguments[config.envArgIndex];
47
+ if (envProcessed && quotedProcessed) {
48
+ applyEnvListReplacement(information, envProcessed, quotedProcessed);
72
49
  }
73
50
  return {
74
51
  ...information,
75
52
  environment: startEnv,
76
53
  in: inRefs,
77
- out: outRefs,
78
- unknownReferences: unknownRefs
54
+ out: others.flatMap(p => p.out),
55
+ unknownReferences: others.flatMap(p => p.unknownReferences)
79
56
  };
80
57
  }
81
58
  /** The uses within `expr`, by name, to match a `substitute` env list against. */
@@ -110,9 +87,6 @@ function applyEnvListReplacement(information, env, expr) {
110
87
  return true;
111
88
  }
112
89
  useMap ??= usesByName(expr);
113
- if (useMap.size === 0) {
114
- return true;
115
- }
116
90
  for (const field of vtx.args.filter(graph_1.FunctionArgument.isNamed)) {
117
91
  for (const useId of useMap.get(field.name) ?? []) {
118
92
  information.graph.addEdge(useId, field.nodeId, edge_1.EdgeType.Reads);
@@ -19,9 +19,10 @@ const built_in_stack_env_1 = require("./built-in-stack-env");
19
19
  const resolve_helper_1 = require("../../../../../environments/resolve-helper");
20
20
  const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
21
21
  const scoping_1 = require("../../../../../environments/scoping");
22
+ const built_in_ambient_state_1 = require("./built-in-ambient-state");
22
23
  /** whether `value` is a call to the *built-in* `ls`/`objects` that lists (and thus clears) the whole scope */
23
24
  function isBuiltInLsCall(value, data) {
24
- if (!r_function_call_2.RFunctionCall.is(value) || !value.named) {
25
+ if (!r_function_call_2.RFunctionCall.isNamed(value)) {
25
26
  return false;
26
27
  }
27
28
  const [fn, ns] = identifier_1.Identifier.toArray(value.functionName.content);
@@ -29,7 +30,7 @@ function isBuiltInLsCall(value, data) {
29
30
  return false;
30
31
  }
31
32
  // a `pattern`/`envir` argument restricts the listing, so only a plain listing clears everything
32
- const listsEverything = value.arguments.every(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && (identifier_1.Identifier.getName(a.name.content) === 'all.names' || identifier_1.Identifier.getName(a.name.content) === 'sorted'));
33
+ const listsEverything = value.arguments.every(a => r_argument_1.RArgument.isNamed(a) && ['all.names', 'sorted'].includes(identifier_1.Identifier.getName(a.name.content)));
33
34
  if (!listsEverything) {
34
35
  return false;
35
36
  }
@@ -208,6 +209,10 @@ function processRm(name, args, rootId, data) {
208
209
  }
209
210
  // apply to our own environment so threading reflects it, and emit the kills so a merging parent can re-apply
210
211
  const kills = buildKills(targets, data.cds, rootId);
211
- return kills.length > 0 ? { ...res, environment: (0, apply_kill_1.applyKills)(res.environment, kills), kill: kills } : res;
212
+ if (kills.length === 0) {
213
+ return res;
214
+ }
215
+ const names = targets.all || targets.unknown ? undefined : targets.names.map(n => n.name);
216
+ return { ...res, environment: (0, built_in_ambient_state_1.ambientWritesOfRelease)((0, apply_kill_1.applyKills)(res.environment, kills), names, rootId, data.cds), kill: kills };
212
217
  }
213
218
  //# sourceMappingURL=built-in-rm.js.map
@@ -24,7 +24,7 @@ export interface S4UseConfig {
24
24
  }
25
25
  /** wires the S4 registrations a call *uses* (the classes and generic its arguments name by string), read against the registry so the call depends on whatever `setClass`/`setGeneric` wrote them */
26
26
  export declare function linkS4Uses<O>(info: DataflowInformation, args: Args<O>, rootId: NodeId, data: Data<O>, config: S4UseConfig): void;
27
- /** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
27
+ /** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 and Reference Classes only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
28
28
  export declare function linkS4Declaration<O>(info: DataflowInformation, rootId: NodeId, data: Data<O>): void;
29
29
  /** Records that the call registers the S4 generics it names, which `setMethod` and a call of the name depend on. */
30
30
  export declare function linkS4Generic<O>(info: DataflowInformation, rootId: NodeId, names: readonly string[], data: Data<O>): void;
@@ -22,29 +22,16 @@ function s4ClassName(cls) {
22
22
  }
23
23
  /** The names an argument states, looking through the `c(...)`/`signature(...)` wrappers a signature may use. */
24
24
  function namesOf(node, data) {
25
- if (node === undefined) {
26
- return [];
27
- }
28
- const known = node_value_1.NodeValue.knownStringsOf(node.info.id, data);
25
+ const known = node === undefined ? [] : node_value_1.NodeValue.knownStringsOf(node.info.id, data);
29
26
  if (known.length > 0 || !r_function_call_1.RFunctionCall.isNamed(node)) {
30
27
  return known;
31
28
  }
32
- const collected = [];
33
- for (const arg of node.arguments) {
34
- if (!r_argument_1.RArgument.isEmpty(arg) && arg.value !== undefined) {
35
- collected.push(...namesOf(arg.value, data));
36
- }
37
- }
38
- return collected;
29
+ return node.arguments.flatMap(arg => namesOf(r_argument_1.RArgument.valueOf(arg), data));
39
30
  }
40
31
  /** Adds a read of every given name to the call, so the call depends on whatever registered them. */
41
32
  function readNames(info, rootId, names, type, data) {
42
- const added = [];
43
- for (const name of names) {
44
- added.push({ nodeId: rootId, name, type, cds: data.cds });
45
- }
46
- if (added.length > 0) {
47
- info.in = [...info.in, ...added];
33
+ if (names.length > 0) {
34
+ info.in = [...info.in, ...names.map(name => ({ nodeId: rootId, name, type, cds: data.cds }))];
48
35
  }
49
36
  }
50
37
  /** Defines `name` in the environment and records it as an out-reference of the call at `rootId`. */
@@ -57,22 +44,19 @@ function linkS4Uses(info, args, rootId, data, config) {
57
44
  for (const ref of config.classArgs ?? []) {
58
45
  readNames(info, rootId, namesOf((0, class_declaration_1.argForImpl)(args, ref), data).map(s4ClassName), identifier_1.ReferenceType.Variable, data);
59
46
  }
60
- if (config.genericArg !== undefined) {
61
- readNames(info, rootId, namesOf((0, class_declaration_1.argForImpl)(args, config.genericArg), data).map(n => n + (config.genericSuffix ?? '')), identifier_1.ReferenceType.Function, data);
62
- }
63
- if (config.registersArg !== undefined) {
64
- const registered = namesOf((0, class_declaration_1.argForImpl)(args, config.registersArg), data);
65
- readNames(info, rootId, registered.map(s4ClassName), identifier_1.ReferenceType.Variable, data);
66
- for (const cls of registered) {
67
- defineOut(info, rootId, s4ClassName(cls), identifier_1.ReferenceType.Variable, data);
68
- }
47
+ const generics = namesOf((0, class_declaration_1.argForImpl)(args, config.genericArg), data).map(n => n + (config.genericSuffix ?? ''));
48
+ readNames(info, rootId, generics, identifier_1.ReferenceType.Function, data);
49
+ const registered = namesOf((0, class_declaration_1.argForImpl)(args, config.registersArg), data).map(s4ClassName);
50
+ readNames(info, rootId, registered, identifier_1.ReferenceType.Variable, data);
51
+ for (const cls of registered) {
52
+ defineOut(info, rootId, cls, identifier_1.ReferenceType.Variable, data);
69
53
  }
70
54
  }
71
- /** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
55
+ /** wires what the attached {@link DataflowGraphVertexFunctionCall.classDecl|class declaration} states, S4 and Reference Classes only: a declaration reads the classes it builds on and registers its own name; a mere relation (`setIs`, `setValidity`) reads and re-registers the class it names */
72
56
  function linkS4Declaration(info, rootId, data) {
73
57
  const vertex = info.graph.getVertex(rootId);
74
58
  const decl = vertex_1.DfgVertex.isFunctionCall(vertex) ? vertex.classDecl : undefined;
75
- if (decl === undefined || decl.system !== "s4" /* ClassSystem.S4 */) {
59
+ if (decl === undefined || (decl.system !== "s4" /* ClassSystem.S4 */ && decl.system !== "rc" /* ClassSystem.RefClass */)) {
76
60
  return;
77
61
  }
78
62
  const used = [...decl.contains, ...(decl.union ?? []), ...decl.members.map(m => m.type).filter(t => t !== undefined)];