@eagleoutice/flowr 2.15.9 → 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 (244) hide show
  1. package/README.md +47 -41
  2. package/abstract-interpretation/absint-inference.d.ts +2 -2
  3. package/abstract-interpretation/absint-inference.js +32 -79
  4. package/abstract-interpretation/data-frame/arguments.js +11 -7
  5. package/benchmark/slicer.d.ts +0 -1
  6. package/benchmark/slicer.js +1 -2
  7. package/cli/repl/commands/repl-signature.js +12 -3
  8. package/config.d.ts +5 -1
  9. package/control-flow/cfg-properties.js +0 -22
  10. package/control-flow/happens-before.d.ts +7 -2
  11. package/control-flow/happens-before.js +55 -31
  12. package/control-flow/useless-loop.d.ts +1 -1
  13. package/control-flow/useless-loop.js +29 -42
  14. package/dataflow/environments/apply-kill.js +6 -2
  15. package/dataflow/environments/built-in-config.d.ts +2 -0
  16. package/dataflow/environments/built-in-props.d.ts +16 -1
  17. package/dataflow/environments/built-in-props.js +33 -20
  18. package/dataflow/environments/built-in.d.ts +8 -3
  19. package/dataflow/environments/built-in.js +52 -82
  20. package/dataflow/environments/default-builtin-config.d.ts +551 -21
  21. package/dataflow/environments/default-builtin-config.js +121 -45
  22. package/dataflow/environments/define.d.ts +3 -2
  23. package/dataflow/environments/define.js +4 -3
  24. package/dataflow/environments/deprecation-info.d.ts +45 -0
  25. package/dataflow/environments/deprecation-info.js +13 -0
  26. package/dataflow/environments/environment.d.ts +7 -5
  27. package/dataflow/environments/environment.js +55 -121
  28. package/dataflow/environments/identifier.d.ts +6 -2
  29. package/dataflow/environments/identifier.js +23 -69
  30. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  31. package/dataflow/environments/reference-to-maybe.js +23 -51
  32. package/dataflow/environments/resolve-by-name.js +37 -76
  33. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  34. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  35. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  36. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  37. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  38. package/dataflow/eval/resolve/resolve.js +23 -14
  39. package/dataflow/extractor.js +180 -58
  40. package/dataflow/fn/class-declaration.d.ts +8 -13
  41. package/dataflow/fn/class-declaration.js +95 -116
  42. package/dataflow/fn/exceptions-of-function.js +68 -37
  43. package/dataflow/fn/frame-reflection.d.ts +12 -4
  44. package/dataflow/fn/frame-reflection.js +51 -41
  45. package/dataflow/fn/function-props.js +15 -33
  46. package/dataflow/fn/function-semantics.d.ts +11 -3
  47. package/dataflow/fn/function-semantics.js +6 -0
  48. package/dataflow/fn/higher-order-function.d.ts +9 -1
  49. package/dataflow/fn/higher-order-function.js +27 -24
  50. package/dataflow/fn/strict-function.d.ts +13 -0
  51. package/dataflow/fn/strict-function.js +291 -123
  52. package/dataflow/graph/call-graph.d.ts +7 -6
  53. package/dataflow/graph/call-graph.js +35 -46
  54. package/dataflow/graph/graph.d.ts +13 -1
  55. package/dataflow/graph/graph.js +74 -66
  56. package/dataflow/graph/vertex.d.ts +1 -1
  57. package/dataflow/info.d.ts +8 -1
  58. package/dataflow/info.js +24 -30
  59. package/dataflow/internal/control-flow.d.ts +31 -4
  60. package/dataflow/internal/control-flow.js +61 -39
  61. package/dataflow/internal/linker.d.ts +17 -8
  62. package/dataflow/internal/linker.js +286 -213
  63. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +179 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +874 -0
  65. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  66. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +60 -48
  67. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +4 -2
  68. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +135 -198
  69. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  70. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +5 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +21 -14
  72. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -4
  73. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  74. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +141 -146
  75. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +56 -24
  76. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +292 -253
  77. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  78. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  79. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  80. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +91 -129
  81. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  82. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +16 -12
  83. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  84. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  85. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  87. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +5 -3
  88. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +13 -31
  89. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  90. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +42 -119
  91. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  92. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +21 -21
  93. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  94. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  95. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  96. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  97. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  98. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -26
  99. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  100. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  101. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  102. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  103. package/dataflow/internal/process/functions/call/common.d.ts +4 -4
  104. package/dataflow/internal/process/functions/call/common.js +49 -71
  105. package/dataflow/internal/process/functions/call/deferred.d.ts +12 -2
  106. package/dataflow/internal/process/functions/call/deferred.js +81 -63
  107. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  108. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  109. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  110. package/dataflow/internal/process/functions/call/named-call-handling.js +48 -19
  111. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  112. package/dataflow/internal/process/functions/call/quoted.js +257 -154
  113. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  114. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  115. package/dataflow/internal/process/process-symbol.js +4 -3
  116. package/dataflow/internal/program-order.d.ts +26 -0
  117. package/dataflow/internal/program-order.js +49 -0
  118. package/documentation/data/faq/faqs.js +3 -3
  119. package/documentation/data/interface/doc-writing-code.js +1 -2
  120. package/documentation/data/server/doc-data-server-messages.js +7 -7
  121. package/documentation/doc-capabilities.js +80 -34
  122. package/documentation/doc-util/doc-query.d.ts +0 -3
  123. package/documentation/doc-util/doc-query.js +4 -3
  124. package/documentation/wiki-analyzer.js +1 -1
  125. package/documentation/wiki-cfg.js +5 -6
  126. package/documentation/wiki-core.js +8 -8
  127. package/documentation/wiki-dataflow-graph.js +10 -11
  128. package/documentation/wiki-interface.js +2 -2
  129. package/documentation/wiki-linting-and-testing.js +3 -3
  130. package/documentation/wiki-overview.js +6 -6
  131. package/documentation/wiki-query.js +9 -101
  132. package/documentation/wiki-setup.js +23 -0
  133. package/documentation/wiki-signature-database.js +1 -1
  134. package/linter/linter-rules.d.ts +18 -9
  135. package/linter/rules/absolute-path.js +63 -87
  136. package/linter/rules/deprecated-functions.d.ts +1 -45
  137. package/linter/rules/deprecated-functions.js +24 -33
  138. package/linter/rules/file-path-validity.d.ts +4 -2
  139. package/linter/rules/file-path-validity.js +114 -80
  140. package/linter/rules/namespace-access.js +21 -33
  141. package/linter/rules/naming-convention.d.ts +1 -1
  142. package/linter/rules/naming-convention.js +60 -48
  143. package/linter/rules/network-functions.js +11 -7
  144. package/linter/rules/no-leaked-credentials.js +15 -18
  145. package/linter/rules/problematic-inputs.d.ts +2 -1
  146. package/linter/rules/problematic-inputs.js +39 -59
  147. package/linter/rules/roxygen-arguments.d.ts +9 -4
  148. package/linter/rules/roxygen-arguments.js +29 -48
  149. package/linter/rules/seeded-randomness.d.ts +7 -4
  150. package/linter/rules/seeded-randomness.js +128 -89
  151. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  152. package/linter/rules/stop-with-call-arg.js +25 -22
  153. package/linter/rules/unclosed-connection.js +31 -24
  154. package/linter/rules/undefined-symbol.d.ts +4 -6
  155. package/linter/rules/undefined-symbol.js +58 -75
  156. package/linter/rules/unescaped-arguments.js +18 -44
  157. package/linter/rules/unused-definition.d.ts +6 -0
  158. package/linter/rules/unused-definition.js +105 -145
  159. package/linter/rules/unused-import.d.ts +3 -0
  160. package/linter/rules/unused-import.js +25 -43
  161. package/package.json +5 -2
  162. package/project/flowr-analyzer.d.ts +2 -0
  163. package/project/flowr-analyzer.js +28 -1
  164. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  165. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  166. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -2
  167. package/project/plugins/file-plugins/files/flowr-rda-file.js +10 -55
  168. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  169. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  170. package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -1
  171. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +22 -45
  172. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -2
  173. package/project/sigdb/build.js +4 -0
  174. package/project/sigdb/manifest.d.ts +2 -0
  175. package/project/sigdb/manifest.js +10 -1
  176. package/project/sigdb/reader.js +23 -61
  177. package/project/sigdb/sigdb-download.d.ts +29 -6
  178. package/project/sigdb/sigdb-download.js +212 -64
  179. package/queries/base-query-format.js +1 -2
  180. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  181. package/queries/catalog/call-context-query/cascade-action.d.ts +3 -1
  182. package/queries/catalog/call-context-query/cascade-action.js +2 -0
  183. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +3 -0
  184. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  185. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  186. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  187. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  188. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  189. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  190. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  191. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  192. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  193. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  194. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +2 -1
  195. package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
  196. package/queries/catalog/origin-query/origin-query-executor.js +2 -2
  197. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -2
  198. package/queries/catalog/origin-query/origin-query-format.js +1 -1
  199. package/queries/query.d.ts +1 -1
  200. package/r-bridge/data/data.d.ts +21 -14
  201. package/r-bridge/data/data.js +28 -20
  202. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  203. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  204. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  205. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  206. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  207. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  208. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  209. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  210. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  211. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  212. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  213. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  214. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  215. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  216. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  217. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  218. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  219. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  220. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  221. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  222. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  223. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  224. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  225. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  226. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
  227. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +11 -2
  228. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  229. package/r-bridge/shell.js +6 -0
  230. package/search/search-executor/search-enrichers.js +25 -37
  231. package/slicing/static/slice-call.d.ts +4 -3
  232. package/slicing/static/slice-call.js +56 -88
  233. package/slicing/static/static-slicer.js +115 -79
  234. package/slicing/static/visiting-queue.d.ts +4 -6
  235. package/slicing/static/visiting-queue.js +9 -13
  236. package/util/files.d.ts +2 -0
  237. package/util/files.js +3 -1
  238. package/util/mermaid/mermaid.js +6 -2
  239. package/util/proc.js +2 -1
  240. package/util/r-base-packages.d.ts +2 -0
  241. package/util/r-base-packages.js +23 -13
  242. package/util/text/playground-link.d.ts +12 -3
  243. package/util/text/playground-link.js +18 -27
  244. package/util/version.js +4 -10
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.onlyLiterals = onlyLiterals;
3
4
  exports.resolveNode = resolveNode;
