@eagleoutice/flowr 2.2.11 → 2.2.13
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 +82 -20
- package/benchmark/slicer.d.ts +49 -22
- package/benchmark/slicer.js +89 -29
- package/benchmark/stats/print.js +16 -10
- package/benchmark/stats/size-of.js +18 -1
- package/benchmark/stats/stats.d.ts +3 -0
- package/benchmark/summarizer/first-phase/input.js +1 -1
- package/benchmark/summarizer/first-phase/process.js +3 -3
- package/benchmark/summarizer/second-phase/process.js +9 -3
- package/benchmark/summarizer/summarizer.js +1 -1
- package/cli/benchmark-app.d.ts +5 -0
- package/cli/benchmark-app.js +49 -6
- package/cli/benchmark-helper-app.d.ts +4 -0
- package/cli/benchmark-helper-app.js +20 -4
- package/cli/common/options.js +15 -6
- package/cli/common/script.js +1 -1
- package/cli/flowr.js +1 -1
- package/cli/repl/commands/repl-cfg.d.ts +2 -0
- package/cli/repl/commands/repl-cfg.js +38 -24
- package/cli/repl/commands/repl-commands.js +6 -2
- package/cli/repl/commands/repl-dataflow.d.ts +2 -0
- package/cli/repl/commands/repl-dataflow.js +37 -3
- package/cli/repl/commands/repl-execute.js +1 -1
- package/cli/repl/commands/repl-main.d.ts +1 -1
- package/cli/repl/commands/repl-main.js +1 -1
- package/cli/repl/commands/repl-normalize.js +1 -1
- package/cli/repl/commands/repl-query.js +2 -2
- package/cli/repl/core.js +1 -1
- package/cli/repl/prompt.js +1 -1
- package/cli/repl/server/connection.js +4 -4
- package/cli/repl/server/messages/message-analysis.d.ts +1 -1
- package/cli/script-core/statistics-core.js +1 -1
- package/cli/script-core/statistics-helper-core.js +4 -4
- package/config.d.ts +60 -21
- package/config.js +24 -4
- package/control-flow/basic-cfg-guided-visitor.d.ts +39 -0
- package/control-flow/basic-cfg-guided-visitor.js +114 -0
- package/control-flow/cfg-properties.d.ts +26 -0
- package/control-flow/cfg-properties.js +100 -0
- package/control-flow/cfg-simplification.d.ts +18 -0
- package/control-flow/cfg-simplification.js +55 -0
- package/control-flow/cfg-to-basic-blocks.d.ts +5 -0
- package/control-flow/cfg-to-basic-blocks.js +81 -0
- package/control-flow/control-flow-graph.d.ts +247 -0
- package/control-flow/control-flow-graph.js +290 -0
- package/control-flow/dfg-cfg-guided-visitor.d.ts +32 -0
- package/control-flow/dfg-cfg-guided-visitor.js +71 -0
- package/control-flow/diff-cfg.d.ts +11 -0
- package/control-flow/diff-cfg.js +161 -0
- package/control-flow/extract-cfg.d.ts +30 -0
- package/control-flow/extract-cfg.js +475 -0
- package/control-flow/happens-before.d.ts +7 -0
- package/{util/cfg → control-flow}/happens-before.js +3 -3
- package/control-flow/semantic-cfg-guided-visitor.d.ts +452 -0
- package/control-flow/semantic-cfg-guided-visitor.js +492 -0
- package/control-flow/simple-visitor.d.ts +25 -0
- package/control-flow/simple-visitor.js +80 -0
- package/control-flow/syntax-cfg-guided-visitor.d.ts +128 -0
- package/control-flow/syntax-cfg-guided-visitor.js +166 -0
- package/core/print/print.d.ts +1 -1
- package/core/print/slice-diff-ansi.js +1 -1
- package/core/steps/pipeline/create-pipeline.js +1 -1
- package/dataflow/environments/built-in-config.d.ts +5 -2
- package/dataflow/environments/built-in-config.js +17 -8
- package/dataflow/environments/built-in.d.ts +16 -5
- package/dataflow/environments/built-in.js +55 -6
- package/dataflow/environments/clone.d.ts +5 -0
- package/dataflow/environments/clone.js +5 -0
- package/dataflow/environments/default-builtin-config.d.ts +2 -0
- package/dataflow/environments/default-builtin-config.js +164 -13
- package/dataflow/environments/define.d.ts +5 -1
- package/dataflow/environments/define.js +36 -10
- package/dataflow/environments/overwrite.js +4 -0
- package/dataflow/environments/remove.d.ts +6 -0
- package/dataflow/environments/remove.js +24 -0
- package/dataflow/environments/resolve-by-name.js +16 -5
- package/dataflow/extractor.js +2 -2
- package/dataflow/graph/dataflowgraph-builder.d.ts +79 -7
- package/dataflow/graph/dataflowgraph-builder.js +106 -8
- package/dataflow/graph/diff-dataflow-graph.d.ts +16 -0
- package/dataflow/graph/{diff.js → diff-dataflow-graph.js} +30 -56
- package/dataflow/graph/graph.d.ts +17 -4
- package/dataflow/graph/graph.js +51 -12
- package/dataflow/graph/vertex.d.ts +59 -4
- package/dataflow/graph/vertex.js +32 -0
- package/dataflow/internal/linker.d.ts +3 -2
- package/dataflow/internal/linker.js +36 -25
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +1 -1
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-access.d.ts +1 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +67 -54
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +108 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +54 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +10 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +140 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +9 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +15 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +51 -17
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.d.ts +4 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +100 -31
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +35 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-special-bin-op.js +4 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.d.ts +15 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-vector.js +75 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +3 -3
- package/dataflow/internal/process/functions/call/common.d.ts +5 -2
- package/dataflow/internal/process/functions/call/common.js +9 -5
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +3 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +2 -1
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +2 -0
- package/dataflow/internal/process/functions/call/named-call-handling.js +10 -6
- package/dataflow/internal/process/functions/call/unnamed-call-handling.d.ts +1 -0
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +6 -4
- package/dataflow/internal/process/process-named-call.d.ts +4 -1
- package/dataflow/internal/process/process-named-call.js +8 -5
- package/dataflow/origin/dfg-get-origin.d.ts +82 -0
- package/dataflow/origin/dfg-get-origin.js +116 -0
- package/documentation/doc-util/doc-cfg.d.ts +20 -4
- package/documentation/doc-util/doc-cfg.js +41 -7
- package/documentation/doc-util/doc-cli-option.js +4 -2
- package/documentation/doc-util/doc-code.js +10 -2
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-escape.d.ts +7 -0
- package/documentation/doc-util/doc-escape.js +19 -0
- package/documentation/doc-util/doc-files.d.ts +1 -0
- package/documentation/doc-util/doc-files.js +2 -1
- package/documentation/doc-util/doc-normalized-ast.js +3 -3
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -1
- package/documentation/doc-util/doc-search.js +1 -1
- package/documentation/doc-util/doc-server-message.js +2 -2
- package/documentation/doc-util/doc-structure.d.ts +1 -0
- package/documentation/doc-util/doc-structure.js +5 -0
- package/documentation/doc-util/doc-types.d.ts +7 -1
- package/documentation/doc-util/doc-types.js +13 -2
- package/documentation/print-capabilities-markdown.js +28 -2
- package/documentation/print-cfg-wiki.d.ts +1 -0
- package/documentation/print-cfg-wiki.js +572 -0
- package/documentation/print-core-wiki.js +2 -2
- package/documentation/print-dataflow-graph-wiki.js +180 -25
- package/documentation/print-engines-wiki.js +1 -1
- package/documentation/print-faq-wiki.d.ts +1 -0
- package/documentation/print-faq-wiki.js +75 -0
- package/documentation/print-interface-wiki.js +2 -1
- package/documentation/print-linting-and-testing-wiki.js +52 -36
- package/documentation/print-normalized-ast-wiki.js +1 -1
- package/documentation/print-onboarding-wiki.d.ts +1 -0
- package/documentation/print-onboarding-wiki.js +42 -0
- package/documentation/print-query-wiki.js +23 -3
- package/documentation/print-readme.js +10 -3
- package/package.json +10 -6
- package/queries/catalog/call-context-query/call-context-query-executor.js +5 -5
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.js +2 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.d.ts +2 -2
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +24 -21
- package/queries/catalog/cluster-query/cluster-query-format.d.ts +1 -1
- package/queries/catalog/cluster-query/cluster-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.js +2 -2
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -2
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +17 -7
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +2 -26
- package/queries/catalog/dependencies-query/dependencies-query-format.js +4 -147
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +24 -0
- package/queries/catalog/dependencies-query/function-info/function-info.js +10 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.js +18 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +101 -0
- package/queries/catalog/dependencies-query/function-info/source-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/source-functions.js +11 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +87 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +4 -4
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +1 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +1 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +2 -2
- package/queries/catalog/lineage-query/lineage-query-format.d.ts +1 -1
- package/queries/catalog/lineage-query/lineage-query-format.js +2 -2
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +2 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +1 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +5 -0
- package/queries/catalog/origin-query/origin-query-executor.js +33 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +71 -0
- package/queries/catalog/origin-query/origin-query-format.js +27 -0
- package/queries/catalog/project-query/project-query-format.d.ts +1 -1
- package/queries/catalog/project-query/project-query-format.js +2 -2
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +2 -2
- package/queries/catalog/search-query/search-query-format.d.ts +1 -1
- package/queries/catalog/search-query/search-query-format.js +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.js +2 -2
- package/queries/query-print.d.ts +1 -1
- package/queries/query-print.js +4 -4
- package/queries/query.d.ts +61 -2
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +2 -2
- package/r-bridge/data/data.js +2 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +5 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +5 -0
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -1
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +3 -1
- package/r-bridge/lang-4.x/ast/model/processing/stateful-fold.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/expression/normalize-expression.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-root.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +2 -2
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +4 -4
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +26 -8
- package/r-bridge/retriever.js +1 -1
- package/search/search-executor/search-generators.d.ts +1 -1
- package/search/search-executor/search-transformer.d.ts +1 -1
- package/slicing/criterion/collect-all.js +1 -1
- package/slicing/static/slice-call.js +13 -3
- package/statistics/features/supported/assignments/post-process.js +1 -1
- package/statistics/features/supported/defined-functions/post-process.js +2 -2
- package/statistics/features/supported/used-functions/post-process.js +1 -1
- package/statistics/features/supported/used-packages/post-process.js +2 -2
- package/statistics/features/supported/values/post-process.js +2 -2
- package/statistics/output/print-stats.js +2 -2
- package/statistics/summarizer/post-process/clusterer.d.ts +1 -1
- package/statistics/summarizer/post-process/clusterer.js +1 -1
- package/statistics/summarizer/post-process/histogram.js +3 -3
- package/statistics/summarizer/post-process/post-process-output.js +3 -3
- package/statistics/summarizer/second-phase/process.js +2 -2
- package/statistics/summarizer/summarizer.js +2 -2
- package/util/assert.js +36 -1
- package/util/cfg/cfg.d.ts +0 -80
- package/util/cfg/cfg.js +0 -549
- package/util/{arrays.d.ts → collections/arrays.d.ts} +24 -1
- package/util/{arrays.js → collections/arrays.js} +44 -3
- package/util/collections/set.js +17 -0
- package/util/{list-access.d.ts → containers.d.ts} +24 -4
- package/util/{list-access.js → containers.js} +42 -12
- package/util/diff-graph.d.ts +47 -0
- package/util/diff-graph.js +61 -0
- package/util/diff.d.ts +6 -6
- package/util/diff.js +1 -1
- package/util/mermaid/ast.js +12 -1
- package/util/mermaid/cfg.d.ts +9 -2
- package/util/mermaid/cfg.js +65 -13
- package/util/mermaid/dfg.d.ts +2 -1
- package/util/mermaid/dfg.js +26 -10
- package/util/mermaid/mermaid.d.ts +2 -0
- package/util/mermaid/mermaid.js +6 -0
- package/util/parallel.d.ts +2 -1
- package/util/parallel.js +11 -2
- package/util/prefix.d.ts +13 -0
- package/util/prefix.js +34 -0
- package/util/quads.js +1 -1
- package/util/schema.d.ts +1 -1
- package/util/schema.js +1 -1
- package/util/summarizer.js +1 -1
- package/util/{text.js → text/text.js} +1 -1
- package/util/{time.js → text/time.js} +1 -1
- package/util/version.js +1 -1
- package/dataflow/graph/diff.d.ts +0 -36
- package/util/cfg/happens-before.d.ts +0 -7
- package/util/cfg/visitor.d.ts +0 -9
- package/util/cfg/visitor.js +0 -30
- package/util/set.js +0 -31
- /package/util/{bimap.d.ts → collections/bimap.d.ts} +0 -0
- /package/util/{bimap.js → collections/bimap.js} +0 -0
- /package/util/{defaultmap.d.ts → collections/defaultmap.d.ts} +0 -0
- /package/util/{defaultmap.js → collections/defaultmap.js} +0 -0
- /package/util/{set.d.ts → collections/set.d.ts} +0 -0
- /package/util/{ansi.d.ts → text/ansi.d.ts} +0 -0
- /package/util/{ansi.js → text/ansi.js} +0 -0
- /package/util/{args.d.ts → text/args.d.ts} +0 -0
- /package/util/{args.js → text/args.js} +0 -0
- /package/util/{strings.d.ts → text/strings.d.ts} +0 -0
- /package/util/{strings.js → text/strings.js} +0 -0
- /package/util/{text.d.ts → text/text.d.ts} +0 -0
- /package/util/{time.d.ts → text/time.d.ts} +0 -0
package/dataflow/graph/graph.js
CHANGED
|
@@ -5,15 +5,14 @@ exports.isPositionalArgument = isPositionalArgument;
|
|
|
5
5
|
exports.isNamedArgument = isNamedArgument;
|
|
6
6
|
exports.getReferenceOfArgument = getReferenceOfArgument;
|
|
7
7
|
const assert_1 = require("../../util/assert");
|
|
8
|
-
const
|
|
8
|
+
const diff_dataflow_graph_1 = require("./diff-dataflow-graph");
|
|
9
9
|
const vertex_1 = require("./vertex");
|
|
10
|
-
const arrays_1 = require("../../util/arrays");
|
|
10
|
+
const arrays_1 = require("../../util/collections/arrays");
|
|
11
11
|
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
12
12
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
13
13
|
const environment_1 = require("../environments/environment");
|
|
14
14
|
const clone_1 = require("../environments/clone");
|
|
15
15
|
const json_1 = require("../../util/json");
|
|
16
|
-
const built_in_1 = require("../environments/built-in");
|
|
17
16
|
const logger_1 = require("../logger");
|
|
18
17
|
/**
|
|
19
18
|
* Check if the given argument is a {@link PositionalFunctionArgument}.
|
|
@@ -50,7 +49,7 @@ function getReferenceOfArgument(arg) {
|
|
|
50
49
|
* @see {@link DataflowGraph#addEdge|`addEdge`} - to add an edge to the graph
|
|
51
50
|
* @see {@link DataflowGraph#addVertex|`addVertex`} - to add a vertex to the graph
|
|
52
51
|
* @see {@link DataflowGraph#fromJson|`fromJson`} - to construct a dataflow graph object from a deserialized JSON object.
|
|
53
|
-
* @see {@link emptyGraph} - to create an empty graph (useful in tests)
|
|
52
|
+
* @see {@link emptyGraph|`emptyGraph`} - to create an empty graph (useful in tests)
|
|
54
53
|
*/
|
|
55
54
|
class DataflowGraph {
|
|
56
55
|
static DEFAULT_ENVIRONMENT = undefined;
|
|
@@ -111,6 +110,24 @@ class DataflowGraph {
|
|
|
111
110
|
}
|
|
112
111
|
return edges;
|
|
113
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Given a node in the normalized AST this either:
|
|
115
|
+
* * returns the id if the node directly exists in the DFG
|
|
116
|
+
* * returns the ids of all vertices in the DFG that are linked to this
|
|
117
|
+
* * returns undefined if the node is not part of the DFG and not linked to any node
|
|
118
|
+
*/
|
|
119
|
+
getLinked(nodeId) {
|
|
120
|
+
if (this.vertexInformation.has(nodeId)) {
|
|
121
|
+
return [nodeId];
|
|
122
|
+
}
|
|
123
|
+
const linked = [];
|
|
124
|
+
for (const [id, vtx] of this.vertexInformation) {
|
|
125
|
+
if (vtx.link?.origin.includes(nodeId)) {
|
|
126
|
+
linked.push(id);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return linked.length > 0 ? linked : undefined;
|
|
130
|
+
}
|
|
114
131
|
/** Retrieves the id-map to the normalized AST attached to the dataflow graph */
|
|
115
132
|
get idMap() {
|
|
116
133
|
return this._idMap;
|
|
@@ -180,13 +197,14 @@ class DataflowGraph {
|
|
|
180
197
|
* @param vertex - The vertex to add
|
|
181
198
|
* @param asRoot - If false, this will only add the vertex but do not add it to the {@link rootIds|root vertices} of the graph.
|
|
182
199
|
* This is probably only of use, when you construct dataflow graphs for tests.
|
|
200
|
+
* @param overwrite - If true, this will overwrite the vertex if it already exists in the graph (based on the id).
|
|
183
201
|
*
|
|
184
202
|
* @see DataflowGraphVertexInfo
|
|
185
203
|
* @see DataflowGraphVertexArgument
|
|
186
204
|
*/
|
|
187
|
-
addVertex(vertex, asRoot = true) {
|
|
205
|
+
addVertex(vertex, asRoot = true, overwrite = false) {
|
|
188
206
|
const oldVertex = this.vertexInformation.get(vertex.id);
|
|
189
|
-
if (oldVertex !== undefined) {
|
|
207
|
+
if (oldVertex !== undefined && !overwrite) {
|
|
190
208
|
return this;
|
|
191
209
|
}
|
|
192
210
|
const fallback = vertex.tag === vertex_1.VertexType.VariableDefinition || vertex.tag === vertex_1.VertexType.Use || vertex.tag === vertex_1.VertexType.Value || (vertex.tag === vertex_1.VertexType.FunctionCall && vertex.onlyBuiltin) ? undefined : DataflowGraph.DEFAULT_ENVIRONMENT;
|
|
@@ -201,12 +219,9 @@ class DataflowGraph {
|
|
|
201
219
|
}
|
|
202
220
|
return this;
|
|
203
221
|
}
|
|
204
|
-
/**
|
|
205
|
-
* Please note that this will never make edges to {@link BuiltIn} as they are not part of the graph.
|
|
206
|
-
*/
|
|
207
222
|
addEdge(from, to, type) {
|
|
208
223
|
const [fromId, toId] = extractEdgeIds(from, to);
|
|
209
|
-
if (fromId === toId
|
|
224
|
+
if (fromId === toId) {
|
|
210
225
|
return this;
|
|
211
226
|
}
|
|
212
227
|
/* we now that we pass all required arguments */
|
|
@@ -244,7 +259,7 @@ class DataflowGraph {
|
|
|
244
259
|
this.rootVertices.add(root);
|
|
245
260
|
}
|
|
246
261
|
}
|
|
247
|
-
this.
|
|
262
|
+
this._sourced = this._sourced.concat(otherGraph.sourced);
|
|
248
263
|
for (const unknown of otherGraph.unknownSideEffects) {
|
|
249
264
|
this._unknownSideEffects.add(unknown);
|
|
250
265
|
}
|
|
@@ -335,6 +350,11 @@ class DataflowGraph {
|
|
|
335
350
|
const graph = new DataflowGraph(undefined);
|
|
336
351
|
graph.rootVertices = new Set(data.rootVertices);
|
|
337
352
|
graph.vertexInformation = new Map(data.vertexInformation);
|
|
353
|
+
for (const [, vertex] of graph.vertexInformation) {
|
|
354
|
+
if (vertex.environment) {
|
|
355
|
+
vertex.environment = renvFromJson(vertex.environment);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
338
358
|
graph.edgeInformation = new Map(data.edgeInformation.map(([id, edges]) => [id, new Map(edges)]));
|
|
339
359
|
if (data.sourced) {
|
|
340
360
|
graph._sourced = data.sourced;
|
|
@@ -352,7 +372,7 @@ function mergeNodeInfos(current, next) {
|
|
|
352
372
|
(0, assert_1.guard)(current.scope === next.scope, 'nodes to be joined for the same id must have the same scope');
|
|
353
373
|
}
|
|
354
374
|
else if (current.tag === vertex_1.VertexType.FunctionCall) {
|
|
355
|
-
(0, assert_1.guard)((0,
|
|
375
|
+
(0, assert_1.guard)((0, diff_dataflow_graph_1.equalFunctionArguments)(current.id, current.args, next.args), 'nodes to be joined for the same id must have the same function call information');
|
|
356
376
|
}
|
|
357
377
|
else if (current.tag === vertex_1.VertexType.FunctionDefinition) {
|
|
358
378
|
(0, assert_1.guard)(current.scope === next.scope, 'nodes to be joined for the same id must have the same scope');
|
|
@@ -368,4 +388,23 @@ function extractEdgeIds(from, to) {
|
|
|
368
388
|
const toId = typeof to === 'object' ? to.nodeId : to;
|
|
369
389
|
return [fromId, toId];
|
|
370
390
|
}
|
|
391
|
+
function envFromJson(json) {
|
|
392
|
+
const parent = json.parent ? envFromJson(json.parent) : undefined;
|
|
393
|
+
const memory = new Map();
|
|
394
|
+
for (const [key, value] of Object.entries(json.memory)) {
|
|
395
|
+
memory.set(key, value);
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
id: json.id,
|
|
399
|
+
parent: parent,
|
|
400
|
+
memory
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
function renvFromJson(json) {
|
|
404
|
+
const current = envFromJson(json.current);
|
|
405
|
+
return {
|
|
406
|
+
current,
|
|
407
|
+
level: json.level
|
|
408
|
+
};
|
|
409
|
+
}
|
|
371
410
|
//# sourceMappingURL=graph.js.map
|
|
@@ -3,6 +3,7 @@ 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 } from '../info';
|
|
6
|
+
import type { BuiltInMappingName } from '../environments/built-in';
|
|
6
7
|
export declare enum VertexType {
|
|
7
8
|
Value = "value",
|
|
8
9
|
Use = "use",
|
|
@@ -14,6 +15,36 @@ export declare const ValidVertexTypes: Set<string>;
|
|
|
14
15
|
export declare const ValidVertexTypeReverse: {
|
|
15
16
|
[k: string]: string;
|
|
16
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* Identifier for arguments e.g. for `3` in `c(2, 3, 5)` the identifier would be
|
|
20
|
+
* ```ts
|
|
21
|
+
* {
|
|
22
|
+
* index: 2
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export interface UnnamedArgumentId {
|
|
27
|
+
readonly index: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Identifier for named arguments e.g. for `age` in `list(name = 'John', age = 8)`
|
|
31
|
+
* the indentifier would be
|
|
32
|
+
* ```ts
|
|
33
|
+
* {
|
|
34
|
+
* index: 2,
|
|
35
|
+
* lexeme: 'age'
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export interface NamedArgumentId {
|
|
40
|
+
/**
|
|
41
|
+
* Index may be undefined, when no index information is available.
|
|
42
|
+
*/
|
|
43
|
+
readonly index: number | undefined;
|
|
44
|
+
readonly lexeme: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function isNamedArgumentId(identifier: IndexIdentifier): identifier is NamedArgumentId;
|
|
47
|
+
export type IndexIdentifier = UnnamedArgumentId | NamedArgumentId;
|
|
17
48
|
/**
|
|
18
49
|
* A single index of a container, which is not a container itself.
|
|
19
50
|
*
|
|
@@ -21,9 +52,9 @@ export declare const ValidVertexTypeReverse: {
|
|
|
21
52
|
*/
|
|
22
53
|
export interface ContainerLeafIndex {
|
|
23
54
|
/**
|
|
24
|
-
* Distinctive
|
|
55
|
+
* Distinctive identifier of index, see {@link IndexIdentifier}.
|
|
25
56
|
*/
|
|
26
|
-
readonly
|
|
57
|
+
readonly identifier: IndexIdentifier;
|
|
27
58
|
/**
|
|
28
59
|
* NodeId of index in graph.
|
|
29
60
|
*/
|
|
@@ -48,6 +79,16 @@ export declare function isParentContainerIndex(index: ContainerIndex): index is
|
|
|
48
79
|
* A single index of a container.
|
|
49
80
|
*/
|
|
50
81
|
export type ContainerIndex = ContainerLeafIndex | ContainerParentIndex;
|
|
82
|
+
/**
|
|
83
|
+
* Checks whether {@link index} is accessed by {@link accessLexeme}.
|
|
84
|
+
*
|
|
85
|
+
* @param index - The {@link ContainerIndex}, which is accessed
|
|
86
|
+
* @param accessLexeme - The access lexeme
|
|
87
|
+
* @param isIndexBasedAccess - Whether the index of the {@link ContainerIndex} is accessed i.e. the position in the container and not e.g. the name of the index
|
|
88
|
+
* @returns true, when {@link accessLexeme} accesses the {@link index}, false otherwise
|
|
89
|
+
*/
|
|
90
|
+
export declare function isAccessed(index: ContainerIndex, accessLexeme: string, isIndexBasedAccess: boolean): boolean;
|
|
91
|
+
export declare function isSameIndex(a: ContainerIndex, b: ContainerIndex): boolean;
|
|
51
92
|
/**
|
|
52
93
|
* List of indices of a single statement like `list(a=3, b=2)`
|
|
53
94
|
*/
|
|
@@ -95,6 +136,14 @@ interface DataflowGraphVertexBase extends MergeableRecord {
|
|
|
95
136
|
* this attribute links a vertex to indices (pointer links) it may be affected by or related to
|
|
96
137
|
*/
|
|
97
138
|
indicesCollection?: ContainerIndicesCollection;
|
|
139
|
+
/**
|
|
140
|
+
* Describes the collection of AST vertices that contributed to this vertex.
|
|
141
|
+
* For example, this is useful with replacement operators, telling you which assignment operator caused them
|
|
142
|
+
*/
|
|
143
|
+
link?: DataflowGraphVertexAstLink;
|
|
144
|
+
}
|
|
145
|
+
export interface DataflowGraphVertexAstLink {
|
|
146
|
+
origin: NodeId[];
|
|
98
147
|
}
|
|
99
148
|
/**
|
|
100
149
|
* Marker vertex for a value in the dataflow of the program.
|
|
@@ -133,7 +182,9 @@ export interface DataflowGraphVertexUse extends DataflowGraphVertexBase {
|
|
|
133
182
|
readonly environment?: undefined;
|
|
134
183
|
}
|
|
135
184
|
/**
|
|
136
|
-
* Arguments required to construct a vertex which represents the
|
|
185
|
+
* Arguments required to construct a vertex which represents the call to a function in the {@link DataflowGraph|dataflow graph}.
|
|
186
|
+
* This describes all kinds of function calls, including calls to built-ins and control-flow structures such as `if` or `for` (they are
|
|
187
|
+
* treated as function calls in R).
|
|
137
188
|
*
|
|
138
189
|
* @see {@link isFunctionCallVertex} - to check if a vertex is a function call vertex
|
|
139
190
|
*/
|
|
@@ -146,13 +197,17 @@ export interface DataflowGraphVertexFunctionCall extends DataflowGraphVertexBase
|
|
|
146
197
|
* have the compound name (e.g., `[<-`).
|
|
147
198
|
*/
|
|
148
199
|
readonly name: string;
|
|
149
|
-
/** The arguments of the function call, in order (as they are passed to the respective call if executed in R. */
|
|
200
|
+
/** The arguments of the function call, in order (as they are passed to the respective call if executed in R). */
|
|
150
201
|
args: FunctionArgument[];
|
|
151
202
|
/** a performance flag to indicate that the respective call is _only_ calling a builtin function without any df graph attached */
|
|
152
203
|
onlyBuiltin: boolean;
|
|
153
204
|
/** The environment attached to the call (if such an attachment is necessary, e.g., because it represents the calling closure */
|
|
154
205
|
environment: REnvironmentInformation | undefined;
|
|
206
|
+
/** More detailed Information on this function call */
|
|
207
|
+
origin: FunctionOriginInformation[] | 'unnamed';
|
|
155
208
|
}
|
|
209
|
+
/** Describes the processor responsible for a function call */
|
|
210
|
+
export type FunctionOriginInformation = BuiltInMappingName | string;
|
|
156
211
|
/**
|
|
157
212
|
* Arguments required to construct a vertex which represents the definition of a variable in the {@link DataflowGraph|dataflow graph}.
|
|
158
213
|
*
|
package/dataflow/graph/vertex.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ValidVertexTypeReverse = exports.ValidVertexTypes = exports.VertexType = void 0;
|
|
4
|
+
exports.isNamedArgumentId = isNamedArgumentId;
|
|
4
5
|
exports.isParentContainerIndex = isParentContainerIndex;
|
|
6
|
+
exports.isAccessed = isAccessed;
|
|
7
|
+
exports.isSameIndex = isSameIndex;
|
|
5
8
|
exports.isValueVertex = isValueVertex;
|
|
6
9
|
exports.isUseVertex = isUseVertex;
|
|
7
10
|
exports.isFunctionCallVertex = isFunctionCallVertex;
|
|
@@ -17,9 +20,38 @@ var VertexType;
|
|
|
17
20
|
})(VertexType || (exports.VertexType = VertexType = {}));
|
|
18
21
|
exports.ValidVertexTypes = new Set(Object.values(VertexType));
|
|
19
22
|
exports.ValidVertexTypeReverse = Object.fromEntries(Object.entries(VertexType).map(([k, v]) => [v, k]));
|
|
23
|
+
function isNamedArgumentId(identifier) {
|
|
24
|
+
return 'lexeme' in identifier;
|
|
25
|
+
}
|
|
20
26
|
function isParentContainerIndex(index) {
|
|
21
27
|
return 'subIndices' in index;
|
|
22
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks whether {@link index} is accessed by {@link accessLexeme}.
|
|
31
|
+
*
|
|
32
|
+
* @param index - The {@link ContainerIndex}, which is accessed
|
|
33
|
+
* @param accessLexeme - The access lexeme
|
|
34
|
+
* @param isIndexBasedAccess - Whether the index of the {@link ContainerIndex} is accessed i.e. the position in the container and not e.g. the name of the index
|
|
35
|
+
* @returns true, when {@link accessLexeme} accesses the {@link index}, false otherwise
|
|
36
|
+
*/
|
|
37
|
+
function isAccessed(index, accessLexeme, isIndexBasedAccess) {
|
|
38
|
+
if (isIndexBasedAccess) {
|
|
39
|
+
return index.identifier.index === Number(accessLexeme);
|
|
40
|
+
}
|
|
41
|
+
if (isNamedArgumentId(index.identifier)) {
|
|
42
|
+
return index.identifier.lexeme === accessLexeme;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
function isSameIndex(a, b) {
|
|
47
|
+
if (isNamedArgumentId(a.identifier) && isNamedArgumentId(b.identifier)) {
|
|
48
|
+
return a.identifier.lexeme === b.identifier.lexeme;
|
|
49
|
+
}
|
|
50
|
+
if (a.identifier.index === undefined || b.identifier.index === undefined) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return a.identifier.index === b.identifier.index;
|
|
54
|
+
}
|
|
23
55
|
/**
|
|
24
56
|
* Check if the given vertex is a {@link DataflowGraphVertexValue|value vertex}.
|
|
25
57
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { DefaultMap } from '../../util/defaultmap';
|
|
1
|
+
import { DefaultMap } from '../../util/collections/defaultmap';
|
|
2
2
|
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
3
3
|
import type { IdentifierReference } from '../environments/identifier';
|
|
4
4
|
import type { DataflowGraph, FunctionArgument } from '../graph/graph';
|
|
5
5
|
import type { RParameter } from '../../r-bridge/lang-4.x/ast/model/nodes/r-parameter';
|
|
6
6
|
import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
7
7
|
import type { DataflowGraphVertexFunctionCall, DataflowGraphVertexFunctionDefinition, DataflowGraphVertexInfo } from '../graph/vertex';
|
|
8
|
+
import type { BuiltIn } from '../environments/built-in';
|
|
8
9
|
import type { REnvironmentInformation } from '../environments/environment';
|
|
9
10
|
export type NameIdMap = DefaultMap<string, IdentifierReference[]>;
|
|
10
11
|
export declare function findNonLocalReads(graph: DataflowGraph, ignore: readonly IdentifierReference[]): IdentifierReference[];
|
|
@@ -27,7 +28,7 @@ export declare function linkFunctionCalls(graph: DataflowGraph, idMap: AstIdMap,
|
|
|
27
28
|
* convenience function returning all known call targets, as well as the name source which defines them
|
|
28
29
|
*/
|
|
29
30
|
export declare function getAllFunctionCallTargets(call: NodeId, graph: DataflowGraph, environment?: REnvironmentInformation): NodeId[];
|
|
30
|
-
export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadIds: ReadonlySet<NodeId>, dataflowGraph: DataflowGraph): Set<DataflowGraphVertexInfo
|
|
31
|
+
export declare function getAllLinkedFunctionDefinitions(functionDefinitionReadIds: ReadonlySet<NodeId>, dataflowGraph: DataflowGraph): [Set<DataflowGraphVertexInfo>, Set<BuiltIn>];
|
|
31
32
|
/**
|
|
32
33
|
* This method links a set of read variables to definitions in an environment.
|
|
33
34
|
*
|
|
@@ -9,7 +9,7 @@ exports.getAllFunctionCallTargets = getAllFunctionCallTargets;
|
|
|
9
9
|
exports.getAllLinkedFunctionDefinitions = getAllLinkedFunctionDefinitions;
|
|
10
10
|
exports.linkInputs = linkInputs;
|
|
11
11
|
exports.linkCircularRedefinitionsWithinALoop = linkCircularRedefinitionsWithinALoop;
|
|
12
|
-
const defaultmap_1 = require("../../util/defaultmap");
|
|
12
|
+
const defaultmap_1 = require("../../util/collections/defaultmap");
|
|
13
13
|
const assert_1 = require("../../util/assert");
|
|
14
14
|
const log_1 = require("../../util/log");
|
|
15
15
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
@@ -22,7 +22,7 @@ const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
|
22
22
|
const vertex_1 = require("../graph/vertex");
|
|
23
23
|
const resolve_by_name_1 = require("../environments/resolve-by-name");
|
|
24
24
|
const built_in_1 = require("../environments/built-in");
|
|
25
|
-
const
|
|
25
|
+
const prefix_1 = require("../../util/prefix");
|
|
26
26
|
function findNonLocalReads(graph, ignore) {
|
|
27
27
|
const ignores = new Set(ignore.map(i => i.nodeId));
|
|
28
28
|
const ids = new Set([...graph.vertices(true)]
|
|
@@ -74,26 +74,27 @@ function produceNameSharedIdMap(references) {
|
|
|
74
74
|
}
|
|
75
75
|
function linkArgumentsOnCall(args, params, graph) {
|
|
76
76
|
const nameArgMap = new Map(args.filter(graph_1.isNamedArgument).map(a => [a.name, a]));
|
|
77
|
-
const nameParamMap = new Map(params.map(p => [p.name.content, p]));
|
|
77
|
+
const nameParamMap = new Map(params.filter(p => p !== undefined && p.name !== undefined && p.name.content !== undefined).map(p => [p.name.content, p]));
|
|
78
78
|
const specialDotParameter = params.find(p => p.special);
|
|
79
79
|
// all parameters matched by name
|
|
80
80
|
const matchedParameters = new Set();
|
|
81
81
|
// first map names
|
|
82
82
|
for (const [name, arg] of nameArgMap) {
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const pmatchName = (0, prefix_1.findByPrefixIfUnique)(name, [...nameParamMap.keys()]) ?? name;
|
|
84
|
+
const param = nameParamMap.get(pmatchName);
|
|
85
|
+
if (param !== undefined && param.name) {
|
|
85
86
|
logger_1.dataflowLogger.trace(`mapping named argument "${name}" to parameter "${param.name.content}"`);
|
|
86
87
|
graph.addEdge(arg.nodeId, param.name.info.id, edge_1.EdgeType.DefinesOnCall);
|
|
87
88
|
graph.addEdge(param.name.info.id, arg.nodeId, edge_1.EdgeType.DefinedByOnCall);
|
|
88
89
|
matchedParameters.add(name);
|
|
89
90
|
}
|
|
90
|
-
else if (specialDotParameter !== undefined) {
|
|
91
|
+
else if (specialDotParameter !== undefined && specialDotParameter.name) {
|
|
91
92
|
logger_1.dataflowLogger.trace(`mapping named argument "${name}" to dot-dot-dot parameter`);
|
|
92
93
|
graph.addEdge(arg.nodeId, specialDotParameter.name.info.id, edge_1.EdgeType.DefinesOnCall);
|
|
93
94
|
graph.addEdge(specialDotParameter.name.info.id, arg.nodeId, edge_1.EdgeType.DefinedByOnCall);
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
|
-
const remainingParameter = params.filter(p => !matchedParameters.has(p.name.content));
|
|
97
|
+
const remainingParameter = params.filter(p => !p || !p.name || !matchedParameters.has(p.name.content));
|
|
97
98
|
const remainingArguments = args.filter(a => !(0, graph_1.isNamedArgument)(a));
|
|
98
99
|
for (let i = 0; i < remainingArguments.length; i++) {
|
|
99
100
|
const arg = remainingArguments[i];
|
|
@@ -113,9 +114,11 @@ function linkArgumentsOnCall(args, params, graph) {
|
|
|
113
114
|
continue;
|
|
114
115
|
}
|
|
115
116
|
const param = remainingParameter[i];
|
|
116
|
-
logger_1.dataflowLogger.trace(`mapping unnamed argument ${i} (id: ${arg.nodeId}) to parameter "${param.name
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
logger_1.dataflowLogger.trace(`mapping unnamed argument ${i} (id: ${arg.nodeId}) to parameter "${param.name?.content ?? '??'}"`);
|
|
118
|
+
if (param.name) {
|
|
119
|
+
graph.addEdge(arg.nodeId, param.name.info.id, edge_1.EdgeType.DefinesOnCall);
|
|
120
|
+
graph.addEdge(param.name.info.id, arg.nodeId, edge_1.EdgeType.DefinedByOnCall);
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
123
|
}
|
|
121
124
|
function linkFunctionCallArguments(targetId, idMap, functionCallName, functionRootId, callArgs, finalGraph) {
|
|
@@ -142,8 +145,10 @@ function linkFunctionCallWithSingleTarget(graph, def, info, idMap) {
|
|
|
142
145
|
continue;
|
|
143
146
|
}
|
|
144
147
|
for (const def of defs) {
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
if (!(0, built_in_1.isBuiltIn)(def.nodeId)) {
|
|
149
|
+
graph.addEdge(ingoing, def, edge_1.EdgeType.DefinedByOnCall);
|
|
150
|
+
graph.addEdge(id, def, edge_1.EdgeType.DefinesOnCall);
|
|
151
|
+
}
|
|
147
152
|
}
|
|
148
153
|
}
|
|
149
154
|
}
|
|
@@ -166,7 +171,7 @@ function linkFunctionCall(graph, id, info, idMap, thisGraph, calledFunctionDefin
|
|
|
166
171
|
const readBits = edge_1.EdgeType.Reads | edge_1.EdgeType.Calls;
|
|
167
172
|
const functionDefinitionReadIds = [...edges].filter(([_, e]) => (0, edge_1.edgeDoesNotIncludeType)(e.types, edge_1.EdgeType.Argument)
|
|
168
173
|
&& (0, edge_1.edgeIncludesType)(e.types, readBits)).map(([target, _]) => target);
|
|
169
|
-
const functionDefs = getAllLinkedFunctionDefinitions(new Set(functionDefinitionReadIds), graph);
|
|
174
|
+
const functionDefs = getAllLinkedFunctionDefinitions(new Set(functionDefinitionReadIds), graph)[0];
|
|
170
175
|
for (const def of functionDefs.values()) {
|
|
171
176
|
(0, assert_1.guard)(def.tag === vertex_1.VertexType.FunctionDefinition, () => `expected function definition, but got ${def.tag}`);
|
|
172
177
|
linkFunctionCallWithSingleTarget(graph, def, info, idMap);
|
|
@@ -196,7 +201,7 @@ function linkFunctionCalls(graph, idMap, thisGraph) {
|
|
|
196
201
|
* convenience function returning all known call targets, as well as the name source which defines them
|
|
197
202
|
*/
|
|
198
203
|
function getAllFunctionCallTargets(call, graph, environment) {
|
|
199
|
-
|
|
204
|
+
let found = [];
|
|
200
205
|
const callVertex = graph.get(call, true);
|
|
201
206
|
if (callVertex === undefined) {
|
|
202
207
|
return [];
|
|
@@ -212,29 +217,28 @@ function getAllFunctionCallTargets(call, graph, environment) {
|
|
|
212
217
|
functionCallDefs.push(target);
|
|
213
218
|
}
|
|
214
219
|
}
|
|
215
|
-
const functionCallTargets = getAllLinkedFunctionDefinitions(new Set(functionCallDefs), graph);
|
|
220
|
+
const [functionCallTargets, builtInTargets] = getAllLinkedFunctionDefinitions(new Set(functionCallDefs), graph);
|
|
216
221
|
for (const target of functionCallTargets) {
|
|
217
222
|
found.push(target.id);
|
|
218
223
|
}
|
|
219
|
-
|
|
220
|
-
found.push(def);
|
|
221
|
-
}
|
|
224
|
+
found = found.concat(...builtInTargets, functionCallDefs);
|
|
222
225
|
}
|
|
223
226
|
return found;
|
|
224
227
|
}
|
|
225
228
|
function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGraph) {
|
|
226
|
-
|
|
229
|
+
let potential = [...functionDefinitionReadIds];
|
|
227
230
|
const visited = new Set();
|
|
228
231
|
const result = new Set();
|
|
232
|
+
const builtIns = new Set();
|
|
229
233
|
while (potential.length > 0) {
|
|
230
234
|
const currentId = potential.pop();
|
|
231
|
-
// do not traverse builtins
|
|
232
|
-
if (
|
|
235
|
+
// do not traverse builtins further
|
|
236
|
+
if ((0, built_in_1.isBuiltIn)(currentId)) {
|
|
237
|
+
builtIns.add(currentId);
|
|
233
238
|
continue;
|
|
234
239
|
}
|
|
235
240
|
const currentInfo = dataflowGraph.get(currentId, true);
|
|
236
241
|
if (currentInfo === undefined) {
|
|
237
|
-
static_slicer_1.slicerLogger.trace('skipping unknown link');
|
|
238
242
|
continue;
|
|
239
243
|
}
|
|
240
244
|
visited.add(currentId);
|
|
@@ -242,7 +246,7 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
242
246
|
const returnEdges = outgoingEdges.filter(([_, e]) => (0, edge_1.edgeIncludesType)(e.types, edge_1.EdgeType.Returns));
|
|
243
247
|
if (returnEdges.length > 0) {
|
|
244
248
|
// only traverse return edges and do not follow `calls` etc. as this indicates that we have a function call which returns a result, and not the function calls itself
|
|
245
|
-
potential.
|
|
249
|
+
potential = potential.concat(...returnEdges.map(([target]) => target).filter(id => !visited.has(id)));
|
|
246
250
|
continue;
|
|
247
251
|
}
|
|
248
252
|
const followBits = edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedBy | edge_1.EdgeType.DefinedByOnCall;
|
|
@@ -251,9 +255,9 @@ function getAllLinkedFunctionDefinitions(functionDefinitionReadIds, dataflowGrap
|
|
|
251
255
|
result.add(currentInfo[0]);
|
|
252
256
|
}
|
|
253
257
|
// trace all joined reads
|
|
254
|
-
potential.
|
|
258
|
+
potential = potential.concat(followEdges.map(([target]) => target).filter(id => !visited.has(id)));
|
|
255
259
|
}
|
|
256
|
-
return result;
|
|
260
|
+
return [result, builtIns];
|
|
257
261
|
}
|
|
258
262
|
/**
|
|
259
263
|
* This method links a set of read variables to definitions in an environment.
|
|
@@ -277,9 +281,16 @@ function linkInputs(referencesToLinkAgainstEnvironment, environmentInformation,
|
|
|
277
281
|
givenInputs.push(bodyInput);
|
|
278
282
|
}
|
|
279
283
|
else {
|
|
284
|
+
let allBuiltIn = true;
|
|
280
285
|
for (const target of probableTarget) {
|
|
281
286
|
// we can stick with maybe even if readId.attribute is always
|
|
282
287
|
graph.addEdge(bodyInput, target, edge_1.EdgeType.Reads);
|
|
288
|
+
if (!(0, identifier_1.isReferenceType)(target.type, identifier_1.ReferenceType.BuiltInConstant | identifier_1.ReferenceType.BuiltInFunction)) {
|
|
289
|
+
allBuiltIn = false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (allBuiltIn) {
|
|
293
|
+
givenInputs.push(bodyInput);
|
|
283
294
|
}
|
|
284
295
|
}
|
|
285
296
|
}
|
|
@@ -3,4 +3,4 @@ import type { RNode } from '../../../../../../r-bridge/lang-4.x/ast/model/model'
|
|
|
3
3
|
/**
|
|
4
4
|
* Retrieve the value from an argument, if it is not empty.
|
|
5
5
|
*/
|
|
6
|
-
export declare function unpackArgument<OtherInfo>(arg: RFunctionArgument<OtherInfo
|
|
6
|
+
export declare function unpackArgument<OtherInfo>(arg: RFunctionArgument<OtherInfo> | undefined, noNameOnly?: boolean): RNode<OtherInfo> | undefined;
|
|
@@ -6,6 +6,6 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
6
6
|
* Retrieve the value from an argument, if it is not empty.
|
|
7
7
|
*/
|
|
8
8
|
function unpackArgument(arg, noNameOnly = true) {
|
|
9
|
-
return arg === r_function_call_1.EmptyArgument || (noNameOnly && arg.name) ? undefined : arg.value;
|
|
9
|
+
return arg === undefined || arg === r_function_call_1.EmptyArgument || (noNameOnly && arg.name) ? undefined : arg.value;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=unpack-argument.js.map
|
|
@@ -19,3 +19,4 @@ import type { ForceArguments } from '../common';
|
|
|
19
19
|
export declare function processAccess<OtherInfo>(name: RSymbol<OtherInfo & ParentInformation>, args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], rootId: NodeId, data: DataflowProcessorInformation<OtherInfo & ParentInformation>, config: {
|
|
20
20
|
treatIndicesAsString: boolean;
|
|
21
21
|
} & ForceArguments): DataflowInformation;
|
|
22
|
+
export declare function symbolArgumentsToStrings<OtherInfo>(args: readonly RFunctionArgument<OtherInfo & ParentInformation>[], firstIndexInclusive?: number, lastIndexInclusive?: number): RFunctionArgument<OtherInfo & ParentInformation>[];
|