@eagleoutice/flowr 2.2.14 → 2.2.15

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 (83) hide show
  1. package/README.md +4 -4
  2. package/cli/repl/commands/repl-commands.js +1 -1
  3. package/cli/repl/commands/repl-execute.js +2 -1
  4. package/config.js +1 -1
  5. package/control-flow/basic-cfg-guided-visitor.d.ts +3 -3
  6. package/control-flow/cfg-dead-code.d.ts +4 -0
  7. package/control-flow/cfg-dead-code.js +81 -0
  8. package/control-flow/cfg-simplification.d.ts +17 -6
  9. package/control-flow/cfg-simplification.js +23 -19
  10. package/control-flow/control-flow-graph.d.ts +2 -1
  11. package/control-flow/control-flow-graph.js +1 -0
  12. package/control-flow/dfg-cfg-guided-visitor.d.ts +4 -4
  13. package/control-flow/dfg-cfg-guided-visitor.js +1 -1
  14. package/control-flow/extract-cfg.d.ts +1 -1
  15. package/control-flow/extract-cfg.js +60 -57
  16. package/control-flow/semantic-cfg-guided-visitor.d.ts +17 -8
  17. package/control-flow/semantic-cfg-guided-visitor.js +50 -17
  18. package/control-flow/simple-visitor.d.ts +4 -0
  19. package/control-flow/simple-visitor.js +14 -0
  20. package/control-flow/syntax-cfg-guided-visitor.d.ts +2 -2
  21. package/dataflow/environments/built-in-config.d.ts +1 -0
  22. package/dataflow/environments/built-in.d.ts +10 -1
  23. package/dataflow/environments/built-in.js +9 -3
  24. package/dataflow/environments/default-builtin-config.js +1 -1
  25. package/dataflow/environments/resolve-by-name.d.ts +0 -36
  26. package/dataflow/environments/resolve-by-name.js +0 -240
  27. package/dataflow/eval/resolve/alias-tracking.d.ts +87 -0
  28. package/dataflow/eval/resolve/alias-tracking.js +349 -0
  29. package/dataflow/eval/resolve/resolve.d.ts +34 -0
  30. package/dataflow/eval/resolve/resolve.js +93 -0
  31. package/dataflow/eval/values/general.d.ts +27 -0
  32. package/dataflow/eval/values/general.js +73 -0
  33. package/dataflow/eval/values/intervals/interval-constants.d.ts +4 -0
  34. package/dataflow/eval/values/intervals/interval-constants.js +27 -0
  35. package/dataflow/eval/values/logical/logical-constants.d.ts +7 -0
  36. package/dataflow/eval/values/logical/logical-constants.js +31 -0
  37. package/dataflow/eval/values/r-value.d.ts +58 -0
  38. package/dataflow/eval/values/r-value.js +90 -0
  39. package/dataflow/eval/values/scalar/scalar-consatnts.d.ts +15 -0
  40. package/dataflow/eval/values/scalar/scalar-consatnts.js +35 -0
  41. package/dataflow/eval/values/sets/set-constants.d.ts +7 -0
  42. package/dataflow/eval/values/sets/set-constants.js +34 -0
  43. package/dataflow/eval/values/string/string-constants.d.ts +8 -0
  44. package/dataflow/eval/values/string/string-constants.js +40 -0
  45. package/dataflow/eval/values/vectors/vector-constants.d.ts +14 -0
  46. package/dataflow/eval/values/vectors/vector-constants.js +35 -0
  47. package/dataflow/graph/unknown-replacement.d.ts +11 -0
  48. package/dataflow/graph/unknown-replacement.js +12 -0
  49. package/dataflow/graph/unknown-side-effect.d.ts +7 -0
  50. package/dataflow/graph/unknown-side-effect.js +13 -0
  51. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +8 -5
  52. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +4 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +12 -9
  54. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +5 -4
  55. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +9 -2
  56. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +12 -15
  57. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +23 -0
  58. package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
  59. package/documentation/doc-util/doc-query.d.ts +6 -3
  60. package/documentation/doc-util/doc-query.js +3 -1
  61. package/documentation/print-cfg-wiki.js +6 -6
  62. package/documentation/print-dataflow-graph-wiki.js +4 -3
  63. package/documentation/print-engines-wiki.js +1 -1
  64. package/documentation/print-query-wiki.js +80 -0
  65. package/linter/rules/1-deprecated-functions.js +1 -1
  66. package/linter/rules/2-file-path-validity.js +1 -1
  67. package/package.json +1 -1
  68. package/queries/catalog/control-flow-query/control-flow-query-executor.d.ts +3 -0
  69. package/queries/catalog/control-flow-query/control-flow-query-executor.js +20 -0
  70. package/queries/catalog/control-flow-query/control-flow-query-format.d.ts +81 -0
  71. package/queries/catalog/control-flow-query/control-flow-query-format.js +34 -0
  72. package/queries/catalog/dependencies-query/dependencies-query-executor.js +33 -32
  73. package/queries/catalog/linter-query/linter-query-format.js +2 -1
  74. package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +3 -3
  75. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -1
  76. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -22
  77. package/queries/query.d.ts +61 -1
  78. package/queries/query.js +2 -0
  79. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +11 -4
  80. package/search/search-executor/search-enrichers.js +5 -2
  81. package/slicing/criterion/parse.d.ts +8 -0
  82. package/slicing/criterion/parse.js +20 -0
  83. package/util/version.js +1 -1
