@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
@@ -21,7 +21,7 @@ interface S7GenericDispatchConfig {
21
21
  export declare function processS7NewGeneric<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S7GenericDispatchConfig): DataflowInformation;
22
22
  /**
23
23
  * Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
24
- * `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, …). We model the result as a
24
+ * `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, ...). We model the result as a
25
25
  * synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
26
26
  * constant.
27
27
  */
@@ -14,6 +14,7 @@ const edge_1 = require("../../../../../graph/edge");
14
14
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
15
15
  const assert_1 = require("../../../../../../util/assert");
16
16
  const identifier_1 = require("../../../../../environments/identifier");
17
+ const resolve_helper_1 = require("../../../../../environments/resolve-helper");
17
18
  const node_value_1 = require("../../../../../eval/resolve/node-value");
18
19
  const vertex_1 = require("../../../../../graph/vertex");
19
20
  const range_1 = require("../../../../../../util/range");
@@ -29,16 +30,15 @@ function processS7NewGeneric(name, args, rootId, data, config) {
29
30
  logger_1.dataflowLogger.warn('empty s7 new_generic, skipping');
30
31
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
31
32
  }
32
- const params = {
33
+ const { dispatchArg } = config.args;
34
+ const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
33
35
  [config.args.name]: 'name',
34
- };
35
- if (config.args.dispatchArg) {
36
- params[config.args.dispatchArg] = 'dispatchArg';
37
- }
38
- params[config.args.fun] = 'fun';
39
- params['...'] = '...';
40
- const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
41
- const genName = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('name')?.[0]));
36
+ ...dispatchArg ? { [dispatchArg]: 'dispatchArg' } : {},
37
+ [config.args.fun]: 'fun',
38
+ '...': '...'
39
+ });
40
+ const argNamed = (formal) => (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get(formal)?.[0]));
41
+ const genName = argNamed('name');
42
42
  if (!genName) {
43
43
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
44
44
  }
@@ -48,14 +48,12 @@ function processS7NewGeneric(name, args, rootId, data, config) {
48
48
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
49
49
  }
50
50
  data = { ...data, currentS7name: accessedIdentifiers };
51
- let funArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('fun')?.[0]))?.info.id;
51
+ let funArg = argNamed('fun')?.info.id;
52
52
  const effectiveArgs = args.slice();
53
53
  if (!funArg) {
54
- const dispatchArg = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('dispatchArg')?.[0]));
55
- const newFun = makeS7DispatchFDef(name, [dispatchArg?.lexeme ?? undefined], rootId, args.length, data.completeAst.idMap);
56
- // fake it 'function([dispatch_args],...) S7_dispatch()'
57
- effectiveArgs.push(newFun[0]);
58
- funArg = newFun[1];
54
+ const [fun, funId] = makeS7DispatchFDef(name, [argNamed('dispatchArg')?.lexeme], rootId, args.length, data.completeAst.idMap);
55
+ effectiveArgs.push(fun);
56
+ funArg = funId;
59
57
  }
60
58
  const info = (0, known_call_handling_1.processKnownFunctionCall)({ name, sig: function_semantics_1.FunctionSemantics.call.signature.every, args: effectiveArgs, rootId, data, origin: built_in_proc_name_1.BuiltInProcName.S7NewGeneric }).information;
61
59
  info.graph.addEdge(rootId, funArg, edge_1.EdgeType.Returns);
@@ -71,7 +69,7 @@ function processS7NewGeneric(name, args, rootId, data, config) {
71
69
  }
72
70
  /**
73
71
  * Process a call that **returns a function**: S7/S4 constructor factories (`make_constructor`, `new_class`,
74
- * `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, …). We model the result as a
72
+ * `setClass`) and generic function factories (`Negate`, `Vectorize`, `partial`, ...). We model the result as a
75
73
  * synthetic function definition so the assigned symbol is recognized as a **function** rather than a plain
76
74
  * constant.
77
75
  */