4
5
  exports.resolveAsVector = resolveAsVector;
5
6
  exports.resolveAsSeq = resolveAsSeq;
6
7
  const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
7
8
  const r_value_1 = require("../values/r-value");
8
9
  const type_1 = require("../../../r-bridge/lang-4.x/ast/model/type");
10
+ const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
11
+ const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
12
+ const r_logical_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
9
13
  const r_value_2 = require("../../../util/r-value");
10
14
  const logical_constants_1 = require("../values/logical/logical-constants");
11
15
  const r_value_3 = require("../values/r-value");
@@ -17,6 +21,7 @@ const df_helper_1 = require("../../graph/df-helper");
17
21
  const node_id_1 = require("../../../r-bridge/lang-4.x/ast/model/processing/node-id");
18
22
  const resolve_helper_1 = require("../../environments/resolve-helper");
19
23
  const r_binary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
24
+ const r_unary_op_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
20
25
  const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
21
26
  /**
22
27
  * The {@link BuiltInEvalHandler} the given name resolves to in the current environment, just like the
@@ -24,21 +29,27 @@ const r_expression_list_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/
24
29
  * by a user definition or its built-in declares no handler.
25
30
  */
26
31
  function evalHandlerOf(name, environment, ctx) {
27
- const defs = environment ?
28
- resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.BuiltInFunction)
29
- /* without an environment the search path is unknown, so what a package states about the name has its say */
30
- : ctx.env.builtInEnvironment.memory.get(identifier_1.Identifier.getName(name))
31
- ?? ctx.env.statedDefinitionsOf(name);
32
+ /* without an environment the search path is unknown, so what a package states about the name has its say */
33
+ const defs = environment ? resolve_helper_1.Resolve.byNameAndType(name, environment, identifier_1.ReferenceType.BuiltInFunction) : builtInDefinitionsOf(name, ctx);
32
34
  const def = defs?.length === 1 ? defs[0] : undefined;
