@eagleoutice/flowr 2.2.10 → 2.2.12

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 (132) hide show
  1. package/README.md +4 -4
  2. package/benchmark/slicer.d.ts +49 -22
  3. package/benchmark/slicer.js +88 -28
  4. package/benchmark/stats/print.js +16 -10
  5. package/benchmark/stats/size-of.js +18 -1
  6. package/benchmark/stats/stats.d.ts +3 -0
  7. package/benchmark/summarizer/second-phase/process.js +8 -2
  8. package/cli/benchmark-app.d.ts +5 -0
  9. package/cli/benchmark-app.js +49 -6
  10. package/cli/benchmark-helper-app.d.ts +4 -0
  11. package/cli/benchmark-helper-app.js +20 -4
  12. package/cli/common/options.js +13 -4
  13. package/cli/repl/commands/repl-commands.js +2 -0
  14. package/cli/repl/commands/repl-dataflow.d.ts +2 -0
  15. package/cli/repl/commands/repl-dataflow.js +35 -1
  16. package/cli/repl/server/compact.d.ts +2 -2
  17. package/cli/repl/server/compact.js +3 -3
  18. package/cli/repl/server/messages/message-analysis.d.ts +2 -2
  19. package/cli/repl/server/messages/message-analysis.js +2 -2
  20. package/config.d.ts +27 -2
  21. package/config.js +30 -4
  22. package/dataflow/environments/built-in-config.d.ts +5 -2
  23. package/dataflow/environments/built-in-config.js +8 -2
  24. package/dataflow/environments/built-in.d.ts +8 -1
  25. package/dataflow/environments/built-in.js +8 -1
  26. package/dataflow/environments/clone.d.ts +5 -0
  27. package/dataflow/environments/clone.js +5 -0
  28. package/dataflow/environments/default-builtin-config.js +96 -10
  29. package/dataflow/environments/define.d.ts +5 -1
  30. package/dataflow/environments/define.js +36 -10
  31. package/dataflow/environments/environment.js +4 -2
  32. package/dataflow/environments/overwrite.js +4 -0
  33. package/dataflow/environments/remove.d.ts +6 -0
  34. package/dataflow/environments/remove.js +24 -0
  35. package/dataflow/environments/resolve-by-name.js +1 -1
  36. package/dataflow/extractor.d.ts +1 -1
  37. package/dataflow/extractor.js +8 -6
  38. package/dataflow/graph/dataflowgraph-builder.d.ts +76 -6
  39. package/dataflow/graph/dataflowgraph-builder.js +102 -6
  40. package/dataflow/graph/edge.js +4 -1
  41. package/dataflow/graph/graph.d.ts +12 -1
  42. package/dataflow/graph/graph.js +37 -0
  43. package/dataflow/graph/vertex.d.ts +42 -2
  44. package/dataflow/graph/vertex.js +32 -0
  45. package/dataflow/internal/linker.js +3 -1
  46. package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +3 -0
  47. package/dataflow/internal/process/functions/call/argument/unpack-argument.js +4 -10
  48. package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
  49. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +55 -45
  50. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -4
  51. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +27 -8
  52. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +37 -7
  53. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +10 -0
  54. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +140 -0
  55. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -3
  56. package/dataflow/internal/process/functions/call/built-in/built-in-list.js +51 -17
  57. package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +21 -3
  58. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +3 -0
  59. package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +83 -29
  60. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +7 -0
  61. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +41 -0
  62. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +20 -6
  63. package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +15 -0
  64. package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +75 -0
  65. package/dataflow/internal/process/functions/call/common.d.ts +1 -1
  66. package/dataflow/internal/process/functions/call/common.js +4 -2
  67. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +2 -0
  68. package/dataflow/internal/process/functions/call/named-call-handling.js +9 -5
  69. package/dataflow/internal/process/process-named-call.d.ts +3 -0
  70. package/dataflow/internal/process/process-named-call.js +3 -0
  71. package/dataflow/processor.d.ts +7 -7
  72. package/documentation/data/server/doc-data-server-messages.js +2 -2
  73. package/documentation/doc-util/doc-cfg.d.ts +11 -2
  74. package/documentation/doc-util/doc-cfg.js +35 -6
  75. package/documentation/doc-util/doc-code.js +10 -2
  76. package/documentation/print-capabilities-markdown.js +1 -1
  77. package/documentation/print-cfg-wiki.d.ts +1 -0
  78. package/documentation/print-cfg-wiki.js +84 -0
  79. package/documentation/print-core-wiki.js +2 -2
  80. package/documentation/print-interface-wiki.js +4 -0
  81. package/documentation/print-query-wiki.js +22 -3
  82. package/package.json +4 -3
  83. package/queries/catalog/call-context-query/call-context-query-executor.js +13 -0
  84. package/queries/catalog/call-context-query/call-context-query-format.d.ts +4 -0
  85. package/queries/catalog/call-context-query/call-context-query-format.js +1 -0
  86. package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +1 -1
  87. package/queries/catalog/dependencies-query/dependencies-query-executor.js +13 -5
  88. package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -25
  89. package/queries/catalog/dependencies-query/dependencies-query-format.js +2 -145
  90. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +24 -0
  91. package/queries/catalog/dependencies-query/function-info/function-info.js +10 -0
  92. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +2 -0
  93. package/queries/catalog/dependencies-query/function-info/library-functions.js +18 -0
  94. package/queries/catalog/dependencies-query/function-info/read-functions.d.ts +2 -0
  95. package/queries/catalog/dependencies-query/function-info/read-functions.js +101 -0
  96. package/queries/catalog/dependencies-query/function-info/source-functions.d.ts +2 -0
  97. package/queries/catalog/dependencies-query/function-info/source-functions.js +11 -0
  98. package/queries/catalog/dependencies-query/function-info/write-functions.d.ts +2 -0
  99. package/queries/catalog/dependencies-query/function-info/write-functions.js +87 -0
  100. package/queries/catalog/location-map-query/location-map-query-executor.d.ts +1 -1
  101. package/queries/catalog/location-map-query/location-map-query-executor.js +38 -3
  102. package/queries/catalog/location-map-query/location-map-query-format.d.ts +10 -1
  103. package/queries/catalog/location-map-query/location-map-query-format.js +5 -1
  104. package/queries/catalog/project-query/project-query-executor.d.ts +3 -0
  105. package/queries/catalog/project-query/project-query-executor.js +17 -0
  106. package/queries/catalog/project-query/project-query-format.d.ts +67 -0
  107. package/queries/catalog/project-query/project-query-format.js +26 -0
  108. package/queries/query.d.ts +60 -1
  109. package/queries/query.js +3 -1
  110. package/r-bridge/data/data.d.ts +2 -2
  111. package/r-bridge/data/data.js +2 -2
  112. package/slicing/static/fingerprint.js +8 -1
  113. package/slicing/static/slice-call.d.ts +1 -1
  114. package/slicing/static/slice-call.js +5 -16
  115. package/slicing/static/slicer-types.d.ts +2 -0
  116. package/slicing/static/static-slicer.d.ts +4 -2
  117. package/slicing/static/static-slicer.js +24 -18
  118. package/slicing/static/visiting-queue.d.ts +7 -1
  119. package/slicing/static/visiting-queue.js +20 -6
  120. package/util/arrays.d.ts +23 -0
  121. package/util/arrays.js +41 -0
  122. package/util/cfg/visitor.d.ts +1 -1
  123. package/util/cfg/visitor.js +2 -2
  124. package/util/{list-access.d.ts → containers.d.ts} +24 -4
  125. package/util/{list-access.js → containers.js} +42 -12
  126. package/util/mermaid/ast.js +12 -1
  127. package/util/mermaid/cfg.js +2 -2
  128. package/util/parallel.d.ts +2 -1
  129. package/util/parallel.js +11 -2
  130. package/util/prefix.d.ts +13 -0
  131. package/util/prefix.js +34 -0
  132. package/util/version.js +1 -1