@@ -83,7 +81,8 @@ function processMakeConstructor(name, args, rootId, data, config) {
83
81
  info.entryPoint = funId;
84
82
  const fArg = info.graph.getVertex(funId);
85
83
  if (vertex_1.DfgVertex.isFunctionDefinition(fArg) && config?.mode) {
86
- fArg.mode ??= config.mode.slice(); // copy: mode is mutated in place later, config.mode is shared
84
+ /* a copy, as the mode is mutated in place later and config.mode is shared */
85
+ fArg.mode ??= config.mode.slice();
87
86
  }
88
87
  if (config?.wrapIndex !== undefined) {
89
88
  linkWrappedFunction(info, args, rootId, config.wrapIndex, config.wrapName, data);
@@ -94,25 +93,25 @@ function processMakeConstructor(name, args, rootId, data, config) {
94
93
  }
95
94
  /** Records on the call vertex what a class-declaring call states, see {@link DataflowGraphVertexFunctionCall.classDecl}. */
96
95
  function attachClassDeclaration(info, rootId, args, config) {
97
- if (config === undefined) {
98
- return;
99
- }
100
96
  const vertex = info.graph.getVertex(rootId);
101
- if (vertex_1.DfgVertex.isFunctionCall(vertex)) {
97
+ if (config !== undefined && vertex_1.DfgVertex.isFunctionCall(vertex)) {
102
98
  vertex.classDecl = function_semantics_1.FunctionSemantics.classes.of(config, args);
103
99
  }
104
100
  }
105
101
  function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
106
102
  const wrapped = (0, class_declaration_1.argForImpl)(args, { name: wrapName, idx: wrapIndex });
107
- if (wrapped === undefined) {
103
+ const resolved = wrapped === undefined ? undefined : (0, built_in_apply_1.resolveFunctionArgument)(wrapped, data, {});
104
+ if (resolved === undefined) {
108
105
  return;
109
106
  }
110
- const resolved = (0, built_in_apply_1.resolveFunctionArgument)(wrapped, data, {});
111
- if (resolved === undefined || resolved.anonymous) {
112
- return;
107
+ const body = rootId + '-s7-new-generic-fun-body';
108
+ /* the wrapper runs what it wraps, so a call of it does what the wrapped function does */
109
+ const targets = resolved.anonymous ? [resolved.functionId] : (resolve_helper_1.Resolve.byNameAndType(resolved.functionName, data.environment, identifier_1.ReferenceType.Function) ?? [])
110
+ .flatMap(d => d.type === identifier_1.ReferenceType.BuiltInFunction ? [d.nodeId] : d.value ?? []);
111
+ for (const target of targets) {
112
+ info.graph.addEdge(body, target, edge_1.EdgeType.Calls);
113
113
  }
114
- const vertex = info.graph.getVertex(resolved.functionId);
115
- if (!vertex_1.DfgVertex.isUse(vertex)) {
114
+ if (resolved.anonymous || !vertex_1.DfgVertex.isUse(info.graph.getVertex(resolved.functionId))) {
116
115
  return;
117
116
  }
118
117
  info.graph.updateToFunctionCall({
@@ -125,7 +124,7 @@ function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
125
124
  cds: data.cds,
126
125
  origin: [built_in_proc_name_1.BuiltInProcName.Function]
127
126
  });
128
- info.graph.addEdge(rootId + '-s7-new-generic-fun-body', resolved.functionId, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
127
+ info.graph.addEdge(body, resolved.functionId, edge_1.EdgeType.Reads | edge_1.EdgeType.Calls);
129
128
  }
130
129
  /**
131
130
  * Node-id suffix of the `fun = function(...) S7_dispatch()` argument flowR synthesizes for S7 calls that do not
@@ -133,41 +132,17 @@ function linkWrappedFunction(info, args, rootId, wrapIndex, wrapName, data) {
133
132
  * about how the *code* calls a function (e.g. matching a call against a package's signature history) must skip it.
134
133
  */
135
134
  exports.S7SyntheticFunArgSuffix = '-s7-new-generic-fun-arg';
136
- // 'function([dispatch_args],...) S7_dispatch()'; returns the value id
135
+ /** Synthesizes the argument `fun = function([dispatch_args], ...) S7_dispatch()`, returning it and the id of its value. */
137
136
  function makeS7DispatchFDef(name, names, rootId, args, idMap) {
138
- const argNameId = rootId + '-s7-new-generic-fun-arg-name';
139
137
  const r = name.location ?? range_1.SourceRange.invalid();
140
- const argName = {
141
- type: type_1.RType.Symbol,
142
- lexeme: 'fun',
143
- content: 'fun',
144
- info: {
145
- id: argNameId,
146
- nest: name.info.nest,
147
- role: "arg-n" /* RoleInParent.ArgumentName */,
148
- fullRange: r,
149
- adToks: undefined,
150
- file: name.info.file,
151
- parent: rootId,
152
- index: 0
153
- },
154
- location: r,
155
- };
156
- idMap.set(argNameId, argName);
157
- const funcNameId = rootId + '-s7-new-generic-fun-name';
138
+ const info = (id, role, parent, index = 0) => ({ id, nest: name.info.nest, role, fullRange: r, adToks: undefined, file: name.info.file, parent, index });
139
+ const symbol = (id, lexeme, role, parent, index = 0) => ({ type: type_1.RType.Symbol, lexeme, content: lexeme, info: info(id, role, parent, index), location: r });
140
+ const argName = symbol(rootId + '-s7-new-generic-fun-arg-name', 'fun', "arg-n" /* RoleInParent.ArgumentName */, rootId);
141
+ idMap.set(argName.info.id, argName);
158
142
  const funcName = {
159
143
  type: type_1.RType.Symbol,
160
144
  lexeme: 'S7_dispatch',
161
- info: {
162
- id: funcNameId,
163
- nest: name.info.nest,
164
- role: "call-name" /* RoleInParent.FunctionCallName */,
165
- fullRange: r,
166
- adToks: undefined,
167
- file: name.info.file,
168
- parent: rootId,
169
- index: 0
170
- },
145
+ info: info(rootId + '-s7-new-generic-fun-name', "call-name" /* RoleInParent.FunctionCallName */, rootId),
171
146
  location: r,
172
147
  content: identifier_1.Identifier.make('S7_dispatch', 'S7'),
173
148
  };
@@ -178,51 +153,17 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
178
153
  named: true,
179
154
  functionName: funcName,
180
155
  arguments: [],
181
- info: {
182
- id: rootId + '-s7-new-generic-fun-body',
183
- nest: name.info.nest,
184
- role: "fun-b" /* RoleInParent.FunctionDefinitionBody */,
185
- fullRange: r,
186
- adToks: undefined,
187
- file: name.info.file,
188
- parent: rootId,
189
- index: 0
190
- }
156
+ info: info(rootId + '-s7-new-generic-fun-body', "fun-b" /* RoleInParent.FunctionDefinitionBody */, rootId)
191
157
  };
192
158
  const fdefId = rootId + '-s7-new-generic-fun-fdef';
193
159
  const argValue = {
194
160
  type: type_1.RType.FunctionDefinition,
195
- info: {
196
- file: name.info.file,
197
- id: fdefId,
198
- nest: name.info.nest,
199
- role: "arg-v" /* RoleInParent.ArgumentValue */,
200
- parent: rootId,
201
- index: args + 1,
202
- adToks: undefined,
203
- fullRange: r,
204
- },
161
+ info: info(fdefId, "arg-v" /* RoleInParent.ArgumentValue */, rootId, args + 1),
205
162
  lexeme: 'function',
206
163
  location: r,
207
164
  parameters: [...names.filter(assert_1.isNotUndefined), '...'].map((n, i) => {
208
165
  const paramId = fdefId + `-param-${i}`;
209
- const paramNameId = paramId + '-name';
210
- const paramName = {
211
- type: type_1.RType.Symbol,
212
- lexeme: n,
213
- content: n,
214
- info: {
215
- id: paramNameId,
216
- nest: name.info.nest,
217
- role: "param-n" /* RoleInParent.ParameterName */,
218
- fullRange: r,
219
- adToks: undefined,
220
- file: name.info.file,
221
- index: i,
222
- parent: paramId
223
- },
224
- location: r,
225
- };
166
+ const paramName = symbol(paramId + '-name', n, "param-n" /* RoleInParent.ParameterName */, paramId, i);
226
167
  const param = {
227
168
  type: type_1.RType.Parameter,
228
169
  location: r,
@@ -230,41 +171,22 @@ function makeS7DispatchFDef(name, names, rootId, args, idMap) {
230
171
  name: paramName,
231
172
  defaultValue: undefined,
232
173
  special: n === '...',
233
- info: {
234
- id: paramId,
235
- nest: name.info.nest,
236
- role: "param" /* RoleInParent.FunctionDefinitionParameter */,
237
- parent: fdefId,
238
- index: i,
239
- adToks: undefined,
240
- file: name.info.file,
241
- fullRange: r,
242
- }
174
+ info: info(paramId, "param" /* RoleInParent.FunctionDefinitionParameter */, fdefId, i)
243
175
  };
244
- idMap.set(paramNameId, paramName);
176
+ idMap.set(paramName.info.id, paramName);
245
177
  idMap.set(paramId, param);
246
178
  return param;
247
179
  }),
248
180
  body: funcBody,
249
181
  };
250
- idMap.set(funcNameId, funcName);
182
+ idMap.set(funcName.info.id, funcName);
251
183
  idMap.set(funcBody.info.id, funcBody);
252
184
  idMap.set(fdefId, argValue);
253
- const argId = rootId + exports.S7SyntheticFunArgSuffix;
254
185
  const argument = {
255
186
  type: type_1.RType.Argument,
256
187
  lexeme: 'fun',
257
188
  location: r,
258
- info: {
259
- id: argId,
260
- nest: name.info.nest,
261
- role: "call-arg" /* RoleInParent.FunctionCallArgument */,
262
- fullRange: r,
263
- adToks: undefined,
264
- file: name.info.file,
265
- parent: rootId,
266
- index: args + 1
267
- },
189
+ info: info(rootId + exports.S7SyntheticFunArgSuffix, "call-arg" /* RoleInParent.FunctionCallArgument */, rootId, args + 1),
268
190
  name: argName,
269
191
  value: argValue
270
192
  };
@@ -13,8 +13,6 @@ interface S3DispatchConfig {
13
13
  /** For NextMethod/if `generic` is not given, try to infer from the closure? */
14
14
  inferFromClosure?: boolean;
15
15
  }
16
- /**
17
- * Process an S3 dispatch call like `UseMethod`.
18
- */
16
+ /** Process an S3 dispatch call like `UseMethod`. */
19
17
  export declare function processS3Dispatch<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly PotentiallyEmptyRArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: S3DispatchConfig): DataflowInformation;
20
18
  export {};
@@ -9,6 +9,7 @@ const logger_1 = require("../../../../../logger");
9
9
  const common_1 = require("../common");
10
10
  const unpack_argument_1 = require("../argument/unpack-argument");
11
11
  const node_value_1 = require("../../../../../eval/resolve/node-value");
12
+ const edge_1 = require("../../../../../graph/edge");
12
13
  const identifier_1 = require("../../../../../environments/identifier");
13
14
  const type_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/type");
14
15
  const range_1 = require("../../../../../../util/range");
@@ -17,27 +18,25 @@ const built_in_proc_name_1 = require("../../../../../environments/built-in-proc-
17
18
  const control_flow_1 = require("../../../../control-flow");
18
19
  const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
19
20
  const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
20
- /**
21
- * Process an S3 dispatch call like `UseMethod`.
22
- */
21
+ /** Process an S3 dispatch call like `UseMethod`. */
23
22
  function processS3Dispatch(name, args, rootId, data, config) {
24
23
  if (args.length === 0 && !config.inferFromClosure) {
25
24
  logger_1.dataflowLogger.warn('empty s3, skipping');
26
25
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
27
26
  }
28
- const params = {
27
+ const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), {
29
28
  [config.args.generic]: 'generic',
30
29
  [config.args.object]: 'object',
31
30
  '...': '...'
32
- };
33
- const argMaps = function_semantics_1.FunctionSemantics.call.match.toSpec((0, common_1.convertFnArguments)(args), params);
31
+ });
34
32
  const generic = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('generic')?.[0]));
35
33
  if (!generic && !config.inferFromClosure) {
36
34
  return (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
37
35
  }
38
36
  const obj = (0, unpack_argument_1.unpackArg)(r_argument_1.RArgument.getWithId(args, argMaps.get('object')?.[0]));
39
37
  const dfObj = obj ? (0, processor_1.processDataflowFor)(obj, data) : info_1.DataflowInformation.initialize(rootId, data);
40
- if (control_flow_1.ControlFlow.alwaysExits(dfObj)) {
38
+ const fnRef = { nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function };
39
+ if (control_flow_1.ControlFlow.alwaysExits(dfObj, data.cds)) {
41
40
  (0, common_1.patchFunctionCall)({
42
41
  nextGraph: dfObj.graph,
43
42
  rootId,
@@ -57,24 +56,20 @@ function processS3Dispatch(name, args, rootId, data, config) {
57
56
  argumentProcessResult: [dfObj],
58
57
  origin: built_in_proc_name_1.BuiltInProcName.S3DispatchNext
59
58
  });
60
- const ingoing = dfObj.in.concat(dfObj.unknownReferences);
61
- ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
62
59
  /* the next method receives the current values of the formals of the method it is called from */
63
60
  const idMap = data.completeAst.idMap;
64
61
  const enclosing = idMap.get(model_1.RNode.findEnclosing(rootId, idMap, r_function_definition_1.RFunctionDefinition.is) ?? rootId);
65
- for (const param of r_function_definition_1.RFunctionDefinition.is(enclosing) ? enclosing.parameters : []) {
66
- ingoing.push({ nodeId: rootId, name: param.name.content, cds: data.cds, type: identifier_1.ReferenceType.Variable });
67
- }
68
- const cfgEntry = control_flow_1.ControlFlow.inSequence(dfObj.graph, [dfObj], rootId);
62
+ const formals = r_function_definition_1.RFunctionDefinition.is(enclosing) ? enclosing.parameters : [];
63
+ const formalReads = formals.map(param => ({ nodeId: rootId, name: param.name.content, cds: data.cds, type: identifier_1.ReferenceType.Variable }));
69
64
  return {
70
65
  hooks: dfObj.hooks,
71
66
  environment: dfObj.environment,
72
67
  exitPoints: dfObj.exitPoints,
73
68
  graph: dfObj.graph,
74
69
  entryPoint: rootId,
75
- cfgEntry,
70
+ cfgEntry: control_flow_1.ControlFlow.inSequence(dfObj.graph, [dfObj], rootId),
76
71
  cfgExit: rootId,
77
- in: ingoing,
72
+ in: [...dfObj.in, ...dfObj.unknownReferences, fnRef, ...formalReads],
78
73
  out: dfObj.out,
79
74
  unknownReferences: []
80
75
  };
@@ -108,22 +103,19 @@ function processS3Dispatch(name, args, rootId, data, config) {
108
103
  argumentProcessResult: [dfGeneric, dfObj],
109
104
  origin: built_in_proc_name_1.BuiltInProcName.Function
110
105
  });
111
- const ingoing = dfObj.in.concat(dfGeneric.in, dfObj.unknownReferences, dfGeneric.unknownReferences);
112
- ingoing.push({ nodeId: rootId, name: name.content, cds: data.cds, type: identifier_1.ReferenceType.Function });
113
- for (const id of accessedIdentifiers) {
114
- ingoing.push({ nodeId: generic.info.id, name: id, cds: data.cds, type: identifier_1.ReferenceType.S3MethodPrefix });
115
- }
106
+ /* the method runs only as the dispatch does */
107
+ dfGeneric.graph.addEdge(generic.info.id, rootId, edge_1.EdgeType.Reads);
116
108
  const graph = dfObj.graph.mergeWith(dfGeneric.graph);
117
- const cfgEntry = control_flow_1.ControlFlow.inSequence(graph, [dfGeneric, dfObj], rootId);
109
+ const methodPrefixes = accessedIdentifiers.map(id => ({ nodeId: generic.info.id, name: id, cds: data.cds, type: identifier_1.ReferenceType.S3MethodPrefix }));
118
110
  return {
119
- hooks: dfGeneric.hooks.concat(dfObj?.hooks),
111
+ hooks: dfGeneric.hooks.concat(dfObj.hooks),
120
112
  environment: dfGeneric.environment,
121
113
  exitPoints: dfObj.exitPoints.concat(dfGeneric.exitPoints),
122
114
  graph,
123
115
  entryPoint: rootId,
124
- cfgEntry,
116
+ cfgEntry: control_flow_1.ControlFlow.inSequence(graph, [dfGeneric, dfObj], rootId),
125
117
  cfgExit: rootId,
126
- in: ingoing,
118
+ in: [...dfObj.in, ...dfGeneric.in, ...dfObj.unknownReferences, ...dfGeneric.unknownReferences, fnRef, ...methodPrefixes],
127
119
  out: dfGeneric.out.concat(dfObj.out),
128
120
  unknownReferences: []
129
121
  };
@@ -1,3 +1,4 @@
1
+ import { type AmbientStateAccess } from './built-in-ambient-state';
1
2
  import { type DataflowProcessorInformation } from '../../../../../processor';
2
3
  import { DataflowInformation } from '../../../../../info';
3
4
  import { type FlowrLaxSourcingOptions, InferWorkingDirectory } from '../../../../../../config';
@@ -40,6 +41,7 @@ export declare function processSourceCall<OtherInfo>(name: RSymbol<OtherInfo & P
40
41
  includeFunctionCall?: boolean;
41
42
  /** should this function call be followed, even when the configuration disables it? */
42
43
  forceFollow?: boolean;
44
+ ambient?: AmbientStateAccess | readonly AmbientStateAccess[];
43
45
  }): DataflowInformation;
44
46
  /**
45
47
  * Processes a source request with the given dataflow processor information and existing dataflow information