@@ -1,5 +1,4 @@
1
1
  import type { CfgExpressionVertex, CfgStatementVertex, ControlFlowInformation } from './control-flow-graph';
2
- import type { DataflowInformation } from '../dataflow/info';
3
2
  import type { DataflowCfgGuidedVisitorConfiguration } from './dfg-cfg-guided-visitor';
4
3
  import { DataflowAwareCfgGuidedVisitor } from './dfg-cfg-guided-visitor';
5
4
  import type { NormalizedAst, ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
@@ -10,12 +9,12 @@ import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefini
10
9
  import type { RString } from '../r-bridge/lang-4.x/ast/model/nodes/r-string';
11
10
  import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
12
11
  import type { RLogical } from '../r-bridge/lang-4.x/ast/model/nodes/r-logical';
13
- import type { FunctionArgument } from '../dataflow/graph/graph';
12
+ import type { DataflowGraph, FunctionArgument } from '../dataflow/graph/graph';
14
13
  import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
15
14
  import type { RSymbol } from '../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
16
15
  import type { BuiltInProcessorMapper } from '../dataflow/environments/built-in';
17
16
  import type { RExpressionList } from '../r-bridge/lang-4.x/ast/model/nodes/r-expression-list';
18
- export interface SemanticCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, Cfg extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Dfg extends DataflowInformation = DataflowInformation> extends DataflowCfgGuidedVisitorConfiguration<Cfg, Dfg>, SyntaxCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast> {
17
+ export interface SemanticCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Dfg extends DataflowGraph = DataflowGraph> extends DataflowCfgGuidedVisitorConfiguration<ControlFlow, Dfg>, SyntaxCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast> {
19
18
  }
20
19
  /**
21
20
  * This visitor extends on the {@link DataflowAwareCfgGuidedVisitor} by dispatching visitors for separate function calls as well,
@@ -40,7 +39,7 @@ export interface SemanticCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, Cfg e
40
39
  *
41
40
  * Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
42
41
  */
43
- export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Dfg extends DataflowInformation = DataflowInformation, Config extends SemanticCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast, Dfg> = SemanticCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast, Dfg>> extends DataflowAwareCfgGuidedVisitor<Cfg, Dfg, Config> {
42
+ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Dfg extends DataflowGraph = DataflowGraph, Config extends SemanticCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast, Dfg> = SemanticCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast, Dfg>> extends DataflowAwareCfgGuidedVisitor<ControlFlow, Dfg, Config> {
44
43
  /**
45
44
  * A helper function to get the normalized AST node for the given id or fail if it does not exist.
46
45
  */
@@ -117,6 +116,11 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends Co
117
116
  * @protected
118
117
  */
119
118
  protected onDispatchFunctionCallOrigin(call: DataflowGraphVertexFunctionCall, origin: keyof typeof BuiltInProcessorMapper | string): void;
119
+ /**
120
+ * This event is called for the root program node, i.e., the program that is being analyzed.
121
+ *
122
+ * @protected
123
+ */
120
124
  protected onProgram(_data: RExpressionList<OtherInfo>): void;
121
125
  /**
122
126
  * A helper function to request the {@link getOriginInDfg|origins} of the given node.
@@ -180,6 +184,7 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends Co
180
184
  */
181
185
  protected onFunctionDefinition(_data: {
182
186
  vertex: DataflowGraphVertexFunctionDefinition;
187
+ parameters?: readonly NodeId[];
183
188
  }): void;
184
189
  /**
185
190
  * This event triggers for every anonymous call within the program.
@@ -211,7 +216,7 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends Co
211
216
  *
212
217
  * This explicitly will not trigger for scenarios in which the function has no name (i.e., if it is anonymous).
213
218
  * For such cases, you may rely on the {@link SemanticCfgGuidedVisitor#onUnnamedCall|`onUnnamedCall`} event.
214
- * The main reason for this separation is part of flowR's handling of these functions, as anonmyous calls cannot be resolved using the active environment.
219
+ * The main reason for this separation is part of flowR's handling of these functions, as anonymous calls cannot be resolved using the active environment.
215
220
  *
216
221
  * @protected
217
222
  */
@@ -282,9 +287,9 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends Co
282
287
  */
283
288
  protected onIfThenElseCall(_data: {
284
289
  call: DataflowGraphVertexFunctionCall;
285
- condition: FunctionArgument;
286
- then: FunctionArgument;
287
- else: FunctionArgument | undefined;
290
+ condition: NodeId | undefined;
291
+ then: NodeId | undefined;
292
+ else: NodeId | undefined;
288
293
  }): void;
289
294
  /**
290
295
  * This event triggers for every call to the `get` function, which is used to access variables in the global environment.
@@ -346,6 +351,8 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends Co
346
351
  */
347
352
  protected onSpecialBinaryOpCall(_data: {
348
353
  call: DataflowGraphVertexFunctionCall;
354
+ lhs?: FunctionArgument;
355
+ rhs?: FunctionArgument;
349
356
  }): void;
350
357
  /**
351
358
  * This event triggers for every call to R's pipe operator, i.e., for every call to `|>`.
@@ -354,6 +361,8 @@ export declare class SemanticCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends Co
354
361
  */
355
362
  protected onPipeCall(_data: {
356
363
  call: DataflowGraphVertexFunctionCall;
364
+ lhs?: FunctionArgument;
365
+ rhs?: FunctionArgument;
357
366
  }): void;
358
367
  /**
359
368
  * This event triggers for every call to the `quote` function, which is used to quote expressions.
@@ -6,6 +6,7 @@ const dfg_get_origin_1 = require("../dataflow/origin/dfg-get-origin");
6
6
  const type_1 = require("../r-bridge/lang-4.x/ast/model/type");
7
7
  const edge_1 = require("../dataflow/graph/edge");
8
8
  const assert_1 = require("../util/assert");
9
+ const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
10
  /**
10
11
  * This visitor extends on the {@link DataflowAwareCfgGuidedVisitor} by dispatching visitors for separate function calls as well,
11
12
  * providing more information!
@@ -90,7 +91,13 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
90
91
  */
91
92
  visitFunctionDefinition(vertex) {
92
93
  super.visitFunctionDefinition(vertex);
93
- this.onFunctionDefinition({ vertex });
94
+ const ast = this.getNormalizedAst(vertex.id);
95
+ if (ast?.type === type_1.RType.FunctionDefinition) {
96
+ this.onFunctionDefinition({ vertex, parameters: ast.parameters.map(p => p.info.id) });
97
+ }
98
+ else {
99
+ this.onFunctionDefinition({ vertex });
100
+ }
94
101
  }
95
102
  /**
96
103
  * See {@link DataflowAwareCfgGuidedVisitor#visitFunctionCall} for the base implementation.
@@ -161,8 +168,26 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
161
168
  return this.onSourceCall({ call });
162
169
  case 'builtin:access':
163
170
  return this.onAccessCall({ call });
164
- case 'builtin:if-then-else':
165
- return this.onIfThenElseCall({ call, condition: call.args[0], then: call.args[1], else: call.args[2] });
171
+ case 'builtin:if-then-else': {
172
+ // recover dead arguments from ast
173
+ const ast = this.getNormalizedAst(call.id);
174
+ if (!ast || ast.type !== type_1.RType.IfThenElse) {
175
+ return this.onIfThenElseCall({
176
+ call,
177
+ condition: call.args[0] === r_function_call_1.EmptyArgument ? undefined : call.args[0].nodeId,
178
+ then: call.args[1] === r_function_call_1.EmptyArgument ? undefined : call.args[1].nodeId,
179
+ else: call.args[2] === r_function_call_1.EmptyArgument ? undefined : call.args[2].nodeId
180
+ });
181
+ }
182
+ else {
183
+ return this.onIfThenElseCall({
184
+ call,
185
+ condition: ast.condition.info.id,
186
+ then: ast.then.info.id,
187
+ else: ast.otherwise?.info.id
188
+ });
189
+ }
190
+ }
166
191
  case 'builtin:get':
167
192
  return this.onGetCall({ call });
168
193
  case 'builtin:rm':
@@ -173,11 +198,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
173
198
  return this.onVectorCall({ call });
174
199
  case 'table:assign':
175
200
  case 'builtin:assignment': {
176
- const outgoing = this.config.dataflow.graph.outgoingEdges(call.id);
201
+ const outgoing = this.config.dfg.outgoingEdges(call.id);
177
202
  if (outgoing) {
178
203
  const target = [...outgoing.entries()].filter(([, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.Returns));
179
204
  if (target.length === 1) {
180
- const targetOut = this.config.dataflow.graph.outgoingEdges(target[0][0]);
205
+ const targetOut = this.config.dfg.outgoingEdges(target[0][0]);
181
206
  if (targetOut) {
182
207
  const source = [...targetOut.entries()].filter(([t, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.DefinedBy) && t !== call.id);
183
208
  if (source.length === 1) {
@@ -189,9 +214,15 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
189
214
  return this.onAssignmentCall({ call, target: undefined, source: undefined });
190
215
  }
191
216
  case 'builtin:special-bin-op':
192
- return this.onSpecialBinaryOpCall({ call });
217
+ if (call.args.length !== 2) {
218
+ return this.onSpecialBinaryOpCall({ call });
219
+ }
220
+ return this.onSpecialBinaryOpCall({ call, lhs: call.args[0], rhs: call.args[1] });
193
221
  case 'builtin:pipe':
194
- return this.onPipeCall({ call });
222
+ if (call.args.length !== 2) {
223
+ return this.onPipeCall({ call });
224
+ }
225
+ return this.onPipeCall({ call, lhs: call.args[0], rhs: call.args[1] });
195
226
  case 'builtin:quote':
196
227
  return this.onQuoteCall({ call });
197
228
  case 'builtin:for-loop':
@@ -201,11 +232,11 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
201
232
  case 'builtin:while-loop':
202
233
  return this.onWhileLoopCall({ call, condition: call.args[0], body: call.args[1] });
203
234
  case 'builtin:replacement': {
204
- const outgoing = this.config.dataflow.graph.outgoingEdges(call.id);
235
+ const outgoing = this.config.dfg.outgoingEdges(call.id);
205
236
  if (outgoing) {
206
237
  const target = [...outgoing.entries()].filter(([, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.Returns));
207
238
  if (target.length === 1) {
208
- const targetOut = this.config.dataflow.graph.outgoingEdges(target[0][0]);
239
+ const targetOut = this.config.dfg.outgoingEdges(target[0][0]);
209
240
  if (targetOut) {
210
241
  const source = [...targetOut.entries()].filter(([t, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.DefinedBy) && t !== call.id);
211
242
  if (source.length === 1) {
@@ -223,13 +254,17 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
223
254
  return this.onDefaultFunctionCall({ call });
224
255
  }
225
256
  }
226
- onProgram(_data) {
227
- }
257
+ /**
258
+ * This event is called for the root program node, i.e., the program that is being analyzed.
259
+ *
260
+ * @protected
261
+ */
262
+ onProgram(_data) { }
228
263
  /**
229
264
  * A helper function to request the {@link getOriginInDfg|origins} of the given node.
230
265
  */
231
266
  getOrigins(id) {
232
- return (0, dfg_get_origin_1.getOriginInDfg)(this.config.dataflow.graph, id);
267
+ return (0, dfg_get_origin_1.getOriginInDfg)(this.config.dfg, id);
233
268
  }
234
269
  /** Called for every occurrence of a `NULL` in the program. */
235
270
  onNullConstant(_data) { }
@@ -300,7 +335,7 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
300
335
  *
301
336
  * This explicitly will not trigger for scenarios in which the function has no name (i.e., if it is anonymous).
302
337
  * For such cases, you may rely on the {@link SemanticCfgGuidedVisitor#onUnnamedCall|`onUnnamedCall`} event.
303
- * The main reason for this separation is part of flowR's handling of these functions, as anonmyous calls cannot be resolved using the active environment.
338
+ * The main reason for this separation is part of flowR's handling of these functions, as anonymous calls cannot be resolved using the active environment.
304
339
  *
305
340
  * @protected
306
341
  */
@@ -351,15 +386,13 @@ class SemanticCfgGuidedVisitor extends dfg_cfg_guided_visitor_1.DataflowAwareCfg
351
386
  *
352
387
  * @protected
353
388
  */
354
- onAccessCall(_data) {
355
- }
389
+ onAccessCall(_data) { }
356
390
  /**
357
391
  * This event triggers for every call to the `if` function, which is used to implement the `if-then-else` control flow.
358
392
  *
359
393
  * @protected
360
394
  */
361
- onIfThenElseCall(_data) {
362
- }
395
+ onIfThenElseCall(_data) { }
363
396
  /**
364
397
  * This event triggers for every call to the `get` function, which is used to access variables in the global environment.
365
398
  *
@@ -23,3 +23,7 @@ export declare function visitCfgInReverseOrder(graph: ControlFlowGraph, startNod
23
23
  * @see {@link visitCfgInReverseOrder} for a traversal in reversed order
24
24
  */
25
25
  export declare function visitCfgInOrder(graph: ControlFlowGraph, startNodes: readonly NodeId[], visitor: (node: NodeId) => boolean | void): void;
26
+ /**
27
+ * Check if a node can reach another node in the control flow graph.
28
+ */
29
+ export declare function canReach(graph: ControlFlowGraph, from: NodeId[], to: NodeId): boolean;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.visitCfgInReverseOrder = visitCfgInReverseOrder;
4
4
  exports.visitCfgInOrder = visitCfgInOrder;
5
+ exports.canReach = canReach;
5
6
  const control_flow_graph_1 = require("./control-flow-graph");
6
7
  /**
7
8
  * Visit all nodes reachable from the start node in the control flow graph, traversing the dependencies but ignoring cycles.
@@ -77,4 +78,17 @@ visitor) {
77
78
  }
78
79
  }
79
80
  }
81
+ /**
82
+ * Check if a node can reach another node in the control flow graph.
83
+ */
84
+ function canReach(graph, from, to) {
85
+ let reached = false;
86
+ visitCfgInOrder(graph, from, node => {
87
+ if (node === to) {
88
+ reached = true;
89
+ return true;
90
+ }
91
+ });
92
+ return reached;
93
+ }
80
94
  //# sourceMappingURL=simple-visitor.js.map
@@ -25,7 +25,7 @@ import type { RNext } from '../r-bridge/lang-4.x/ast/model/nodes/r-next';
25
25
  import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
26
26
  import type { RSymbol } from '../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
27
27
  import type { NoInfo, RNode } from '../r-bridge/lang-4.x/ast/model/model';
28
- export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, Cfg extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>> extends BasicCfgGuidedVisitorConfiguration<Cfg> {
28
+ export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>> extends BasicCfgGuidedVisitorConfiguration<ControlFlow> {
29
29
  readonly normalizedAst: Ast;
30
30
  }
31
31
  /**
@@ -33,7 +33,7 @@ export interface SyntaxCfgGuidedVisitorConfiguration<OtherInfo = NoInfo, Cfg ext
33
33
  *
34
34
  * Use {@link BasicCfgGuidedVisitor#start} to start the traversal.
35
35
  */
36
- export declare class SyntaxAwareCfgGuidedVisitor<OtherInfo = NoInfo, Cfg extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Config extends SyntaxCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast> = SyntaxCfgGuidedVisitorConfiguration<OtherInfo, Cfg, Ast>> extends BasicCfgGuidedVisitor<Cfg, Config> {
36
+ export declare class SyntaxAwareCfgGuidedVisitor<OtherInfo = NoInfo, ControlFlow extends ControlFlowInformation = ControlFlowInformation, Ast extends NormalizedAst<OtherInfo> = NormalizedAst<OtherInfo>, Config extends SyntaxCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast> = SyntaxCfgGuidedVisitorConfiguration<OtherInfo, ControlFlow, Ast>> extends BasicCfgGuidedVisitor<ControlFlow, Config> {
37
37
  /**
38
38
  * Get the normalized AST node for the given id or fail if it does not exist.
39
39
  */
@@ -27,6 +27,7 @@ export interface BuiltInFunctionDefinition<BuiltInProcessor extends BuiltInMappi
27
27
  readonly type: 'function';
28
28
  readonly processor: BuiltInProcessor;
29
29
  readonly config?: ConfigOfBuiltInMappingName<BuiltInProcessor>;
30
+ readonly evalHandler?: string;
30
31
  }
31
32
  /**
32
33
  * Define a built-in replacement (like `[` or `$`) and the processor to use.
@@ -15,7 +15,7 @@ import { processQuote } from '../internal/process/functions/call/built-in/built-
15
15
  import { processFunctionDefinition } from '../internal/process/functions/call/built-in/built-in-function-definition';
16
16
  import { processExpressionList } from '../internal/process/functions/call/built-in/built-in-expression-list';
17
17
  import { processGet } from '../internal/process/functions/call/built-in/built-in-get';
18
- import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
18
+ import type { AstIdMap, ParentInformation, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
19
19
  import type { RFunctionArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
20
20
  import type { RSymbol } from '../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
21
21
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
@@ -28,6 +28,10 @@ import { processList } from '../internal/process/functions/call/built-in/built-i
28
28
  import { processVector } from '../internal/process/functions/call/built-in/built-in-vector';
29
29
  import { processRm } from '../internal/process/functions/call/built-in/built-in-rm';
30
30
  import { processEvalCall } from '../internal/process/functions/call/built-in/built-in-eval';
31
+ import type { REnvironmentInformation } from './environment';
32
+ import type { Value } from '../eval/values/r-value';
33
+ import { resolveAsVector } from '../eval/resolve/resolve';
34
+ import type { DataflowGraph } from '../graph/graph';
31
35
  export type BuiltIn = `built-in:${string}`;
32
36
  export declare function builtInId(name: string): BuiltIn;
33
37
  export declare function isBuiltIn(name: NodeId | string): name is BuiltIn;
@@ -52,6 +56,7 @@ export interface DefaultBuiltInProcessorConfiguration extends ForceArguments {
52
56
  /** record mapping the actual function name called to the arguments that should be treated as function calls */
53
57
  readonly treatAsFnCall?: Record<string, readonly string[]>;
54
58
  }
59
+ export type BuiltInEvalHandler = (a: RNodeWithParent, env: REnvironmentInformation, graph?: DataflowGraph, map?: AstIdMap) => Value;
55
60
  declare function defaultBuiltInProcessor<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: DefaultBuiltInProcessorConfiguration): DataflowInformation;
56
61
  export declare function registerBuiltInFunctions<Config extends object, Proc extends BuiltInIdentifierProcessorWithConfig<Config>>(both: boolean, names: readonly Identifier[], processor: Proc, config: Config): void;
57
62
  export declare const BuiltInProcessorMapper: {
@@ -77,6 +82,10 @@ export declare const BuiltInProcessorMapper: {
77
82
  readonly 'builtin:list': typeof processList;
78
83
  readonly 'builtin:vector': typeof processVector;
79
84
  };
85
+ export declare const BuiltInEvalHandlerMapper: {
86
+ readonly 'built-in:c': typeof resolveAsVector;
87
+ readonly 'builtin:vector': typeof resolveAsVector;
88
+ };
80
89
  export type BuiltInMappingName = keyof typeof BuiltInProcessorMapper;
81
90
  export type ConfigOfBuiltInMappingName<N extends BuiltInMappingName> = Parameters<typeof BuiltInProcessorMapper[N]>[4];
82
91
  export declare const BuiltInMemory: Map<Identifier, IdentifierDefinition[]>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmptyBuiltInMemory = exports.BuiltInMemory = exports.BuiltInProcessorMapper = void 0;
3
+ exports.EmptyBuiltInMemory = exports.BuiltInMemory = exports.BuiltInEvalHandlerMapper = exports.BuiltInProcessorMapper = void 0;
4
4
  exports.builtInId = builtInId;
5
5
  exports.isBuiltIn = isBuiltIn;
6
6
  exports.registerBuiltInFunctions = registerBuiltInFunctions;
@@ -33,6 +33,8 @@ const built_in_rm_1 = require("../internal/process/functions/call/built-in/built
33
33
  const built_in_eval_1 = require("../internal/process/functions/call/built-in/built-in-eval");
34
34
  const vertex_1 = require("../graph/vertex");
35
35
  const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
36
+ const unknown_side_effect_1 = require("../graph/unknown-side-effect");
37
+ const resolve_1 = require("../eval/resolve/resolve");
36
38
  function builtInId(name) {
37
39
  return `built-in:${name}`;
38
40
  }
@@ -56,10 +58,10 @@ function defaultBuiltInProcessor(name, args, rootId, data, config) {
56
58
  }
57
59
  if (config.hasUnknownSideEffects) {
58
60
  if (typeof config.hasUnknownSideEffects !== 'boolean') {
59
- res.graph.markIdForUnknownSideEffects(rootId, config.hasUnknownSideEffects);
61
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId, config.hasUnknownSideEffects);
60
62
  }
61
63
  else {
62
- res.graph.markIdForUnknownSideEffects(rootId);
64
+ (0, unknown_side_effect_1.handleUnknownSideEffect)(res.graph, res.environment, rootId);
63
65
  }
64
66
  }
65
67
  const fnCallNames = config.treatAsFnCall?.[name.content];
@@ -140,6 +142,10 @@ exports.BuiltInProcessorMapper = {
140
142
  'builtin:list': built_in_list_1.processList,
141
143
  'builtin:vector': built_in_vector_1.processVector,
142
144
  };
145
+ exports.BuiltInEvalHandlerMapper = {
146
+ 'built-in:c': resolve_1.resolveAsVector,
147
+ 'builtin:vector': resolve_1.resolveAsVector
148
+ };
143
149
  exports.BuiltInMemory = new Map();
144
150
  exports.EmptyBuiltInMemory = new Map();
145
151
  (0, built_in_config_1.registerBuiltInDefinitions)(default_builtin_config_1.DefaultBuiltinConfig);
@@ -245,7 +245,7 @@ exports.DefaultBuiltinConfig = [
245
245
  { type: 'function', names: ['interference'], processor: 'builtin:apply', config: { unquoteFunction: true, nameOfFunctionArgument: 'propensity_integrand' }, assumePrimitive: false },
246
246
  { type: 'function', names: ['ddply'], processor: 'builtin:apply', config: { unquoteFunction: true, indexOfFunction: 2, nameOfFunctionArgument: '.fun' }, assumePrimitive: false },
247
247
  { type: 'function', names: ['list'], processor: 'builtin:list', config: {}, assumePrimitive: true },
248
- { type: 'function', names: ['c'], processor: 'builtin:vector', config: {}, assumePrimitive: true },
248
+ { type: 'function', names: ['c'], processor: 'builtin:vector', config: {}, assumePrimitive: true, evalHandler: 'builtin:c' },
249
249
  {
250
250
  type: 'function',
251
251
  names: ['setnames', 'setNames', 'setkey', 'setkeyv', 'setindex', 'setindexv', 'setattr'],
@@ -2,9 +2,6 @@ import type { REnvironmentInformation } from './environment';
2
2
  import { Ternary } from '../../util/logic';
3
3
  import type { Identifier, IdentifierDefinition } from './identifier';
4
4
  import { ReferenceType } from './identifier';
5
- import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
- import type { DataflowGraph } from '../graph/graph';
7
- import type { AstIdMap, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
8
5
  /**
9
6
  * Resolves a given identifier name to a list of its possible definition location using R scoping and resolving rules.
10
7
  *
@@ -17,36 +14,3 @@ import type { AstIdMap, RNodeWithParent } from '../../r-bridge/lang-4.x/ast/mode
17
14
  */
18
15
  export declare function resolveByName(name: Identifier, environment: REnvironmentInformation, target?: ReferenceType): IdentifierDefinition[] | undefined;
19
16
  export declare function resolvesToBuiltInConstant(name: Identifier | undefined, environment: REnvironmentInformation, wantedValue: unknown): Ternary;
20
- /** Please use {@link resolveValueOfVariable} */
21
- export declare function resolveToConstants(name: Identifier | undefined, environment: REnvironmentInformation): unknown[] | undefined;
22
- export declare function getAliases(sourceIds: readonly NodeId[], dataflow: DataflowGraph, environment: REnvironmentInformation): NodeId[] | undefined;
23
- /** Please use {@link resolveValueOfVariable} */
24
- export declare function trackAliasInEnvironments(identifier: Identifier | undefined, use: REnvironmentInformation, idMap?: AstIdMap): unknown[] | undefined;
25
- export declare function trackAliasesInGraph(id: NodeId, graph: DataflowGraph, idMap?: AstIdMap): unknown[] | undefined;
26
- /**
27
- * Convenience function using the variable resolver as specified within the configuration file
28
- * In the future we may want to have this set once at the start of the analysis
29
- *
30
- * @see {@link resolveIdToValue} - for a more general approach which "evaluates" a node based on value resolve
31
- */
32
- export declare function resolveValueOfVariable(identifier: Identifier | undefined, environment: REnvironmentInformation, idMap?: AstIdMap): unknown[] | undefined;
33
- export interface ResolveInfo {
34
- /** The current environment used for name resolution */
35
- environment?: REnvironmentInformation;
36
- /** The id map to resolve the node if given as an id */
37
- idMap?: AstIdMap;
38
- /** The graph to resolve in */
39
- graph?: DataflowGraph;
40
- /** Whether to track variables */
41
- full?: boolean;
42
- }
43
- /**
44
- * Generalized {@link resolveValueOfVariable} function which evaluates a node based on the value resolve
45
- *
46
- * @param id - The node id or node to resolve
47
- * @param environment - The current environment used for name resolution
48
- * @param graph - The graph to resolve in
49
- * @param idMap - The id map to resolve the node if given as an id
50
- * @param full - Whether to track variables
51
- */
52
- export declare function resolveIdToValue(id: NodeId | RNodeWithParent, { environment, graph, idMap, full }: ResolveInfo): unknown[] | undefined;