33
35
  return def?.type === identifier_1.ReferenceType.BuiltInFunction ? def.evalHandler : undefined;
34
36
  }
35
- function foldsThroughBuiltIn(name, ctx) {
36
- const defs = ctx.env.builtInEnvironment.memory.get(identifier_1.Identifier.getName(name))
37
+ function builtInDefinitionsOf(name, ctx) {
38
+ return ctx.env.builtInEnvironment.memory.get(identifier_1.Identifier.getName(name))
37
39
  ?? ctx.env.statedDefinitionsOf(name);
38
- return defs?.some(d => d.type === identifier_1.ReferenceType.BuiltInFunction && d.evalHandler !== undefined) ?? false;
40
+ }
41
+ function foldsThroughBuiltIn(name, ctx) {
42
+ return builtInDefinitionsOf(name, ctx)?.some(d => d.type === identifier_1.ReferenceType.BuiltInFunction && d.evalHandler !== undefined) ?? false;
39
43
  }
40
44
  /** the node types that may fold through a built-in: calls, operators, and the `(`/`{` groupings */
41
45
  const EvalNodeTypes = [type_1.RType.FunctionCall, type_1.RType.BinaryOp, type_1.RType.UnaryOp, type_1.RType.ExpressionList];
46
+ /** Whether the operator only combines literals (`1 + 2`), which alone fold while the analysis runs, as a name may still change its value. */
47
+ function onlyLiterals(node) {
48
+ return r_binary_op_1.RBinaryOp.is(node) ? onlyLiterals(node.lhs) && onlyLiterals(node.rhs)
49
+ : r_unary_op_1.RUnaryOp.is(node) ? onlyLiterals(node.operand)
50
+ : r_expression_list_1.RExpressionList.is(node) && node.grouping !== undefined && node.children.length === 1 ? onlyLiterals(node.children[0])
51
+ : r_number_1.RNumber.is(node) || r_string_1.RString.is(node) || r_logical_1.RLogical.is(node);
52
+ }
42
53
  /**
43
54
  * The name of the built-in the given node folds through, `undefined` if it is no call to one or if it may just
44
55
  * as well resolve to something else (a user redefinition, a conditional one, ...), which must not be folded.
@@ -49,7 +60,8 @@ function evalNameOf({ node, graph, environment, ctx }) {
49
60
  }
50
61
  else if (graph === undefined) {
51
62
  const named = r_expression_list_1.RExpressionList.is(node) ? r_expression_list_1.RExpressionList.groupStart(node)?.content
52
- : r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.content : undefined;
63
+ : r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.content
64
+ : (r_binary_op_1.RBinaryOp.is(node) || r_unary_op_1.RUnaryOp.is(node)) && onlyLiterals(node) ? identifier_1.Identifier.make(node.operator) : undefined;
53
65
  return named !== undefined && environment !== undefined && foldsThroughBuiltIn(named, ctx)
54
66
  && resolve_helper_1.Resolve.isBuiltIn(named, environment, identifier_1.ReferenceType.Function) ? named : undefined;
55
67
  }
@@ -114,11 +126,8 @@ function resolveAsSeq(args) {
114
126
  }
115
127
  const leftValue = (0, r_value_2.unliftRValue)(resolve_helper_1.Resolve.toValue(operator.lhs, args));
116
128
  const rightValue = (0, r_value_2.unliftRValue)(resolve_helper_1.Resolve.toValue(operator.rhs, args));
117
- if ((0, r_value_2.isRNumberValue)(leftValue) && (0, r_value_2.isRNumberValue)(rightValue)) {
118
- const sequence = createNumberSequence(leftValue, rightValue);
119
- return sequence === undefined ? r_value_3.Top : (0, vector_constants_1.vectorFrom)(sequence.map(scalar_constants_1.liftScalar));
120
- }
121
- return r_value_3.Top;
129
+ const sequence = (0, r_value_2.isRNumberValue)(leftValue) && (0, r_value_2.isRNumberValue)(rightValue) ? createNumberSequence(leftValue, rightValue) : undefined;
130
+ return sequence === undefined ? r_value_3.Top : (0, vector_constants_1.vectorFrom)(sequence.map(scalar_constants_1.liftScalar));
122
131
  }
123
132
  /**
124
133
  * How many elements of a sequence are worth naming one by one. `1:148066` is a loop bound rather than a set of
@@ -23,16 +23,22 @@ const edge_1 = require("./graph/edge");
23
23
  const identify_link_to_last_call_relation_1 = require("../queries/catalog/call-context-query/identify-link-to-last-call-relation");
24
24
  const built_in_function_definition_1 = require("./internal/process/functions/call/built-in/built-in-function-definition");
25
25
  const transitive_side_effects_1 = require("./internal/process/functions/call/built-in/transitive-side-effects");
26
+ const built_in_try_catch_1 = require("./internal/process/functions/call/built-in/built-in-try-catch");
27
+ const linker_1 = require("./internal/linker");
26
28
  const flowr_file_1 = require("../project/context/flowr-file");
29
+ const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
27
30
  const vertex_1 = require("./graph/vertex");
28
31
  const identifier_1 = require("./environments/identifier");
29
32
  const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
30
- const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
33
+ const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
34
+ const r_function_definition_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
31
35
  const range_1 = require("../util/range");
32
36
  const logger_1 = require("./logger");
33
37
  const gas_1 = require("../gas");
34
38
  const config_1 = require("../config");
35
39
  const df_helper_1 = require("./graph/df-helper");
40
+ const built_in_ambient_state_1 = require("./internal/process/functions/call/built-in/built-in-ambient-state");
41
+ const unnamed_call_handling_1 = require("./internal/process/functions/call/unnamed-call-handling");
36
42
  const built_in_proc_name_1 = require("./environments/built-in-proc-name");
37
43
  const arrays_1 = require("../util/collections/arrays");
38
44
  const defaultmap_1 = require("../util/collections/defaultmap");
@@ -42,6 +48,7 @@ const query_fn_props_1 = require("./environments/query-fn-props");
42
48
  const resolve_helper_1 = require("./environments/resolve-helper");
43
49
  const happens_before_1 = require("../control-flow/happens-before");
44
50
  const assert_1 = require("../util/assert");
51
+ const frame_reflection_1 = require("./fn/frame-reflection");
45
52
  /**
46
53
  * The best friend of {@link produceDataFlowGraph} and {@link processDataflowFor}.
47
54
  * Maps every {@link RType} in the normalized AST to a processor.
@@ -95,10 +102,7 @@ function linkEnvironmentArgumentsWrittenByCallee(graph, environment) {
95
102
  if (!holdsEnvironment(graph, argument, environment)) {
96
103
  continue;
97
104
  }
98
- for (const [call, handed] of graph.edgesTo(argument)) {
99
- if (!edge_1.DfEdge.includesType(handed, edge_1.EdgeType.Argument) || !vertex_1.DfgVertex.isFunctionCall(graph.getVertex(call))) {
100
- continue;
101
- }
105
+ for (const call of (0, frame_reflection_1.edgeSources)(graph, argument, edge_1.EdgeType.Argument).filter(c => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(c)))) {
102
106
  (0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, call);
103
107
  for (const write of writes) {
104
108
  graph.addEdge(call, write, edge_1.EdgeType.Reads);
@@ -110,76 +114,151 @@ function linkEnvironmentArgumentsWrittenByCallee(graph, environment) {
110
114
  }
111
115
  function tracksAnyEnvironment(environment) {
112
116
  for (let e = environment.current; e !== undefined && !e.builtInEnv; e = e.parent) {
113
- for (const [, defs] of e.memory) {
114
- for (const def of defs) {
115
- if ((0, identifier_1.hasEnvState)(def)) {
116
- return true;
117
- }
118
- }
117
+ if (e.memory.values().some(defs => defs.some(identifier_1.hasEnvState))) {
118
+ return true;
119
119
  }
120
120
  }
121
121
  return false;
122
122
  }
123
+ /** Collects, per parameter of `definition`, the replacements (`x$f <- v`) and the side-effecting calls in its body that write into it. */
123
124
  function writesOfParameters(graph, definition, parameters, written, environment) {
124
125
  for (const node of definition.subflow.graph) {
125
126
  const vertex = graph.getVertex(node);
126
- if (!vertex_1.DfgVertex.isVariableDefinition(vertex) || !vertex.par) {
127
- if (vertex_1.DfgVertex.isFunctionCall(vertex) && graph.unknownSideEffects.has(node_id_1.NodeId.normalize(node))) {
128
- for (const target of argsWithProp(vertex, (0, query_fn_props_1.callFnProps)(node, { graph, environment }), built_in_props_1.ArgProp.Written)) {
129
- for (const reached of definitionsReachedBy(target, graph)) {
130
- if (parameters.has(reached)) {
131
- written.get(reached).push(node);
132
- }
127
+ if (vertex_1.DfgVertex.isVariableDefinition(vertex) && vertex.par) {
128
+ const replacements = (0, frame_reflection_1.edgeTargets)(graph, node, edge_1.EdgeType.DefinedBy).filter(t => vertex_1.DfgVertex.hasOrigin(graph.getVertex(t), built_in_proc_name_1.BuiltInProcName.Replacement));
129
+ for (const parameter of (0, frame_reflection_1.edgeTargets)(graph, node, edge_1.EdgeType.Reads).filter(t => parameters.has(t))) {
130
+ written.get(parameter).push(...replacements);
131
+ }
132
+ }
133
+ else if (vertex_1.DfgVertex.isFunctionCall(vertex) && graph.unknownSideEffects.has(node_id_1.NodeId.normalize(node))) {
134
+ for (const target of argsWithProp(vertex, (0, query_fn_props_1.callFnProps)(node, { graph, environment }), built_in_props_1.ArgProp.Written)) {
135
+ for (const reached of definitionsReachedBy(target, graph)) {
136
+ if (parameters.has(reached)) {
137
+ written.get(reached).push(node);
133
138
  }
134
139
  }
135
140
  }
141
+ }
142
+ }
143
+ }
144
+ function holdsEnvironment(graph, argument, environment) {
145
+ const node = graph.idMap?.get(argument);
146
+ return r_symbol_1.RSymbol.is(node) && (resolve_helper_1.Resolve.byName(node.content, environment)?.some(identifier_1.hasEnvState) ?? false);
147
+ }
148
+ function openReadsOfCalledFunctions(graph) {
149
+ const reads = new Map();
150
+ for (const [id, definition] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
151
+ if ((0, frame_reflection_1.edgeSources)(graph, id, edge_1.EdgeType.Calls).length > 0) {
152
+ for (const read of definition.subflow.in) {
153
+ if (read.name !== undefined && !built_in_ambient_state_1.AmbientStateName.is(read.name) && !identifier_1.Identifier.getName(read.name).startsWith(unnamed_call_handling_1.UnnamedFunctionCallPrefix)) {
154
+ reads.set(read.nodeId, read);
155
+ }
156
+ }
157
+ }
158
+ }
159
+ return [...reads.values()];
160
+ }
161
+ /** An active binding (`makeActiveBinding`) runs its function on every assignment to and read of the name, so each becomes a call of it. */
162
+ function callActiveBindings(graph) {
163
+ const bindings = new Map();
164
+ for (const [id] of graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
165
+ const fns = (0, frame_reflection_1.calledDefinitions)(graph, id);
166
+ if (fns.length > 0) {
167
+ bindings.set(id, fns);
168
+ }
169
+ }
170
+ for (const [, ids] of bindings.size === 0 ? [] : (0, frame_reflection_1.definitionsByName)(graph).entries()) {
171
+ const fns = ids.flatMap(id => bindings.get(id) ?? []);
172
+ for (const id of fns.length === 0 ? [] : ids.filter(id => !bindings.has(id))) {
173
+ for (const assignment of (0, frame_reflection_1.edgeSources)(graph, id, edge_1.EdgeType.Returns).filter(a => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(a)))) {
174
+ for (const fn of fns) {
175
+ graph.addEdge(assignment, fn, edge_1.EdgeType.Calls);
176
+ graph.addEdge(id, fn, edge_1.EdgeType.Calls);
177
+ }
178
+ }
179
+ }
180
+ }
181
+ const isActiveBinding = (def) => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(def)) && (0, frame_reflection_1.edgeTargets)(graph, def, edge_1.EdgeType.Calls).length > 0;
182
+ for (const id of graph.vertexIdsOfType(vertex_1.VertexType.Use)) {
183
+ const node = graph.idMap?.get(id);
184
+ if (r_symbol_1.RSymbol.is(node) && (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads).some(isActiveBinding)) {
185
+ graph.updateToFunctionCall({ tag: vertex_1.VertexType.FunctionCall, id, name: node.content, args: [], environment: undefined, onlyBuiltin: false, cds: graph.getVertex(id)?.cds, origin: [built_in_proc_name_1.BuiltInProcName.Function] });
186
+ }
187
+ }
188
+ }
189
+ /** A call of what a closure returned that we could not link (`h2 <- h()` with `h` returning `sys.function()`) may run anything. */
190
+ function markCallsOfUnknownValues(graph, environment) {
191
+ const fromClosure = (def) => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(def))
192
+ && (0, frame_reflection_1.edgeTargets)(graph, def, edge_1.EdgeType.DefinedBy).some(c => (0, frame_reflection_1.calledDefinitions)(graph, c).length > 0);
193
+ for (const [id, call] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
194
+ if (!call.onlyBuiltin && (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Calls).length === 0 && (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads).some(fromClosure)) {
195
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(graph, environment, id);
196
+ }
197
+ }
198
+ }
199
+ /** `environment()` hands out the function's frame by reference, so the call reads every definition of the frame, a closure's `<<-` included. */
200
+ function readFramesThroughEnvironment(graph) {
201
+ const idMap = graph.idMap;
202
+ if (idMap === undefined) {
203
+ return;
204
+ }
205
+ const environmentCall = node_id_1.NodeId.toBuiltIn('environment');
206
+ const callsEnvironment = (id) => (0, frame_reflection_1.hasEdgeOfType)(graph, id, environmentCall, edge_1.EdgeType.Calls);
207
+ /* `environment(fn)` hands out the frame `fn` was created in */
208
+ const ofClosures = new defaultmap_1.DefaultMap(() => []);
209
+ for (const [id, call] of graph.verticesOfType(vertex_1.VertexType.FunctionCall)) {
210
+ const fn = call.args.length === 1 && callsEnvironment(id) ? graph_1.FunctionArgument.getReference(call.args[0]) : undefined;
211
+ for (const closure of fn === undefined ? [] : (0, linker_1.getAllLinkedFunctionDefinitions)(new Set([fn]), graph)[0]) {
212
+ const creator = model_1.RNode.strictlyEnclosingFunction(closure.id, idMap);
213
+ if (creator !== undefined) {
214
+ ofClosures.get(creator).push(id);
215
+ }
216
+ }
217
+ }
218
+ for (const [, definition] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
219
+ const frameCalls = ofClosures.get(definition.id);
220
+ if (frameCalls.length === 0 && !definition.subflow.graph.values().some(callsEnvironment)) {
136
221
  continue;
137
222
  }
138
- const onParameter = [];
139
- const replacements = [];
140
- for (const [target, edge] of graph.edgesFrom(node)) {
141
- if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && parameters.has(target)) {
142
- onParameter.push(target);
223
+ /* the nested functions' bodies, too, where a closure may write the frame */
224
+ const within = [...definition.subflow.graph];
225
+ for (const id of within) {
226
+ const vertex = graph.getVertex(id);
227
+ if (vertex_1.DfgVertex.isFunctionDefinition(vertex) && vertex.id !== definition.id) {
228
+ within.push(...vertex.subflow.graph);
143
229
  }
144
- else if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy) && vertex_1.DfgVertex.hasOrigin(graph.getVertex(target), built_in_proc_name_1.BuiltInProcName.Replacement)) {
145
- replacements.push(target);
230
+ }
231
+ const definitions = [];
232
+ for (const id of new Set(within)) {
233
+ const vertex = graph.getVertex(id);
234
+ const own = model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is) === definition.id;
235
+ if (own && vertex_1.DfgVertex.isFunctionCall(vertex) && vertex.args.length === 0 && callsEnvironment(id)) {
236
+ frameCalls.push(id);
237
+ }
238
+ else if (vertex_1.DfgVertex.isVariableDefinition(vertex) && !(id in definition.params)) {
239
+ /* a parameter is what the call binds, which reflecting on the frame already accounts for */
240
+ definitions.push({ id, own, name: node_id_1.NodeId.recoverName(id, idMap) });
146
241
  }
147
242
  }
148
- for (const parameter of onParameter) {
149
- written.get(parameter).push(...replacements);
243
+ const local = new Set(definitions.filter(d => d.own && d.name !== undefined).map(d => d.name));
244
+ /* a nested definition writes this frame only by `<<-` to a name it binds */
245
+ const bySuperAssignment = (id) => vertex_1.DfgVertex.hasOrigin(graph.getVertex(idMap.get(id)?.info.parent ?? ''), built_in_proc_name_1.BuiltInProcName.SuperAssignment);
246
+ for (const d of definitions.filter(d => local.has(d.name ?? '') && (d.own || bySuperAssignment(d.id)))) {
247
+ for (const call of frameCalls) {
248
+ graph.addEdge(call, d.id, edge_1.EdgeType.Reads);
249
+ }
150
250
  }
151
251
  }
152
252
  }
153
253
  function argsWithProp(vertex, info, prop) {
154
254
  return info?.sig === undefined ? [] : match_args_1.MatchArgs.findWithProps(vertex.args, info.sig, prop);
155
255
  }
156
- function holdsEnvironment(graph, argument, environment) {
157
- const node = graph.idMap?.get(argument);
158
- if (!r_symbol_1.RSymbol.is(node)) {
159
- return false;
160
- }
161
- return (resolve_helper_1.Resolve.byName(node.content, environment) ?? [])
162
- .some(identifier_1.hasEnvState);
163
- }
164
256
  function definitionsReachedBy(node, graph) {
165
257
  return df_helper_1.Dataflow.reachable(graph, node, {
166
258
  follow: edge_1.EdgeType.Reads,
167
259
  stopAt: id => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(id))
168
260
  });
169
261
  }
170
- function sameResource(a, b, reachedBy, pathOf) {
171
- if (a === b) {
172
- return true;
173
- }
174
- const reachedByA = reachedBy(a);
175
- for (const t of reachedBy(b)) {
176
- if (reachedByA.has(t)) {
177
- return true;
178
- }
179
- }
180
- const path = pathOf(a);
181
- return path !== undefined && path === pathOf(b);
182
- }
183
262
  function fileCallNames(index) {
184
263
  return new Set(index.with(built_in_props_1.SemanticCallTag.File).map(identifier_1.Identifier.getName));
185
264
  }
@@ -211,10 +290,10 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
211
290
  continue;
212
291
  }
