@eagleoutice/flowr 2.9.13 → 2.10.1
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.
- package/README.md +52 -28
- package/abstract-interpretation/absint-visitor.d.ts +1 -1
- package/abstract-interpretation/absint-visitor.js +20 -20
- package/abstract-interpretation/data-frame/mappers/replacement-mapper.js +2 -2
- package/benchmark/slicer.d.ts +1 -1
- package/benchmark/slicer.js +7 -5
- package/benchmark/stats/stats.d.ts +2 -2
- package/cli/repl/commands/repl-dataflow.js +5 -5
- package/cli/repl/parser/slice-query-parser.d.ts +3 -3
- package/cli/repl/parser/slice-query-parser.js +2 -2
- package/cli/repl/server/connection.js +2 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/repl/server/messages/message-slice.js +2 -2
- package/config.d.ts +12 -8
- package/config.js +5 -3
- package/control-flow/extract-cfg.js +2 -2
- package/control-flow/semantic-cfg-guided-visitor.d.ts +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +43 -43
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +3 -3
- package/core/print/dataflow-printer.d.ts +0 -14
- package/core/print/dataflow-printer.js +0 -21
- package/core/steps/all/core/20-dataflow.d.ts +3 -3
- package/core/steps/all/core/20-dataflow.js +3 -2
- package/core/steps/all/static-slicing/00-slice.d.ts +2 -5
- package/core/steps/all/static-slicing/00-slice.js +6 -8
- package/core/steps/pipeline/default-pipelines.d.ts +89 -89
- package/dataflow/environments/built-in-proc-name.d.ts +83 -0
- package/dataflow/environments/built-in-proc-name.js +88 -0
- package/dataflow/environments/built-in.d.ts +1 -83
- package/dataflow/environments/built-in.js +37 -120
- package/dataflow/environments/default-builtin-config.d.ts +1 -1
- package/dataflow/environments/default-builtin-config.js +75 -75
- package/dataflow/environments/identifier.d.ts +5 -0
- package/dataflow/environments/identifier.js +18 -0
- package/dataflow/eval/resolve/resolve.js +2 -2
- package/dataflow/fn/exceptions-of-function.d.ts +1 -1
- package/dataflow/fn/exceptions-of-function.js +2 -2
- package/dataflow/graph/call-graph.d.ts +46 -19
- package/dataflow/graph/call-graph.js +95 -114
- package/dataflow/graph/dataflowgraph-builder.d.ts +1 -1
- package/dataflow/graph/dataflowgraph-builder.js +2 -2
- package/dataflow/graph/df-helper.d.ts +133 -0
- package/dataflow/graph/df-helper.js +138 -0
- package/dataflow/graph/diff-dataflow-graph.d.ts +5 -10
- package/dataflow/graph/diff-dataflow-graph.js +3 -28
- package/dataflow/graph/edge.d.ts +1 -0
- package/dataflow/graph/edge.js +1 -0
- package/dataflow/graph/graph-helper.d.ts +60 -0
- package/dataflow/graph/graph-helper.js +128 -0
- package/dataflow/graph/graph.d.ts +19 -3
- package/dataflow/graph/graph.js +32 -5
- package/dataflow/graph/vertex.d.ts +3 -1
- package/dataflow/info.d.ts +14 -4
- package/dataflow/info.js +28 -16
- package/dataflow/internal/linker.d.ts +14 -10
- package/dataflow/internal/linker.js +29 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +8 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +6 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-recall.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-register-hook.js +5 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-dispatch.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-stop-if-not.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +6 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +2 -2
- package/dataflow/internal/process/functions/call/common.js +2 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -2
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +1 -1
- package/dataflow/internal/process/functions/call/named-call-handling.js +1 -1
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/functions/process-parameter.js +1 -1
- package/dataflow/internal/process/process-uninteresting-leaf.d.ts +1 -1
- package/dataflow/internal/process/process-uninteresting-leaf.js +1 -1
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-symbol-refs.js +6 -6
- package/documentation/doc-readme.js +2 -1
- package/documentation/doc-util/doc-dfg.d.ts +3 -0
- package/documentation/doc-util/doc-dfg.js +5 -7
- package/documentation/doc-util/doc-normalized-ast.d.ts +0 -6
- package/documentation/doc-util/doc-normalized-ast.js +0 -23
- package/documentation/doc-util/doc-structure.js +3 -3
- package/documentation/doc-util/doc-types.js +3 -3
- package/documentation/wiki-core.js +5 -4
- package/documentation/wiki-dataflow-graph.js +14 -12
- package/documentation/wiki-interface.js +3 -3
- package/documentation/wiki-linter.js +6 -0
- package/documentation/wiki-normalized-ast.js +5 -4
- package/documentation/wiki-query.js +28 -3
- package/linter/linter-rules.d.ts +49 -1
- package/linter/linter-rules.js +5 -1
- package/linter/rules/problematic-eval.d.ts +44 -0
- package/linter/rules/problematic-eval.js +83 -0
- package/linter/rules/seeded-randomness.js +2 -2
- package/linter/rules/stop-with-call-arg.d.ts +35 -0
- package/linter/rules/stop-with-call-arg.js +72 -0
- package/linter/rules/useless-loop.d.ts +1 -1
- package/package.json +7 -7
- package/project/cache/flowr-analyzer-cache.d.ts +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/flowr-analyzer-builder.d.ts +3 -0
- package/project/flowr-analyzer.d.ts +1 -1
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +2 -2
- package/queries/catalog/call-graph-query/call-graph-query-format.d.ts +1 -1
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -2
- package/queries/catalog/cluster-query/cluster-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
- package/queries/catalog/df-shape-query/df-shape-query-executor.js +1 -2
- package/queries/catalog/df-shape-query/df-shape-query-format.d.ts +3 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -2
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +3 -3
- package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +6 -0
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +66 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +36 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +63 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +90 -0
- package/queries/catalog/input-sources-query/simple-input-classifier.js +308 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.d.ts +2 -2
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +1 -1
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +3 -3
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +2 -2
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -2
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +2 -2
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +3 -3
- package/queries/catalog/provenance-query/provenance-query-executor.d.ts +6 -0
- package/queries/catalog/provenance-query/provenance-query-executor.js +34 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +35 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +62 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -2
- package/queries/catalog/search-query/search-query-format.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +4 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -3
- package/queries/query.d.ts +17 -1
- package/queries/query.js +4 -0
- package/r-bridge/lang-4.x/ast/model/model.d.ts +9 -0
- package/r-bridge/lang-4.x/ast/model/model.js +10 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +15 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +15 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +29 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +29 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +16 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +2 -0
- package/search/flowr-search-filters.d.ts +1 -1
- package/search/flowr-search-printer.js +3 -3
- package/search/search-executor/search-enrichers.js +2 -2
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/parse.d.ts +43 -18
- package/slicing/criterion/parse.js +68 -63
- package/slicing/static/slicer-types.d.ts +2 -3
- package/slicing/static/static-slicer.d.ts +3 -4
- package/slicing/static/static-slicer.js +32 -12
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +7 -0
- package/util/diff.d.ts +2 -2
- package/util/mermaid/ast.js +4 -4
- package/util/mermaid/cfg.js +5 -5
- package/util/mermaid/dfg.d.ts +33 -18
- package/util/mermaid/dfg.js +47 -31
- package/util/mermaid/mermaid.d.ts +57 -12
- package/util/mermaid/mermaid.js +74 -67
- package/util/range.d.ts +8 -0
- package/util/range.js +13 -1
- package/util/slice-direction.d.ts +7 -0
- package/util/slice-direction.js +12 -0
- package/util/version.js +1 -1
- package/dataflow/graph/invert-dfg.d.ts +0 -6
- package/dataflow/graph/invert-dfg.js +0 -20
- package/dataflow/graph/resolve-graph.d.ts +0 -8
- package/dataflow/graph/resolve-graph.js +0 -59
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.equalFunctionArguments = equalFunctionArguments;
|
|
3
|
+
exports.diffDataflowGraph = diffDataflowGraph;
|
|
5
4
|
exports.diffFunctionArguments = diffFunctionArguments;
|
|
6
5
|
exports.diffVertices = diffVertices;
|
|
7
6
|
exports.diffEdges = diffEdges;
|
|
@@ -16,20 +15,10 @@ const identifier_1 = require("../environments/identifier");
|
|
|
16
15
|
const diff_2 = require("../environments/diff");
|
|
17
16
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
18
17
|
const info_1 = require("../info");
|
|
19
|
-
const diff_graph_1 = require("../../util/diff-graph");
|
|
20
18
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @see {@link diffOfControlFlowGraphs} - for control flow graphs
|
|
19
|
+
* This is the underlying function to calculate the difference based on a given context.
|
|
20
|
+
* Use {@link Dataflow.diff} to calculate the diff of two graphs.
|
|
24
21
|
*/
|
|
25
|
-
function diffOfDataflowGraphs(left, right, config) {
|
|
26
|
-
if (left.graph === right.graph) {
|
|
27
|
-
return new diff_graph_1.GraphDifferenceReport();
|
|
28
|
-
}
|
|
29
|
-
const ctx = (0, diff_graph_1.initDiffContext)(left, right, config);
|
|
30
|
-
diffDataflowGraph(ctx);
|
|
31
|
-
return ctx.report;
|
|
32
|
-
}
|
|
33
22
|
function diffDataflowGraph(ctx) {
|
|
34
23
|
diffRootVertices(ctx);
|
|
35
24
|
diffVertices(ctx);
|
|
@@ -80,20 +69,6 @@ function diffFunctionArgumentsReferences(fn, a, b, ctx) {
|
|
|
80
69
|
}
|
|
81
70
|
(0, diff_2.diffIdentifierReferences)(a, b, ctx);
|
|
82
71
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Checks whether two function argument lists are equal.
|
|
85
|
-
*/
|
|
86
|
-
function equalFunctionArguments(fn, a, b) {
|
|
87
|
-
const ctx = {
|
|
88
|
-
report: new diff_graph_1.GraphDifferenceReport(),
|
|
89
|
-
leftname: 'left',
|
|
90
|
-
rightname: 'right',
|
|
91
|
-
position: '',
|
|
92
|
-
config: {}
|
|
93
|
-
};
|
|
94
|
-
diffFunctionArguments(fn, a, b, ctx);
|
|
95
|
-
return ctx.report.isEqual();
|
|
96
|
-
}
|
|
97
72
|
/**
|
|
98
73
|
* Compares two function argument lists and reports differences.
|
|
99
74
|
*/
|
package/dataflow/graph/edge.d.ts
CHANGED
package/dataflow/graph/edge.js
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { df2quads } from './quads';
|
|
2
|
+
import type { NamedGraph } from '../../util/diff-graph';
|
|
3
|
+
import { GraphDifferenceReport } from '../../util/diff-graph';
|
|
4
|
+
import type { GenericDiffConfiguration } from '../../util/diff';
|
|
5
|
+
import { DataflowGraph } from './graph';
|
|
6
|
+
import type { REnvironmentInformation } from '../environments/environment';
|
|
7
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
8
|
+
import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
10
|
+
import { DefaultMap } from '../../util/collections/defaultmap';
|
|
11
|
+
/**
|
|
12
|
+
* The underlying functions which work for any graph* like view
|
|
13
|
+
* **Please do not use this object directly but use the helpers**
|
|
14
|
+
* - {@link Dataflow}
|
|
15
|
+
* - {@link CallGraph}
|
|
16
|
+
*/
|
|
17
|
+
export declare const GraphHelper: {
|
|
18
|
+
/** Maps to the mermaid-centric visualization helper for dataflow graphs and their views */
|
|
19
|
+
readonly visualize: {
|
|
20
|
+
/**
|
|
21
|
+
* Mermaid rendering helper for dataflow graphs
|
|
22
|
+
* - {@link DataflowMermaid.url}, {@link DataflowMermaid.raw} - to render the graph as a mermaid graph (e.g., in markdown or the mermaid live editor)
|
|
23
|
+
* - {@link DataflowMermaid.convert} - for the underlying transformation
|
|
24
|
+
* @see {@link DataflowMermaid}
|
|
25
|
+
*/
|
|
26
|
+
readonly mermaid: {
|
|
27
|
+
readonly name: "DataflowMermaid";
|
|
28
|
+
readonly convert: (this: void, config: import("../../util/mermaid/dfg").MermaidGraphConfiguration) => {
|
|
29
|
+
string: string;
|
|
30
|
+
mermaid: import("../../util/mermaid/dfg").MermaidGraph;
|
|
31
|
+
};
|
|
32
|
+
readonly raw: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
33
|
+
readonly url: (this: void, graph: DataflowGraph | import("../info").DataflowInformation, includeEnvironments?: boolean, mark?: ReadonlySet<NodeId>, simplified?: boolean) => string;
|
|
34
|
+
};
|
|
35
|
+
readonly quads: {
|
|
36
|
+
readonly convert: typeof df2quads;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Compare two dataflow graphs and return a report on the differences.
|
|
41
|
+
* If you simply want to check whether they equal, use {@link GraphDifferenceReport#isEqual|`<result>.isEqual()`}.
|
|
42
|
+
* @see {@link diffOfControlFlowGraphs} - for control flow graphs
|
|
43
|
+
*/
|
|
44
|
+
readonly diffGraphs: <G extends DataflowGraph>(this: void, left: NamedGraph<G>, right: NamedGraph<G>, config?: Partial<GenericDiffConfiguration>) => GraphDifferenceReport;
|
|
45
|
+
/**
|
|
46
|
+
* Inverts the given dataflow graph by reversing all edges.
|
|
47
|
+
*/
|
|
48
|
+
readonly invertGraph: <G extends DataflowGraph>(this: void, graph: G, cleanEnv: REnvironmentInformation) => G;
|
|
49
|
+
/**
|
|
50
|
+
* Resolves the dataflow graph ids from slicing criterion form to ids.
|
|
51
|
+
* This returns a **new** graph with the resolved ids.
|
|
52
|
+
* The main use-case for this is testing - if you do not know/want to fix the specific id,
|
|
53
|
+
* you can use, e.g. `2@x` as a placeholder for the first x in the second line!
|
|
54
|
+
*/
|
|
55
|
+
readonly resolveGraphCriteria: <G extends DataflowGraph>(graph: G, ctx: ReadOnlyFlowrAnalyzerContext, idMap?: AstIdMap) => G;
|
|
56
|
+
/**
|
|
57
|
+
* Determines whether there is a path from `from` to `to` in the given graph (via any edge type, only respecting direction)
|
|
58
|
+
*/
|
|
59
|
+
readonly reaches: <G extends DataflowGraph>(this: void, from: NodeId, to: NodeId, graph: G, knownReachability?: DefaultMap<NodeId, Set<NodeId>>) => boolean;
|
|
60
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphHelper = void 0;
|
|
4
|
+
const dfg_1 = require("../../util/mermaid/dfg");
|
|
5
|
+
const quads_1 = require("./quads");
|
|
6
|
+
const diff_graph_1 = require("../../util/diff-graph");
|
|
7
|
+
const diff_dataflow_graph_1 = require("./diff-dataflow-graph");
|
|
8
|
+
const graph_1 = require("./graph");
|
|
9
|
+
const assert_1 = require("../../util/assert");
|
|
10
|
+
const parse_1 = require("../../slicing/criterion/parse");
|
|
11
|
+
const edge_1 = require("./edge");
|
|
12
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
13
|
+
/**
|
|
14
|
+
* The underlying functions which work for any graph* like view
|
|
15
|
+
* **Please do not use this object directly but use the helpers**
|
|
16
|
+
* - {@link Dataflow}
|
|
17
|
+
* - {@link CallGraph}
|
|
18
|
+
*/
|
|
19
|
+
exports.GraphHelper = {
|
|
20
|
+
/** Maps to the mermaid-centric visualization helper for dataflow graphs and their views */
|
|
21
|
+
visualize: {
|
|
22
|
+
/**
|
|
23
|
+
* Mermaid rendering helper for dataflow graphs
|
|
24
|
+
* - {@link DataflowMermaid.url}, {@link DataflowMermaid.raw} - to render the graph as a mermaid graph (e.g., in markdown or the mermaid live editor)
|
|
25
|
+
* - {@link DataflowMermaid.convert} - for the underlying transformation
|
|
26
|
+
* @see {@link DataflowMermaid}
|
|
27
|
+
*/
|
|
28
|
+
mermaid: dfg_1.DataflowMermaid,
|
|
29
|
+
quads: { convert: quads_1.df2quads }
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Compare two dataflow graphs and return a report on the differences.
|
|
33
|
+
* If you simply want to check whether they equal, use {@link GraphDifferenceReport#isEqual|`<result>.isEqual()`}.
|
|
34
|
+
* @see {@link diffOfControlFlowGraphs} - for control flow graphs
|
|
35
|
+
*/
|
|
36
|
+
diffGraphs(left, right, config) {
|
|
37
|
+
if (left.graph === right.graph) {
|
|
38
|
+
return new diff_graph_1.GraphDifferenceReport();
|
|
39
|
+
}
|
|
40
|
+
const ctx = (0, diff_graph_1.initDiffContext)(left, right, config);
|
|
41
|
+
(0, diff_dataflow_graph_1.diffDataflowGraph)(ctx);
|
|
42
|
+
return ctx.report;
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* Inverts the given dataflow graph by reversing all edges.
|
|
46
|
+
*/
|
|
47
|
+
invertGraph(graph, cleanEnv) {
|
|
48
|
+
const invertedGraph = new graph_1.DataflowGraph(graph.idMap);
|
|
49
|
+
for (const [, v] of graph.vertices(true)) {
|
|
50
|
+
invertedGraph.addVertex(v, cleanEnv);
|
|
51
|
+
}
|
|
52
|
+
for (const [from, targets] of graph.edges()) {
|
|
53
|
+
for (const [to, { types }] of targets) {
|
|
54
|
+
invertedGraph.addEdge(to, from, types);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return invertedGraph;
|
|
58
|
+
},
|
|
59
|
+
/**
|
|
60
|
+
* Resolves the dataflow graph ids from slicing criterion form to ids.
|
|
61
|
+
* This returns a **new** graph with the resolved ids.
|
|
62
|
+
* The main use-case for this is testing - if you do not know/want to fix the specific id,
|
|
63
|
+
* you can use, e.g. `2@x` as a placeholder for the first x in the second line!
|
|
64
|
+
*/
|
|
65
|
+
resolveGraphCriteria(graph, ctx, idMap) {
|
|
66
|
+
const resolveMap = idMap ?? graph.idMap;
|
|
67
|
+
(0, assert_1.guard)(resolveMap !== undefined, 'idMap must be provided to resolve the graph');
|
|
68
|
+
const cache = new Map();
|
|
69
|
+
const resolve = (id) => {
|
|
70
|
+
const cached = cache.get(id);
|
|
71
|
+
if (cached !== undefined) {
|
|
72
|
+
return cached;
|
|
73
|
+
}
|
|
74
|
+
const resolved = parse_1.SlicingCriterion.tryParse(id, resolveMap) ?? id;
|
|
75
|
+
cache.set(id, resolved);
|
|
76
|
+
return resolved;
|
|
77
|
+
};
|
|
78
|
+
const resultGraph = new graph_1.DataflowGraph(resolveMap);
|
|
79
|
+
const roots = graph.rootIds();
|
|
80
|
+
/* recreate vertices */
|
|
81
|
+
for (const [id, vertex] of graph.vertices(true)) {
|
|
82
|
+
resultGraph.addVertex({
|
|
83
|
+
...vertex,
|
|
84
|
+
id: resolve(id)
|
|
85
|
+
}, ctx.env.makeCleanEnv(), roots.has(id));
|
|
86
|
+
}
|
|
87
|
+
/* recreate edges */
|
|
88
|
+
for (const [from, targets] of graph.edges()) {
|
|
89
|
+
for (const [to, info] of targets) {
|
|
90
|
+
for (const type of edge_1.DfEdge.splitTypes(info)) {
|
|
91
|
+
resultGraph.addEdge(resolve(from), resolve(to), type);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
for (const unknown of graph.unknownSideEffects) {
|
|
96
|
+
if (typeof unknown === 'object') {
|
|
97
|
+
resultGraph.markIdForUnknownSideEffects(resolve(unknown.id), unknown.linkTo);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
resultGraph.markIdForUnknownSideEffects(resolve(unknown));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return resultGraph;
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* Determines whether there is a path from `from` to `to` in the given graph (via any edge type, only respecting direction)
|
|
107
|
+
*/
|
|
108
|
+
reaches(from, to, graph, knownReachability = new defaultmap_1.DefaultMap(() => new Set())) {
|
|
109
|
+
const visited = new Set();
|
|
110
|
+
const toVisit = [from];
|
|
111
|
+
while (toVisit.length > 0) {
|
|
112
|
+
const currentId = toVisit.pop();
|
|
113
|
+
if (visited.has(currentId)) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (currentId === to || knownReachability.get(currentId).has(to)) {
|
|
117
|
+
knownReachability.get(from).add(to);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
visited.add(currentId);
|
|
121
|
+
for (const [tar] of graph.outgoingEdges(currentId) ?? []) {
|
|
122
|
+
toVisit.push(tar);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=graph-helper.js.map
|
|
@@ -25,6 +25,7 @@ export type DataflowFunctionFlowInformation = Omit<DataflowInformation, 'graph'
|
|
|
25
25
|
*/
|
|
26
26
|
export interface NamedFunctionArgument extends IdentifierReference {
|
|
27
27
|
readonly name: string;
|
|
28
|
+
readonly valueId: NodeId | undefined;
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* A reference which does not have a name, like the references to the arguments `3` and `2` in the following:
|
|
@@ -32,7 +33,6 @@ export interface NamedFunctionArgument extends IdentifierReference {
|
|
|
32
33
|
* ```r
|
|
33
34
|
* foo(3, 2)
|
|
34
35
|
* ```
|
|
35
|
-
* @see #isPositionalArgument
|
|
36
36
|
* @see NamedFunctionArgument
|
|
37
37
|
*/
|
|
38
38
|
export interface PositionalFunctionArgument extends Omit<IdentifierReference, 'name'> {
|
|
@@ -51,6 +51,7 @@ export type FunctionArgument = NamedFunctionArgument | PositionalFunctionArgumen
|
|
|
51
51
|
* @see {@link EmptyArgument} - the marker for empty arguments
|
|
52
52
|
*/
|
|
53
53
|
export declare const FunctionArgument: {
|
|
54
|
+
readonly name: "FunctionArgument";
|
|
54
55
|
/**
|
|
55
56
|
* Checks whether the given argument is a positional argument.
|
|
56
57
|
* @example
|
|
@@ -94,16 +95,29 @@ export declare const FunctionArgument: {
|
|
|
94
95
|
* @see {@link FunctionArgument.isEmpty}
|
|
95
96
|
*/
|
|
96
97
|
readonly isNotEmpty: <T>(this: void, arg: T) => arg is Exclude<T, typeof EmptyArgument>;
|
|
98
|
+
/**
|
|
99
|
+
* Returns the id of a non-empty argument.
|
|
100
|
+
* @example
|
|
101
|
+
* ```r
|
|
102
|
+
* foo(a=3, 2) # returns the node id of either `a` or `2`
|
|
103
|
+
* ```
|
|
104
|
+
* @see {@link FunctionArgument.getReference}
|
|
105
|
+
*/
|
|
106
|
+
readonly getId: (this: void, arg: FunctionArgument) => NodeId | undefined;
|
|
97
107
|
/**
|
|
98
108
|
* Returns the reference of a non-empty argument.
|
|
99
109
|
* @example
|
|
100
110
|
* ```r
|
|
101
111
|
* foo(a=3, 2) # returns the node id of either `3` or `2`, but skips a
|
|
102
112
|
* ```
|
|
113
|
+
* @see {@link FunctionArgument.getId}
|
|
103
114
|
*/
|
|
104
115
|
readonly getReference: (this: void, arg: FunctionArgument) => NodeId | undefined;
|
|
105
116
|
/**
|
|
106
117
|
* Checks whether the given argument is a named argument with the specified name.
|
|
118
|
+
* Please note that this only checks whether the name is exactly identical and not whether
|
|
119
|
+
* R's argument matching resolves to the correct argument.
|
|
120
|
+
* For this, please refer to the {@link pMatch} function!
|
|
107
121
|
* @see {@link isNamed}
|
|
108
122
|
*/
|
|
109
123
|
readonly hasName: (this: void, arg: FunctionArgument, name: string | undefined) => arg is NamedFunctionArgument;
|
|
@@ -138,7 +152,8 @@ export type UnknownSideEffect = NodeId | {
|
|
|
138
152
|
};
|
|
139
153
|
/**
|
|
140
154
|
* The dataflow graph holds the dataflow information found within the given AST.
|
|
141
|
-
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}
|
|
155
|
+
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}.
|
|
156
|
+
* The helper object associated with the DFG is {@link Dataflow}.
|
|
142
157
|
*
|
|
143
158
|
* The vertices of the graph are organized in a hierarchical fashion, with a function-definition node containing the node ids of its subgraph.
|
|
144
159
|
* However, all *edges* are hoisted at the top level in the form of an (attributed) adjacency list.
|
|
@@ -254,8 +269,9 @@ export declare class DataflowGraph<Vertex extends DataflowGraphVertexInfo = Data
|
|
|
254
269
|
/**
|
|
255
270
|
* Marks a vertex in the graph to be a definition
|
|
256
271
|
* @param reference - The reference to the vertex to mark as definition
|
|
272
|
+
* @param sourceIds - The id of the source vertex of the def, if available
|
|
257
273
|
*/
|
|
258
|
-
setDefinitionOfVertex(reference: IdentifierReference): void;
|
|
274
|
+
setDefinitionOfVertex(reference: IdentifierReference, sourceIds: readonly NodeId[] | undefined): void;
|
|
259
275
|
/**
|
|
260
276
|
* Marks a vertex in the graph to be a function call with the new information
|
|
261
277
|
* @param info - The information about the new function call node
|
package/dataflow/graph/graph.js
CHANGED
|
@@ -13,6 +13,7 @@ const clone_1 = require("../environments/clone");
|
|
|
13
13
|
* @see {@link EmptyArgument} - the marker for empty arguments
|
|
14
14
|
*/
|
|
15
15
|
exports.FunctionArgument = {
|
|
16
|
+
name: 'FunctionArgument',
|
|
16
17
|
/**
|
|
17
18
|
* Checks whether the given argument is a positional argument.
|
|
18
19
|
* @example
|
|
@@ -67,20 +68,41 @@ exports.FunctionArgument = {
|
|
|
67
68
|
return arg !== r_function_call_1.EmptyArgument;
|
|
68
69
|
},
|
|
69
70
|
/**
|
|
70
|
-
* Returns the
|
|
71
|
+
* Returns the id of a non-empty argument.
|
|
71
72
|
* @example
|
|
72
73
|
* ```r
|
|
73
|
-
* foo(a=3, 2) # returns the node id of either `
|
|
74
|
+
* foo(a=3, 2) # returns the node id of either `a` or `2`
|
|
74
75
|
* ```
|
|
76
|
+
* @see {@link FunctionArgument.getReference}
|
|
75
77
|
*/
|
|
76
|
-
|
|
78
|
+
getId(arg) {
|
|
77
79
|
if (arg !== r_function_call_1.EmptyArgument) {
|
|
78
80
|
return arg?.nodeId;
|
|
79
81
|
}
|
|
80
82
|
return undefined;
|
|
81
83
|
},
|
|
84
|
+
/**
|
|
85
|
+
* Returns the reference of a non-empty argument.
|
|
86
|
+
* @example
|
|
87
|
+
* ```r
|
|
88
|
+
* foo(a=3, 2) # returns the node id of either `3` or `2`, but skips a
|
|
89
|
+
* ```
|
|
90
|
+
* @see {@link FunctionArgument.getId}
|
|
91
|
+
*/
|
|
92
|
+
getReference(arg) {
|
|
93
|
+
if (arg === r_function_call_1.EmptyArgument) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
else if (arg.name === undefined) {
|
|
97
|
+
return arg.nodeId;
|
|
98
|
+
}
|
|
99
|
+
return arg.valueId;
|
|
100
|
+
},
|
|
82
101
|
/**
|
|
83
102
|
* Checks whether the given argument is a named argument with the specified name.
|
|
103
|
+
* Please note that this only checks whether the name is exactly identical and not whether
|
|
104
|
+
* R's argument matching resolves to the correct argument.
|
|
105
|
+
* For this, please refer to the {@link pMatch} function!
|
|
84
106
|
* @see {@link isNamed}
|
|
85
107
|
*/
|
|
86
108
|
hasName(arg, name) {
|
|
@@ -89,7 +111,8 @@ exports.FunctionArgument = {
|
|
|
89
111
|
};
|
|
90
112
|
/**
|
|
91
113
|
* The dataflow graph holds the dataflow information found within the given AST.
|
|
92
|
-
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}
|
|
114
|
+
* We differentiate the directed edges in {@link EdgeType} and the vertices indicated by {@link DataflowGraphVertexArgument}.
|
|
115
|
+
* The helper object associated with the DFG is {@link Dataflow}.
|
|
93
116
|
*
|
|
94
117
|
* The vertices of the graph are organized in a hierarchical fashion, with a function-definition node containing the node ids of its subgraph.
|
|
95
118
|
* However, all *edges* are hoisted at the top level in the form of an (attributed) adjacency list.
|
|
@@ -364,8 +387,9 @@ class DataflowGraph {
|
|
|
364
387
|
/**
|
|
365
388
|
* Marks a vertex in the graph to be a definition
|
|
366
389
|
* @param reference - The reference to the vertex to mark as definition
|
|
390
|
+
* @param sourceIds - The id of the source vertex of the def, if available
|
|
367
391
|
*/
|
|
368
|
-
setDefinitionOfVertex(reference) {
|
|
392
|
+
setDefinitionOfVertex(reference, sourceIds) {
|
|
369
393
|
const vertex = this.getVertex(reference.nodeId);
|
|
370
394
|
(0, assert_1.guard)(vertex !== undefined, () => `node must be defined for ${JSON.stringify(reference)} to set reference`);
|
|
371
395
|
if (vertex.tag === vertex_1.VertexType.FunctionDefinition || vertex.tag === vertex_1.VertexType.VariableDefinition) {
|
|
@@ -374,6 +398,9 @@ class DataflowGraph {
|
|
|
374
398
|
else {
|
|
375
399
|
const oldTag = vertex.tag;
|
|
376
400
|
vertex.tag = vertex_1.VertexType.VariableDefinition;
|
|
401
|
+
if (sourceIds) {
|
|
402
|
+
vertex.source = sourceIds;
|
|
403
|
+
}
|
|
377
404
|
this.types.set(oldTag, (this.types.get(oldTag) ?? []).filter(id => id !== reference.nodeId));
|
|
378
405
|
this.types.set(vertex_1.VertexType.VariableDefinition, (this.types.get(vertex_1.VertexType.VariableDefinition) ?? []).concat([reference.nodeId]));
|
|
379
406
|
}
|
|
@@ -3,8 +3,8 @@ import type { DataflowFunctionFlowInformation, FunctionArgument } from './graph'
|
|
|
3
3
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
4
4
|
import type { REnvironmentInformation } from '../environments/environment';
|
|
5
5
|
import type { ControlDependency, ExitPoint } from '../info';
|
|
6
|
-
import type { BuiltInProcName } from '../environments/built-in';
|
|
7
6
|
import type { Identifier } from '../environments/identifier';
|
|
7
|
+
import type { BuiltInProcName } from '../environments/built-in-proc-name';
|
|
8
8
|
export declare enum VertexType {
|
|
9
9
|
Value = "value",
|
|
10
10
|
Use = "use",
|
|
@@ -123,6 +123,8 @@ export interface DataflowGraphVertexVariableDefinition extends DataflowGraphVert
|
|
|
123
123
|
readonly environment?: undefined;
|
|
124
124
|
/** Indicates whether the variable definition is a *partial* definition (e.g,. in `x[a] <- b`) */
|
|
125
125
|
readonly par?: true;
|
|
126
|
+
/** Points to the source ids of the "value" if there is one, this is more of a best-effort flag and not guaranteed to be there */
|
|
127
|
+
readonly source?: readonly NodeId[];
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
128
130
|
* Arguments required to construct a vertex which represents the definition of a function in the {@link DataflowGraph|dataflow graph}.
|
package/dataflow/info.d.ts
CHANGED
|
@@ -125,11 +125,21 @@ export interface DataflowInformation extends DataflowCfgInformation {
|
|
|
125
125
|
graph: DataflowGraph;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
129
|
-
* This is to be used as a "starting point" when processing leaf nodes during the dataflow extraction.
|
|
130
|
-
* @see {@link DataflowInformation}
|
|
128
|
+
* Helper object for {@link DataflowInformation}
|
|
131
129
|
*/
|
|
132
|
-
export declare
|
|
130
|
+
export declare const DataflowInformation: {
|
|
131
|
+
readonly name: "DataflowInformation";
|
|
132
|
+
/**
|
|
133
|
+
* Initializes an empty {@link DataflowInformation} object with the given entry point and data.
|
|
134
|
+
* This is to be used as a "starting point" when processing leaf nodes during the dataflow extraction.
|
|
135
|
+
* @see {@link DataflowInformation}
|
|
136
|
+
*/
|
|
137
|
+
readonly initialize: <T>(this: void, entryPoint: NodeId, data: Pick<DataflowProcessorInformation<T>, "environment" | "completeAst">) => DataflowInformation;
|
|
138
|
+
/**
|
|
139
|
+
* Type guard to check whether the given information is a {@link DataflowInformation}.
|
|
140
|
+
*/
|
|
141
|
+
readonly is: (info: unknown) => info is DataflowInformation;
|
|
142
|
+
};
|
|
133
143
|
/**
|
|
134
144
|
* Checks whether the given control dependencies are exhaustive (i.e. if for every control dependency on a boolean,
|
|
135
145
|
* the list contains a dependency on the `true` and on the `false` case).
|
package/dataflow/info.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataflowInformation = void 0;
|
|
3
4
|
exports.negateControlDependency = negateControlDependency;
|
|
4
5
|
exports.doesExitPointPropagateCalls = doesExitPointPropagateCalls;
|
|
5
6
|
exports.addNonDefaultExitPoints = addNonDefaultExitPoints;
|
|
6
7
|
exports.overwriteExitPoints = overwriteExitPoints;
|
|
7
|
-
exports.initializeCleanDataflowInformation = initializeCleanDataflowInformation;
|
|
8
8
|
exports.happensInEveryBranch = happensInEveryBranch;
|
|
9
9
|
exports.happensInEveryBranchSet = happensInEveryBranchSet;
|
|
10
10
|
exports.alwaysExits = alwaysExits;
|
|
@@ -56,22 +56,34 @@ function overwriteExitPoints(existing, replace) {
|
|
|
56
56
|
return existing.concat(replace);
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
60
|
-
* This is to be used as a "starting point" when processing leaf nodes during the dataflow extraction.
|
|
61
|
-
* @see {@link DataflowInformation}
|
|
59
|
+
* Helper object for {@link DataflowInformation}
|
|
62
60
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
exports.DataflowInformation = {
|
|
62
|
+
name: 'DataflowInformation',
|
|
63
|
+
/**
|
|
64
|
+
* Initializes an empty {@link DataflowInformation} object with the given entry point and data.
|
|
65
|
+
* This is to be used as a "starting point" when processing leaf nodes during the dataflow extraction.
|
|
66
|
+
* @see {@link DataflowInformation}
|
|
67
|
+
*/
|
|
68
|
+
initialize(entryPoint, data) {
|
|
69
|
+
return {
|
|
70
|
+
unknownReferences: [],
|
|
71
|
+
in: [],
|
|
72
|
+
out: [],
|
|
73
|
+
environment: data.environment,
|
|
74
|
+
graph: new graph_1.DataflowGraph(undefined),
|
|
75
|
+
entryPoint,
|
|
76
|
+
exitPoints: [{ nodeId: entryPoint, type: 0 /* ExitPointType.Default */ }],
|
|
77
|
+
hooks: []
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check whether the given information is a {@link DataflowInformation}.
|
|
82
|
+
*/
|
|
83
|
+
is(info) {
|
|
84
|
+
return typeof info === 'object' && info !== null && 'entryPoint' in info && 'exitPoints' in info && 'hooks' in info;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
75
87
|
/**
|
|
76
88
|
* Checks whether the given control dependencies are exhaustive (i.e. if for every control dependency on a boolean,
|
|
77
89
|
* the list contains a dependency on the `true` and on the `false` case).
|
|
@@ -25,22 +25,26 @@ export declare function produceNameSharedIdMap(references: IdentifierReference[]
|
|
|
25
25
|
* If you just want to match by name, use {@link pMatch}.
|
|
26
26
|
*/
|
|
27
27
|
export declare function linkArgumentsOnCall(args: readonly FunctionArgument[], params: readonly RParameter<ParentInformation>[], graph: DataflowGraph): Map<NodeId, NodeId>;
|
|
28
|
-
/**
|
|
29
|
-
* Returns all argument ids that map to the given target parameter id.
|
|
30
|
-
*/
|
|
31
|
-
export declare function getAllIdsWithTarget<Targets extends NodeId>(maps: Map<NodeId, Targets>, target: Targets): NodeId[];
|
|
32
|
-
/**
|
|
33
|
-
* Inverts the argument to parameter map to a parameter to argument map.
|
|
34
|
-
*/
|
|
35
|
-
export declare function invertArgumentMap<Targets extends NodeId>(maps: Map<NodeId, Targets>): Map<Targets, NodeId[]>;
|
|
36
28
|
/**
|
|
37
29
|
* Links the given arguments to the given parameters within the given graph by name only.
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const parameterSpec = {
|
|
33
|
+
* 'paramName': 'paramId',
|
|
34
|
+
* 'anotherParamName': 'anotherParamId',
|
|
35
|
+
* // we recommend to always add '...' to your specification
|
|
36
|
+
* // this way you can collect all arguments that could not be matched!
|
|
37
|
+
* '...': '...'
|
|
38
|
+
* } as const;
|
|
39
|
+
*
|
|
40
|
+
* const match = pMatch(convertFnArguments(args), parameterSpec);
|
|
41
|
+
* const addParam = match.get('paramId');
|
|
42
|
+
* ```
|
|
38
43
|
* @note
|
|
39
44
|
* To obtain the arguments from a {@link RFunctionCall}[], either use {@link processAllArguments} (also available via {@link processKnownFunctionCall})
|
|
40
45
|
* or convert them with {@link convertFnArguments}.
|
|
41
|
-
* You can use {@link getAllIdsWithTarget} to get all argument ids that map to a given parameter.
|
|
42
46
|
*/
|
|
43
|
-
export declare function pMatch<Targets extends NodeId>(args: readonly FunctionArgument[], params: Record<string, Targets>): Map<
|
|
47
|
+
export declare function pMatch<Targets extends NodeId>(args: readonly FunctionArgument[], params: Record<string, Targets>): Map<Targets, NodeId[]>;
|
|
44
48
|
/**
|
|
45
49
|
* Links a function call with a single target function definition.
|
|
46
50
|
*/
|