@@ -1,17 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeDefinitions = mergeDefinitions;
3
4
  exports.define = define;
4
5
  const assert_1 = require("../../util/assert");
5
6
  const environment_1 = require("./environment");
6
7
  const clone_1 = require("./clone");
7
8
  const vertex_1 = require("../graph/vertex");
9
+ const config_1 = require("../../config");
8
10
  function defInEnv(newEnvironments, name, definition) {
9
11
  const existing = newEnvironments.memory.get(name);
10
12
  // When there are defined indices, merge the definitions
11
13
  const inGraphDefinition = definition;
12
- if (existing !== undefined && inGraphDefinition.indicesCollection !== undefined && inGraphDefinition.controlDependencies === undefined) {
13
- newEnvironments.memory.set(name, mergeDefinitions(existing, inGraphDefinition));
14
- return;
14
+ if ((0, config_1.getConfig)().solver.pointerTracking &&
15
+ existing !== undefined &&
16
+ inGraphDefinition.controlDependencies === undefined) {
17
+ if (inGraphDefinition.indicesCollection !== undefined) {
18
+ newEnvironments.memory.set(name, mergeDefinitions(existing, inGraphDefinition));
19
+ return;
20
+ }
21
+ else if (existing?.flatMap(i => i.indicesCollection ?? []).length > 0) {
22
+ // When indices couldn't be resolved, but indices where defined before, just add the definition
23
+ existing.push(definition);
24
+ return;
25
+ }
15
26
  }
16
27
  // check if it is maybe or not
17
28
  if (existing === undefined || definition.controlDependencies === undefined) {
@@ -21,28 +32,43 @@ function defInEnv(newEnvironments, name, definition) {
21
32
  existing.push(definition);
22
33
  }
23
34
  }
35
+ /**
36
+ * assumes: existing is not undefined, the overwrite has indices
37
+ */
24
38
  function mergeDefinitions(existing, definition) {
25
39
  // When new definition is not a single index, e.g., a list redefinition, then reset existing definition
26
40
  if (definition.indicesCollection?.some(indices => indices.isContainer)) {
27
41
  return [definition];
28
42
  }
29
- const existingDefs = existing.map((def) => def).filter((def) => def !== undefined);
43
+ const existingDefs = existing.filter(assert_1.isNotUndefined);
30
44
  const overwriteIndices = definition.indicesCollection?.flatMap(indices => indices.indices) ?? [];
31
45
  // Compare existing and new definitions,
32
46
  // add new definitions and remove existing definitions that are overwritten by new definition
33
47
  const newExistingDefs = [];
48
+ const hasCache = new Set();
34
49
  for (const overwriteIndex of overwriteIndices) {
35
50
  for (const existingDef of existingDefs) {
36
- if (existingDef.indicesCollection === undefined) {
51
+ // empty or missing
52
+ if (existingDef.indicesCollection === undefined || existingDef.indicesCollection.length === 0) {
53
+ const existingDefPrint = JSON.stringify(existingDef);
54
+ if (!hasCache.has(existingDefPrint)) {
55
+ newExistingDefs.push(existingDef);
56
+ hasCache.add(existingDefPrint);
57
+ }
37
58
  continue;
38
59
  }
39
60
  const newIndicesCollection = overwriteContainerIndices(existingDef.indicesCollection, overwriteIndex);
40
61
  // if indices are now empty list, don't keep empty definition
41
62
  if (newIndicesCollection.length > 0) {
42
- newExistingDefs.push({
63
+ const obj = {
43
64
  ...existingDef,
44
65
  indicesCollection: newIndicesCollection,
45
- });
66
+ };
67
+ const objHash = JSON.stringify(obj);
68
+ if (!hasCache.has(objHash)) {
69
+ newExistingDefs.push(obj);
70
+ hasCache.add(objHash);
71
+ }
46
72
  }
47
73
  }
48
74
  }
@@ -57,7 +83,7 @@ function overwriteContainerIndices(existingIndices, overwriteIndex) {
57
83
  if ((0, vertex_1.isParentContainerIndex)(overwriteIndex)) {
58
84
  newIndices = [];
59
85
  for (const index of indices.indices) {
60
- if (index.lexeme === overwriteIndex.lexeme && (0, vertex_1.isParentContainerIndex)(index)) {
86
+ if ((0, vertex_1.isSameIndex)(index, overwriteIndex) && (0, vertex_1.isParentContainerIndex)(index)) {
61
87
  const overwriteSubIndices = overwriteIndex.subIndices.flatMap(a => a.indices);
62
88
  let newSubIndices = index.subIndices;
63
89
  for (const overwriteSubIndex of overwriteSubIndices) {
@@ -70,7 +96,7 @@ function overwriteContainerIndices(existingIndices, overwriteIndex) {
70
96
  });
71
97
  }
72
98
  }
73
- if (index.lexeme !== overwriteIndex.lexeme || !(0, vertex_1.isParentContainerIndex)(index)) {
99
+ if (!(0, vertex_1.isSameIndex)(index, overwriteIndex) || !(0, vertex_1.isParentContainerIndex)(index)) {
74
100
  newIndices.push(index);
75
101
  }
76
102
  }
@@ -81,7 +107,7 @@ function overwriteContainerIndices(existingIndices, overwriteIndex) {
81
107
  }
82
108
  else {
83
109
  // Filter existing indices with the same name
84
- newIndices = indices.indices.filter(def => def.lexeme !== overwriteIndex.lexeme);
110
+ newIndices = indices.indices.filter(def => !(0, vertex_1.isSameIndex)(def, overwriteIndex));
85
111
  }
86
112
  if (indices.isContainer || newIndices.length > 0) {
87
113
  newIndicesCollection.push({
@@ -81,8 +81,10 @@ exports.EmptyBuiltInEnvironment = {
81
81
  * See {@link EmptyBuiltInEnvironment} for the case `fullBuiltIns = false`.
82
82
  */
83
83
  function initializeCleanEnvironments(fullBuiltIns = true) {
84
- exports.BuiltInEnvironment.memory ??= built_in_1.BuiltInMemory;
85
- exports.EmptyBuiltInEnvironment.memory ??= built_in_1.EmptyBuiltInMemory;
84
+ if (exports.BuiltInEnvironment.memory === undefined) {
85
+ exports.BuiltInEnvironment.memory = built_in_1.BuiltInMemory;
86
+ exports.EmptyBuiltInEnvironment.memory = built_in_1.EmptyBuiltInMemory;
87
+ }
86
88
  return {
87
89
  current: new Environment(fullBuiltIns ? exports.BuiltInEnvironment : exports.EmptyBuiltInEnvironment),
88
90
  level: 0
@@ -4,6 +4,7 @@ exports.overwriteIEnvironmentWith = overwriteIEnvironmentWith;
4
4
  exports.overwriteEnvironment = overwriteEnvironment;
5
5
  const assert_1 = require("../../util/assert");
6
6
  const environment_1 = require("./environment");
7
+ const log_1 = require("../../util/log");
7
8
  function anyIsMaybeOrEmpty(values) {
8
9
  if (values.length === 0) {
9
10
  return true;
@@ -19,6 +20,9 @@ function overwriteIEnvironmentWith(base, next, includeParent = true, applyCds) {
19
20
  (0, assert_1.guard)(base !== undefined && next !== undefined, 'can not overwrite environments with undefined');
20
21
  const map = new Map(base.memory);
21
22
  for (const [key, values] of next.memory) {
23
+ if (values.length > 1_000_000) {
24
+ log_1.log.warn(`Overwriting environment with ${values.length} definitions for ${key}`);
25
+ }
22
26
  const hasMaybe = applyCds?.length === 0 || applyCds !== undefined ? true : anyIsMaybeOrEmpty(values);
23
27
  if (hasMaybe) {
24
28
  const old = map.get(key);
@@ -0,0 +1,6 @@
1
+ import type { REnvironmentInformation } from './environment';
2
+ import type { Identifier } from './identifier';
3
+ /**
4
+ * Removes all definitions of a given name from the environment.
5
+ */
6
+ export declare function remove(name: Identifier, environment: REnvironmentInformation): REnvironmentInformation;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remove = remove;
4
+ const environment_1 = require("./environment");
5
+ const info_1 = require("../info");
6
+ /**
7
+ * Removes all definitions of a given name from the environment.
8
+ */
9
+ function remove(name, environment) {
10
+ let current = environment.current;
11
+ do {
12
+ const definition = current.memory.get(name);
13
+ if (definition !== undefined) {
14
+ current.memory.delete(name);
15
+ if (definition.every(d => (0, info_1.happensInEveryBranch)(d.controlDependencies))) {
16
+ break;
17
+ }
18
+ }
19
+ current = current.parent;
20
+ } while (current.id !== environment_1.BuiltInEnvironment.id);
21
+ // we never remove built ins
22
+ return environment;
23
+ }
24
+ //# sourceMappingURL=remove.js.map
@@ -58,7 +58,7 @@ function resolveByName(name, environment, target = identifier_1.ReferenceType.Un
58
58
  }
59
59
  else if (filtered.length > 0) {
60
60
  definitions ??= [];
61
- definitions.push(...filtered);
61
+ definitions = definitions.concat(filtered);
62
62
  }
63
63
  }
64
64
  current = current.parent;
@@ -14,4 +14,4 @@ export declare const processors: DataflowProcessors<ParentInformation>;
14
14
  * (e.g., in the event of a `source` call).
15
15
  * For the actual, canonical fold entry point, see {@link processDataflowFor}.
16
16
  */
17
- export declare function produceDataFlowGraph<OtherInfo>(parser: Parser<KnownParserType>, request: RParseRequests, ast: NormalizedAst<OtherInfo & ParentInformation>): DataflowInformation;
17
+ export declare function produceDataFlowGraph<OtherInfo>(parser: Parser<KnownParserType>, request: RParseRequests, completeAst: NormalizedAst<OtherInfo & ParentInformation>): DataflowInformation;
@@ -80,9 +80,9 @@ function resolveLinkToSideEffects(ast, graph) {
80
80
  * (e.g., in the event of a `source` call).
81
81
  * For the actual, canonical fold entry point, see {@link processDataflowFor}.
82
82
  */
83
- function produceDataFlowGraph(parser, request, ast) {
84
- const multifile = Array.isArray(request);
83
+ function produceDataFlowGraph(parser, request, completeAst) {
85
84
  let firstRequest;
85
+ const multifile = Array.isArray(request);
86
86
  if (multifile) {
87
87
  firstRequest = request[0];
88
88
  }
@@ -90,23 +90,25 @@ function produceDataFlowGraph(parser, request, ast) {
90
90
  firstRequest = request;
91
91
  }
92
92
  const dfData = {
93
- parser: parser,
94
- completeAst: ast,
93
+ parser,
94
+ completeAst,
95
95
  environment: (0, environment_1.initializeCleanEnvironments)(),
96
96
  processors: exports.processors,
97
97
  currentRequest: firstRequest,
98
98
  controlDependencies: undefined,
99
99
  referenceChain: [firstRequest],
100
100
  };
101
- let df = (0, processor_1.processDataflowFor)(ast.ast, dfData);
101
+ let df = (0, processor_1.processDataflowFor)(completeAst.ast, dfData);
102
+ df.graph.sourced.unshift(firstRequest.request === 'file' ? firstRequest.content : '<inline>');
102
103
  if (multifile) {
103
104
  for (let i = 1; i < request.length; i++) {
105
+ /* source requests register automatically */
104
106
  df = (0, built_in_source_1.standaloneSourceFile)(request[i], dfData, `root-${i}`, df);
105
107
  }
106
108
  }
107
109
  // finally, resolve linkages
108
110
  (0, built_in_function_definition_1.updateNestedFunctionCalls)(df.graph, df.environment);
109
- resolveLinkToSideEffects(ast, df.graph);
111
+ resolveLinkToSideEffects(completeAst, df.graph);
110
112
  return df;
111
113
  }
112
114
  //# sourceMappingURL=extractor.js.map
@@ -6,6 +6,9 @@ import type { REnvironmentInformation } from '../environments/environment';
6
6
  import type { DataflowGraphVertexUse } from './vertex';
7
7
  import type { ControlDependency } from '../info';
8
8
  import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
9
+ import type { FlowrSearchLike } from '../../search/flowr-search-builder';
10
+ import type { Pipeline } from '../../core/steps/pipeline/pipeline';
11
+ import type { FlowrSearchInput } from '../../search/flowr-search';
9
12
  export declare function emptyGraph(idMap?: AstIdMap): DataflowGraphBuilder;
10
13
  export type DataflowGraphEdgeTarget = NodeId | (readonly NodeId[]);
11
14
  /**
@@ -82,8 +85,9 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
82
85
  controlDependencies?: ControlDependency[];
83
86
  }, asRoot?: boolean): this;
84
87
  private edgeHelper;
88
+ private queryHelper;
85
89
  /**
86
- * Adds a **read edge** (E1).
90
+ * Adds a **read edge**.
87
91
  *
88
92
  * @param from - NodeId of the source vertex
89
93
  * @param to - Either a single or multiple target ids.
@@ -91,30 +95,62 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
91
95
  */
92
96
  reads(from: NodeId, to: DataflowGraphEdgeTarget): this;
93
97
  /**
94
- * Adds a **defined-by edge** (E2), with from as defined variable, and to
98
+ * Adds a **read edge** with a query for the from and/or to vertices.
99
+ *
100
+ * @param from - Either a node id or a query to find the node id.
101
+ * @param to - Either a node id or a query to find the node id.
102
+ * @param data - The data to search in i.e. the dataflow graph.
103
+ */
104
+ readsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
105
+ /**
106
+ * Adds a **defined-by edge** with from as defined variable, and to
95
107
  * as a variable/function contributing to its definition.
96
108
  *
97
109
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
98
110
  */
99
111
  definedBy(from: NodeId, to: DataflowGraphEdgeTarget): this;
100
112
  /**
101
- * Adds a **call edge** (E5) with from as caller, and to as callee.
113
+ * Adds a **defined-by edge** with a query for the from and/or to vertices.
114
+ *
115
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
116
+ */
117
+ definedByQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
118
+ /**
119
+ * Adds a **call edge** with from as caller, and to as callee.
102
120
  *
103
121
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
104
122
  */
105
123
  calls(from: NodeId, to: DataflowGraphEdgeTarget): this;
106
124
  /**
107
- * Adds a **return edge** (E6) with from as function, and to as exit point.
125
+ * Adds a **call edge** with a query for the from and/or to vertices.
126
+ *
127
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
128
+ */
129
+ callsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
130
+ /**
131
+ * Adds a **return edge** with from as function, and to as exit point.
108
132
  *
109
133
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
110
134
  */
111
135
  returns(from: NodeId, to: DataflowGraphEdgeTarget): this;
112
136
  /**
113
- * Adds a **defines-on-call edge** (E7) with from as variable, and to as its definition
137
+ * Adds a **return edge** with a query for the from and/or to vertices.
138
+ *
139
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
140
+ */
141
+ returnsQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
142
+ /**
143
+ * Adds a **defines-on-call edge** with from as variable, and to as its definition
114
144
  *
115
145
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
116
146
  */
117
147
  definesOnCall(from: NodeId, to: DataflowGraphEdgeTarget): this;
148
+ /**
149
+ * Adds a **defines-on-call edge** with a query for the from and/or to vertices.
150
+ *
151
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
152
+ */
153
+ definesOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
118
154
  /**
119
155
  * Adds a **defined-by-on-call edge** with from as definition, and to as variable.
120
156
  *
@@ -122,23 +158,47 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
122
158
  */
123
159
  definedByOnCall(from: NodeId, to: DataflowGraphEdgeTarget): this;
124
160
  /**
125
- * Adds an **argument edge** (E9) with from as function call, and to as argument.
161
+ * Adds a **defined-by-on-call edge** with a query for the from and/or to vertices.
162
+ *
163
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
164
+ */
165
+ definedByOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
166
+ /**
167
+ * Adds an **argument edge** with from as function call, and to as argument.
126
168
  *
127
169
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
128
170
  */
129
171
  argument(from: NodeId, to: DataflowGraphEdgeTarget): this;
172
+ /**
173
+ * Adds a **argument edge** with a query for the from and/or to vertices.
174
+ *
175
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
176
+ */
177
+ argumentQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
130
178
  /**
131
179
  * Adds a **non-standard evaluation edge** with from as vertex, and to as vertex.
132
180
  *
133
181
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
134
182
  */
135
183
  nse(from: NodeId, to: DataflowGraphEdgeTarget): this;
184
+ /**
185
+ * Adds a **non-standard evaluation edge** with a query for the from and/or to vertices.
186
+ *
187
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
188
+ */
189
+ nseQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
136
190
  /**
137
191
  * Adds a **side-effect-on-call edge** with from as vertex, and to as vertex.
138
192
  *
139
193
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
140
194
  */
141
195
  sideEffectOnCall(from: NodeId, to: DataflowGraphEdgeTarget): this;
196
+ /**
197
+ * Adds a **side-effect-on-call edge** with a query for the from and/or to vertices.
198
+ *
199
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
200
+ */
201
+ sideEffectOnCallQuery<P extends Pipeline>(from: FromQueryParam, to: ToQueryParam, data: FlowrSearchInput<P>): this;
142
202
  /**
143
203
  * explicitly overwrite the root ids of the graph,
144
204
  * this is just an easier variant in case you working with a lot of functions this saves you a lot of `false` flags.
@@ -146,3 +206,13 @@ export declare class DataflowGraphBuilder extends DataflowGraph {
146
206
  overwriteRootIds(ids: readonly NodeId[]): this;
147
207
  }
148
208
  export declare function getBuiltInSideEffect(name: string): LinkTo<RegExp> | undefined;
209
+ interface Query {
210
+ query: FlowrSearchLike;
211
+ }
212
+ type FromQueryParam = {
213
+ nodeId: NodeId;
214
+ } | Query;
215
+ type ToQueryParam = {
216
+ target: DataflowGraphEdgeTarget;
217
+ } | Query;
218
+ export {};
@@ -12,6 +12,8 @@ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-fun
12
12
  const built_in_1 = require("../environments/built-in");
13
13
  const edge_1 = require("./edge");
14
14
  const default_builtin_config_1 = require("../environments/default-builtin-config");
15
+ const flowr_search_executor_1 = require("../../search/flowr-search-executor");
16
+ const assert_1 = require("../../util/assert");
15
17
  function emptyGraph(idMap) {
16
18
  return new DataflowGraphBuilder(idMap);
17
19
  }
@@ -170,8 +172,28 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
170
172
  }
171
173
  return this.addEdge((0, node_id_1.normalizeIdToNumberIfPossible)(from), (0, node_id_1.normalizeIdToNumberIfPossible)(to), type);
172
174
  }
175
+ queryHelper(from, to, data, type) {
176
+ let fromId;
177
+ if ('nodeId' in from) {
178
+ fromId = from.nodeId;
179
+ }
180
+ else {
181
+ const result = (0, flowr_search_executor_1.runSearch)(from.query, data);
182
+ (0, assert_1.guard)(result.length === 1, `from query result should yield exactly one node, but yielded ${result.length}`);
183
+ fromId = result[0].node.info.id;
184
+ }
185
+ let toIds;
186
+ if ('target' in to) {
187
+ toIds = to.target;
188
+ }
189
+ else {
190
+ const result = (0, flowr_search_executor_1.runSearch)(to.query, data);
191
+ toIds = result.map(r => r.node.info.id);
192
+ }
193
+ return this.edgeHelper(fromId, toIds, type);
194
+ }
173
195
  /**
174
- * Adds a **read edge** (E1).
196
+ * Adds a **read edge**.
175
197
  *
176
198
  * @param from - NodeId of the source vertex
177
199
  * @param to - Either a single or multiple target ids.
@@ -181,7 +203,17 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
181
203
  return this.edgeHelper(from, to, edge_1.EdgeType.Reads);
182
204
  }
183
205
  /**
184
- * Adds a **defined-by edge** (E2), with from as defined variable, and to
206
+ * Adds a **read edge** with a query for the from and/or to vertices.
207
+ *
208
+ * @param from - Either a node id or a query to find the node id.
209
+ * @param to - Either a node id or a query to find the node id.
210
+ * @param data - The data to search in i.e. the dataflow graph.
211
+ */
212
+ readsQuery(from, to, data) {
213
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Reads);
214
+ }
215
+ /**
216
+ * Adds a **defined-by edge** with from as defined variable, and to
185
217
  * as a variable/function contributing to its definition.
186
218
  *
187
219
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
@@ -190,7 +222,15 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
190
222
  return this.edgeHelper(from, to, edge_1.EdgeType.DefinedBy);
191
223
  }
192
224
  /**
193
- * Adds a **call edge** (E5) with from as caller, and to as callee.
225
+ * Adds a **defined-by edge** with a query for the from and/or to vertices.
226
+ *
227
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
228
+ */
229
+ definedByQuery(from, to, data) {
230
+ return this.queryHelper(from, to, data, edge_1.EdgeType.DefinedBy);
231
+ }
232
+ /**
233
+ * Adds a **call edge** with from as caller, and to as callee.
194
234
  *
195
235
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
196
236
  */
@@ -198,7 +238,15 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
198
238
  return this.edgeHelper(from, to, edge_1.EdgeType.Calls);
199
239
  }
200
240
  /**
201
- * Adds a **return edge** (E6) with from as function, and to as exit point.
241
+ * Adds a **call edge** with a query for the from and/or to vertices.
242
+ *
243
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
244
+ */
245
+ callsQuery(from, to, data) {
246
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Calls);
247
+ }
248
+ /**
249
+ * Adds a **return edge** with from as function, and to as exit point.
202
250
  *
203
251
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
204
252
  */
@@ -206,13 +254,29 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
206
254
  return this.edgeHelper(from, to, edge_1.EdgeType.Returns);
207
255
  }
208
256
  /**
209
- * Adds a **defines-on-call edge** (E7) with from as variable, and to as its definition
257
+ * Adds a **return edge** with a query for the from and/or to vertices.
258
+ *
259
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
260
+ */
261
+ returnsQuery(from, to, data) {
262
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Returns);
263
+ }
264
+ /**
265
+ * Adds a **defines-on-call edge** with from as variable, and to as its definition
210
266
  *
211
267
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
212
268
  */
213
269
  definesOnCall(from, to) {
214
270
  return this.edgeHelper(from, to, edge_1.EdgeType.DefinesOnCall);
215
271
  }
272
+ /**
273
+ * Adds a **defines-on-call edge** with a query for the from and/or to vertices.
274
+ *
275
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
276
+ */
277
+ definesOnCallQuery(from, to, data) {
278
+ return this.queryHelper(from, to, data, edge_1.EdgeType.DefinesOnCall);
279
+ }
216
280
  /**
217
281
  * Adds a **defined-by-on-call edge** with from as definition, and to as variable.
218
282
  *
@@ -222,13 +286,29 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
222
286
  return this.edgeHelper(from, to, edge_1.EdgeType.DefinedByOnCall);
223
287
  }
224
288
  /**
225
- * Adds an **argument edge** (E9) with from as function call, and to as argument.
289
+ * Adds a **defined-by-on-call edge** with a query for the from and/or to vertices.
290
+ *
291
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
292
+ */
293
+ definedByOnCallQuery(from, to, data) {
294
+ return this.queryHelper(from, to, data, edge_1.EdgeType.DefinedByOnCall);
295
+ }
296
+ /**
297
+ * Adds an **argument edge** with from as function call, and to as argument.
226
298
  *
227
299
  * @see {@link DataflowGraphBuilder#reads|reads} for parameters.
228
300
  */
229
301
  argument(from, to) {
230
302
  return this.edgeHelper(from, to, edge_1.EdgeType.Argument);
231
303
  }
304
+ /**
305
+ * Adds a **argument edge** with a query for the from and/or to vertices.
306
+ *
307
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
308
+ */
309
+ argumentQuery(from, to, data) {
310
+ return this.queryHelper(from, to, data, edge_1.EdgeType.Argument);
311
+ }
232
312
  /**
233
313
  * Adds a **non-standard evaluation edge** with from as vertex, and to as vertex.
234
314
  *
@@ -237,6 +317,14 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
237
317
  nse(from, to) {
238
318
  return this.edgeHelper(from, to, edge_1.EdgeType.NonStandardEvaluation);
239
319
  }
320
+ /**
321
+ * Adds a **non-standard evaluation edge** with a query for the from and/or to vertices.
322
+ *
323
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
324
+ */
325
+ nseQuery(from, to, data) {
326
+ return this.queryHelper(from, to, data, edge_1.EdgeType.NonStandardEvaluation);
327
+ }
240
328
  /**
241
329
  * Adds a **side-effect-on-call edge** with from as vertex, and to as vertex.
242
330
  *
@@ -245,6 +333,14 @@ class DataflowGraphBuilder extends graph_1.DataflowGraph {
245
333
  sideEffectOnCall(from, to) {
246
334
  return this.edgeHelper(from, to, edge_1.EdgeType.SideEffectOnCall);
247
335
  }
336
+ /**
337
+ * Adds a **side-effect-on-call edge** with a query for the from and/or to vertices.
338
+ *
339
+ * @see {@link DataflowGraphBuilder#readsQuery|readsQuery} for parameters.
340
+ */
341
+ sideEffectOnCallQuery(from, to, data) {
342
+ return this.queryHelper(from, to, data, edge_1.EdgeType.SideEffectOnCall);
343
+ }
248
344
  /**
249
345
  * explicitly overwrite the root ids of the graph,
250
346
  * this is just an easier variant in case you working with a lot of functions this saves you a lot of `false` flags.
@@ -98,7 +98,10 @@ function edgeDoesNotIncludeType(type, types) {
98
98
  const alwaysTraverseEdgeTypes = EdgeType.Reads | EdgeType.DefinedBy | EdgeType.Argument | EdgeType.Calls;
99
99
  const definedByOnCallTypes = EdgeType.DefinesOnCall | EdgeType.DefinedByOnCall;
100
100
  function shouldTraverseEdge(types) {
101
- if (edgeIncludesType(types, alwaysTraverseEdgeTypes)) {
101
+ if (edgeIncludesType(types, EdgeType.NonStandardEvaluation)) {
102
+ return 0 /* TraverseEdge.Never */;
103
+ }
104
+ else if (edgeIncludesType(types, alwaysTraverseEdgeTypes)) {
102
105
  return 3 /* TraverseEdge.Always */;
103
106
  }
104
107
  else if (edgeIncludesType(types, definedByOnCallTypes)) {
@@ -2,7 +2,7 @@ import type { DataflowGraphEdge, EdgeType } from './edge';
2
2
  import type { DataflowInformation } from '../info';
3
3
  import type { DataflowGraphVertexArgument, DataflowGraphVertexFunctionCall, DataflowGraphVertexInfo } from './vertex';
4
4
  import { EmptyArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
5
- import type { IdentifierDefinition, IdentifierReference } from '../environments/identifier';
5
+ import type { Identifier, IdentifierDefinition, IdentifierReference } from '../environments/identifier';
6
6
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
7
7
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
8
8
  import type { LinkTo } from '../../queries/catalog/call-context-query/call-context-query-format';
@@ -73,6 +73,7 @@ export interface DataflowGraphJson {
73
73
  readonly rootVertices: NodeId[];
74
74
  readonly vertexInformation: [NodeId, DataflowGraphVertexInfo][];
75
75
  readonly edgeInformation: [NodeId, [NodeId, DataflowGraphEdge][]][];
76
+ readonly sourced?: (string | '<inline>')[];
76
77
  }
77
78
  /**
78
79
  * An unknown side effect describes something that we cannot handle correctly (in all cases).
@@ -103,6 +104,8 @@ export type UnknownSidEffect = NodeId | {
103
104
  export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = DataflowGraphVertexInfo, Edge extends DataflowGraphEdge = DataflowGraphEdge> {
104
105
  private static DEFAULT_ENVIRONMENT;
105
106
  private _idMap;
107
+ /** all file paths included in this dfg */
108
+ private _sourced;
106
109
  private readonly _unknownSideEffects;
107
110
  constructor(idMap: AstIdMap | undefined);
108
111
  /** Contains the vertices of the root level graph (i.e., included those vertices from the complete graph, that are nested within function definitions) */
@@ -135,6 +138,9 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
135
138
  ingoingEdges(id: NodeId): IngoingEdges | undefined;
136
139
  /** Retrieves the id-map to the normalized AST attached to the dataflow graph */
137
140
  get idMap(): AstIdMap | undefined;
141
+ get sourced(): (string | '<inline>')[];
142
+ /** Mark this file as being part of the dfg */
143
+ addFile(source: string | '<inline>'): void;
138
144
  /**
139
145
  * Retrieves the set of vertices which have side effects that we do not know anything about.
140
146
  */
@@ -213,4 +219,9 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
213
219
  */
214
220
  static fromJson(data: DataflowGraphJson): DataflowGraph;
215
221
  }
222
+ export interface IEnvironmentJson {
223
+ readonly id: number;
224
+ parent: IEnvironmentJson;
225
+ memory: Record<Identifier, IdentifierDefinition[]>;
226
+ }
216
227
  export {};