213
292
  const resource = argsWithProp(vertex, info, built_in_props_1.ArgProp.Resource)[0];
214
- if (resource === undefined) {
215
- continue; /* writing to the console names no file, and neither does a reader we cannot pin down */
293
+ /* writing to the console names no file, and neither does a reader we cannot pin down */
294
+ if (resource !== undefined) {
295
+ (reads ? readers : writers).push({ id, resource });
216
296
  }
217
- (reads ? readers : writers).push({ id, resource });
218
297
  }
219
298
  if (readers.length === 0 || writers.length === 0) {
220
299
  return;
@@ -222,16 +301,49 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
222
301
  const reachedBy = (0, defaultmap_1.memoize)((id) => definitionsReachedBy(id, graph));
223
302
  const where = { graph, idMap: graph.idMap, resolve: ctx.config.solver.variables, ctx, environment };
224
303
  const pathOf = (0, defaultmap_1.memoize)((id) => resolve_helper_1.Resolve.toSingleString(id, where));
304
+ const sameResource = (a, b) => {
305
+ if (a === b || reachedBy(b).values().some(t => reachedBy(a).has(t))) {
306
+ return true;
307
+ }
308
+ const path = pathOf(a);
309
+ return path !== undefined && path === pathOf(b);
310
+ };
225
311
  let cfg;
226
312
  for (const reader of readers) {
227
313
  let before;
228
314
  for (const writer of writers) {
229
- if (reader.id === writer.id || !sameResource(reader.resource, writer.resource, reachedBy, pathOf)) {
315
+ if (reader.id === writer.id || !sameResource(reader.resource, writer.resource)) {
230
316
  continue;
231
317
  }
232
318
  before ??= (0, happens_before_1.reachableTo)(cfg ??= new control_flow_graph_1.ControlFlowGraph(graph), [reader.id]);
233
319
  if (before.has(writer.id)) {
234
320
  graph.addEdge(reader.id, writer.id, edge_1.EdgeType.Reads);
321
+ /* whatever is linked to a diverting writer (`print` after `sink(file)`) writes to the resource as well */
322
+ for (const id of (0, frame_reflection_1.edgeSources)(graph, writer.id, edge_1.EdgeType.Reads)) {
323
+ graph.addEdge(reader.id, id, edge_1.EdgeType.Reads);
324
+ }
325
+ }
326
+ }
327
+ }
328
+ }
329
+ /** A variable read linked to a call diverting the output (`sink(con)`, see `AmbientStateName.textConnection`) also reads what that call diverts. */
330
+ function linkReadsOfDivertedOutput(graph, environment) {
331
+ if (!(0, built_in_ambient_state_1.mayForce)(environment)) {
332
+ return;
333
+ }
334
+ const printsOf = (0, defaultmap_1.memoize)((id) => function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(id, { graph, environment }), [built_in_props_1.SemanticCallTag.Prints]));
335
+ const printingCall = (writer) => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(writer)) && printsOf(writer);
336
+ const writersOf = (0, defaultmap_1.memoize)((target) => (0, frame_reflection_1.edgeSources)(graph, target, edge_1.EdgeType.Reads).filter(printingCall));
337
+ for (const [id] of graph.verticesOfType(vertex_1.VertexType.Use)) {
338
+ for (const target of (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads)) {
339
+ const diverting = graph.getVertex(target);
340
+ if (!vertex_1.DfgVertex.isFunctionCall(diverting) || diverting.args.length === 0) {
341
+ continue;
342
+ }
343
+ for (const writer of writersOf(target)) {
344
+ if (writer !== id) {
345
+ graph.addEdge(id, writer, edge_1.EdgeType.Reads);
346
+ }
235
347
  }
236
348
  }
237
349
  }
@@ -240,12 +352,12 @@ function resolveLinkToSideEffects(graph, ctx) {
240
352
  const gasLevel = ctx.gas.checkGas(gas_1.GasFeatureKey.SideEffectLinking);
241
353
  if (gasLevel >= 2 /* GasLevel.Critical */) {
242
354
  logger_1.dataflowLogger.warn('Skipping side-effect link resolution due to resource pressure (gas: critical). See ' + gas_1.GasWikiRef);
243
- return undefined;
355
+ return;
244
356
  }
245
357
  else if (gasLevel >= 1 /* GasLevel.Problematic */) {
246
358
  logger_1.dataflowLogger.warn('Approaching resource limits during side-effect link resolution (gas: problematic). See ' + gas_1.GasWikiRef);
247
359
  }
248
- let cf = undefined;
360
+ let cf;
249
361
  let knownCalls;
250
362
  let allCallNames = [];
251
363
  const killedRegexes = new Set();
@@ -268,11 +380,10 @@ function resolveLinkToSideEffects(graph, ctx) {
268
380
  handled.add(s.id);
269
381
  const regexKey = s.linkTo.callName.source + '//' + s.linkTo.callName.flags;
270
382
  if (killedRegexes.has(regexKey)) {
271
- // we already know we will not find it!
272
383
  continue;
273
384
  }
274
385
  else if (allCallNames.length > 0 && !allCallNames.some(name => s.linkTo.callName.test(name))) {
275
- // we know no call matches the regex
386
+ /* we know no call matches the regex */
276
387
  killedRegexes.add(regexKey);
277
388
  continue;
278
389
  }
@@ -326,13 +437,17 @@ function extractDataFlowGraph(parser, completeAst, ctx) {
326
437
  df = (0, built_in_source_1.standaloneSourceFile)(i, files[i], dfData, df);
327
438
  }
328
439
  // resolve linkages and propagate transitive side effects across calls to a fixpoint
440
+ callActiveBindings(df.graph);
441
+ readFramesThroughEnvironment(df.graph);
329
442
  (0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment, ctx);
330
443
  const escapedNames = new Set();
331
444
  /* carried across the rounds, so a definition already folded in does not read as growth again */
332
445
  const foldedIn = new Set();
333
446
  const rounds = ctx.config.solver.transitiveSideEffectRounds ?? config_1.DefaultTransitiveSideEffectRounds;
447
+ /* a read of the options or graphics state nothing set reads the state R starts with, unless a write escaping a call replaces it */
448
+ const [initialState, open] = (0, arrays_1.partitionArray)(df.in, r => built_in_ambient_state_1.AmbientStateName.is(r.name));
334
449
  for (let round = 0; round < rounds; round++) {
335
- const { environment, grew, escapedNames: roundNames } = df_helper_1.Dataflow.sideEffects.propagateTransitive(df.graph, df.environment, ctx, foldedIn);
450
+ const { environment, grew, escapedNames: roundNames } = df_helper_1.Dataflow.sideEffects.propagateTransitive(df.graph, df.environment, ctx, foldedIn, initialState);
336
451
  df.environment = environment;
337
452
  for (const n of roundNames) {
338
453
  escapedNames.add(n);
@@ -342,16 +457,23 @@ function extractDataFlowGraph(parser, completeAst, ctx) {
342
457
  }
343
458
  (0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment, ctx);
344
459
  }
460
+ markCallsOfUnknownValues(df.graph, df.environment);
461
+ df.in = open.concat(openReadsOfCalledFunctions(df.graph));
345
462
  // resolve top-level reads that now see the escaped `<<-` definitions folded in above
346
463
  if (escapedNames.size > 0) {
347
464
  (0, transitive_side_effects_1.reResolveOpenReferences)(df.graph, df.environment, [...df.in, ...df.unknownReferences], escapedNames);
348
465
  }
349
466
  // link on-demand-materialized package exports back to their `library()` loaders
350
467
  (0, transitive_side_effects_1.linkMaterializedExportsToLoaders)(df.graph, df.environment);
468
+ const cleanEnvironment = ctx.env.makeCleanEnv();
469
+ (0, linker_1.separateClosureInstances)(df.graph, name => (0, query_fn_props_1.queryFnProps)(name, { environment: cleanEnvironment }));
351
470
  function_semantics_1.FunctionSemantics.call.quoted.finalize(df.graph, df.environment, completeAst.idMap, () => new control_flow_graph_1.ControlFlowGraph(df.graph));
471
+ (0, built_in_try_catch_1.orderRaisingBodies)(df.graph, completeAst.idMap, ctx);
472
+ function_semantics_1.FunctionSemantics.settleJumpsInPromises(df.graph, df.exitPoints, { ctx });
352
473
  linkEnvironmentArgumentsWrittenByCallee(df.graph, df.environment);
353
- linkResourceReadersToWriters(df.graph, df.environment, ctx);
354
474
  resolveLinkToSideEffects(df.graph, ctx);
475
+ linkResourceReadersToWriters(df.graph, df.environment, ctx);
476
+ linkReadsOfDivertedOutput(df.graph, df.environment);
355
477
  return df;
356
478
  }
357
479
  //# sourceMappingURL=extractor.js.map
@@ -3,11 +3,12 @@
3
3
  * which argument means what is configured per built-in in {@link ClassDeclarationConfig}, not guessed.
4
4
  */
5
5
  import type { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
6
- import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
7
- import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
+ import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
7
+ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import { type PotentiallyEmptyRArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
9
9
  import type { DataflowGraph } from '../graph/graph';
10
10
  import type { SigClassInfo } from '../../project/sigdb/schema';
11
+ import type { ResolveInfo } from '../eval/resolve/alias-tracking';
11
12
  /** The object system a declaration belongs to. */
12
13
  export declare const enum ClassSystem {
13
14
  /** `setClass`, `setClassUnion`, `setIs`, `setValidity` */
@@ -89,13 +90,6 @@ export interface ClassDeclarationConfig {
89
90
  }
90
91
  /** The argument `ref` names, by name when the call gives one and by position among the unnamed ones otherwise. */
91
92
  export declare function argForImpl<Info>(args: readonly PotentiallyEmptyRArgument<Info & ParentInformation>[], ref: ClassArgRef | undefined): RNode<Info & ParentInformation> | undefined;
92
- /**
93
- * The argument `ref` names, by name when the call gives one and by position among the unnamed ones otherwise.
94
- * Exported so `built-in-s-four.ts` can drop its own copy of this instead of hand-rolling it again; that file
95
- * already imports {@link ClassArgRef} from here, so the reverse import would cycle.
96
- * @deprecated use {@link argForImpl} instead
97
- */
98
- export declare function argFor<Info>(args: readonly PotentiallyEmptyRArgument<Info & ParentInformation>[], ref: ClassArgRef | undefined): RNode<Info & ParentInformation> | undefined;
99
93
  /**
100
94
  * Reads the {@link ClassDeclaration} a call states, following the argument mapping its built-in declares.
101
95
  * An argument that resolves to no literal contributes a {@link ClassDeclaration.byVariable|by-variable} name, or nothing.
@@ -110,8 +104,6 @@ export interface DeclaredClass extends ClassDeclaration {
110
104
  }
111
105
  /** Every class the graph declares, keyed by name. A later declaration of the same name wins, as it would in R. */
112
106
  export declare function declaredClassesImpl(graph: DataflowGraph): Map<string, DeclaredClass>;
113
- /** @deprecated use {@link declaredClassesImpl} instead */
114
- export declare function declaredClasses(graph: DataflowGraph): Map<string, DeclaredClass>;
115
107
  /**
116
108
  * The transitive superclasses of `name` among `classes`, nearest first and each named once. A class the
117
109
  * analysis never saw declared ends the chain, so what another package contributes is simply not in the answer.
@@ -122,5 +114,8 @@ export declare function superClassesOfImpl(name: string, classes: ReadonlyMap<st
122
114
  * the analysis declared carries no `package`; a referenced class `ownerOf` can place becomes a `foreign` record.
123
115
  */
124
116
  export declare function toSigClassesImpl(classes: ReadonlyMap<string, DeclaredClass>, ownerOf?: (name: string) => string | undefined): SigClassInfo[];
125
- /** @deprecated use {@link toSigClassesImpl} instead */
126
- export declare function toSigClasses(classes: ReadonlyMap<string, DeclaredClass>, ownerOf?: (name: string) => string | undefined): SigClassInfo[];
117
+ /** The class vectors S3 dispatch may see for the argument at `id`, one per reaching definition, `undefined` unless all are known. */
118
+ export declare function s3DispatchClassesOf(id: NodeId, info: ResolveInfo & {
119
+ readonly graph: DataflowGraph;
120
+ readonly idMap: AstIdMap;
121
+ }): readonly (readonly string[])[] | undefined;